添加申请退货
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package cn.iocoder.mall.order.biz.convert;
|
||||
|
||||
import cn.iocoder.mall.order.api.bo.OrderInfoBO;
|
||||
import cn.iocoder.mall.order.api.bo.OrderItemBO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderItemUpdateDTO;
|
||||
@@ -32,4 +33,7 @@ public interface OrderItemConvert {
|
||||
|
||||
@Mappings({})
|
||||
List<OrderItemBO> convertOrderItemDO(List<OrderItemDO> orderItemDOList);
|
||||
|
||||
@Mappings({})
|
||||
List<OrderInfoBO.OrderItem> convertOrderInfoWithOrderItem(List<OrderItemDO> orderItemDOList);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.iocoder.mall.order.biz.convert;
|
||||
|
||||
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderReturnApplyDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderReturnCreateDTO;
|
||||
import cn.iocoder.mall.order.biz.dataobject.OrderReturnDO;
|
||||
import org.mapstruct.Mapper;
|
||||
@@ -20,4 +20,7 @@ public interface OrderReturnConvert {
|
||||
|
||||
@Mappings({})
|
||||
OrderReturnDO convert(OrderReturnCreateDTO orderReturnCreate);
|
||||
|
||||
@Mappings({})
|
||||
OrderReturnDO convert(OrderReturnApplyDTO orderReturnApplyDTO);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package cn.iocoder.mall.order.biz.dao;
|
||||
|
||||
import cn.iocoder.mall.order.biz.dataobject.OrderReturnDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
@@ -10,4 +12,30 @@ import org.springframework.stereotype.Repository;
|
||||
*/
|
||||
@Repository
|
||||
public interface OrderReturnMapper {
|
||||
|
||||
/**
|
||||
* 插入 - 退货信息
|
||||
*
|
||||
* @param orderReturnDO
|
||||
* @return
|
||||
*/
|
||||
int insert(OrderReturnDO orderReturnDO);
|
||||
|
||||
/**
|
||||
* 更新 - 根据 orderId
|
||||
*
|
||||
* @param orderReturnDO
|
||||
* @return
|
||||
*/
|
||||
int updateByOrderId(OrderReturnDO orderReturnDO);
|
||||
|
||||
/**
|
||||
* 查询 - 根据 orderId
|
||||
*
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
OrderReturnDO selectByOrderId(
|
||||
@Param("orderId") Integer orderId
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.iocoder.mall.order.biz.dataobject;
|
||||
|
||||
import cn.iocoder.common.framework.dataobject.BaseDO;
|
||||
import cn.iocoder.common.framework.dataobject.DeletableDO;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -14,7 +15,7 @@ import java.util.Date;
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class OrderReturnDO extends DeletableDO {
|
||||
public class OrderReturnDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号自动增长
|
||||
@@ -28,22 +29,6 @@ public class OrderReturnDO extends DeletableDO {
|
||||
* 订单号 (保存一个冗余)
|
||||
*/
|
||||
private String orderNo;
|
||||
/**
|
||||
* 订单 item 编号
|
||||
*/
|
||||
private Integer orderItemId;
|
||||
/**
|
||||
* 商品编号(保存一个冗余,如果一个订单下存在多个商品,会有很大的作用)
|
||||
*/
|
||||
private Integer skuId;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String skuName;
|
||||
/**
|
||||
* 商品图片
|
||||
*/
|
||||
private String skuImage;
|
||||
/**
|
||||
* 物流id
|
||||
*/
|
||||
@@ -57,21 +42,15 @@ public class OrderReturnDO extends DeletableDO {
|
||||
*
|
||||
* {@link cn.iocoder.mall.order.biz.constants.OrderReturnReasonEnum}
|
||||
*/
|
||||
private Integer orderReason;
|
||||
private Integer reason;
|
||||
/**
|
||||
* 原因(如果选择其他,原因保存在这)
|
||||
*
|
||||
* {@link cn.iocoder.mall.order.biz.constants.OrderReturnReasonEnum#REASON_000}
|
||||
* 问题描述
|
||||
*/
|
||||
private String otherReasons;
|
||||
private String describe;
|
||||
|
||||
///
|
||||
/// 时间信息
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 同意时间
|
||||
*/
|
||||
@@ -88,17 +67,13 @@ public class OrderReturnDO extends DeletableDO {
|
||||
* 成交时间(确认时间)
|
||||
*/
|
||||
private Date closingTime;
|
||||
|
||||
///
|
||||
/// 其他
|
||||
|
||||
/**
|
||||
* 订单类型
|
||||
* 退款类型
|
||||
*
|
||||
* - 0、为 Order 订单 (对整个订单退货)
|
||||
* - 1、为 OrderItem 订单 (对订单某一个商品退货)
|
||||
* - 1、退货退款
|
||||
* - 2、退款
|
||||
*/
|
||||
private Integer orderType;
|
||||
private Integer returnType;
|
||||
/**
|
||||
* 状态
|
||||
*
|
||||
@@ -109,5 +84,4 @@ public class OrderReturnDO extends DeletableDO {
|
||||
* - 5、退货成功
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -20,10 +21,9 @@ import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDetailDO;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -67,10 +67,12 @@ public class OrderLogisticsServiceImpl implements OrderLogisticsService {
|
||||
.map(o -> o.getOrderLogisticsId())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
List<OrderLogisticsDO> orderLogisticsDOList = orderLogisticsMapper.selectByIds(orderLogisticsIds);
|
||||
|
||||
List<OrderLogisticsDetailDO> orderLogisticsDetailDOList
|
||||
= orderLogisticsDetailMapper.selectByOrderLogisticsIds(orderLogisticsIds);
|
||||
List<OrderLogisticsDO> orderLogisticsDOList = Collections.emptyList();
|
||||
List<OrderLogisticsDetailDO> orderLogisticsDetailDOList = Collections.emptyList();
|
||||
if (!CollectionUtils.isEmpty(orderLogisticsIds)) {
|
||||
orderLogisticsDOList = orderLogisticsMapper.selectByIds(orderLogisticsIds);
|
||||
orderLogisticsDetailDOList = orderLogisticsDetailMapper.selectByOrderLogisticsIds(orderLogisticsIds);
|
||||
}
|
||||
|
||||
// 转换 return 的数据
|
||||
List<OrderLogisticsInfoBO.Logistics> logistics
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package cn.iocoder.mall.order.biz.service;
|
||||
|
||||
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.constant.OrderErrorCodeEnum;
|
||||
import cn.iocoder.mall.order.api.constant.OrderReturnStatusEnum;
|
||||
import cn.iocoder.mall.order.api.dto.OrderReturnCreateDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderReturnApplyDTO;
|
||||
import cn.iocoder.mall.order.biz.convert.OrderReturnConvert;
|
||||
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.OrderReturnDO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -22,19 +26,30 @@ import java.util.Date;
|
||||
@com.alibaba.dubbo.config.annotation.Service(validation = "true")
|
||||
public class OrderReturnServiceImpl implements OrderReturnService {
|
||||
|
||||
@Autowired
|
||||
private OrderMapper orderMapper;
|
||||
@Autowired
|
||||
private OrderReturnMapper orderReturnMapper;
|
||||
|
||||
@Override
|
||||
public CommonResult createOrderReturn(OrderReturnCreateDTO orderReturnCreate) {
|
||||
public CommonResult orderReturnApply(OrderReturnApplyDTO orderReturnDTO) {
|
||||
OrderDO checkOrder = orderMapper.selectById(orderReturnDTO.getOrderId());
|
||||
|
||||
// 检查订单是否 存在
|
||||
if (checkOrder == null) {
|
||||
return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode());
|
||||
}
|
||||
|
||||
|
||||
OrderReturnDO orderReturnDO = OrderReturnConvert.INSTANCE.convert(orderReturnCreate);
|
||||
// 转换 DO
|
||||
OrderReturnDO orderReturnDO = OrderReturnConvert.INSTANCE.convert(orderReturnDTO);
|
||||
orderReturnDO
|
||||
.setCreateTime(new Date())
|
||||
.setStatus(OrderReturnStatusEnum.RETURN_APPLICATION.getValue());
|
||||
.setOrderId(checkOrder.getId())
|
||||
.setOrderNo(checkOrder.getOrderNo())
|
||||
.setStatus(OrderReturnStatusEnum.RETURN_APPLICATION.getValue())
|
||||
.setCreateTime(new Date());
|
||||
|
||||
return null;
|
||||
// 保存申请信息
|
||||
orderReturnMapper.insert(orderReturnDO);
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,7 @@ import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.order.api.OrderService;
|
||||
import cn.iocoder.mall.order.api.bo.*;
|
||||
import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
|
||||
import cn.iocoder.mall.order.api.constant.OrderHasReturnExchangeEnum;
|
||||
import cn.iocoder.mall.order.api.constant.OrderStatusEnum;
|
||||
import cn.iocoder.mall.order.api.constant.PayAppId;
|
||||
import cn.iocoder.mall.order.api.constant.*;
|
||||
import cn.iocoder.mall.order.api.dto.*;
|
||||
import cn.iocoder.mall.order.biz.constants.OrderDeliveryTypeEnum;
|
||||
import cn.iocoder.mall.order.biz.constants.OrderRecipientTypeEnum;
|
||||
@@ -61,6 +58,8 @@ public class OrderServiceImpl implements OrderService {
|
||||
private OrderRecipientMapper orderRecipientMapper;
|
||||
@Autowired
|
||||
private OrderCancelMapper orderCancelMapper;
|
||||
@Autowired
|
||||
private OrderReturnMapper orderReturnMapper;
|
||||
|
||||
@Reference
|
||||
private ProductSpuService productSpuService;
|
||||
@@ -165,11 +164,16 @@ public class OrderServiceImpl implements OrderService {
|
||||
List<OrderItemDO> itemDOList = orderItemMapper
|
||||
.selectByDeletedAndOrderId(orderId, DeletedStatusEnum.DELETED_NO.getValue());
|
||||
|
||||
List<OrderInfoBO.OrderItem> orderItems
|
||||
= OrderItemConvert.INSTANCE.convertOrderInfoWithOrderItem(itemDOList);
|
||||
|
||||
Set<Integer> orderLogisticsIds = itemDOList.stream()
|
||||
.filter(o -> o.getOrderLogisticsId() != null)
|
||||
.map(o -> o.getOrderLogisticsId())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
|
||||
|
||||
// 收件人信息
|
||||
OrderRecipientDO orderRecipientDO = orderRecipientMapper.selectByOrderId(orderId);
|
||||
|
||||
@@ -186,6 +190,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
OrderInfoBO.Recipient recipient = OrderRecipientConvert.INSTANCE.convertOrderInfoRecipient(orderRecipientDO);
|
||||
OrderInfoBO orderInfoBO = OrderConvert.INSTANCE.convert(orderDO);
|
||||
orderInfoBO.setRecipient(recipient);
|
||||
orderInfoBO.setOrderItems(orderItems);
|
||||
orderInfoBO.setLatestLogisticsDetail(logisticsDetail);
|
||||
return CommonResult.success(orderInfoBO);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.mall.order.biz.dao.OrderReturnMapper">
|
||||
|
||||
<sql id="FIELDS">
|
||||
id,
|
||||
order_id,
|
||||
order_no,
|
||||
order_logistics_id,
|
||||
reason,
|
||||
`describe`,
|
||||
approval_time,
|
||||
logistics_time,
|
||||
receiver_time,
|
||||
closing_time,
|
||||
return_type,
|
||||
status,
|
||||
create_time,
|
||||
update_time
|
||||
</sql>
|
||||
|
||||
<!--
|
||||
插入数据
|
||||
-->
|
||||
<insert id="insert" parameterType="OrderReturnDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
INSERT INTO `order_return` (
|
||||
order_id, order_no, order_logistics_id,
|
||||
reason, `describe`,
|
||||
approval_time, logistics_time, receiver_time, closing_time,
|
||||
return_type, status,
|
||||
create_time, update_time)
|
||||
VALUES (
|
||||
#{orderId}, #{orderNo}, #{orderLogisticsId},
|
||||
#{reason}, #{describe},
|
||||
#{approvalTime}, #{logisticsTime}, #{receiverTime}, #{closingTime},
|
||||
#{returnType}, #{status}, #{createTime}, #{updateTime})
|
||||
</insert>
|
||||
|
||||
<!--
|
||||
更新 - 可更新的字段
|
||||
-->
|
||||
<sql id="updateFieldSql">
|
||||
<set>
|
||||
<if test="orderLogisticsId != null">
|
||||
, order_logistics_id = #{orderLogisticsId}
|
||||
</if>
|
||||
<if test="reason != null">
|
||||
, reason = #{reason}
|
||||
</if>
|
||||
<if test="describe != null">
|
||||
, `describe` = #{describe}
|
||||
</if>
|
||||
<if test="approvalTime != null">
|
||||
, approval_time = #{approvalTime}
|
||||
</if>
|
||||
<if test="logisticsTime != null">
|
||||
, logistics_time = #{logisticsTime}
|
||||
</if>
|
||||
<if test="receiverTime != null">
|
||||
, receiver_time = #{receiverTime}
|
||||
</if>
|
||||
<if test="deliveryTime != null">
|
||||
, delivery_time = #{deliveryTime}
|
||||
</if>
|
||||
<if test="closingTime != null">
|
||||
, closing_time = #{closingTime}
|
||||
</if>
|
||||
<if test="returnType != null">
|
||||
, return_type = #{returnType}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
, status = #{status}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
, create_time = #{createTime}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
, update_time = #{updateTime}
|
||||
</if>
|
||||
</set>
|
||||
</sql>
|
||||
|
||||
<!--
|
||||
更新 - 根据 id 更新
|
||||
-->
|
||||
<update id="updateByOrderId" parameterType="OrderReturnDO">
|
||||
UPDATE `order_return`
|
||||
<include refid="updateFieldSql"/>
|
||||
WHERE order_id = #{orderId}
|
||||
</update>
|
||||
|
||||
<!--
|
||||
查询 - 根据id 查询
|
||||
-->
|
||||
<select id="selectByOrderId" resultType="cn.iocoder.mall.order.biz.dataobject.OrderReturnDO">
|
||||
SELECT
|
||||
<include refid="FIELDS"/>
|
||||
FROM `order_return`
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user