From 071153064e6771e377ee148712be012dba9e13c5 Mon Sep 17 00:00:00 2001
From: phpcjl <phpcjl@gmail.com>
Date: 星期二, 10 十二月 2024 19:25:35 +0800
Subject: [PATCH] 1.

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java |  210 ++++++++++++++++++----------------------------------
 1 files changed, 72 insertions(+), 138 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 d589c8d..dc8cb2b 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
@@ -27,7 +27,6 @@
 import com.ruoyi.other.api.vo.GetGoodsBargainPrice;
 import com.ruoyi.other.api.vo.GetGoodsShopByGoodsIds;
 import com.ruoyi.other.api.vo.GetSeckillActivityInfo;
-import lombok.Data;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -35,81 +34,80 @@
 import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
 public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, ShoppingCart> implements ShoppingCartService {
-	
+
 	@Resource
 	private TokenService tokenService;
-	
+
 	@Resource
 	private GoodsClient goodsClient;
-	
+
 	@Resource
 	private GoodsShopClient goodsShopClient;
-	
+
 	@Resource
 	private AppUserClient appUserClient;
-	
+
 	@Resource
 	private GoodsAreaClient goodsAreaClient;
-	
+
 	@Resource
 	private GoodsVipClient goodsVipClient;
-	
+
 	@Resource
 	private SeckillActivityInfoClient seckillActivityInfoClient;
-	
+
 	@Resource
 	private GoodsBargainPriceClient goodsBargainPriceClient;
-	
+
 	@Resource
 	private OrderService orderService;
-	
+
 	@Resource
 	private OrderGoodService orderGoodService;
-	
+
 	@Resource
 	private ShopClient shopClient;
-	
+
 	@Resource
 	private OrderActivityInfoClient orderActivityInfoClient;
-	
+
 	@Resource
 	private BaseSettingClient baseSettingClient;
-	
+
 	@Resource
 	private UserAddressClient userAddressClient;
-	
+
 	@Resource
 	private UserCouponClient userCouponClient;
-	
+
 	@Resource
 	private SystemConfigClient systemConfigClient;
-	
+
 	@Resource
 	private UserPointClient userPointClient;
-	
+
 	@Resource
 	private BalanceChangeRecordClient balanceChangeRecordClient;
-	
+
 	@Resource
 	private CommissionService commissionService;
-	
+
 	@Resource
 	private VipSettingClient vipSettingClient;
-	
+
 	@Resource
 	private UserChangeLogClient userChangeLogClient;
-	
-	
-	
-	
-	
-	
+
+
+
+
+
+
 	/**
 	 * 获取购物车列表
 	 * @param type
@@ -132,8 +130,8 @@
 		List<MyShoppingCartVo> page = buildDetail(appUser, shopId, list, null);
 		return page;
 	}
-	
-	
+
+
 	/**
 	 * 获取支付价格
 	 * @param appUser
@@ -155,8 +153,11 @@
 			GetGoodsBargainPrice goodsBargainPrice = new GetGoodsBargainPrice();
 			goodsBargainPrice.setGoodsId(goodsId);
 			goodsBargainPrice.setVip(appUser.getVipId());
-			goodsBargainPrice.setShopId(shopId);
-			GoodsBargainPriceDetail bargainPriceDetail = goodsBargainPriceClient.getGoodsBargainPrice(goodsBargainPrice).getData();
+			GoodsBargainPriceDetail bargainPriceDetail = null;
+			if (shopId != null){
+				goodsBargainPrice.setShopId(shopId);
+				bargainPriceDetail = goodsBargainPriceClient.getGoodsBargainPrice(goodsBargainPrice).getData();
+			}
 			if(null == bargainPriceDetail){
 				//没有门店特价,判断地区价格配置
 				GoodsArea area = new GoodsArea();
@@ -174,8 +175,8 @@
 					}else{
 						price.setCash(goodsVip.getSellingPrice());
 						price.setPoint(goodsVip.getIntegral());
-						price.setCashPayment(goodsVip.getCashPayment() == 1 ? true : false);
-						price.setPointPayment(goodsVip.getPointPayment() == 1 ? true : false);
+						price.setCashPayment(goodsVip.getCashPayment() == 1);
+						price.setPointPayment(goodsVip.getPointPayment() == 1);
 						price.setEarnSpendingPoints(goodsVip.getEarnSpendingPoints());
 						price.setSuperiorSubcommission(goodsVip.getSuperiorSubcommission());
 						price.setSuperiorRebatePoints(goodsVip.getSuperiorRebatePoints());
@@ -191,8 +192,8 @@
 				}else{
 					price.setCash(goodsArea.getSellingPrice());
 					price.setPoint(goodsArea.getIntegral());
-					price.setCashPayment(goodsArea.getCashPayment() == 1 ? true : false);
-					price.setPointPayment(goodsArea.getPointPayment() == 1 ? true : false);
+					price.setCashPayment(goodsArea.getCashPayment() == 1);
+					price.setPointPayment(goodsArea.getPointPayment() == 1);
 					price.setEarnSpendingPoints(goodsArea.getEarnSpendingPoints());
 					price.setSuperiorSubcommission(goodsArea.getSuperiorSubcommission());
 					price.setSuperiorRebatePoints(goodsArea.getSuperiorRebatePoints());
@@ -208,8 +209,8 @@
 			}else{
 				price.setCash(bargainPriceDetail.getSellingPrice());
 				price.setPoint(bargainPriceDetail.getIntegral());
-				price.setCashPayment(bargainPriceDetail.getSellingPrice() != null ? true : false);
-				price.setPointPayment(bargainPriceDetail.getIntegral() != null ? true : false);
+				price.setCashPayment(bargainPriceDetail.getSellingPrice() != null);
+				price.setPointPayment(bargainPriceDetail.getIntegral() != null);
 				//门店特价,消费积分使用会员等级的消费积分
 				GoodsArea area = new GoodsArea();
 				area.setDistrictsCode(appUser.getDistrictCode());
@@ -241,8 +242,8 @@
 			if(goodsSeckill.getCashPayment() == 0 && goodsSeckill.getPointPayment() == 1){
 				price.setPoint(goodsSeckill.getIntegral());
 			}
-			price.setCashPayment(goodsSeckill.getCashPayment() == 1 ? true : false);
-			price.setPointPayment(goodsSeckill.getPointPayment() == 1 ? true : false);
+			price.setCashPayment(goodsSeckill.getCashPayment() == 1);
+			price.setPointPayment(goodsSeckill.getPointPayment() == 1);
 			price.setEndTime(goodsSeckill.getEndTime());
 			price.setEarnSpendingPoints(goodsSeckill.getEarnSpendingPoints());
 			price.setSuperiorSubcommission(goodsSeckill.getSuperiorSubcommission());
@@ -258,76 +259,9 @@
 		}
 		return price;
 	}
-	
-	
-	@Data
-	class Price {
-		/**
-		 * 现金
-		 */
-		private BigDecimal cash;
-		/**
-		 * 积分
-		 */
-		private Integer point;
-		/**
-		 * 获取结束时间
-		 */
-		private Long endTime;
-		/**
-		 * 现金支付
-		 */
-		private Boolean cashPayment;
-		/**
-		 * 积分支付
-		 */
-		private Boolean pointPayment;
-		/**
-		 * 可获得消费积分
-		 */
-		private Integer earnSpendingPoints;
-		/**
-		 * 上级获得分佣金额
-		 */
-		private BigDecimal superiorSubcommission;
-		/**
-		 * 上级获得返佣积分
-		 */
-		private Integer superiorRebatePoints;
-		/**
-		 * 获取返佣积分上级类型(1=直推上级,2=直帮上级)
-		 */
-		private Integer superiorType;
-		/**
-		 * 核销门店可获得服务费
-		 */
-		private BigDecimal servuceShopCharges;
-		/**
-		 * 核销门店可获得服务积分
-		 */
-		private Integer servuceShopPoints;
-		/**
-		 * 技师可获得服务积分
-		 */
-		private Integer technicianPoints;
-		/**
-		 * 绑定门店可获得分佣金额
-		 */
-		private BigDecimal boundShopCharges;
-		/**
-		 * 绑定门店可获得返佣积分
-		 */
-		private Integer boundShopPoints;
-		/**
-		 * 绑定门店上级门店可获得分佣金额
-		 */
-		private BigDecimal boundShopSuperiorsCharges;
-		/**
-		 * 绑定门店上级门店可获得返佣积分
-		 */
-		private Integer boundShopSuperiorsPoints;
-	}
-	
+
+
+
 
 	@Override
 	public Long addGoods(ShoppingCart shoppingCart) {
@@ -336,8 +270,8 @@
 		this.save(shoppingCart);
 		return shoppingCart.getId();
 	}
-	
-	
+
+
 	/**
 	 * 修改购物车数量
 	 * @param setGoodsNumber
@@ -362,8 +296,8 @@
 		}
 		return R.ok();
 	}
-	
-	
+
+
 	/**
 	 * 确认购物车订单
 	 * @param confirmOrder
@@ -500,8 +434,8 @@
 		}
 		return confirmOrderVo;
 	}
-	
-	
+
+
 	/**
 	 * 构建购物车商品列表
 	 * @param appUser
@@ -581,8 +515,8 @@
 		}
 		return page;
 	}
-	
-	
+
+
 	/**
 	 * 购物车支付操作
 	 * @param shoppingCartPayment
@@ -619,7 +553,7 @@
 			}
 			ids.add(id);
 		}
-		
+
 		List<ShoppingCart> list = this.listByIds(ids);
 		//构建商品明细列表
 		List<MyShoppingCartVo> goodsList = buildDetail(appUser, shopId, list, objects);
@@ -689,7 +623,7 @@
 		BigDecimal discountAmount = BigDecimal.ZERO;
 		//活动优惠金额
 		BigDecimal activityAmount = BigDecimal.ZERO;
-		
+
 		//减去优惠券优惠金额
 		CouponInfoVo couponInfoVo = null;
 		if(null != shoppingCartPayment.getUserCouponId() && 3 != shoppingCartPayment.getPaymentType()){
@@ -732,7 +666,7 @@
 						paymentMoney = paymentMoney.add(cash);
 					}
 				}
-				
+
 				//满减
 				if(1 == couponInfoVo.getCouponType() && couponInfoVo.getConditionAmount().compareTo(goodsMoney) <= 0){
 					goodsMoney = goodsMoney.subtract(couponInfoVo.getDiscountAmount());
@@ -757,7 +691,7 @@
 				paymentMoney = paymentMoney.add(goodsMoney);
 			}
 		}
-		
+
 		//查询当前是否有订单活动
 		OrderActivityInfo orderActivityInfo = orderActivityInfoClient.getNowOrderActivityInfo(appUser.getVipId()).getData();
 		BaseSetting baseSetting = baseSettingClient.getBaseSetting(4).getData();
@@ -774,7 +708,7 @@
 			paymentMoney = paymentMoney1;
 			activityAmount = activityAmount.add(bigDecimal);
 		}
-		
+
 		//可获得的消费积分
 		int earnPoint = 0;
 		for (MyShoppingCartVo myShoppingCartVo : goodsList) {
@@ -783,7 +717,7 @@
 		if(null != shoppingCartPayment.getUserAddressId()){
 			userAddressClient.getUserAddressById(shoppingCartPayment.getUserAddressId()).getData();
 		}
-		
+
 		//获取快递策略,计算快递费
 		BigDecimal expressFee = BigDecimal.ZERO;
 		if(null != shoppingCartPayment.getUserAddressId()){
@@ -855,7 +789,7 @@
 		order.setDelFlag(0);
 		order.setCreateTime(LocalDateTime.now());
 		order.setExpressPayMethod(shoppingCartPayment.getFreightPaymentType());
-		
+
 		if(2 == shoppingCartPayment.getPaymentType()){
 			BigDecimal balance = appUser.getBalance();
 			if(balance.compareTo(paymentMoney) < 0){
@@ -869,7 +803,7 @@
 				return R.fail("账户余额不足");
 			}
 		}
-		
+
 		orderService.save(order);
 		//构建订单明细数据
 		for (MyShoppingCartVo myShoppingCartVo : goodsList) {
@@ -909,15 +843,15 @@
 			orderGood.setBoundShopSuperiorsPoints(myShoppingCartVo.getBoundShopSuperiorsPoints());
 			orderGoodService.save(orderGood);
 		}
-		
+
 		//开始构建支付数据
 		//现金支付
 		paymentMoney = paymentMoney.add(expressFee).setScale(2, RoundingMode.HALF_EVEN);
 		if(1 == shoppingCartPayment.getPaymentType()){
 			//调起微信支付 TODO 待完善
-			
-			
-			
+
+
+
 		}
 		//账户余额
 		if(2 == shoppingCartPayment.getPaymentType()){
@@ -952,7 +886,7 @@
 				appUser.setShopPoint(appUser.getShopPoint() + earnPoint);
 				appUser.setLavePoint(appUser.getLavePoint() + earnPoint);
 				appUser.setTotalPoint(appUser.getTotalPoint() + earnPoint);
-				
+
 				UserPoint userPoint = new UserPoint();
 				userPoint.setType(1);
 				userPoint.setHistoricalPoint(appUser.getLavePoint() - earnPoint);
@@ -997,7 +931,7 @@
 			appUserClient.editAppUserById(appUser);
 			//检查消费积分满足后升级会员
 			vipUpgrade(appUser);
-			
+
 			//构建积分流水记录
 			UserPoint userPoint = new UserPoint();
 			userPoint.setType(4);
@@ -1051,7 +985,7 @@
 							appUser.setBalance(balance);
 						}
 					}
-					
+
 					appUserClient.editAppUserById(appUser);
 					//构建余额明细变动记录
 					BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord();
@@ -1080,8 +1014,8 @@
 		}
 		return R.ok(order.getId().toString());
 	}
-	
-	
+
+
 	public String getNumber(Integer size){
 		String str = "";
 		for (Integer i = 0; i < size; i++) {
@@ -1089,8 +1023,8 @@
 		}
 		return str;
 	}
-	
-	
+
+
 	/**
 	 * 会员等级变化
 	 * @param appUser

--
Gitblit v1.7.1