|
@@ -1,9 +1,5 @@
|
|
|
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;
|
|
@@ -12,26 +8,26 @@ import com.ym.mec.biz.dal.entity.TenantInfo;
|
|
|
import com.ym.mec.biz.dal.entity.TenantProductSumm;
|
|
|
import com.ym.mec.biz.service.TenantInfoSendMsgService;
|
|
|
import com.ym.mec.biz.service.TenantInfoService;
|
|
|
+import com.ym.mec.biz.service.TenantOrderRecordService;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
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.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
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;
|
|
@@ -46,6 +42,7 @@ import static com.ym.mec.biz.service.impl.TenantInfoSendMsgServiceImpl.OPEN;
|
|
|
@Api(tags = "机构管理")
|
|
|
@RestController
|
|
|
public class TenantInfoController extends BaseController {
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(TenantInfoController.class);
|
|
|
|
|
|
@Autowired
|
|
|
private TenantInfoService tenantInfoService;
|
|
@@ -56,6 +53,9 @@ public class TenantInfoController extends BaseController {
|
|
|
@Autowired
|
|
|
private TenantInfoSendMsgService tenantInfoSendMsgService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private TenantOrderRecordService tenantOrderRecordService;
|
|
|
+
|
|
|
@ApiOperation("添加机构信息")
|
|
|
@PostMapping(value = "/add")
|
|
|
@PreAuthorize("@pcs.hasPermissions('tenantInfo/add')")
|
|
@@ -188,55 +188,8 @@ public class TenantInfoController extends BaseController {
|
|
|
}
|
|
|
|
|
|
@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";
|
|
|
- }
|
|
|
+ public String callback(HttpServletRequest request) {
|
|
|
+ return tenantOrderRecordService.callback(request);
|
|
|
+ }
|
|
|
|
|
|
}
|