From 18e68871f0423910f748a727ceab297a8e4765d1 Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期二, 10 十二月 2024 14:27:50 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java |   47 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 46 insertions(+), 1 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java
index a4d0f97..32c95e5 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java
@@ -1,11 +1,19 @@
 package com.ruoyi.order.controller;
 
+import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.web.controller.BaseController;
 import com.ruoyi.common.core.web.page.TableDataInfo;
 import com.ruoyi.common.security.service.TokenService;
 import com.ruoyi.order.service.ShoppingCartService;
 import com.ruoyi.order.vo.*;
+import com.ruoyi.other.api.domain.GoodsShop;
+import com.ruoyi.other.api.domain.Shop;
+import com.ruoyi.other.api.feignClient.GoodsShopClient;
+import com.ruoyi.other.api.feignClient.ShopClient;
+import com.ruoyi.other.api.vo.GetGoodsShopByGoodsIds;
+import com.ruoyi.system.api.model.LoginUser;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -14,6 +22,9 @@
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
 
 @RestController
 @RequestMapping("/shopping-cart")
@@ -25,6 +36,11 @@
 	
 	@Resource
 	private TokenService tokenService;
+
+	@Resource
+	private GoodsShopClient goodsShopClient;
+	@Resource
+	private ShopClient shopClient;
 	
 	
 	
@@ -88,9 +104,38 @@
 	@ResponseBody
 	@PostMapping("/shoppingCartPayment")
 	@ApiOperation(value = "购物车订单支付", tags = {"商城-购物车-小程序"})
-	public R<Void> shoppingCartPayment(@RequestBody ShoppingCartPayment shoppingCartPayment){
+	public R<String> shoppingCartPayment(@RequestBody ShoppingCartPayment shoppingCartPayment){
 		return shoppingCartService.shoppingCartPayment(shoppingCartPayment);
 	}
+
+
+	@ResponseBody
+	@GetMapping("/getVerifiableShop")
+	@ApiOperation(value = "获取可核销门店列表", tags = {"购物车-小程序"})
+	public R<List<VerifiableShopVo>> getVerifiableShop(){
+		LoginUser loginUser = tokenService.getLoginUserApplet();
+		List<ShoppingCart> shoppingCarts = shoppingCartService.list(new LambdaQueryWrapper<ShoppingCart>()
+				.eq(ShoppingCart::getAppUserId, loginUser.getUserid()));
+
+		List<Integer> goodsIds = shoppingCarts.stream().map(ShoppingCart::getGoodsId).collect(Collectors.toList());
+		GetGoodsShopByGoodsIds goodsShopByGoodsIds = new GetGoodsShopByGoodsIds();
+		goodsShopByGoodsIds.setGoodsIds(goodsIds);
+		R<List<GoodsShop>> r = goodsShopClient.getGoodsShopByGoodsIds(goodsShopByGoodsIds);
+		List<GoodsShop> goodsShops = r.getData();
+		List<VerifiableShopVo> verifiableShopVoList = new ArrayList<>();
+		if (CollectionUtil.isNotEmpty(goodsShops)){
+			for (GoodsShop goodsShop : goodsShops) {
+				R<Shop> shopR = shopClient.getShopById(goodsShop.getShopId());
+				if (R.isSuccess(shopR)){
+					VerifiableShopVo verifiableShopVo = new VerifiableShopVo();
+					verifiableShopVo.setId(shopR.getData().getId());
+					verifiableShopVo.setName(shopR.getData().getName());
+					verifiableShopVoList.add(verifiableShopVo);
+				}
+			}
+		}
+		return R.ok(verifiableShopVoList);
+	}
 	
 	
 }

--
Gitblit v1.7.1