添加申请退货

pull/1/head
sin 2019-04-26 00:23:29 +08:00
parent cddffabeba
commit 718554bcfa
17 changed files with 436 additions and 78 deletions

View File

@ -13,9 +13,12 @@ import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
import cn.iocoder.mall.order.api.dto.CalcOrderPriceDTO;
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderQueryDTO;
import cn.iocoder.mall.order.api.dto.OrderReturnApplyDTO;
import cn.iocoder.mall.order.application.convert.CartConvert;
import cn.iocoder.mall.order.application.convert.OrderConvertAPP;
import cn.iocoder.mall.order.application.convert.OrderReturnConvert;
import cn.iocoder.mall.order.application.po.user.OrderCreatePO;
import cn.iocoder.mall.order.application.po.user.OrderReturnApplyPO;
import cn.iocoder.mall.order.application.vo.UsersOrderConfirmCreateVO;
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
import com.alibaba.dubbo.config.annotation.Reference;
@ -38,7 +41,7 @@ import java.util.stream.Collectors;
@RestController
@RequestMapping("users/order")
@Api(description = "用户订单")
public class UsersOrderController {
public class OrderController {
@Reference(validation = "true")
private OrderService orderService;
@ -124,9 +127,11 @@ public class UsersOrderController {
CommonResult<OrderInfoBO> commonResult = orderService.info(userId, orderId);
OrderInfoBO orderInfoBO = commonResult.getData();
CommonResult<DataDictBO> dictResult = dataDictService
.getDataDict(DictKeyConstants.ORDER_STATUS, orderInfoBO.getStatus());
orderInfoBO.setStatusText(dictResult.getData().getDisplayName());
if(orderInfoBO != null) {
CommonResult<DataDictBO> dictResult = dataDictService
.getDataDict(DictKeyConstants.ORDER_STATUS, orderInfoBO.getStatus());
orderInfoBO.setStatusText(dictResult.getData().getDisplayName());
}
return commonResult;
}
}

View File

@ -12,6 +12,7 @@ import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
import com.alibaba.dubbo.config.annotation.Reference;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@ -49,25 +50,27 @@ public class OrderLogisticsController {
// 获取字典值
Set<Integer> dictValues = logisticsList.stream().map(o -> o.getLogistics()).collect(Collectors.toSet());
CommonResult<List<DataDictBO>> dictResult = dataDictService
.getDataDictList(DictKeyConstants.ORDER_LOGISTICS_COMPANY, dictValues);
if (!CollectionUtils.isEmpty(dictValues)) {
CommonResult<List<DataDictBO>> dictResult = dataDictService
.getDataDictList(DictKeyConstants.ORDER_LOGISTICS_COMPANY, dictValues);
if (dictResult.isError()) {
// 错误情况
return ServiceExceptionUtil.error(OrderErrorCodeEnum.DICT_SERVER_INVOKING_FAIL.getCode());
}
// 转换结果字典值
Map<String, DataDictBO> dataDictBOMap = dictResult.getData()
.stream().collect(Collectors.toMap(o -> o.getValue(), o -> o));
logisticsList.stream().map(o -> {
String dicValue = o.getLogistics().toString();
if (dataDictBOMap.containsKey(dicValue)) {
o.setLogisticsText(dataDictBOMap.get(dicValue).getDisplayName());
if (dictResult.isError()) {
// 错误情况
return ServiceExceptionUtil.error(OrderErrorCodeEnum.DICT_SERVER_INVOKING_FAIL.getCode());
}
return o;
}).collect(Collectors.toList());
// 转换结果字典值
Map<String, DataDictBO> dataDictBOMap = dictResult.getData()
.stream().collect(Collectors.toMap(o -> o.getValue(), o -> o));
logisticsList.stream().map(o -> {
String dicValue = o.getLogistics().toString();
if (dataDictBOMap.containsKey(dicValue)) {
o.setLogisticsText(dataDictBOMap.get(dicValue).getDisplayName());
}
return o;
}).collect(Collectors.toList());
}
}
return commonResult;

View File

@ -0,0 +1,44 @@
package cn.iocoder.mall.order.application.controller.users;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.admin.api.DataDictService;
import cn.iocoder.mall.admin.api.bo.DataDictBO;
import cn.iocoder.mall.order.api.OrderReturnService;
import cn.iocoder.mall.order.api.constant.DictKeyConstants;
import cn.iocoder.mall.order.api.dto.OrderReturnApplyDTO;
import cn.iocoder.mall.order.application.convert.OrderReturnConvert;
import cn.iocoder.mall.order.application.po.user.OrderReturnApplyPO;
import com.alibaba.dubbo.config.annotation.Reference;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 退/
*
* @author Sin
* @time 2019-04-25 22:04
*/
@RestController
@RequestMapping("users/order_return")
public class OrderReturnController {
@Reference(validation = "true")
private OrderReturnService orderReturnService;
@Reference(validation = "true")
private DataDictService dataDictService;
@GetMapping("reason")
@ApiOperation("原因")
public CommonResult<List<DataDictBO>> orderReturnReason() {
return dataDictService.getDataDict(DictKeyConstants.ORDER_RETURN_REASON);
}
@PostMapping("apply")
@ApiOperation("订单售后")
public CommonResult orderReturnApply(@RequestBody OrderReturnApplyPO orderReturnApplyPO) {
OrderReturnApplyDTO applyDTO = OrderReturnConvert.INSTANCE.convert(orderReturnApplyPO);
return orderReturnService.orderReturnApply(applyDTO);
}
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.mall.order.application.convert;
import cn.iocoder.mall.order.api.dto.OrderReturnApplyDTO;
import cn.iocoder.mall.order.application.po.user.OrderReturnApplyPO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
/**
* 退
*
* @author Sin
* @time 2019-04-25 21:54
*/
@Mapper
public interface OrderReturnConvert {
OrderReturnConvert INSTANCE = Mappers.getMapper(OrderReturnConvert.class);
@Mappings({})
OrderReturnApplyDTO convert(OrderReturnApplyPO orderReturnApplyPO);
}

View File

@ -0,0 +1,48 @@
package cn.iocoder.mall.order.application.po.user;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
/**
*
*
* @author Sin
* @time 2019-04-25 20:59
*/
@Data
@Accessors(chain = true)
public class OrderReturnApplyPO implements Serializable {
/**
*
*/
@NotNull(message = "orderId 不能为空!")
private Integer orderId;
/**
* 退
*
* - 1退退
* - 2退
*/
@NotNull(message = "退货类型不能为空!")
private Integer returnType;
/**
* 退()
*
* {@link cn.iocoder.mall.order.biz.constants.OrderReturnReasonEnum}
*/
@NotNull(message = "必须选择退货原因")
private Integer reason;
/**
*
*
* {@link cn.iocoder.mall.order.biz.constants.OrderReturnReasonEnum#REASON_000}
*/
@Size(max = 200)
private String describe;
}

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.dto.OrderReturnApplyDTO;
import cn.iocoder.mall.order.api.dto.OrderReturnCreateDTO;
/**
@ -11,11 +12,13 @@ import cn.iocoder.mall.order.api.dto.OrderReturnCreateDTO;
*/
public interface OrderReturnService {
/**
* 退 -
* - 退
*
* @param orderReturnCreate
* @param orderReturnApplyDTO
* @return
*/
CommonResult createOrderReturn(OrderReturnCreateDTO orderReturnCreate);
CommonResult orderReturnApply(OrderReturnApplyDTO orderReturnApplyDTO);
}

View File

@ -5,6 +5,7 @@ import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* info
@ -104,6 +105,64 @@ public class OrderInfoBO implements Serializable {
*
*/
private LogisticsDetail latestLogisticsDetail;
/**
* item
*/
private List<OrderItem> orderItems;
@Data
@Accessors(chain = true)
public static class OrderItem {
/**
*
*/
private Integer skuId;
/**
*
*/
private String skuName;
/**
*
*/
private String skuImage;
/**
*
*/
private Integer quantity;
/**
*
*/
private Integer originPrice;
/**
*
*/
private Integer buyPrice;
/**
*
*/
private Integer presentPrice;
/**
*
*
* {@link #presentTotal}
*/
private Integer buyTotal;
/**
*
*/
private Integer discountTotal;
/**
*
*
* presentPrice * quantity presentTotal
*
* presentPrice = 8.33 quantity = 3 presentTotal 24.99 25
*
*/
private Integer presentTotal;
}
@Data
@Accessors(chain = true)

View File

@ -16,4 +16,8 @@ public class DictKeyConstants {
* -
*/
public static final String ORDER_LOGISTICS_COMPANY = "logistics_company";
/**
* - 退
*/
public static final String ORDER_RETURN_REASON = "order_return_reason";
}

View File

@ -0,0 +1,37 @@
package cn.iocoder.mall.order.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* @author Sin
* @time 2019-04-25 21:06
*/
@Data
@Accessors(chain = true)
public class OrderReturnApplyDTO implements Serializable {
/**
*
*/
private Integer orderId;
/**
* 退()
*/
private Integer reason;
/**
*
*/
private String describe;
/**
* 退
*
* - 1退退
* - 2退
*/
private Integer returnType;
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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
);
}

View File

@ -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;
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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>