|
@@ -2,21 +2,31 @@ package com.huiju.estateagents.controller;
|
2
|
2
|
|
3
|
3
|
import com.huiju.estateagents.base.BaseController;
|
4
|
4
|
import com.huiju.estateagents.base.ResponseBean;
|
|
5
|
+import com.huiju.estateagents.common.MD5Utils;
|
5
|
6
|
import com.huiju.estateagents.common.wxpay.WXPayConstants;
|
6
|
7
|
import com.huiju.estateagents.common.wxpay.WXPayUtil;
|
7
|
8
|
import com.huiju.estateagents.entity.TaOrder;
|
8
|
9
|
import com.huiju.estateagents.service.IWxPayService;
|
9
|
10
|
import lombok.extern.slf4j.Slf4j;
|
|
11
|
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
10
|
12
|
import org.springframework.beans.factory.annotation.Autowired;
|
11
|
13
|
import org.springframework.web.bind.annotation.*;
|
|
14
|
+import sun.misc.BASE64Decoder;
|
|
15
|
+import sun.security.provider.MD5;
|
12
|
16
|
|
|
17
|
+import javax.crypto.Cipher;
|
|
18
|
+import javax.crypto.spec.SecretKeySpec;
|
13
|
19
|
import javax.servlet.http.HttpServletRequest;
|
14
|
20
|
import java.io.ByteArrayOutputStream;
|
15
|
21
|
import java.io.InputStream;
|
|
22
|
+import java.security.Security;
|
|
23
|
+import java.util.Base64;
|
16
|
24
|
import java.util.HashMap;
|
17
|
25
|
import java.util.List;
|
18
|
26
|
import java.util.Map;
|
19
|
27
|
|
|
28
|
+import static sun.security.x509.CertificateAlgorithmId.ALGORITHM;
|
|
29
|
+
|
20
|
30
|
@Slf4j
|
21
|
31
|
@RestController
|
22
|
32
|
@RequestMapping("/api")
|
|
@@ -116,7 +126,7 @@ public class WxPayController extends BaseController {
|
116
|
126
|
|
117
|
127
|
// 获取微信调用我们notify_url的返回信息
|
118
|
128
|
String result = new String(outSteam.toByteArray(), "utf-8");
|
119
|
|
- log.info("wxnotify:微信支付----result----=" + result);
|
|
129
|
+ log.info("wxnotify:微信退款----result----=" + result);
|
120
|
130
|
|
121
|
131
|
// 关闭流
|
122
|
132
|
outSteam.close();
|
|
@@ -125,7 +135,10 @@ public class WxPayController extends BaseController {
|
125
|
135
|
resultMap = WXPayUtil.xmlToMap(result);
|
126
|
136
|
//处理业务需求
|
127
|
137
|
if (WXPayConstants.SUCCESS.equalsIgnoreCase(resultMap.get("result_code"))) {
|
128
|
|
- wxPayService.wxNotify(resultMap, type);
|
|
138
|
+ SecretKeySpec key = new SecretKeySpec(MD5Utils.md5("key需要从库里获取", "UTF-8").toLowerCase().getBytes(), "AES");
|
|
139
|
+ Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
|
140
|
+ cipher.init(Cipher.DECRYPT_MODE, key);
|
|
141
|
+ String req_info = new String(cipher.doFinal(new BASE64Decoder().decodeBuffer(resultMap.get("req_info"))), "UTF-8");
|
129
|
142
|
}else {
|
130
|
143
|
log.error("支付回调出错{}",resultMap.get("return_msg"));
|
131
|
144
|
return failResult;
|