1
0
فهرست منبع

Merge branch 'master' of wangchaoqun/kmall-haikong into master

王超群 3 سال پیش
والد
کامیت
e6c5a99136

+ 4 - 4
kmall-admin/src/main/java/com/kmall/admin/service/impl/GoodsServiceImpl.java

@@ -1595,8 +1595,8 @@ public class GoodsServiceImpl implements GoodsService {
         // 计算税费
         GoodsEntity goodsEntity = goodsDao.queryByBarcodeAndSku(prodBarcode, goods.getGoodsSn());
         // 计算算税金额 实际支付价 + 积分抵扣金额
-        BigDecimal deductionPrice = Objects.isNull(goodsEntity.getDeductionPrice()) ? new BigDecimal("0") : goodsEntity.getDeductionPrice();
-        BigDecimal actualPaymentAmount = Objects.isNull(goodsEntity.getActualPaymentAmount()) ? new BigDecimal("0") : goodsEntity.getActualPaymentAmount();
+        BigDecimal deductionPrice = Objects.isNull(goods.getDeductionPrice()) ? new BigDecimal("0") : goods.getDeductionPrice();
+        BigDecimal actualPaymentAmount = Objects.isNull(goods.getActualPaymentAmount()) ? new BigDecimal("0") : goods.getActualPaymentAmount();
         BigDecimal price = deductionPrice.add(actualPaymentAmount);
         BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity, price,this).setScale(3,RoundingMode.HALF_UP);
         goods.setGoodstaxes(tax.toString());
@@ -1717,8 +1717,8 @@ public class GoodsServiceImpl implements GoodsService {
         // 计算税费
         GoodsEntity goodsEntity = goodsDao.queryByBarcodeAndSku(prodBarcode, goods.getGoodsSn());
         // 计算算税金额 实际支付价 + 积分抵扣金额
-        BigDecimal deductionPrice = Objects.isNull(goodsEntity.getDeductionPrice()) ? new BigDecimal("0") : goodsEntity.getDeductionPrice();
-        BigDecimal actualPaymentAmount = Objects.isNull(goodsEntity.getActualPaymentAmount()) ? new BigDecimal("0") : goodsEntity.getActualPaymentAmount();
+        BigDecimal deductionPrice = Objects.isNull(goods.getDeductionPrice()) ? new BigDecimal("0") : goods.getDeductionPrice();
+        BigDecimal actualPaymentAmount = Objects.isNull(goods.getActualPaymentAmount()) ? new BigDecimal("0") : goods.getActualPaymentAmount();
         BigDecimal price = deductionPrice.add(actualPaymentAmount);
         BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity,price,this).setScale(3,RoundingMode.HALF_UP);
         goods.setGoodstaxes(tax.toString());

+ 10 - 6
kmall-admin/src/main/java/com/kmall/admin/service/impl/OrderServiceImpl.java

@@ -2647,6 +2647,8 @@ public class OrderServiceImpl implements OrderService {
                  * 根据门店id 和时间查询积分赠送规则
                  */
                 List<PointsRulesAndDetailVO> pointsRulesAndDetailVOList= mall2PointsRulesService.queryListByTime(new Date(), store.getId().toString());
+                // 将此商品列表信息分组  key:sku 值:购买数量
+                Map<String, Integer> queryGoodsVOListMap = queryGoodsVOList.stream().collect(Collectors.toMap(QueryGoodsVO::getSku, QueryGoodsVO::getSellVolume, (k1, k2) -> k2));
 
                 // 商品map,key===>sku value===>金额
                 Map<String, BigDecimal> goodsMap = goodsEntities.stream().collect(Collectors.toMap(GoodsEntity::getSku, GoodsEntity::getActualPaymentAmount, (k1, k2) -> k2));
@@ -2681,7 +2683,7 @@ public class OrderServiceImpl implements OrderService {
                             // 商品积分生成规则包含这个sku
                             // 订单中该sku的总金额
                             BigDecimal money = goodsMap.get(pointsDetailNameId);
-                            GoodsEntity goodsEntity = goodsDataMap.get(pointsDetailNameId);
+                            Integer number = queryGoodsVOListMap.get(pointsDetailNameId);
                             OrderGiftScoreRulesVo orderGiftScoreRulesVo = new OrderGiftScoreRulesVo();
                             orderGiftScoreRulesVo.setGenerateType(Constants.MemberScoreRulesEnum.TWO.getCode());
                             BigDecimal bigDecimal = new BigDecimal(0);
@@ -2700,7 +2702,7 @@ public class OrderServiceImpl implements OrderService {
                             }
                             // 在这里计算赠送积分,并放入
                             // 判断此sku是否参加活动 并计算活动积分
-                            getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, pointsDetailNameId, orderGiftScoreRulesVo,goodsEntity);
+                            getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, pointsDetailNameId, orderGiftScoreRulesVo,number);
                             giftGoodsScoreDetailMap.put(pointsDetailNameId, orderGiftScoreRulesVo);
                             goodsDataMap.remove(pointsDetailNameId);
                         }
@@ -2713,6 +2715,7 @@ public class OrderServiceImpl implements OrderService {
                             // 商品类别
                             Integer categoryId = goodsEntity.getCategoryId();
                             String sku = goodsEntity.getSku();
+                            Integer number = queryGoodsVOListMap.get(sku);
                             OrderGiftScoreRulesVo orderGiftScoreRulesVo = new OrderGiftScoreRulesVo();
                             orderGiftScoreRulesVo.setGenerateType(Constants.MemberScoreRulesEnum.ONE.getCode());
                             if (categorySet.contains(categoryId)) {
@@ -2734,7 +2737,7 @@ public class OrderServiceImpl implements OrderService {
                                         orderGiftScoreRulesVo.setGenerateRatio(BigDecimal.ZERO);
                                     }
                                     // 判断此sku是否参加活动 并计算活动积分
-                                    getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, sku, orderGiftScoreRulesVo, goodsEntity);
+                                    getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, sku, orderGiftScoreRulesVo, number);
                                     giftGoodsScoreDetailMap.put(sku, orderGiftScoreRulesVo);
                                     goodsDataMap.remove(sku);
                                 }
@@ -2748,6 +2751,7 @@ public class OrderServiceImpl implements OrderService {
                         for(GoodsEntity goodsEntity : goodsEntityCollection){
                             Integer storeId1 = goodsEntity.getStoreId();
                             String sku = goodsEntity.getSku();
+                            Integer number = queryGoodsVOListMap.get(sku);
                             OrderGiftScoreRulesVo orderGiftScoreRulesVo = new OrderGiftScoreRulesVo();
                             orderGiftScoreRulesVo.setGenerateType(Constants.MemberScoreRulesEnum.ZERO.getCode());
                             BigDecimal bigDecimal = new BigDecimal(0);
@@ -2770,7 +2774,7 @@ public class OrderServiceImpl implements OrderService {
                             }
 
                             // 判断此sku是否参加活动 并计算活动积分
-                            getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, sku, orderGiftScoreRulesVo,goodsEntity);
+                            getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, sku, orderGiftScoreRulesVo,number);
                             giftGoodsScoreDetailMap.put(sku, orderGiftScoreRulesVo);
                         }
 
@@ -2897,14 +2901,14 @@ public class OrderServiceImpl implements OrderService {
      * @param sku
      */
     private void getGiftScore(AtomicReference<Integer> activityGiftScore, BigDecimal baseScore
-            , Map<String, MkActivitiesPresentIntegralEntity> mkActivitiesEntityMap, String sku, OrderGiftScoreRulesVo orderGiftScoreRulesVo,GoodsEntity goodsEntity) {
+            , Map<String, MkActivitiesPresentIntegralEntity> mkActivitiesEntityMap, String sku, OrderGiftScoreRulesVo orderGiftScoreRulesVo,Integer number) {
         if(mkActivitiesEntityMap.containsKey(sku)){
             // 存在表示它参加赠送积分活动
             MkActivitiesPresentIntegralEntity mkActivitiesPresentIntegralEntity = mkActivitiesEntityMap.get(sku);
             // 计算活动积分
             if(ActivityGiveTypeEnum.FIXED_VALUE.getCode().equals(mkActivitiesPresentIntegralEntity.getActivityGiveType())){
                 // 固定值  那赠送积分就是固定值
-                BigDecimal giftScoreTmp = mkActivitiesPresentIntegralEntity.getActivityGiveNum().multiply(new BigDecimal(goodsEntity.getGoodsNumber()));
+                BigDecimal giftScoreTmp = mkActivitiesPresentIntegralEntity.getActivityGiveNum().multiply(new BigDecimal(number));
                 // 此sku赠送的积分加上之前赠送的积分 算出来订单赠送总分
                 int giftScore = giftScoreTmp.add(new BigDecimal(activityGiftScore.get())).intValue();
                 activityGiftScore.set(giftScore);