mirror of
https://gitee.com/dromara/dax-pay
synced 2026-08-10 14:56:06 +08:00
feat: 支付产品配置增加 enabled 启停开关字段
This commit is contained in:
@@ -1,2 +1,5 @@
|
||||
-- 订单商品明细列表
|
||||
ALTER TABLE pay_normal_order ADD COLUMN IF NOT EXISTS goods_detail jsonb;
|
||||
|
||||
-- 支付产品配置增加启用/停用开关
|
||||
ALTER TABLE pay_product_config ADD COLUMN IF NOT EXISTS enabled boolean NOT NULL DEFAULT TRUE;
|
||||
|
||||
@@ -35,6 +35,16 @@ public class PayProductConfigController {
|
||||
return Res.ok(payProductConfigService.listAll());
|
||||
}
|
||||
|
||||
@PermCode(code = "edit", nameCn = "产品配置编辑", nameEn = "Product Config Edit")
|
||||
@Operation(summary = "切换产品启停")
|
||||
@PostMapping("/switch-enabled")
|
||||
public Result<Void> switchEnabled(
|
||||
@NotBlank(message = "{validation.field.product.notBlank}") String product,
|
||||
@NotNull(message = "{validation.field.enabled.notNull}") Boolean enabled) {
|
||||
payProductConfigService.switchEnabled(product, enabled);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
@PermCode(code = "edit", nameCn = "产品配置编辑", nameEn = "Product Config Edit")
|
||||
@Operation(summary = "切换产品生效环境")
|
||||
@PostMapping("/switch-env")
|
||||
|
||||
@@ -23,6 +23,9 @@ public class PayProductConfig extends MpBaseEntity implements ToResult<PayProduc
|
||||
/// 通道编码
|
||||
private String channel;
|
||||
|
||||
/// 是否启用
|
||||
private boolean enabled;
|
||||
|
||||
/// 生效环境: prod/sandbox
|
||||
private String activeEnv;
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ public class PayProductConfigParam {
|
||||
@Schema(description = "是否已配置参数")
|
||||
private boolean configured;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private boolean enabled;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ public class PayProductConfigResult extends BaseResult {
|
||||
@Schema(description = "是否支持沙箱环境")
|
||||
private boolean sandboxSupport;
|
||||
|
||||
@Schema(description = "是否启用")
|
||||
private boolean enabled;
|
||||
|
||||
@Schema(description = "生效环境: prod/sandbox")
|
||||
private String activeEnv;
|
||||
|
||||
|
||||
@@ -44,6 +44,15 @@ public class PayProductConfigService {
|
||||
.toList();
|
||||
}
|
||||
|
||||
/// 切换产品的启用/停用
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void switchEnabled(String product, boolean enabled) {
|
||||
PayProductConfig config = payProductConfigManager.findByProduct(product)
|
||||
.orElseGet(() -> createDefaultConfig(product));
|
||||
config.setEnabled(enabled);
|
||||
payProductConfigManager.saveOrUpdate(config);
|
||||
}
|
||||
|
||||
/// 切换产品的生效环境
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void switchEnv(String product, boolean sandbox) {
|
||||
@@ -66,6 +75,7 @@ public class PayProductConfigService {
|
||||
|
||||
config.setProduct(param.getProduct());
|
||||
config.setChannel(param.getChannel());
|
||||
config.setEnabled(param.isEnabled());
|
||||
config.setActiveEnv(param.getActiveEnv() != null ? param.getActiveEnv() : PayEnvEnum.PROD.getCode());
|
||||
config.setConfigured(param.isConfigured());
|
||||
config.setRemark(param.getRemark());
|
||||
@@ -100,9 +110,11 @@ public class PayProductConfigService {
|
||||
PayProductConfig config = configMap.get(payProduct.getCode());
|
||||
if (config != null) {
|
||||
result.setId(config.getId());
|
||||
result.setEnabled(config.isEnabled());
|
||||
result.setActiveEnv(config.getActiveEnv());
|
||||
result.setConfigured(config.isConfigured());
|
||||
} else {
|
||||
result.setEnabled(true);
|
||||
result.setActiveEnv(PayEnvEnum.PROD.getCode());
|
||||
result.setConfigured(false);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,9 @@
|
||||
"sandbox": {
|
||||
"notNull": "Sandbox environment cannot be blank"
|
||||
},
|
||||
"enabled": {
|
||||
"notNull": "Enabled status cannot be blank"
|
||||
},
|
||||
"enable": {
|
||||
"notNull": "Enable status cannot be blank"
|
||||
},
|
||||
|
||||
@@ -49,6 +49,9 @@
|
||||
"sandbox": {
|
||||
"notNull": "沙箱环境不可为空"
|
||||
},
|
||||
"enabled": {
|
||||
"notNull": "启用状态不可为空"
|
||||
},
|
||||
"enable": {
|
||||
"notNull": "是否启用不可为空"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user