fix: 商城支付微信返回jsapi
parent
540caf9cc1
commit
76c248f865
|
@ -245,25 +245,28 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||||
// 微信支付,调用微信预下单,返回拉起微信支付需要的信息
|
// 微信支付,调用微信预下单,返回拉起微信支付需要的信息
|
||||||
if (storeOrder.getPayType().equals(PayConstants.PAY_TYPE_WE_CHAT)) {
|
if (storeOrder.getPayType().equals(PayConstants.PAY_TYPE_WE_CHAT)) {
|
||||||
// 预下单
|
// 预下单
|
||||||
Map<String, String> unifiedorder = unifiedorder(storeOrder, ip, orderPayRequest.getOpenid());
|
WxPayUnifiedOrderV3Result wxPayUnifiedOrderV3Result = unifiedorder(storeOrder, ip, orderPayRequest.getOpenid());
|
||||||
|
WxPayService wxPayService = wxPayOneAutoConfiguration.wxPayOneService();
|
||||||
|
WxPayUnifiedOrderV3Result.JsapiResult jsapiResult = wxPayUnifiedOrderV3Result.getPayInfo(TradeTypeEnum.JSAPI, payProperties.getAppId(), payProperties.getMchId(), wxPayService.getConfig().getPrivateKey());
|
||||||
response.setStatus(true);
|
response.setStatus(true);
|
||||||
WxPayJsResultVo vo = new WxPayJsResultVo();
|
WxPayJsResultVo vo = new WxPayJsResultVo();
|
||||||
vo.setAppId(unifiedorder.get("appId"));
|
|
||||||
vo.setNonceStr(unifiedorder.get("nonceStr"));
|
vo.setAppId(/*unifiedorder.get("appId")*/jsapiResult.getAppId());
|
||||||
vo.setPackages(unifiedorder.get("package"));
|
vo.setNonceStr(/*unifiedorder.get("nonceStr")*/jsapiResult.getNonceStr());
|
||||||
vo.setSignType(unifiedorder.get("signType"));
|
// vo.setPackages(unifiedorder.get("package"));
|
||||||
vo.setTimeStamp(unifiedorder.get("timeStamp"));
|
vo.setSignType(/*unifiedorder.get("signType")*/jsapiResult.getSignType());
|
||||||
vo.setPaySign(unifiedorder.get("paySign"));
|
vo.setTimeStamp(/*unifiedorder.get("timeStamp")*/jsapiResult.getTimeStamp());
|
||||||
|
vo.setPaySign(/*unifiedorder.get("paySign")*/jsapiResult.getPaySign());
|
||||||
if (storeOrder.getIsChannel() == 2) {
|
if (storeOrder.getIsChannel() == 2) {
|
||||||
vo.setMwebUrl(unifiedorder.get("mweb_url"));
|
vo.setMwebUrl(wxPayUnifiedOrderV3Result.getH5Url());
|
||||||
response.setPayType(PayConstants.PAY_CHANNEL_WE_CHAT_H5);
|
response.setPayType(PayConstants.PAY_CHANNEL_WE_CHAT_H5);
|
||||||
}
|
}
|
||||||
if (storeOrder.getIsChannel() == 4 || storeOrder.getIsChannel() == 5) {
|
// if (storeOrder.getIsChannel() == 4 || storeOrder.getIsChannel() == 5) {
|
||||||
vo.setPartnerid(unifiedorder.get("partnerid"));
|
// vo.setPartnerid(unifiedorder.get("partnerid"));
|
||||||
}
|
// }
|
||||||
// 更新商户订单号
|
// 更新商户订单号
|
||||||
storeOrder.setOutTradeNo(unifiedorder.get("outTradeNo"));
|
// storeOrder.setOutTradeNo(unifiedorder.get("outTradeNo"));
|
||||||
storeOrderService.updateById(storeOrder);
|
// storeOrderService.updateById(storeOrder);
|
||||||
response.setJsConfig(vo);
|
response.setJsConfig(vo);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
@ -287,7 +290,7 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||||
* @param ip ip
|
* @param ip ip
|
||||||
* @return 预下单返回对象
|
* @return 预下单返回对象
|
||||||
*/
|
*/
|
||||||
private Map<String, String> unifiedorder(StoreOrder storeOrder, String ip,String openid) {
|
private WxPayUnifiedOrderV3Result unifiedorder(StoreOrder storeOrder, String ip,String openid) {
|
||||||
// 获取用户openId
|
// 获取用户openId
|
||||||
// 根据订单支付类型来判断获取公众号openId还是小程序openId
|
// 根据订单支付类型来判断获取公众号openId还是小程序openId
|
||||||
|
|
||||||
|
@ -316,7 +319,7 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||||
// 预下单(统一下单)
|
// 预下单(统一下单)
|
||||||
//CreateOrderResponseVo responseVo = wechatNewService.payUnifiedorder(unifiedorderVo);
|
//CreateOrderResponseVo responseVo = wechatNewService.payUnifiedorder(unifiedorderVo);
|
||||||
// 组装前端预下单参数
|
// 组装前端预下单参数
|
||||||
Map<String, String> map = new HashMap<>();
|
// Map<String, String> map = new HashMap<>();
|
||||||
// map.put("appId", unifiedorderVo.getAppid());
|
// map.put("appId", unifiedorderVo.getAppid());
|
||||||
// map.put("nonceStr", unifiedorderVo.getAppid());
|
// map.put("nonceStr", unifiedorderVo.getAppid());
|
||||||
// map.put("package", "prepay_id=".concat(responseVo.getPrepayId()));
|
// map.put("package", "prepay_id=".concat(responseVo.getPrepayId()));
|
||||||
|
@ -348,11 +351,12 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||||
wxPayRequest.setTimeExpire(formatLocalDateTime(LocalDateTime.now().plusMinutes(30), "yyyyMMddHHmmss"));
|
wxPayRequest.setTimeExpire(formatLocalDateTime(LocalDateTime.now().plusMinutes(30), "yyyyMMddHHmmss"));
|
||||||
try {
|
try {
|
||||||
WxPayUnifiedOrderV3Result wxPayUnifiedOrderV3Result = wxPayService.unifiedOrderV3(TradeTypeEnum.JSAPI, wxPayRequest);
|
WxPayUnifiedOrderV3Result wxPayUnifiedOrderV3Result = wxPayService.unifiedOrderV3(TradeTypeEnum.JSAPI, wxPayRequest);
|
||||||
map.put("mweb_url",wxPayUnifiedOrderV3Result.getH5Url());
|
// map.put("mweb_url",wxPayUnifiedOrderV3Result.getH5Url());
|
||||||
|
return wxPayUnifiedOrderV3Result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.getMessage();
|
e.getMessage();
|
||||||
}
|
}
|
||||||
return map;
|
return null;
|
||||||
}
|
}
|
||||||
public static String formatLocalDateTime(LocalDateTime localDateTime, String pattern) {
|
public static String formatLocalDateTime(LocalDateTime localDateTime, String pattern) {
|
||||||
return localDateTime.format(DateTimeFormatter.ofPattern(pattern));
|
return localDateTime.format(DateTimeFormatter.ofPattern(pattern));
|
||||||
|
|
Loading…
Reference in New Issue