|
|
@@ -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;
|
|
|
+ }
|
|
|
+
|
|
|
// ===================== 校验类私有方法 =====================
|
|
|
|
|
|
/**
|