🆕 #4029 【视频号】增加微信小店店铺链接与收藏管理相关接口
This commit is contained in:
@@ -5,7 +5,10 @@ import me.chanjar.weixin.channel.bean.address.AddressCodeResponse;
|
||||
import me.chanjar.weixin.channel.bean.image.ChannelImageInfo;
|
||||
import me.chanjar.weixin.channel.bean.image.ChannelImageResponse;
|
||||
import me.chanjar.weixin.channel.bean.image.QualificationFileResponse;
|
||||
import me.chanjar.weixin.channel.bean.shop.ShopH5UrlResponse;
|
||||
import me.chanjar.weixin.channel.bean.shop.ShopInfoResponse;
|
||||
import me.chanjar.weixin.channel.bean.shop.ShopQrCodeResponse;
|
||||
import me.chanjar.weixin.channel.bean.shop.ShopTagLinkResponse;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
/**
|
||||
@@ -22,6 +25,31 @@ public interface WxChannelBasicService {
|
||||
*/
|
||||
ShopInfoResponse getShopInfo() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取店铺H5链接
|
||||
*
|
||||
* @return 店铺H5链接
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
ShopH5UrlResponse getShopH5Url() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取店铺二维码
|
||||
*
|
||||
* @param qrcodeType 二维码类型,1:二维码;2:标准物料;3:送礼物物料
|
||||
* @return 店铺二维码
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
ShopQrCodeResponse getShopQrCode(int qrcodeType) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取店铺口令
|
||||
*
|
||||
* @return 店铺口令
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
ShopTagLinkResponse getShopTagLink() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package me.chanjar.weixin.channel.api;
|
||||
|
||||
import me.chanjar.weixin.channel.bean.favorite.FavoriteCountResponse;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
/**
|
||||
* 视频号小店 收藏管理接口
|
||||
*
|
||||
* @author <a href="https://github.com/copilot">GitHub Copilot</a>
|
||||
* @link <a href="https://developers.weixin.qq.com/doc/channels/API/favorite/shopfavorite/">收藏管理接口文档</a>
|
||||
*/
|
||||
public interface WxChannelFavoriteService {
|
||||
|
||||
/**
|
||||
* 获取店铺收藏的人数
|
||||
*
|
||||
* @return 店铺收藏人数响应
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
FavoriteCountResponse getFavoriteCount() throws WxErrorException;
|
||||
}
|
||||
@@ -196,4 +196,11 @@ public interface WxChannelService extends BaseWxChannelService {
|
||||
*/
|
||||
WxTalentService getTalentService();
|
||||
|
||||
/**
|
||||
* 收藏管理服务
|
||||
*
|
||||
* @return 收藏管理服务
|
||||
*/
|
||||
WxChannelFavoriteService getFavoriteService();
|
||||
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ public abstract class BaseWxChannelServiceImpl<H, P> implements WxChannelService
|
||||
private WxChannelLiveDashboardService liveDashboardService = null;
|
||||
private WxChannelQicService qicService = null;
|
||||
private WxTalentService talentService = null;
|
||||
private WxChannelFavoriteService favoriteService = null;
|
||||
|
||||
protected WxChannelConfig config;
|
||||
private int retrySleepMillis = 1000;
|
||||
@@ -491,4 +492,12 @@ public abstract class BaseWxChannelServiceImpl<H, P> implements WxChannelService
|
||||
return talentService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized WxChannelFavoriteService getFavoriteService() {
|
||||
if (favoriteService == null) {
|
||||
favoriteService = new WxChannelFavoriteServiceImpl(this);
|
||||
}
|
||||
return favoriteService;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,10 @@ package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.GET_ADDRESS_CODE;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.GET_IMG_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.GET_SHOP_H5URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.GET_SHOP_INFO;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.GET_SHOP_QRCODE;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.GET_SHOP_TAGLINK;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.IMG_UPLOAD_URL;
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Basics.UPLOAD_QUALIFICATION_FILE;
|
||||
|
||||
@@ -16,7 +19,10 @@ import me.chanjar.weixin.channel.bean.image.ChannelImageInfo;
|
||||
import me.chanjar.weixin.channel.bean.image.ChannelImageResponse;
|
||||
import me.chanjar.weixin.channel.bean.image.QualificationFileResponse;
|
||||
import me.chanjar.weixin.channel.bean.image.UploadImageResponse;
|
||||
import me.chanjar.weixin.channel.bean.shop.ShopH5UrlResponse;
|
||||
import me.chanjar.weixin.channel.bean.shop.ShopInfoResponse;
|
||||
import me.chanjar.weixin.channel.bean.shop.ShopQrCodeResponse;
|
||||
import me.chanjar.weixin.channel.bean.shop.ShopTagLinkResponse;
|
||||
import me.chanjar.weixin.channel.executor.ChannelFileUploadRequestExecutor;
|
||||
import me.chanjar.weixin.channel.executor.ChannelMediaDownloadRequestExecutor;
|
||||
import me.chanjar.weixin.channel.util.ResponseUtils;
|
||||
@@ -93,4 +99,23 @@ public class WxChannelBasicServiceImpl implements WxChannelBasicService {
|
||||
return ResponseUtils.decode(resJson, AddressCodeResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopH5UrlResponse getShopH5Url() throws WxErrorException {
|
||||
String resJson = shopService.post(GET_SHOP_H5URL, "{}");
|
||||
return ResponseUtils.decode(resJson, ShopH5UrlResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopQrCodeResponse getShopQrCode(int qrcodeType) throws WxErrorException {
|
||||
String reqJson = "{\"qrcode_type\":" + qrcodeType + "}";
|
||||
String resJson = shopService.post(GET_SHOP_QRCODE, reqJson);
|
||||
return ResponseUtils.decode(resJson, ShopQrCodeResponse.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopTagLinkResponse getShopTagLink() throws WxErrorException {
|
||||
String resJson = shopService.post(GET_SHOP_TAGLINK, "{}");
|
||||
return ResponseUtils.decode(resJson, ShopTagLinkResponse.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Favorite.GET_FAVORITE_COUNT;
|
||||
|
||||
import me.chanjar.weixin.channel.api.WxChannelFavoriteService;
|
||||
import me.chanjar.weixin.channel.bean.favorite.FavoriteCountResponse;
|
||||
import me.chanjar.weixin.channel.util.ResponseUtils;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
|
||||
/**
|
||||
* 视频号小店 收藏管理接口实现
|
||||
*
|
||||
* @author <a href="https://github.com/copilot">GitHub Copilot</a>
|
||||
*/
|
||||
public class WxChannelFavoriteServiceImpl implements WxChannelFavoriteService {
|
||||
|
||||
/** 微信商店服务 */
|
||||
private final BaseWxChannelServiceImpl<?, ?> shopService;
|
||||
|
||||
public WxChannelFavoriteServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
|
||||
this.shopService = shopService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FavoriteCountResponse getFavoriteCount() throws WxErrorException {
|
||||
String resJson = shopService.post(GET_FAVORITE_COUNT, "{}");
|
||||
return ResponseUtils.decode(resJson, FavoriteCountResponse.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package me.chanjar.weixin.channel.bean.favorite;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
|
||||
/**
|
||||
* 店铺收藏人数 响应
|
||||
*
|
||||
* @author <a href="https://github.com/copilot">GitHub Copilot</a>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class FavoriteCountResponse extends WxChannelBaseResponse {
|
||||
|
||||
/** 店铺首页收藏用户数 */
|
||||
@JsonProperty("favor_uv_acc_shop_homepage")
|
||||
private Long favorUvAccShopHomepage;
|
||||
|
||||
/** 订单详情页收藏用户数 */
|
||||
@JsonProperty("favor_uv_acc_order_detail")
|
||||
private Long favorUvAccOrderDetail;
|
||||
|
||||
/** 商品详情页收藏用户数 */
|
||||
@JsonProperty("favor_uv_acc_product_detail")
|
||||
private Long favorUvAccProductDetail;
|
||||
|
||||
/** 其他场景收藏用户数 */
|
||||
@JsonProperty("favor_uv_acc_other_scene")
|
||||
private Long favorUvAccOtherScene;
|
||||
|
||||
/** 所有收藏用户数 */
|
||||
@JsonProperty("favor_uv_acc_all")
|
||||
private Long favorUvAccAll;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package me.chanjar.weixin.channel.bean.shop;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
|
||||
/**
|
||||
* 店铺H5链接 响应
|
||||
*
|
||||
* @author <a href="https://github.com/copilot">GitHub Copilot</a>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ShopH5UrlResponse extends WxChannelBaseResponse {
|
||||
|
||||
/** 店铺H5链接 */
|
||||
@JsonProperty("shop_h5url")
|
||||
private String shopH5url;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package me.chanjar.weixin.channel.bean.shop;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
|
||||
/**
|
||||
* 店铺二维码 响应
|
||||
*
|
||||
* @author <a href="https://github.com/copilot">GitHub Copilot</a>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ShopQrCodeResponse extends WxChannelBaseResponse {
|
||||
|
||||
/** 店铺二维码链接 */
|
||||
@JsonProperty("shop_qrcode")
|
||||
private String shopQrcode;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package me.chanjar.weixin.channel.bean.shop;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
|
||||
|
||||
/**
|
||||
* 店铺口令 响应
|
||||
*
|
||||
* @author <a href="https://github.com/copilot">GitHub Copilot</a>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ShopTagLinkResponse extends WxChannelBaseResponse {
|
||||
|
||||
/** 店铺微信口令 */
|
||||
@JsonProperty("shop_taglink")
|
||||
private String shopTaglink;
|
||||
}
|
||||
@@ -34,6 +34,19 @@ public class WxChannelApiUrlConstants {
|
||||
String GET_IMG_URL = "https://api.weixin.qq.com/channels/ec/basics/media/get";
|
||||
/** 获取地址编码 */
|
||||
String GET_ADDRESS_CODE = "https://api.weixin.qq.com/channels/ec/basics/addresscode/get";
|
||||
/** 获取店铺H5链接 */
|
||||
String GET_SHOP_H5URL = "https://api.weixin.qq.com/channels/ec/basics/shop/h5url/get";
|
||||
/** 获取店铺二维码 */
|
||||
String GET_SHOP_QRCODE = "https://api.weixin.qq.com/channels/ec/basics/shop/qrcode/get";
|
||||
/** 获取店铺口令 */
|
||||
String GET_SHOP_TAGLINK = "https://api.weixin.qq.com/channels/ec/basics/shop/taglink/get";
|
||||
}
|
||||
|
||||
/** 收藏管理相关接口 */
|
||||
public interface Favorite {
|
||||
|
||||
/** 获取店铺收藏的人数 */
|
||||
String GET_FAVORITE_COUNT = "https://api.weixin.qq.com/channels/ec/favorites/count/get";
|
||||
}
|
||||
|
||||
/** 商品类目相关接口 */
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.channel.api.WxChannelFavoriteService;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.bean.favorite.FavoriteCountResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.channel.util.JsonUtils;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* 收藏管理接口 测试
|
||||
*
|
||||
* @author <a href="https://github.com/copilot">GitHub Copilot</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxChannelFavoriteServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testGetFavoriteCount() throws WxErrorException {
|
||||
WxChannelFavoriteService favoriteService = channelService.getFavoriteService();
|
||||
FavoriteCountResponse response = favoriteService.getFavoriteCount();
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
System.out.println(JsonUtils.encode(response));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package me.chanjar.weixin.channel.api.impl;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import me.chanjar.weixin.channel.api.WxChannelBasicService;
|
||||
import me.chanjar.weixin.channel.api.WxChannelService;
|
||||
import me.chanjar.weixin.channel.bean.shop.ShopH5UrlResponse;
|
||||
import me.chanjar.weixin.channel.bean.shop.ShopQrCodeResponse;
|
||||
import me.chanjar.weixin.channel.bean.shop.ShopTagLinkResponse;
|
||||
import me.chanjar.weixin.channel.test.ApiTestModule;
|
||||
import me.chanjar.weixin.channel.util.JsonUtils;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* 店铺链接接口 测试
|
||||
*
|
||||
* @author <a href="https://github.com/copilot">GitHub Copilot</a>
|
||||
*/
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxChannelShopLinkServiceImplTest {
|
||||
|
||||
@Inject
|
||||
private WxChannelService channelService;
|
||||
|
||||
@Test
|
||||
public void testGetShopH5Url() throws WxErrorException {
|
||||
WxChannelBasicService basicService = channelService.getBasicService();
|
||||
ShopH5UrlResponse response = basicService.getShopH5Url();
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
System.out.println(JsonUtils.encode(response));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetShopQrCode() throws WxErrorException {
|
||||
WxChannelBasicService basicService = channelService.getBasicService();
|
||||
// qrcodeType: 1=二维码, 2=标准物料, 3=送礼物物料
|
||||
ShopQrCodeResponse response = basicService.getShopQrCode(1);
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
System.out.println(JsonUtils.encode(response));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetShopTagLink() throws WxErrorException {
|
||||
WxChannelBasicService basicService = channelService.getBasicService();
|
||||
ShopTagLinkResponse response = basicService.getShopTagLink();
|
||||
assertNotNull(response);
|
||||
assertTrue(response.isSuccess());
|
||||
System.out.println(JsonUtils.encode(response));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user