Skip to content
Merged
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 @@ -109,7 +109,7 @@ public interface WxCpExternalContactService {
* @param userId 外部联系人的userid
* @return . external contact
* @throws WxErrorException the wx error exception
* @deprecated 建议使用 {@link #getContactDetail(String)}
* @deprecated 建议使用 {@link #getContactDetail(String, String)}
*/
@Deprecated
WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorException;
Expand All @@ -130,10 +130,11 @@ public interface WxCpExternalContactService {
* </pre>
*
* @param userId 外部联系人的userid,注意不是企业成员的帐号
* @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
* @return . contact detail
* @throws WxErrorException .
*/
WxCpExternalContactInfo getContactDetail(String userId) throws WxErrorException;
WxCpExternalContactInfo getContactDetail(String userId, String cursor) throws WxErrorException;

/**
* 企业和服务商可通过此接口,将微信外部联系人的userid转为微信openid,用于调用支付相关接口。暂不支持企业微信外部联系人(ExternalUserid为wo开头)的userid转openid。
Expand Down Expand Up @@ -190,7 +191,7 @@ public interface WxCpExternalContactService {
* @throws WxErrorException .
*/
String opengidToChatid(@NotNull String opengid) throws WxErrorException;

/**
* 批量获取客户详情.
* <pre>
Expand Down Expand Up @@ -789,4 +790,31 @@ WxCpGetMomentComments getMomentComments(String momentId, String userId)
* @throws WxErrorException the wx error exception
*/
WxCpBaseResp delGroupWelcomeTemplate(@NotNull String templateId, String agentId) throws WxErrorException;

/**
* <pre>
* 获取商品图册
* https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册列表
* </pre>
*
* @param limit 返回的最大记录数,整型,最大值100,默认值50,超过最大值时取默认值
* @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
WxCpProductAlbumListResult getProductAlbumList(Integer limit, String cursor) throws WxErrorException;

/**
* <pre>
* 获取商品图册
* https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册
* </pre>
*
* @param productId 商品id
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
WxCpProductAlbumResult getProductAlbum(String productId) throws WxErrorException;


}
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ public WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorE
}

@Override
public WxCpExternalContactInfo getContactDetail(String userId) throws WxErrorException {
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CONTACT_DETAIL + userId);
public WxCpExternalContactInfo getContactDetail(String userId, String cursor) throws WxErrorException {
String params = userId;
if(StringUtils.isNotEmpty(cursor)){
params = params + "&cursor=" + cursor;
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CONTACT_DETAIL + params);
String responseContent = this.mainService.get(url, null);
return WxCpExternalContactInfo.fromJson(responseContent);
}
Expand Down Expand Up @@ -702,4 +706,45 @@ public WxCpBaseResp delGroupWelcomeTemplate(@NotNull String templateId, String a
final String result = this.mainService.post(url, json.toString());
return WxCpBaseResp.fromJson(result);
}

/**
* <pre>
* 获取商品图册
* https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册列表
* </pre>
*
* @param limit 返回的最大记录数,整型,最大值100,默认值50,超过最大值时取默认值
* @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
@Override
public WxCpProductAlbumListResult getProductAlbumList(Integer limit, String cursor) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("limit", limit);
json.addProperty("cursor", cursor);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_PRODUCT_ALBUM_LIST);
final String result = this.mainService.post(url, json.toString());
return WxCpProductAlbumListResult.fromJson(result);
}

/**
* <pre>
* 获取商品图册
* https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册
* </pre>
*
* @param productId 商品id
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
@Override
public WxCpProductAlbumResult getProductAlbum(String productId) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("product_id", productId);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_PRODUCT_ALBUM);
final String result = this.mainService.post(url, json.toString());
return WxCpProductAlbumResult.fromJson(result);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package me.chanjar.weixin.cp.bean.external;

import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import me.chanjar.weixin.cp.bean.external.product.Attachment;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

/**
* <pre>
* 获取商品图册
* 参考文档:https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册
* </pre>
*
* @author <a href="https://github.com/Loading-Life">Lo_ading</a>
*/
@Getter
@Setter
public class WxCpProductAlbumInfo implements Serializable {

private static final long serialVersionUID = -8338202601802366899L;

@SerializedName("product_id")
private String productId;

@SerializedName("product_sn")
private String productSn;

@SerializedName("description")
private String description;

/**
* NOTE: 20211110 价钱返回全部为0
*/
@SerializedName("price")
private Integer price;

/**
* NOTE: 20211110 商品列表接口不返回此字段, 商品详情接口返回
*/
@SerializedName("create_time")
private Long createTime;

@SerializedName("attachments")
private List<Attachment> attachments;

public static WxCpProductAlbumInfo fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpProductAlbumInfo.class);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package me.chanjar.weixin.cp.bean.external;

import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

/**
* <pre>
* 获取商品图册列表执行结果
* 参考文档:https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册列表
* </pre>
*
* @author <a href="https://github.com/Loading-Life">Lo_ading</a>
*/
@Getter
@Setter
public class WxCpProductAlbumListResult extends WxCpBaseResp implements Serializable {

private static final long serialVersionUID = 121265727802015428L;

@SerializedName("product_list")
private List<WxCpProductAlbumInfo> productList;

@SerializedName("next_cursor")
private String nextCursor;

public static WxCpProductAlbumListResult fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpProductAlbumListResult.class);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package me.chanjar.weixin.cp.bean.external;

import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Getter;
import lombok.Setter;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

/**
* <pre>
* 获取商品图册执行结果
* 参考文档:https://work.weixin.qq.com/api/doc/90000/90135/95096#获取商品图册
* </pre>
*
* @author <a href="https://github.com/Loading-Life">Lo_ading</a>
*/
@Getter
@Setter
public class WxCpProductAlbumResult extends WxCpBaseResp implements Serializable {

private static final long serialVersionUID = 4076734101839851497L;

@SerializedName("product")
private WxCpProductAlbumInfo product;

public static WxCpProductAlbumResult fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpProductAlbumResult.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,30 @@ public class ExternalContact implements Serializable {
public static class ExternalProfile implements Serializable {
private static final long serialVersionUID = -2899906589789022765L;

@SerializedName("external_corp_name")
private String externalCorpName;

@SerializedName("wechat_channels")
private WechatChannel wechatChannels;

@SerializedName("external_attr")
private List<ExternalAttribute> externalAttrs;
}

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class WechatChannel implements Serializable {

@SerializedName("nickname")
private String nickname;

@SerializedName("status")
private Integer status;

}

@Data
@Builder
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package me.chanjar.weixin.cp.bean.external.product;

import java.io.Serializable;
import lombok.Data;
import me.chanjar.weixin.cp.constant.WxCpConsts;

/**
* 商品画册附件
*
* @author <a href="https://github.com/Loading-Life">Lo_ading</a>
*/
@Data
public class Attachment implements Serializable {

private static final long serialVersionUID = -4545283630169056262L;

/**
* NOTE: 20211110 字段接口未返回
*/
private String type;

/**
* 附件类型,目前仅支持image
*/
private Image image;

public void setImage(Image image) {
this.image = image;
this.type = WxCpConsts.ProductAttachmentType.IMAGE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package me.chanjar.weixin.cp.bean.external.product;

import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Data;

/**
* 商品画册图片
*
* @author <a href="https://github.com/Loading-Life">Lo_ading</a>
*/
@Data
public class Image implements Serializable {

private static final long serialVersionUID = -2737415903252627814L;

@SerializedName("media_id")
private String mediaId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ interface ExternalContact {
String GET_GROUP_MSG_TASK = "/cgi-bin/externalcontact/get_groupmsg_task";
String GET_GROUP_MSG_LIST_V2 = "/cgi-bin/externalcontact/get_groupmsg_list_v2";

String GET_PRODUCT_ALBUM = "/cgi-bin/externalcontact/get_product_album";
String GET_PRODUCT_ALBUM_LIST = "/cgi-bin/externalcontact/get_product_album_list";

String GROUP_WELCOME_TEMPLATE_ADD = "/cgi-bin/externalcontact/group_welcome_template/add";
String GROUP_WELCOME_TEMPLATE_EDIT = "/cgi-bin/externalcontact/group_welcome_template/edit";
String GROUP_WELCOME_TEMPLATE_GET = "/cgi-bin/externalcontact/group_welcome_template/get";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,15 @@ public static class WelcomeMsgType {
*/
public static final String FILE = "file";
}

@UtilityClass
public static class ProductAttachmentType {

/**
* 图片消息.
*/
public static final String IMAGE = "image";

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.testng.collections.CollectionUtils;

import static org.testng.Assert.assertNotNull;

Expand Down Expand Up @@ -111,7 +112,7 @@ public void testListExternalWithPermission() throws WxErrorException {
@Test
public void testGetContactDetail() throws WxErrorException {
String externalUserId = this.configStorage.getExternalUserId();
WxCpExternalContactInfo result = this.wxCpService.getExternalContactService().getContactDetail(externalUserId);
WxCpExternalContactInfo result = this.wxCpService.getExternalContactService().getContactDetail(externalUserId, null);
System.out.println(result);
assertNotNull(result);
}
Expand Down Expand Up @@ -314,4 +315,18 @@ public void testUpdateRemark() throws WxErrorException {
.remarkPicMediaId("aaa")
.build());
}

@Test
public void testGetProductListAlbum() throws WxErrorException {
WxCpProductAlbumListResult result = this.wxCpService.getExternalContactService()
.getProductAlbumList(100, null);
System.out.println(result);
assertNotNull(result);
if(CollectionUtils.hasElements(result.getProductList())){
WxCpProductAlbumResult result1 = this.wxCpService.getExternalContactService().getProductAlbum(result.getProductList().get(0).getProductId());
System.out.println(result1);
assertNotNull(result1);
}
}

}