|
@@ -3,6 +3,7 @@ package com.ruoyi.web.controller.front;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
|
|
import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryV3Result;
|
|
import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryV3Result;
|
|
|
|
|
+import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result;
|
|
|
import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum;
|
|
import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum;
|
|
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
@@ -248,25 +249,33 @@ public class FrontECardController extends BaseController {
|
|
|
|
|
|
|
|
order.setNotifyUrl(notifyUrl).setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(totalFee2));
|
|
order.setNotifyUrl(notifyUrl).setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(totalFee2));
|
|
|
|
|
|
|
|
- WxPayUnifiedOrderV3Request.SceneInfo sceneInfo = new WxPayUnifiedOrderV3Request.SceneInfo();
|
|
|
|
|
- sceneInfo.setPayerClientIp(IpUtils.getIpAddr(request));
|
|
|
|
|
- WxPayUnifiedOrderV3Request.H5Info h5Info = new WxPayUnifiedOrderV3Request.H5Info();
|
|
|
|
|
- String os = UserAgent.parseUserAgentString(request.getHeader("User-Agent")).getOperatingSystem().getName();
|
|
|
|
|
- h5Info.setType(os);
|
|
|
|
|
- sceneInfo.setH5Info(h5Info);
|
|
|
|
|
- order.setSceneInfo(sceneInfo);
|
|
|
|
|
- String h5Url = wxService.createOrderV3(TradeTypeEnum.H5, order);
|
|
|
|
|
- String prepayId = StringUtils.substringBetween(h5Url, "prepay_id=", "&package=");
|
|
|
|
|
-
|
|
|
|
|
|
|
+ Map data = new HashMap<>();
|
|
|
BBusiPaymentOrders upOrder = new BBusiPaymentOrders();
|
|
BBusiPaymentOrders upOrder = new BBusiPaymentOrders();
|
|
|
- upOrder.setPrepayId(prepayId);
|
|
|
|
|
- upOrder.setDetail(h5Url);
|
|
|
|
|
|
|
+ if("h5".equals(type)) {
|
|
|
|
|
+ WxPayUnifiedOrderV3Request.SceneInfo sceneInfo = new WxPayUnifiedOrderV3Request.SceneInfo();
|
|
|
|
|
+ sceneInfo.setPayerClientIp(IpUtils.getIpAddr(request));
|
|
|
|
|
+ WxPayUnifiedOrderV3Request.H5Info h5Info = new WxPayUnifiedOrderV3Request.H5Info();
|
|
|
|
|
+ String os = UserAgent.parseUserAgentString(request.getHeader("User-Agent")).getOperatingSystem().getName();
|
|
|
|
|
+ h5Info.setType(os);
|
|
|
|
|
+ sceneInfo.setH5Info(h5Info);
|
|
|
|
|
+ order.setSceneInfo(sceneInfo);
|
|
|
|
|
+ String h5Url = wxService.createOrderV3(TradeTypeEnum.H5, order);
|
|
|
|
|
+ String prepayId = StringUtils.substringBetween(h5Url, "prepay_id=", "&package=");
|
|
|
|
|
+ upOrder.setPrepayId(prepayId);
|
|
|
|
|
+ upOrder.setDetail(h5Url);
|
|
|
|
|
+ data.put("h5url", h5Url);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ WxPayUnifiedOrderV3Result.JsapiResult jsapiResult = wxService.createOrderV3(TradeTypeEnum.JSAPI, order);
|
|
|
|
|
+ String detail = JSONObject.toJSONString(jsapiResult);
|
|
|
|
|
+ String prepayId = StringUtils.substringAfterLast(jsapiResult.getPackageValue(), "prepay_id=");
|
|
|
|
|
+ upOrder.setPrepayId(prepayId);
|
|
|
|
|
+ upOrder.setDetail(detail);
|
|
|
|
|
+ data.put("wcPayData", detail);
|
|
|
|
|
+ }
|
|
|
upOrder.setOutTradeNo(outTradeNo);
|
|
upOrder.setOutTradeNo(outTradeNo);
|
|
|
upOrder.setId(orderId);
|
|
upOrder.setId(orderId);
|
|
|
paymentOrdersService.updateBBusiPaymentOrders(upOrder);
|
|
paymentOrdersService.updateBBusiPaymentOrders(upOrder);
|
|
|
|
|
|
|
|
- Map data = new HashMap<>();
|
|
|
|
|
- data.put("h5url", h5Url);
|
|
|
|
|
data.put("outTradeNo", outTradeNo);
|
|
data.put("outTradeNo", outTradeNo);
|
|
|
data.put("orderId", String.valueOf(orderId));
|
|
data.put("orderId", String.valueOf(orderId));
|
|
|
return AjaxResult.success(data);
|
|
return AjaxResult.success(data);
|