- 添加退货详情

This commit is contained in:
sin 2019-04-27 12:48:10 +08:00
parent a5a51b9cdb
commit 983f00ab40
16 changed files with 298 additions and 21 deletions

View File

@ -85,7 +85,7 @@ public class OrderController {
remark, HttpUtil.getIp(request),
cartItems, couponCardId);
// 创建订单
CommonResult<OrderCreateBO> createResult= orderService.createOrder(orderCreateDTO);
CommonResult<OrderCreateBO> createResult = orderService.createOrder(orderCreateDTO);
if (createResult.isError()) {
return CommonResult.error(createResult);
}
@ -127,7 +127,7 @@ public class OrderController {
CommonResult<OrderInfoBO> commonResult = orderService.info(userId, orderId);
OrderInfoBO orderInfoBO = commonResult.getData();
if(orderInfoBO != null) {
if (orderInfoBO != null) {
CommonResult<DataDictBO> dictResult = dataDictService
.getDataDict(DictKeyConstants.ORDER_STATUS, orderInfoBO.getStatus());
orderInfoBO.setStatusText(dictResult.getData().getDisplayName());

View File

@ -4,6 +4,7 @@ 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.bo.OrderReturnInfoBO;
import cn.iocoder.mall.order.api.constant.DictKeyConstants;
import cn.iocoder.mall.order.api.dto.OrderReturnApplyDTO;
import cn.iocoder.mall.order.application.convert.OrderReturnConvert;
@ -41,4 +42,23 @@ public class OrderReturnController {
OrderReturnApplyDTO applyDTO = OrderReturnConvert.INSTANCE.convert(orderReturnApplyPO);
return orderReturnService.orderReturnApply(applyDTO);
}
@GetMapping("info")
@ApiOperation("订单售后详细")
public CommonResult<OrderReturnInfoBO> orderApplyInfo(@RequestParam("orderId") Integer orderId) {
CommonResult<OrderReturnInfoBO> commonResult = orderReturnService.orderApplyInfo(orderId);
// 转换 字典值
if (commonResult.isSuccess()) {
CommonResult<DataDictBO> dataDictResult = dataDictService.getDataDict(
DictKeyConstants.ORDER_RETURN_SERVICE_TYPE,
commonResult.getData().getReturnInfo().getServiceType());
if (dataDictResult.isSuccess()) {
commonResult.getData().getReturnInfo().setServiceTypeText(dataDictResult.getData().getDisplayName());
}
}
return commonResult;
}
}

View File

@ -32,4 +32,11 @@ public interface OrderReturnService {
*/
String updateRefundSuccess(String orderId, Integer refundPrice);
/**
* 订单申请信息
*
* @param orderId
* @return
*/
CommonResult orderApplyInfo(Integer orderId);
}

View File

@ -110,6 +110,15 @@ public class OrderInfoBO implements Serializable {
*/
private List<OrderItem> orderItems;
///
/// 其他字段
/**
* 是否退货
*/
private Integer hasOrderReturn;
@Data
@Accessors(chain = true)
public static class OrderItem {

View File

@ -0,0 +1,133 @@
package cn.iocoder.mall.order.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 订单退货 info
*
* @author Sin
* @time 2019-04-27 10:19
*/
@Data
@Accessors(chain = true)
public class OrderReturnInfoBO implements Serializable {
/**
* 退货信息
*/
private ReturnInfo returnInfo;
/**
* 订单 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 presentTotal;
}
@Data
@Accessors(chain = true)
public static class ReturnInfo {
/**
* 编号自动增长
*/
private Integer id;
/**
* 服务号
*/
private String serviceNumber;
/**
* 订单编号
*/
private Integer orderId;
/**
* 订单号 保存一个冗余
*/
private String orderNo;
/**
* 物流id
*/
private Integer orderLogisticsId;
///
/// 退货原因
/**
* 退货原因(字典值)
*/
private Integer reason;
/**
* 问题描述
*/
private String describe;
///
/// 时间信息
/**
* 同意时间
*/
private Date approvalTime;
/**
* 物流时间填写物流单号时间
*/
private Date logisticsTime;
/**
* 收货时间
*/
private Date receiverTime;
/**
* 成交时间确认时间
*/
private Date closingTime;
/**
* 退款类型
*
* - 1退货退款
* - 2退款
*/
private Integer serviceType;
/**
* 退款类型 转换值
*/
private String serviceTypeText;
/**
* 状态
*
* - 1退货申请
* - 2申请成功
* - 3申请失败
* - 4退货中
* - 5退货成功
*/
private Integer status;
}
}

View File

@ -20,4 +20,8 @@ public class DictKeyConstants {
* 订单 - 退货原因
*/
public static final String ORDER_RETURN_REASON = "order_return_reason";
/**
* 订单退货 - 退货类型
*/
public static final String ORDER_RETURN_SERVICE_TYPE = "order_return_service_type";
}

View File

@ -32,7 +32,8 @@ public enum OrderErrorCodeEnum {
ORDER_ITEM_ONLY_ONE(1008000200, "订单Item只有一个!"),
ORDER_ITEM_SOME_NOT_EXISTS(1008000201, "有不存在的商品!"),
// 订单退货
ORDER_RETURN_NO_RETURN_APPLY(1008000400, "未退货申请"),
// ========== 购物车 ==========
CARD_ITEM_NOT_FOUND(1008003000, "购物车项不存在"),
@ -41,6 +42,8 @@ public enum OrderErrorCodeEnum {
// 工具类服务 1008004000
DICT_SERVER_INVOKING_FAIL(1008004000, "字典服务调用失败!"),
;
private final int code;

View File

@ -0,0 +1,36 @@
package cn.iocoder.mall.order.api.constant;
/**
* 订单退货 - returnType
*
* @author Sin
* @time 2019-04-27 11:53
*/
public enum OrderReturnReturnTypeEnum {
/**
* 状态
*
* - 1退货退款
* - 2退款
*/
RETURN_REFUND(1, "退货退款"),
REFUND(2, "退款")
;
private final int value;
private final String name;
OrderReturnReturnTypeEnum(int value, String name) {
this.value = value;
this.name = name;
}
public int getValue() {
return value;
}
public String getName() {
return name;
}
}

View File

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

View File

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

View File

@ -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;
/**
* 状态
*

View File

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

View File

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

View File

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

View File

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

View File

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