feat: 添加服务商支付模式
1. 添加服务商模式标识字段
2. 添加服务商相关字段
3. 添加子商户相关字段
4. 创建索引以提高查询性能
5. 添加注释说明
This commit is contained in:
+81
-39
@@ -28,21 +28,90 @@ public class SysWechatConfigController {
|
||||
@Resource
|
||||
private WechatConfigService wechatConfigService;
|
||||
|
||||
|
||||
@Operation(summary = "查询列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "page",description = "分页起始位置",required = true,in= ParameterIn.QUERY),
|
||||
@Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY)
|
||||
})
|
||||
@GetMapping
|
||||
public PageResult list(@RequestParam Map<String, Object> params) {
|
||||
return wechatConfigService.findList(params);
|
||||
@Operation(summary = "分页查询微信配置")
|
||||
@GetMapping("/list")
|
||||
public Result<PageResult<WechatConfig>> list(@RequestParam Map<String, Object> params) {
|
||||
PageResult<WechatConfig> pageResult = wechatConfigService.findList(params);
|
||||
return Result.succeed(pageResult);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取微信配置")
|
||||
@Operation(summary = "根据ID查询微信配置")
|
||||
@GetMapping("/{id}")
|
||||
public Result<WechatConfig> getById(@PathVariable Long id) {
|
||||
WechatConfig config = wechatConfigService.getById(id);
|
||||
return Result.succeed(config);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据类型和租户ID查询微信配置")
|
||||
@GetMapping("/{type}")
|
||||
public WechatConfig getConfig(@PathVariable String type) {
|
||||
return wechatConfigService.getConfig(type, TenantContextHolder.getTenant());
|
||||
public Result<WechatConfig> getConfig(@PathVariable String type, @RequestParam String tenantId) {
|
||||
WechatConfig config = wechatConfigService.getConfig(type, tenantId);
|
||||
return Result.succeed(config);
|
||||
}
|
||||
|
||||
@Operation(summary = "保存微信配置")
|
||||
@PostMapping
|
||||
public Result<Boolean> save(@RequestBody WechatConfig config) {
|
||||
boolean result = wechatConfigService.saveConfig(config);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新微信配置")
|
||||
@PutMapping
|
||||
public Result<Boolean> update(@RequestBody WechatConfig config) {
|
||||
boolean result = wechatConfigService.updateConfig(config);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除微信配置")
|
||||
@DeleteMapping("/{id}")
|
||||
public Result<Boolean> delete(@PathVariable Long id) {
|
||||
boolean result = wechatConfigService.deleteConfig(id);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
// ========== 服务商模式相关接口 ==========
|
||||
|
||||
@Operation(summary = "获取服务商配置")
|
||||
@GetMapping("/service/{tenantId}")
|
||||
public Result<WechatConfig> getServiceConfig(@PathVariable String tenantId) {
|
||||
WechatConfig config = wechatConfigService.getServiceConfig(tenantId);
|
||||
return Result.succeed(config);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据子商户号查询配置")
|
||||
@GetMapping("/sub/{subMchId}")
|
||||
public Result<WechatConfig> getConfigBySubMchId(@PathVariable String subMchId) {
|
||||
WechatConfig config = wechatConfigService.getConfigBySubMchId(subMchId);
|
||||
return Result.succeed(config);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取指定服务商下的所有子商户配置")
|
||||
@GetMapping("/submerchants/{serviceMchId}")
|
||||
public Result<java.util.List<WechatConfig>> getSubMerchantConfigs(@PathVariable String serviceMchId) {
|
||||
java.util.List<WechatConfig> configs = wechatConfigService.getSubMerchantConfigs(serviceMchId);
|
||||
return Result.succeed(configs);
|
||||
}
|
||||
|
||||
@Operation(summary = "保存服务商配置")
|
||||
@PostMapping("/service")
|
||||
public Result<Boolean> saveServiceConfig(@RequestBody WechatConfig config) {
|
||||
boolean result = wechatConfigService.saveServiceConfig(config);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "保存子商户配置")
|
||||
@PostMapping("/submerchant")
|
||||
public Result<Boolean> saveSubMerchantConfig(@RequestBody WechatConfig config) {
|
||||
boolean result = wechatConfigService.saveSubMerchantConfig(config);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "切换配置")
|
||||
@PutMapping("/switch")
|
||||
public Result<Boolean> switchConfig(@RequestParam String type, @RequestParam String merchantId) {
|
||||
boolean result = wechatConfigService.switchConfig(type, merchantId);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取微信配置")
|
||||
@@ -57,27 +126,6 @@ public class SysWechatConfigController {
|
||||
return wechatConfigService.getConfigBySerialNumber(serialNumber);
|
||||
}
|
||||
|
||||
@Operation(summary = "保存微信配置")
|
||||
@PostMapping
|
||||
public Result<Boolean> saveConfig(@RequestBody WechatConfig config) {
|
||||
if (config.getId() == null) {
|
||||
config.setTenantId(TenantContextHolder.getTenant());
|
||||
}
|
||||
return Result.succeed(wechatConfigService.saveConfig(config));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新微信配置")
|
||||
@PutMapping
|
||||
public Result<Boolean> updateConfig(@RequestBody WechatConfig config) {
|
||||
return Result.succeed(wechatConfigService.updateConfig(config));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除微信配置")
|
||||
@DeleteMapping("/{id}")
|
||||
public Result<Boolean> deleteConfig(@PathVariable Long id) {
|
||||
return Result.succeed(wechatConfigService.deleteConfig(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "上传支付私钥")
|
||||
@PostMapping("/private-key")
|
||||
public Result<Boolean> uploadPrivateKey(@RequestParam("file") MultipartFile file) {
|
||||
@@ -92,12 +140,6 @@ public class SysWechatConfigController {
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "切换微信配置")
|
||||
@PostMapping("/switch/{type}")
|
||||
public Result<Boolean> switchConfig(@PathVariable String type) {
|
||||
return Result.succeed(wechatConfigService.switchConfig(type, TenantContextHolder.getTenant()));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取当前配置")
|
||||
@GetMapping("/current/{type}")
|
||||
public Result<WechatConfig> getCurrentConfig(@PathVariable String type) {
|
||||
|
||||
+43
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.wechat.entity.WechatConfig;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface WechatConfigService extends IService<WechatConfig> {
|
||||
@@ -72,4 +73,46 @@ public interface WechatConfigService extends IService<WechatConfig> {
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean switchConfig(String type, String merchantId);
|
||||
|
||||
// ========== 服务商模式新增方法 ==========
|
||||
|
||||
/**
|
||||
* 获取服务商配置
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @return 服务商配置
|
||||
*/
|
||||
WechatConfig getServiceConfig(String tenantId);
|
||||
|
||||
/**
|
||||
* 根据子商户号获取配置
|
||||
*
|
||||
* @param subMchId 子商户号
|
||||
* @return 微信配置
|
||||
*/
|
||||
WechatConfig getConfigBySubMchId(String subMchId);
|
||||
|
||||
/**
|
||||
* 获取指定服务商下的所有子商户配置
|
||||
*
|
||||
* @param serviceMchId 服务商商户号
|
||||
* @return 子商户配置列表
|
||||
*/
|
||||
List<WechatConfig> getSubMerchantConfigs(String serviceMchId);
|
||||
|
||||
/**
|
||||
* 保存服务商配置
|
||||
*
|
||||
* @param config 服务商配置
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean saveServiceConfig(WechatConfig config);
|
||||
|
||||
/**
|
||||
* 保存子商户配置
|
||||
*
|
||||
* @param config 子商户配置
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean saveSubMerchantConfig(WechatConfig config);
|
||||
}
|
||||
|
||||
+43
@@ -76,4 +76,47 @@ public class WechatConfigServiceImpl extends ServiceImpl<WechatConfigMapper, Wec
|
||||
// 这里可以添加切换配置的具体逻辑
|
||||
return true;
|
||||
}
|
||||
|
||||
// ========== 服务商模式新增方法实现 ==========
|
||||
|
||||
@Override
|
||||
public WechatConfig getServiceConfig(String tenantId) {
|
||||
return getOne(new LambdaQueryWrapper<WechatConfig>()
|
||||
.eq(WechatConfig::getTenantId, tenantId)
|
||||
.eq(WechatConfig::getType, "PAY")
|
||||
.eq(WechatConfig::getIsServiceMode, true)
|
||||
.eq(WechatConfig::getStatus, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public WechatConfig getConfigBySubMchId(String subMchId) {
|
||||
return getOne(new LambdaQueryWrapper<WechatConfig>()
|
||||
.eq(WechatConfig::getSubMchId, subMchId)
|
||||
.eq(WechatConfig::getIsServiceMode, true)
|
||||
.eq(WechatConfig::getStatus, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WechatConfig> getSubMerchantConfigs(String serviceMchId) {
|
||||
return list(new LambdaQueryWrapper<WechatConfig>()
|
||||
.eq(WechatConfig::getServiceMchId, serviceMchId)
|
||||
.eq(WechatConfig::getIsServiceMode, true)
|
||||
.eq(WechatConfig::getStatus, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveServiceConfig(WechatConfig config) {
|
||||
// 设置服务商模式标识
|
||||
config.setIsServiceMode(true);
|
||||
config.setType("PAY");
|
||||
return save(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveSubMerchantConfig(WechatConfig config) {
|
||||
// 设置服务商模式标识
|
||||
config.setIsServiceMode(true);
|
||||
config.setType("PAY");
|
||||
return save(config);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user