feat: 支付产品配置增加 enabled 启停开关字段

This commit is contained in:
DaxPay Dev
2026-06-17 13:50:22 +08:00
parent 1fc1a11931
commit da3749a09a
8 changed files with 40 additions and 0 deletions

View File

@@ -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;

View File

@@ -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")

View File

@@ -23,6 +23,9 @@ public class PayProductConfig extends MpBaseEntity implements ToResult<PayProduc
/// 通道编码
private String channel;
/// 是否启用
private boolean enabled;
/// 生效环境: prod/sandbox
private String activeEnv;

View File

@@ -26,6 +26,9 @@ public class PayProductConfigParam {
@Schema(description = "是否已配置参数")
private boolean configured;
@Schema(description = "是否启用")
private boolean enabled;
@Schema(description = "备注")
private String remark;
}

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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"
},

View File

@@ -49,6 +49,9 @@
"sandbox": {
"notNull": "沙箱环境不可为空"
},
"enabled": {
"notNull": "启用状态不可为空"
},
"enable": {
"notNull": "是否启用不可为空"
},