瀏覽代碼

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

王超群 3 年之前
父節點
當前提交
e9d166149d

+ 6 - 2
kmall-admin/src/main/java/com/kmall/admin/controller/order/OrderController.java

@@ -615,7 +615,9 @@ public class OrderController {
             BigDecimal allDiscountedPrice = new BigDecimal(0);
             for (OrderGoodsEntity orderGoodsEntity : goodsList) {
                 GoodsEntity goodsEntity = goodsService.queryObject(orderGoodsEntity.getGoodsId());
-                BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity,orderGoodsEntity.getMarketPrice(),goodsService).setScale(3,RoundingMode.HALF_UP);
+                // 计算算税金额 实际支付价 + 积分抵扣金额
+                BigDecimal price = orderGoodsEntity.getDeductionPrice().add(orderGoodsEntity.getActualPaymentAmount());
+                BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity,price,goodsService).setScale(3,RoundingMode.HALF_UP);
                 goodsTax = goodsTax.multiply(new BigDecimal(orderGoodsEntity.getNumber())).setScale(2,RoundingMode.HALF_UP);
                 orderGoodsEntity.setTax(goodsTax);
                 tax = tax.add(goodsTax).setScale(2,RoundingMode.HALF_UP);
@@ -671,7 +673,9 @@ public class OrderController {
         BigDecimal allDiscountedPrice = new BigDecimal(0);
         for (OrderGoodsEntity orderGoodsEntity : goodsList) {
             GoodsEntity goodsEntity = goodsService.queryObject(orderGoodsEntity.getGoodsId());
-            BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity,orderGoodsEntity.getMarketPrice(),goodsService).setScale(3,RoundingMode.HALF_UP);
+            // 计算算税金额 实际支付价 + 积分抵扣金额
+            BigDecimal price = orderGoodsEntity.getDeductionPrice().add(orderGoodsEntity.getActualPaymentAmount());
+            BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity,price,goodsService).setScale(3,RoundingMode.HALF_UP);
             goodsTax = goodsTax.multiply(new BigDecimal(orderGoodsEntity.getNumber())).setScale(2,RoundingMode.HALF_UP);
             orderGoodsEntity.setTax(goodsTax);
             tax = tax.add(goodsTax).setScale(2,RoundingMode.HALF_UP);

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

@@ -1594,7 +1594,9 @@ public class GoodsServiceImpl implements GoodsService {
 
         // 计算税费
         GoodsEntity goodsEntity = goodsDao.queryByBarcodeAndSku(prodBarcode, goods.getGoodsSn());
-        BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity, goods.getActualPaymentAmount(),this).setScale(3,RoundingMode.HALF_UP);
+        // 计算算税金额 实际支付价 + 积分抵扣金额
+        BigDecimal price = goodsEntity.getDeductionPrice().add(goodsEntity.getActualPaymentAmount());
+        BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity, price,this).setScale(3,RoundingMode.HALF_UP);
         goods.setGoodstaxes(tax.toString());
         goods.setSellVolume(1);
 
@@ -1712,7 +1714,9 @@ public class GoodsServiceImpl implements GoodsService {
         Map<String,Object> skuActivitiesMap = new HashMap<>();
         // 计算税费
         GoodsEntity goodsEntity = goodsDao.queryByBarcodeAndSku(prodBarcode, goods.getGoodsSn());
-        BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity,goods.getActualPaymentAmount(),this).setScale(3,RoundingMode.HALF_UP);
+        // 计算算税金额 实际支付价 + 积分抵扣金额
+        BigDecimal price = goodsEntity.getDeductionPrice().add(goodsEntity.getActualPaymentAmount());
+        BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity,price,this).setScale(3,RoundingMode.HALF_UP);
         goods.setGoodstaxes(tax.toString());
 
 
@@ -2019,7 +2023,9 @@ public class GoodsServiceImpl implements GoodsService {
         goods.setRetailPrice(promotionEntity.getActivityPrice());
         goods.setActivity("临时促销");
         try {
-            CalculateTax.calculateFinalTax(goods,goods.getActualPaymentAmount(),this).setScale(3,RoundingMode.HALF_UP);
+            // 计算算税金额 实际支付价 + 积分抵扣金额
+            BigDecimal price = goods.getDeductionPrice().add(goods.getActualPaymentAmount());
+            CalculateTax.calculateFinalTax(goods,price,this).setScale(3,RoundingMode.HALF_UP);
         } catch (Exception e) {
             ShopErrorPriceRecordEntity shopErrorPriceRecordEntity = new ShopErrorPriceRecordEntity();
             shopErrorPriceRecordEntity.setMerchSn(goods.getMerchSn());
@@ -2068,7 +2074,9 @@ public class GoodsServiceImpl implements GoodsService {
         goods.setActivity("日常活动");
         // 计算税费
         try {
-            CalculateTax.calculateFinalTax(goods,goods.getActualPaymentAmount(),this).setScale(3,RoundingMode.HALF_UP);
+            // 计算算税金额 实际支付价 + 积分抵扣金额
+            BigDecimal price = goods.getDeductionPrice().add(goods.getActualPaymentAmount());
+            CalculateTax.calculateFinalTax(goods,price,this).setScale(3,RoundingMode.HALF_UP);
         } catch (Exception e) {
             // 记录有异常的sku
             ShopErrorPriceRecordEntity shopErrorPriceRecordEntity = new ShopErrorPriceRecordEntity();
@@ -2106,7 +2114,9 @@ public class GoodsServiceImpl implements GoodsService {
 
         // 计算税费
         try {
-            CalculateTax.calculateFinalTax(goods,goods.getActualPaymentAmount(),this).setScale(3,RoundingMode.HALF_UP);
+            // 计算算税金额 实际支付价 + 积分抵扣金额
+            BigDecimal price = goods.getDeductionPrice().add(goods.getActualPaymentAmount());
+            CalculateTax.calculateFinalTax(goods,price,this).setScale(3,RoundingMode.HALF_UP);
         } catch (Exception e) {
             // 记录有异常的sku
             ShopErrorPriceRecordEntity shopErrorPriceRecordEntity = new ShopErrorPriceRecordEntity();

+ 12 - 7
kmall-admin/src/main/java/com/kmall/admin/service/impl/OrderServiceImpl.java

@@ -562,7 +562,9 @@ public class OrderServiceImpl implements OrderService {
 
 
             GoodsEntity goodsEntity = goodsService.queryObject(orderGoods.getGoodsId());
-            BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity, orderGoods.getRetailPrice(), goodsService).setScale(3, RoundingMode.HALF_UP);
+            // 计算算税金额 实际支付价 + 积分抵扣金额
+            BigDecimal price = orderGoods.getDeductionPrice().add(orderGoods.getActualPaymentAmount());
+            BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity, price, goodsService).setScale(3, RoundingMode.HALF_UP);
             goodsTax = goodsTax.multiply(new BigDecimal(orderGoods.getNumber())).setScale(2, RoundingMode.HALF_UP);
             taxTotal = taxTotal.add(goodsTax).setScale(2, RoundingMode.HALF_UP);
 
@@ -2652,7 +2654,9 @@ public class OrderServiceImpl implements OrderService {
                 Map<String, GoodsEntity> goodsDataMap = goodsEntities.stream().collect(Collectors.toMap(GoodsEntity::getSku, goodsEntity -> goodsEntity, (k1, k2) -> k2));
                 // 根据门店、时间和活动类型 查询参加积分赠送活动的sku,转换为map
                 //  ,sku为key,对象为值,判断sku是否在此之中,在则计算赠送积分算完
-                List<MkActivitiesPresentIntegralEntity> mkActivitiesEntityList = mkActivitiesPresentIntegralService.querySkuByNow(store.getId().toString(), DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"), Constants.ActivityTopicEnum.ZSJF.getTopicCode());
+                List<MkActivitiesPresentIntegralEntity> mkActivitiesEntityList = mkActivitiesPresentIntegralService.querySkuByNow(store.getId().toString(), DateUtils.format(new Date()
+                        , "yyyy-MM-dd HH:mm:ss")
+                        , Constants.ActivityTopicEnum.ZSJF.getTopicCode());
                 Map<String, MkActivitiesPresentIntegralEntity> mkActivitiesEntityMap = new HashMap<>();
                 if(!CollectionUtils.isEmpty(mkActivitiesEntityList) && mkActivitiesEntityList.size() > 0){
                     // 不为空 则处理
@@ -2677,6 +2681,7 @@ public class OrderServiceImpl implements OrderService {
                             // 商品积分生成规则包含这个sku
                             // 订单中该sku的总金额
                             BigDecimal money = goodsMap.get(pointsDetailNameId);
+                            GoodsEntity goodsEntity = goodsDataMap.get(pointsDetailNameId);
                             OrderGiftScoreRulesVo orderGiftScoreRulesVo = new OrderGiftScoreRulesVo();
                             orderGiftScoreRulesVo.setGenerateType(Constants.MemberScoreRulesEnum.TWO.getCode());
                             BigDecimal bigDecimal = new BigDecimal(0);
@@ -2695,7 +2700,7 @@ public class OrderServiceImpl implements OrderService {
                             }
                             // 在这里计算赠送积分,并放入
                             // 判断此sku是否参加活动 并计算活动积分
-                            getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, pointsDetailNameId, orderGiftScoreRulesVo);
+                            getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, pointsDetailNameId, orderGiftScoreRulesVo,goodsEntity);
                             giftGoodsScoreDetailMap.put(pointsDetailNameId, orderGiftScoreRulesVo);
                             goodsDataMap.remove(pointsDetailNameId);
                         }
@@ -2729,7 +2734,7 @@ public class OrderServiceImpl implements OrderService {
                                         orderGiftScoreRulesVo.setGenerateRatio(BigDecimal.ZERO);
                                     }
                                     // 判断此sku是否参加活动 并计算活动积分
-                                    getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, sku, orderGiftScoreRulesVo);
+                                    getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, sku, orderGiftScoreRulesVo, goodsEntity);
                                     giftGoodsScoreDetailMap.put(sku, orderGiftScoreRulesVo);
                                     goodsDataMap.remove(sku);
                                 }
@@ -2765,7 +2770,7 @@ public class OrderServiceImpl implements OrderService {
                             }
 
                             // 判断此sku是否参加活动 并计算活动积分
-                            getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, sku, orderGiftScoreRulesVo);
+                            getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, sku, orderGiftScoreRulesVo,goodsEntity);
                             giftGoodsScoreDetailMap.put(sku, orderGiftScoreRulesVo);
                         }
 
@@ -2892,14 +2897,14 @@ public class OrderServiceImpl implements OrderService {
      * @param sku
      */
     private void getGiftScore(AtomicReference<Integer> activityGiftScore, BigDecimal baseScore
-            , Map<String, MkActivitiesPresentIntegralEntity> mkActivitiesEntityMap, String sku, OrderGiftScoreRulesVo orderGiftScoreRulesVo) {
+            , Map<String, MkActivitiesPresentIntegralEntity> mkActivitiesEntityMap, String sku, OrderGiftScoreRulesVo orderGiftScoreRulesVo,GoodsEntity goodsEntity) {
         if(mkActivitiesEntityMap.containsKey(sku)){
             // 存在表示它参加赠送积分活动
             MkActivitiesPresentIntegralEntity mkActivitiesPresentIntegralEntity = mkActivitiesEntityMap.get(sku);
             // 计算活动积分
             if(ActivityGiveTypeEnum.FIXED_VALUE.getCode().equals(mkActivitiesPresentIntegralEntity.getActivityGiveType())){
                 // 固定值  那赠送积分就是固定值
-                BigDecimal giftScoreTmp = mkActivitiesPresentIntegralEntity.getActivityGiveNum();
+                BigDecimal giftScoreTmp = mkActivitiesPresentIntegralEntity.getActivityGiveNum().multiply(new BigDecimal(goodsEntity.getGoodsNumber()));
                 // 此sku赠送的积分加上之前赠送的积分 算出来订单赠送总分
                 int giftScore = giftScoreTmp.add(new BigDecimal(activityGiftScore.get())).intValue();
                 activityGiftScore.set(giftScore);