From b9371ee62d1f24c667b1d5b1df504ebb59a2289d Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期一, 19 一月 2026 18:06:30 +0800
Subject: [PATCH] 小程序   接口开发

---
 server/dmmall_service/src/main/java/com/doumee/dao/web/response/MailConfigResponse.java         |   34 +++++++++++
 server/dmmall_service/src/main/java/com/doumee/core/utils/Constants.java                        |    5 +
 server/dmmall_service/src/main/java/com/doumee/dao/web/response/goods/MemberOrderResponse.java  |    2 
 server/dmmall_service/src/main/java/com/doumee/dao/business/model/Goodsorder.java               |    7 ++
 server/dmmall_service/src/main/java/com/doumee/biz/system/SystemDictDataBiz.java                |    3 +
 server/dmmall_service/src/main/java/com/doumee/biz/system/impl/SystemDictDataBizImpl.java       |   51 +++++++++++++++-
 server/dmmall_service/src/main/java/com/doumee/service/business/impl/GoodsorderServiceImpl.java |   35 ++++++-----
 7 files changed, 117 insertions(+), 20 deletions(-)

diff --git a/server/dmmall_service/src/main/java/com/doumee/biz/system/SystemDictDataBiz.java b/server/dmmall_service/src/main/java/com/doumee/biz/system/SystemDictDataBiz.java
index d5244d5..0330b32 100644
--- a/server/dmmall_service/src/main/java/com/doumee/biz/system/SystemDictDataBiz.java
+++ b/server/dmmall_service/src/main/java/com/doumee/biz/system/SystemDictDataBiz.java
@@ -1,6 +1,7 @@
 package com.doumee.biz.system;
 
 import com.doumee.dao.system.model.SystemDictData;
+import com.doumee.dao.web.response.MailConfigResponse;
 
 import java.util.List;
 
@@ -40,4 +41,6 @@
    * @return
    */
   SystemDictData findCoffeeArticleBackground(String codes);
+
+  MailConfigResponse getMailConfig();
 }
diff --git a/server/dmmall_service/src/main/java/com/doumee/biz/system/impl/SystemDictDataBizImpl.java b/server/dmmall_service/src/main/java/com/doumee/biz/system/impl/SystemDictDataBizImpl.java
index d81be9c..bee76a0 100644
--- a/server/dmmall_service/src/main/java/com/doumee/biz/system/impl/SystemDictDataBizImpl.java
+++ b/server/dmmall_service/src/main/java/com/doumee/biz/system/impl/SystemDictDataBizImpl.java
@@ -7,6 +7,7 @@
 import com.doumee.core.utils.Constants;
 import com.doumee.dao.system.model.SystemDict;
 import com.doumee.dao.system.model.SystemDictData;
+import com.doumee.dao.web.response.MailConfigResponse;
 import com.doumee.service.system.SystemDictDataService;
 import com.doumee.service.system.SystemDictService;
 import org.apache.commons.lang3.StringUtils;
@@ -15,10 +16,8 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Optional;
+import java.math.BigDecimal;
+import java.util.*;
 
 @Service
 public class SystemDictDataBizImpl implements SystemDictDataBiz {
@@ -168,4 +167,48 @@
         one.setCode(path+one.getCode());
         return one;
     }
+
+
+
+    @Override
+    public MailConfigResponse getMailConfig(){
+        MailConfigResponse mailConfigResponse = new MailConfigResponse();
+
+        SystemDictData systemDictData = new SystemDictData();
+        systemDictData.setDeleted(Boolean.FALSE);
+        systemDictData.setLabel(Constants.FIRST_WEIGHT);
+        SystemDictData one = systemDictDataService.findOne(systemDictData);
+        if(Objects.isNull(one)){
+            throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "鏁版嵁鍊间笉瀛樺湪");
+        }
+        mailConfigResponse.setFee0(new BigDecimal(one.getCode()));
+        systemDictData.setLabel(Constants.CONTINUE_FEE);
+        one = systemDictDataService.findOne(systemDictData);
+        if(Objects.isNull(one)){
+            throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "鏁版嵁鍊间笉瀛樺湪");
+        }
+        mailConfigResponse.setFee1(new BigDecimal(one.getCode()));
+
+        systemDictData.setLabel(Constants.FIRST_WEIGHT);
+        one = systemDictDataService.findOne(systemDictData);
+        if(Objects.isNull(one)){
+            throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "鏁版嵁鍊间笉瀛樺湪");
+        }
+        mailConfigResponse.setWeight0(new BigDecimal(one.getCode()));
+
+        systemDictData.setLabel(Constants.CONTINUE_WEIGHT);
+        one = systemDictDataService.findOne(systemDictData);
+        if(Objects.isNull(one)){
+            throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(), "鏁版嵁鍊间笉瀛樺湪");
+        }
+
+        mailConfigResponse.setWeight1(new BigDecimal(one.getCode()));
+
+
+
+        return mailConfigResponse;
+
+
+    }
+
 }
diff --git a/server/dmmall_service/src/main/java/com/doumee/core/utils/Constants.java b/server/dmmall_service/src/main/java/com/doumee/core/utils/Constants.java
index 88b1ebf..be04e8f 100644
--- a/server/dmmall_service/src/main/java/com/doumee/core/utils/Constants.java
+++ b/server/dmmall_service/src/main/java/com/doumee/core/utils/Constants.java
@@ -77,6 +77,11 @@
     public static final String CASH_EXCHANGE_INTEGRAL_RATA = "CASH_EXCHANGE_INTEGRAL_RATA";//鐜伴噾-绉垎鍏戞崲姣斾緥锛�1鍏冨彲寰楀埌XXX绉垎锛�
 
 
+    public static final String MAIL_CONFIG = "MAIL_CONFIG";
+    public static final String FIRST_WEIGHT = "FIRST_WEIGHT";
+    public static final String CONTINUE_WEIGHT = "CONTINUE_WEIGHT";
+    public static final String FIRST_FEE = "FIRST_FEE";
+    public static final String CONTINUE_FEE = "CONTINUE_FEE";
 
 
     public static final String INITIAL_ROLE = "INITIAL_ROLE";
diff --git a/server/dmmall_service/src/main/java/com/doumee/dao/business/model/Goodsorder.java b/server/dmmall_service/src/main/java/com/doumee/dao/business/model/Goodsorder.java
index 3472592..959dc2a 100644
--- a/server/dmmall_service/src/main/java/com/doumee/dao/business/model/Goodsorder.java
+++ b/server/dmmall_service/src/main/java/com/doumee/dao/business/model/Goodsorder.java
@@ -205,6 +205,13 @@
     @ApiModelProperty(value = "缁忛攢鍟嗙粨绠楅噾棰�", example = "1")
     private BigDecimal shopSettlement;
 
+    @ApiModelProperty(value = "杩旇繕缁忛攢鍟嗙Н鍒�", example = "1")
+    private BigDecimal returnCustomerIntegral;
+
+    @ApiModelProperty(value = "杩旇繕鐢ㄦ埛绉垎", example = "1")
+    private BigDecimal returnMemberIntegral;
+
+
     @ApiModelProperty(value = "鏂囦欢鍦板潃")
     @TableField(exist = false)
     private String resourcePath;
diff --git a/server/dmmall_service/src/main/java/com/doumee/dao/web/response/MailConfigResponse.java b/server/dmmall_service/src/main/java/com/doumee/dao/web/response/MailConfigResponse.java
new file mode 100644
index 0000000..034b84a
--- /dev/null
+++ b/server/dmmall_service/src/main/java/com/doumee/dao/web/response/MailConfigResponse.java
@@ -0,0 +1,34 @@
+package com.doumee.dao.web.response;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * Created by IntelliJ IDEA.
+ *
+ * @Author : Rk
+ * @create 2023/3/23 9:50
+ */
+@Data
+@ApiModel("閭垂閰嶇疆淇℃伅")
+public class MailConfigResponse {
+
+    @ApiModelProperty(value = "棣栭噸")
+    private BigDecimal weight0;
+
+    @ApiModelProperty(value = "棣栭噸杩愯垂")
+    private BigDecimal fee0;
+
+    @ApiModelProperty(value = "缁噸")
+    private BigDecimal weight1;
+
+    @ApiModelProperty(value = "缁噸杩愯垂")
+    private BigDecimal fee1;
+
+
+}
diff --git a/server/dmmall_service/src/main/java/com/doumee/dao/web/response/goods/MemberOrderResponse.java b/server/dmmall_service/src/main/java/com/doumee/dao/web/response/goods/MemberOrderResponse.java
index a076e15..d84ed79 100644
--- a/server/dmmall_service/src/main/java/com/doumee/dao/web/response/goods/MemberOrderResponse.java
+++ b/server/dmmall_service/src/main/java/com/doumee/dao/web/response/goods/MemberOrderResponse.java
@@ -90,7 +90,7 @@
     @ApiModelProperty(value = "鏍搁攢鐮�", example = "1")
     private String exchangeCode;
 
-    @ApiModelProperty(value = "鎶垫墸閲戦", example = "1")
+    @ApiModelProperty(value = "绉垎鎶垫墸閲戦", example = "1")
     private BigDecimal integral;
 
     @ApiModelProperty(value = "蹇�掑悕绉�", example = "1")
diff --git a/server/dmmall_service/src/main/java/com/doumee/service/business/impl/GoodsorderServiceImpl.java b/server/dmmall_service/src/main/java/com/doumee/service/business/impl/GoodsorderServiceImpl.java
index f098231..0753bde 100644
--- a/server/dmmall_service/src/main/java/com/doumee/service/business/impl/GoodsorderServiceImpl.java
+++ b/server/dmmall_service/src/main/java/com/doumee/service/business/impl/GoodsorderServiceImpl.java
@@ -1,5 +1,6 @@
 package com.doumee.service.business.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.doumee.biz.system.SystemDictDataBiz;
@@ -24,6 +25,7 @@
 import com.doumee.dao.web.request.*;
 import com.doumee.dao.web.request.goods.*;
 import com.doumee.dao.web.response.HomeInfoResponse;
+import com.doumee.dao.web.response.MailConfigResponse;
 import com.doumee.dao.web.response.MyPageResponse;
 import com.doumee.dao.web.response.goods.*;
 import com.doumee.service.business.AreasService;
@@ -814,6 +816,8 @@
                     .eq(MemberCoupon::getId,orderPayConfirmResponse.getMemberCoupon().getId())
             );
         }
+        goodsorder.setReturnCustomerIntegral(getBackIntegral(goodsorder.getPrice(),Constants.ONE));
+        goodsorder.setReturnMemberIntegral(getBackIntegral(goodsorder.getPrice(),Constants.ZERO));
         goodsorderMapper.insert(goodsorder);
         List<OrderGoodsCalculateResponse> goodsCalculateList  = orderPayConfirmResponse.getGoodsCalculateList();
         if(CollectionUtils.isEmpty(goodsCalculateList)){
@@ -1389,6 +1393,7 @@
         //閭垂閲戦
         if(Objects.nonNull(request.getReceiveType())){
             if(Constants.equalsInteger(request.getReceiveType(),Constants.ZERO)){
+                MailConfigResponse mailConfigResponse = systemDictDataBiz.getMailConfig();
                 if(Objects.nonNull(request.getAddressId())){
                     Addr addr = addrMapper.selectById(request.getAddressId());
                     if(Objects.isNull(addr)){
@@ -1404,28 +1409,28 @@
                         Labels  labels = labelsMapper.selectById(areas.getYunFeeId());
                         if(Objects.nonNull(labels)&&StringUtils.isNotBlank(labels.getParam())){
                             //{weight0:10,fee0:10,weight1:10,fee1:10},{棣栭噸:10,棣栭噸杩愯垂锛�10,缁噸锛�10,缁噸璐癸細10}
-
+                            mailConfigResponse = JSONObject.parseObject(labels.getParam(),MailConfigResponse.class);
                         }
-
                     }
-
-
-
                 }
-
-
-
-                //TODO  鏍规嵁鏀惰揣鍦板潃 鏌ヨ杩愯垂閰嶇疆
-
-
-
+                //鏍规嵁鏀惰揣鍦板潃 鏌ヨ杩愯垂閰嶇疆
                 //璁$畻鍟嗗搧淇℃伅鎬婚噸閲�
                 BigDecimal totalWeight = goodsCalculateList.stream().map(i->
                         i.getWeight().multiply(new BigDecimal(i.getGoodsNum().toString()))
                 ).reduce(BigDecimal.ZERO,BigDecimal::add);
-                //TODO 鏆傛椂鏃犺繍璐归噾棰�
-                mailAmount = BigDecimal.ZERO;
-
+                if(totalWeight.compareTo(mailConfigResponse.getWeight0())>=Constants.ZERO){
+                    mailAmount = mailConfigResponse.getFee0();
+                }else{
+                    //瓒呴噸閲嶉噺
+                    BigDecimal overWeight = totalWeight.subtract(mailConfigResponse.getWeight0());
+                    if (overWeight.compareTo(mailConfigResponse.getWeight1()) >= Constants.ZERO) {
+                        mailAmount = mailConfigResponse.getFee0().add(
+                                mailConfigResponse.getFee1()
+                                .multiply(overWeight.divide(mailConfigResponse.getWeight1(),2,RoundingMode.HALF_UP)));
+                    }else{
+                        mailAmount = mailConfigResponse.getFee0().add(mailConfigResponse.getFee1());
+                    }
+                }
                 amount = amount.add(mailAmount);
             }
         }

--
Gitblit v1.9.3