|
@@ -13,6 +13,7 @@ import com.zsElectric.boot.business.model.form.applet.AppLevelOrderForm;
|
|
|
import com.zsElectric.boot.business.model.form.applet.AppUserPayForm;
|
|
import com.zsElectric.boot.business.model.form.applet.AppUserPayForm;
|
|
|
import com.zsElectric.boot.business.model.query.applet.AppUserOrderInfoQuery;
|
|
import com.zsElectric.boot.business.model.query.applet.AppUserOrderInfoQuery;
|
|
|
import com.zsElectric.boot.business.model.vo.applet.AppUserInfoVO;
|
|
import com.zsElectric.boot.business.model.vo.applet.AppUserInfoVO;
|
|
|
|
|
+import com.zsElectric.boot.business.model.vo.applet.WechatPayParamsVO;
|
|
|
import com.zsElectric.boot.business.service.*;
|
|
import com.zsElectric.boot.business.service.*;
|
|
|
import com.zsElectric.boot.common.constant.SystemConstants;
|
|
import com.zsElectric.boot.common.constant.SystemConstants;
|
|
|
import com.zsElectric.boot.core.exception.BusinessException;
|
|
import com.zsElectric.boot.core.exception.BusinessException;
|
|
@@ -189,7 +190,7 @@ public class UserOrderInfoServiceImpl extends ServiceImpl<UserOrderInfoMapper, U
|
|
|
//查询档位
|
|
//查询档位
|
|
|
RechargeLevel level = rechargeLevelMapper.selectById(appLevelOrderForm.getLevelId());
|
|
RechargeLevel level = rechargeLevelMapper.selectById(appLevelOrderForm.getLevelId());
|
|
|
|
|
|
|
|
- Map<String, Object> result = payment(userOpenId, orderNo, level.getMoney());
|
|
|
|
|
|
|
+ WechatPayParamsVO result = payment(userOpenId, orderNo, level.getMoney());
|
|
|
payForm.setParams(result);
|
|
payForm.setParams(result);
|
|
|
return payForm;
|
|
return payForm;
|
|
|
}
|
|
}
|
|
@@ -210,7 +211,7 @@ public class UserOrderInfoServiceImpl extends ServiceImpl<UserOrderInfoMapper, U
|
|
|
//查询档位
|
|
//查询档位
|
|
|
RechargeLevel level = rechargeLevelMapper.selectById(orderInfo.getLevelId());
|
|
RechargeLevel level = rechargeLevelMapper.selectById(orderInfo.getLevelId());
|
|
|
|
|
|
|
|
- Map<String, Object> result = payment(orderInfo.getOpenid(), orderInfo.getOrderNo(), level.getMoney());
|
|
|
|
|
|
|
+ WechatPayParamsVO result = payment(orderInfo.getOpenid(), orderInfo.getOrderNo(), level.getMoney());
|
|
|
payForm.setParams(result);
|
|
payForm.setParams(result);
|
|
|
return payForm;
|
|
return payForm;
|
|
|
}
|
|
}
|
|
@@ -672,7 +673,7 @@ public class UserOrderInfoServiceImpl extends ServiceImpl<UserOrderInfoMapper, U
|
|
|
* @param amount
|
|
* @param amount
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- private Map<String, Object> payment(String openId, String orderNo, BigDecimal amount) {
|
|
|
|
|
|
|
+ private WechatPayParamsVO payment(String openId, String orderNo, BigDecimal amount) {
|
|
|
//15分钟超时限制
|
|
//15分钟超时限制
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 15);
|
|
calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 15);
|
|
@@ -714,7 +715,7 @@ public class UserOrderInfoServiceImpl extends ServiceImpl<UserOrderInfoMapper, U
|
|
|
* @return
|
|
* @return
|
|
|
* @throws ServiceException
|
|
* @throws ServiceException
|
|
|
*/
|
|
*/
|
|
|
- public Map<String, Object> wechatPay(JsonObject params) throws ServiceException {
|
|
|
|
|
|
|
+ public WechatPayParamsVO wechatPay(JsonObject params) throws ServiceException {
|
|
|
|
|
|
|
|
//发起请求
|
|
//发起请求
|
|
|
JsonObject res = wechatPayV3Utils.sendPost(WechatUrlConstants.PAY_V3_JSAPI, params);
|
|
JsonObject res = wechatPayV3Utils.sendPost(WechatUrlConstants.PAY_V3_JSAPI, params);
|
|
@@ -725,19 +726,19 @@ public class UserOrderInfoServiceImpl extends ServiceImpl<UserOrderInfoMapper, U
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
StringBuilder sb = new StringBuilder();
|
|
|
//返回给小程序拉起微信支付的参数
|
|
//返回给小程序拉起微信支付的参数
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
|
|
- result.put("appId", WechatConstants.WECHAT_APPID); //小程序appid
|
|
|
|
|
- sb.append(result.get("appId")).append("\n");
|
|
|
|
|
- result.put("timeStamp", (new Date().getTime() / 1000) + ""); //时间戳
|
|
|
|
|
- sb.append(result.get("timeStamp")).append("\n");
|
|
|
|
|
- result.put("nonceStr", RandomStringUtils.randomAlphanumeric(32)); //32位随机字符串
|
|
|
|
|
- sb.append(result.get("nonceStr")).append("\n");
|
|
|
|
|
- result.put("package", "prepay_id=" + res.get("prepay_id").getAsString()); //预支付id 格式为 prepay_id=xxx
|
|
|
|
|
- sb.append(result.get("package")).append("\n");
|
|
|
|
|
|
|
+ WechatPayParamsVO result = new WechatPayParamsVO();
|
|
|
|
|
+ result.setAppId(WechatConstants.WECHAT_APPID); //小程序appid
|
|
|
|
|
+ sb.append(result.getAppId()).append("\n");
|
|
|
|
|
+ result.setTimeStamp((new Date().getTime() / 1000) + ""); //时间戳
|
|
|
|
|
+ sb.append(result.getTimeStamp()).append("\n");
|
|
|
|
|
+ result.setNonceStr(RandomStringUtils.randomAlphanumeric(32)); //32位随机字符串
|
|
|
|
|
+ sb.append(result.getNonceStr()).append("\n");
|
|
|
|
|
+ result.setPackageValue("prepay_id=" + res.get("prepay_id").getAsString()); //预支付id 格式为 prepay_id=xxx
|
|
|
|
|
+ sb.append(result.getPackageValue()).append("\n");
|
|
|
//签名
|
|
//签名
|
|
|
- result.put("paySign", wechatPayV3Utils.signRSA(sb.toString()));
|
|
|
|
|
- result.put("signType", "RSA"); //加密方式 固定RSA
|
|
|
|
|
- result.put("out_trade_no", params.get("out_trade_no").getAsString()); //商户订单号 此参数不是小程序拉起支付所需的参数 因此不参与签名
|
|
|
|
|
|
|
+ result.setPaySign(wechatPayV3Utils.signRSA(sb.toString()));
|
|
|
|
|
+ result.setSignType("RSA"); //加密方式 固定RSA
|
|
|
|
|
+ result.setOutTradeNo(params.get("out_trade_no").getAsString()); //商户订单号 此参数不是小程序拉起支付所需的参数 因此不参与签名
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|