|  | @@ -2,18 +2,29 @@ package com.yami.shop.api.controller;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import cn.hutool.core.util.StrUtil;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
	
		
			
				|  |  | +import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
 | 
	
		
			
				|  |  | +import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
 | 
	
		
			
				|  |  | +import com.github.binarywang.wxpay.config.WxPayConfig;
 | 
	
		
			
				|  |  | +import com.github.binarywang.wxpay.constant.WxPayConstants;
 | 
	
		
			
				|  |  | +import com.github.binarywang.wxpay.service.WxPayService;
 | 
	
		
			
				|  |  | +import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
 | 
	
		
			
				|  |  |  import com.yami.shop.bean.app.param.PayParam;
 | 
	
		
			
				|  |  |  import com.yami.shop.bean.model.Order;
 | 
	
		
			
				|  |  |  import com.yami.shop.bean.model.RefundDelivery;
 | 
	
		
			
				|  |  |  import com.yami.shop.bean.pay.PayInfoDto;
 | 
	
		
			
				|  |  |  import com.yami.shop.common.exception.GlobalException;
 | 
	
		
			
				|  |  |  import com.yami.shop.common.util.Arith;
 | 
	
		
			
				|  |  | +import com.yami.shop.common.util.IPHelper;
 | 
	
		
			
				|  |  |  import com.yami.shop.security.api.model.YamiUser;
 | 
	
		
			
				|  |  |  import com.yami.shop.security.api.util.SecurityUtils;
 | 
	
		
			
				|  |  | -import com.yami.shop.service.*;
 | 
	
		
			
				|  |  | +import com.yami.shop.service.OrderService;
 | 
	
		
			
				|  |  | +import com.yami.shop.service.PayService;
 | 
	
		
			
				|  |  | +import com.yami.shop.service.RefundDeliveryService;
 | 
	
		
			
				|  |  | +import com.yami.shop.wx.config.WechatPayServiceConfig;
 | 
	
		
			
				|  |  |  import com.yami.shop.wx.po.JsapiPayInfoPo;
 | 
	
		
			
				|  |  |  import com.yami.shop.wx.service.WxProviderService;
 | 
	
		
			
				|  |  |  import com.yami.shop.wx.utils.CullenUtils;
 | 
	
		
			
				|  |  | +import com.yami.shop.wx.utils.OrderUtils;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.Api;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  |  import lombok.AllArgsConstructor;
 | 
	
	
		
			
				|  | @@ -34,6 +45,35 @@ public class PayController {
 | 
	
		
			
				|  |  |      private final RefundDeliveryService refundDeliveryService;
 | 
	
		
			
				|  |  |      private final WxProviderService wxProviderService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @SneakyThrows
 | 
	
		
			
				|  |  | +    //@PostMapping("/doPay")
 | 
	
		
			
				|  |  | +    @ApiOperation(value = "ApiV2版本的服务商支付")
 | 
	
		
			
				|  |  | +    public ResponseEntity<?> doPay() {
 | 
	
		
			
				|  |  | +        WechatPayServiceConfig wxConfig = wxProviderService.getWxConfig();
 | 
	
		
			
				|  |  | +        WxPayConfig payConfig = new WxPayConfig();
 | 
	
		
			
				|  |  | +        payConfig.setAppId(wxConfig.getSpAppId());
 | 
	
		
			
				|  |  | +        payConfig.setMchId(wxConfig.getSpMchId());
 | 
	
		
			
				|  |  | +        payConfig.setSubAppId(wxConfig.getSubAppId());
 | 
	
		
			
				|  |  | +        payConfig.setSubMchId(wxConfig.getSubMchId());
 | 
	
		
			
				|  |  | +        payConfig.setMchKey(wxConfig.getApiV3Key());
 | 
	
		
			
				|  |  | +        payConfig.setKeyPath(wxConfig.getKeyPemPath());
 | 
	
		
			
				|  |  | +        WxPayService wxPayService = new WxPayServiceImpl();
 | 
	
		
			
				|  |  | +        wxPayService.setConfig(payConfig);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
 | 
	
		
			
				|  |  | +        orderRequest.setBody("商城下单");
 | 
	
		
			
				|  |  | +        orderRequest.setOutTradeNo(OrderUtils.getOrderNo(""));
 | 
	
		
			
				|  |  | +        orderRequest.setTotalFee(1);
 | 
	
		
			
				|  |  | +        orderRequest.setSpbillCreateIp(IPHelper.getIpAddr());
 | 
	
		
			
				|  |  | +        orderRequest.setSubOpenid("owrSr6y0TGPHBU2tgMVoCO13Gjww");
 | 
	
		
			
				|  |  | +        orderRequest.setNotifyUrl("http://localhost:8112");
 | 
	
		
			
				|  |  | +        orderRequest.setTradeType(WxPayConstants.TradeType.JSAPI);
 | 
	
		
			
				|  |  | +        WxPayMpOrderResult wxPayMpOrderResult = wxPayService.createOrder(orderRequest);
 | 
	
		
			
				|  |  | +        return ResponseEntity.ok(wxPayMpOrderResult);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @SneakyThrows
 | 
	
		
			
				|  |  |      @PostMapping("/pay")
 | 
	
		
			
				|  |  |      @ApiOperation(value = "根据订单号进行支付", notes = "根据订单号进行支付")
 | 
	
	
		
			
				|  | @@ -52,7 +92,8 @@ public class PayController {
 | 
	
		
			
				|  |  |          CullenUtils.validateDataThrowException(payInfo.getPayAmount() < 0.01, "订单金额有误,无法进行支付");
 | 
	
		
			
				|  |  |          JsapiPayInfoPo po = new JsapiPayInfoPo();
 | 
	
		
			
				|  |  |          po.setDescription(payInfo.getBody());
 | 
	
		
			
				|  |  | -        po.setTotal((int) Arith.mul(payInfo.getPayAmount(), 100));
 | 
	
		
			
				|  |  | +        //po.setTotal((int) Arith.mul(payInfo.getPayAmount(), 100));
 | 
	
		
			
				|  |  | +        po.setTotal(1);
 | 
	
		
			
				|  |  |          po.setOpenId(user.getBizUserId());
 | 
	
		
			
				|  |  |          po.setOutTradeNo(payInfo.getPayNo());
 | 
	
		
			
				|  |  |          po.setNotifyUrl(getNotifyUrl("http://localhost:8112"));
 |