- 零零碎碎的

- 退货申请,物流信息
This commit is contained in:
sin 2019-04-27 16:31:49 +08:00
parent 6e92e7162c
commit 6e91c41cca
17 changed files with 220 additions and 81 deletions

View File

@ -6,6 +6,7 @@ import cn.iocoder.mall.admin.api.DataDictService;
import cn.iocoder.mall.admin.api.bo.DataDictBO;
import cn.iocoder.mall.order.api.OrderLogisticsService;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoWithOrderBO;
import cn.iocoder.mall.order.api.constant.DictKeyConstants;
import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
@ -39,14 +40,20 @@ public class OrderLogisticsController {
@Reference(validation = "true")
private DataDictService dataDictService;
@GetMapping("logistics_info")
@ApiOperation("物流详细 - 返回订单所关联的所有物流信息")
public CommonResult<OrderLogisticsInfoBO> logisticsInfo(@RequestParam("orderId") Integer orderId) {
@GetMapping("info")
@ApiOperation("物流详细 - 物流通用")
public CommonResult<OrderLogisticsInfoBO> logistics(@RequestParam("logisticsId") Integer logisticsId) {
return orderLogisticsService.getLogisticsInfo(logisticsId);
}
@GetMapping("info_order")
@ApiOperation("物流详细 - 返回订单所关联的所有物流信息(订单用的)")
public CommonResult<OrderLogisticsInfoWithOrderBO> logisticsInfoWithOrder(@RequestParam("orderId") Integer orderId) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
CommonResult<OrderLogisticsInfoBO> commonResult = orderLogisticsService.logisticsInfo(userId, orderId);
CommonResult<OrderLogisticsInfoWithOrderBO> commonResult = orderLogisticsService.getOrderLogisticsInfo(userId, orderId);
if (commonResult.isSuccess()) {
OrderLogisticsInfoBO orderLogisticsInfoBO = commonResult.getData();
List<OrderLogisticsInfoBO.Logistics> logisticsList = orderLogisticsInfoBO.getLogistics();
OrderLogisticsInfoWithOrderBO orderLogisticsInfoBO = commonResult.getData();
List<OrderLogisticsInfoWithOrderBO.Logistics> logisticsList = orderLogisticsInfoBO.getLogistics();
// 获取字典值
Set<Integer> dictValues = logisticsList.stream().map(o -> o.getLogistics()).collect(Collectors.toSet());
@ -72,7 +79,6 @@ public class OrderLogisticsController {
}).collect(Collectors.toList());
}
}
return commonResult;
}
}

View File

@ -1,10 +1,9 @@
package cn.iocoder.mall.order.api;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.bo.OrderLogisticsBO;
import cn.iocoder.mall.order.api.bo.OrderLastLogisticsInfoBO;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO;
import java.util.List;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoWithOrderBO;
/**
* 订单物流信息
@ -14,13 +13,31 @@ import java.util.List;
*/
public interface OrderLogisticsService {
/**
* 物流信息
* 获取物流信息 - 根据id
*
* @param id
* @return
*/
CommonResult<OrderLogisticsInfoBO> getLogisticsInfo(Integer id);
/**
* 获取 last 物流信息 - 根据id
*
* @param id
* @return
*/
CommonResult<OrderLastLogisticsInfoBO> getLastLogisticsInfo(Integer id);
/**
* 获取物流信息 - 根据 orderId
*
* @param userId
* @param orderId
* @return
*/
CommonResult<OrderLogisticsInfoBO> logisticsInfo(Integer userId, Integer orderId);
CommonResult<OrderLogisticsInfoWithOrderBO> getOrderLogisticsInfo(Integer userId, Integer orderId);
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.mall.order.api;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.bo.OrderReturnInfoBO;
import cn.iocoder.mall.order.api.dto.OrderReturnApplyDTO;
/**
@ -38,5 +39,5 @@ public interface OrderReturnService {
* @param orderId
* @return
*/
CommonResult orderApplyInfo(Integer orderId);
CommonResult<OrderReturnInfoBO> orderApplyInfo(Integer orderId);
}

View File

@ -17,23 +17,6 @@ import java.util.List;
@Accessors(chain = true)
public class OrderLogisticsInfoBO implements Serializable {
/**
* 订单id
*/
private Integer orderId;
/**
* 订单编号
*/
private String orderNo;
/**
* 物流信息
*/
private List<Logistics> logistics;
@Data
@Accessors(chain = true)
public static class Logistics {
/**
* id
*/
@ -71,7 +54,6 @@ public class OrderLogisticsInfoBO implements Serializable {
/// 物流信息
private List<LogisticsDetail> details;
}
@Data
@Accessors(chain = true)

View File

@ -25,6 +25,10 @@ public class OrderReturnInfoBO implements Serializable {
* 订单 item
*/
private List<OrderItem> orderItems;
/**
* 最后一个物流信息/最新物流信息
*/
private OrderLastLogisticsInfoBO lastLogisticsInfo;
@Data
@Accessors(chain = true)
@ -80,6 +84,10 @@ public class OrderReturnInfoBO implements Serializable {
///
/// 退货原因
/**
* 退货金额
*/
private Integer refundPrice;
/**
* 退货原因(字典值)
*/

View File

@ -42,6 +42,7 @@ public enum OrderErrorCodeEnum {
// 工具类服务 1008004000
DICT_SERVER_INVOKING_FAIL(1008004000, "字典服务调用失败!"),
ORDER_LOGISTICS_INVOKING_FAIL(1008004001, "订单物流调用失败!"),
;

View File

@ -1,14 +1,16 @@
package cn.iocoder.mall.order.biz.convert;
import cn.iocoder.mall.order.api.bo.OrderLogisticsBO;
import cn.iocoder.mall.order.api.bo.OrderLastLogisticsInfoBO;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO;
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoWithOrderBO;
import cn.iocoder.mall.order.api.dto.OrderDeliveryDTO;
import cn.iocoder.mall.order.api.dto.OrderLogisticsUpdateDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDO;
import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO;
import cn.iocoder.mall.order.biz.dataobject.OrderRecipientDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;
import java.util.List;
@ -34,5 +36,21 @@ public interface OrderLogisticsConvert {
OrderLogisticsDO convert(OrderRecipientDO orderRecipientDO);
@Mappings({})
List<OrderLogisticsInfoBO.Logistics> convertLogistics(List<OrderLogisticsDO> orderLogisticsDOList);
List<OrderLogisticsInfoWithOrderBO.Logistics> convertLogistics(List<OrderLogisticsDO> orderLogisticsDOList);
@Mappings({})
List<OrderLogisticsInfoWithOrderBO.LogisticsDetail> convertLogisticsDetail(List<OrderLogisticsDetailDO> orderLogisticsDOList);
@Mappings({})
OrderLogisticsInfoBO convert(OrderLogisticsDO orderLogisticsDO);
@Mappings({})
List<OrderLogisticsInfoBO.LogisticsDetail> convert(List<OrderLogisticsDetailDO> orderLogisticsDetailDOList);
@Mappings({})
@Named(value = "orderLastLogisticsInfoBO")
OrderLastLogisticsInfoBO convertOrderLastLogisticsInfoBO(OrderLogisticsDO orderLogisticsDO);
@Mappings({})
OrderLastLogisticsInfoBO.LogisticsDetail convertLastLogisticsDetail(OrderLogisticsDetailDO orderLogisticsDetailDO);
}

View File

@ -1,7 +1,7 @@
package cn.iocoder.mall.order.biz.convert;
import cn.iocoder.mall.order.api.bo.OrderInfoBO;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoWithOrderBO;
import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
@ -20,9 +20,6 @@ public interface OrderLogisticsDetailConvert {
OrderLogisticsDetailConvert INSTANCE = Mappers.getMapper(OrderLogisticsDetailConvert.class);
@Mappings({})
List<OrderLogisticsInfoBO.LogisticsDetail> convertLogisticsDetail(List<OrderLogisticsDetailDO> orderLogisticsDOList);
@Mappings({})
OrderInfoBO.LogisticsDetail convertLogisticsDetail(OrderLogisticsDetailDO orderLogisticsDetailDO);
}

View File

@ -50,7 +50,17 @@ public interface OrderLogisticsDetailMapper {
* @param orderLogisticsIds
* @return
*/
OrderLogisticsDetailDO selectLatest(
OrderLogisticsDetailDO selectLast(
@Param("orderLogisticsIds") Collection<Integer> orderLogisticsIds
);
/**
* 查询 - 根据 last 根据物理id
*
* @param orderLogisticsId
* @return
*/
OrderLogisticsDetailDO selectLastByLogisticsId(
@Param("orderLogisticsId") Integer orderLogisticsId
);
}

View File

@ -30,6 +30,16 @@ public interface OrderLogisticsMapper {
*/
void updateById(OrderLogisticsDO orderLogisticsDO);
/**
* 查询 - 根据 ids
*
* @param id
* @return
*/
OrderLogisticsDO selectById(
@Param("id") Integer id
);
/**
* 查询 - 根据 ids
*

View File

@ -41,6 +41,10 @@ public class OrderReturnDO extends BaseDO {
///
/// 退货原因
/**
* 退货金额
*/
private Integer refundPrice;
/**
* 退货原因(字典值)
*

View File

@ -1,12 +1,13 @@
package cn.iocoder.mall.order.biz.service;
import cn.iocoder.common.framework.constant.DeletedStatusEnum;
import cn.iocoder.common.framework.util.CollectionUtil;
import cn.iocoder.common.framework.util.DateUtil;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.OrderLogisticsService;
import cn.iocoder.mall.order.api.bo.OrderLastLogisticsInfoBO;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO;
import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoWithOrderBO;
import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
import cn.iocoder.mall.order.biz.convert.OrderLogisticsConvert;
import cn.iocoder.mall.order.biz.convert.OrderLogisticsDetailConvert;
@ -46,7 +47,46 @@ public class OrderLogisticsServiceImpl implements OrderLogisticsService {
private OrderLogisticsDetailMapper orderLogisticsDetailMapper;
@Override
public CommonResult<OrderLogisticsInfoBO> logisticsInfo(Integer userId, Integer orderId) {
public CommonResult<OrderLogisticsInfoBO> getLogisticsInfo(Integer id) {
OrderLogisticsDO orderLogisticsDO = orderLogisticsMapper.selectById(id);
if (orderLogisticsDO == null) {
return CommonResult.success(null);
}
List<OrderLogisticsDetailDO> orderLogisticsDetailDOList = orderLogisticsDetailMapper
.selectByOrderLogisticsId(orderLogisticsDO.getId());
// 转换数据结构
List<OrderLogisticsInfoBO.LogisticsDetail> logisticsDetails
= OrderLogisticsConvert.INSTANCE.convert(orderLogisticsDetailDOList);
OrderLogisticsInfoBO orderLogisticsInfo2BO = OrderLogisticsConvert.INSTANCE.convert(orderLogisticsDO);
orderLogisticsInfo2BO.setDetails(logisticsDetails);
return CommonResult.success(orderLogisticsInfo2BO);
}
@Override
public CommonResult<OrderLastLogisticsInfoBO> getLastLogisticsInfo(Integer id) {
OrderLogisticsDO orderLogisticsDO = orderLogisticsMapper.selectById(id);
if (orderLogisticsDO == null) {
return CommonResult.success(null);
}
OrderLogisticsDetailDO orderLastLogisticsDetailDO = orderLogisticsDetailMapper.selectLastByLogisticsId(id);
// 转换数据结构
OrderLastLogisticsInfoBO.LogisticsDetail lastLogisticsDetail
= OrderLogisticsConvert.INSTANCE.convertLastLogisticsDetail(orderLastLogisticsDetailDO);
OrderLastLogisticsInfoBO lastLogisticsInfoBO = OrderLogisticsConvert
.INSTANCE.convertOrderLastLogisticsInfoBO(orderLogisticsDO);
lastLogisticsInfoBO.setLastLogisticsDetail(lastLogisticsDetail);
return CommonResult.success(lastLogisticsInfoBO);
}
@Override
public CommonResult<OrderLogisticsInfoWithOrderBO> getOrderLogisticsInfo(Integer userId, Integer orderId) {
OrderDO orderDO = orderMapper.selectById(orderId);
if (orderDO == null) {
@ -75,18 +115,18 @@ public class OrderLogisticsServiceImpl implements OrderLogisticsService {
}
// 转换 return 的数据
List<OrderLogisticsInfoBO.Logistics> logistics
List<OrderLogisticsInfoWithOrderBO.Logistics> logistics
= OrderLogisticsConvert.INSTANCE.convertLogistics(orderLogisticsDOList);
List<OrderLogisticsInfoBO.LogisticsDetail> logisticsDetails
= OrderLogisticsDetailConvert.INSTANCE.convertLogisticsDetail(orderLogisticsDetailDOList);
List<OrderLogisticsInfoWithOrderBO.LogisticsDetail> logisticsDetails
= OrderLogisticsConvert.INSTANCE.convertLogisticsDetail(orderLogisticsDetailDOList);
logisticsDetails.stream().map(o -> {
o.setLogisticsTimeText(DateUtil.format(o.getLogisticsTime(), "yyyy-MM-dd HH:mm"));
return o;
}).collect(Collectors.toList());
Map<Integer, List<OrderLogisticsInfoBO.LogisticsDetail>> logisticsDetailMultimap
Map<Integer, List<OrderLogisticsInfoWithOrderBO.LogisticsDetail>> logisticsDetailMultimap
= logisticsDetails.stream().collect(
Collectors.toMap(
o -> o.getOrderLogisticsId(),
@ -106,7 +146,7 @@ public class OrderLogisticsServiceImpl implements OrderLogisticsService {
}).collect(Collectors.toList());
return CommonResult.success(
new OrderLogisticsInfoBO()
new OrderLogisticsInfoWithOrderBO()
.setOrderId(orderId)
.setOrderNo(orderDO.getOrderNo())
.setLogistics(logistics)

View File

@ -4,18 +4,22 @@ import cn.iocoder.common.framework.constant.DeletedStatusEnum;
import cn.iocoder.common.framework.exception.ServiceException;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.OrderLogisticsService;
import cn.iocoder.mall.order.api.OrderReturnService;
import cn.iocoder.mall.order.api.bo.OrderLastLogisticsInfoBO;
import cn.iocoder.mall.order.api.bo.OrderReturnInfoBO;
import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
import cn.iocoder.mall.order.api.constant.OrderReturnStatusEnum;
import cn.iocoder.mall.order.api.dto.OrderReturnApplyDTO;
import cn.iocoder.mall.order.biz.convert.OrderReturnConvert;
import cn.iocoder.mall.order.biz.dao.OrderItemMapper;
import cn.iocoder.mall.order.biz.dao.OrderLogisticsMapper;
import cn.iocoder.mall.order.biz.dao.OrderMapper;
import cn.iocoder.mall.order.biz.dao.OrderReturnMapper;
import cn.iocoder.mall.order.biz.dataobject.OrderDO;
import cn.iocoder.mall.order.biz.dataobject.OrderItemDO;
import cn.iocoder.mall.order.biz.dataobject.OrderReturnDO;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@ -41,6 +45,9 @@ public class OrderReturnServiceImpl implements OrderReturnService {
@Autowired
private OrderReturnMapper orderReturnMapper;
@Reference(validation = "true")
private OrderLogisticsService orderLogisticsService;
@Override
public CommonResult orderReturnApply(OrderReturnApplyDTO orderReturnDTO) {
OrderDO checkOrder = orderMapper.selectById(orderReturnDTO.getOrderId());
@ -71,7 +78,7 @@ public class OrderReturnServiceImpl implements OrderReturnService {
}
@Override
public CommonResult orderApplyInfo(Integer orderId) {
public CommonResult<OrderReturnInfoBO> orderApplyInfo(Integer orderId) {
// 检查订单是否退货
OrderReturnDO orderReturnDO = orderReturnMapper.selectByOrderId(orderId);
@ -91,9 +98,19 @@ public class OrderReturnServiceImpl implements OrderReturnService {
OrderReturnInfoBO.ReturnInfo returnInfo = OrderReturnConvert.INSTANCE.convert(orderReturnDO);
List<OrderReturnInfoBO.OrderItem> itemList = OrderReturnConvert.INSTANCE.convert(orderItemDOList);
// 物流信息
CommonResult<OrderLastLogisticsInfoBO> lastLogisticsCommonResult = orderLogisticsService
.getLastLogisticsInfo(orderReturnDO.getOrderLogisticsId());
if (lastLogisticsCommonResult.isError()) {
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_LOGISTICS_INVOKING_FAIL.getCode());
}
OrderLastLogisticsInfoBO lastLogisticsInfoBO = lastLogisticsCommonResult.getData();
OrderReturnInfoBO orderReturnInfoBO = new OrderReturnInfoBO()
.setOrderItems(itemList)
.setReturnInfo(returnInfo);
.setReturnInfo(returnInfo)
.setLastLogisticsInfo(lastLogisticsInfoBO);
return CommonResult.success(orderReturnInfoBO);
}

View File

@ -184,7 +184,7 @@ public class OrderServiceImpl implements OrderService {
// 订单物流信息
OrderLogisticsDetailDO orderLogisticsDetailDO = null;
if (!CollectionUtils.isEmpty(orderLogisticsIds)) {
orderLogisticsDetailDO = orderLogisticsDetailMapper.selectLatest(orderLogisticsIds);
orderLogisticsDetailDO = orderLogisticsDetailMapper.selectLast(orderLogisticsIds);
}
// 检查是否申请退货

View File

@ -50,7 +50,7 @@
<!--
查询 - 最新的物流信息
-->
<select id="selectLatest" resultType="cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO">
<select id="selectLast" resultType="cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO">
SELECT
<include refid="FIELDS"/>
FROM order_logistics_detail
@ -61,4 +61,17 @@
ORDER BY create_time DESC
LIMIT 0, 1
</select>
<!--
查询 - 根据 last 根据物理id
-->
<select id="selectLastByLogisticsId"
resultType="cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO">
SELECT
<include refid="FIELDS"/>
FROM order_logistics_detail
WHERE order_logistics_id = #{orderLogisticsId}
ORDER BY create_time DESC
LIMIT 1
</select>
</mapper>

View File

@ -66,4 +66,15 @@
#{id}
</foreach>
</select>
<!--
查询 - 根据 ids
-->
<select id="selectById" resultType="cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDO">
SELECT
<include refid="FIELDS" />
FROM `order_logistics`
WHERE `id` = #{id}
LIMIT 1
</select>
</mapper>

View File

@ -8,6 +8,7 @@
order_id,
order_no,
order_logistics_id,
refund_price,
reason,
`describe`,
approval_time,
@ -26,13 +27,13 @@
<insert id="insert" parameterType="OrderReturnDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO `order_return` (
service_number, order_id, order_no, order_logistics_id,
reason, `describe`,
refund_price, reason, `describe`,
approval_time, logistics_time, receiver_time, closing_time,
service_type, status,
create_time, update_time)
VALUES (
#{serviceNumber}, #{orderId}, #{orderNo}, #{orderLogisticsId},
#{reason}, #{describe},
${refundPrice}, #{reason}, #{describe},
#{approvalTime}, #{logisticsTime}, #{receiverTime}, #{closingTime},
#{serviceType}, #{status}, #{createTime}, #{updateTime})
</insert>
@ -45,6 +46,9 @@
<if test="orderLogisticsId != null">
, order_logistics_id = #{orderLogisticsId}
</if>
<if test="refundPrice != null">
, refund_price = #{refundPrice}
</if>
<if test="reason != null">
, reason = #{reason}
</if>