|
|
@@ -1,6 +1,5 @@
|
|
|
package com.cyksj.service.wechat.impl;
|
|
|
|
|
|
-import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
@@ -27,6 +26,7 @@ import java.net.URLEncoder;
|
|
|
import java.net.http.HttpRequest;
|
|
|
import java.net.http.HttpResponse;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
import java.util.Map;
|
|
|
import java.util.Optional;
|
|
|
|
|
|
@@ -184,9 +184,8 @@ public class WeChatServiceImpl implements WeChatService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public H5JsPayParams getJsPayParams(String appid, String openid, Integer totalFee, String outTradeNo, String notifyUrl, String attach, String body, String tradeType) throws Exception {
|
|
|
+ public H5JsPayParams getJsPayParams(String appid, String openid, Integer totalFee, String outTradeNo, String notifyUrl, String attach, String body, String tradeType, Date expireTime) throws Exception {
|
|
|
log.info("------------------- 调用微信h5支付 开始 -------------------");
|
|
|
- DateTime now = DateTime.now();
|
|
|
BaseWeChatConfig weChatConfigStrategy = WeChatFactory.getWeChatConfigStrategy(appid);
|
|
|
|
|
|
// 拼接统一下单实体类
|
|
|
@@ -198,13 +197,14 @@ public class WeChatServiceImpl implements WeChatService {
|
|
|
.setNonceStr("chan.123")
|
|
|
.setNotifyUrl(notifyUrl)
|
|
|
.setOutTradeNo(outTradeNo)
|
|
|
+ //5分钟过期
|
|
|
+ .setTimeExpire(DateUtil.format(DateUtil.offsetMinute(expireTime, 5), "yyyyMMddHHmmss"))
|
|
|
.setSpbillCreateIp("127.0.0.1")
|
|
|
.setTotalFee(totalFee)
|
|
|
.setTradeType(tradeType);
|
|
|
- if ("NATIVE".equals(tradeType)) {
|
|
|
- //5分钟订单失效时间
|
|
|
- order.setTimeExpire(DateUtil.format(DateUtil.offsetMinute(now, 5), "yyyyMMddHHmmss"));
|
|
|
- } else order.setOpenid(openid);
|
|
|
+ if (!"NATIVE".equals(tradeType)) {
|
|
|
+ order.setOpenid(openid);
|
|
|
+ }
|
|
|
String sign = Codec.DoDigest.custom()
|
|
|
.setAlgorithm(Codec.DoDigest.Algorithm.MD5)
|
|
|
.setStringData(order.getPrintln(tradeType, weChatConfigStrategy.getShopKey()))
|