2
0

feat: 退款审批

This commit is contained in:
caiyuchao
2025-03-31 10:25:14 +08:00
parent 1a65c76613
commit 5f46f3044b
36 changed files with 942 additions and 88 deletions

View File

@@ -0,0 +1,31 @@
package org.wfc.user.api;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.wfc.common.core.constant.SecurityConstants;
import org.wfc.common.core.constant.ServiceNameConstants;
import org.wfc.common.core.domain.R;
import org.wfc.user.api.factory.RemoteUPaymentFallbackFactory;
/**
* @description: 支付服务
* @author: cyc
* @since: 2025-03-27
*/
@FeignClient(contextId = "remoteUPaymentService", value = ServiceNameConstants.PAYMENT_SERVICE, fallbackFactory = RemoteUPaymentFallbackFactory.class)
public interface RemoteUPaymentService {
/**
* 退款
*
* @param orderId 订单id
* @return boolean
*/
@PostMapping(value = "/aliPay/tradeRefund")
R<Boolean> aliPayRefund(@RequestParam(value = "orderId") Long orderId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@PostMapping(value = "/refund")
R<String> wxPayRefund(@RequestParam(value = "orderId") Long orderId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}

View File

@@ -86,8 +86,12 @@ public interface RemoteUUserService
@PostMapping("/client/recordClientUser")
public R<Boolean> recordClientUser(@RequestBody UClientBo clientBo);
@PostMapping("/order/paySuccess/{id}")
public R<Boolean> paySuccess(@PathVariable("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@PostMapping("/order/paySuccess/{paymentType}/{id}")
public R<Boolean> paySuccess(@PathVariable("paymentType")Integer paymentType, @PathVariable("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@PostMapping("/order/refundSuccess/{paymentType}/{id}")
public R<Boolean> refundSuccess(@PathVariable("paymentType")Integer paymentType, @PathVariable("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@GetMapping(value = "/order/{id}")
public R<UOrderVo> getOrderById(@PathVariable("id") Long id);

View File

@@ -0,0 +1,33 @@
package org.wfc.user.api.factory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.wfc.common.core.domain.R;
import org.wfc.user.api.RemoteUPaymentService;
/**
* @description: 支付服务降级处理
* @author: cyc
* @since: 2025-03-27
*/
@Component
@Slf4j
public class RemoteUPaymentFallbackFactory implements FallbackFactory<RemoteUPaymentService> {
@Override
public RemoteUPaymentService create(Throwable throwable) {
log.error("Payment service call failed:{}", throwable.getMessage());
return new RemoteUPaymentService() {
@Override
public R<Boolean> aliPayRefund(Long orderId, String source) {
return R.fail("Failed to alipay refund:" + throwable.getMessage());
}
@Override
public R<String> wxPayRefund(Long orderId, String source) {
return R.fail("Failed to wxpay refund:" + throwable.getMessage());
}
};
}
}

View File

@@ -74,10 +74,15 @@ public class RemoteUUserFallbackFactory implements FallbackFactory<RemoteUUserSe
}
@Override
public R<Boolean> paySuccess(Long id, String source) {
public R<Boolean> paySuccess(Integer type, Long id, String source) {
return R.fail("pay callback error:" + throwable.getMessage());
}
@Override
public R<Boolean> refundSuccess(Integer paymentType, Long id, String source) {
return R.fail("refund callback error:" + throwable.getMessage());
}
@Override
public R<UOrderVo> getOrderById(Long id) {
return R.fail("get order error:" + throwable.getMessage());

View File

@@ -1,3 +1,4 @@
org.wfc.user.api.factory.RemoteUUserFallbackFactory
org.wfc.user.api.factory.RemoteULogFallbackFactory
org.wfc.user.api.factory.RemoteUFileFallbackFactory
org.wfc.user.api.factory.RemoteUPaymentFallbackFactory