Bladeren bron

订单规则配置相关代码提交

wangzhijun 1 dag geleden
bovenliggende
commit
ca15c9ac0e

+ 2 - 1
nightFragrance-massage/src/main/java/com/ylx/fareSetting/controller/MaProjectFareSettingController.java

@@ -7,6 +7,7 @@ import com.ylx.fareSetting.service.IMaProjectFareSettingService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -24,7 +25,7 @@ public class MaProjectFareSettingController {
     @Resource
     private IMaProjectFareSettingService maProjectFareSettingService;
 
-
+    @PreAuthorize("@customerAuth.isCustomer()")
     @PostMapping("/calculate")
     @ApiOperation("下单前计算打车费")
     public R<FareCalculateResultVO> calculate(@Validated @RequestBody FareCalculateDTO dto) {

+ 32 - 0
nightFragrance-massage/src/main/java/com/ylx/order/controller/RefundController.java

@@ -0,0 +1,32 @@
+package com.ylx.order.controller;
+
+import com.ylx.common.core.domain.R;
+import com.ylx.order.domain.vo.RegulationConfigVO;
+import com.ylx.order.service.RegulationService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@RequestMapping("/order/refund")
+@Api(tags = {"订单退款模块"})
+@Slf4j
+public class RefundController {
+
+    @Resource
+    private RegulationService regulationService;
+
+    @ApiOperation("根据商户履约状态获取退款描述")
+    @GetMapping("/desc/list")
+    public R<List<RegulationConfigVO>> getDescList(Integer execStatus) {
+        List<RegulationConfigVO> list = this.regulationService.getDescListByExecStatus(execStatus);
+        return R.ok(list);
+    }
+
+}

+ 0 - 2
nightFragrance-massage/src/main/java/com/ylx/order/controller/RegulationController.java

@@ -2,8 +2,6 @@ package com.ylx.order.controller;
 
 import com.ylx.common.core.domain.R;
 import com.ylx.order.domain.dto.RegulationConfigDTO;
-import com.ylx.order.service.AutoFlowConfigService;
-import com.ylx.order.service.RefundRuleMasterService;
 import com.ylx.order.service.RegulationService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;

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

@@ -0,0 +1,29 @@
+package com.ylx.order.domain.vo;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.ylx.giftCard.domain.GiftCard;
+import com.ylx.order.domain.RefundRuleDetail;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+@ApiModel("订单退款规则配置VO")
+@Data
+public class RegulationConfigVO {
+
+    /**
+     * 退款规则描述
+     */
+    private String refundDesc;
+
+    /**
+     * 前端展示排序
+     */
+    private Integer sortOrder;
+
+
+    public RegulationConfigVO(RefundRuleDetail entity) {
+        this.refundDesc = entity.getRefundDesc();
+        this.sortOrder = entity.getSortOrder();
+    }
+
+}

+ 3 - 3
nightFragrance-massage/src/main/java/com/ylx/order/enums/RefundStageTypeEnum.java

@@ -5,9 +5,9 @@ import lombok.Getter;
 @Getter
 public enum RefundStageTypeEnum {
 
-    PRE_DEPARTURE(0, "技师未出发前"),
-    ON_THE_WAY(1, "商户已出发(途中)"),
-    IN_SERVICE(2, "服务进行中");
+    PRE_DEPARTURE(0, "商户未出发前"),
+    ON_THE_WAY(1, "商户已出发"),
+    IN_SERVICE(2, "服务中订单");
 
     private final Integer code;
     private final String info;

+ 5 - 0
nightFragrance-massage/src/main/java/com/ylx/order/service/RegulationService.java

@@ -1,9 +1,14 @@
 package com.ylx.order.service;
 
 import com.ylx.order.domain.dto.RegulationConfigDTO;
+import com.ylx.order.domain.vo.RegulationConfigVO;
+
+import java.util.List;
 
 public interface RegulationService {
     void saveFullConfig(RegulationConfigDTO dto);
 
     RegulationConfigDTO getFullConfig();
+
+    List<RegulationConfigVO> getDescListByExecStatus(Integer execStatus);
 }

+ 12 - 0
nightFragrance-massage/src/main/java/com/ylx/order/service/impl/RefundRuleMasterServiceImpl.java

@@ -246,6 +246,17 @@ public class RefundRuleMasterServiceImpl extends ServiceImpl<RefundRuleMasterMap
         detail.setCreateBy(operator);
         detail.setCreateTime(DateUtils.getNowDate());
 
+        Integer type = ruleItem.getRefundType();
+        BigDecimal percent = ruleItem.getRefundPercent();
+
+        String desc;
+        if (type != null && type == 0) {
+            desc = stageDesc + "全额退款";
+        } else {
+            desc = String.format(stageDesc + ",不再支持全额退款,只退实付金额的%s%%", percent);
+        }
+        detail.setRefundDesc(desc);
+
         targetList.add(detail);
 
         // 3. 处理完成日志
@@ -290,6 +301,7 @@ public class RefundRuleMasterServiceImpl extends ServiceImpl<RefundRuleMasterMap
 
     /**
      * 根据时间段规则项生成对应的中文描述
+     *
      * @param item 规则项(包含开始时间、结束时间、比例)
      * @return 格式化后的文案
      */

+ 24 - 0
nightFragrance-massage/src/main/java/com/ylx/order/service/impl/RegulationServiceImpl.java

@@ -1,7 +1,12 @@
 package com.ylx.order.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.ylx.order.domain.RefundRuleDetail;
 import com.ylx.order.domain.dto.RegulationConfigDTO;
+import com.ylx.order.domain.vo.RegulationConfigVO;
 import com.ylx.order.service.AutoFlowConfigService;
+import com.ylx.order.service.RefundRuleDetailService;
 import com.ylx.order.service.RefundRuleMasterService;
 import com.ylx.order.service.RegulationService;
 import lombok.extern.slf4j.Slf4j;
@@ -9,6 +14,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
 
 @Slf4j
 @Service
@@ -18,6 +26,8 @@ public class RegulationServiceImpl implements RegulationService {
     private AutoFlowConfigService autoFlowConfigService;
     @Resource
     private RefundRuleMasterService refundRuleMasterService;
+    @Resource
+    private RefundRuleDetailService refundRuleDetailService;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -44,4 +54,18 @@ public class RegulationServiceImpl implements RegulationService {
         this.refundRuleMasterService.loadRefundRules(dto);
         return dto;
     }
+
+    @Override
+    public List<RegulationConfigVO> getDescListByExecStatus(Integer execStatus) {
+        LambdaQueryWrapper<RefundRuleDetail> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(RefundRuleDetail::getStageType, execStatus)
+                .orderByAsc(RefundRuleDetail::getSortOrder);
+        List<RefundRuleDetail> list = this.refundRuleDetailService.list(wrapper);
+        if (CollUtil.isNotEmpty(list)){
+            return list.stream()
+                    .map(RegulationConfigVO::new)
+                    .collect(Collectors.toList());
+        }
+        return Collections.emptyList();
+    }
 }