Skip to content
Open
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 @@ -499,6 +499,11 @@ public static class EventType {
* 订单完成发货时、订单结算时
*/
public static final String TRADE_MANAGE_ORDER_SETTLEMENT = "trade_manage_order_settlement";
/**
* 虚拟支付 iOS 退款查询通知
* 文档:https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/business-capabilities/virtual-payment/ios.html
*/
public static final String XPAY_SUBSCRIBE_IOS_REFUND_QUERY_NOTIFY = "xpay_subscribe_ios_refund_query_notify";
Comment on lines +502 to +506
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

仓库里小程序虚拟支付通知事件名已在 WxMaConstants.XPayNotifyEvent 中集中维护(含 xpay_refund_notify/xpay_complaint_notify 等)。这里单独在 WxConsts.EventType 新增一个 XPAY_* 常量会造成事件常量来源分散;建议要么把该事件也补充到 WxMaConstants.XPayNotifyEvent 并在 miniapp 场景统一使用它,要么在 WxConsts 中补齐同类 XPAY 通知常量以保持一致。

Copilot uses AI. Check for mistakes.
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,80 @@ public class WxMaMessage implements Serializable {
@XStreamConverter(value = XStreamCDataConverter.class)
private String requestId;

// xpay_subscribe_ios_refund_query_notify iOS退款查询通知字段

/**
* 问询时间,Unix时间戳.
* xpay_subscribe_ios_refund_query_notify
*/
@SerializedName("refund_time")
@XStreamAlias("refund_time")
@XStreamConverter(value = XStreamCDataConverter.class)
private String refundTime;
Comment on lines +475 to +476
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

这里的 refund_time 在文档中是 Unix 时间戳(数值语义),但当前用 String + XStreamCDataConverter 建模,会导致调用方需要自行解析且与本类里其他时间戳字段(如 ComplaintTime/RefundStartTimestamp 等 Long 类型)不一致。建议将 refundTime 改为 Long(或 Integer/Long 统一口径),并移除该字段上的 XStreamCDataConverter(数值字段通常不需要 CDATA converter),同时相应更新测试断言。

Suggested change
@XStreamConverter(value = XStreamCDataConverter.class)
private String refundTime;
private Long refundTime;

Copilot uses AI. Check for mistakes.

/**
* 该笔退款的订单时间(退款订单对应的交易时间),Unix时间戳.
* xpay_subscribe_ios_refund_query_notify
*/
@SerializedName("order_time")
@XStreamAlias("order_time")
@XStreamConverter(value = XStreamCDataConverter.class)
private String orderTime;
Comment on lines +484 to +485
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

order_time 同样是 Unix 时间戳字段,目前用 String 表达会弱化类型信息且与本类既有的 Long 时间戳字段不一致。建议将 orderTime 改为 Long,并去掉 XStreamCDataConverter(如果需要兼容字符串/数值两种 JSON 表达,可保留 Long 并依赖 Gson/XStream 的数值解析能力),同时调整对应测试。

Suggested change
@XStreamConverter(value = XStreamCDataConverter.class)
private String orderTime;
private Long orderTime;

Copilot uses AI. Check for mistakes.

/**
* Apple 支付票据号.
* xpay_subscribe_ios_refund_query_notify
*/
@SerializedName("channel_bill")
@XStreamAlias("channel_bill")
@XStreamConverter(value = XStreamCDataConverter.class)
private String channelBill;

/**
* 应用的 Apple bundleid.
* xpay_subscribe_ios_refund_query_notify
*/
@SerializedName("bundleid")
@XStreamAlias("bundleid")
@XStreamConverter(value = XStreamCDataConverter.class)
private String bundleid;

/**
* 道具 id.
* xpay_subscribe_ios_refund_query_notify
*/
@SerializedName("product_id")
@XStreamAlias("product_id")
@XStreamConverter(value = XStreamCDataConverter.class)
private String xpayProductId;

/**
* 道具/代币数量.
* xpay_subscribe_ios_refund_query_notify
*/
@SerializedName("p_count")
@XStreamAlias("p_count")
@XStreamConverter(value = XStreamCDataConverter.class)
private String pCount;
Comment on lines +520 to +521
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

p_count 是数量字段(数值语义),目前用 String 建模不利于后续做数值比较/计算,也与本类中类似字段(如 RefundFee/RetryTimes 等 Integer)不一致。建议将 pCount 改为 Integer,并移除 XStreamCDataConverter,同时更新解析测试断言。

Suggested change
@XStreamConverter(value = XStreamCDataConverter.class)
private String pCount;
private Integer pCount;

Copilot uses AI. Check for mistakes.

/**
* 用户请求退款的原因.
* xpay_subscribe_ios_refund_query_notify
*/
@SerializedName("refund_request_reason")
@XStreamAlias("refund_request_reason")
@XStreamConverter(value = XStreamCDataConverter.class)
private String refundRequestReason;

/**
* 发货状态,0:未发货 1:已发货 2:发货中.
* xpay_subscribe_ios_refund_query_notify
*/
@SerializedName("provide_status")
@XStreamAlias("provide_status")
@XStreamConverter(value = XStreamCDataConverter.class)
private String provideStatus;
Copy link
Copy Markdown

@augmentcode augmentcode Bot Apr 30, 2026

Choose a reason for hiding this comment

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

WxMaMessage.java:539 — The WeChat spec for WxaVirtualPayIosRefundQueryNotifyEvent also includes pay_order_id (退款对应支付订单号), but there’s no corresponding field here, so callers can’t read that value.

Severity: medium

Other Locations
  • weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java:479
  • weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java:504
  • weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/bean/WxMaMessageTest.java:516

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment on lines +538 to +539
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

provide_status 表示枚举状态(0/1/2),建议用 Integer 而不是 String 来建模,避免调用方自行解析且与本类其它状态字段(如 retCode/teamType 等 Integer)保持一致;相应可移除 XStreamCDataConverter 并更新测试断言。

Suggested change
@XStreamConverter(value = XStreamCDataConverter.class)
private String provideStatus;
private Integer provideStatus;

Copilot uses AI. Check for mistakes.

/**
* 不要直接使用这个字段,
* 这个字段只是为了适配 SubscribeMsgPopupEvent SubscribeMsgChangeEvent SubscribeMsgSentEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,4 +457,70 @@ private void checkXPayComplaintNotifyMessage(WxMaMessage msg) {
assertEquals(msg.getRetryTimes(), new Integer(0));
assertEquals(msg.getRequestId(), "req_005");
}

/**
* 虚拟支付 iOS 退款查询通知事件 xpay_subscribe_ios_refund_query_notify 测试用例(XML格式)
*/
@Test
public void testXPaySubscribeIosRefundQueryNotifyFromXml() {
String xml = "<xml>\n" +
" <ToUserName><![CDATA[gh_abcdefg]]></ToUserName>\n" +
" <FromUserName><![CDATA[oABCDEFG]]></FromUserName>\n" +
" <CreateTime>1700001000</CreateTime>\n" +
" <MsgType><![CDATA[event]]></MsgType>\n" +
" <Event><![CDATA[xpay_subscribe_ios_refund_query_notify]]></Event>\n" +
" <refund_time><![CDATA[1700000900]]></refund_time>\n" +
" <order_time><![CDATA[1699990000]]></order_time>\n" +
" <channel_bill><![CDATA[apple_bill_001]]></channel_bill>\n" +
" <bundleid><![CDATA[com.example.app]]></bundleid>\n" +
" <product_id><![CDATA[product_xyz]]></product_id>\n" +
" <p_count><![CDATA[1]]></p_count>\n" +
" <refund_request_reason><![CDATA[不喜欢]]></refund_request_reason>\n" +
" <provide_status><![CDATA[1]]></provide_status>\n" +
"</xml>";

WxMaMessage msg = WxMaMessage.fromXml(xml);
checkXPaySubscribeIosRefundQueryNotifyMessage(msg);
}

/**
* 虚拟支付 iOS 退款查询通知事件 xpay_subscribe_ios_refund_query_notify 测试用例(JSON格式)
*/
@Test
public void testXPaySubscribeIosRefundQueryNotifyFromJson() {
String json = "{\n" +
" \"ToUserName\": \"gh_abcdefg\",\n" +
" \"FromUserName\": \"oABCDEFG\",\n" +
" \"CreateTime\": 1700001000,\n" +
" \"MsgType\": \"event\",\n" +
" \"Event\": \"xpay_subscribe_ios_refund_query_notify\",\n" +
" \"refund_time\": \"1700000900\",\n" +
" \"order_time\": \"1699990000\",\n" +
" \"channel_bill\": \"apple_bill_001\",\n" +
" \"bundleid\": \"com.example.app\",\n" +
" \"product_id\": \"product_xyz\",\n" +
" \"p_count\": \"1\",\n" +
" \"refund_request_reason\": \"不喜欢\",\n" +
" \"provide_status\": \"1\"\n" +
"}";

WxMaMessage msg = WxMaMessage.fromJson(json);
checkXPaySubscribeIosRefundQueryNotifyMessage(msg);
}

private void checkXPaySubscribeIosRefundQueryNotifyMessage(WxMaMessage msg) {
assertEquals(msg.getToUser(), "gh_abcdefg");
assertEquals(msg.getFromUser(), "oABCDEFG");
assertEquals(msg.getCreateTime(), new Integer(1700001000));
assertEquals(msg.getMsgType(), WxConsts.XmlMsgType.EVENT);
assertEquals(msg.getEvent(), WxConsts.EventType.XPAY_SUBSCRIBE_IOS_REFUND_QUERY_NOTIFY);
assertEquals(msg.getRefundTime(), "1700000900");
assertEquals(msg.getOrderTime(), "1699990000");
assertEquals(msg.getChannelBill(), "apple_bill_001");
assertEquals(msg.getBundleid(), "com.example.app");
assertEquals(msg.getXpayProductId(), "product_xyz");
assertEquals(msg.getPCount(), "1");
assertEquals(msg.getRefundRequestReason(), "不喜欢");
assertEquals(msg.getProvideStatus(), "1");
}
}