Skip to content

修复商家转账电子回单接口至微信支付新版 fund-app 路径并兼容新字段#3994

Merged
binarywang merged 4 commits into
developfrom
copilot/fix-merchant-transfer-receipt-api
May 11, 2026
Merged

修复商家转账电子回单接口至微信支付新版 fund-app 路径并兼容新字段#3994
binarywang merged 4 commits into
developfrom
copilot/fix-merchant-transfer-receipt-api

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 11, 2026

当前“商家转账-申请/获取电子回单”仍走旧版 v3/transfer/bill-receipt,与微信支付新版文档不一致。该改动将相关实现切换到新版 v3/fund-app/mch-transfer/elecsign/*,并同步处理新旧字段命名兼容。

  • 问题背景(简述)

    • 电子回单申请/查询接口使用旧路径,导致与微信支付新版商家转账接口体系不一致。
    • issue 中也要求给出对应新版官方文档地址并对齐实现。
  • 接口路径切换(核心变更)

    • MerchantTransferServiceImpl
      • applyElectronicBillPOST /v3/fund-app/mch-transfer/elecsign/out-bill-no
      • queryElectronicBillGET /v3/fund-app/mch-transfer/elecsign/out-bill-no/{out_bill_no}
    • PartnerTransferServiceImpl
      • receiptBillPOST /v3/fund-app/mch-transfer/elecsign/out-bill-no
      • queryBillReceiptGET /v3/fund-app/mch-transfer/elecsign/out-bill-no/{out_bill_no}
  • 请求/响应字段兼容

    • 请求对象支持新版字段:
      • out_bill_no(兼容旧 out_batch_no
    • 响应对象支持新版字段:
      • state(兼容旧 signature_status
    • 涉及对象:
      • ElectronicBillApplyRequest
      • ReceiptBillRequest
      • ElectronicBillResult
      • BillReceiptResult
  • 接口契约与注释同步

    • MerchantTransferServicePartnerTransferService 更新为新版文档与 URL 注释。
    • 查询方法参数统一为 outBillNo,减少语义歧义。
  • 示例(路径与字段)

// 申请电子回单(新版)
String url = String.format("%s/v3/fund-app/mch-transfer/elecsign/out-bill-no", payBaseUrl);

// 查询电子回单(新版)
String url = String.format("%s/v3/fund-app/mch-transfer/elecsign/out-bill-no/%s", payBaseUrl, outBillNo);

// 请求字段映射(兼容新旧)
@SerializedName(value = "out_bill_no", alternate = {"out_batch_no"})
private String outBatchNo;

// 响应字段映射(兼容新旧)
@SerializedName(value = "state", alternate = {"signature_status"})
private String signatureStatus;
  • 对应官方文档
    • 商户单号申请电子回单:https://pay.weixin.qq.com/doc/v3/merchant/4012716452
    • 商户单号查询电子回单:https://pay.weixin.qq.com/doc/v3/merchant/4012716436
    • 微信单号查询电子回单:https://pay.weixin.qq.com/doc/v3/merchant/4012716455

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • wx.gtimg.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI and others added 2 commits May 11, 2026 02:36
Copilot AI changed the title [WIP] Fix merchant transfer electronic receipt API to use latest version 修复商家转账电子回单接口至微信支付新版 fund-app 路径并兼容新字段 May 11, 2026
Copilot AI requested a review from binarywang May 11, 2026 02:40
@binarywang binarywang marked this pull request as ready for review May 11, 2026 02:44
Copilot AI review requested due to automatic review settings May 11, 2026 02:44
Copy link
Copy Markdown

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

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: 06dc88f1db

ℹ️ 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".

@Override
public ElectronicBillResult applyElectronicBill(ElectronicBillApplyRequest request) throws WxPayException {
String url = String.format("%s/v3/transfer/bill-receipt", this.wxPayService.getPayBaseUrl());
String url = String.format("%s/v3/fund-app/mch-transfer/elecsign/out-bill-no", this.wxPayService.getPayBaseUrl());
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 Preserve batch-transfer receipt endpoint

When this service is used for the existing batch-transfer APIs, applyElectronicBill still receives an outBatchNo from ElectronicBillApplyRequest, but this line now sends it to the new single-transfer out_bill_no endpoint. The current WeChat docs keep batch receipt applications on /v3/transfer/bill-receipt with out_batch_no (https://pay.wechatpay.cn/doc/v3/merchant/4012458946), while the new endpoint is for ordinary-merchant user-confirm transfer bills and requires a transfer bill number (https://pay.wechatpay.cn/doc/v3/merchant/4012716452). Existing callers applying/querying receipts for batch transfers will therefore get parameter/not-found errors instead of their batch receipt.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

该 PR 对齐微信支付新版「商家转账-电子回单」接口规范:将直连商户/服务商的电子回单申请与查询接口从旧版 v3/transfer/bill-receipt 切换到新版 v3/fund-app/mch-transfer/elecsign/out-bill-no/*,并通过 Gson @SerializedName(alternate=...) 兼容新旧字段命名(out_bill_no/out_batch_nostate/signature_status),同时补充了兼容性测试来验证路径与字段映射。

Changes:

  • 将电子回单申请/查询接口请求路径切换到新版 fund-app 路径(直连商户与服务商实现)。
  • 请求/响应对象增加新旧字段名兼容反序列化/序列化映射。
  • 新增测试验证:请求 URL 是否为新版路径、请求体是否使用 out_bill_no、结果对象是否可反序列化 state/out_bill_no

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/TransferReceiptApiCompatibilityTest.java 新增兼容性测试,断言新版路径与新字段反序列化行为
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/PartnerTransferService.java 更新服务商电子回单接口文档链接/URL 注释与参数语义
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/MerchantTransferService.java 更新直连商户电子回单接口文档链接/URL 注释与参数语义
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/PartnerTransferServiceImpl.java 服务商侧电子回单申请/查询改用新版 fund-app 路径
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImpl.java 直连商户侧电子回单申请/查询改用新版 fund-app 路径
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/ElectronicBillResult.java 响应对象兼容 out_bill_no/out_batch_nostate/signature_status
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/merchanttransfer/ElectronicBillApplyRequest.java 请求对象兼容 out_bill_no/out_batch_no
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/ReceiptBillRequest.java 请求对象兼容 out_bill_no/out_batch_no
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/marketing/transfer/BillReceiptResult.java 响应对象兼容 out_bill_no/out_batch_nostate/signature_status

@Override
public BillReceiptResult receiptBill(ReceiptBillRequest request) throws WxPayException {
String url = String.format("%s/v3/transfer/bill-receipt", this.payService.getPayBaseUrl());
String url = String.format("%s/v3/fund-app/mch-transfer/elecsign/out-bill-no", this.payService.getPayBaseUrl());
* 请求URL:https://api.mch.weixin.qq.com/v3/fund-app/mch-transfer/elecsign/out-bill-no
* 请求方式:POST
*
* @param request 商家批次单号
Comment on lines +101 to 103
public ElectronicBillResult queryElectronicBill(String outBillNo) throws WxPayException {
String url = String.format("%s/v3/fund-app/mch-transfer/elecsign/out-bill-no/%s", this.wxPayService.getPayBaseUrl(), outBillNo);
String response = wxPayService.getV3(url);
public BillReceiptResult queryBillReceipt(String outBatchNo) throws WxPayException {
String url = String.format("%s/v3/transfer/bill-receipt/%s", this.payService.getPayBaseUrl(), outBatchNo);
public BillReceiptResult queryBillReceipt(String outBillNo) throws WxPayException {
String url = String.format("%s/v3/fund-app/mch-transfer/elecsign/out-bill-no/%s", this.payService.getPayBaseUrl(), outBillNo);
Comment on lines +36 to 37
@SerializedName(value = "out_bill_no", alternate = {"out_batch_no"})
private String outBatchNo;
Comment on lines +66 to 67
@SerializedName(value = "state", alternate = {"signature_status"})
private String signatureStatus;
Comment on lines +41 to 42
@SerializedName(value = "out_bill_no", alternate = {"out_batch_no"})
private String outBatchNo;
Comment on lines +71 to 72
@SerializedName(value = "state", alternate = {"signature_status"})
private String signatureStatus;
Comment on lines 33 to 37
* 示例值:plfk2020042013
* </pre>
*/
@SerializedName("out_batch_no")
@SerializedName(value = "out_bill_no", alternate = {"out_batch_no"})
private String outBatchNo;
Comment on lines 31 to 34
* </pre>
*/
@SerializedName(value = "out_batch_no")
@SerializedName(value = "out_bill_no", alternate = {"out_batch_no"})
private String outBatchNo;
@binarywang
Copy link
Copy Markdown
Owner

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 11, 2026

@copilot apply changes based on the comments in this thread

已按该评审线程逐条完成修改并推送,涵盖文档链接/参数说明一致性、字段注释同步以及超长行修复。对应提交:fc60838。

@binarywang binarywang merged commit 4034834 into develop May 11, 2026
1 check passed
@binarywang binarywang deleted the copilot/fix-merchant-transfer-receipt-api branch May 11, 2026 05:30
@binarywang binarywang modified the milestone: 4.8.3 May 11, 2026
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.

商家转账 - 申请、获取电子回单接口

3 participants