|
@@ -11,6 +11,7 @@ import com.huiju.estateagents.entity.TaWxPayConfig;
|
11
|
11
|
import com.huiju.estateagents.service.ITaWxPayConfigService;
|
12
|
12
|
import com.huiju.estateagents.service.IWxPayService;
|
13
|
13
|
import lombok.extern.slf4j.Slf4j;
|
|
14
|
+import org.apache.commons.codec.digest.DigestUtils;
|
14
|
15
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
15
|
16
|
import org.springframework.beans.factory.annotation.Autowired;
|
16
|
17
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -117,7 +118,7 @@ public class WxPayController extends BaseController {
|
117
|
118
|
*/
|
118
|
119
|
@RequestMapping(value = "/refund/{type}",method = RequestMethod.POST)
|
119
|
120
|
public String wxRefund(@PathVariable String type, HttpServletRequest request){
|
120
|
|
- log.info("支付成功回调开始,支付类型是{}",type);
|
|
121
|
+ log.info("微信退款成功回调开始,退款类型是{}",type);
|
121
|
122
|
String failResult = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>" + "<return_msg><![CDATA[失败]]></return_msg>" + "</xml> ";
|
122
|
123
|
String successResult = "<xml>" + "<return_code><![CDATA[SUCCESS]]></return_code>" + "<return_msg><![CDATA[OK]]></return_msg>" + "</xml> ";
|
123
|
124
|
Map<String, String> resultMap = new HashMap<>();
|
|
@@ -140,15 +141,17 @@ public class WxPayController extends BaseController {
|
140
|
141
|
// xml转换为map
|
141
|
142
|
resultMap = WXPayUtil.xmlToMap(result);
|
142
|
143
|
//处理业务需求
|
143
|
|
- if (WXPayConstants.SUCCESS.equalsIgnoreCase(resultMap.get("result_code"))) {
|
|
144
|
+ if (WXPayConstants.SUCCESS.equalsIgnoreCase(resultMap.get("return_code"))) {
|
144
|
145
|
String mchId = resultMap.get("mch_id");
|
145
|
146
|
QueryWrapper<TaWxPayConfig> queryWrapper = new QueryWrapper<>();
|
146
|
147
|
queryWrapper.eq("mch_id",mchId);
|
147
|
148
|
String mchKey = taWxPayConfigService.list(queryWrapper).get(0).getMchKey();
|
148
|
|
- SecretKeySpec key = new SecretKeySpec(MD5Utils.md5(mchKey, "UTF-8").toLowerCase().getBytes(), "AES");
|
|
149
|
+ log.info("key等于{}",mchKey);
|
|
150
|
+ SecretKeySpec key = new SecretKeySpec(DigestUtils.md5Hex(mchKey).toLowerCase().getBytes(), "AES");
|
149
|
151
|
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
150
|
152
|
cipher.init(Cipher.DECRYPT_MODE, key);
|
151
|
153
|
String req_info = new String(cipher.doFinal(new BASE64Decoder().decodeBuffer(resultMap.get("req_info"))), "UTF-8");
|
|
154
|
+ log.info("req_info等于{}",req_info);
|
152
|
155
|
Map<String, String> orderInfo = WXPayUtil.xmlToMap(req_info);
|
153
|
156
|
wxPayService.houseRefund(orderInfo);
|
154
|
157
|
}else {
|