Skip to content

feat(pay): 支持连锁品牌入驻、门店管理和分账 - #4139

Open
binarywang wants to merge 1 commit into
developfrom
feat/3972-chain-brand
Open

binarywang wants to merge 1 commit into
developfrom
feat/3972-chain-brand

Conversation

@binarywang

Copy link
Copy Markdown
Owner

WxJava 尚未封装服务商模式下的连锁品牌接口。此 PR 增加品牌入驻(4 项)、门店管理(6 项)和连锁品牌分账(9 项)三个独立服务,支持分账通知验签与解密,并通过 WxPayService 提供入口。

敏感字段自动加密且不修改调用方请求,允许使用同一对象重试。门店删除保留官方要求的 JSON 请求体;保持 Java 8 兼容,无新增依赖,原普通分账和品牌红包行为保持不变。附带调用文档。

验证:新增及相关回归测试共 53 项通过,零失败、零跳过;git diff --check 通过;独立代码审查通过。测试覆盖 HTTP 方法/路径、字段映射、RSA 加密、AES-GCM 通知解密及签名拒绝。真实微信接口联调尚未执行,需要已开通品牌权限的服务商账号。

测试命令:

mvn -pl weixin-java-pay -am -Dmaven.test.skip=false -DskipTests=false -Dtest=BrandApplymentServiceTest,BrandStoreServiceTest,BrandProfitSharingServiceTest,BrandServiceEntryTest,PartnerInvoiceServiceImplTest,TransferAuthorizationApiCompatibilityTest,TransferUserAuthorizationApiCompatibilityTest,TransferReceiptApiCompatibilityTest -Dsurefire.failIfNoSpecifiedTests=false test

Closes #3972

Copilot AI balanced review requested due to automatic review settings October 13, 2026 08:56

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6512b7184e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +136 to +143
@Getter
private final BrandApplymentService brandApplymentService = new BrandApplymentServiceImpl(this);

@Getter
private final BrandStoreService brandStoreService = new BrandStoreServiceImpl(this);

@Getter
private final BrandProfitSharingService brandProfitSharingService = new BrandProfitSharingServiceImpl(this);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 为 Jodd 客户端补齐品牌服务的 V3 请求能力

当调用方使用 WxPayServiceJoddHttpImpl 时,这三个新增服务虽然都会被创建并由兼容性测试判定可用,但其依赖的 postV3、patchV3、postV3WithWechatpaySerial、requestV3 和 getV3 在该客户端中仍直接返回 null;因此查询和创建操作不会发出请求而只返回 null,门店删除甚至会无请求地正常返回,导致调用方误以为删除成功。请补齐 Jodd 的 V3 执行能力,或至少明确拒绝该客户端而不是暴露一个静默失效的服务。

AGENTS.md reference: AGENTS.md:L55-L56

Useful? React with 👍 / 👎.

import org.testng.annotations.Test;

/** 连锁品牌服务入口兼容性测试。 */
public class BrandServiceEntryTest {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 将新增测试加入默认 TestNG 套件

weixin-java-pay/pom.xml 通过 suiteXmlFiles 固定运行 src/test/resources/testng.xml,但本次新增的四个测试类均未登记到该文件,因此常规的 mvn -pl weixin-java-pay -am test 不会执行它们;提交说明中的 -Dtest=... 能运行是因为该参数会覆盖 suiteXmlFiles,这也符合 Maven Surefire 参数文档 的说明。请把这些类加入套件,否则后续回归(包括上述 Jodd 静默失效)无法由默认 CI 发现。

AGENTS.md reference: AGENTS.md:L63-L64

Useful? React with 👍 / 👎.

查询品牌入驻申请:

```java
BrandApplymentQueryResult application = applyments.queryApplymentByBusinessCode("brand-application-001");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 在入驻示例中使用合法的 business_code

这里的示例值包含连字符,但 queryApplymentByBusinessCode 的 Javadoc 及微信支付的官方接口契约都规定 business_code 只能由数字、字母或下划线组成;用户直接照抄文档会得到 PARAM_ERROR。请改为例如 brand_application_001 的合法值。

AGENTS.md reference: AGENTS.md:L53-L54

Useful? React with 👍 / 👎.


@Override
public BrandProfitSharingReceiverResult addReceiver(BrandProfitSharingReceiverRequest request) throws WxPayException {
return GSON.fromJson(this.payService.postV3(url("/receivers/add"), GSON.toJson(request)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 避免把分账接收方姓名和 OpenID 写入日志

当 type 为 PERSONAL_OPENID 或 PERSONAL_SUB_OPENID 时,这里的 JSON 包含明文 name 和可识别用户的 account,而两个实际可用的 Apache 客户端都会在 postV3 成功和异常路径中以 INFO/ERROR 记录完整的 requestStr;每次添加个人接收方都会因此把姓名和 OpenID 持久化到应用日志。请在进入通用日志链路前对这些字段脱敏,或提供不会记录敏感请求体的发送路径,同时保持实际签名和请求体不变。

AGENTS.md reference: AGENTS.md:L58-L59

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T09:03:14.114952Z 6512b71 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@augmentcode

augmentcode Bot commented Oct 13, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

摘要:补齐微信支付服务商模式下的连锁品牌接口,覆盖品牌入驻、门店管理和分账。

  • 新增三个独立服务,与普通分账及品牌红包转账区分。
  • 品牌入驻支持提交、撤销及按两类申请编号查询。
  • 门店管理支持创建、查询、更新、删除以及绑定、解绑收款商户号。
  • 品牌分账支持请求、查询、回退、完结及接收方管理等九项操作。
  • 新增对应请求、响应模型和微信字段映射。
  • 通过 WxPayService 提供入口,并在基础实现中缓存服务实例。
  • 发送前复制请求并加密敏感字段,保留调用方明文以支持重试。
  • 复用现有分账通知验签与 AES-GCM 解密逻辑,并拒绝空签名头。
  • 门店删除使用携带 JSON 请求体的 DELETE 请求;未新增依赖。
  • 添加离线契约、加密、通知及服务入口测试,并补充调用文档。
    审查结论:静态审查及官方接口文档核对未发现实质性缺陷;本次未执行测试或真实接口联调。

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

Copilot stopped reviewing on behalf of binarywang due to an error October 13, 2026 09:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Copilot was unable to run its full agentic suite in this review.

Copilot review overview

1 open finding
What changed in this PR

Adds offline contract coverage and production implementations for WeChat Pay “chain brand” capabilities (brand applyment, brand store management, and chain-brand profit sharing), plus documentation and service entrypoints.

Changes:

  • Introduces new BrandApplymentService, BrandStoreService, and BrandProfitSharingService APIs with corresponding impls and request/response beans.
  • Wires the new services into WxPayService (default methods) and BaseWxPayServiceImpl (cached getters).
  • Adds TestNG offline contract tests and a usage guide doc.
File Description
weixin-java-pay/​src/​test/​java/​com/​github/​binarywang/​wxpay/​service/​impl/​BrandStoreServiceTest.java Adds offline contract tests for brand store CRUD + recipient binding/unbinding.
weixin-java-pay/​src/​test/​java/​com/​github/​binarywang/​wxpay/​service/​impl/​BrandServiceEntryTest.java Verifies service entrypoints are exposed across supported WxPayService implementations.
weixin-java-pay/​src/​test/​java/​com/​github/​binarywang/​wxpay/​service/​impl/​BrandProfitSharingServiceTest.java Adds offline contract tests for chain-brand profit sharing routes, encryption, and notify parsing.
weixin-java-pay/​src/​test/​java/​com/​github/​binarywang/​wxpay/​service/​BrandApplymentServiceTest.java Adds offline contract tests for brand applyment encryption, routing, and error propagation.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​service/​impl/​BrandStoreServiceImpl.java Implements brand store API calls, including DELETE-with-body support.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​service/​impl/​BrandProfitSharingServiceImpl.java Implements chain-brand profit sharing APIs, including field encryption and notify parsing delegation.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​service/​impl/​BrandApplymentServiceImpl.java Implements brand applyment APIs, including request encryption without mutating caller objects.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​service/​impl/​BaseWxPayServiceImpl.java Adds cached getters for the new brand services.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​service/​WxPayService.java Adds default interface methods to access the new brand services for compatibility.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​service/​BrandStoreService.java Declares brand store service API.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​service/​BrandProfitSharingService.java Declares chain-brand profit sharing service API.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​service/​BrandApplymentService.java Declares brand applyment service API.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandstore/​BrandStoreUnbindRecipientResult.java Adds unbind-recipient response model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandstore/​BrandStoreUnbindRecipientRequest.java Adds unbind-recipient request model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandstore/​BrandStoreResult.java Adds store create/query/update response model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandstore/​BrandStoreRequest.java Adds store create/update request model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandstore/​BrandStoreRecipient.java Adds bound-recipient model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandstore/​BrandStoreBusiness.java Adds store business info model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandstore/​BrandStoreBindRecipientResult.java Adds bind-recipient response model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandstore/​BrandStoreBindRecipientRequest.java Adds bind-recipient request model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandstore/​BrandStoreBasics.java Adds store basics model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandstore/​BrandStoreAddress.java Adds store address model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandprofitsharing/​BrandProfitSharingReturnResult.java Adds profit sharing return response model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandprofitsharing/​BrandProfitSharingReturnRequest.java Adds profit sharing return request model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandprofitsharing/​BrandProfitSharingReturnQueryRequest.java Adds profit sharing return query request model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandprofitsharing/​BrandProfitSharingResult.java Adds profit sharing query/result model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandprofitsharing/​BrandProfitSharingRequest.java Adds profit sharing create request model with encrypted fields.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandprofitsharing/​BrandProfitSharingReceiverResult.java Adds receiver add/delete result model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandprofitsharing/​BrandProfitSharingReceiverRequest.java Adds receiver add request model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandprofitsharing/​BrandProfitSharingReceiverDeleteRequest.java Adds receiver delete request model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandprofitsharing/​BrandProfitSharingRatioResult.java Adds max ratio response model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandprofitsharing/​BrandProfitSharingQueryRequest.java Adds profit sharing query request model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandprofitsharing/​BrandProfitSharingFinishResult.java Adds finish response model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandprofitsharing/​BrandProfitSharingFinishRequest.java Adds finish request model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandprofitsharing/​BrandProfitSharingAmountResult.java Adds remaining-amount response model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandapplyment/​BrandApplymentResult.java Adds brand applyment create/cancel response model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandapplyment/​BrandApplymentRequest.java Adds brand applyment request model with encrypted fields.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandapplyment/​BrandApplymentQueryResult.java Adds brand applyment status response model.
weixin-java-pay/​src/​main/​java/​com/​github/​binarywang/​wxpay/​bean/​brandapplyment/​BrandApplymentCancelRequest.java Adds brand applyment cancel request model.
docs/​WECHAT_PAY_CHAIN_BRAND_USAGE.md Adds end-user documentation for accessing and using the new services.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

/**
* 根据业务申请编号查询申请状态。
*
* @param businessCode 服务商自定义的业务申请编号,仅包含数字、字母或下划线
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

微信支付功能增加对支付品牌的支持

2 participants