Explorar o código

Merge remote-tracking branch 'origin/point_dev' into point_dev

jinshihui hai 5 días
pai
achega
8a3eb83762

+ 14 - 1
nightFragrance-admin/src/main/java/com/ylx/web/controller/massage/AfterSaleOrderController.java

@@ -3,8 +3,10 @@ package com.ylx.web.controller.massage;
 import com.ylx.common.annotation.Log;
 import com.ylx.common.core.domain.R;
 import com.ylx.common.enums.BusinessType;
+import com.ylx.massage.domain.dto.AfterSaleOrderDTO;
 import com.ylx.massage.domain.dto.AfterSaleOrderFeeBatchDTO;
 import com.ylx.massage.service.IAfterSaleOrderFeeService;
+import com.ylx.massage.service.IAfterSaleOrderService;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.validation.annotation.Validated;
@@ -23,13 +25,24 @@ public class AfterSaleOrderController {
     @Resource
     private IAfterSaleOrderFeeService afterSaleOrderFeeService;
 
+    @Resource
+    private IAfterSaleOrderService afterSaleOrderService;
+
 
     @ApiOperation("批量添加售后费用")
     @Log(title = "批量添加售后费用", businessType = BusinessType.INSERT)
     @PostMapping("/fee/batch")
-    public R add(@Validated @RequestBody AfterSaleOrderFeeBatchDTO batchDTO) {
+    public R addFee(@Validated @RequestBody AfterSaleOrderFeeBatchDTO batchDTO) {
         this.afterSaleOrderFeeService.batchSaveFees(batchDTO);
         return R.ok();
     }
 
+    @ApiOperation("发起售后")
+    @Log(title = "发起售后", businessType = BusinessType.INSERT)
+    @PostMapping
+    public R add(@Validated @RequestBody AfterSaleOrderDTO dto) {
+        this.afterSaleOrderService.add(dto);
+        return R.ok();
+    }
+
 }

+ 1 - 1
nightFragrance-admin/src/main/java/com/ylx/web/controller/massage/ProductOrderController.java

@@ -156,7 +156,7 @@ public class ProductOrderController extends BaseController {
     @PreAuthorize("@ss.hasPermi('product:order:query')")
     @GetMapping("/admin/detail/{orderId}")
     @ApiOperation("积分订单管理详情接口")
-    public R<ProductOrderDetailAdminVo> getOrderDetailForAdmin(@PathVariable String orderId) {
+    public R<ProductOrderDetailAdminVo> getOrderDetailForAdmin(@PathVariable Long orderId) {
         ProductOrderDetailAdminVo detailVO = productOrderInfoService.getOrderDetailForAdmin(orderId);
         return R.ok(detailVO);
     }

+ 3 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/domain/AfterSaleOrder.java

@@ -99,6 +99,9 @@ public class AfterSaleOrder implements Serializable {
     /** 售后完成时间 */
     private LocalDateTime finishTime;
 
+    /** 快递单号 */
+    private String logisticsNo;
+
     /** 备注 */
     private String remark;
 

+ 39 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/domain/dto/AfterSaleOrderDTO.java

@@ -0,0 +1,39 @@
+package com.ylx.massage.domain.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+@Data
+@ApiModel(description = "售后添加请求")
+public class AfterSaleOrderDTO {
+
+    @NotNull(message = "订单ID不能为空")
+    @ApiModelProperty(value = "订单ID", required = true)
+    private Long orderId;
+
+    @NotBlank(message = "订单编号不能为空")
+    @ApiModelProperty(value = "订单编号", required = true)
+    private String orderNo;
+
+    @NotNull(message = "收货状态不能为空")
+    @ApiModelProperty(value = "收货状态(1:未收货 2:已收货)", required = true)
+    private Integer receiptStatus;
+
+    @NotNull(message = "申请原因不能为空")
+    @ApiModelProperty(value = "申请原因", required = true)
+    private Integer applyReason;
+
+    @ApiModelProperty(value = "售后类型 (1退货 2换货)")
+    private Integer afterSaleType;
+
+    @ApiModelProperty(value = "问题描述")
+    private String applyDesc;
+
+    @ApiModelProperty(value = "凭证图片URL,多个逗号分隔")
+    private String applyImages;
+
+}

+ 6 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/domain/vo/OrderBaseInfoVo.java

@@ -35,6 +35,12 @@ public class OrderBaseInfoVo {
     @ApiModelProperty("实付金额")
     private BigDecimal payAmount;
 
+    @ApiModelProperty("使用积分数量")
+    private Integer pointsUsed;
+
+    @ApiModelProperty("付款类型(1:积分 2:金额 3:积分+金额)")
+    private Integer paymentType;
+
     @ApiModelProperty("电话号码")
     private String phone;
 

+ 6 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/domain/vo/OrderItemVo.java

@@ -31,4 +31,10 @@ public class OrderItemVo {
     @ApiModelProperty("实付")
     private BigDecimal payAmount;
 
+    @ApiModelProperty("使用积分数量")
+    private Integer pointsUsed;
+
+    @ApiModelProperty("付款类型(1:积分 2:金额 3:积分+金额)")
+    private Integer paymentType;
+
 }

+ 30 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/enums/AfterSaleStatusEnum.java

@@ -0,0 +1,30 @@
+package com.ylx.massage.enums;
+
+import lombok.Getter;
+
+@Getter
+public enum AfterSaleStatusEnum {
+
+    WAIT_AUDIT(0, "待审核"),
+
+    AUDIT_PASS(1, "审核通过"),
+
+    AUDIT_REJECT(2, "审核拒绝"),
+
+    WAIT_BUYER_RETURN(3, "待买家退货"),
+
+    WAIT_MERCHANT_RECEIVE(4, "待商家收货"),
+
+    REFUND_PROCESSING(5, "退款处理中"),
+
+    COMPLETE(6, "售后完成");
+
+    private final Integer code;
+
+    private final String desc;
+
+    AfterSaleStatusEnum(Integer code, String desc) {
+        this.code = code;
+        this.desc = desc;
+    }
+}

+ 14 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/mapper/AfterSaleOrderMapper.java

@@ -0,0 +1,14 @@
+package com.ylx.massage.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ylx.massage.domain.AfterSaleOrder;
+import com.ylx.massage.domain.vo.OrderAfterSaleVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+@Mapper
+public interface AfterSaleOrderMapper extends BaseMapper<AfterSaleOrder> {
+
+    OrderAfterSaleVo selectAfterSaleVoByOrderId(@Param("orderId") Long orderId);
+
+}

+ 14 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/service/IAfterSaleOrderService.java

@@ -0,0 +1,14 @@
+package com.ylx.massage.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ylx.massage.domain.AfterSaleOrder;
+import com.ylx.massage.domain.dto.AfterSaleOrderDTO;
+import com.ylx.massage.domain.vo.OrderAfterSaleVo;
+
+public interface IAfterSaleOrderService extends IService<AfterSaleOrder> {
+
+    void add(AfterSaleOrderDTO dto);
+
+    OrderAfterSaleVo getOrderAfterSaleVo(Long orderId);
+
+}

+ 1 - 1
nightFragrance-massage/src/main/java/com/ylx/massage/service/IProductOrderInfoService.java

@@ -61,7 +61,7 @@ public interface IProductOrderInfoService extends IService<ProductOrderInfo> {
 
     Page<ProductOrderPageItemVo> adminPage(Page<ProductOrderInfo> page, ProductOrderPageDTO dto);
 
-    ProductOrderDetailAdminVo getOrderDetailForAdmin(String orderId);
+    ProductOrderDetailAdminVo getOrderDetailForAdmin(Long orderId);
 
     ProductOrderCountVo adminPageStats();
 }

+ 13 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/service/impl/AfterSaleOrderFeeServiceImpl.java

@@ -2,15 +2,19 @@ package com.ylx.massage.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ylx.common.exception.ServiceException;
 import com.ylx.common.utils.DateUtils;
 import com.ylx.common.utils.SecurityUtils;
+import com.ylx.massage.domain.AfterSaleOrder;
 import com.ylx.massage.domain.AfterSaleOrderFee;
 import com.ylx.massage.domain.dto.AfterSaleOrderFeeBatchDTO;
 import com.ylx.massage.domain.dto.AfterSaleOrderFeeDTO;
 import com.ylx.massage.mapper.AfterSaleOrderFeeMapper;
 import com.ylx.massage.service.IAfterSaleOrderFeeService;
+import com.ylx.massage.service.IAfterSaleOrderService;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -24,11 +28,19 @@ public class AfterSaleOrderFeeServiceImpl extends ServiceImpl<AfterSaleOrderFeeM
 
     @Resource
     private AfterSaleOrderFeeMapper afterSaleOrderFeeMapper;
+    @Resource
+    private IAfterSaleOrderService afterSaleOrderService;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void batchSaveFees(AfterSaleOrderFeeBatchDTO batchDTO) {
         Long afterSaleOrderId = batchDTO.getAfterSaleOrderId();
+        AfterSaleOrder afterSaleOrder = this.afterSaleOrderService.getById(afterSaleOrderId);
+
+        if (ObjectUtil.isNull(afterSaleOrder)) {
+            throw new ServiceException("售后订单不存在");
+        }
+
         List<AfterSaleOrderFeeDTO> feeList = batchDTO.getFeeList();
 
         if (CollUtil.isEmpty(feeList)) {
@@ -53,6 +65,7 @@ public class AfterSaleOrderFeeServiceImpl extends ServiceImpl<AfterSaleOrderFeeM
                     .map(dto -> {
                         AfterSaleOrderFee entity = BeanUtil.copyProperties(dto, AfterSaleOrderFee.class);
                         entity.setAfterSaleOrderId(afterSaleOrderId);
+                        entity.setOrderNo(afterSaleOrder.getOrderNo());
                         entity.setCreateBy(SecurityUtils.getUsername());
                         entity.setCreateTime(DateUtils.getNowDate());
                         return entity;

+ 62 - 0
nightFragrance-massage/src/main/java/com/ylx/massage/service/impl/AfterSaleOrderServiceImpl.java

@@ -0,0 +1,62 @@
+package com.ylx.massage.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ylx.common.core.domain.model.WxLoginUser;
+import com.ylx.common.exception.ServiceException;
+import com.ylx.common.utils.SecurityUtils;
+import com.ylx.massage.domain.AfterSaleOrder;
+import com.ylx.massage.domain.dto.AfterSaleOrderDTO;
+import com.ylx.massage.domain.vo.OrderAfterSaleVo;
+import com.ylx.massage.enums.AfterSaleStatusEnum;
+import com.ylx.massage.mapper.AfterSaleOrderMapper;
+import com.ylx.massage.service.IAfterSaleOrderService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+
+@Service
+public class AfterSaleOrderServiceImpl extends ServiceImpl<AfterSaleOrderMapper, AfterSaleOrder> implements IAfterSaleOrderService {
+
+    @Resource
+    private AfterSaleOrderMapper afterSaleOrderMapper;
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void add(AfterSaleOrderDTO dto) {
+
+        // 1. 获取当前登录用户(公共方法提取)
+        WxLoginUser loginUser = getCurrentWxLoginUser();
+
+        // 2. 添加售后订单
+        AfterSaleOrder entity = new AfterSaleOrder();
+        BeanUtil.copyProperties(dto, entity);
+        entity.setOpenId(loginUser.getCOpenid());
+        entity.setCreateTime(LocalDateTime.now());
+        entity.setAfterSaleStatus(AfterSaleStatusEnum.WAIT_AUDIT.getCode());
+        entity.setAfterSaleNo(generateAfterSaleNo(dto.getOrderId()));
+
+        this.afterSaleOrderMapper.insert(entity);
+    }
+
+    @Override
+    public OrderAfterSaleVo getOrderAfterSaleVo(Long orderId) {
+        return this.afterSaleOrderMapper.selectAfterSaleVoByOrderId(orderId);
+    }
+
+    private WxLoginUser getCurrentWxLoginUser() {
+        WxLoginUser loginUser = SecurityUtils.getWxLoginUser();
+        if (ObjectUtil.isNull(loginUser)) {
+            throw new ServiceException("用户未登录或登录已过期");
+        }
+        return loginUser;
+    }
+
+    private String generateAfterSaleNo(Long orderId) {
+        return "AFTERSALE" + orderId + System.currentTimeMillis();
+    }
+
+}

+ 6 - 7
nightFragrance-massage/src/main/java/com/ylx/massage/service/impl/ProductOrderInfoServiceImpl.java

@@ -21,10 +21,7 @@ import com.ylx.massage.mapper.ProductMapper;
 import com.ylx.massage.mapper.ProductOrderInfoMapper;
 import com.ylx.massage.mapper.ProductOrderItemMapper;
 import com.ylx.massage.mapper.ProductSkuMapper;
-import com.ylx.massage.service.IProductOrderInfoService;
-import com.ylx.massage.service.TConsumptionLogService;
-import com.ylx.massage.service.TRechargeService;
-import com.ylx.massage.service.TWxUserService;
+import com.ylx.massage.service.*;
 import com.ylx.massage.utils.OrderNumberGenerator;
 import com.ylx.product.domain.ProductOrderAddress;
 import com.ylx.product.service.IProductOrderAddressService;
@@ -73,6 +70,8 @@ public class ProductOrderInfoServiceImpl extends ServiceImpl<ProductOrderInfoMap
 
     @Autowired
     private ProductSkuMapper productSkuMapper;
+    @Resource
+    private IAfterSaleOrderService afterSaleOrderService;
 
 
     /**
@@ -492,7 +491,7 @@ public class ProductOrderInfoServiceImpl extends ServiceImpl<ProductOrderInfoMap
     }
 
     @Override
-    public ProductOrderDetailAdminVo getOrderDetailForAdmin(String orderId) {
+    public ProductOrderDetailAdminVo getOrderDetailForAdmin(Long orderId) {
 
         ProductOrderInfo productOrderInfo = this.productOrderInfoMapper.selectById(orderId);
         if (ObjectUtil.isNull(productOrderInfo)) {
@@ -554,8 +553,8 @@ public class ProductOrderInfoServiceImpl extends ServiceImpl<ProductOrderInfoMap
         }
         vo.setOrderItemInfo(itemVo);
 
-        // 4. 售后列表
-        OrderAfterSaleVo orderAfterSaleVo = new OrderAfterSaleVo();
+        // 4. 售后信息
+        OrderAfterSaleVo orderAfterSaleVo = this.afterSaleOrderService.getOrderAfterSaleVo(orderId);
         vo.setAfterSaleInfo(orderAfterSaleVo);
 
         return vo;

+ 48 - 0
nightFragrance-massage/src/main/resources/mapper/massage/AfterSaleOrderMapper.xml

@@ -0,0 +1,48 @@
+<?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="com.ylx.massage.mapper.AfterSaleOrderMapper">
+
+    <!-- 费用VO映射 -->
+    <resultMap id="AfterSaleFeeResultMap" type="com.ylx.massage.domain.vo.AfterSaleOrderFeeVo">
+        <result column="type" property="type"/>
+        <result column="fee" property="fee"/>
+        <result column="remark" property="remark"/>
+    </resultMap>
+
+    <!-- 主VO映射 + 集合自动封装 feeList -->
+    <resultMap id="AfterSaleVoResultMap" type="com.ylx.massage.domain.vo.OrderAfterSaleVo">
+        <id column="id" property="id"/>
+        <result column="after_sale_type" property="afterSaleType"/>
+        <result column="create_time" property="createTime"/>
+        <result column="apply_reason" property="applyReason"/>
+        <result column="after_sale_status" property="afterSaleStatus"/>
+        <result column="logistics_no" property="logisticsNo"/>
+
+        <!-- 关键:自动封装 List<feeList> -->
+        <collection
+                property="feeList"
+                javaType="ArrayList"
+                ofType="com.ylx.massage.domain.vo.AfterSaleOrderFeeVo"
+                resultMap="AfterSaleFeeResultMap"/>
+    </resultMap>
+
+    <select id="selectAfterSaleVoByOrderId" resultMap="AfterSaleVoResultMap">
+        SELECT
+            a.id,
+            a.after_sale_type,
+            a.create_time,
+            a.apply_reason,
+            a.after_sale_status,
+            a.logistics_no,
+            f.type,
+            f.fee,
+            f.remark
+        FROM
+            after_sale_order a
+        LEFT JOIN after_sale_order_fee f ON a.id = f.after_sale_order_id
+        WHERE
+            a.order_id = #{orderId}
+        AND a.is_deleted = 0
+    </select>
+
+</mapper>