回调处理

This commit is contained in:
gong
2026-01-14 14:41:30 +08:00
parent e341630e82
commit 946fe4de4c
7 changed files with 285 additions and 11 deletions

View File

@@ -4,8 +4,12 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.CzgPayUtils;
import com.czg.PayCst;
import com.czg.constants.PayTypeConstants;
import com.czg.dto.req.WechatNotifyReqDto;
import com.czg.dto.req.WechatPayNotifyDataDto;
import com.czg.entity.CzgBaseRespParams;
import com.czg.exception.CzgException;
import com.czg.market.entity.MkShopConsumeDiscountRecord;
import com.czg.market.service.MkDistributionUserService;
import com.czg.market.service.MkShopConsumeDiscountRecordService;
@@ -15,15 +19,13 @@ import com.czg.order.entity.OrderPayment;
import com.czg.order.service.OrderInfoCustomService;
import com.czg.order.service.OrderPaymentService;
import com.czg.service.market.service.impl.AppWxServiceImpl;
import com.czg.third.wechat.WechatReqUtils;
import com.czg.utils.AssertUtil;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
@@ -59,6 +61,48 @@ public class NotifyController {
return "success";
}
/**
* 原生支付回调
*/
@RequestMapping("/native/pay/{platform}")
public String pay(@PathVariable String platform, @RequestBody JSONObject json) {
if (PayCst.Platform.WECHAT.equalsIgnoreCase(platform)) {
// 微信
WechatNotifyReqDto reqDto = JSONObject.parseObject(json.toJSONString(), WechatNotifyReqDto.class);
log.info("【微信支付回调】收到微信支付回调 data: {}", JSONObject.toJSONString(reqDto));
String decrypted = WechatReqUtils.decryptRespParam(null, reqDto);
log.info("【微信支付回调】解密数据 {}", decrypted);
WechatPayNotifyDataDto dataDto = JSONObject.parseObject(decrypted, WechatPayNotifyDataDto.class);
return "success";
} else if (PayCst.Platform.ALIPAY.equalsIgnoreCase(platform)) {
// 支付宝
return "success";
}
throw new CzgException("不支持的支付平台");
}
/**
* 原生退款回调
*/
@RequestMapping("/native/refund/{platform}")
public String refund(@PathVariable String platform, @RequestBody JSONObject json) {
if (PayCst.Platform.WECHAT.equalsIgnoreCase(platform)) {
// 微信
WechatNotifyReqDto reqDto = JSONObject.parseObject(json.toJSONString(), WechatNotifyReqDto.class);
log.info("【微信退款回调】收到微信退款回调 data: {}", JSONObject.toJSONString(reqDto));
String decrypted = WechatReqUtils.decryptRespParam(null, reqDto);
log.info("【微信退款回调】解密数据 {}", decrypted);
return "success";
} else if (PayCst.Platform.ALIPAY.equalsIgnoreCase(platform)) {
// 支付宝
return "success";
}
throw new CzgException("不支持的支付平台");
}
@RequestMapping("/payCallBack")
public String notifyCallBack(@RequestBody CzgBaseRespParams respParams) {