From 63104c5fa7ac0f8663fa628722d25810faefd0aa Mon Sep 17 00:00:00 2001 From: daxpay Date: Mon, 3 Aug 2026 19:52:38 +0800 Subject: [PATCH] =?UTF-8?q?refactor(union):=20=E9=93=B6=E8=81=94=E9=80=9A?= =?UTF-8?q?=E9=81=93=E5=8E=BB=20direct=20=E5=AD=90=E5=8C=85,=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=B1=BB=E4=B8=8E=E5=95=86=E6=88=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=89=81=E5=B9=B3=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除 union/**/direct/ 子包, Controller/Service/Entity/Param/Result/Convert/Manager/Mapper 上移至模块根包 - UnionDirectConfigAssembler → UnionConfigAssembler, UnionDirectKeyConfig* → UnionKeyConfig*, UnionDirectChannelMerchant* → UnionChannelMerchant* - 各 strategy/callback 引用同步更新 - pom 描述与产品策略注释「直连银联 ACP」→「银联 ACP」 --- daxpay-channel/daxpay-channel-union/pom.xml | 2 +- .../open/channel/union/UnionChannelApp.java | 4 +- .../client/credential/UnionSdkCredential.java | 2 +- ...va => UnionChannelMerchantController.java} | 38 +++++++++---------- .../union/convert/UnionKeyConfigConvert.java | 19 ++++++++++ .../direct/UnionDirectKeyConfigConvert.java | 19 ---------- .../union/dao/UnionKeyConfigManager.java | 27 +++++++++++++ .../union/dao/UnionKeyConfigMapper.java | 10 +++++ .../direct/UnionDirectKeyConfigManager.java | 27 ------------- .../direct/UnionDirectKeyConfigMapper.java | 10 ----- ...rectKeyConfig.java => UnionKeyConfig.java} | 18 ++++----- ...a => UnionChannelMerchantCreateParam.java} | 8 ++-- ...figParam.java => UnionKeyConfigParam.java} | 8 ++-- ...gResult.java => UnionKeyConfigResult.java} | 6 +-- ....java => UnionChannelMerchantService.java} | 27 ++++++------- ...sembler.java => UnionConfigAssembler.java} | 20 +++++----- ...ervice.java => UnionKeyConfigService.java} | 35 ++++++++--------- .../callback/UnionPayCallbackService.java | 4 +- .../callback/UnionRefundCallbackService.java | 4 +- .../strategy/pay/UnionPayCloseStrategy.java | 6 +-- .../strategy/pay/UnionPayPayStrategy.java | 6 +-- .../product/UnionPayProductStrategy.java | 2 +- .../refund/UnionPayRefundStrategy.java | 6 +-- .../refund/UnionPaySyncRefundStrategy.java | 6 +-- .../strategy/sync/UnionPaySyncStrategy.java | 6 +-- 25 files changed, 161 insertions(+), 159 deletions(-) rename daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/controller/{direct/UnionDirectChannelMerchantController.java => UnionChannelMerchantController.java} (60%) create mode 100644 daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/convert/UnionKeyConfigConvert.java delete mode 100644 daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/convert/direct/UnionDirectKeyConfigConvert.java create mode 100644 daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/dao/UnionKeyConfigManager.java create mode 100644 daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/dao/UnionKeyConfigMapper.java delete mode 100644 daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/dao/direct/UnionDirectKeyConfigManager.java delete mode 100644 daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/dao/direct/UnionDirectKeyConfigMapper.java rename daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/entity/{direct/UnionDirectKeyConfig.java => UnionKeyConfig.java} (73%) rename daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/param/{direct/UnionDirectChannelMerchantCreateParam.java => UnionChannelMerchantCreateParam.java} (81%) rename daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/param/{direct/UnionDirectKeyConfigParam.java => UnionKeyConfigParam.java} (87%) rename daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/result/{direct/UnionDirectKeyConfigResult.java => UnionKeyConfigResult.java} (88%) rename daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/{direct/UnionDirectChannelMerchantService.java => UnionChannelMerchantService.java} (74%) rename daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/{direct/UnionDirectConfigAssembler.java => UnionConfigAssembler.java} (75%) rename daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/{direct/UnionDirectKeyConfigService.java => UnionKeyConfigService.java} (57%) diff --git a/daxpay-channel/daxpay-channel-union/pom.xml b/daxpay-channel/daxpay-channel-union/pom.xml index 6c1301188..770dfc327 100644 --- a/daxpay-channel/daxpay-channel-union/pom.xml +++ b/daxpay-channel/daxpay-channel-union/pom.xml @@ -12,5 +12,5 @@ daxpay-channel-union jar - 云闪付(直连银联 ACP)支付通道 + 云闪付(银联 ACP)支付通道 diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/UnionChannelApp.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/UnionChannelApp.java index 0624eb2dd..f0d9f1209 100644 --- a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/UnionChannelApp.java +++ b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/UnionChannelApp.java @@ -6,9 +6,9 @@ import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.context.properties.ConfigurationPropertiesScan; import org.springframework.context.annotation.ComponentScan; -/// # 云闪付(直连银联 ACP)支付实现 +/// # 云闪付(银联 ACP)支付实现 /// -/// 云闪付直连银联全渠道支付平台, 通过证书签名支持主扫/被扫/H5 支付。 +/// 云闪付对接银联全渠道支付平台, 通过证书签名支持主扫/被扫/H5 支付。 /// 主应用通过声明式 HTTP 客户端调用子应用 dax-pay-channel-one 完成实际通道交互。 @AutoConfiguration @ConfigurationPropertiesScan diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/client/credential/UnionSdkCredential.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/client/credential/UnionSdkCredential.java index 94ca85226..ae6299460 100644 --- a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/client/credential/UnionSdkCredential.java +++ b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/client/credential/UnionSdkCredential.java @@ -5,7 +5,7 @@ import lombok.Data; /// # 云闪付 SDK 凭证 /// /// 与子应用 dax-pay-channel-one 的 `UnionSdkCredential` 镜像, 跨 HTTP 传输时字段对齐。 -/// 主应用从直连配置(union_direct_key_config)提取商户号、签名类型与三证书后组装, 下发给子应用。 +/// 主应用从密钥配置(union_key_config)提取商户号、签名类型与三证书后组装, 下发给子应用。 /// /// 银联 ACP 采用 RSA2 证书签名(私钥证书 PKCS12 + 中级/根证书), 三证书均为 Base64 字符串。 @Data diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/controller/direct/UnionDirectChannelMerchantController.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/controller/UnionChannelMerchantController.java similarity index 60% rename from daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/controller/direct/UnionDirectChannelMerchantController.java rename to daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/controller/UnionChannelMerchantController.java index 29017b2d5..7c43b80e0 100644 --- a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/controller/direct/UnionDirectChannelMerchantController.java +++ b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/controller/UnionChannelMerchantController.java @@ -1,10 +1,10 @@ -package cn.daxpay.open.channel.union.controller.direct; +package cn.daxpay.open.channel.union.controller; -import cn.daxpay.open.channel.union.param.direct.UnionDirectChannelMerchantCreateParam; -import cn.daxpay.open.channel.union.param.direct.UnionDirectKeyConfigParam; -import cn.daxpay.open.channel.union.result.direct.UnionDirectKeyConfigResult; -import cn.daxpay.open.channel.union.service.direct.UnionDirectChannelMerchantService; -import cn.daxpay.open.channel.union.service.direct.UnionDirectKeyConfigService; +import cn.daxpay.open.channel.union.param.UnionChannelMerchantCreateParam; +import cn.daxpay.open.channel.union.param.UnionKeyConfigParam; +import cn.daxpay.open.channel.union.result.UnionKeyConfigResult; +import cn.daxpay.open.channel.union.service.UnionChannelMerchantService; +import cn.daxpay.open.channel.union.service.UnionKeyConfigService; import cn.daxpay.open.platform.core.annotation.PermCode; import cn.daxpay.open.platform.core.code.PermCodes; import cn.daxpay.open.platform.core.rest.Res; @@ -21,36 +21,36 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -/// # 云闪付直连通道商户管理 +/// # 云闪付通道商户管理 /// /// 提供通道商户创建和 RSA2 证书配置管理。 /// 银联商户号(merId)创建时录入, 私钥/中级/根证书由密钥配置维护。 @PermCode(menuCode = PermCodes.Channel.Merchant.MENU) @Validated -@Tag(name = "云闪付直连通道商户管理") +@Tag(name = "云闪付通道商户管理") @RestController -@RequestMapping("/admin/union/direct-channel-merchant") +@RequestMapping("/admin/union/channel-merchant") @RequiredArgsConstructor -public class UnionDirectChannelMerchantController { +public class UnionChannelMerchantController { - private final UnionDirectChannelMerchantService unionDirectChannelMerchantService; - private final UnionDirectKeyConfigService unionDirectKeyConfigService; + private final UnionChannelMerchantService unionChannelMerchantService; + private final UnionKeyConfigService unionKeyConfigService; @PermCode(code = PermCodes.Action.MANAGE) - @Operation(summary = "创建云闪付直连通道商户") + @Operation(summary = "创建云闪付通道商户") @PostMapping("/create") - public Result create(@RequestBody @Validated UnionDirectChannelMerchantCreateParam param) { - unionDirectChannelMerchantService.create(param); + public Result create(@RequestBody @Validated UnionChannelMerchantCreateParam param) { + unionChannelMerchantService.create(param); return Res.ok(); } @PermCode(code = PermCodes.Action.VIEW) @Operation(summary = "根据通道商户号查询证书配置") @GetMapping("/find-key-config") - public Result findKeyConfig( + public Result findKeyConfig( @NotBlank(message = "{validation.field.channelMerchantNo.notBlank}") String channelMchNo, @NotNull(message = "{validation.field.sandbox.notNull}") Boolean sandbox) { - var config = unionDirectKeyConfigService.findByChannelMchNo(channelMchNo, sandbox); + var config = unionKeyConfigService.findByChannelMchNo(channelMchNo, sandbox); var result = config.toResult(); result.setKeyPrivateCertConfigured(config.getKeyPrivateCert() != null); result.setKeyPrivateCertPwdConfigured(config.getKeyPrivateCertPwd() != null); @@ -60,8 +60,8 @@ public class UnionDirectChannelMerchantController { @PermCode(code = PermCodes.Action.MANAGE) @Operation(summary = "保存证书配置") @PostMapping("/save-key-config") - public Result saveKeyConfig(@RequestBody @Validated UnionDirectKeyConfigParam param) { - unionDirectKeyConfigService.save(param); + public Result saveKeyConfig(@RequestBody @Validated UnionKeyConfigParam param) { + unionKeyConfigService.save(param); return Res.ok(); } } diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/convert/UnionKeyConfigConvert.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/convert/UnionKeyConfigConvert.java new file mode 100644 index 000000000..53835c347 --- /dev/null +++ b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/convert/UnionKeyConfigConvert.java @@ -0,0 +1,19 @@ +package cn.daxpay.open.channel.union.convert; + +import cn.daxpay.open.channel.union.entity.UnionKeyConfig; +import cn.daxpay.open.channel.union.param.UnionKeyConfigParam; +import cn.daxpay.open.channel.union.result.UnionKeyConfigResult; +import org.mapstruct.Mapper; +import org.mapstruct.MappingTarget; +import org.mapstruct.NullValuePropertyMappingStrategy; +import org.mapstruct.factory.Mappers; + +/// # 云闪付密钥配置转换 +@Mapper(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE) +public interface UnionKeyConfigConvert { + UnionKeyConfigConvert CONVERT = Mappers.getMapper(UnionKeyConfigConvert.class); + + UnionKeyConfigResult toResult(UnionKeyConfig entity); + + void copy(UnionKeyConfigParam param, @MappingTarget UnionKeyConfig entity); +} diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/convert/direct/UnionDirectKeyConfigConvert.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/convert/direct/UnionDirectKeyConfigConvert.java deleted file mode 100644 index c03d1603e..000000000 --- a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/convert/direct/UnionDirectKeyConfigConvert.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.daxpay.open.channel.union.convert.direct; - -import cn.daxpay.open.channel.union.entity.direct.UnionDirectKeyConfig; -import cn.daxpay.open.channel.union.param.direct.UnionDirectKeyConfigParam; -import cn.daxpay.open.channel.union.result.direct.UnionDirectKeyConfigResult; -import org.mapstruct.Mapper; -import org.mapstruct.MappingTarget; -import org.mapstruct.NullValuePropertyMappingStrategy; -import org.mapstruct.factory.Mappers; - -/// # 云闪付直连密钥配置转换 -@Mapper(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE) -public interface UnionDirectKeyConfigConvert { - UnionDirectKeyConfigConvert CONVERT = Mappers.getMapper(UnionDirectKeyConfigConvert.class); - - UnionDirectKeyConfigResult toResult(UnionDirectKeyConfig entity); - - void copy(UnionDirectKeyConfigParam param, @MappingTarget UnionDirectKeyConfig entity); -} diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/dao/UnionKeyConfigManager.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/dao/UnionKeyConfigManager.java new file mode 100644 index 000000000..2679bb488 --- /dev/null +++ b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/dao/UnionKeyConfigManager.java @@ -0,0 +1,27 @@ +package cn.daxpay.open.channel.union.dao; + +import cn.daxpay.open.channel.union.entity.UnionKeyConfig; +import cn.daxpay.open.platform.common.mybatisplus.impl.BaseManager; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +/// # 云闪付密钥配置 +@Repository +public class UnionKeyConfigManager extends BaseManager { + + /// 根据通道商户号和沙箱标志查询(双环境并存) + public Optional findByChannelMchNoAndSandbox(String channelMchNo, boolean sandbox) { + return lambdaQuery() + .eq(UnionKeyConfig::getChannelMchNo, channelMchNo) + .eq(UnionKeyConfig::getSandbox, sandbox) + .oneOpt(); + } + + /// 根据通道商户号删除 + public void deleteByChannelMchNo(String channelMchNo) { + lambdaUpdate() + .eq(UnionKeyConfig::getChannelMchNo, channelMchNo) + .remove(); + } +} diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/dao/UnionKeyConfigMapper.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/dao/UnionKeyConfigMapper.java new file mode 100644 index 000000000..41bf81e1f --- /dev/null +++ b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/dao/UnionKeyConfigMapper.java @@ -0,0 +1,10 @@ +package cn.daxpay.open.channel.union.dao; + +import cn.daxpay.open.channel.union.entity.UnionKeyConfig; +import com.github.yulichang.base.MPJBaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/// # 云闪付密钥配置 +@Mapper +public interface UnionKeyConfigMapper extends MPJBaseMapper { +} diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/dao/direct/UnionDirectKeyConfigManager.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/dao/direct/UnionDirectKeyConfigManager.java deleted file mode 100644 index 601861cf0..000000000 --- a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/dao/direct/UnionDirectKeyConfigManager.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.daxpay.open.channel.union.dao.direct; - -import cn.daxpay.open.channel.union.entity.direct.UnionDirectKeyConfig; -import cn.daxpay.open.platform.common.mybatisplus.impl.BaseManager; -import org.springframework.stereotype.Repository; - -import java.util.Optional; - -/// # 云闪付直连密钥配置 -@Repository -public class UnionDirectKeyConfigManager extends BaseManager { - - /// 根据通道商户号和沙箱标志查询(双环境并存) - public Optional findByChannelMchNoAndSandbox(String channelMchNo, boolean sandbox) { - return lambdaQuery() - .eq(UnionDirectKeyConfig::getChannelMchNo, channelMchNo) - .eq(UnionDirectKeyConfig::getSandbox, sandbox) - .oneOpt(); - } - - /// 根据通道商户号删除 - public void deleteByChannelMchNo(String channelMchNo) { - lambdaUpdate() - .eq(UnionDirectKeyConfig::getChannelMchNo, channelMchNo) - .remove(); - } -} diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/dao/direct/UnionDirectKeyConfigMapper.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/dao/direct/UnionDirectKeyConfigMapper.java deleted file mode 100644 index 31e7abfed..000000000 --- a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/dao/direct/UnionDirectKeyConfigMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.daxpay.open.channel.union.dao.direct; - -import cn.daxpay.open.channel.union.entity.direct.UnionDirectKeyConfig; -import com.github.yulichang.base.MPJBaseMapper; -import org.apache.ibatis.annotations.Mapper; - -/// # 云闪付直连密钥配置 -@Mapper -public interface UnionDirectKeyConfigMapper extends MPJBaseMapper { -} diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/entity/direct/UnionDirectKeyConfig.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/entity/UnionKeyConfig.java similarity index 73% rename from daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/entity/direct/UnionDirectKeyConfig.java rename to daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/entity/UnionKeyConfig.java index b88733a62..db96aec94 100644 --- a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/entity/direct/UnionDirectKeyConfig.java +++ b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/entity/UnionKeyConfig.java @@ -1,7 +1,7 @@ -package cn.daxpay.open.channel.union.entity.direct; +package cn.daxpay.open.channel.union.entity; -import cn.daxpay.open.channel.union.convert.direct.UnionDirectKeyConfigConvert; -import cn.daxpay.open.channel.union.result.direct.UnionDirectKeyConfigResult; +import cn.daxpay.open.channel.union.convert.UnionKeyConfigConvert; +import cn.daxpay.open.channel.union.result.UnionKeyConfigResult; import cn.daxpay.open.payment.common.entity.MchBaseEntity; import cn.daxpay.open.platform.common.mybatisplus.function.ToResult; import cn.daxpay.open.platform.common.mybatisplus.handler.encrypt.DataEncryptTypeHandler; @@ -12,9 +12,9 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; -/// # 云闪付直连配置 +/// # 云闪付密钥配置 /// -/// 直连商户维度的通道配置, 含银联商户号(merId)与 RSA2 三证书, 敏感字段(私钥证书/密码)加密存储。 +/// 商户维度的通道配置, 含银联商户号(merId)与 RSA2 三证书, 敏感字段(私钥证书/密码)加密存储。 /// merId 创建时录入不可修改, 三证书由密钥配置维护。 /// /// 银联 ACP 签名依赖证书(区别于银联商务的 HmacSHA256 无证书模式): @@ -23,8 +23,8 @@ import lombok.experimental.Accessors; @EqualsAndHashCode(callSuper = true) @Data @Accessors(chain = true) -@TableName(value = "union_direct_key_config", autoResultMap = true) -public class UnionDirectKeyConfig extends MchBaseEntity implements ToResult { +@TableName(value = "union_key_config", autoResultMap = true) +public class UnionKeyConfig extends MchBaseEntity implements ToResult { /// 通道商户号 @TableField(updateStrategy = FieldStrategy.NEVER) @@ -58,7 +58,7 @@ public class UnionDirectKeyConfig extends MchBaseEntity implements ToResult new DataNotExistException("error.payment.channel.channelMerchantNotExist")); boolean sandbox = channelMerchant.isSandbox(); - // 2. 直连配置(银联商户号 merId + RSA2 三证书) - UnionDirectKeyConfig keyConfig = keyConfigService.findByChannelMchNo(channelMchNo, sandbox); + // 2. 密钥配置(银联商户号 merId + RSA2 三证书) + UnionKeyConfig keyConfig = keyConfigService.findByChannelMchNo(channelMchNo, sandbox); // 3. 组装凭证 var credential = new UnionSdkCredential(); credential.setMerId(keyConfig.getMerId()); diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/direct/UnionDirectKeyConfigService.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/UnionKeyConfigService.java similarity index 57% rename from daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/direct/UnionDirectKeyConfigService.java rename to daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/UnionKeyConfigService.java index c78ac29a8..84a26fe7e 100644 --- a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/direct/UnionDirectKeyConfigService.java +++ b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/UnionKeyConfigService.java @@ -1,35 +1,35 @@ -package cn.daxpay.open.channel.union.service.direct; +package cn.daxpay.open.channel.union.service; import cn.daxpay.open.channel.union.code.UnionCode; -import cn.daxpay.open.channel.union.convert.direct.UnionDirectKeyConfigConvert; -import cn.daxpay.open.channel.union.dao.direct.UnionDirectKeyConfigManager; -import cn.daxpay.open.channel.union.entity.direct.UnionDirectKeyConfig; -import cn.daxpay.open.channel.union.param.direct.UnionDirectKeyConfigParam; +import cn.daxpay.open.channel.union.convert.UnionKeyConfigConvert; +import cn.daxpay.open.channel.union.dao.UnionKeyConfigManager; +import cn.daxpay.open.channel.union.entity.UnionKeyConfig; +import cn.daxpay.open.channel.union.param.UnionKeyConfigParam; import cn.daxpay.open.payment.merchant.dao.channel.ChannelMerchantManager; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -/// # 云闪付直连密钥配置 +/// # 云闪付密钥配置 /// -/// 管理直连商户维度的银联证书配置, 查询时不存在则创建默认记录, 保存时合并证书字段。 +/// 管理商户维度的银联证书配置, 查询时不存在则创建默认记录, 保存时合并证书字段。 @Slf4j @Service @RequiredArgsConstructor -public class UnionDirectKeyConfigService { +public class UnionKeyConfigService { - private final UnionDirectKeyConfigManager unionDirectKeyConfigManager; + private final UnionKeyConfigManager unionKeyConfigManager; private final ChannelMerchantManager channelMerchantManager; /// 根据通道商户号查询密钥配置, 不存在则创建默认记录 @Transactional(rollbackFor = Exception.class) - public UnionDirectKeyConfig findByChannelMchNo(String channelMchNo, boolean sandbox) { - var existing = unionDirectKeyConfigManager.findByChannelMchNoAndSandbox(channelMchNo, sandbox); + public UnionKeyConfig findByChannelMchNo(String channelMchNo, boolean sandbox) { + var existing = unionKeyConfigManager.findByChannelMchNoAndSandbox(channelMchNo, sandbox); if (existing.isPresent()) { return existing.get(); } - var config = new UnionDirectKeyConfig() + var config = new UnionKeyConfig() .setChannelMchNo(channelMchNo) .setSignType(UnionCode.SIGN_TYPE_RSA2) .setCertSign(true) @@ -37,7 +37,7 @@ public class UnionDirectKeyConfigService { // 查询通用通道商户主表填充平台商户号(运营端写 MchBaseEntity 必须显式 mchNo) channelMerchantManager.findByChannelMchNo(channelMchNo) .ifPresent(mch -> config.setMchNo(mch.getMchNo())); - unionDirectKeyConfigManager.save(config); + unionKeyConfigManager.save(config); return config; } @@ -46,14 +46,15 @@ public class UnionDirectKeyConfigService { /// 以 channelMchNo 定位记录, 仅更新证书字段; /// mchNo/merId 为不可变身份字段(实体 FieldStrategy.NEVER), 由 findByChannelMchNo 从 DB 加载后保持不变。 @Transactional(rollbackFor = Exception.class) - public void save(UnionDirectKeyConfigParam param) { + public void save(UnionKeyConfigParam param) { var config = this.findByChannelMchNo(param.getChannelMchNo(), Boolean.TRUE.equals(param.getSandbox())); - UnionDirectKeyConfigConvert.CONVERT.copy(param, config); - unionDirectKeyConfigManager.updateById(config); + UnionKeyConfigConvert.CONVERT.copy(param, config); + unionKeyConfigManager.updateById(config); } /// 根据通道商户号删除密钥配置 public void deleteByChannelMchNo(String channelMchNo) { - unionDirectKeyConfigManager.deleteByChannelMchNo(channelMchNo); + unionKeyConfigManager.deleteByChannelMchNo(channelMchNo); } } + diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/callback/UnionPayCallbackService.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/callback/UnionPayCallbackService.java index cec7649f4..abedf8284 100644 --- a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/callback/UnionPayCallbackService.java +++ b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/callback/UnionPayCallbackService.java @@ -5,7 +5,7 @@ import cn.daxpay.open.channel.union.client.credential.UnionSdkCredential; import cn.daxpay.open.channel.union.client.req.UnionCallbackParseReq; import cn.daxpay.open.channel.union.client.resp.UnionCallbackParseResp; import cn.daxpay.open.channel.union.code.UnionCode; -import cn.daxpay.open.channel.union.service.direct.UnionDirectConfigAssembler; +import cn.daxpay.open.channel.union.service.UnionConfigAssembler; import cn.daxpay.open.channel.union.util.UnionDateUtil; import cn.daxpay.open.payment.common.result.DaxResult; import cn.daxpay.open.payment.trade.record.service.PayCallbackRecordService; @@ -34,7 +34,7 @@ import java.util.Map; public class UnionPayCallbackService { private final UnionChannelClient unionChannelClient; - private final UnionDirectConfigAssembler configAssembler; + private final UnionConfigAssembler configAssembler; private final PayCallbackService payCallbackService; private final PayCallbackRecordService payCallbackRecordService; diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/callback/UnionRefundCallbackService.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/callback/UnionRefundCallbackService.java index 5587417e1..b2851da1f 100644 --- a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/callback/UnionRefundCallbackService.java +++ b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/service/callback/UnionRefundCallbackService.java @@ -5,7 +5,7 @@ import cn.daxpay.open.channel.union.client.credential.UnionSdkCredential; import cn.daxpay.open.channel.union.client.req.UnionCallbackParseReq; import cn.daxpay.open.channel.union.client.resp.UnionCallbackParseResp; import cn.daxpay.open.channel.union.code.UnionCode; -import cn.daxpay.open.channel.union.service.direct.UnionDirectConfigAssembler; +import cn.daxpay.open.channel.union.service.UnionConfigAssembler; import cn.daxpay.open.payment.common.result.DaxResult; import cn.daxpay.open.payment.trade.record.service.PayCallbackRecordService; import cn.daxpay.open.payment.trade.runtime.bo.RefundCallbackData; @@ -31,7 +31,7 @@ import java.util.Objects; public class UnionRefundCallbackService { private final UnionChannelClient unionChannelClient; - private final UnionDirectConfigAssembler configAssembler; + private final UnionConfigAssembler configAssembler; private final RefundCallbackService refundCallbackService; private final PayCallbackRecordService payCallbackRecordService; diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/pay/UnionPayCloseStrategy.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/pay/UnionPayCloseStrategy.java index 87efbd42f..a9c16a48e 100644 --- a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/pay/UnionPayCloseStrategy.java +++ b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/pay/UnionPayCloseStrategy.java @@ -2,7 +2,7 @@ package cn.daxpay.open.channel.union.strategy.pay; import cn.daxpay.open.channel.union.client.credential.UnionSdkCredential; import cn.daxpay.open.channel.union.client.enums.UnionPayMethod; -import cn.daxpay.open.channel.union.service.direct.UnionDirectConfigAssembler; +import cn.daxpay.open.channel.union.service.UnionConfigAssembler; import cn.daxpay.open.channel.union.service.payment.close.UnionCloseService; import cn.daxpay.open.channel.union.strategy.UnionStrategySupport; import cn.daxpay.open.platform.core.enums.pay.channel.ProductEnum; @@ -23,12 +23,12 @@ import org.springframework.stereotype.Service; public class UnionPayCloseStrategy extends AbsPayCloseStrategy { private final UnionCloseService unionCloseService; - private final UnionDirectConfigAssembler unionDirectConfigAssembler; + private final UnionConfigAssembler unionConfigAssembler; @Override public CloseTypeEnum doClose(PayStrategyContext context, boolean useCancel) { PayTrade trade = context.getTrade(); - UnionSdkCredential credential = unionDirectConfigAssembler.buildConfig( + UnionSdkCredential credential = unionConfigAssembler.buildConfig( trade.getMchNo(), context.getChannelMchNo(), context.getCapability()); UnionPayMethod method = UnionStrategySupport.resolveMethod(context.getCapability()); return unionCloseService.close(trade, credential, useCancel, method); diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/pay/UnionPayPayStrategy.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/pay/UnionPayPayStrategy.java index 9cc06e18a..f5f587a8e 100644 --- a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/pay/UnionPayPayStrategy.java +++ b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/pay/UnionPayPayStrategy.java @@ -1,7 +1,7 @@ package cn.daxpay.open.channel.union.strategy.pay; import cn.daxpay.open.channel.union.client.credential.UnionSdkCredential; -import cn.daxpay.open.channel.union.service.direct.UnionDirectConfigAssembler; +import cn.daxpay.open.channel.union.service.UnionConfigAssembler; import cn.daxpay.open.channel.union.service.payment.pay.UnionPayService; import cn.daxpay.open.platform.core.enums.pay.channel.ProductEnum; import cn.daxpay.open.payment.strategy.pay.AbsNormalPayStrategy; @@ -22,13 +22,13 @@ import org.springframework.stereotype.Service; public class UnionPayPayStrategy extends AbsNormalPayStrategy { private final UnionPayService unionPayService; - private final UnionDirectConfigAssembler unionDirectConfigAssembler; + private final UnionConfigAssembler unionConfigAssembler; /// 支付前预处理: 组装通道凭证写入上下文 @Override public void doBeforePay(PayStrategyContext context) { NormalPayParam payParam = context.getPayParam(); - UnionSdkCredential credential = unionDirectConfigAssembler.buildConfig( + UnionSdkCredential credential = unionConfigAssembler.buildConfig( payParam.getMchNo(), payParam.getChannelMchNo(), payParam.getCapability()); context.setChannelConfig(credential); } diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/product/UnionPayProductStrategy.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/product/UnionPayProductStrategy.java index 70bbfe187..e93c79147 100644 --- a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/product/UnionPayProductStrategy.java +++ b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/product/UnionPayProductStrategy.java @@ -14,7 +14,7 @@ import java.util.Map; /// # 云闪付产品策略 /// -/// 云闪付为单一产品(直连银联 ACP), 含主扫([PayMethodEnum#UNION_QR]) / H5([PayMethodEnum#UNION_H5]) +/// 云闪付为单一产品(银联 ACP), 含主扫([PayMethodEnum#UNION_QR]) / H5([PayMethodEnum#UNION_H5]) /// / 被扫([PayMethodEnum#UNION_BARCODE]) 三种支付方式, 方式→能力一对一同码。 @Slf4j @Service diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/refund/UnionPayRefundStrategy.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/refund/UnionPayRefundStrategy.java index fcff238f5..2f62ca485 100644 --- a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/refund/UnionPayRefundStrategy.java +++ b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/refund/UnionPayRefundStrategy.java @@ -2,7 +2,7 @@ package cn.daxpay.open.channel.union.strategy.refund; import cn.daxpay.open.channel.union.client.credential.UnionSdkCredential; import cn.daxpay.open.channel.union.client.enums.UnionPayMethod; -import cn.daxpay.open.channel.union.service.direct.UnionDirectConfigAssembler; +import cn.daxpay.open.channel.union.service.UnionConfigAssembler; import cn.daxpay.open.channel.union.service.payment.refund.UnionRefundService; import cn.daxpay.open.channel.union.strategy.UnionStrategySupport; import cn.daxpay.open.platform.core.enums.pay.channel.ProductEnum; @@ -22,11 +22,11 @@ import org.springframework.stereotype.Service; public class UnionPayRefundStrategy extends AbsRefundStrategy { private final UnionRefundService unionRefundService; - private final UnionDirectConfigAssembler unionDirectConfigAssembler; + private final UnionConfigAssembler unionConfigAssembler; @Override public RefundResultBo doRefund(RefundOrder refundOrder) { - UnionSdkCredential credential = unionDirectConfigAssembler.buildConfig( + UnionSdkCredential credential = unionConfigAssembler.buildConfig( refundOrder.getMchNo(), refundOrder.getChannelMchNo(), refundOrder.getCapability()); UnionPayMethod method = UnionStrategySupport.resolveMethod(refundOrder.getCapability()); return unionRefundService.refund(refundOrder, credential, method); diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/refund/UnionPaySyncRefundStrategy.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/refund/UnionPaySyncRefundStrategy.java index 26631f2e4..2ab38b993 100644 --- a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/refund/UnionPaySyncRefundStrategy.java +++ b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/refund/UnionPaySyncRefundStrategy.java @@ -2,7 +2,7 @@ package cn.daxpay.open.channel.union.strategy.refund; import cn.daxpay.open.channel.union.client.credential.UnionSdkCredential; import cn.daxpay.open.channel.union.client.enums.UnionPayMethod; -import cn.daxpay.open.channel.union.service.direct.UnionDirectConfigAssembler; +import cn.daxpay.open.channel.union.service.UnionConfigAssembler; import cn.daxpay.open.channel.union.service.payment.refund.UnionRefundSyncService; import cn.daxpay.open.channel.union.strategy.UnionStrategySupport; import cn.daxpay.open.platform.core.enums.pay.channel.ProductEnum; @@ -22,11 +22,11 @@ import org.springframework.stereotype.Service; public class UnionPaySyncRefundStrategy extends AbsSyncRefundStrategy { private final UnionRefundSyncService unionRefundSyncService; - private final UnionDirectConfigAssembler unionDirectConfigAssembler; + private final UnionConfigAssembler unionConfigAssembler; @Override public RefundResultBo doSync(RefundOrder refundOrder) { - UnionSdkCredential credential = unionDirectConfigAssembler.buildConfig( + UnionSdkCredential credential = unionConfigAssembler.buildConfig( refundOrder.getMchNo(), refundOrder.getChannelMchNo(), refundOrder.getCapability()); UnionPayMethod method = UnionStrategySupport.resolveMethod(refundOrder.getCapability()); return unionRefundSyncService.sync(refundOrder, credential, method); diff --git a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/sync/UnionPaySyncStrategy.java b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/sync/UnionPaySyncStrategy.java index ecb5e243b..21336a8d0 100644 --- a/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/sync/UnionPaySyncStrategy.java +++ b/daxpay-channel/daxpay-channel-union/src/main/java/cn/daxpay/open/channel/union/strategy/sync/UnionPaySyncStrategy.java @@ -2,7 +2,7 @@ package cn.daxpay.open.channel.union.strategy.sync; import cn.daxpay.open.channel.union.client.credential.UnionSdkCredential; import cn.daxpay.open.channel.union.client.enums.UnionPayMethod; -import cn.daxpay.open.channel.union.service.direct.UnionDirectConfigAssembler; +import cn.daxpay.open.channel.union.service.UnionConfigAssembler; import cn.daxpay.open.channel.union.service.payment.sync.UnionSyncService; import cn.daxpay.open.channel.union.strategy.UnionStrategySupport; import cn.daxpay.open.platform.core.enums.pay.channel.ProductEnum; @@ -22,11 +22,11 @@ import org.springframework.stereotype.Service; public class UnionPaySyncStrategy extends AbsSyncPayOrderStrategy { private final UnionSyncService unionSyncService; - private final UnionDirectConfigAssembler unionDirectConfigAssembler; + private final UnionConfigAssembler unionConfigAssembler; @Override public PaySyncResultBo doSync(PayStrategyContext context) { - UnionSdkCredential credential = unionDirectConfigAssembler.buildConfig( + UnionSdkCredential credential = unionConfigAssembler.buildConfig( context.getTrade().getMchNo(), context.getChannelMchNo(), context.getCapability()); UnionPayMethod method = UnionStrategySupport.resolveMethod(context.getCapability()); return unionSyncService.sync(context.getTrade(), credential, method);