feat: 退款审批
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user