mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
汇付退款回调接口
This commit is contained in:
@@ -311,10 +311,32 @@ public class PayController extends BaseController {
|
||||
|
||||
/**
|
||||
* 汇付支付退款
|
||||
* 用户余额退款
|
||||
* https://api.jsowellcloud.com/uniapp/pay/adapayRefund
|
||||
*/
|
||||
@PostMapping("/adapayRefund")
|
||||
public RestApiResponse<?> adapayRefund(HttpServletRequest request, @RequestBody WeChatRefundDTO dto) {
|
||||
|
||||
return null;
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
if (dto.getRefundAmount() == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isBlank(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
dto.setMemberId(memberId);
|
||||
dto.setRefundType("2");
|
||||
orderService.adapayRefund(dto);
|
||||
response = new RestApiResponse<>();
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("微信退款接口 warn", e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("微信退款接口 error", e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_WEIXIN_REFUND_ERROR);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -329,4 +351,18 @@ public class PayController extends BaseController {
|
||||
logger.error("汇付支付回调失败 error", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 汇付退款回调接口
|
||||
* https://api.jsowellcloud.com/uniapp/pay/adapayRefundCallback
|
||||
* @param request
|
||||
*/
|
||||
@PostMapping("/adapayRefundCallback")
|
||||
public void adapayRefundCallback(HttpServletRequest request) {
|
||||
try {
|
||||
orderService.adapayRefundCallback(request);
|
||||
} catch (Exception e) {
|
||||
logger.error("汇付支付退款回调失败 error", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -757,6 +757,11 @@ public class OrderService {
|
||||
orderBasicInfoService.weChatRefund(dto);
|
||||
}
|
||||
|
||||
public void adapayRefund(WeChatRefundDTO dto) {
|
||||
log.info("汇付退款 param:{}", JSON.toJSONString(dto));
|
||||
orderBasicInfoService.adapayRefund(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单详情信息
|
||||
* @param orderCode 订单编号
|
||||
@@ -1313,4 +1318,20 @@ public class OrderService {
|
||||
memberTransactionRecordService.insertSelective(record);
|
||||
}
|
||||
|
||||
public void adapayRefundCallback(HttpServletRequest request) throws Exception {
|
||||
//验签请参data
|
||||
String data = request.getParameter("data");
|
||||
//验签请参sign
|
||||
String sign = request.getParameter("sign");
|
||||
//验签请参publicKey
|
||||
String publicKey = AdapayCore.PUBLIC_KEY;
|
||||
log.info("汇付支付回调验签请参data={}, sign={}", data, sign);
|
||||
//验签标记
|
||||
boolean checkSign = AdapaySign.verifySign(data, sign, publicKey);
|
||||
if (!checkSign) {
|
||||
log.info("汇付支付回调验签失败:{}", data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -256,4 +256,6 @@ public interface IOrderBasicInfoService {
|
||||
|
||||
|
||||
String tempUpdateVirtualAmount(QueryOrderDTO dto);
|
||||
|
||||
void adapayRefund(WeChatRefundDTO dto);
|
||||
}
|
||||
|
||||
@@ -1727,4 +1727,19 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
||||
}
|
||||
return "共查询到" + orderListVOS.size() + "条订单,修改成功" + i + "条订单数据";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adapayRefund(WeChatRefundDTO dto) {
|
||||
// 退款有两种情况 1-订单结算退款 2-用户余额退款
|
||||
String refundType = dto.getRefundType();
|
||||
if (StringUtils.equals(refundType, "1")) {
|
||||
WechatPayRefundResponse response = refundForOrder(dto);
|
||||
logger.info("订单结算退款 result:{}", JSONObject.toJSONString(response));
|
||||
} else if (StringUtils.equals(refundType, "2")) {
|
||||
WechatPayRefundResponse response = refundForBalance(dto);
|
||||
logger.info("用户余额退款 result:{}", JSONObject.toJSONString(response));
|
||||
} else {
|
||||
logger.warn("没有找到退款处理逻辑");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user