| 
					
				 | 
			
			
				@@ -38,9 +38,7 @@ import com.kmall.admin.fromcomm.entity.SysUserEntity; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.kmall.admin.haikong.constant.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.kmall.admin.haikong.dto.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.kmall.admin.haikong.utils.ListUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.kmall.admin.haikong.vo.CalculateOrderDiscountPriceResponseVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.kmall.admin.haikong.vo.PointsRulesAndDetailVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.kmall.admin.haikong.vo.QueryGoodsVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.kmall.admin.haikong.vo.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.kmall.admin.haikong.client.HaiKongMemberTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.kmall.admin.haikong.client.HaiKongWarehouseTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.kmall.admin.haikong.client.VmcShopTemplate; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -63,7 +61,6 @@ import com.kmall.admin.utils.data.response.ResponseMessageData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.kmall.admin.utils.jackson.JacksonUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.kmall.admin.utils.oms.OmsSign; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.kmall.admin.utils.pdf.BarcodeUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.kmall.admin.haikong.vo.CalculateOrderDiscountPriceVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.kmall.admin.websocket.WebSocketServer; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.kmall.api.entity.OrderGoodsRestoreVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.kmall.api.entity.OrderGoodsVo; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2494,6 +2491,7 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 总的积分:基础积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             AtomicReference<Integer> memberScore = new AtomicReference<>(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 无会员码,不参与积分赠送 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, OrderGiftScoreRulesVo> giftGoodsScoreDetailMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (!org.springframework.util.StringUtils.isEmpty(memberCode)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 List<PointsRulesAndDetailVO> pointsRulesAndDetailVOList = mall2PointsRulesService.queryListByTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 商品map,key===>sku value===>金额 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2516,13 +2514,21 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             // 商品积分生成规则包含这个sku 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             // 订单中该sku的总金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             BigDecimal money = goodsMap.get(pointsDetailNameId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            OrderGiftScoreRulesVo orderGiftScoreRulesVo = new OrderGiftScoreRulesVo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            orderGiftScoreRulesVo.setGenerateType(Constants.MemberScoreRulesEnum.TWO.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             if (ratio.compareTo(BigDecimal.ZERO) > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 // 算出所积的分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                memberScore.set(money.multiply(ratio).add(new BigDecimal(memberScore.get())).intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                int giftScore = money.multiply(ratio).add(new BigDecimal(memberScore.get())).intValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                memberScore.set(giftScore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                orderGiftScoreRulesVo.setGiftScore(giftScore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                orderGiftScoreRulesVo.setGenerateRatio(ratio); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 // 积分比例设置为0,该商品不记积分。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 LOGGER.info("商品SKU:【{}】,积分生成规则设置积分比例为:{},故不产生积分!", pointsDetailNameId, ratio); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                orderGiftScoreRulesVo.setGiftScore(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                orderGiftScoreRulesVo.setGenerateRatio(BigDecimal.ZERO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            giftGoodsScoreDetailMap.put(pointsDetailNameId, orderGiftScoreRulesVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             goodsDataMap.remove(pointsDetailNameId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2533,17 +2539,25 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             // 商品类别 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             Integer categoryId = goodsEntity.getCategoryId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             String sku = goodsEntity.getSku(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            OrderGiftScoreRulesVo orderGiftScoreRulesVo = new OrderGiftScoreRulesVo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            orderGiftScoreRulesVo.setGenerateType(Constants.MemberScoreRulesEnum.ONE.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             if (categorySet.contains(categoryId)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 if (categoryId.equals(Integer.parseInt(pointsDetailNameId))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     // 订单中该sku的总金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     BigDecimal money = goodsMap.get(sku); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     if (ratio.compareTo(BigDecimal.ZERO) > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                         // 算出所积的分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        memberScore.set(money.multiply(ratio).add(new BigDecimal(memberScore.get())).intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        int giftScore = money.multiply(ratio).add(new BigDecimal(memberScore.get())).intValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        memberScore.set(giftScore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        orderGiftScoreRulesVo.setGiftScore(giftScore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        orderGiftScoreRulesVo.setGenerateRatio(ratio); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                         // 积分比例设置为0,该商品不记积分。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                         LOGGER.info("分类:【{}】,积分生成规则设置积分比例为:{},故不产生积分!", pointsDetailNameId, ratio); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        orderGiftScoreRulesVo.setGiftScore(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        orderGiftScoreRulesVo.setGenerateRatio(BigDecimal.ZERO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    giftGoodsScoreDetailMap.put(sku, orderGiftScoreRulesVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     goodsDataMap.remove(sku); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2555,20 +2569,37 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         goodsEntityCollection.forEach(goodsEntity -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             Integer storeId1 = goodsEntity.getStoreId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             String sku = goodsEntity.getSku(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            OrderGiftScoreRulesVo orderGiftScoreRulesVo = new OrderGiftScoreRulesVo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            orderGiftScoreRulesVo.setGenerateType(Constants.MemberScoreRulesEnum.ZERO.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             if (storeId.equals(storeId1)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 // 订单中该sku的总金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 BigDecimal money = goodsMap.get(sku); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 if (ratio.compareTo(BigDecimal.ZERO) != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     // 算出所积的分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    memberScore.set(money.multiply(ratio).add(new BigDecimal(memberScore.get())).intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    int giftScore = money.multiply(ratio).add(new BigDecimal(memberScore.get())).intValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    memberScore.set(giftScore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    orderGiftScoreRulesVo.setGiftScore(giftScore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    orderGiftScoreRulesVo.setGenerateRatio(ratio); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     // 积分比例设置为0,该商品不记积分。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     LOGGER.info("门店:【{}】,积分生成规则设置积分比例为:{},故不产生积分!", pointsDetailNameId, ratio); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    orderGiftScoreRulesVo.setGiftScore(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    orderGiftScoreRulesVo.setGenerateRatio(BigDecimal.ZERO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            giftGoodsScoreDetailMap.put(sku, orderGiftScoreRulesVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                goodsSkuList.forEach(s -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (!giftGoodsScoreDetailMap.containsKey(s)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        OrderGiftScoreRulesVo orderGiftScoreRulesVo = new OrderGiftScoreRulesVo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        orderGiftScoreRulesVo.setGiftScore(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        orderGiftScoreRulesVo.setGenerateRatio(BigDecimal.ZERO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        orderGiftScoreRulesVo.setGenerateType(3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        giftGoodsScoreDetailMap.put(s, orderGiftScoreRulesVo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 增加该会员的积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 Mall2MemberPointsEntity memberPointsEntity = memberPointsDao.queryByUserId(userEntityId); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -2621,10 +2652,10 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (!org.springframework.util.StringUtils.isEmpty(memberCode)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 同步会员订单消费记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 syncMemberConsumeRecord(memberPhone, order, deductionScore); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                syncMemberScoreChangeRecord(openId, order, deductionScore, "下单扣减", queryGoodsVOList, HaiKongMemberScoreChangeEventEnum.SUBTRACT.getEvent()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                syncMemberScoreChangeRecord(openId, order, deductionScore, "下单扣减", queryGoodsVOList, giftGoodsScoreDetailMap, HaiKongMemberScoreChangeEventEnum.SUBTRACT.getEvent()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 积分变动接口,下单扣减 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 Integer score = memberScore.get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                syncMemberScoreChangeRecord(openId, order, score, "下单赠送", queryGoodsVOList, HaiKongMemberScoreChangeEventEnum.ADD.getEvent()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                syncMemberScoreChangeRecord(openId, order, score, "下单赠送", queryGoodsVOList, giftGoodsScoreDetailMap, HaiKongMemberScoreChangeEventEnum.ADD.getEvent()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 生成取票码 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3045,9 +3076,16 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param changeEvent 变动事件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param changeReason 变动原因 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param goodsList 商品详情 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     * @param giftGoodsScoreDetailMap 赠送积分详情 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param score     变动积分 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private void syncMemberScoreChangeRecord(String openId, OrderVo order, Integer score, String changeReason, List<QueryGoodsVO> goodsList, String changeEvent) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void syncMemberScoreChangeRecord(String openId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                             OrderVo order, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                             Integer score, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                             String changeReason, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                             List<QueryGoodsVO> goodsList, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                             Map<String, OrderGiftScoreRulesVo> giftGoodsScoreDetailMap, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                             String changeEvent) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         HaiKongMemberScoreChangeRecordEntity haiKongMemberScoreChangeRecordEntity = new HaiKongMemberScoreChangeRecordEntity(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         MemberScoreChangeDTO memberScoreChangeDTO = new MemberScoreChangeDTO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String changeId = UUID.randomUUID(true).toString(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3081,14 +3119,22 @@ public class OrderServiceImpl implements OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             haiKongMemberScoreChangeRecordEntity.setResendStatus(HaiKongMemberOrderResendStatusEnum.WAIT_RESEND.getStatus()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             haiKongMemberScoreChangeRecordService.save(haiKongMemberScoreChangeRecordEntity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        LOGGER.info("保存会员系统积分变动详情记录中......"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<HaiKongMemberScoreChangeDetailRecordEntity> recordEntityList = goodsList.stream().map(goodsEntity -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             HaiKongMemberScoreChangeDetailRecordEntity entity = new HaiKongMemberScoreChangeDetailRecordEntity(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String sku = goodsEntity.getSku(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            OrderGiftScoreRulesVo orderGiftScoreRulesVo = giftGoodsScoreDetailMap.get(sku); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (Objects.nonNull(orderGiftScoreRulesVo)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                entity.setGenerateRatio(orderGiftScoreRulesVo.getGenerateRatio()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                entity.setGenerateRules(orderGiftScoreRulesVo.getGenerateType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                entity.setGiftScore(orderGiftScoreRulesVo.getGiftScore()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             entity.setOrderSn(order.getOrder_sn()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             entity.setRetailPrice(goodsEntity.getRetailPrice()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             entity.setActualPrice(goodsEntity.getTotalPrice()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             entity.setProductBarcode(goodsEntity.getProdBarcode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             entity.setSellVolume(goodsEntity.getSellVolume()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            entity.setSku(goodsEntity.getSku()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            entity.setSku(sku); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             entity.setDeductionScore(goodsEntity.getDeductionScore()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return entity; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }).collect(Collectors.toList()); 
			 |