From e4f9739d74323aacf09d139700f22a383910ee97 Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期三, 04 三月 2026 10:38:32 +0800
Subject: [PATCH] 合并

---
 server/dmmall_service/src/main/java/com/doumee/service/business/impl/GoodsorderServiceImpl.java |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

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 4ffb780..7f9c503 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
@@ -1418,7 +1418,6 @@
             if(Objects.isNull(orderGoodsCalculateResponse.getCouponDeductCash())){
                 orderGoodsCalculateResponse.setCouponDeductCash(BigDecimal.ZERO);
             }
-//            orderGoodsCalculateResponse.setIntegralDeductCash(BigDecimal.ZERO);
         }
         //璁㈠崟鎬婚噾棰�
         BigDecimal amount = BigDecimal.ZERO;
@@ -1446,6 +1445,9 @@
         List<MemberCoupon> memberCouponList = memberCouponService.getApplyCoupon(request.getPayDetailRequestList(),request.getMemberId());
         if(CollectionUtils.isNotEmpty(memberCouponList)){
             orderPayConfirmResponse.setMemberCouponList(memberCouponList);
+            if(Objects.nonNull(request.getCouponId())&&Constants.equalsInteger(request.getCouponId(),-Constants.ONE)&&Objects.nonNull(memberCouponList)){
+                request.setCouponId(memberCouponList.get(Constants.ZERO).getId());
+            }
             //濡傛灉閫夋嫨浜嗕紭鎯犲埜锛屽垯鍒ゆ柇閫夋嫨鐨勪紭鎯犲埜鏄惁鏈夋晥
             if(Objects.nonNull(request.getCouponId())){
                 List<MemberCoupon>  memberCoupons = memberCouponList.stream().filter(i->Constants.equalsInteger(i.getId(),request.getCouponId())).collect(Collectors.toList());
@@ -1465,7 +1467,7 @@
         //鏌ヨ鐢ㄦ埛鎬荤Н鍒�
         Member member = memberMapper.selectById(request.getMemberId());
         //鏈�浣庡彲鐢ㄥ惎鐢ㄧН鍒�
-        BigDecimal minimumIntegral = new BigDecimal(systemDictDataBiz.queryByCode(Constants.SHOP_CONFIG,Constants.MINIMUM_AVAILABLE_INTEGRAL).getCode());
+        BigDecimal minimumIntegral = new BigDecimal(systemDictDataBiz.queryByCode(Constants.INTEGRAL_SET,Constants.INTERALSET_MININTEGRALPRICELIMIT).getCode());
         //绉垎鍙娇鐢ㄧ姸鎬�  澶т簬0 澶т簬鏈�灏忓彲鐢ㄩ厤缃Н鍒嗗��
         orderPayConfirmResponse.setIntegralStatus(
                 (member.getIntegral().compareTo(BigDecimal.ZERO)<=Constants.ZERO||
@@ -1476,6 +1478,8 @@
         orderPayConfirmResponse.setIntegralAmount(integralAmount);
         if(Constants.equalsInteger(orderPayConfirmResponse.getIntegralStatus(),Constants.ZERO)){
             integralAmount = this.calculateIntegralRata(orderPayConfirmResponse,goodsCalculateList,member.getIntegral());
+        }else{
+            orderPayConfirmResponse.setSurplusIntegral(member.getIntegral());
         }
 
         //閭垂閲戦
@@ -1489,7 +1493,7 @@
                     }
                     Areas areas = areasMapper.selectOne(new QueryWrapper<Areas>().lambda()
                             .eq(Areas::getIsdeleted,Constants.ZERO)
-                            .eq(Areas::getId,StringUtils.leftPad(addr.getAreaId().toString().substring(0,2),6,"0"))
+                            .eq(Areas::getId,StringUtils.rightPad(addr.getAreaId().toString().substring(0,2),6,"0"))
                             .isNotNull(Areas::getYunFeeId)
                             .last(" limit 1 ")
                     );
@@ -1506,7 +1510,7 @@
                 BigDecimal totalWeight = goodsCalculateList.stream().map(i->
                         i.getWeight().multiply(new BigDecimal(i.getGoodsNum().toString()))
                 ).reduce(BigDecimal.ZERO,BigDecimal::add);
-                if(totalWeight.compareTo(mailConfigResponse.getWeight0())>=Constants.ZERO){
+                if(totalWeight.compareTo(mailConfigResponse.getWeight0())<=Constants.ZERO){
                     mailAmount = mailConfigResponse.getFee0();
                 }else{
                     //瓒呴噸閲嶉噺
@@ -1581,9 +1585,9 @@
     public BigDecimal  calculateIntegralRata(OrderPayConfirmResponse orderPayConfirmResponse,List<OrderGoodsCalculateResponse> goodsCalculateList,BigDecimal totalIntegral){
         //褰撳墠閫夋嫨鍟嗗搧鏈�澶у彲鐢ㄧН鍒嗘姷鎵g殑閲戦
         BigDecimal maxDeductionCash =  goodsCalculateList.stream().map(i->i.getSkuAmount().subtract(Objects.isNull(i.getCouponDeductCash())?BigDecimal.ZERO:i.getCouponDeductCash())
-                .multiply(i.getDeductRata()).multiply(new BigDecimal("0.01"))).reduce(BigDecimal.ZERO,BigDecimal::add);
+                .multiply(i.getDeductRata()).divide(new BigDecimal("100"),2,RoundingMode.DOWN)).reduce(BigDecimal.ZERO,BigDecimal::add);
         //绉垎-鐜伴噾鍏戞崲姣斾緥锛圶XX绉垎鎶垫墸1鍏冿級
-        BigDecimal cashToIntegralRata = new BigDecimal(systemDictDataBiz.queryByCode(Constants.SHOP_CONFIG,Constants.INTEGRAL_EXCHANGE_CASH_RATA).getCode());
+        BigDecimal cashToIntegralRata = new BigDecimal(systemDictDataBiz.queryByCode(Constants.INTEGRAL_SET,Constants.INTERALSET_DEDUCTINTEGRALLIMIT).getCode());
         //褰撳墠閫夋嫨鍟嗗搧鎶垫墸闇�瑕佷娇鐢ㄧ殑绉垎
         BigDecimal maxDeductionIntegral =  maxDeductionCash.multiply(cashToIntegralRata);
         //鑾峰彇褰撳墠闇�瑕佹敮浠樼殑鐜伴噾鎬婚
@@ -1593,7 +1597,9 @@
         //寰幆涓嬪崟鍟嗗搧鍒楄〃 璁$畻搴旇浣跨敤鐨勭Н鍒嗗��
         BigDecimal realDeductionCash = BigDecimal.ZERO;
         for (int j = 0; j < goodsCalculateList.size(); j++) {
-            BigDecimal deductionCash = goodsCalculateList.get(j).getSkuAmount().subtract(goodsCalculateList.get(j).getCouponDeductCash());
+            //鑾峰彇鏈�澶у彲鎶垫墸閲戦
+            BigDecimal deductionCash = goodsCalculateList.get(j).getSkuAmount().subtract(goodsCalculateList.get(j).getCouponDeductCash())
+                    .multiply(goodsCalculateList.get(j).getDeductRata()).divide(new BigDecimal("100"),2,RoundingMode.DOWN);
             goodsCalculateList.get(j).setIntegralMaxDeductCash(deductionCash);
             //濡傛灉鍓╀綑绉垎澶т簬鍙互浣跨敤绉垎 鍒欑洿鎺ユ弧棰濊绠� 鍙嶄箣 鍓╀綑绉垎涓嶈兘婊¤冻鍏ㄩ儴鎶垫墸 鍗曠嫭璁$畻姣忎釜鍟嗗搧鍗犳瘮
             if(totalIntegral.compareTo(maxDeductionIntegral)<Constants.ZERO){

--
Gitblit v1.9.3