Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,58 @@ public class WxPayCodepayRequest implements Serializable {
*/
@SerializedName(value = "mchid")
protected String mchid;
/**
* <pre>
* 字段名:服务商应用ID
* 变量名:sp_appid
* 是否必填:否
* 类型:string[1,32]
* 描述:
* 服务商模式下使用,由微信生成的应用ID,全局唯一。
* 示例值:wxd678efh567hg6787
* </pre>
*/
@SerializedName(value = "sp_appid")
protected String spAppid;
/**
* <pre>
* 字段名:服务商商户号
* 变量名:sp_mchid
* 是否必填:否
* 类型:string[1,32]
* 描述:
* 服务商模式下使用,服务商商户号,由微信支付生成并下发。
* 示例值:1230000109
* </pre>
*/
@SerializedName(value = "sp_mchid")
protected String spMchid;
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

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

字段命名与现有的服务商请求类不一致。在 WxPayPartnerUnifiedOrderV3Request 中,对应字段命名为 spMchId(Id 的 'I' 大写),而此处使用 spMchid(全小写)。为保持代码库的一致性,建议将字段名改为 spMchId 以匹配现有模式。

Suggested change
protected String spMchid;
protected String spMchId;

Copilot uses AI. Check for mistakes.
/**
* <pre>
* 字段名:子商户应用ID
* 变量名:sub_appid
* 是否必填:否
* 类型:string[1,32]
* 描述:
* 服务商模式下使用,由微信生成的应用ID,全局唯一。
* 示例值:wxd678efh567hg6787
* </pre>
*/
@SerializedName(value = "sub_appid")
protected String subAppid;
/**
* <pre>
* 字段名:子商户商户号
* 变量名:sub_mchid
* 是否必填:否
* 类型:string[1,32]
* 描述:
* 服务商模式下使用,子商户商户号,由微信支付生成并下发。
* 示例值:1230000109
* </pre>
*/
@SerializedName(value = "sub_mchid")
protected String subMchid;
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

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

字段命名与现有的服务商请求类不一致。在 WxPayPartnerUnifiedOrderV3Request 中,对应字段命名为 subMchId(Id 的 'I' 大写),而此处使用 subMchid(全小写)。为保持代码库的一致性,建议将字段名改为 subMchId 以匹配现有模式。

Suggested change
protected String subMchid;
protected String subMchId;

Copilot uses AI. Check for mistakes.
/**
* <pre>
* 字段名:商品描述
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1146,15 +1146,40 @@ public WxPayMicropayResult micropay(WxPayMicropayRequest request) throws WxPayEx

@Override
public WxPayCodepayResult codepay(WxPayCodepayRequest request) throws WxPayException {
if (StringUtils.isBlank(request.getAppid())) {
request.setAppid(this.getConfig().getAppId());
}
if (StringUtils.isBlank(request.getMchid())) {
request.setMchid(this.getConfig().getMchId());
// 判断是否为服务商模式:如果设置了sp_appid或sp_mchid或sub_mchid中的任何一个,则认为是服务商模式
boolean isPartnerMode = StringUtils.isNotBlank(request.getSpAppid())
|| StringUtils.isNotBlank(request.getSpMchid())
|| StringUtils.isNotBlank(request.getSubMchid());

if (isPartnerMode) {
// 服务商模式
if (StringUtils.isBlank(request.getSpAppid())) {
request.setSpAppid(this.getConfig().getAppId());
}
if (StringUtils.isBlank(request.getSpMchid())) {
request.setSpMchid(this.getConfig().getMchId());
}
Comment on lines +1151 to +1161
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

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

如果字段名从 spMchid 更改为 spMchId 以保持一致性,此处的方法调用也需要相应更新为 request.getSpMchId()request.setSpMchId()

Copilot uses AI. Check for mistakes.
if (StringUtils.isBlank(request.getSubAppid())) {
request.setSubAppid(this.getConfig().getSubAppId());
}
if (StringUtils.isBlank(request.getSubMchid())) {
request.setSubMchid(this.getConfig().getSubMchId());
}
Comment on lines +1152 to +1167
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

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

如果字段名从 subMchid 更改为 subMchId 以保持一致性,此处的方法调用也需要相应更新为 request.getSubMchId()request.setSubMchId()

Copilot uses AI. Check for mistakes.
String url = String.format("%s/v3/pay/partner/transactions/codepay", this.getPayBaseUrl());
String body = this.postV3WithWechatpaySerial(url, GSON.toJson(request));
return GSON.fromJson(body, WxPayCodepayResult.class);
} else {
// 直连商户模式
if (StringUtils.isBlank(request.getAppid())) {
request.setAppid(this.getConfig().getAppId());
}
if (StringUtils.isBlank(request.getMchid())) {
request.setMchid(this.getConfig().getMchId());
}
String url = String.format("%s/v3/pay/transactions/codepay", this.getPayBaseUrl());
String body = this.postV3WithWechatpaySerial(url, GSON.toJson(request));
return GSON.fromJson(body, WxPayCodepayResult.class);
}
String url = String.format("%s/v3/pay/transactions/codepay", this.getPayBaseUrl());
String body = this.postV3WithWechatpaySerial(url, GSON.toJson(request));
return GSON.fromJson(body, WxPayCodepayResult.class);
}
Comment on lines 1148 to 1183
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

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

此实现偏离了项目中处理服务商模式的既定模式。现有的服务商模式实现(如 queryPartnerOrderV3、closePartnerOrderV3、unifiedPartnerOrderV3 等)使用单独的方法,而不是在同一方法中自动检测模式。建议考虑创建单独的 codepayPartner 方法以保持 API 设计的一致性,或者如果自动检测是有意的设计决策,请在代码注释中说明原因。

Copilot uses AI. Check for mistakes.

@Override
Expand Down