|
|
@@ -1,13 +1,6 @@
|
|
|
package com.izouma.zhumj.web;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.alipay.api.AlipayApiException;
|
|
|
-import com.alipay.api.AlipayClient;
|
|
|
-import com.alipay.api.internal.util.AlipaySignature;
|
|
|
-import com.izouma.zhumj.config.AlipayProperties;
|
|
|
-import com.izouma.zhumj.service.CheckinInfoService;
|
|
|
-import com.izouma.zhumj.service.RechargeRecordService;
|
|
|
+
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections.MapUtils;
|
|
|
@@ -29,48 +22,48 @@ import static com.alibaba.fastjson.serializer.SerializerFeature.PrettyFormat;
|
|
|
@Slf4j
|
|
|
@AllArgsConstructor
|
|
|
public class AlipayController {
|
|
|
- private AlipayClient alipayClient;
|
|
|
- private AlipayProperties alipayProperties;
|
|
|
- private CheckinInfoService checkinInfoService;
|
|
|
- private RechargeRecordService rechargeRecordService;
|
|
|
-
|
|
|
- @PostMapping("/payNotify")
|
|
|
- @ResponseBody
|
|
|
- public String notify(HttpServletRequest request) throws AlipayApiException {
|
|
|
- Map<String, String> params = new HashMap<>();
|
|
|
- Set<Map.Entry<String, String[]>> entrySet = request.getParameterMap().entrySet();
|
|
|
- for (Map.Entry<String, String[]> entry : entrySet) {
|
|
|
- String name = entry.getKey();
|
|
|
- String[] values = entry.getValue();
|
|
|
- int valLen = values.length;
|
|
|
-
|
|
|
- if (valLen == 1) {
|
|
|
- params.put(name, values[0]);
|
|
|
- } else if (valLen > 1) {
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
- for (String val : values) {
|
|
|
- sb.append(",").append(val);
|
|
|
- }
|
|
|
- params.put(name, sb.toString().substring(1));
|
|
|
- } else {
|
|
|
- params.put(name, "");
|
|
|
- }
|
|
|
- }
|
|
|
- log.info("支付宝回调 {}", JSON.toJSONString(params, PrettyFormat));
|
|
|
- AlipaySignature.rsaCheckV1(params, alipayProperties.getAliPublicKey(), "UTF-8", "RSA2");
|
|
|
- if (MapUtils.getString(params, "trade_status").equals("TRADE_SUCCESS")) {
|
|
|
- JSONObject body = JSON.parseObject(params.get("body"));
|
|
|
- String type = body.getString("type");
|
|
|
- switch (type) {
|
|
|
- case "deposit":
|
|
|
- checkinInfoService.handleDepositNotify(params, body);
|
|
|
- break;
|
|
|
- case "recharge":
|
|
|
- rechargeRecordService.handleRechargeNotify(params, body);
|
|
|
- break;
|
|
|
- }
|
|
|
- return "success";
|
|
|
- }
|
|
|
- return "error";
|
|
|
- }
|
|
|
+// private AlipayClient alipayClient;
|
|
|
+// private AlipayProperties alipayProperties;
|
|
|
+// private CheckinInfoService checkinInfoService;
|
|
|
+// private RechargeRecordService rechargeRecordService;
|
|
|
+//
|
|
|
+// @PostMapping("/payNotify")
|
|
|
+// @ResponseBody
|
|
|
+// public String notify(HttpServletRequest request) throws AlipayApiException {
|
|
|
+// Map<String, String> params = new HashMap<>();
|
|
|
+// Set<Map.Entry<String, String[]>> entrySet = request.getParameterMap().entrySet();
|
|
|
+// for (Map.Entry<String, String[]> entry : entrySet) {
|
|
|
+// String name = entry.getKey();
|
|
|
+// String[] values = entry.getValue();
|
|
|
+// int valLen = values.length;
|
|
|
+//
|
|
|
+// if (valLen == 1) {
|
|
|
+// params.put(name, values[0]);
|
|
|
+// } else if (valLen > 1) {
|
|
|
+// StringBuilder sb = new StringBuilder();
|
|
|
+// for (String val : values) {
|
|
|
+// sb.append(",").append(val);
|
|
|
+// }
|
|
|
+// params.put(name, sb.toString().substring(1));
|
|
|
+// } else {
|
|
|
+// params.put(name, "");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// log.info("支付宝回调 {}", JSON.toJSONString(params, PrettyFormat));
|
|
|
+// AlipaySignature.rsaCheckV1(params, alipayProperties.getAliPublicKey(), "UTF-8", "RSA2");
|
|
|
+// if (MapUtils.getString(params, "trade_status").equals("TRADE_SUCCESS")) {
|
|
|
+// JSONObject body = JSON.parseObject(params.get("body"));
|
|
|
+// String type = body.getString("type");
|
|
|
+// switch (type) {
|
|
|
+// case "deposit":
|
|
|
+// checkinInfoService.handleDepositNotify(params, body);
|
|
|
+// break;
|
|
|
+// case "recharge":
|
|
|
+// rechargeRecordService.handleRechargeNotify(params, body);
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// return "success";
|
|
|
+// }
|
|
|
+// return "error";
|
|
|
+// }
|
|
|
}
|