|
@@ -1,11 +1,14 @@
|
1
|
1
|
package com.huiju.estateagents.controller;
|
2
|
2
|
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
3
|
4
|
import com.huiju.estateagents.base.BaseController;
|
4
|
5
|
import com.huiju.estateagents.base.ResponseBean;
|
5
|
6
|
import com.huiju.estateagents.common.MD5Utils;
|
6
|
7
|
import com.huiju.estateagents.common.wxpay.WXPayConstants;
|
7
|
8
|
import com.huiju.estateagents.common.wxpay.WXPayUtil;
|
8
|
9
|
import com.huiju.estateagents.entity.TaOrder;
|
|
10
|
+import com.huiju.estateagents.entity.TaWxPayConfig;
|
|
11
|
+import com.huiju.estateagents.service.ITaWxPayConfigService;
|
9
|
12
|
import com.huiju.estateagents.service.IWxPayService;
|
10
|
13
|
import lombok.extern.slf4j.Slf4j;
|
11
|
14
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
|
@@ -35,6 +38,9 @@ public class WxPayController extends BaseController {
|
35
|
38
|
@Autowired
|
36
|
39
|
private IWxPayService wxPayService;
|
37
|
40
|
|
|
41
|
+ @Autowired
|
|
42
|
+ private ITaWxPayConfigService taWxPayConfigService;
|
|
43
|
+
|
38
|
44
|
/**
|
39
|
45
|
* 微信统一下单接口
|
40
|
46
|
* @param taOrder
|
|
@@ -135,10 +141,16 @@ public class WxPayController extends BaseController {
|
135
|
141
|
resultMap = WXPayUtil.xmlToMap(result);
|
136
|
142
|
//处理业务需求
|
137
|
143
|
if (WXPayConstants.SUCCESS.equalsIgnoreCase(resultMap.get("result_code"))) {
|
138
|
|
- SecretKeySpec key = new SecretKeySpec(MD5Utils.md5("key需要从库里获取", "UTF-8").toLowerCase().getBytes(), "AES");
|
|
144
|
+ String mchId = resultMap.get("mch_id");
|
|
145
|
+ QueryWrapper<TaWxPayConfig> queryWrapper = new QueryWrapper<>();
|
|
146
|
+ queryWrapper.eq("mch_id",mchId);
|
|
147
|
+ String mchKey = taWxPayConfigService.list(queryWrapper).get(0).getMchKey();
|
|
148
|
+ SecretKeySpec key = new SecretKeySpec(MD5Utils.md5(mchKey, "UTF-8").toLowerCase().getBytes(), "AES");
|
139
|
149
|
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
140
|
150
|
cipher.init(Cipher.DECRYPT_MODE, key);
|
141
|
151
|
String req_info = new String(cipher.doFinal(new BASE64Decoder().decodeBuffer(resultMap.get("req_info"))), "UTF-8");
|
|
152
|
+ Map<String, String> orderInfo = WXPayUtil.xmlToMap(req_info);
|
|
153
|
+ wxPayService.houseRefund(orderInfo);
|
142
|
154
|
}else {
|
143
|
155
|
log.error("支付回调出错{}",resultMap.get("return_msg"));
|
144
|
156
|
return failResult;
|