|
@@ -1,5 +1,6 @@
|
|
|
package com.ylx.common.weixinPay.service;
|
|
package com.ylx.common.weixinPay.service;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
|
|
|
import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result;
|
|
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;
|
|
@@ -26,7 +27,7 @@ public class WxPayV3Service {
|
|
|
/**
|
|
/**
|
|
|
* V3 JSAPI下单 公众号/小程序
|
|
* V3 JSAPI下单 公众号/小程序
|
|
|
*/
|
|
*/
|
|
|
- public Map<String, Object> createV3JsapiOrder(String orderNo, BigDecimal amount, String body, String openId) {
|
|
|
|
|
|
|
+ public Map<String, Object> createV3JsapiOrder(String orderNo, BigDecimal amount, String body, String openId, String attach) {
|
|
|
try {
|
|
try {
|
|
|
// 1. 获取支付配置
|
|
// 1. 获取支付配置
|
|
|
WxPayConfig payConfig = wxPayService.getConfig();
|
|
WxPayConfig payConfig = wxPayService.getConfig();
|
|
@@ -37,6 +38,11 @@ public class WxPayV3Service {
|
|
|
request.setDescription(body);
|
|
request.setDescription(body);
|
|
|
request.setNotifyUrl(payConfig.getNotifyUrl());
|
|
request.setNotifyUrl(payConfig.getNotifyUrl());
|
|
|
|
|
|
|
|
|
|
+ // 设置 attach 字段
|
|
|
|
|
+ if (StrUtil.isNotBlank(attach)) {
|
|
|
|
|
+ request.setAttach(attach);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 金额转换(元转分,精度校验)
|
|
// 金额转换(元转分,精度校验)
|
|
|
int total = amount.multiply(new BigDecimal(100))
|
|
int total = amount.multiply(new BigDecimal(100))
|
|
|
.setScale(0, RoundingMode.HALF_UP).intValue();
|
|
.setScale(0, RoundingMode.HALF_UP).intValue();
|