Skip to content

Commit 5d14948

Browse files
authored
🆕 #4029 【视频号】增加微信小店店铺链接与收藏管理相关接口
1 parent 51fe97e commit 5d14948

13 files changed

Lines changed: 327 additions & 0 deletions

‎weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelBasicService.java‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
import me.chanjar.weixin.channel.bean.image.ChannelImageInfo;
66
import me.chanjar.weixin.channel.bean.image.ChannelImageResponse;
77
import me.chanjar.weixin.channel.bean.image.QualificationFileResponse;
8+
import me.chanjar.weixin.channel.bean.shop.ShopH5UrlResponse;
89
import me.chanjar.weixin.channel.bean.shop.ShopInfoResponse;
10+
import me.chanjar.weixin.channel.bean.shop.ShopQrCodeResponse;
11+
import me.chanjar.weixin.channel.bean.shop.ShopTagLinkResponse;
912
import me.chanjar.weixin.common.error.WxErrorException;
1013

1114
/**
@@ -22,6 +25,31 @@ public interface WxChannelBasicService {
2225
*/
2326
ShopInfoResponse getShopInfo() throws WxErrorException;
2427

28+
/**
29+
* 获取店铺H5链接
30+
*
31+
* @return 店铺H5链接
32+
* @throws WxErrorException 异常
33+
*/
34+
ShopH5UrlResponse getShopH5Url() throws WxErrorException;
35+
36+
/**
37+
* 获取店铺二维码
38+
*
39+
* @param qrcodeType 二维码类型,1:二维码;2:标准物料;3:送礼物物料
40+
* @return 店铺二维码
41+
* @throws WxErrorException 异常
42+
*/
43+
ShopQrCodeResponse getShopQrCode(int qrcodeType) throws WxErrorException;
44+
45+
/**
46+
* 获取店铺口令
47+
*
48+
* @return 店铺口令
49+
* @throws WxErrorException 异常
50+
*/
51+
ShopTagLinkResponse getShopTagLink() throws WxErrorException;
52+
2553
/**
2654
* 上传图片
2755
*
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package me.chanjar.weixin.channel.api;
2+
3+
import me.chanjar.weixin.channel.bean.favorite.FavoriteCountResponse;
4+
import me.chanjar.weixin.common.error.WxErrorException;
5+
6+
/**
7+
* 视频号小店 收藏管理接口
8+
*
9+
* @author <a href="https://github.com/copilot">GitHub Copilot</a>
10+
* @link <a href="https://developers.weixin.qq.com/doc/channels/API/favorite/shopfavorite/">收藏管理接口文档</a>
11+
*/
12+
public interface WxChannelFavoriteService {
13+
14+
/**
15+
* 获取店铺收藏的人数
16+
*
17+
* @return 店铺收藏人数响应
18+
* @throws WxErrorException 异常
19+
*/
20+
FavoriteCountResponse getFavoriteCount() throws WxErrorException;
21+
}

‎weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelService.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,11 @@ public interface WxChannelService extends BaseWxChannelService {
196196
*/
197197
WxTalentService getTalentService();
198198

199+
/**
200+
* 收藏管理服务
201+
*
202+
* @return 收藏管理服务
203+
*/
204+
WxChannelFavoriteService getFavoriteService();
205+
199206
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public abstract class BaseWxChannelServiceImpl<H, P> implements WxChannelService
6262
private WxChannelLiveDashboardService liveDashboardService = null;
6363
private WxChannelQicService qicService = null;
6464
private WxTalentService talentService = null;
65+
private WxChannelFavoriteService favoriteService = null;
6566

6667
protected WxChannelConfig config;
6768
private int retrySleepMillis = 1000;
@@ -491,4 +492,12 @@ public synchronized WxTalentService getTalentService() {
491492
return talentService;
492493
}
493494

495+
@Override
496+
public synchronized WxChannelFavoriteService getFavoriteService() {
497+
if (favoriteService == null) {
498+
favoriteService = new WxChannelFavoriteServiceImpl(this);
499+
}
500+
return favoriteService;
501+
}
502+
494503
}

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.GET_ADDRESS_CODE;
44
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.GET_IMG_URL;
5+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.GET_SHOP_H5URL;
56
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.GET_SHOP_INFO;
7+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.GET_SHOP_QRCODE;
8+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.GET_SHOP_TAGLINK;
69
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.IMG_UPLOAD_URL;
710
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.UPLOAD_QUALIFICATION_FILE;
811

@@ -16,7 +19,10 @@
1619
import me.chanjar.weixin.channel.bean.image.ChannelImageResponse;
1720
import me.chanjar.weixin.channel.bean.image.QualificationFileResponse;
1821
import me.chanjar.weixin.channel.bean.image.UploadImageResponse;
22+
import me.chanjar.weixin.channel.bean.shop.ShopH5UrlResponse;
1923
import me.chanjar.weixin.channel.bean.shop.ShopInfoResponse;
24+
import me.chanjar.weixin.channel.bean.shop.ShopQrCodeResponse;
25+
import me.chanjar.weixin.channel.bean.shop.ShopTagLinkResponse;
2026
import me.chanjar.weixin.channel.executor.ChannelFileUploadRequestExecutor;
2127
import me.chanjar.weixin.channel.executor.ChannelMediaDownloadRequestExecutor;
2228
import me.chanjar.weixin.channel.util.ResponseUtils;
@@ -93,4 +99,23 @@ public AddressCodeResponse getAddressCode(Integer code) throws WxErrorException
9399
return ResponseUtils.decode(resJson, AddressCodeResponse.class);
94100
}
95101

102+
@Override
103+
public ShopH5UrlResponse getShopH5Url() throws WxErrorException {
104+
String resJson = shopService.post(GET_SHOP_H5URL, "{}");
105+
return ResponseUtils.decode(resJson, ShopH5UrlResponse.class);
106+
}
107+
108+
@Override
109+
public ShopQrCodeResponse getShopQrCode(int qrcodeType) throws WxErrorException {
110+
String reqJson = "{\"qrcode_type\":" + qrcodeType + "}";
111+
String resJson = shopService.post(GET_SHOP_QRCODE, reqJson);
112+
return ResponseUtils.decode(resJson, ShopQrCodeResponse.class);
113+
}
114+
115+
@Override
116+
public ShopTagLinkResponse getShopTagLink() throws WxErrorException {
117+
String resJson = shopService.post(GET_SHOP_TAGLINK, "{}");
118+
return ResponseUtils.decode(resJson, ShopTagLinkResponse.class);
119+
}
120+
96121
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package me.chanjar.weixin.channel.api.impl;
2+
3+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Favorite.GET_FAVORITE_COUNT;
4+
5+
import me.chanjar.weixin.channel.api.WxChannelFavoriteService;
6+
import me.chanjar.weixin.channel.bean.favorite.FavoriteCountResponse;
7+
import me.chanjar.weixin.channel.util.ResponseUtils;
8+
import me.chanjar.weixin.common.error.WxErrorException;
9+
10+
/**
11+
* 视频号小店 收藏管理接口实现
12+
*
13+
* @author <a href="https://github.com/copilot">GitHub Copilot</a>
14+
*/
15+
public class WxChannelFavoriteServiceImpl implements WxChannelFavoriteService {
16+
17+
/** 微信商店服务 */
18+
private final BaseWxChannelServiceImpl<?, ?> shopService;
19+
20+
public WxChannelFavoriteServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
21+
this.shopService = shopService;
22+
}
23+
24+
@Override
25+
public FavoriteCountResponse getFavoriteCount() throws WxErrorException {
26+
String resJson = shopService.post(GET_FAVORITE_COUNT, "{}");
27+
return ResponseUtils.decode(resJson, FavoriteCountResponse.class);
28+
}
29+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package me.chanjar.weixin.channel.bean.favorite;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
import lombok.NoArgsConstructor;
7+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
8+
9+
/**
10+
* 店铺收藏人数 响应
11+
*
12+
* @author <a href="https://github.com/copilot">GitHub Copilot</a>
13+
*/
14+
@Data
15+
@NoArgsConstructor
16+
@EqualsAndHashCode(callSuper = true)
17+
public class FavoriteCountResponse extends WxChannelBaseResponse {
18+
19+
/** 店铺首页收藏用户数 */
20+
@JsonProperty("favor_uv_acc_shop_homepage")
21+
private Long favorUvAccShopHomepage;
22+
23+
/** 订单详情页收藏用户数 */
24+
@JsonProperty("favor_uv_acc_order_detail")
25+
private Long favorUvAccOrderDetail;
26+
27+
/** 商品详情页收藏用户数 */
28+
@JsonProperty("favor_uv_acc_product_detail")
29+
private Long favorUvAccProductDetail;
30+
31+
/** 其他场景收藏用户数 */
32+
@JsonProperty("favor_uv_acc_other_scene")
33+
private Long favorUvAccOtherScene;
34+
35+
/** 所有收藏用户数 */
36+
@JsonProperty("favor_uv_acc_all")
37+
private Long favorUvAccAll;
38+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package me.chanjar.weixin.channel.bean.shop;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
import lombok.NoArgsConstructor;
7+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
8+
9+
/**
10+
* 店铺H5链接 响应
11+
*
12+
* @author <a href="https://github.com/copilot">GitHub Copilot</a>
13+
*/
14+
@Data
15+
@NoArgsConstructor
16+
@EqualsAndHashCode(callSuper = true)
17+
public class ShopH5UrlResponse extends WxChannelBaseResponse {
18+
19+
/** 店铺H5链接 */
20+
@JsonProperty("shop_h5url")
21+
private String shopH5url;
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package me.chanjar.weixin.channel.bean.shop;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
import lombok.NoArgsConstructor;
7+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
8+
9+
/**
10+
* 店铺二维码 响应
11+
*
12+
* @author <a href="https://github.com/copilot">GitHub Copilot</a>
13+
*/
14+
@Data
15+
@NoArgsConstructor
16+
@EqualsAndHashCode(callSuper = true)
17+
public class ShopQrCodeResponse extends WxChannelBaseResponse {
18+
19+
/** 店铺二维码链接 */
20+
@JsonProperty("shop_qrcode")
21+
private String shopQrcode;
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package me.chanjar.weixin.channel.bean.shop;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
import lombok.NoArgsConstructor;
7+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
8+
9+
/**
10+
* 店铺口令 响应
11+
*
12+
* @author <a href="https://github.com/copilot">GitHub Copilot</a>
13+
*/
14+
@Data
15+
@NoArgsConstructor
16+
@EqualsAndHashCode(callSuper = true)
17+
public class ShopTagLinkResponse extends WxChannelBaseResponse {
18+
19+
/** 店铺微信口令 */
20+
@JsonProperty("shop_taglink")
21+
private String shopTaglink;
22+
}

0 commit comments

Comments
 (0)