Skip to content

Commit 6840722

Browse files
lixizebinarywang
authored andcommitted
🎨 #3449【视频号】订单详情和分类详情接口增加部分字段,并增加新增库存不足、团购优惠发放的回调通知处理方法
1 parent 75aa3fc commit 6840722

File tree

12 files changed

+369
-3
lines changed

12 files changed

+369
-3
lines changed

weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/BaseWxChannelMessageService.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
import me.chanjar.weixin.channel.bean.message.product.BrandMessage;
2121
import me.chanjar.weixin.channel.bean.message.product.CategoryAuditMessage;
2222
import me.chanjar.weixin.channel.bean.message.product.SpuAuditMessage;
23+
import me.chanjar.weixin.channel.bean.message.product.SpuStockMessage;
2324
import me.chanjar.weixin.channel.bean.message.store.CloseStoreMessage;
2425
import me.chanjar.weixin.channel.bean.message.store.NicknameUpdateMessage;
2526
import me.chanjar.weixin.channel.bean.message.supplier.SupplierItemMessage;
2627
import me.chanjar.weixin.channel.bean.message.vip.ExchangeInfoMessage;
2728
import me.chanjar.weixin.channel.bean.message.vip.UserInfoMessage;
29+
import me.chanjar.weixin.channel.bean.message.voucher.VoucherMessage;
2830
import me.chanjar.weixin.channel.message.WxChannelMessage;
2931
import me.chanjar.weixin.channel.message.WxChannelMessageRouterRule;
3032
import me.chanjar.weixin.common.session.WxSessionManager;
@@ -197,6 +199,18 @@ void spuStatusUpdate(SpuAuditMessage message, final String content, final String
197199
void spuUpdate(SpuAuditMessage message, final String content, final String appId, final Map<String, Object> context,
198200
final WxSessionManager sessionManager);
199201

202+
/**
203+
* 商品库存不足通知
204+
*
205+
* @param message 消息
206+
* @param content 消息原始内容
207+
* @param appId appId
208+
* @param context 上下文
209+
* @param sessionManager session管理器
210+
*/
211+
void stockNoEnough(SpuStockMessage message, final String content, final String appId,
212+
final Map<String, Object> context, final WxSessionManager sessionManager);
213+
200214
/**
201215
* 类目审核结果
202216
*
@@ -353,6 +367,17 @@ void userCouponUse(UserCouponExpireMessage message, final String content, final
353367
void userCouponUnuse(UserCouponExpireMessage message, final String content, final String appId,
354368
final Map<String, Object> context, final WxSessionManager sessionManager);
355369

370+
/**
371+
* 发放团购优惠成功回调
372+
*
373+
* @param message 消息
374+
* @param content 消息原始内容
375+
* @param appId appId
376+
* @param context 上下文
377+
* @param sessionManager session管理器
378+
*/
379+
void voucherSendSucc(VoucherMessage message, final String content, final String appId,
380+
final Map<String, Object> context, final WxSessionManager sessionManager);
356381
/**
357382
* 结算账户变更回调
358383
*

weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelMessageServiceImpl.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@
2323
import me.chanjar.weixin.channel.bean.message.product.BrandMessage;
2424
import me.chanjar.weixin.channel.bean.message.product.CategoryAuditMessage;
2525
import me.chanjar.weixin.channel.bean.message.product.SpuAuditMessage;
26+
import me.chanjar.weixin.channel.bean.message.product.SpuStockMessage;
2627
import me.chanjar.weixin.channel.bean.message.sharer.SharerChangeMessage;
2728
import me.chanjar.weixin.channel.bean.message.store.CloseStoreMessage;
2829
import me.chanjar.weixin.channel.bean.message.store.NicknameUpdateMessage;
2930
import me.chanjar.weixin.channel.bean.message.supplier.SupplierItemMessage;
3031
import me.chanjar.weixin.channel.bean.message.vip.ExchangeInfoMessage;
3132
import me.chanjar.weixin.channel.bean.message.vip.UserInfoMessage;
33+
import me.chanjar.weixin.channel.bean.message.voucher.VoucherMessage;
3234
import me.chanjar.weixin.channel.message.WxChannelMessage;
3335
import me.chanjar.weixin.channel.message.WxChannelMessageRouter;
3436
import me.chanjar.weixin.channel.message.WxChannelMessageRouterRule;
@@ -64,6 +66,8 @@ protected void addDefaultRule() {
6466
this.addRule(SpuAuditMessage.class, PRODUCT_SPU_STATUS_UPDATE, this::spuStatusUpdate);
6567
/* 商品更新 */
6668
this.addRule(SpuAuditMessage.class, PRODUCT_SPU_UPDATE, this::spuUpdate);
69+
/* 商品库存不足 */
70+
this.addRule(SpuStockMessage.class, PRODUCT_STOCK_NO_ENOUGH, this::stockNoEnough);
6771
/* 类目审核结果 */
6872
this.addRule(CategoryAuditMessage.class, PRODUCT_CATEGORY_AUDIT, this::categoryAudit);
6973
/* 订单下单 */
@@ -106,6 +110,8 @@ protected void addDefaultRule() {
106110
this.addRule(UserCouponExpireMessage.class, USER_COUPON_UNUSE, this::userCouponUnuse);
107111
/* 优惠券返还通知 */
108112
this.addRule(UserCouponExpireMessage.class, USER_COUPON_USE, this::userCouponUse);
113+
/* 发放团购优惠成功通知 */
114+
this.addRule(VoucherMessage.class, VOUCHER_SEND_SUCC, this::voucherSendSucc);
109115
/* 结算账户变更回调 */
110116
this.addRule(AccountNotifyMessage.class, ACCOUNT_NOTIFY, this::accountNotify);
111117
/* 提现回调 */
@@ -151,6 +157,7 @@ protected <T extends WxChannelMessage> void addRule(Class<T> clazz, String event
151157
consumer.accept(message, content, appId, context, sessionManager);
152158
return "success";
153159
});
160+
rule.setNext(true);
154161
this.addRule(rule);
155162
}
156163

@@ -242,6 +249,12 @@ public void spuUpdate(SpuAuditMessage message, String content, String appId,
242249
log.info("商品更新:{}", JsonUtils.encode(message));
243250
}
244251

252+
@Override
253+
public void stockNoEnough(SpuStockMessage message, String content, String appId,
254+
Map<String, Object> context, WxSessionManager sessionManager) {
255+
log.info("商品库存不足:{}", JsonUtils.encode(message));
256+
}
257+
245258
@Override
246259
public void categoryAudit(CategoryAuditMessage message, String content, String appId,
247260
Map<String, Object> context, WxSessionManager sessionManager) {
@@ -320,6 +333,12 @@ public void userCouponUnuse(UserCouponExpireMessage message, String content, Str
320333
log.info("用户优惠券取消使用:{}", JsonUtils.encode(message));
321334
}
322335

336+
@Override
337+
public void voucherSendSucc(VoucherMessage message, String content, String appId,
338+
Map<String, Object> context, WxSessionManager sessionManager) {
339+
log.info("发放团购优惠成功:{}", JsonUtils.encode(message));
340+
}
341+
323342
@Override
324343
public void accountNotify(AccountNotifyMessage message, String content, String appId,
325344
Map<String, Object> context, WxSessionManager sessionManager) {

weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/CategoryDetailResult.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ public static class Attr implements Serializable {
9999
@JsonProperty("size_chart")
100100
private SizeChart sizeChart;
101101

102+
/** 放心买必须打开坏损包赔 */
103+
@JsonProperty("is_confidence_require_bad_must_pay")
104+
private Boolean confidenceRequireBadMustPay;
105+
102106
/** 资质信息 */
103107
@JsonProperty("product_qua_list")
104108
private List<QualificationInfo> productQuaList;

weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/category/CategoryQualification.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,8 @@ public class CategoryQualification implements Serializable {
3939
@JsonProperty("product_qua_list")
4040
private List<QualificationInfo> productQuaList;
4141

42+
/** 放心买必须打开坏损包赔 */
43+
@JsonProperty("is_confidence_require_bad_must_pay")
44+
private Boolean confidenceRequireBadMustPay;
45+
4246
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package me.chanjar.weixin.channel.bean.message.product;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
5+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
6+
import java.util.Map;
7+
import lombok.Data;
8+
import lombok.EqualsAndHashCode;
9+
import lombok.NoArgsConstructor;
10+
import me.chanjar.weixin.channel.message.WxChannelMessage;
11+
12+
/**
13+
* SPU库存不足消息
14+
*
15+
* @author <a href="https://github.com/lixize">Zeyes</a>
16+
*/
17+
@Data
18+
@NoArgsConstructor
19+
@EqualsAndHashCode(callSuper = true)
20+
@JacksonXmlRootElement(localName = "xml")
21+
public class SpuStockMessage extends WxChannelMessage {
22+
23+
private static final long serialVersionUID = 2250860804161527363L;
24+
25+
/** 商品id */
26+
@JsonProperty("product_id")
27+
@JacksonXmlProperty(localName = "product_id")
28+
private String productId;
29+
30+
/** 平台商品id */
31+
@JsonProperty("sku_id")
32+
@JacksonXmlProperty(localName = "sku_id")
33+
private String skuId;
34+
35+
/** 剩余库存:当前实时库存数量 */
36+
@JsonProperty("remaining_stock_amount")
37+
@JacksonXmlProperty(localName = "remaining_stock_amount")
38+
private Long remainingStockAmount;
39+
40+
/** 未发放的预存code数【该字段对code_source_type=2的团购优惠生效,其他类型该字段值为0】 */
41+
@JsonProperty("remaining_code_amount")
42+
@JacksonXmlProperty(localName = "remaining_code_amount")
43+
private Long remainingCodeAmount;
44+
45+
/** ChannelsEcStockNoEnough */
46+
@JsonProperty("channels_ec_stock_no_enough")
47+
@JacksonXmlProperty(localName = "channels_ec_stock_no_enough")
48+
private void stockNoEnough(Map<String, Object> map) {
49+
this.unpackNameFromNestedObject(map);
50+
}
51+
52+
/**
53+
* 从嵌套对象中解析字段
54+
*
55+
* @param map 嵌套对象
56+
*/
57+
protected void unpackNameFromNestedObject(Map<String, Object> map) {
58+
if (map == null) {
59+
return;
60+
}
61+
Object obj = null;
62+
obj = map.get("product_id");
63+
if (obj != null) {
64+
this.productId = (obj instanceof String ? (String) obj : String.valueOf(obj));
65+
}
66+
obj = map.get("sku_id");
67+
if (obj != null) {
68+
this.skuId = (obj instanceof String ? (String) obj : String.valueOf(obj));
69+
}
70+
71+
obj = map.get("remaining_stock_amount");
72+
if (obj != null) {
73+
if (obj instanceof Number) {
74+
this.remainingStockAmount = ((Number) obj).longValue();
75+
} else if (obj instanceof String) {
76+
this.remainingStockAmount = Long.parseLong((String) obj);
77+
}
78+
}
79+
obj = map.get("remaining_code_amount");
80+
if (obj != null) {
81+
if (obj instanceof Number) {
82+
this.remainingCodeAmount = ((Number) obj).longValue();
83+
} else if (obj instanceof String) {
84+
this.remainingCodeAmount = Long.parseLong((String) obj);
85+
}
86+
}
87+
}
88+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package me.chanjar.weixin.channel.bean.message.voucher;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
5+
import java.io.Serializable;
6+
import lombok.Data;
7+
import lombok.NoArgsConstructor;
8+
9+
/**
10+
* @author <a href="https://github.com/lixize">Zeyes</a>
11+
*/
12+
@Data
13+
@NoArgsConstructor
14+
public class VoucherInfo implements Serializable {
15+
private static final long serialVersionUID = 6007964849358969438L;
16+
17+
/** 券code */
18+
@JsonProperty("code")
19+
@JacksonXmlProperty(localName = "code")
20+
private String code;
21+
22+
/** 劵码类型,1商户实时code 2户预存 3平台生成 */
23+
@JsonProperty("code_type")
24+
@JacksonXmlProperty(localName = "code_type")
25+
private Integer codeType;
26+
27+
/** 券状态 */
28+
@JsonProperty("status")
29+
@JacksonXmlProperty(localName = "status")
30+
private Integer status;
31+
32+
/** 发放时间,时间戳 */
33+
@JsonProperty("send_time")
34+
@JacksonXmlProperty(localName = "send_time")
35+
private Long sendTime;
36+
37+
/** 最近更新时间,时间戳 */
38+
@JsonProperty("update_time")
39+
@JacksonXmlProperty(localName = "update_time")
40+
private Long updateTime;
41+
42+
/** 核销生效时间,时间戳 */
43+
@JsonProperty("start_time")
44+
@JacksonXmlProperty(localName = "start_time")
45+
private Long startTime;
46+
47+
/** 核销结束时间,时间戳 */
48+
@JsonProperty("end_time")
49+
@JacksonXmlProperty(localName = "end_time")
50+
private Long endTime;
51+
52+
/** 核销时间,时间戳。次卡时不返回此字段 */
53+
@JsonProperty("consume_time")
54+
@JacksonXmlProperty(localName = "consume_time")
55+
private Long consumeTime;
56+
57+
/** 退券时间,时间戳。次卡时不返回此字段 */
58+
@JsonProperty("refund_time")
59+
@JacksonXmlProperty(localName = "refund_time")
60+
private Long refundTime;
61+
62+
/** 核销门店名称 */
63+
@JsonProperty("consume_store_name")
64+
@JacksonXmlProperty(localName = "consume_store_name")
65+
private String consumeStoreName;
66+
67+
/** */
68+
@JsonProperty("voucher_type")
69+
@JacksonXmlProperty(localName = "voucher_type")
70+
private Integer voucherType;
71+
72+
/** 券的售卖价格(分) */
73+
@JsonProperty("voucher_buy_amount")
74+
@JacksonXmlProperty(localName = "voucher_buy_amount")
75+
private Integer voucherBuyAmount;
76+
77+
/** 券市场金额(分) */
78+
@JsonProperty("voucher_actual_amount")
79+
@JacksonXmlProperty(localName = "voucher_actual_amount")
80+
private Integer voucherActualAmount;
81+
82+
/** 用户手机号 */
83+
@JsonProperty("telphone_no")
84+
@JacksonXmlProperty(localName = "telphone_no")
85+
private String telPhoneNo;
86+
87+
/** 商品id */
88+
@JsonProperty("product_id")
89+
@JacksonXmlProperty(localName = "product_id")
90+
private String productId;
91+
92+
/** 商品下的skuId */
93+
@JsonProperty("sku_id")
94+
@JacksonXmlProperty(localName = "sku_id")
95+
private String skuId;
96+
97+
/** 购买券的订单id */
98+
@JsonProperty("order_id")
99+
@JacksonXmlProperty(localName = "order_id")
100+
private String orderId;
101+
102+
/** 用户在商家品牌appid下的openid */
103+
@JsonProperty("openid")
104+
@JacksonXmlProperty(localName = "openid")
105+
private String openId;
106+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package me.chanjar.weixin.channel.bean.message.voucher;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
5+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
6+
import java.util.List;
7+
import lombok.Data;
8+
import lombok.EqualsAndHashCode;
9+
import lombok.NoArgsConstructor;
10+
import me.chanjar.weixin.channel.message.WxChannelMessage;
11+
12+
/**
13+
* 发放团购优惠成功消息
14+
*
15+
* @author <a href="https://github.com/lixize">Zeyes</a>
16+
*/
17+
@Data
18+
@NoArgsConstructor
19+
@EqualsAndHashCode(callSuper = true)
20+
@JacksonXmlRootElement(localName = "xml")
21+
public class VoucherMessage extends WxChannelMessage {
22+
23+
private static final long serialVersionUID = 975858675917036089L;
24+
25+
/** 发放团购优惠成功消息 */
26+
@JsonProperty("voucher_list")
27+
@JacksonXmlProperty(localName = "voucher_list")
28+
private List<VoucherInfo> voucherInfo;
29+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package me.chanjar.weixin.channel.bean.order;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import java.io.Serializable;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
8+
/**
9+
* 授权账号信息
10+
*
11+
* @author <a href="https://github.com/lixize">Zeyes</a>
12+
*/
13+
@Data
14+
@NoArgsConstructor
15+
public class OrderAgentInfo implements Serializable {
16+
17+
private static final long serialVersionUID = 6396067079343033841L;
18+
19+
/**
20+
* 授权视频号id
21+
*/
22+
@JsonProperty("agent_finder_id")
23+
private String agentFinderId;
24+
25+
/**
26+
* 授权视频号昵称
27+
*/
28+
@JsonProperty("agent_finder_nickname")
29+
private String agentFinderNickname;
30+
}

0 commit comments

Comments
 (0)