| 
					
				 | 
			
			
				@@ -562,8 +562,10 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             GoodsEntity goodsEntity = goodsService.queryObject(orderGoods.getGoodsId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity, orderGoods.getRetailPrice(), goodsService).setScale(3, RoundingMode.HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            goodsTax = goodsTax.multiply(new BigDecimal(orderGoods.getNumber())).setScale(2, 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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Goods goods = new Goods(orderGoods.getGoodsName(), 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2644,6 +2646,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)); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2651,7 +2655,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){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // 不为空 则处理 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2676,6 +2682,7 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             // 商品积分生成规则包含这个sku 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             // 订单中该sku的总金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             BigDecimal money = goodsMap.get(pointsDetailNameId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            Integer number = queryGoodsVOListMap.get(pointsDetailNameId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             OrderGiftScoreRulesVo orderGiftScoreRulesVo = new OrderGiftScoreRulesVo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             orderGiftScoreRulesVo.setGenerateType(Constants.MemberScoreRulesEnum.TWO.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             BigDecimal bigDecimal = new BigDecimal(0); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2694,7 +2701,7 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             // 在这里计算赠送积分,并放入 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             // 判断此sku是否参加活动 并计算活动积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, pointsDetailNameId, orderGiftScoreRulesVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, pointsDetailNameId, orderGiftScoreRulesVo,number); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             giftGoodsScoreDetailMap.put(pointsDetailNameId, orderGiftScoreRulesVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             goodsDataMap.remove(pointsDetailNameId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2707,6 +2714,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)) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2728,7 +2736,7 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                         orderGiftScoreRulesVo.setGenerateRatio(BigDecimal.ZERO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     // 判断此sku是否参加活动 并计算活动积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, sku, orderGiftScoreRulesVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, sku, orderGiftScoreRulesVo, number); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     giftGoodsScoreDetailMap.put(sku, orderGiftScoreRulesVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     goodsDataMap.remove(sku); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2742,6 +2750,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); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2764,7 +2773,7 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             // 判断此sku是否参加活动 并计算活动积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, sku, orderGiftScoreRulesVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            getGiftScore(activityGiftScore, bigDecimal, mkActivitiesEntityMap, sku, orderGiftScoreRulesVo,number); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             giftGoodsScoreDetailMap.put(sku, orderGiftScoreRulesVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2892,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) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            , 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(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                BigDecimal giftScoreTmp = mkActivitiesPresentIntegralEntity.getActivityGiveNum().multiply(new BigDecimal(number)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 此sku赠送的积分加上之前赠送的积分 算出来订单赠送总分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 int giftScore = giftScoreTmp.add(new BigDecimal(activityGiftScore.get())).intValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 activityGiftScore.set(giftScore); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -5494,7 +5503,9 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         /*GoodsEntity goodsEntity = goodsService.queryObject(goodsDto.getId().intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity, goodsDto.getStoreRetailPrice(), goodsService).setScale(3, RoundingMode.HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         goodsTax = goodsTax.multiply(number).setScale(2, RoundingMode.HALF_UP);*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        orderGoodsVo.setTaxPrice(goodsDto.getGoodsTaxes().divide(BigDecimal.valueOf(goodsDto.getSellVolume()), 3, BigDecimal.ROUND_HALF_UP)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // wcq注解: 原先在数据入库的时候  预估税费除以了数量  现在不除以数量了 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 注释代码:.divide(BigDecimal.valueOf(goodsDto.getSellVolume()), 3, BigDecimal.ROUND_HALF_UP) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        orderGoodsVo.setTaxPrice(goodsDto.getGoodsTaxes()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return orderGoodsVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 |