Эх сурвалжийг харах

提交“申请退款页面数据”接口

wangzhijun 1 өдөр өмнө
parent
commit
74157ffe06

+ 9 - 21
nightFragrance-massage/src/main/java/com/ylx/order/controller/AfterSalesServiceController.java

@@ -6,12 +6,10 @@ import com.ylx.common.core.domain.R;
 import com.ylx.common.core.domain.entity.SysDictData;
 import com.ylx.common.utils.DictUtils;
 import com.ylx.order.domain.dto.AfterSalesServiceDTO;
-import com.ylx.order.domain.vo.RefundCalculationVO;
-import com.ylx.order.domain.vo.RegulationConfigVO;
+import com.ylx.order.domain.vo.AfterSalesServiceApplyVO;
 import com.ylx.order.domain.vo.AfterSalesServiceDetailVO;
 import com.ylx.order.enums.AfterSaleServiceDictTypeEnum;
 import com.ylx.order.service.IAfterSalesServiceService;
-import com.ylx.order.service.RegulationService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -30,8 +28,6 @@ import java.util.List;
 @Slf4j
 public class AfterSalesServiceController {
 
-    @Resource
-    private RegulationService regulationService;
     @Resource
     private IAfterSalesServiceService afterSalesServiceService;
 
@@ -59,6 +55,14 @@ public class AfterSalesServiceController {
         return R.ok(list);
     }
 
+    @PreAuthorize("@customerAuth.isCustomer()")
+    @ApiOperation("客户端用户申请退款页面数据接口")
+    @PostMapping("/apply")
+    public R<AfterSalesServiceApplyVO> applyAfterSale(@Validated @RequestBody AfterSalesServiceDTO dto) {
+        AfterSalesServiceApplyVO vo = this.afterSalesServiceService.applyAfterSale(dto);
+        return R.ok(vo);
+    }
+
     @PreAuthorize("@customerAuth.isCustomer()")
     @ApiOperation("客户端用户提交退款")
     @PostMapping("/submit")
@@ -67,14 +71,6 @@ public class AfterSalesServiceController {
         return R.ok();
     }
 
-    @PreAuthorize("@customerAuth.isCustomer()")
-    @ApiOperation("客户端发起售后计算退款金额")
-    @PostMapping("/calculate/refund")
-    public R<RefundCalculationVO> calculateRefund(@Validated @RequestBody AfterSalesServiceDTO dto) {
-        RefundCalculationVO vo = this.afterSalesServiceService.calculateRefund(dto);
-        return R.ok(vo);
-    }
-
     @PreAuthorize("@customerAuth.isCustomer()")
     @ApiOperation("客户端查看售后单详情")
     @GetMapping("/detail/{id}")
@@ -83,12 +79,4 @@ public class AfterSalesServiceController {
         return R.ok(vo);
     }
 
-
-    @ApiOperation("根据商户履约状态获取退款描述")
-    @GetMapping("/desc/list")
-    public R<List<RegulationConfigVO>> getDescList(Integer execStatus) {
-        List<RegulationConfigVO> list = this.regulationService.getDescListByExecStatus(execStatus);
-        return R.ok(list);
-    }
-
 }

+ 29 - 0
nightFragrance-massage/src/main/java/com/ylx/order/domain/vo/AfterSalesServiceApplyVO.java

@@ -0,0 +1,29 @@
+package com.ylx.order.domain.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@ApiModel("售后服务申请VO")
+@Data
+public class AfterSalesServiceApplyVO {
+
+    @ApiModelProperty("退款规则提示")
+    private List<RegulationConfigVO> refundRules;
+
+    @ApiModelProperty("商品信息")
+    private String productName;
+
+    @ApiModelProperty("商品单价")
+    private BigDecimal productPrice;
+
+    @ApiModelProperty("商品购买数量")
+    private Integer productQuantity = 1;
+
+    @ApiModelProperty("退款金额")
+    private BigDecimal refundAmount;
+
+}

+ 3 - 0
nightFragrance-massage/src/main/java/com/ylx/order/service/IAfterSalesServiceService.java

@@ -3,6 +3,7 @@ package com.ylx.order.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ylx.order.domain.AfterSalesService;
 import com.ylx.order.domain.dto.AfterSalesServiceDTO;
+import com.ylx.order.domain.vo.AfterSalesServiceApplyVO;
 import com.ylx.order.domain.vo.RefundCalculationVO;
 import com.ylx.order.domain.vo.AfterSalesServiceDetailVO;
 
@@ -12,4 +13,6 @@ public interface IAfterSalesServiceService extends IService<AfterSalesService> {
     RefundCalculationVO calculateRefund(AfterSalesServiceDTO dto);
 
     AfterSalesServiceDetailVO getDetailById(Long id);
+
+    AfterSalesServiceApplyVO applyAfterSale(AfterSalesServiceDTO dto);
 }

+ 43 - 8
nightFragrance-massage/src/main/java/com/ylx/order/service/impl/AfterSalesServiceServiceImpl.java

@@ -13,14 +13,17 @@ import com.ylx.order.domain.AfterSalesService;
 import com.ylx.order.domain.RefundRuleDetail;
 import com.ylx.order.domain.TOrder;
 import com.ylx.order.domain.dto.AfterSalesServiceDTO;
+import com.ylx.order.domain.vo.AfterSalesServiceApplyVO;
 import com.ylx.order.domain.vo.RefundCalculationVO;
 import com.ylx.order.domain.vo.AfterSalesServiceDetailVO;
+import com.ylx.order.domain.vo.RegulationConfigVO;
 import com.ylx.order.enums.AfterSaleServiceStatusEnum;
 import com.ylx.order.enums.OrderStatusEnum;
 import com.ylx.order.enums.RefundStageTypeEnum;
 import com.ylx.order.mapper.AfterSalesServiceMapper;
 import com.ylx.order.service.IAfterSalesServiceService;
 import com.ylx.order.service.RefundRuleDetailService;
+import com.ylx.order.service.RegulationService;
 import com.ylx.order.service.TOrderService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -50,6 +53,8 @@ public class AfterSalesServiceServiceImpl extends ServiceImpl<AfterSalesServiceM
     private TOrderService tOrderService;
     @Resource
     private RefundRuleDetailService refundRuleDetailService;
+    @Resource
+    private RegulationService regulationService;
 
     // ===================== 业务常量 =====================
     /**
@@ -75,10 +80,7 @@ public class AfterSalesServiceServiceImpl extends ServiceImpl<AfterSalesServiceM
 
         // 2. 订单存在 & 权限校验
         Long orderId = dto.getOrderId();
-        TOrder order = tOrderService.getById(orderId);
-        if (ObjectUtil.isNull(order) || ObjectUtil.equals(1, order.getIsDelete())) {
-            throw new ServiceException("订单不存在");
-        }
+        TOrder order = getOrder(orderId);
         if (!currentUserId.equals(order.getUserId())) {
             throw new ServiceException("无权操作他人订单");
         }
@@ -105,10 +107,7 @@ public class AfterSalesServiceServiceImpl extends ServiceImpl<AfterSalesServiceM
     @Override
     public RefundCalculationVO calculateRefund(AfterSalesServiceDTO dto) {
         Long orderId = dto.getOrderId();
-        TOrder order = tOrderService.getById(orderId);
-        if (ObjectUtil.isNull(order) || ObjectUtil.equals(1, order.getIsDelete())) {
-            throw new ServiceException("订单不存在");
-        }
+        TOrder order = getOrder(orderId);
         return calculateRefund(order);
     }
 
@@ -121,6 +120,42 @@ public class AfterSalesServiceServiceImpl extends ServiceImpl<AfterSalesServiceM
         return detailVO;
     }
 
+    @Override
+    public AfterSalesServiceApplyVO applyAfterSale(AfterSalesServiceDTO dto) {
+
+        AfterSalesServiceApplyVO vo = new AfterSalesServiceApplyVO();
+
+        // 1. 获取订单数据
+        Long orderId = dto.getOrderId();
+        TOrder order = this.getOrder(orderId);
+
+        Integer stageType = resolveRefundStageType(order);
+
+        // 2. 根据订单的流转状态获取退款说明
+        List<RegulationConfigVO> descListByExecStatus = regulationService.getDescListByExecStatus(stageType);
+        vo.setRefundRules(descListByExecStatus);
+
+        // 3. 设置产品信息
+        vo.setProductName(order.getProjectName());
+        vo.setProductPrice(order.getFinalAmount());
+
+        // 3. 根据订单的流转状态获取退款金额
+        RefundCalculationVO refundCalculationVO = this.calculateRefund(dto);
+        if(ObjectUtil.isNotNull(refundCalculationVO)){
+            vo.setRefundAmount(refundCalculationVO.getRefundAmount());
+        }
+
+        return vo;
+    }
+
+    private TOrder getOrder(Long orderId) {
+        TOrder order = tOrderService.getById(orderId);
+        if (ObjectUtil.isNull(order) || ObjectUtil.equals(1, order.getIsDelete())) {
+            throw new ServiceException("订单不存在");
+        }
+        return order;
+    }
+
     // ===================== 校验类私有方法 =====================
 
     /**