Pu Zhibing
2025-01-01 513961ecebcfd0619ede7a7edb7ac5e27de28d26
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ShoppingCartController.java
@@ -2,11 +2,14 @@
import cn.hutool.core.collection.CollectionUtil;
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;
@@ -22,6 +25,9 @@
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;
@@ -41,6 +47,8 @@
   private GoodsShopClient goodsShopClient;
   @Resource
   private ShopClient shopClient;
   @Resource
   private AppUserClient appUserClient;
   
   
   
@@ -107,7 +115,53 @@
   public R<String> shoppingCartPayment(@RequestBody ShoppingCartPayment shoppingCartPayment){
      return shoppingCartService.shoppingCartPayment(shoppingCartPayment);
   }
   /**
    * 订单支付回调通知
    */
   @ResponseBody
   @GetMapping("/shoppingCartPaymentCallback")
   public void shoppingCartPaymentCallback(UniPayCallbackResult uniPayCallbackResult, HttpServletResponse response){
      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();
      }
   }
   @ResponseBody
   @GetMapping("/getVerifiableShop")
@@ -136,6 +190,14 @@
      }
      return R.ok(verifiableShopVoList);
   }
   @GetMapping("/getGoodsPrice")
   public R<Price> getGoodsPrice(Long appUserId, Integer goodsId, Integer shopId){
      AppUser appUser = appUserClient.getAppUserById(appUserId);
      Price price = shoppingCartService.getPrice(appUser, goodsId, shopId);
      return R.ok(price);
   }
   
   
}