From a0432deb1eb8451c8a4311dffe9dd7472d9e6e0e Mon Sep 17 00:00:00 2001
From: phpcjl <phpcjl@gmail.com>
Date: 星期五, 06 十二月 2024 18:41:54 +0800
Subject: [PATCH] 1.

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java |   82 ++++++++++++++++++++++-------------------
 1 files changed, 44 insertions(+), 38 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 b5cf7dd..23e1522 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
@@ -20,6 +20,7 @@
 import com.ruoyi.order.model.Order;
 import com.ruoyi.order.model.OrderGood;
 import com.ruoyi.order.model.ShoppingCart;
+import com.ruoyi.order.service.CommissionService;
 import com.ruoyi.order.service.OrderGoodService;
 import com.ruoyi.order.service.OrderService;
 import com.ruoyi.order.service.ShoppingCartService;
@@ -97,6 +98,9 @@
 	
 	@Resource
 	private BalanceChangeRecordClient balanceChangeRecordClient;
+	
+	@Resource
+	private CommissionService commissionService;
 	
 	
 	
@@ -417,35 +421,37 @@
 		paymentUserCoupon.setType(confirmOrder.getType());
 		if(confirmOrder.getPaymentType() == 1){
 			List<PaymentUserCouponVo> data = userCouponClient.getPaymentUserCoupon(paymentUserCoupon).getData();
-			for (PaymentUserCouponVo couponInfo : data) {
-				List<Integer> forGoodIds = couponInfo.getForGoodIds();
-				//全部商品适用
-				if(null == forGoodIds){
-					//满减券
-					if(1 == couponInfo.getCouponType() && orderMoney.compareTo(couponInfo.getConditionAmount()) >= 0){
-						couponInfo.setAvailable(true);
-					}
-					//代金券和折扣券
-					if(2 == couponInfo.getCouponType() || 3 == couponInfo.getCouponType()){
-						couponInfo.setAvailable(true);
-					}
-				}else{
-					//部分商品适用
-					BigDecimal goodsMoney = BigDecimal.ZERO;
-					for (MyShoppingCartVo myShoppingCartVo : goodsList) {
-						Integer goodsId = myShoppingCartVo.getGoodsId();
-						BigDecimal cash = myShoppingCartVo.getCash();
-						if(forGoodIds.contains(goodsId)){
-							goodsMoney = goodsMoney.add(cash);
+			if(null != data){
+				for (PaymentUserCouponVo couponInfo : data) {
+					List<Integer> forGoodIds = couponInfo.getForGoodIds();
+					//全部商品适用
+					if(null == forGoodIds){
+						//满减券
+						if(1 == couponInfo.getCouponType() && orderMoney.compareTo(couponInfo.getConditionAmount()) >= 0){
+							couponInfo.setAvailable(true);
 						}
-					}
-					//满减
-					if(1 == couponInfo.getCouponType() && couponInfo.getConditionAmount().compareTo(goodsMoney) <= 0){
-						couponInfo.setAvailable(true);
-					}
-					//代金券
-					if(2 == couponInfo.getCouponType() || 3 == couponInfo.getCouponType()){
-						couponInfo.setAvailable(true);
+						//代金券和折扣券
+						if(2 == couponInfo.getCouponType() || 3 == couponInfo.getCouponType()){
+							couponInfo.setAvailable(true);
+						}
+					}else{
+						//部分商品适用
+						BigDecimal goodsMoney = BigDecimal.ZERO;
+						for (MyShoppingCartVo myShoppingCartVo : goodsList) {
+							Integer goodsId = myShoppingCartVo.getGoodsId();
+							BigDecimal cash = myShoppingCartVo.getCash();
+							if(forGoodIds.contains(goodsId)){
+								goodsMoney = goodsMoney.add(cash);
+							}
+						}
+						//满减
+						if(1 == couponInfo.getCouponType() && couponInfo.getConditionAmount().compareTo(goodsMoney) <= 0){
+							couponInfo.setAvailable(true);
+						}
+						//代金券
+						if(2 == couponInfo.getCouponType() || 3 == couponInfo.getCouponType()){
+							couponInfo.setAvailable(true);
+						}
 					}
 				}
 			}
@@ -489,7 +495,7 @@
 		for (ShoppingCart shoppingCart : list) {
 			Goods goods = goodsClient.getGoodsById(shoppingCart.getGoodsId()).getData();
 			MyShoppingCartVo vo = new MyShoppingCartVo();
-			vo.setId(shoppingCart.getId());
+			vo.setId(shoppingCart.getId().toString());
 			vo.setGoodsId(goods.getId());
 			vo.setHomePicture(goods.getHomePagePicture());
 			vo.setName(goods.getName());
@@ -506,6 +512,7 @@
 			//获取支付价格
 			Price price = getPrice(appUser, shoppingCart.getGoodsId(), shopId);
 			if(null == price){
+				price = new Price();
 				//使用商品的基础价格
 				price.setCash(1 == goods.getCashPayment() ? goods.getSellingPrice() : null);
 				price.setPoint(1 == goods.getPointPayment() ? goods.getIntegral() : null);
@@ -816,6 +823,7 @@
 		order.setShopId(shoppingCartPayment.getShopId());
 		order.setDelFlag(0);
 		order.setCreateTime(LocalDateTime.now());
+		order.setExpressPayMethod(shoppingCartPayment.getFreightPaymentType());
 		
 		if(2 == shoppingCartPayment.getPaymentType()){
 			BigDecimal balance = appUser.getBalance();
@@ -824,7 +832,7 @@
 			}
 		}
 		//判断运费支付是否足够
-		if(2 == shoppingCartPayment.getFreightPaymentType() && expressFee.compareTo(BigDecimal.ZERO) > 0){
+		if(null != shoppingCartPayment.getFreightPaymentType() && 2 == shoppingCartPayment.getFreightPaymentType() && expressFee.compareTo(BigDecimal.ZERO) > 0){
 			BigDecimal balance = appUser.getBalance();
 			if(balance.compareTo(expressFee) < 0){
 				return R.fail("账户余额不足");
@@ -845,14 +853,12 @@
 				orderGood.setSeckillJson(JSON.toJSONString(goodsSeckill));
 			}
 			for (int i = 0; i < objects.size(); i++) {
-				Long id = objects.getJSONObject(i).getLong("id");
-				if(myShoppingCartVo.getId().equals(id)){
-					Integer num1 = objects.getJSONObject(i).getInteger("num");
-					orderGood.setNum(num1);
-					Goods goods1 = goodsClient.getGoodsById(myShoppingCartVo.getGoodsId()).getData();
-					orderGood.setGoodJson(JSON.toJSONString(goods1));
-					break;
-				}
+				Integer id = objects.getJSONObject(i).getInteger("id");
+				Integer num1 = objects.getJSONObject(i).getInteger("num");
+				orderGood.setNum(num1);
+				Goods goods1 = goodsClient.getGoodsById(id).getData();
+				orderGood.setGoodJson(JSON.toJSONString(goods1));
+				break;
 			}
 			orderGood.setDelFlag(0);
 			orderGood.setCreateTime(LocalDateTime.now());

--
Gitblit v1.7.1