zoujiajian 1 year ago
parent
commit
963319e52b

+ 8 - 2
netflix-service/src/main/java/com/cyksj/service/order/impl/GoodsWholesalePayServiceImpl.java

@@ -221,6 +221,9 @@ public class GoodsWholesalePayServiceImpl implements GoodsWholesalePayService {
 			Integer payNum = goodsWholesaleOrderDonMapper.getUserWholesaleNumByUserIds(userIdList, orderDon.getSkuId());
 			log.info("目前用户userId:{}购买批发数量:{}", orderDon.getUserId(), payNum);
 			List<GoodsWholesale.GoodsWholesaleConfig> configs = Jsons.parseList(goodsWholesale.getConfig(), GoodsWholesale.GoodsWholesaleConfig.class);
+			if (configs.size() == 1) {
+				return;
+			}
 			GoodsWholesale.GoodsWholesaleConfig firstConfig = configs.get(0);
 			GoodsWholesale.GoodsWholesaleConfig endConfig = configs.get(configs.size() - 1);
 			//未超过第一档
@@ -420,7 +423,6 @@ public class GoodsWholesalePayServiceImpl implements GoodsWholesalePayService {
 		String configStr = goodsWholesale.getConfig();
 		List<GoodsWholesale.GoodsWholesaleConfig> configs = Jsons.parseList(configStr, GoodsWholesale.GoodsWholesaleConfig.class);
 		GoodsWholesale.GoodsWholesaleConfig firstConfig = configs.get(0);
-		GoodsWholesale.GoodsWholesaleConfig endConfig = configs.get(configs.size() - 1);
 		Integer hasPaidNum = goodsWholesaleOrderDonMapper.getUserWholesaleNumByUserIds(userIdList, goodsWholesale.getSkuId());
 		Integer endPayNum = hasPaidNum + thisPayNum;
 		//未超过第一档
@@ -428,12 +430,16 @@ public class GoodsWholesalePayServiceImpl implements GoodsWholesalePayService {
 			orderDon.setMoney(BigDecimal.valueOf(thisPayNum).multiply(firstConfig.getSingle()));
 			return;
 		}
+		if (configs.size() == 1) {
+			throw BusinessRuntimeException.getInstance("您已无法批发下单该规格");
+		}
+		GoodsWholesale.GoodsWholesaleConfig endConfig = configs.get(configs.size() - 1);
 		//超过最后
 		if (hasPaidNum >= endConfig.getStart()) {
 			orderDon.setMoney(BigDecimal.valueOf(thisPayNum).multiply(endConfig.getSingle()));
 			return;
 		}
-		Optional<GoodsWholesale.GoodsWholesaleConfig> first = configs.stream().filter(config -> config.getStart() <= endPayNum && config.getEnd() >= endPayNum).collect(Collectors.toList()).stream().findFirst();
+		Optional<GoodsWholesale.GoodsWholesaleConfig> first = configs.stream().filter(config -> config.getStart() <= endPayNum && (config.getEnd() >= endPayNum || config.getEnd().intValue() == 999)).collect(Collectors.toList()).stream().findFirst();
 		GoodsWholesale.GoodsWholesaleConfig finalLevel = first.get();
 
 		//之前的