From f62b8d5fc74db2391c7769e024e65c2bb51ac6bc Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期五, 11 四月 2025 11:51:12 +0800
Subject: [PATCH] 修改反馈bug

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java |  123 +++++++++++++++++++++++++++++++++++++---
 1 files changed, 113 insertions(+), 10 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 6c92552..4b16e40 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,18 +1,37 @@
 package com.ruoyi.order.controller;
 
+import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.ruoyi.account.api.feignClient.AppUserClient;
+import com.ruoyi.account.api.model.AppUser;
 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.util.payment.model.UniPayCallbackResult;
 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;
 import io.swagger.annotations.ApiOperation;
-import model.ShoppingCart;
+import com.ruoyi.order.model.ShoppingCart;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
 
 @RestController
 @RequestMapping("/shopping-cart")
@@ -21,16 +40,25 @@
 
 	@Resource
 	private ShoppingCartService shoppingCartService;
+	
+	@Resource
+	private TokenService tokenService;
+	
+	@Resource
+	private AppUserClient appUserClient;
+	
+	
+	
 
 	
 	@ResponseBody
-	@GetMapping("/getMyShoppingCart/{type}/{shopId}")
+	@GetMapping("/getMyShoppingCart")
 	@ApiOperation(value = "获取购物车列表", tags = {"商城-购物车-小程序"})
 	@ApiImplicitParams({
 			@ApiImplicitParam(name = "type", value = "商品类型(1=服务商品,2=单品商品)", required = true, dataType = "int"),
 			@ApiImplicitParam(name = "shopId", value = "核销门店id", required = true, dataType = "int")
 	})
-	public TableDataInfo<MyShoppingCartVo> getMyShoppingCart(@PathVariable("type") Integer type, @PathVariable("shopId") Integer shopId){
+	public TableDataInfo<MyShoppingCartVo> getMyShoppingCart(Integer type, Integer shopId){
 		startPage();
 		return getDataTable(shoppingCartService.getMyShoppingCart(type, shopId));
 	}
@@ -46,10 +74,26 @@
 	@ResponseBody
 	@PostMapping("/setGoodsNumber")
 	@ApiOperation(value = "修改购物车数量", tags = {"商城-购物车-小程序"})
-	public R<Void> setGoodsNumber(@RequestBody SetGoodsNumber setGoodsNumber){
-		// todo 待完善 pu
+	public R setGoodsNumber(@RequestBody SetGoodsNumber setGoodsNumber){
+		return shoppingCartService.setGoodsNumber(setGoodsNumber);
+	}
+	
+	
+	
+	@ResponseBody
+	@DeleteMapping("/delShoppingCart")
+	@ApiOperation(value = "删除购物车", tags = {"商城-购物车-小程序"})
+	public R delShoppingCart(Long id){
+		Long userid = tokenService.getLoginUserApplet().getUserid();
+		ShoppingCart shoppingCart = shoppingCartService.getById(id);
+		if(!userid.equals(shoppingCart.getAppUserId())){
+			return R.fail("权限不足,不允许此操作");
+		}
+		shoppingCartService.removeById(id);
 		return R.ok();
 	}
+	
+	
 	
 	
 	
@@ -57,17 +101,76 @@
 	@PostMapping("/confirmOrder")
 	@ApiOperation(value = "确定购物车订单", tags = {"商城-购物车-小程序"})
 	public R<ConfirmOrderVo> confirmOrder(@RequestBody ConfirmOrder confirmOrder){
-		// todo 待完善 pu
-		return R.ok();
+		ConfirmOrderVo confirmOrderVo = shoppingCartService.confirmOrder(confirmOrder);
+		return R.ok(confirmOrderVo);
 	}
 	
 	
 	@ResponseBody
 	@PostMapping("/shoppingCartPayment")
 	@ApiOperation(value = "购物车订单支付", tags = {"商城-购物车-小程序"})
-	public R<Void> shoppingCartPayment(@RequestBody ShoppingCartPayment shoppingCartPayment){
-		// todo 待完善 pu
-		return R.ok();
+	public R<String> shoppingCartPayment(@RequestBody ShoppingCartPayment shoppingCartPayment){
+		return shoppingCartService.shoppingCartPayment(shoppingCartPayment);
+	}
+	
+	/**
+	 * 订单支付回调通知
+	 */
+	@ResponseBody
+	@GetMapping("/shoppingCartPaymentCallback")
+	public void shoppingCartPaymentCallback(UniPayCallbackResult uniPayCallbackResult, HttpServletResponse response){
+		String jsonString = JSONObject.toJSONString(uniPayCallbackResult);
+		System.out.println("1111111111111111111111");
+		System.out.println(jsonString);
+		R callback = shoppingCartService.shoppingCartPaymentCallback(uniPayCallbackResult);
+		if(callback.getCode() == 200){
+			response.setStatus(200);
+			PrintWriter out = null;
+			try {
+				out = response.getWriter();
+			} catch (IOException e) {
+				throw new RuntimeException(e);
+			}
+			out.println("success");
+			out.flush();
+			out.close();
+		}
+	}
+	
+	
+	/**
+	 * 快递费支付回调
+	 * @param uniPayCallbackResult
+	 * @param response
+	 */
+	@ResponseBody
+	@GetMapping("/shoppingCartMaterialFlowPaymentCallback")
+	public void shoppingCartMaterialFlowPaymentCallback(UniPayCallbackResult uniPayCallbackResult, HttpServletResponse response){
+		R callback = shoppingCartService.shoppingCartMaterialFlowPaymentCallback(uniPayCallbackResult);
+		if(callback.getCode() == 200){
+			response.setStatus(200);
+			PrintWriter out = null;
+			try {
+				out = response.getWriter();
+			} catch (IOException e) {
+				throw new RuntimeException(e);
+			}
+			out.println("success");
+			out.flush();
+			out.close();
+		}
+	}
+	
+	
+
+
+
+
+	@GetMapping("/getGoodsPrice")
+	public R<Price> getGoodsPrice(Long appUserId, Integer goodsId, Integer shopId){
+		AppUser appUser = appUserClient.getAppUserById(appUserId);
+		Price price = shoppingCartService.getPrice(appUser, goodsId, 1, shopId);
+		return R.ok(price);
 	}
 	
 	

--
Gitblit v1.7.1