| 
					
				 | 
			
			
				@@ -4614,30 +4614,46 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<MkActivitiesScoreEntity> mkActivitiesScoreEntities = mkActivitiesScoreService.queryActivityInfoByMkaIdList(mkaIdList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 参与了积分抵扣的sku集合 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<String> scoreDeductionSkuList = mkActivitiesScoreEntities.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (CollectionUtils.isEmpty(mkActivitiesScoreEntities)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LOGGER.error("查询积分抵扣活动SKU为空!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new ServiceException("查询积分抵扣活动SKU为空!请先导入积分抵扣活动信息!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 参与了积分抵扣的sku集合,过滤的是参与的sku,如果该list不为空,则默认其余的sku不参与积分抵扣 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<String> scoreDeductionAllowSkuList = mkActivitiesScoreEntities.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 .filter(m -> Constants.RejectStatus.ALLOW.getCode().equals(m.getReject())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 .map(MkActivitiesScoreEntity::getSku) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 .collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 转换成map,保存参与了积分抵扣活动的sku,积分计算比例的数据,key===>sku,value===>最大抵扣比例 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Map<String, BigDecimal> skuScoreLimitMap = mkActivitiesScoreEntities.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .filter(m -> Constants.RejectStatus.ALLOW.getCode().equals(m.getReject())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .collect(Collectors.toMap(MkActivitiesScoreEntity::getSku, mkActivitiesScoreEntity -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    BigDecimal scoreLimit = mkActivitiesScoreEntity.getScoreLimit(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if (Objects.isNull(scoreLimit)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        LOGGER.error("商品:【{}】,未设置最大抵扣比例!请设置后再计算优惠价!", mkActivitiesScoreEntity.getSku()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        throw new ServiceException(String.format("商品:【%s】,未设置最大抵扣比例!请设置后再计算优惠价!", mkActivitiesScoreEntity.getSku())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    return scoreLimit; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                }, (k1, k2) -> k2)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 不参与积分抵扣的sku集合,如果该list不为空,则默认其余的sku参与积分抵扣 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<String> scoreDeductionRejectSkuList = mkActivitiesScoreEntities.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .filter(m -> Constants.RejectStatus.REJECT.getCode().equals(m.getReject())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .map(MkActivitiesScoreEntity::getSku) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!CollectionUtils.isEmpty(scoreDeductionAllowSkuList) && !CollectionUtils.isEmpty(scoreDeductionRejectSkuList)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LOGGER.error("积分抵扣表中既有参与又有不参与!与需求不符!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new ServiceException("导入的积分抵扣活动商品设置有误!请确保导入的数据中只有参与或者不参与!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (CollectionUtils.isEmpty(scoreDeductionAllowSkuList) && CollectionUtils.isEmpty(scoreDeductionRejectSkuList)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LOGGER.error("积分抵扣表中无是否参与字段!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new ServiceException("导入的积分抵扣活动商品设置有误!导入的活动商品数据中必须有参与或者不参与!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 当前订单中参与了积分抵扣活动的sku总支付金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         BigDecimal skuTotalPrice = BigDecimal.ZERO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (GoodsDetailsDto goodsDetailsDto : goodsDetailsDtos) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             String sku = goodsDetailsDto.getGoodsSn(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (!promotionSkuList.contains(sku)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (scoreDeductionSkuList.contains(sku)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    BigDecimal skuActualPaymentAmount = goodsDetailsDto.getActualPaymentAmount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    skuTotalPrice = skuTotalPrice.add(skuActualPaymentAmount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (CollectionUtils.isEmpty(scoreDeductionAllowSkuList) && !CollectionUtils.isEmpty(scoreDeductionRejectSkuList)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (!scoreDeductionRejectSkuList.contains(sku)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        BigDecimal skuActualPaymentAmount = goodsDetailsDto.getActualPaymentAmount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        skuTotalPrice = skuTotalPrice.add(skuActualPaymentAmount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else if (!CollectionUtils.isEmpty(scoreDeductionAllowSkuList) && CollectionUtils.isEmpty(scoreDeductionRejectSkuList)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (scoreDeductionAllowSkuList.contains(sku)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        BigDecimal skuActualPaymentAmount = goodsDetailsDto.getActualPaymentAmount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        skuTotalPrice = skuTotalPrice.add(skuActualPaymentAmount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -4659,8 +4675,19 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 int scoreInteger = score % scoreLimit == 0 ? score : score - (score % scoreLimit); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 过滤掉参与过限时特价并且与积分抵扣互斥的sku,以及未参加积分抵扣活动的sku 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 goodsDetailsDtos = goodsDetailsDtos.stream().filter(goodsDetailsDto -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if (!promotionSkuList.contains(goodsDetailsDto.getSku()) && scoreDeductionSkuList.contains(goodsDetailsDto.getSku())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String sku = goodsDetailsDto.getSku(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (!promotionSkuList.contains(sku)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // 如果导入的商品都为不参与,则其余的商品都默认参与积分抵扣活动 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (CollectionUtils.isEmpty(scoreDeductionAllowSkuList) && !CollectionUtils.isEmpty(scoreDeductionRejectSkuList)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (!scoreDeductionRejectSkuList.contains(sku)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // 如果导入的商品都为参与,则默认其余商品不参与 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } else if (!CollectionUtils.isEmpty(scoreDeductionAllowSkuList) && CollectionUtils.isEmpty(scoreDeductionRejectSkuList)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (scoreDeductionAllowSkuList.contains(sku)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // 满赠商品不参与积分分摊计算 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     return !Constants.ActivityTopicEnum.MZ.getTopicName().equals(goodsDetailsDto.getActivity()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -4672,6 +4699,13 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 订单详情积分抵扣总金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 BigDecimal goodsDetailScoreDeductionPrice = BigDecimal.ZERO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 int size = goodsDetailsDtos.size(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 系统设置的最大抵扣比例(最多能抵扣订单金额的比例),在系统管理的系统参数中设置,KEY为 HAIKONG_MEMBER_MAX_SCORE_RATIO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String scoreRatioStr = sysConfigDao.queryByKey(Constants.HAIKONG_MEMBER_MAX_SCORE_RATIO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (org.springframework.util.StringUtils.isEmpty(scoreRatioStr)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    LOGGER.error("计算优惠价格时,未设置订单的最大积分抵扣比例!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    throw new ServiceException(String.format("请先设置订单的最大积分抵扣比例,设置方式:【系统管理】-->【系统参数】,参数名为:【%s】", Constants.HAIKONG_MEMBER_MAX_SCORE_RATIO)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                BigDecimal scoreRatio = new BigDecimal(scoreRatioStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 for (int i = 0; i < size; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     GoodsDetailsDto goodsDetailsDto = goodsDetailsDtos.get(i); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // 抵扣积分分摊 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -4679,14 +4713,12 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     String activity = goodsDetailsDto.getActivity(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     goodsDetailsDto.setActivity(org.springframework.util.StringUtils.isEmpty(activity) ? "积分抵扣" : activity.contains("积分抵扣") ? activity : activity + ",积分抵扣"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     String sku = goodsDetailsDto.getGoodsSn(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    // 系统设置的最大抵扣比例(最多能抵扣订单金额的比例),导入积分抵扣活动时设置 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    BigDecimal scoreLimitDecimal = skuScoreLimitMap.get(sku); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     String prodBarcode = goodsDetailsDto.getProdBarcode(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // 此字段 = 零售价 - 其他活动优惠金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     BigDecimal actualPaymentAmount = goodsDetailsDto.getActualPaymentAmount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // 当前商品最大支持抵扣的金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     BigDecimal currentSkuMaxDeductionPrice = actualPaymentAmount.multiply(BigDecimal.valueOf(goodsDetailsDto.getSellVolume())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                                                .multiply(scoreLimitDecimal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                                                .multiply(scoreRatio); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // 其他活动优惠金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     BigDecimal otherDiscountedPrice = Objects.isNull(goodsDetailsDto.getDiscountedPrice()) ? BigDecimal.ZERO : goodsDetailsDto.getDiscountedPrice(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |