|
@@ -1,5 +1,9 @@
|
|
|
package com.ym.mec.web.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.huifu.adapay.core.AdapayCore;
|
|
|
+import com.huifu.adapay.core.util.AdapaySign;
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dto.TenantInfoDto;
|
|
@@ -13,7 +17,9 @@ import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import com.ym.mec.common.page.WrapperUtil;
|
|
|
import com.ym.mec.common.tenant.TenantContextHolder;
|
|
|
import com.ym.mec.util.validator.ValidationKit;
|
|
|
+
|
|
|
import io.swagger.annotations.*;
|
|
|
+
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
@@ -21,8 +27,11 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.validation.Valid;
|
|
|
+
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Optional;
|
|
@@ -178,4 +187,56 @@ public class TenantInfoController extends BaseController {
|
|
|
return succeed();
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/callback")
|
|
|
+ public String callback(HttpServletRequest request) {
|
|
|
+ try {
|
|
|
+ // 验签请参data
|
|
|
+ String data = request.getParameter("data");
|
|
|
+ // 验签请参sign
|
|
|
+ String sign = request.getParameter("sign");
|
|
|
+
|
|
|
+ logger.info("callback request param:{}", data);
|
|
|
+
|
|
|
+ // 验签
|
|
|
+ if (AdapaySign.verifySign(data, sign, AdapayCore.PUBLIC_KEY)) {
|
|
|
+
|
|
|
+ JSONObject dataObj = JSON.parseObject(data);
|
|
|
+
|
|
|
+ String transType = request.getParameter("type");
|
|
|
+
|
|
|
+ Map<String, String> notifyMap = new HashMap<>();
|
|
|
+
|
|
|
+ switch (transType) {
|
|
|
+ case "payment.succeeded":// 支付成功
|
|
|
+
|
|
|
+ notifyMap.put("channelType", dataObj.getString("pay_channel"));
|
|
|
+ notifyMap.put("tradeState", "1");
|
|
|
+ notifyMap.put("totalMoney", dataObj.getString("pay_amt"));
|
|
|
+ notifyMap.put("merOrderNo", dataObj.getString("order_no"));
|
|
|
+ studentPaymentOrderService.updateOrder(notifyMap);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "payment.failed":// 支付失败
|
|
|
+
|
|
|
+ notifyMap.put("channelType", dataObj.getString("pay_channel"));
|
|
|
+ notifyMap.put("tradeState", "0");
|
|
|
+ notifyMap.put("totalMoney", dataObj.getString("pay_amt"));
|
|
|
+ notifyMap.put("merOrderNo", dataObj.getString("order_no"));
|
|
|
+ studentPaymentOrderService.updateOrder(notifyMap);
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return "验签失败";
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ return e.getMessage();
|
|
|
+ }
|
|
|
+
|
|
|
+ return "succeeded";
|
|
|
+ }
|
|
|
+
|
|
|
}
|