From d20ede4470f761d0c76a0c993170ebbd96a1bcc1 Mon Sep 17 00:00:00 2001
From: luofl <1442745593@qq.com>
Date: 星期二, 11 二月 2025 11:33:19 +0800
Subject: [PATCH] 修改物流信息导入模板

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java |  106 ++++++++++++++++++++++++++++++++--------------------
 1 files changed, 65 insertions(+), 41 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java
index abe0af2..efbe37e 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java
@@ -142,6 +142,9 @@
 			throw new RuntimeException("根据类型(1=服务商品,2=单品商品)获取商品数据失败");
 		}
 		List<Integer> goodsIds = data.stream().map(Goods::getId).collect(Collectors.toList());
+		if(goodsIds.isEmpty()){
+			return new ArrayList<>();
+		}
 		//查询符合商品类型的商品数据
 		List<ShoppingCart> list = this.list(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid)
 				.in(ShoppingCart::getGoodsId, goodsIds).eq(ShoppingCart::getStatus, 1));
@@ -337,7 +340,20 @@
 				.eq(ShoppingCart::getAppUserId, userid));
 		goodsSaleNum += count;
 		Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData();
-		if(null != goods.getPurchaseLimit() && -1 != goods.getPurchaseLimit() && (goodsSaleNum + shoppingCart.getNumber()) > goods.getPurchaseLimit()){
+
+		Integer maxNum = 0;
+		if(shoppingCart.getType() == 2){
+			R<SeckillActivityInfo> r = seckillActivityInfoClient.getSeckillActivityInfoByGoodsId(shoppingCart.getGoodsId());
+			if (R.isError(r)){
+				throw new ServiceException("获取秒杀商品失败!");
+			}
+			SeckillActivityInfo seckillActivityInfo = r.getData();
+			maxNum = seckillActivityInfo.getMaxNum();
+		}else {
+			maxNum = goods.getPurchaseLimit();
+		}
+
+		if(null != goods.getPurchaseLimit() && -1 != maxNum && (goodsSaleNum + shoppingCart.getNumber()) > maxNum){
 			throw new ServiceException("超出购买数量限制");
 		}
 		ShoppingCart one = this.getOne(new LambdaQueryWrapper<ShoppingCart>().eq(ShoppingCart::getAppUserId, userid)
@@ -1131,16 +1147,18 @@
 						jsonObject.put("transferablePoint", earnPoint1);
 					}
 
-					UserPoint userPoint = new UserPoint();
-					userPoint.setType(1);
-					userPoint.setHistoricalPoint(lavePoint);
-					userPoint.setVariablePoint(earnPoint);
-					userPoint.setBalance(appUser.getLavePoint());
-					userPoint.setCreateTime(LocalDateTime.now());
-					userPoint.setAppUserId(appUser.getId());
-					userPoint.setObjectId(order.getId());
-					userPoint.setExtention(jsonObject.toJSONString());
-					userPointClient.saveUserPoint(userPoint);
+					if(earnPoint > 0){
+						UserPoint userPoint = new UserPoint();
+						userPoint.setType(1);
+						userPoint.setHistoricalPoint(lavePoint);
+						userPoint.setVariablePoint(earnPoint);
+						userPoint.setBalance(appUser.getLavePoint());
+						userPoint.setCreateTime(LocalDateTime.now());
+						userPoint.setAppUserId(appUser.getId());
+						userPoint.setObjectId(order.getId());
+						userPoint.setExtention(jsonObject.toJSONString());
+						userPointClient.saveUserPoint(userPoint);
+					}
 				}
 				appUser.setShopAmount(appUser.getShopAmount().add(paymentMoney).setScale(2, RoundingMode.HALF_EVEN));
 				appUser.setLastShopTime(LocalDateTime.now());
@@ -1315,16 +1333,18 @@
 			}
 
 			//构建积分流水记录
-			UserPoint userPoint = new UserPoint();
-			userPoint.setType(11);
-			userPoint.setHistoricalPoint(lavePoint);
-			userPoint.setVariablePoint(orderPoint);
-			userPoint.setBalance(appUser.getLavePoint());
-			userPoint.setCreateTime(LocalDateTime.now());
-			userPoint.setAppUserId(appUser.getId());
-			userPoint.setObjectId(order.getId());
-			userPoint.setExtention((tra >= 0 ? orderPoint : transferablePoint) + "");
-			userPointClient.saveUserPoint(userPoint);
+			if(orderPoint > 0){
+				UserPoint userPoint = new UserPoint();
+				userPoint.setType(11);
+				userPoint.setHistoricalPoint(lavePoint);
+				userPoint.setVariablePoint(orderPoint);
+				userPoint.setBalance(appUser.getLavePoint());
+				userPoint.setCreateTime(LocalDateTime.now());
+				userPoint.setAppUserId(appUser.getId());
+				userPoint.setObjectId(order.getId());
+				userPoint.setExtention((tra >= 0 ? orderPoint : transferablePoint) + "");
+				userPointClient.saveUserPoint(userPoint);
+			}
 
 			appUser.setLastShopTime(LocalDateTime.now());
 			appUserClient.editAppUserById(appUser);
@@ -1460,16 +1480,18 @@
 				jsonObject.put("transferablePoint", earnPoint1);
 			}
 
-			UserPoint userPoint = new UserPoint();
-			userPoint.setType(1);
-			userPoint.setHistoricalPoint(lavePoint);
-			userPoint.setVariablePoint(earnPoint);
-			userPoint.setBalance(appUser.getLavePoint());
-			userPoint.setCreateTime(LocalDateTime.now());
-			userPoint.setAppUserId(appUser.getId());
-			userPoint.setObjectId(order.getId());
-			userPoint.setExtention(jsonObject.toJSONString());
-			userPointClient.saveUserPoint(userPoint);
+			if(earnPoint > 0){
+				UserPoint userPoint = new UserPoint();
+				userPoint.setType(1);
+				userPoint.setHistoricalPoint(lavePoint);
+				userPoint.setVariablePoint(earnPoint);
+				userPoint.setBalance(appUser.getLavePoint());
+				userPoint.setCreateTime(LocalDateTime.now());
+				userPoint.setAppUserId(appUser.getId());
+				userPoint.setObjectId(order.getId());
+				userPoint.setExtention(jsonObject.toJSONString());
+				userPointClient.saveUserPoint(userPoint);
+			}
 		}
 		appUser.setShopAmount(appUser.getShopAmount().add(paymentMoney).setScale(2, RoundingMode.HALF_EVEN));
 		appUser.setLastShopTime(LocalDateTime.now());
@@ -1539,16 +1561,18 @@
 		}
 
 		//构建积分流水记录
-		UserPoint userPoint = new UserPoint();
-		userPoint.setType(11);
-		userPoint.setHistoricalPoint(lavePoint);
-		userPoint.setVariablePoint(orderPoint);
-		userPoint.setBalance(appUser.getLavePoint());
-		userPoint.setCreateTime(LocalDateTime.now());
-		userPoint.setAppUserId(appUser.getId());
-		userPoint.setObjectId(order.getId());
-		userPoint.setExtention((tra >= 0 ? orderPoint : transferablePoint) + "");
-		userPointClient.saveUserPoint(userPoint);
+		if(orderPoint > 0){
+			UserPoint userPoint = new UserPoint();
+			userPoint.setType(11);
+			userPoint.setHistoricalPoint(lavePoint);
+			userPoint.setVariablePoint(orderPoint);
+			userPoint.setBalance(appUser.getLavePoint());
+			userPoint.setCreateTime(LocalDateTime.now());
+			userPoint.setAppUserId(appUser.getId());
+			userPoint.setObjectId(order.getId());
+			userPoint.setExtention((tra >= 0 ? orderPoint : transferablePoint) + "");
+			userPointClient.saveUserPoint(userPoint);
+		}
 
 		//积分支付不反积分
 

--
Gitblit v1.7.1