mirror of
https://gitee.com/dromara/dax-pay
synced 2026-08-10 14:56:06 +08:00
refactor(payment): 订单关闭入口收敛, 删除pay-trade三套close端点, 统一入口参数对齐核心层(containerId/tradeType)并剥离管理端useCancel
This commit is contained in:
@@ -26,13 +26,12 @@ public class OrderCloseAdminController {
|
||||
private final OrderCloseAdminService orderCloseAdminService;
|
||||
|
||||
@PermCode(menuCode = PermCodes.Trade.Order.MENU, code = PermCodes.Action.MANAGE)
|
||||
@Operation(summary = "关闭/撤销订单(网关/普通统一入口)")
|
||||
@Operation(summary = "关闭订单(网关/普通统一入口)")
|
||||
@PostMapping("/close")
|
||||
public Result<Void> close(
|
||||
@NotNull(message = "{validation.field.id.notNull}") Long id,
|
||||
@NotBlank String type,
|
||||
@RequestParam(defaultValue = "false") boolean useCancel) {
|
||||
orderCloseAdminService.close(id, type, useCancel);
|
||||
@NotNull(message = "{validation.field.id.notNull}") Long containerId,
|
||||
@NotBlank String tradeType) {
|
||||
orderCloseAdminService.close(containerId, tradeType);
|
||||
return Res.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/// # 资金交易凭证(管理)
|
||||
@@ -57,14 +56,4 @@ public class PayTradeAdminController {
|
||||
@NotNull(message = "{validation.field.id.notNull}") Long id) {
|
||||
return Res.ok(payTradeAdminService.sync(id));
|
||||
}
|
||||
|
||||
@PermCode(code = PermCodes.Action.MANAGE)
|
||||
@Operation(summary = "关闭/撤销订单")
|
||||
@PostMapping("/close")
|
||||
public Result<Void> close(
|
||||
@NotNull(message = "{validation.field.id.notNull}") Long id,
|
||||
@RequestParam(defaultValue = "false") boolean useCancel) {
|
||||
payTradeAdminService.close(id, useCancel);
|
||||
return Res.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
/// # 订单关闭统一管理服务
|
||||
///
|
||||
/// 收归网关支付与普通支付的关闭入口, 委托 [PayCloseService.closeByContainer]。
|
||||
/// 收归网关支付与普通支付的关闭入口, 委托 [PayCloseService#closeByContainer]。
|
||||
/// 网关预下单未生成 Trade 的兜底关单由 closeByContainer 内部处理, 本服务不重复实现。
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -14,12 +14,11 @@ public class OrderCloseAdminService {
|
||||
|
||||
private final PayCloseService payCloseService;
|
||||
|
||||
/// 关闭/撤销订单(统一入口)
|
||||
/// 关闭订单(统一入口)
|
||||
///
|
||||
/// @param id 业务容器ID(pay_gateway_order / pay_normal_order 主键)
|
||||
/// @param type 容器类型: gateway=网关支付, normal=普通支付
|
||||
/// @param useCancel 是否以撤销方式关闭
|
||||
public void close(Long id, String type, boolean useCancel) {
|
||||
payCloseService.closeByContainer(id, type, useCancel);
|
||||
/// @param containerId 业务容器ID(pay_gateway_order / pay_normal_order 主键)
|
||||
/// @param tradeType 容器类型: gateway=网关支付, normal=普通支付
|
||||
public void close(Long containerId, String tradeType) {
|
||||
payCloseService.closeByContainer(containerId, tradeType, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import cn.daxpay.open.payment.trade.order.entity.PayTrade;
|
||||
import cn.daxpay.open.payment.trade.order.param.PayTradeQuery;
|
||||
import cn.daxpay.open.payment.trade.order.result.PayTradeResult;
|
||||
import cn.daxpay.open.payment.trade.order.service.TradeOrderDetailAssembler;
|
||||
import cn.daxpay.open.payment.trade.runtime.service.close.PayCloseService;
|
||||
import cn.daxpay.open.payment.trade.runtime.service.sync.PaySyncService;
|
||||
import cn.daxpay.open.payment.unipay.result.trade.pay.NormalPaySyncResult;
|
||||
import cn.daxpay.open.platform.common.translate.service.TransService;
|
||||
@@ -26,7 +25,6 @@ public class PayTradeAdminService {
|
||||
|
||||
private final PayTradeManager payTradeManager;
|
||||
private final PaySyncService paySyncService;
|
||||
private final PayCloseService payCloseService;
|
||||
private final TransService transService;
|
||||
private final TradeOrderDetailAssembler tradeOrderDetailAssembler;
|
||||
|
||||
@@ -63,11 +61,4 @@ public class PayTradeAdminService {
|
||||
.orElseThrow(() -> new DataNotExistException("pay.error.payOrderNotExist"));
|
||||
return paySyncService.syncPayOrder(trade);
|
||||
}
|
||||
|
||||
/// 关闭/撤销订单(传入资金交易ID)
|
||||
public void close(Long id, boolean useCancel) {
|
||||
PayTrade trade = payTradeManager.findById(id)
|
||||
.orElseThrow(() -> new DataNotExistException("pay.error.payOrderNotExist"));
|
||||
payCloseService.closeOrder(trade, useCancel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,13 +26,12 @@ public class AppAdminOrderCloseController {
|
||||
private final AppAdminOrderCloseService appAdminOrderCloseService;
|
||||
|
||||
@PermCode(menuCode = PermCodes.Trade.Order.MENU, code = PermCodes.Action.MANAGE)
|
||||
@Operation(summary = "关闭/撤销订单(网关/普通统一入口)")
|
||||
@Operation(summary = "关闭订单(网关/普通统一入口)")
|
||||
@PostMapping("/close")
|
||||
public Result<Void> close(
|
||||
@NotNull(message = "{validation.field.id.notNull}") Long id,
|
||||
@NotBlank String type,
|
||||
@RequestParam(defaultValue = "false") boolean useCancel) {
|
||||
appAdminOrderCloseService.close(id, type, useCancel);
|
||||
@NotNull(message = "{validation.field.id.notNull}") Long containerId,
|
||||
@NotBlank String tradeType) {
|
||||
appAdminOrderCloseService.close(containerId, tradeType);
|
||||
return Res.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/// # 资金交易凭证(运营移动端)
|
||||
@@ -56,14 +55,4 @@ public class AppAdminPayTradeController {
|
||||
@NotNull(message = "{validation.field.id.notNull}") Long id) {
|
||||
return Res.ok(payTradeService.sync(id));
|
||||
}
|
||||
|
||||
@PermCode(code = PermCodes.Action.MANAGE)
|
||||
@Operation(summary = "关闭/撤销订单")
|
||||
@PostMapping("/close")
|
||||
public Result<Void> close(
|
||||
@NotNull(message = "{validation.field.id.notNull}") Long id,
|
||||
@RequestParam(defaultValue = "false") boolean useCancel) {
|
||||
payTradeService.close(id, useCancel);
|
||||
return Res.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ public class AppAdminOrderCloseService {
|
||||
|
||||
private final OrderCloseAdminService orderCloseAdminService;
|
||||
|
||||
/// 关闭/撤销订单(统一入口)
|
||||
public void close(Long id, String type, boolean useCancel) {
|
||||
orderCloseAdminService.close(id, type, useCancel);
|
||||
/// 关闭订单(统一入口)
|
||||
public void close(Long containerId, String tradeType) {
|
||||
orderCloseAdminService.close(containerId, tradeType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,9 +32,4 @@ public class AppAdminPayTradeService {
|
||||
public NormalPaySyncResult sync(Long id) {
|
||||
return payTradeAdminService.sync(id);
|
||||
}
|
||||
|
||||
/// 关闭/撤销订单
|
||||
public void close(Long id, boolean useCancel) {
|
||||
payTradeAdminService.close(id, useCancel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,13 +26,12 @@ public class MchOrderCloseController {
|
||||
private final MchOrderCloseService mchOrderCloseService;
|
||||
|
||||
@PermCode(menuCode = PermCodes.Trade.Order.MENU, code = PermCodes.Action.MANAGE)
|
||||
@Operation(summary = "关闭/撤销订单(网关/普通统一入口)")
|
||||
@Operation(summary = "关闭订单(网关/普通统一入口)")
|
||||
@PostMapping("/close")
|
||||
public Result<Void> close(
|
||||
@NotNull(message = "{validation.field.id.notNull}") Long id,
|
||||
@NotBlank String type,
|
||||
@RequestParam(defaultValue = "false") boolean useCancel) {
|
||||
mchOrderCloseService.close(id, type, useCancel);
|
||||
@NotNull(message = "{validation.field.id.notNull}") Long containerId,
|
||||
@NotBlank String tradeType) {
|
||||
mchOrderCloseService.close(containerId, tradeType);
|
||||
return Res.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/// # 资金交易凭证(商户端)
|
||||
@@ -56,14 +55,4 @@ public class MchPayTradeController {
|
||||
@NotNull(message = "{validation.field.id.notNull}") Long id) {
|
||||
return Res.ok(mchPayTradeService.sync(id));
|
||||
}
|
||||
|
||||
@PermCode(code = PermCodes.Action.MANAGE)
|
||||
@Operation(summary = "关闭/撤销订单")
|
||||
@PostMapping("/close")
|
||||
public Result<Void> close(
|
||||
@NotNull(message = "{validation.field.id.notNull}") Long id,
|
||||
@RequestParam(defaultValue = "false") boolean useCancel) {
|
||||
mchPayTradeService.close(id, useCancel);
|
||||
return Res.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,11 @@ public class MchOrderCloseService {
|
||||
|
||||
private final PayCloseService payCloseService;
|
||||
|
||||
/// 关闭/撤销订单(统一入口)
|
||||
/// 关闭订单(统一入口)
|
||||
///
|
||||
/// @param id 业务容器ID(pay_gateway_order / pay_normal_order 主键)
|
||||
/// @param type 容器类型: gateway=网关支付, normal=普通支付
|
||||
/// @param useCancel 是否以撤销方式关闭
|
||||
public void close(Long id, String type, boolean useCancel) {
|
||||
payCloseService.closeByContainer(id, type, useCancel);
|
||||
/// @param containerId 业务容器ID(pay_gateway_order / pay_normal_order 主键)
|
||||
/// @param tradeType 容器类型: gateway=网关支付, normal=普通支付
|
||||
public void close(Long containerId, String tradeType) {
|
||||
payCloseService.closeByContainer(containerId, tradeType, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import cn.daxpay.open.payment.trade.order.entity.PayTrade;
|
||||
import cn.daxpay.open.payment.trade.order.param.PayTradeQuery;
|
||||
import cn.daxpay.open.payment.trade.order.result.PayTradeResult;
|
||||
import cn.daxpay.open.payment.trade.order.service.TradeOrderDetailAssembler;
|
||||
import cn.daxpay.open.payment.trade.runtime.service.close.PayCloseService;
|
||||
import cn.daxpay.open.payment.trade.runtime.service.sync.PaySyncService;
|
||||
import cn.daxpay.open.payment.unipay.result.trade.pay.NormalPaySyncResult;
|
||||
import cn.daxpay.open.platform.core.code.CommonCode;
|
||||
@@ -29,7 +28,6 @@ public class MchPayTradeService {
|
||||
private final PaymentContext paymentContext;
|
||||
private final PayTradeManager payTradeManager;
|
||||
private final PaySyncService paySyncService;
|
||||
private final PayCloseService payCloseService;
|
||||
private final TradeOrderDetailAssembler tradeOrderDetailAssembler;
|
||||
|
||||
/// 分页查询(强制当前商户)
|
||||
@@ -62,13 +60,6 @@ public class MchPayTradeService {
|
||||
return paySyncService.syncPayOrder(trade);
|
||||
}
|
||||
|
||||
/// 关闭/撤销订单(传入资金交易ID)
|
||||
public void close(Long id, boolean useCancel) {
|
||||
PayTrade trade = payTradeManager.findById(id)
|
||||
.orElseThrow(() -> new DataNotExistException("pay.error.payOrderNotExist"));
|
||||
payCloseService.closeOrder(trade, useCancel);
|
||||
}
|
||||
|
||||
/// 解析并强制写入当前商户号
|
||||
private void forceMchNo(PayTradeQuery query) {
|
||||
String mchNo = requireMchNo();
|
||||
|
||||
Reference in New Issue
Block a user