🎨 #3963 【小程序】补充虚拟支付 xpay_complaint_notify 投诉推送事件支持
This commit is contained in:
@@ -189,7 +189,7 @@ public class WxMaMessage implements Serializable {
|
||||
@XStreamConverter(value = XStreamCDataConverter.class)
|
||||
private String revokeInfo;
|
||||
|
||||
@SerializedName("OpenID")
|
||||
@SerializedName(value = "OpenID", alternate = {"OpenId"})
|
||||
@XStreamAlias("OpenID")
|
||||
@XStreamConverter(value = XStreamCDataConverter.class)
|
||||
private String openId;
|
||||
@@ -418,6 +418,52 @@ public class WxMaMessage implements Serializable {
|
||||
@XStreamAlias("TeamInfo")
|
||||
private WxMaXPayTeamInfo teamInfo;
|
||||
|
||||
// xpay_complaint_notify 用户投诉推送字段
|
||||
|
||||
/**
|
||||
* 微信支付交易单号.
|
||||
* xpay_complaint_notify
|
||||
*/
|
||||
@SerializedName("TransactionId")
|
||||
@XStreamAlias("TransactionId")
|
||||
@XStreamConverter(value = XStreamCDataConverter.class)
|
||||
private String complaintTransactionId;
|
||||
|
||||
/**
|
||||
* 投诉单号.
|
||||
* xpay_complaint_notify
|
||||
*/
|
||||
@SerializedName("ComplaintId")
|
||||
@XStreamAlias("ComplaintId")
|
||||
@XStreamConverter(value = XStreamCDataConverter.class)
|
||||
private String complaintId;
|
||||
|
||||
/**
|
||||
* 投诉详情.
|
||||
* xpay_complaint_notify
|
||||
*/
|
||||
@SerializedName("ComplaintDetail")
|
||||
@XStreamAlias("ComplaintDetail")
|
||||
@XStreamConverter(value = XStreamCDataConverter.class)
|
||||
private String complaintDetail;
|
||||
|
||||
/**
|
||||
* 投诉时间,秒级时间戳.
|
||||
* xpay_complaint_notify
|
||||
*/
|
||||
@SerializedName("ComplaintTime")
|
||||
@XStreamAlias("ComplaintTime")
|
||||
private Long complaintTime;
|
||||
|
||||
/**
|
||||
* 请求编号.
|
||||
* xpay_complaint_notify
|
||||
*/
|
||||
@SerializedName("RequestId")
|
||||
@XStreamAlias("RequestId")
|
||||
@XStreamConverter(value = XStreamCDataConverter.class)
|
||||
private String requestId;
|
||||
|
||||
/**
|
||||
* 不要直接使用这个字段,
|
||||
* 这个字段只是为了适配 SubscribeMsgPopupEvent SubscribeMsgChangeEvent SubscribeMsgSentEvent
|
||||
|
||||
@@ -261,9 +261,10 @@ public class WxMaConstants {
|
||||
}
|
||||
@UtilityClass
|
||||
public static final class XPayNotifyEvent {
|
||||
public static String COIN_PAY = "xpay_coin_pay_notify";
|
||||
public static String GOODS_DELIVER = "xpay_goods_deliver_notify";
|
||||
public static String REFUND = "xpay_refund_notify";
|
||||
public static final String COIN_PAY = "xpay_coin_pay_notify";
|
||||
public static final String GOODS_DELIVER = "xpay_goods_deliver_notify";
|
||||
public static final String REFUND = "xpay_refund_notify";
|
||||
public static final String COMPLAINT = "xpay_complaint_notify";
|
||||
|
||||
}
|
||||
@UtilityClass
|
||||
|
||||
@@ -101,6 +101,8 @@ public class XStreamTransformer {
|
||||
if (clz.equals(WxMaMessage.class)) {
|
||||
// 操蛋的微信,模板消息推送成功的消息是MsgID,其他消息推送过来是MsgId
|
||||
xstream.aliasField("MsgID", WxMaMessage.class, "msgId");
|
||||
// xpay 事件推送使用 OpenId(小写 d),但通用字段注解为 OpenID(大写 D)
|
||||
xstream.aliasField("OpenId", WxMaMessage.class, "openId");
|
||||
}
|
||||
|
||||
register(clz, xstream);
|
||||
|
||||
@@ -388,4 +388,73 @@ public class WxMaMessageTest {
|
||||
assertEquals(teamInfo.getTeamType(), new Integer(1));
|
||||
assertEquals(teamInfo.getTeamAction(), new Integer(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* 虚拟支付投诉推送事件 xpay_complaint_notify 测试用例(XML格式)
|
||||
*/
|
||||
@Test
|
||||
public void testXPayComplaintNotifyFromXml() {
|
||||
String xml = "<xml>\n" +
|
||||
" <ToUserName><![CDATA[gh_abcdefg]]></ToUserName>\n" +
|
||||
" <FromUserName><![CDATA[official_openid]]></FromUserName>\n" +
|
||||
" <CreateTime>1700000100</CreateTime>\n" +
|
||||
" <MsgType><![CDATA[event]]></MsgType>\n" +
|
||||
" <Event><![CDATA[xpay_complaint_notify]]></Event>\n" +
|
||||
" <OpenId><![CDATA[user_openid_abc]]></OpenId>\n" +
|
||||
" <WxOrderId><![CDATA[wx_order_cmp_001]]></WxOrderId>\n" +
|
||||
" <MchOrderId><![CDATA[mch_order_cmp_002]]></MchOrderId>\n" +
|
||||
" <TransactionId><![CDATA[transaction_cmp_003]]></TransactionId>\n" +
|
||||
" <ComplaintId><![CDATA[complaint_004]]></ComplaintId>\n" +
|
||||
" <ComplaintDetail><![CDATA[商品未收到]]></ComplaintDetail>\n" +
|
||||
" <ComplaintTime>1700000050</ComplaintTime>\n" +
|
||||
" <RetryTimes>0</RetryTimes>\n" +
|
||||
" <RequestId><![CDATA[req_005]]></RequestId>\n" +
|
||||
"</xml>";
|
||||
|
||||
WxMaMessage msg = WxMaMessage.fromXml(xml);
|
||||
checkXPayComplaintNotifyMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 虚拟支付投诉推送事件 xpay_complaint_notify 测试用例(JSON格式)
|
||||
*/
|
||||
@Test
|
||||
public void testXPayComplaintNotifyFromJson() {
|
||||
String json = "{\n" +
|
||||
" \"ToUserName\": \"gh_abcdefg\",\n" +
|
||||
" \"FromUserName\": \"official_openid\",\n" +
|
||||
" \"CreateTime\": 1700000100,\n" +
|
||||
" \"MsgType\": \"event\",\n" +
|
||||
" \"Event\": \"xpay_complaint_notify\",\n" +
|
||||
" \"OpenId\": \"user_openid_abc\",\n" +
|
||||
" \"WxOrderId\": \"wx_order_cmp_001\",\n" +
|
||||
" \"MchOrderId\": \"mch_order_cmp_002\",\n" +
|
||||
" \"TransactionId\": \"transaction_cmp_003\",\n" +
|
||||
" \"ComplaintId\": \"complaint_004\",\n" +
|
||||
" \"ComplaintDetail\": \"商品未收到\",\n" +
|
||||
" \"ComplaintTime\": 1700000050,\n" +
|
||||
" \"RetryTimes\": 0,\n" +
|
||||
" \"RequestId\": \"req_005\"\n" +
|
||||
"}";
|
||||
|
||||
WxMaMessage msg = WxMaMessage.fromJson(json);
|
||||
checkXPayComplaintNotifyMessage(msg);
|
||||
}
|
||||
|
||||
private void checkXPayComplaintNotifyMessage(WxMaMessage msg) {
|
||||
assertEquals(msg.getToUser(), "gh_abcdefg");
|
||||
assertEquals(msg.getFromUser(), "official_openid");
|
||||
assertEquals(msg.getCreateTime(), new Integer(1700000100));
|
||||
assertEquals(msg.getMsgType(), WxConsts.XmlMsgType.EVENT);
|
||||
assertEquals(msg.getEvent(), "xpay_complaint_notify");
|
||||
assertEquals(msg.getOpenId(), "user_openid_abc");
|
||||
assertEquals(msg.getWxOrderId(), "wx_order_cmp_001");
|
||||
assertEquals(msg.getMchOrderId(), "mch_order_cmp_002");
|
||||
assertEquals(msg.getComplaintTransactionId(), "transaction_cmp_003");
|
||||
assertEquals(msg.getComplaintId(), "complaint_004");
|
||||
assertEquals(msg.getComplaintDetail(), "商品未收到");
|
||||
assertEquals(msg.getComplaintTime(), new Long(1700000050L));
|
||||
assertEquals(msg.getRetryTimes(), new Integer(0));
|
||||
assertEquals(msg.getRequestId(), "req_005");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user