|
@@ -304,6 +304,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
* @param paramData 参数
|
|
|
* @return
|
|
|
*/
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public Map<String,Object> jsapiPay(JSONObject paramData) throws Exception {
|
|
|
log.info("jsapiPay===="+paramData.toString());
|
|
@@ -324,12 +325,12 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
return map;
|
|
|
}
|
|
|
//调用统一下单API
|
|
|
- HttpPost httpPost = new HttpPost(wxPayConfig.getDomain().concat(WxTradeType.JSAPI.getType()));
|
|
|
+ HttpPost httpPost = new HttpPost(wxPayConfig.getDomain().concat(WxApiType.ASPI_PAY.getType()));
|
|
|
//构建必要参数
|
|
|
Gson gson = new Gson();
|
|
|
Map<String,Object> paramsMap = new HashMap<>();
|
|
|
- paramsMap.put("sp_appid",wxPayConfig.getAppId());
|
|
|
- paramsMap.put("sp_mchid",wxPayConfig.getMchId());
|
|
|
+ paramsMap.put("appid",wxPayConfig.getOa_appid());
|
|
|
+ paramsMap.put("mchid",wxPayConfig.getMchId());
|
|
|
paramsMap.put("description",description);
|
|
|
paramsMap.put("out_trade_no",orderInfo.getOrderNo());
|
|
|
paramsMap.put("notify_url",wxPayConfig.getNotifyDomain().concat(WxNotifyType.NATIVE_NOTIFY.getType()));
|
|
@@ -340,7 +341,7 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
log.info("paramsMap:"+paramsMap);
|
|
|
|
|
|
Map<String,String> payerMap = new HashMap<>();
|
|
|
- payerMap.put("sp_openid",paramData.getString("openId"));
|
|
|
+ payerMap.put("openid",paramData.getString("openId"));
|
|
|
paramsMap.put("payer",payerMap);
|
|
|
|
|
|
//将body转化为json字符串
|
|
@@ -366,7 +367,25 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
}
|
|
|
//响应结果
|
|
|
Map<String,String> resultMap = gson.fromJson(bodyAsString,HashMap.class);
|
|
|
- codeUrl = resultMap.get("prepay_id");
|
|
|
+ //codeUrl = resultMap.get("prepay_id");
|
|
|
+ //构建拉起微信支付参数
|
|
|
+ JSONObject payParam = new JSONObject();
|
|
|
+ payParam.put("prepay_id",resultMap.get("prepay_id"));
|
|
|
+ payParam.put("timeStamp",System.currentTimeMillis()/1000+"");
|
|
|
+ payParam.put("package","prepay_id="+resultMap.get("prepay_id"));
|
|
|
+ payParam.put("signType","RSA");
|
|
|
+ payParam.put("appId",wxPayConfig.getAspi_appid());
|
|
|
+ payParam.put("nonceStr",RandomUtil.getRandomString(32));
|
|
|
+ Signature signature = Signature.getInstance("SHA256withRSA");
|
|
|
+ signature.initSign(wxPayConfig.getPrivateKey(wxPayConfig.getPrivateKeyPath()));
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ buffer.append(payParam.getString("appId")).append("\n").
|
|
|
+ append(payParam.getLong("timeStamp")).append("\n").
|
|
|
+ append(payParam.getString("nonceStr")).append("\n").
|
|
|
+ append(payParam.getString("package")).append("\n");
|
|
|
+ signature.update(buffer.toString().getBytes(StandardCharsets.UTF_8));
|
|
|
+ payParam.put("paySign",Base64Utils.encodeToString(signature.sign()));
|
|
|
+ codeUrl = payParam.toJSONString();
|
|
|
orderInfo.setCodeUrl(codeUrl);
|
|
|
orderInfoService.saveCodeUrl(orderInfo);
|
|
|
log.info("orderInfo:" + orderInfo);
|