会员退款

退款回调
This commit is contained in:
2025-02-19 17:15:42 +08:00
parent c024d83309
commit 1ef28891a5
14 changed files with 323 additions and 41 deletions

View File

@@ -28,9 +28,18 @@ public class NotifyController {
@RequestMapping("/payCallBack")
public String notifyCallBack(@RequestBody CzgBaseRespParams respParams){
JSONObject czg = CzgPayUtils.getCzg(respParams);
AssertUtil.isNull(czg, "回调数据为空");
AssertUtil.isNull(czg, "支付回调数据为空");
log.info("支付回调数据为:{}", czg);
orderInfoService.payCallBackOrder(czg.getString("mchOrderNo"), czg);
return SUCCESS;
}
@RequestMapping("/refundCallBack")
public String refundCallBack(@RequestBody CzgBaseRespParams respParams){
JSONObject czg = CzgPayUtils.getCzg(respParams);
AssertUtil.isNull(czg, "退款回调数据为空");
log.info("退款回调数据为:{}", czg);
orderInfoService.refundCallBackOrder(czg.getString("mchOrderNo"), czg);
return SUCCESS;
}
}

View File

@@ -2,6 +2,7 @@ package com.czg.controller;
import com.czg.resp.CzgResult;
import com.czg.service.order.dto.VipPayParamDTO;
import com.czg.service.order.dto.VipRefundDTO;
import com.czg.service.order.service.PayService;
import com.czg.utils.AssertUtil;
import com.czg.utils.ServletUtil;
@@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.Map;
/**
@@ -68,7 +70,7 @@ public class VipPayController {
@PostMapping("/scanPayVip")
public CzgResult<Map<String, Object>> scanPayVip(HttpServletRequest request, @Validated @RequestBody VipPayParamDTO payParam) {
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(request, "platformType"));
return payService.scanPayVip(ServletUtil.getClientIPByHeader(request), payParam);
}
@@ -82,4 +84,34 @@ public class VipPayController {
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
return payService.microPayVip(payParam);
}
/**
* 退款前置
* 最大退款金额 为 充值金额 inAmount
*/
@PostMapping("/refundVipBefore")
public CzgResult<Map<String, BigDecimal>> refundVipBefore(@Validated @RequestBody VipRefundDTO payParam) {
return payService.refundVipBefore(payParam);
}
/**
* cashRefund 是否是现金退款
* 会员退款(先调用 退款前置接口 refundVipBefore)
* 最大退款金额为 充值金额 inAmount
* 理论可退最大金额为
* 用户余额-赠送金额 >充值金额 则可退充值金额
* 实际可退最大金额为 充值金额
* 如果实际 大于 理论 则 需要勾选 outOfRange 超额退款 为true 默认为false
*/
@PostMapping("/refundVip")
public CzgResult<Object> refundVip(HttpServletRequest request, @Validated @RequestBody VipRefundDTO payParam) {
AssertUtil.isNull(payParam.getRefAmount(), "退款金额不能为空");
if (payParam.getRefAmount().compareTo(BigDecimal.ZERO) <= 0) {
return CzgResult.failure("退款金额必须大于0");
} else if (payParam.getRefAmount().compareTo(new BigDecimal("10001")) > 0) {
return CzgResult.failure("退款金额过大");
}
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(request, "platformType"));
return payService.refundVip(payParam);
}
}