- 添加退货详情
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
package cn.iocoder.mall.order.biz.convert;
|
||||
|
||||
import cn.iocoder.mall.order.api.bo.OrderReturnInfoBO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderReturnApplyDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderReturnCreateDTO;
|
||||
import cn.iocoder.mall.order.biz.dataobject.OrderItemDO;
|
||||
import cn.iocoder.mall.order.biz.dataobject.OrderReturnDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单 return
|
||||
*
|
||||
@@ -23,4 +27,10 @@ public interface OrderReturnConvert {
|
||||
|
||||
@Mappings({})
|
||||
OrderReturnDO convert(OrderReturnApplyDTO orderReturnApplyDTO);
|
||||
|
||||
@Mappings({})
|
||||
OrderReturnInfoBO.ReturnInfo convert(OrderReturnDO orderReturnDO);
|
||||
|
||||
@Mappings({})
|
||||
List<OrderReturnInfoBO.OrderItem> convert(List<OrderItemDO> orderItemDOList);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import cn.iocoder.mall.order.biz.dataobject.OrderItemDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -79,7 +78,7 @@ public interface OrderItemMapper {
|
||||
* @return
|
||||
*/
|
||||
List<OrderItemDO> selectByDeletedAndOrderId(
|
||||
@Param("orderId") Integer orderId,
|
||||
@Param("deleted") @NotNull Integer deleted
|
||||
@Param("deleted") Integer deleted,
|
||||
@Param("orderId") Integer orderId
|
||||
);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ public class OrderReturnDO extends BaseDO {
|
||||
* 编号自动增长
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 服务号
|
||||
*/
|
||||
private String serviceNumber;
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
@@ -68,12 +72,12 @@ public class OrderReturnDO extends BaseDO {
|
||||
*/
|
||||
private Date closingTime;
|
||||
/**
|
||||
* 退款类型
|
||||
* 服务类型
|
||||
*
|
||||
* - 1、退货退款
|
||||
* - 2、退款
|
||||
*/
|
||||
private Integer returnType;
|
||||
private Integer serviceType;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
|
||||
@@ -59,7 +59,7 @@ public class OrderLogisticsServiceImpl implements OrderLogisticsService {
|
||||
|
||||
// 获取订单所发货的订单 id
|
||||
List<OrderItemDO> orderItemDOList = orderItemMapper.selectByDeletedAndOrderId(
|
||||
orderId, DeletedStatusEnum.DELETED_NO.getValue());
|
||||
DeletedStatusEnum.DELETED_NO.getValue(), orderId);
|
||||
|
||||
// 获取物流 信息
|
||||
Set<Integer> orderLogisticsIds = orderItemDOList.stream()
|
||||
|
||||
@@ -1,20 +1,28 @@
|
||||
package cn.iocoder.mall.order.biz.service;
|
||||
|
||||
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.OrderReturnService;
|
||||
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.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 org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 订单退货 service
|
||||
@@ -29,6 +37,8 @@ public class OrderReturnServiceImpl implements OrderReturnService {
|
||||
@Autowired
|
||||
private OrderMapper orderMapper;
|
||||
@Autowired
|
||||
private OrderItemMapper orderItemMapper;
|
||||
@Autowired
|
||||
private OrderReturnMapper orderReturnMapper;
|
||||
|
||||
@Override
|
||||
@@ -44,6 +54,8 @@ public class OrderReturnServiceImpl implements OrderReturnService {
|
||||
OrderReturnDO orderReturnDO = OrderReturnConvert.INSTANCE.convert(orderReturnDTO);
|
||||
orderReturnDO
|
||||
.setOrderId(checkOrder.getId())
|
||||
// TODO: 2019-04-27 Sin 服务号生成规则
|
||||
.setServiceNumber(UUID.randomUUID().toString().replaceAll("-", "").substring(0, 16))
|
||||
.setOrderNo(checkOrder.getOrderNo())
|
||||
.setStatus(OrderReturnStatusEnum.RETURN_APPLICATION.getValue())
|
||||
.setCreateTime(new Date());
|
||||
@@ -57,4 +69,32 @@ public class OrderReturnServiceImpl implements OrderReturnService {
|
||||
public String updateRefundSuccess(String orderId, Integer refundPrice) {
|
||||
return "success";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult orderApplyInfo(Integer orderId) {
|
||||
|
||||
// 检查订单是否退货
|
||||
OrderReturnDO orderReturnDO = orderReturnMapper.selectByOrderId(orderId);
|
||||
if (orderReturnDO == null) {
|
||||
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_RETURN_NO_RETURN_APPLY.getCode());
|
||||
}
|
||||
|
||||
List<OrderItemDO> orderItemDOList = orderItemMapper
|
||||
.selectByDeletedAndOrderId(DeletedStatusEnum.DELETED_NO.getValue(), orderId);
|
||||
|
||||
// 订单不存在
|
||||
if (CollectionUtils.isEmpty(orderItemDOList)) {
|
||||
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode());
|
||||
}
|
||||
|
||||
// 转换 returnInfo
|
||||
OrderReturnInfoBO.ReturnInfo returnInfo = OrderReturnConvert.INSTANCE.convert(orderReturnDO);
|
||||
List<OrderReturnInfoBO.OrderItem> itemList = OrderReturnConvert.INSTANCE.convert(orderItemDOList);
|
||||
|
||||
OrderReturnInfoBO orderReturnInfoBO = new OrderReturnInfoBO()
|
||||
.setOrderItems(itemList)
|
||||
.setReturnInfo(returnInfo);
|
||||
|
||||
return CommonResult.success(orderReturnInfoBO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
}
|
||||
|
||||
List<OrderItemDO> orderItemDOList = orderItemMapper
|
||||
.selectByDeletedAndOrderId(orderId, DeletedStatusEnum.DELETED_NO.getValue());
|
||||
.selectByDeletedAndOrderId(DeletedStatusEnum.DELETED_NO.getValue(), orderId);
|
||||
|
||||
List<OrderItemBO> orderItemBOList = OrderItemConvert.INSTANCE.convertOrderItemBO(orderItemDOList);
|
||||
return CommonResult.success(orderItemBOList);
|
||||
@@ -166,7 +166,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
}
|
||||
|
||||
List<OrderItemDO> itemDOList = orderItemMapper
|
||||
.selectByDeletedAndOrderId(orderId, DeletedStatusEnum.DELETED_NO.getValue());
|
||||
.selectByDeletedAndOrderId(DeletedStatusEnum.DELETED_NO.getValue(), orderId);
|
||||
|
||||
List<OrderInfoBO.OrderItem> orderItems
|
||||
= OrderItemConvert.INSTANCE.convertOrderInfoWithOrderItem(itemDOList);
|
||||
@@ -187,6 +187,9 @@ public class OrderServiceImpl implements OrderService {
|
||||
orderLogisticsDetailDO = orderLogisticsDetailMapper.selectLatest(orderLogisticsIds);
|
||||
}
|
||||
|
||||
// 检查是否申请退货
|
||||
OrderReturnDO orderReturnDO = orderReturnMapper.selectByOrderId(orderId);
|
||||
|
||||
// convert 信息
|
||||
OrderInfoBO.LogisticsDetail logisticsDetail
|
||||
= OrderLogisticsDetailConvert.INSTANCE.convertLogisticsDetail(orderLogisticsDetailDO);
|
||||
@@ -196,6 +199,13 @@ public class OrderServiceImpl implements OrderService {
|
||||
orderInfoBO.setRecipient(recipient);
|
||||
orderInfoBO.setOrderItems(orderItems);
|
||||
orderInfoBO.setLatestLogisticsDetail(logisticsDetail);
|
||||
|
||||
// 是否退货
|
||||
if (orderReturnDO != null) {
|
||||
orderInfoBO.setHasOrderReturn(orderReturnDO.getStatus());
|
||||
} else {
|
||||
orderInfoBO.setHasOrderReturn(-1);
|
||||
}
|
||||
return CommonResult.success(orderInfoBO);
|
||||
}
|
||||
|
||||
@@ -405,7 +415,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
// 再重新计算订单金额
|
||||
List<OrderItemDO> orderItemDOList = orderItemMapper
|
||||
.selectByDeletedAndOrderId(orderId, DeletedStatusEnum.DELETED_NO.getValue());
|
||||
.selectByDeletedAndOrderId(DeletedStatusEnum.DELETED_NO.getValue(), orderId);
|
||||
// Integer price = orderCommon.calculatedPrice(orderItemDOList);
|
||||
// Integer amount = orderCommon.calculatedAmount(orderItemDOList);
|
||||
Integer price = -1; // TODO 芋艿,这里要修改,价格
|
||||
@@ -522,7 +532,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
// 获取当前有效的订单 item
|
||||
List<OrderItemDO> orderItemDOList = orderItemMapper
|
||||
.selectByDeletedAndOrderId(orderId, DeletedStatusEnum.DELETED_NO.getValue());
|
||||
.selectByDeletedAndOrderId(DeletedStatusEnum.DELETED_NO.getValue(), orderId);
|
||||
|
||||
List<OrderItemDO> effectiveOrderItems = orderItemDOList.stream()
|
||||
.filter(orderItemDO -> !orderItemIds.contains(orderItemDO.getId()))
|
||||
|
||||
@@ -147,10 +147,10 @@
|
||||
<select id="selectByDeletedAndOrderId" resultType="cn.iocoder.mall.order.biz.dataobject.OrderItemDO">
|
||||
SELECT * FROM `order_item`
|
||||
WHERE 1=1
|
||||
<if test="deleted">
|
||||
<if test="deleted != null">
|
||||
AND deleted = #{deleted}
|
||||
</if>
|
||||
<if test="orderId">
|
||||
<if test="orderId != null">
|
||||
AND order_id = #{orderId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
<sql id="FIELDS">
|
||||
id,
|
||||
service_number,
|
||||
order_id,
|
||||
order_no,
|
||||
order_logistics_id,
|
||||
@@ -13,7 +14,7 @@
|
||||
logistics_time,
|
||||
receiver_time,
|
||||
closing_time,
|
||||
return_type,
|
||||
service_type,
|
||||
status,
|
||||
create_time,
|
||||
update_time
|
||||
@@ -24,16 +25,16 @@
|
||||
-->
|
||||
<insert id="insert" parameterType="OrderReturnDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
INSERT INTO `order_return` (
|
||||
order_id, order_no, order_logistics_id,
|
||||
service_number, order_id, order_no, order_logistics_id,
|
||||
reason, `describe`,
|
||||
approval_time, logistics_time, receiver_time, closing_time,
|
||||
return_type, status,
|
||||
service_type, status,
|
||||
create_time, update_time)
|
||||
VALUES (
|
||||
#{orderId}, #{orderNo}, #{orderLogisticsId},
|
||||
#{serviceNumber}, #{orderId}, #{orderNo}, #{orderLogisticsId},
|
||||
#{reason}, #{describe},
|
||||
#{approvalTime}, #{logisticsTime}, #{receiverTime}, #{closingTime},
|
||||
#{returnType}, #{status}, #{createTime}, #{updateTime})
|
||||
#{serviceType}, #{status}, #{createTime}, #{updateTime})
|
||||
</insert>
|
||||
|
||||
<!--
|
||||
@@ -96,7 +97,8 @@
|
||||
SELECT
|
||||
<include refid="FIELDS"/>
|
||||
FROM `order_return`
|
||||
WHERE id = #{id}
|
||||
WHERE order_id = #{orderId}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user