不同app用不同的appid支付

This commit is contained in:
wuchunlei
2024-05-11 13:09:27 +08:00
parent 6ab413377a
commit 8282c37f53
10 changed files with 73 additions and 14 deletions

View File

@@ -299,6 +299,7 @@ public class BuyOrderController {
paymentInfo.setOrderSn(orderSn);
paymentInfo.setBuyOrderId(buyOrder.getOrderId());
paymentInfo.setTotalAmount(totalPrice);
paymentInfo.setAppName(buyOrder.getAppName());
wxpayService.prepay(paymentInfo);
}
Map<String, Object> result = new HashMap<>();
@@ -528,6 +529,7 @@ public class BuyOrderController {
paymentInfo.setOrderSn(buyOrderEntity.getOrderSn());
paymentInfo.setBuyOrderId(Integer.valueOf(buyOrderEntity.getProductId()));
paymentInfo.setTotalAmount(buyOrderEntity.getRealMoney());
paymentInfo.setAppName(buyOrder.getAppName());
wxpayService.prepay(paymentInfo);
rabbitTemplate.convertAndSend(
DelayQueueConfig.ORDER_TO_BE_PAY_EXCHANGE,

View File

@@ -189,4 +189,7 @@ public class BuyOrder implements Serializable {
@TableField(exist = false)
private ConsigneeVo consigneeVo;
@TableField(exist = false)
private String appName;
}

View File

@@ -42,7 +42,9 @@ public class WechatPayConfig implements Serializable {
* APPID
*/
@Value("${wxpay.appId}")
private String appId;
private String appId;//fzds
@Value("${wxpay.zmzmappId}")
private String zmzmappId;
/**
* 商户号
*/

View File

@@ -63,8 +63,14 @@ public class WeChatPayController {
}
String nonceStr = UUID.randomUUID().toString().replace("-", "");
Map<String, Object> paramMap = new HashMap<>();
String appid = "";
if (paymentInfo.getAppName()==null||"".equals(paymentInfo.getAppName())){
appid = wechatPayConfig.getAppId();
}else if ("zmzm".equals(paymentInfo.getAppName())){
appid = wechatPayConfig.getZmzmappId();
}
Map<String, Object> map = new HashMap<>();
paramMap.put("appid", wechatPayConfig.getAppId());
paramMap.put("appid", appid);
map.put("noncestr", nonceStr);
map.put("package", "Sign=WXPay");
paramMap.put("mchid", wechatPayConfig.getMchId());
@@ -75,7 +81,7 @@ public class WeChatPayController {
map.put("prepayid", prepayId);
long timestamp = System.currentTimeMillis() / 1000;
map.put("timestamp", timestamp);
String sign = wxPayUtil.getSign(wechatPayConfig.getAppId(), timestamp, nonceStr, prepayId);
String sign = wxPayUtil.getSign(appid, timestamp, nonceStr, prepayId);
map.put("sign", sign);
Map<String, Object> result = new HashMap<>();
result.put("paramMap", paramMap);

View File

@@ -20,4 +20,8 @@ public class WechatPaymentInfo implements Serializable {
* 总金额
*/
private BigDecimal totalAmount;
/**
* appName
*/
private String appName;
}

View File

@@ -73,8 +73,14 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
@Override
public void prepay(WechatPaymentInfo paymentInfo){
Map<String, Object> paramMap = new HashMap<>();
String appid = "";
if (paymentInfo.getAppName()==null||"".equals(paymentInfo.getAppName())){
appid = wechatPayConfig.getAppId();
}else if ("zmzm".equals(paymentInfo.getAppName())){
appid = wechatPayConfig.getZmzmappId();
}
// app id
paramMap.put("appid", wechatPayConfig.getAppId());
paramMap.put("appid", appid);
// 商户 id
paramMap.put("mchid", wechatPayConfig.getMchId());
// 描述