fix
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
package com.starry.admin.modules.weichat.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
|
||||
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
||||
import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderResult;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import com.github.binarywang.wxpay.util.SignUtils;
|
||||
import com.starry.admin.common.aspect.CustomUserLogin;
|
||||
import com.starry.admin.common.conf.ThreadLocalRequestDetail;
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
@@ -126,6 +121,15 @@ public class WxPlayController {
|
||||
//}
|
||||
|
||||
|
||||
@CustomUserLogin
|
||||
@GetMapping("/custom/getCustomPaymentAmount")
|
||||
public R getCustomPaymentAmount(@RequestParam("money") String money) {
|
||||
if (StringUtils.isEmpty(money)) {
|
||||
throw new CustomException("请求参数错误,money不能为空");
|
||||
}
|
||||
BigDecimal paymentAmount = customUserInfoService.getCustomPaymentAmount(new BigDecimal(money), ThreadLocalRequestDetail.getCustomUserInfo().getId());
|
||||
return R.ok(paymentAmount);
|
||||
}
|
||||
@CustomUserLogin
|
||||
@GetMapping("/custom/createOrder")
|
||||
public R createOrder(@RequestParam("money") String money) {
|
||||
@@ -143,42 +147,45 @@ public class WxPlayController {
|
||||
// 订单总金额,单位为分
|
||||
long totalFee = getTotalFee(money);
|
||||
// 创建订单信息
|
||||
String orderNo = playOrderInfoService.getOrderNo();
|
||||
orderInfoService.createRechargeOrder(orderNo, new BigDecimal(totalFee * 1.0 / 100), new BigDecimal(totalFee * 1.0 / 100), customUserInfo.getId());
|
||||
// String orderNo = playOrderInfoService.getOrderNo();
|
||||
String orderId = IdUtil.fastSimpleUUID();
|
||||
orderInfoService.createRechargeOrder(orderId, new BigDecimal(totalFee * 1.0 / 100), new BigDecimal(totalFee * 1.0 / 100), customUserInfo.getId());
|
||||
customUserInfoService.customAccountBalanceRecharge(new BigDecimal(money), ThreadLocalRequestDetail.getCustomUserInfo().getId(), orderId);
|
||||
return R.ok("充值成功");
|
||||
|
||||
WxPayService wxPayService = mpService.getWxPay();
|
||||
WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest();
|
||||
request.setOpenid(customUserInfo.getOpenid());
|
||||
// 订单总金额,单位为分(开发阶段固定设置为支付1分钱)
|
||||
request.setTotalFee(1);
|
||||
request.setOutTradeNo(orderNo);
|
||||
request.setTradeType("JSAPI");
|
||||
request.setSpbillCreateIp("101.43.206.16");
|
||||
request.setNotifyUrl(wxPayService.getConfig().getNotifyUrl());
|
||||
request.setBody("船票充值");
|
||||
WxPayUnifiedOrderResult orderResult;
|
||||
try {
|
||||
orderResult = wxPayService.unifiedOrder(request);
|
||||
} catch (WxPayException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
String prepayId = orderResult.getPrepayId();
|
||||
//组合参数构建支付
|
||||
Map<String, String> paySignInfo = new HashMap<>(5);
|
||||
String timeStamp = String.valueOf(System.currentTimeMillis());
|
||||
String nonceStr = "dalfhh241lnandnsklajax";
|
||||
paySignInfo.put("appId", wxPayService.getConfig().getAppId());
|
||||
paySignInfo.put("nonceStr", nonceStr);
|
||||
paySignInfo.put("timeStamp", timeStamp);
|
||||
paySignInfo.put("signType", "MD5");
|
||||
paySignInfo.put("package", "prepay_id=" + prepayId);
|
||||
String[] signInfo = new String[0];
|
||||
String paySign = SignUtils.createSign(paySignInfo, "MD5", wxPayService.getConfig().getMchKey(), signInfo);
|
||||
|
||||
//组合支付参数
|
||||
JSONObject jsonObject = new JSONObject().fluentPut("appId", wxPayService.getConfig().getAppId()).fluentPut("timeStamp", timeStamp).fluentPut("nonceStr", nonceStr).fluentPut("package", "prepay_id=" + prepayId).fluentPut("signType", "MD5").fluentPut("paySign", paySign);
|
||||
return R.ok(jsonObject);
|
||||
// WxPayService wxPayService = mpService.getWxPay();
|
||||
// WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest();
|
||||
// request.setOpenid(customUserInfo.getOpenid());
|
||||
// // 订单总金额,单位为分(开发阶段固定设置为支付1分钱)
|
||||
// request.setTotalFee(1);
|
||||
// request.setOutTradeNo(orderNo);
|
||||
// request.setTradeType("JSAPI");
|
||||
// request.setSpbillCreateIp("101.43.206.16");
|
||||
// request.setNotifyUrl(wxPayService.getConfig().getNotifyUrl());
|
||||
// request.setBody("船票充值");
|
||||
// WxPayUnifiedOrderResult orderResult;
|
||||
// try {
|
||||
// orderResult = wxPayService.unifiedOrder(request);
|
||||
// } catch (WxPayException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
//
|
||||
// String prepayId = orderResult.getPrepayId();
|
||||
// //组合参数构建支付
|
||||
// Map<String, String> paySignInfo = new HashMap<>(5);
|
||||
// String timeStamp = String.valueOf(System.currentTimeMillis());
|
||||
// String nonceStr = "dalfhh241lnandnsklajax";
|
||||
// paySignInfo.put("appId", wxPayService.getConfig().getAppId());
|
||||
// paySignInfo.put("nonceStr", nonceStr);
|
||||
// paySignInfo.put("timeStamp", timeStamp);
|
||||
// paySignInfo.put("signType", "MD5");
|
||||
// paySignInfo.put("package", "prepay_id=" + prepayId);
|
||||
// String[] signInfo = new String[0];
|
||||
// String paySign = SignUtils.createSign(paySignInfo, "MD5", wxPayService.getConfig().getMchKey(), signInfo);
|
||||
//
|
||||
// //组合支付参数
|
||||
// JSONObject jsonObject = new JSONObject().fluentPut("appId", wxPayService.getConfig().getAppId()).fluentPut("timeStamp", timeStamp).fluentPut("nonceStr", nonceStr).fluentPut("package", "prepay_id=" + prepayId).fluentPut("signType", "MD5").fluentPut("paySign", paySign);
|
||||
// return R.ok(jsonObject);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user