|
|
@@ -46,6 +46,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* @author chan
|
|
|
@@ -254,12 +255,15 @@ public class RegisterOrderDonServiceImpl extends ServiceImpl<RegisterOrderDonMap
|
|
|
OrderAttach attach = new OrderAttach();
|
|
|
attach.setO(orderDon.getId());
|
|
|
|
|
|
+ //获取支付默认商户
|
|
|
+ String shopId = sysConfigService.getDefaultShopConfigByType("wx");
|
|
|
+
|
|
|
String toWechatAttach = Codec.DoBase64.custom()
|
|
|
.setData(Jsons.toJson(attach)).encodeAsText();
|
|
|
|
|
|
H5JsPayParams params = weChatService.getJsPayParams(
|
|
|
weChatConfig.getAppid(),
|
|
|
- ShopConfig.WX_DEFAULT_APP_ID,
|
|
|
+ shopId,
|
|
|
orderDon.getOpenId(),
|
|
|
orderDon.getMoney().intValue(),
|
|
|
orderDon.getOrderNo(),
|
|
|
@@ -293,9 +297,10 @@ public class RegisterOrderDonServiceImpl extends ServiceImpl<RegisterOrderDonMap
|
|
|
if (null == order) {
|
|
|
throw BusinessRuntimeException.getInstance("订单不存在.");
|
|
|
}
|
|
|
+ String appId = map.get("mch_id");
|
|
|
|
|
|
// 校验签名
|
|
|
- boolean f = weChatService.checkSignWithMd5(map, shopConfigMapper.getByAppId(weChatConfig.getShopid()).getSecret());
|
|
|
+ boolean f = weChatService.checkSignWithMd5(map, shopConfigMapper.getByAppId(appId).getSecret());
|
|
|
if (!f) {
|
|
|
log.error("回调数据:{}", map);
|
|
|
throw BusinessRuntimeException.getInstance("支付成功回调, 校验签名失败.");
|
|
|
@@ -352,7 +357,7 @@ public class RegisterOrderDonServiceImpl extends ServiceImpl<RegisterOrderDonMap
|
|
|
.toHexString();
|
|
|
wxOrderRefundReq.setRefundMoney(registerOrderDon.getMoney());
|
|
|
weChatService.refundWxOrder(weChatConfig.getAppid(),
|
|
|
- ShopConfig.WX_DEFAULT_APP_ID,
|
|
|
+ Optional.ofNullable(registerOrderDon.getShopId()).orElse(ShopConfig.WX_DEFAULT_APP_ID),
|
|
|
registerOrderDon.getTransactionId(),
|
|
|
outRefundNo,
|
|
|
registerOrderDon.getMoney(),
|
|
|
@@ -367,7 +372,7 @@ public class RegisterOrderDonServiceImpl extends ServiceImpl<RegisterOrderDonMap
|
|
|
@Override
|
|
|
public void wxRefundNotify(Map<String, String> map) throws Exception {
|
|
|
// 对退款数据 解密
|
|
|
- String md5Key = Codec.DoDigest.custom().setAlgorithm(Codec.DoDigest.Algorithm.MD5).setStringData(shopConfigMapper.getByAppId(weChatConfig.getShopid()).getSecret()).toHexString();
|
|
|
+ String md5Key = Codec.DoDigest.custom().setAlgorithm(Codec.DoDigest.Algorithm.MD5).setStringData(shopConfigMapper.getByAppId(map.get("mch_id")).getSecret()).toHexString();
|
|
|
String reqInfoXml = Codec.DoCipher.custom().setAlgorithm(Codec.DoCipher.Trans.AES_ECB_PKCS7Padding).setBase64Data(map.get("req_info")).setStringKey(md5Key).ofDecrypt().toText();
|
|
|
log.info("=== 退款数据解密: \n {}", reqInfoXml);
|
|
|
Map<String, String> reqInfoMap = Xmls.toMap(reqInfoXml);
|