From 6f54cebf07887237f5eb8efdf9d1d0b784dbaa49 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期二, 10 十二月 2024 10:05:20 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/ShoppingCartServiceImpl.java |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 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 4e0068c..0665cec 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
@@ -327,10 +327,11 @@
 	
 
 	@Override
-	public void addGoods(ShoppingCart shoppingCart) {
+	public Long addGoods(ShoppingCart shoppingCart) {
 		Long userid = tokenService.getLoginUserApplet().getUserid();
 		shoppingCart.setAppUserId(userid);
 		this.save(shoppingCart);
+		return shoppingCart.getId();
 	}
 	
 	
@@ -412,6 +413,7 @@
 		confirmOrderVo.setResidualPoint(appUser.getLavePoint().intValue());
 		//获取默认收货地址
 		UserAddress userAddress = userAddressClient.getDefaultUserAddress(userid).getData();
+		userAddress.setIdStr(userAddress.getId().toString());
 		confirmOrderVo.setUserAddress(userAddress);
 		confirmOrderVo.setPaymentType(confirmOrder.getPaymentType());
 		//获取用户优惠券,用户全部优惠券,不能使用的需要标识出来置灰展示
@@ -570,7 +572,22 @@
 	 */
 	@Override
 	public R shoppingCartPayment(ShoppingCartPayment shoppingCartPayment) {
+		Integer position = shoppingCartPayment.getPosition();
 		Long userid = tokenService.getLoginUserApplet().getUserid();
+		//直接购买商品
+		if(2 == position){
+			//先加入购物车
+			String goodsJson = shoppingCartPayment.getGoodsJson();
+			JSONArray objects = JSON.parseArray(goodsJson);
+			Long id = objects.getJSONObject(0).getLong("id");
+			Integer num1 = objects.getJSONObject(0).getInteger("num");
+			ShoppingCart shoppingCart = new ShoppingCart();
+			shoppingCart.setAppUserId(userid);
+			shoppingCart.setGoodsId(id.intValue());
+			shoppingCart.setNumber(num1);
+			Long shoppingCarId = addGoods(shoppingCart);
+			shoppingCartPayment.setGoodsJson("[{\"id\": " + shoppingCarId + ", \"num\": " + num1 + "}]");
+		}
 		AppUser appUser = appUserClient.getAppUserById(userid);
 		Integer shopId = shoppingCartPayment.getShopId();
 		String goodsJson = shoppingCartPayment.getGoodsJson();

--
Gitblit v1.7.1