liujie
2026-07-22 fdd6c6769ee253cd20392383aa52a3d73f933619
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TGoodsController.java
@@ -36,10 +36,11 @@
import com.ruoyi.other.service.TGoodsService;
import com.ruoyi.other.util.RedisLock;
import com.ruoyi.payment.api.feignClient.AliPaymentClient;
import com.ruoyi.payment.api.feignClient.WxPaymentClient;
import com.ruoyi.payment.api.feignClient.IcbcPaymentClient;
import com.ruoyi.payment.api.vo.AliPaymentReq;
import com.ruoyi.payment.api.vo.AliPaymentResp;
import com.ruoyi.payment.api.vo.PaymentOrder;
import com.ruoyi.payment.api.vo.IcbcPaymentReq;
import com.ruoyi.payment.api.vo.IcbcPaymentResp;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
@@ -80,7 +81,7 @@
    @Resource
    private TCouponService couponService;
    @Resource
    private WxPaymentClient wxPaymentClient;
    private IcbcPaymentClient icbcPaymentClient;
    @Resource
    private RedisService redisService;
    
@@ -379,18 +380,31 @@
        exchangeDto.setVipDiscount(vipDiscount);
        exchangeDto.setUserId(userId);
        exchangeDto.setPhone(user.getPhone());
        boolean wechatMiniProgramPay = exchangeDto.getPayMethod() == 1;
        if (wechatMiniProgramPay) {
            exchangeDto.setPayMethod(3);
        }
        //创建订单
        TShoppingOrder shopOrder = orderClient.shopCreate(exchangeDto).getData();
        if (exchangeDto.getPayMethod()==1) {
            //调起支付
            PaymentOrder paymentOrder = new PaymentOrder();
            paymentOrder.setCode(shopOrder.getCode());
            paymentOrder.setAmount(exchangeDto.getPayPrice());
            paymentOrder.setOpenId(user.getWxOpenid());
            paymentOrder.setDescription("购买商品");
            R<Map<String, Object>> mapR = wxPaymentClient.orderPay(paymentOrder);
            mapR.getData().put("orderId",shopOrder.getId().toString());
            return    mapR;
        if (wechatMiniProgramPay) {
            IcbcPaymentReq paymentReq = new IcbcPaymentReq();
            paymentReq.setOutTradeNo(shopOrder.getCode());
            paymentReq.setAmount(exchangeDto.getPayPrice());
            paymentReq.setOpenId(user.getWxOpenid());
            paymentReq.setPaymentType(1);
            paymentReq.setSubject("购买商品");
            paymentReq.setBody(exchangeDto.getTitle());
            R<IcbcPaymentResp> paymentResult = icbcPaymentClient.payment(paymentReq);
            if (paymentResult == null || paymentResult.getCode() != 200 || paymentResult.getData() == null) {
                return R.fail(paymentResult == null ? "工行支付无响应" : paymentResult.getMsg());
            }
            IcbcPaymentResp paymentResp = paymentResult.getData();
            if (!"SUCCESS".equals(paymentResp.getStatus())) {
                return R.fail(paymentResp.getRawResponse());
            }
            Map<String, Object> data = JSON.parseObject(JSON.toJSONString(paymentResp), Map.class);
            data.put("orderId", shopOrder.getId().toString());
            return R.ok(data);
        }else {
            AliPaymentReq req = new AliPaymentReq();
            req.setOutTradeNo(shopOrder.getCode());