repo
stringclasses
1k values
file_url
stringlengths
96
373
file_path
stringlengths
11
294
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
6 values
commit_sha
stringclasses
1k values
retrieved_at
stringdate
2026-01-04 14:45:56
2026-01-04 18:30:23
truncated
bool
2 classes
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMediaImgUploadResult.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMediaImgUploadResult.java
package me.chanjar.weixin.mp.bean.material; import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; /** * @author miller */ @Data public class WxMediaImgUploadResult implements Serializable { private static final long serialVersionUID = 1996392453428768829L; private String url; public static WxMediaImgUploadResult fromJson(String json) { return WxMpGsonBuilder.create().fromJson(json, WxMediaImgUploadResult.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialCountResult.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialCountResult.java
package me.chanjar.weixin.mp.bean.material; import java.io.Serializable; import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; /** * @author codepiano */ @Data public class WxMpMaterialCountResult implements Serializable { private static final long serialVersionUID = -5568772662085874138L; private int voiceCount; private int videoCount; private int imageCount; private int newsCount; @Override public String toString() { return WxMpGsonBuilder.create().toJson(this); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialNewsBatchGetResult.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialNewsBatchGetResult.java
package me.chanjar.weixin.mp.bean.material; import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; import java.util.Date; import java.util.List; @Data public class WxMpMaterialNewsBatchGetResult implements Serializable { private static final long serialVersionUID = -1617952797921001666L; private int totalCount; private int itemCount; private List<WxMaterialNewsBatchGetNewsItem> items; @Override public String toString() { return WxMpGsonBuilder.create().toJson(this); } @Data public static class WxMaterialNewsBatchGetNewsItem implements Serializable { private static final long serialVersionUID = -5227864606579602345L; private String mediaId; private Date updateTime; private WxMpMaterialNews content; @Override public String toString() { return WxMpGsonBuilder.create().toJson(this); } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialVideoInfoResult.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialVideoInfoResult.java
package me.chanjar.weixin.mp.bean.material; import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.Serializable; @Data public class WxMpMaterialVideoInfoResult implements Serializable { private static final long serialVersionUID = 1269131745333792202L; private String title; private String description; private String downUrl; public static WxMpMaterialVideoInfoResult fromJson(String json) { return WxMpGsonBuilder.create().fromJson(json, WxMpMaterialVideoInfoResult.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialNews.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialNews.java
package me.chanjar.weixin.mp.bean.material; import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import java.util.List; import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; /** * 图文素材. * * @author codepiano */ @Data public class WxMpMaterialNews implements Serializable { private static final long serialVersionUID = -3283203652013494976L; private Date createTime; private Date updateTime; private List<WxMpNewsArticle> articles = new ArrayList<>(); public List<WxMpNewsArticle> getArticles() { return this.articles; } public void addArticle(WxMpNewsArticle article) { this.articles.add(article); } public String toJson() { return WxMpGsonBuilder.create().toJson(this); } public boolean isEmpty() { return this.articles == null || this.articles.isEmpty(); } @Override public String toString() { return this.toJson(); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterial.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterial.java
package me.chanjar.weixin.mp.bean.material; import lombok.Data; import java.io.File; import java.io.Serializable; import java.util.HashMap; import java.util.Map; @Data public class WxMpMaterial implements Serializable { private static final long serialVersionUID = -1651816949780969485L; private String name; private File file; private String videoTitle; private String videoIntroduction; public WxMpMaterial() { } public WxMpMaterial(String name, File file, String videoTitle, String videoIntroduction) { this.name = name; this.file = file; this.videoTitle = videoTitle; this.videoIntroduction = videoIntroduction; } public Map<String, String> getForm() { Map<String, String> form = new HashMap<>(); form.put("title", this.videoTitle); form.put("introduction", this.videoIntroduction); return form; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialUploadResult.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/material/WxMpMaterialUploadResult.java
package me.chanjar.weixin.mp.bean.material; import java.io.Serializable; import lombok.Data; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; @Data public class WxMpMaterialUploadResult implements Serializable { private static final long serialVersionUID = -128818731449449537L; private String mediaId; private String url; private Integer errCode; private String errMsg; public static WxMpMaterialUploadResult fromJson(String json) { return WxMpGsonBuilder.create().fromJson(json, WxMpMaterialUploadResult.class); } @Override public String toString() { return WxMpGsonBuilder.create().toJson(this); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishItem.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishItem.java
package me.chanjar.weixin.mp.bean.freepublish; import com.google.gson.annotations.SerializedName; import lombok.Data; import lombok.NoArgsConstructor; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 发布列表的一条记录 * * @author dragon * created on 2021-10-23 */ @NoArgsConstructor @Data public class WxMpFreePublishItem implements Serializable { private static final long serialVersionUID = -6435229818150835883L; /** * 成功发布的图文消息id */ @SerializedName("article_id") private String articleId; /** * 图文消息的具体内容,支持HTML标签,必须少于2万字符,小于1M,且此处会去除JS。 */ @SerializedName("content") private WxMpFreePublishInfo content; /** * 这篇图文消息素材的最后更新时间 */ @SerializedName("update_time") private String updateTime; public static WxMpFreePublishItem fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpFreePublishItem.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishInfo.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishInfo.java
package me.chanjar.weixin.mp.bean.freepublish; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; import java.util.List; /** * 发布能力-通过 article_id 获取已发布文章. * * @author dragon * created on 2021-10-23 */ @Data @Builder @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor public class WxMpFreePublishInfo implements ToJson, Serializable { private static final long serialVersionUID = 3331288672996730705L; /** * 文章列表 */ @SerializedName("news_item") private List<WxMpFreePublishArticles> newsItem; public static WxMpFreePublishInfo fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpFreePublishInfo.class); } @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishList.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishList.java
package me.chanjar.weixin.mp.bean.freepublish; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; import java.util.List; /** * 发布能力-获取成功发布列表. * * @author dragon * created on 2021-10-22 */ @Data public class WxMpFreePublishList implements Serializable { private static final long serialVersionUID = 764054773431665250L; /** * 成功发布素材的总数 */ @SerializedName("total_count") private Integer totalCount; /** * 本次调用获取的素材的数量 */ @SerializedName("item_count") private Integer itemCount; /** * 所有成功发布列表 */ @SerializedName("item") private List<WxMpFreePublishItem> items; public static WxMpFreePublishList fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpFreePublishList.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishArticles.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishArticles.java
package me.chanjar.weixin.mp.bean.freepublish; import com.google.gson.annotations.SerializedName; import lombok.Data; import lombok.NoArgsConstructor; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 一条发布的图文记录 * * @author dragon * created on 2021-10-23 */ @NoArgsConstructor @Data public class WxMpFreePublishArticles implements Serializable { private static final long serialVersionUID = -6435229818150835883L; /** * 标题 */ @SerializedName("title") private String title; /** * 作者 */ @SerializedName("author") private String author; /** * 图文消息的摘要,仅有单图文消息才有摘要,多图文此处为空。 */ @SerializedName("digest") private String digest; /** * 图文消息的具体内容,支持HTML标签,必须少于2万字符,小于1M,且此处会去除JS */ @SerializedName("content") private String content; /** * 图文消息的原文地址,即点击“阅读原文”后的URL */ @SerializedName("content_source_url") private String contentSourceUrl; /** * 图文消息的封面图片素材id(一定是永久MediaID) */ @SerializedName("thumb_media_id") private String thumbMediaId; /** * 是否显示封面,0为false,即不显示,1为true,即显示(默认) */ @SerializedName("show_cover_pic") private Integer showCoverPic; /** * 是否打开评论,0不打开(默认),1打开 */ @SerializedName("need_open_comment") private Integer needOpenComment; /** * 是否粉丝才可评论,0所有人可评论(默认),1粉丝才可评论 */ @SerializedName("only_fans_can_comment") private Integer onlyFansCanComment; /** * 图文消息的封面url */ @SerializedName("thumb_url") private String thumbUrl; /* * ===== 上面的参数,就是草稿箱的内容的字段,为了后续扩展,单独写一份==== */ /** * 草稿的临时链接 */ @SerializedName("url") private String url; /** * 该图文是否被删除 */ @SerializedName("is_deleted") private Boolean isDeleted; public static WxMpFreePublishArticles fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpFreePublishArticles.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishStatus.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/freepublish/WxMpFreePublishStatus.java
package me.chanjar.weixin.mp.bean.freepublish; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; import java.util.List; /** * 发布能力-发布状态轮询接口,通过publishId返回 article_id(删除发布时需要用到). * * @author dragon * created on 2021-10-23 */ @Data @Builder @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor public class WxMpFreePublishStatus implements ToJson, Serializable { private static final long serialVersionUID = -7526369389476785732L; private String publish_id; private Integer publish_status; private String article_id; private ArticleDetail article_detail; private List<Integer> fail_idx; public static WxMpFreePublishStatus fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpFreePublishStatus.class); } @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } @NoArgsConstructor @Data public static class ArticleDetail implements Serializable{ private static final long serialVersionUID = 2802949203075628412L; private Integer count; private List<Item> item; @NoArgsConstructor @Data public static class Item implements Serializable{ private static final long serialVersionUID = -6496102084844816489L; private Integer idx; private String article_url; } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroup.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroup.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 顾问分组信息 * * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/8/008 */ @Data public class WxMpGuideGroup implements ToJson, Serializable { private static final long serialVersionUID = 6235142804489175294L; /** * 顾问分组id */ @SerializedName("id") private Long id; /** * 顾问分组名称 */ @SerializedName("name") private String name; /** * 创建时间戳 */ @SerializedName("create_time") private Long createTime; /** * 更新时间戳 */ @SerializedName("update_time") private Long updateTime; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideGroup fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideGroup.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideList.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideList.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; import java.util.List; /** * 顾问列表. * * @author <a href="https://github.com/binarywang">Binary Wang</a> * created on 2020-10-07 */ @Data public class WxMpGuideList implements Serializable { private static final long serialVersionUID = 144044550239346216L; /** * 顾问总数量 */ @SerializedName("total_num") private Integer totalNum; /** * 顾问列表 */ private List<WxMpGuideInfo> list; public static WxMpGuideList fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideList.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerInfo.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerInfo.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 客户信息 * * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/10/010 */ @Data @Builder @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor public class WxMpGuideBuyerInfo implements ToJson, Serializable { private static final long serialVersionUID = -8076715937378141119L; /** * 客户的openId */ @SerializedName("openid") private String openid; /** * 客户的名称 */ @SerializedName("buyer_nickname") private String nickname; /** * 创建时间戳 */ @SerializedName("create_time") private Long createTime; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideBuyerInfo fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideBuyerInfo.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideWordMaterialInfo.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideWordMaterialInfo.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** 文字素材信息 * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/12/012 */ @Data public class WxMpGuideWordMaterialInfo implements ToJson, Serializable { private static final long serialVersionUID = -1370377663251409658L; /** * 文字内容 */ @SerializedName("word") private String word; /** * 创建时间戳 */ @SerializedName("create_time") private Long createTime; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideWordMaterialInfo fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideWordMaterialInfo.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassedInfo.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassedInfo.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.JsonElement; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; import java.util.List; /** * 群发任务信息 * * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/13/013 */ @Data public class WxMpGuideMassedInfo implements ToJson, Serializable { private static final long serialVersionUID = -6120573244255111822L; /** * 任务id */ @SerializedName("task_id") private String taskId; /** * 顾问openid */ @SerializedName("guide_openid") private String openid; /** * 任务创建时间 */ @SerializedName("create_time") private Long createTime; /** * 任务最后修改时间 */ @SerializedName("update_time") private Long updateTime; /** * 任务下发时间 */ @SerializedName("push_time") private Long pushTime; /** * 任务完成时间 */ @SerializedName("finish_time") private Long finishTime; /** * 任务名称 */ @SerializedName("task_name") private String taskName; /** * 任务备注 */ @SerializedName("task_remark") private String taskRemark; /** * 任务状态(1.任务未执行 2.已执行 3.执行完成 4.任务取消) */ @SerializedName("task_status") private int taskStatus; /** * 素材 */ @SerializedName("material") private List<WxMpGuideMaterialInfo> material; /** * 客户列表 */ @SerializedName("buyer_info") private List<WxMpGuideMassedBuyerInfo> buyerInfos; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static <T> WxMpGuideMassedInfo fromJson(T json) { if (json instanceof String) { return WxGsonBuilder.create().fromJson((String) json, WxMpGuideMassedInfo.class); } else if (json instanceof JsonElement) { return WxGsonBuilder.create().fromJson((JsonElement) json, WxMpGuideMassedInfo.class); } return null; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideCardMaterialInfo.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideCardMaterialInfo.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 小程序素材信息 * * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/12/012 */ @Data public class WxMpGuideCardMaterialInfo implements ToJson, Serializable { private static final long serialVersionUID = -3165724834271407258L; /** * 卡片名字 */ @SerializedName("title") private String title; /** * 小程序appid */ @SerializedName("appid") private String appId; /** * 路径 */ @SerializedName("path") private String path; /** * 图片链接 */ @SerializedName("picurl") private String picUrl; /** * 图片id */ @SerializedName("master_id") private Long masterId; /** * 图片id */ @SerializedName("slave_id") private Long slaveId; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideCardMaterialInfo fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideCardMaterialInfo.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideAcctConfig.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideAcctConfig.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 离线自动回复与敏感词 * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/8/008 */ @Data public class WxMpGuideAcctConfig implements Serializable { private static final long serialVersionUID = -5941249630655543648L; /** * 敏感词 */ @SerializedName("black_keyword") private WxMpGuideSensitiveWords guideSensitiveWords; /** * 离线自动回复内容 */ @SerializedName("guide_auto_reply") private WxMpGuideOffLineReply guideOffLineReply; public static WxMpGuideAcctConfig fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideAcctConfig.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideImgMaterialInfo.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideImgMaterialInfo.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 图片素材信息 * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/12/012 */ @Data public class WxMpGuideImgMaterialInfo implements ToJson, Serializable { private static final long serialVersionUID = 9165977127399850455L; /** * 图片链接 */ @SerializedName("picurl") private String picUrl; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideImgMaterialInfo fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideImgMaterialInfo.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerInfoList.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerInfoList.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; import java.util.List; /** * 顾问的客户列表 * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/11/011 */ @Data public class WxMpGuideBuyerInfoList implements Serializable { private static final long serialVersionUID = 9094928050460133322L; /** * 客户总数量 */ @SerializedName("total_num") private Integer totalNum; /** * 客户列表 */ private List<WxMpGuideBuyerInfo> list; public static WxMpGuideBuyerInfoList fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideBuyerInfoList.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideConfig.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideConfig.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; import java.util.List; /** * 获取快捷回复,关注顾问自动回复返回类 * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/8/008 */ @Data public class WxMpGuideConfig implements Serializable { private static final long serialVersionUID = -343579331927473027L; /** * 快捷回复列表 */ @SerializedName("guide_fast_reply_list") private List<WxMpGuideFastReply> guideFastReplyList; /** * 第一条关注顾问自动回复(欢迎语) */ @SerializedName("guide_auto_reply") private WxMpGuideAutoReply guideAutoReply; /** * 第二条关注顾问自动回复(欢迎语) */ @SerializedName("guide_auto_reply_plus") private WxMpGuideAutoReply guideAutoReplyPlus; public static WxMpGuideConfig fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideConfig.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideOffLineReply.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideOffLineReply.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 离线自动回复 * * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/8/008 */ @Data @Builder @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor public class WxMpGuideOffLineReply implements ToJson, Serializable { private static final long serialVersionUID = 1337376246361830706L; /** * 离线自动回复内容 */ @SerializedName("content") private String content; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideOffLineReply fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideOffLineReply.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideInfo.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideInfo.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 对话能力-顾问信息. * * @author <a href="https://github.com/binarywang">Binary Wang</a> * created on 2020-10-06 */ @Data @Builder @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor public class WxMpGuideInfo implements ToJson, Serializable { private static final long serialVersionUID = -8159470115679031290L; /** * 顾问的微信帐号 */ @SerializedName("guide_account") private String account; /** * 顾问的openid或者unionid */ @SerializedName("guide_openid") private String openid; /** * 顾问昵称 */ @SerializedName("guide_nickname") private String nickName; /** * 顾问头像 */ @SerializedName("guide_headimgurl") private String headImgUrl; /** * 顾问状态(1:确认中;2已确认;3已拒绝;4已过期) */ @SerializedName("status") private Integer status; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideInfo fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideInfo.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideFastReply.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideFastReply.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 顾问快捷回复 * * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/8/008 */ @Data public class WxMpGuideFastReply implements ToJson, Serializable { private static final long serialVersionUID = -3316181204068248972L; /** * 快捷回复内容 */ @SerializedName("content") private String content; /** * 修改时间 */ @SerializedName("updatetime") private Long updateTime; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideFastReply fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideFastReply.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideSensitiveWords.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideSensitiveWords.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 顾问敏感词 * * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/8/008 */ @Data public class WxMpGuideSensitiveWords implements ToJson, Serializable { private static final long serialVersionUID = 1546603590395563048L; /** * 敏感词数组 */ @SerializedName("values") private String[] values; /** * 修改时间 */ @SerializedName("updatetime") private Long updateTime; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideSensitiveWords fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideSensitiveWords.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpAddGuideAutoReply.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpAddGuideAutoReply.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.Data; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 关注顾问自动回复(欢迎语)添加实体 * * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/8/008 */ @Data @Builder public class WxMpAddGuideAutoReply implements ToJson, Serializable { private static final long serialVersionUID = -3364721434924095836L; /** * 新客户关注自动回复内容 */ @SerializedName("content") private String content; /** * 新客户关注自动回复内容类型 * 1表示文字,2表示图片,3表示小程序卡片 */ @SerializedName("msgtype") private Integer msgType; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpAddGuideAutoReply fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpAddGuideAutoReply.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideImgMaterialInfoList.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideImgMaterialInfoList.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; import java.util.List; /** * 图片素材列表 * * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/12/012 */ @Data public class WxMpGuideImgMaterialInfoList implements Serializable { private static final long serialVersionUID = 8876840664010690223L; /** * 图片素材总数 */ @SerializedName("total_num") private Integer totalNum; /** * 图片素材列表 */ @SerializedName("model_list") private List<WxMpGuideImgMaterialInfo> list; public static WxMpGuideImgMaterialInfoList fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideImgMaterialInfoList.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideWordMaterialInfoList.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideWordMaterialInfoList.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; import java.util.List; /** * 文字素材信息列表 * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/12/012 */ @Data public class WxMpGuideWordMaterialInfoList implements Serializable { private static final long serialVersionUID = 6891519244712898267L; /** * 文字素材总数 */ @SerializedName("total_num") private Integer totalNum; /** * 文字素材列表 */ @SerializedName("word_list") private List<WxMpGuideWordMaterialInfo> list; public static WxMpGuideWordMaterialInfoList fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideWordMaterialInfoList.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMaterialInfo.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMaterialInfo.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.Data; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 素材信息 * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/13/013 */ @Data @Builder public class WxMpGuideMaterialInfo implements ToJson, Serializable { private static final long serialVersionUID = -6201520701655588983L; /** * 素材类型,1.文本,3.图片,49.小程序卡片 */ @SerializedName("type") private int type; /** * 图片类型素材或者卡片类型素材的封面,只能用《素材管理获取media_id》(注意目前只能用临时素材的media_id) */ @SerializedName("media_id") private String mediaId; /** * 小程序卡片标题,最多35字 */ @SerializedName("title") private String title; /** * 小程序卡片路径 */ @SerializedName("path") private String path; /** * 小程序卡片appid,需要关联到公众号 */ @SerializedName("appid") private String appId; /** * 文本类型素材的内容,不超过300字节 */ @SerializedName("word") private String word; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideMaterialInfo fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideMaterialInfo.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerResp.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerResp.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 批量操作客户是否成功返回信息 * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/10/010 */ @Data public class WxMpGuideBuyerResp implements ToJson, Serializable { private static final long serialVersionUID = -5628199106867822424L; /** * 错误码 */ @SerializedName("errcode") private Integer errCode; /** * 错误信息 */ @SerializedName("errmsg") private String errMsg; /** * 客户openid */ @SerializedName("openid") private String openid; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideBuyerResp fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideBuyerResp.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMsg.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMsg.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 顾问聊天记录 * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/7/007 */ @Data @Builder @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor public class WxMpGuideMsg implements ToJson, Serializable { private static final long serialVersionUID = -5175162334221904778L; /** * 顾问的微信帐号 */ @SerializedName("guide_account") private String account; /** * 顾问的openid或者unionid */ @SerializedName("guide_openid") private String openid; /** * 聊天记录生成时间 */ @SerializedName("create_time") private Long createTime; /** * 聊天内容 */ @SerializedName("content") private String content; /** * 聊天记录类型 * * 1 文字类型 * 3 图片类型 * 49 小程序卡片类型 */ @SerializedName("content_type") private Integer contentType; /** * 消息指向 * * 1 顾问发送消息给客户 * 2 客户发送消息给顾问 */ @SerializedName("direction") private Integer direction; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideMsg fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideMsg.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroupInfoList.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroupInfoList.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; import java.util.List; /** * 顾问分组内顾问信息 * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/8/008 */ @Data public class WxMpGuideGroupInfoList implements Serializable { private static final long serialVersionUID = 7037631524066068497L; /** * 分组顾问总数量 */ @SerializedName("total_num") private Integer totalNum; /** * 分组顾问列表 */ @SerializedName("guide_list") private List<WxMpGuideGroupInfo> list; public static WxMpGuideGroupInfoList fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideGroupInfoList.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroupInfo.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideGroupInfo.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 分组顾问信息. * * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/8/008 */ @Data @Builder @Accessors(chain = true) @NoArgsConstructor @AllArgsConstructor public class WxMpGuideGroupInfo implements ToJson, Serializable { private static final long serialVersionUID = -4927568853154487513L; /** * 顾问的微信帐号 */ @SerializedName("guide_account") private String account; /** * 顾问的openid或者unionid */ @SerializedName("guide_openid") private String openid; /** * 顾问昵称 */ @SerializedName("guide_nickname") private String nickName; /** * 顾问头像 */ @SerializedName("guide_headimgurl") private String headImgUrl; /** * 创建时间戳 */ @SerializedName("create_time") private Long createTime; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideGroupInfo fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideGroupInfo.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMsgList.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMsgList.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; import java.util.List; /** * 顾问聊天记录列表 * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/7/007 */ @Data public class WxMpGuideMsgList implements Serializable { private static final long serialVersionUID = -4041549590019624417L; /** * 顾问聊天记录总数量 */ @SerializedName("total_num") private Integer totalNum; /** * 顾问聊天记录列表 */ @SerializedName("msg_list") private List<WxMpGuideMsg> msgList; public static WxMpGuideMsgList fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideMsgList.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassed.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassed.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.JsonElement; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; import java.util.List; /** * 添加群发任务返回值 * * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/13/013 */ @Data public class WxMpGuideMassed implements ToJson, Serializable { private static final long serialVersionUID = 7049976499427665050L; @SerializedName("task_id") private Long taskId; @SerializedName("openid") private List<String> list; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static <T> WxMpGuideMassed fromJson(T json) { if (json instanceof String) { return WxGsonBuilder.create().fromJson((String) json, WxMpGuideMassed.class); } else if (json instanceof JsonElement) { return WxGsonBuilder.create().fromJson((JsonElement) json, WxMpGuideMassed.class); } return null; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerRelation.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideBuyerRelation.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 客户顾问关系 * * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/11/011 */ @Data public class WxMpGuideBuyerRelation implements ToJson, Serializable { private static final long serialVersionUID = 1531261524650705552L; /** * 顾问的微信帐号 */ @SerializedName("guide_account") private String guideAccount; /** * 顾问的openid或者unionid */ @SerializedName("guide_openid") private String guideOpenid; /** * 客户的openId */ @SerializedName("openid") private String openid; /** * 客户的名称 */ @SerializedName("buyer_nickname") private String nickname; /** * 创建时间戳 */ @SerializedName("create_time") private Long createTime; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideBuyerRelation fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideBuyerRelation.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideAutoReply.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideAutoReply.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 关注顾问自动回复(欢迎语) * * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/8/008 */ @Data public class WxMpGuideAutoReply implements ToJson, Serializable { private static final long serialVersionUID = -3584275317132197695L; /** * 新客户关注自动回复内容 */ @SerializedName("content") private String content; /** * 新客户关注自动回复内容类型 * 1表示文字,2表示图片,3表示小程序卡片 */ @SerializedName("msgtype") private Integer msgType; /** * 修改时间 */ @SerializedName("updatetime") private Long updateTime; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideAutoReply fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideAutoReply.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpAddGuideBuyerInfo.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpAddGuideBuyerInfo.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Builder; import lombok.Data; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 客户信息dto * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/11/011 */ @Data @Builder public class WxMpAddGuideBuyerInfo implements ToJson, Serializable { private static final long serialVersionUID = -1703303970552268691L; /** * 客户的openId */ @SerializedName("openid") private String openid; /** * 客户的名称 */ @SerializedName("buyer_nickname") private String nickname; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpAddGuideBuyerInfo fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpAddGuideBuyerInfo.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideTagInfo.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideTagInfo.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; import java.util.List; /** * 标签信息 * * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/11/011 */ @Data public class WxMpGuideTagInfo implements ToJson, Serializable { private static final long serialVersionUID = 2086445319422158695L; /** * 标签类型名称 */ @SerializedName("tag_name") private String tagName; /** * 标签值 */ @SerializedName("tag_values") private List<String> values; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideTagInfo fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideTagInfo.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassedBuyerInfo.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideMassedBuyerInfo.java
package me.chanjar.weixin.mp.bean.guide; import com.google.gson.annotations.SerializedName; import lombok.Data; import me.chanjar.weixin.common.bean.ToJson; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; /** * 下方客户状态信息 * * @author <a href="https://www.sacoc.cn">广州跨界-宋心成</a> * created on 2021/5/13/013 */ @Data public class WxMpGuideMassedBuyerInfo implements ToJson, Serializable { private static final long serialVersionUID = -7433816414896345471L; /** * 客户openid */ @SerializedName("openid") private String openid; /** * 消息发送状态(1.未发送 2.发送成功 3.未关注公众号 4.没有quota(没有发送机会) 5.系统错误) */ @SerializedName("send_status") private int sendStatus; @Override public String toJson() { return WxGsonBuilder.create().toJson(this); } public static WxMpGuideMassedBuyerInfo fromJson(String json) { return WxGsonBuilder.create().fromJson(json, WxMpGuideMassedBuyerInfo.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/WxMpHostConfig.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/WxMpHostConfig.java
package me.chanjar.weixin.mp.config; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.io.Serializable; /** * 微信接口地址域名部分的自定义设置信息. * * @author <a href="https://github.com/binarywang">Binary Wang</a> * created on 2019-06-09 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxMpHostConfig implements Serializable { public static final String API_DEFAULT_HOST_URL = "https://api.weixin.qq.com"; public static final String MP_DEFAULT_HOST_URL = "https://mp.weixin.qq.com"; public static final String OPEN_DEFAULT_HOST_URL = "https://open.weixin.qq.com"; private static final long serialVersionUID = 6998547464242356375L; /** * 对应于:https://api.weixin.qq.com */ private String apiHost; /** * 对应于:https://open.weixin.qq.com */ private String openHost; /** * 对应于:https://mp.weixin.qq.com */ private String mpHost; public static String buildUrl(WxMpHostConfig hostConfig, String prefix, String path) { if (hostConfig == null) { return prefix + path; } if (hostConfig.getApiHost() != null && prefix.equals(API_DEFAULT_HOST_URL)) { return hostConfig.getApiHost() + path; } if (hostConfig.getMpHost() != null && prefix.equals(MP_DEFAULT_HOST_URL)) { return hostConfig.getMpHost() + path; } if (hostConfig.getOpenHost() != null && prefix.equals(OPEN_DEFAULT_HOST_URL)) { return hostConfig.getOpenHost() + path; } return prefix + path; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/WxMpConfigStorage.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/WxMpConfigStorage.java
package me.chanjar.weixin.mp.config; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.enums.TicketType; import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; import java.io.File; import java.util.concurrent.locks.Lock; /** * 微信客户端配置存储. * * @author chanjarster */ public interface WxMpConfigStorage { /** * Gets access token. * * @return the access token */ String getAccessToken(); /** * Is use stable access token api * * @return the boolean * @link https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/getStableAccessToken.html */ boolean isStableAccessToken(); /** * Set use stable access token api * * @param useStableAccessToken true is use, false is not */ void useStableAccessToken(boolean useStableAccessToken); /** * Gets access token lock. * * @return the access token lock */ Lock getAccessTokenLock(); /** * Is access token expired boolean. * * @return the boolean */ boolean isAccessTokenExpired(); /** * 强制将access token过期掉. */ void expireAccessToken(); /** * 应该是线程安全的. * * @param accessToken 要更新的WxAccessToken对象 */ void updateAccessToken(WxAccessToken accessToken); /** * 应该是线程安全的. * * @param accessToken 新的accessToken值 * @param expiresInSeconds 过期时间,以秒为单位 */ void updateAccessToken(String accessToken, int expiresInSeconds); /** * Gets ticket. * * @param type the type * @return the ticket */ String getTicket(TicketType type); /** * Gets ticket lock. * * @param type the type * @return the ticket lock */ Lock getTicketLock(TicketType type); /** * Is ticket expired boolean. * * @param type the type * @return the boolean */ boolean isTicketExpired(TicketType type); /** * 强制将ticket过期掉. * * @param type the type */ void expireTicket(TicketType type); /** * 更新ticket. * 应该是线程安全的 * * @param type ticket类型 * @param ticket 新的ticket值 * @param expiresInSeconds 过期时间,以秒为单位 */ void updateTicket(TicketType type, String ticket, int expiresInSeconds); /** * Gets app id. * * @return the app id */ String getAppId(); /** * Gets secret. * * @return the secret */ String getSecret(); /** * Gets token. * * @return the token */ String getToken(); /** * Gets aes key. * * @return the aes key */ String getAesKey(); /** * Gets template id. * * @return the template id */ String getTemplateId(); /** * Gets expires time. * * @return the expires time */ long getExpiresTime(); /** * Gets oauth 2 redirect uri. * * @return the oauth 2 redirect uri * @deprecated This method is deprecated due to incorrect naming convention. * Use {@link #getOauth2RedirectUrl()} instead. */ @Deprecated String getOauth2redirectUri(); /** * Gets OAuth 2.0 redirect Url * * @return the OAuth 2.0 redirect Url * @author <a href="https://gitee.com/pengles">Peng Les</a> */ String getOauth2RedirectUrl(); /** * Gets QR connect redirect Url * * @return the QR connect redirect Url * @author <a href="https://gitee.com/pengles">Peng Les</a> */ String getQrConnectRedirectUrl(); /** * Gets http proxy host. * * @return the http proxy host */ String getHttpProxyHost(); /** * Gets http proxy port. * * @return the http proxy port */ int getHttpProxyPort(); /** * Gets http proxy username. * * @return the http proxy username */ String getHttpProxyUsername(); /** * Gets http proxy password. * * @return the http proxy password */ String getHttpProxyPassword(); /** * http 请求重试间隔 * <pre> * {@link me.chanjar.weixin.mp.api.impl.BaseWxMpServiceImpl#setRetrySleepMillis(int)} * </pre> */ int getRetrySleepMillis(); /** * http 请求最大重试次数 * <pre> * {@link me.chanjar.weixin.mp.api.impl.BaseWxMpServiceImpl#setMaxRetryTimes(int)} * </pre> */ int getMaxRetryTimes(); /** * Gets tmp dir file. * * @return the tmp dir file */ File getTmpDirFile(); /** * http client builder. * * @return ApacheHttpClientBuilder apache http client builder */ ApacheHttpClientBuilder getApacheHttpClientBuilder(); /** * 是否自动刷新token. * * @return the boolean */ boolean autoRefreshToken(); /** * 得到微信接口地址域名部分的自定义设置信息. * * @return the host config */ WxMpHostConfig getHostConfig(); /** * 设置微信接口地址域名部分的自定义设置信息. * * @param hostConfig host config */ void setHostConfig(WxMpHostConfig hostConfig); }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpRedissonConfigImpl.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpRedissonConfigImpl.java
package me.chanjar.weixin.mp.config.impl; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; import me.chanjar.weixin.common.enums.TicketType; import me.chanjar.weixin.common.redis.RedissonWxRedisOps; import me.chanjar.weixin.common.redis.WxRedisOps; import org.redisson.api.RedissonClient; import java.util.concurrent.TimeUnit; /** * @author wuxingye * created on 2020/6/12 */ @EqualsAndHashCode(callSuper = true) @Data public class WxMpRedissonConfigImpl extends WxMpDefaultConfigImpl { private static final long serialVersionUID = -5139855123878455556L; private static final String ACCESS_TOKEN_KEY_TPL = "%s:access_token:%s"; private static final String TICKET_KEY_TPL = "%s:ticket:key:%s:%s"; private static final String LOCK_KEY_TPL = "%s:lock:%s:"; private final WxRedisOps redisOps; private final String keyPrefix; private String accessTokenKey; private String lockKey; public WxMpRedissonConfigImpl(@NonNull RedissonClient redissonClient, String keyPrefix) { this(new RedissonWxRedisOps(redissonClient), keyPrefix); } public WxMpRedissonConfigImpl(@NonNull RedissonClient redissonClient) { this(redissonClient, null); } private WxMpRedissonConfigImpl(@NonNull WxRedisOps redisOps, String keyPrefix) { this.redisOps = redisOps; this.keyPrefix = keyPrefix; } /** * 每个公众号生成独有的存储key. */ @Override public void setAppId(String appId) { super.setAppId(appId); this.accessTokenKey = String.format(ACCESS_TOKEN_KEY_TPL, this.keyPrefix, appId); this.lockKey = String.format(LOCK_KEY_TPL, this.keyPrefix, appId); accessTokenLock = this.redisOps.getLock(lockKey.concat("accessTokenLock")); jsapiTicketLock = this.redisOps.getLock(lockKey.concat("jsapiTicketLock")); sdkTicketLock = this.redisOps.getLock(lockKey.concat("sdkTicketLock")); cardApiTicketLock = this.redisOps.getLock(lockKey.concat("cardApiTicketLock")); } private String getTicketRedisKey(TicketType type) { return String.format(TICKET_KEY_TPL, this.keyPrefix, appId, type.getCode()); } @Override public String getAccessToken() { return redisOps.getValue(this.accessTokenKey); } @Override public boolean isAccessTokenExpired() { Long expire = redisOps.getExpire(this.accessTokenKey); return expire == null || expire < 2; } @Override public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) { redisOps.setValue(this.accessTokenKey, accessToken, expiresInSeconds - 200, TimeUnit.SECONDS); } @Override public void expireAccessToken() { redisOps.expire(this.accessTokenKey, 0, TimeUnit.SECONDS); } @Override public String getTicket(TicketType type) { return redisOps.getValue(this.getTicketRedisKey(type)); } @Override public boolean isTicketExpired(TicketType type) { return redisOps.getExpire(this.getTicketRedisKey(type)) < 2; } @Override public synchronized void updateTicket(TicketType type, String jsapiTicket, int expiresInSeconds) { redisOps.setValue(this.getTicketRedisKey(type), jsapiTicket, expiresInSeconds - 200, TimeUnit.SECONDS); } @Override public void expireTicket(TicketType type) { redisOps.expire(this.getTicketRedisKey(type), 0, TimeUnit.SECONDS); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpDefaultConfigImpl.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpDefaultConfigImpl.java
package me.chanjar.weixin.mp.config.impl; import lombok.Data; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.enums.TicketType; import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; import me.chanjar.weixin.mp.config.WxMpConfigStorage; import me.chanjar.weixin.mp.config.WxMpHostConfig; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; import java.io.File; import java.io.Serializable; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; /** * 基于内存的微信配置provider,在实际生产环境中应该将这些配置持久化. * * @author chanjarster */ @Data public class WxMpDefaultConfigImpl implements WxMpConfigStorage, Serializable { private static final long serialVersionUID = -6646519023303395185L; protected volatile String appId; protected volatile String secret; /** * 是否使用稳定版 Access Token */ private boolean useStableAccessToken; protected volatile String token; protected volatile String templateId; protected volatile String accessToken; protected volatile String aesKey; protected volatile long expiresTime; @Deprecated protected volatile String oauth2redirectUri; protected volatile String oauth2RedirectUrl; protected volatile String qrConnectRedirectUrl; protected volatile String httpProxyHost; protected volatile int httpProxyPort; protected volatile String httpProxyUsername; protected volatile String httpProxyPassword; protected volatile int retrySleepMillis = 1000; protected volatile int maxRetryTimes = 5; protected volatile String jsapiTicket; protected volatile long jsapiTicketExpiresTime; protected volatile String sdkTicket; protected volatile long sdkTicketExpiresTime; protected volatile String cardApiTicket; protected volatile long cardApiTicketExpiresTime; protected volatile Lock accessTokenLock = new ReentrantLock(); protected volatile Lock jsapiTicketLock = new ReentrantLock(); protected volatile Lock sdkTicketLock = new ReentrantLock(); protected volatile Lock cardApiTicketLock = new ReentrantLock(); protected volatile File tmpDirFile; protected volatile ApacheHttpClientBuilder apacheHttpClientBuilder; private WxMpHostConfig hostConfig = null; @Override public boolean isStableAccessToken() { return this.useStableAccessToken; } @Override public void useStableAccessToken(boolean useStableAccessToken) { this.useStableAccessToken = useStableAccessToken; } @Override public boolean isAccessTokenExpired() { return System.currentTimeMillis() > this.expiresTime; } @Override public synchronized void updateAccessToken(WxAccessToken accessToken) { updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); } @Override public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) { this.accessToken = accessToken; this.expiresTime = System.currentTimeMillis() + (expiresInSeconds - 200) * 1000L; } @Override public void expireAccessToken() { this.expiresTime = 0; } @Override public String getTicket(TicketType type) { switch (type) { case SDK: return this.sdkTicket; case JSAPI: return this.jsapiTicket; case WX_CARD: return this.cardApiTicket; default: return null; } } public void setTicket(TicketType type, String ticket) { switch (type) { case JSAPI: this.jsapiTicket = ticket; break; case WX_CARD: this.cardApiTicket = ticket; break; case SDK: this.sdkTicket = ticket; break; default: } } @Override public Lock getTicketLock(TicketType type) { switch (type) { case SDK: return this.sdkTicketLock; case JSAPI: return this.jsapiTicketLock; case WX_CARD: return this.cardApiTicketLock; default: return null; } } @Override public boolean isTicketExpired(TicketType type) { switch (type) { case SDK: return System.currentTimeMillis() > this.sdkTicketExpiresTime; case JSAPI: return System.currentTimeMillis() > this.jsapiTicketExpiresTime; case WX_CARD: return System.currentTimeMillis() > this.cardApiTicketExpiresTime; default: return false; } } @Override public synchronized void updateTicket(TicketType type, String ticket, int expiresInSeconds) { switch (type) { case JSAPI: this.jsapiTicket = ticket; // 预留200秒的时间 this.jsapiTicketExpiresTime = System.currentTimeMillis() + (expiresInSeconds - 200) * 1000L; break; case WX_CARD: this.cardApiTicket = ticket; // 预留200秒的时间 this.cardApiTicketExpiresTime = System.currentTimeMillis() + (expiresInSeconds - 200) * 1000L; break; case SDK: this.sdkTicket = ticket; // 预留200秒的时间 this.sdkTicketExpiresTime = System.currentTimeMillis() + (expiresInSeconds - 200) * 1000L; break; default: } } @Override public void expireTicket(TicketType type) { switch (type) { case JSAPI: this.jsapiTicketExpiresTime = 0; break; case WX_CARD: this.cardApiTicketExpiresTime = 0; break; case SDK: this.sdkTicketExpiresTime = 0; break; default: } } @Override public String toString() { return WxMpGsonBuilder.create().toJson(this); } @Override public boolean autoRefreshToken() { return true; } @Override public WxMpHostConfig getHostConfig() { return this.hostConfig; } @Override public void setHostConfig(WxMpHostConfig hostConfig) { this.hostConfig = hostConfig; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpMapConfigImpl.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpMapConfigImpl.java
package me.chanjar.weixin.mp.config.impl; import lombok.Data; import me.chanjar.weixin.common.bean.WxAccessToken; import java.util.concurrent.ConcurrentHashMap; /** * @author Brayden Wong * created on 2021/1/16 * 提供accesstoken保存在concurrenthashmap中的实现,支持高并发。仅限于单机部署。 */ @Data public class WxMpMapConfigImpl extends WxMpDefaultConfigImpl { private static final long serialVersionUID = 5311395137835650104L; private final ConcurrentHashMap<String, String> CONCURRENT_HASH_MAP = new ConcurrentHashMap<>(1); private static final String MAP_KEY = "access_token"; @Override public String getAccessToken() { return CONCURRENT_HASH_MAP.get(MAP_KEY); } @Override public void setAccessToken(String accessToken) { CONCURRENT_HASH_MAP.put(MAP_KEY, accessToken); } @Override public void updateAccessToken(WxAccessToken accessToken) { updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); } @Override public void updateAccessToken(String accessToken, int expiresInSeconds) { CONCURRENT_HASH_MAP.put(MAP_KEY, accessToken); this.expiresTime = System.currentTimeMillis() + (expiresInSeconds - 200) * 1000L; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpRedisConfigImpl.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/config/impl/WxMpRedisConfigImpl.java
package me.chanjar.weixin.mp.config.impl; import lombok.Data; import lombok.EqualsAndHashCode; import me.chanjar.weixin.common.enums.TicketType; import me.chanjar.weixin.common.redis.WxRedisOps; import java.util.concurrent.TimeUnit; /** * 基于Redis的微信配置provider. * * <pre> * 使用说明:本实现仅供参考,并不完整, * 比如为减少项目依赖,未加入redis分布式锁的实现,如有需要请自行实现。 * </pre> * * @author nickwong */ @Data @EqualsAndHashCode(callSuper = false) public class WxMpRedisConfigImpl extends WxMpDefaultConfigImpl { private static final long serialVersionUID = -988502871997239733L; private static final String ACCESS_TOKEN_KEY_TPL = "%s:access_token:%s"; private static final String TICKET_KEY_TPL = "%s:ticket:key:%s:%s"; private static final String LOCK_KEY_TPL = "%s:lock:%s:"; private final WxRedisOps redisOps; private final String keyPrefix; private String accessTokenKey; private String lockKey; public WxMpRedisConfigImpl(WxRedisOps redisOps, String keyPrefix) { this.redisOps = redisOps; this.keyPrefix = keyPrefix; } /** * 每个公众号生成独有的存储key. */ @Override public void setAppId(String appId) { super.setAppId(appId); this.accessTokenKey = String.format(ACCESS_TOKEN_KEY_TPL, this.keyPrefix, appId); this.lockKey = String.format(LOCK_KEY_TPL, this.keyPrefix, appId); accessTokenLock = this.redisOps.getLock(lockKey.concat("accessTokenLock")); jsapiTicketLock = this.redisOps.getLock(lockKey.concat("jsapiTicketLock")); sdkTicketLock = this.redisOps.getLock(lockKey.concat("sdkTicketLock")); cardApiTicketLock = this.redisOps.getLock(lockKey.concat("cardApiTicketLock")); } private String getTicketRedisKey(TicketType type) { return String.format(TICKET_KEY_TPL, this.keyPrefix, appId, type.getCode()); } @Override public String getAccessToken() { return redisOps.getValue(this.accessTokenKey); } @Override public boolean isAccessTokenExpired() { Long expire = redisOps.getExpire(this.accessTokenKey); return expire == null || expire < 2; } @Override public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) { redisOps.setValue(this.accessTokenKey, accessToken, expiresInSeconds, TimeUnit.SECONDS); } @Override public void expireAccessToken() { redisOps.expire(this.accessTokenKey, 0, TimeUnit.SECONDS); } @Override public String getTicket(TicketType type) { return redisOps.getValue(this.getTicketRedisKey(type)); } @Override public boolean isTicketExpired(TicketType type) { return redisOps.getExpire(this.getTicketRedisKey(type)) < 2; } @Override public synchronized void updateTicket(TicketType type, String jsapiTicket, int expiresInSeconds) { redisOps.setValue(this.getTicketRedisKey(type), jsapiTicket, expiresInSeconds - 200, TimeUnit.SECONDS); } @Override public void expireTicket(TicketType type) { redisOps.expire(this.getTicketRedisKey(type), 0, TimeUnit.SECONDS); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/WxCardType.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/WxCardType.java
package me.chanjar.weixin.mp.enums; /** * 微信卡券类型. * * @author chenyixin * created on 2019-09-07 23:33 **/ public enum WxCardType { MEMBER_CARD("MEMBER_CARD"), GROUPON("GROUPON"), CASH("CASH"), DISCOUNT("DISCOUNT"), GIFT("GIFT"), GENERAL_COUPON("GENERAL_COUPON"); private final String code; WxCardType(String code) { this.code = code; } public String getCode() { return code; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/WxMpApiUrl.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/WxMpApiUrl.java
package me.chanjar.weixin.mp.enums; import lombok.AllArgsConstructor; import lombok.Getter; import me.chanjar.weixin.mp.config.WxMpConfigStorage; import me.chanjar.weixin.mp.config.WxMpHostConfig; import static me.chanjar.weixin.mp.config.WxMpHostConfig.API_DEFAULT_HOST_URL; import static me.chanjar.weixin.mp.config.WxMpHostConfig.MP_DEFAULT_HOST_URL; import static me.chanjar.weixin.mp.config.WxMpHostConfig.OPEN_DEFAULT_HOST_URL; import static me.chanjar.weixin.mp.config.WxMpHostConfig.buildUrl; /** * <pre> * 公众号接口api地址 * Created by BinaryWang on 2019-06-03. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public interface WxMpApiUrl { /** * 得到api完整地址. * * @param config 微信公众号配置 * @return api地址 */ default String getUrl(WxMpConfigStorage config) { WxMpHostConfig hostConfig = null; if (config != null) { hostConfig = config.getHostConfig(); } return buildUrl(hostConfig, this.getPrefix(), this.getPath()); } /** * the path * * @return path */ String getPath(); /** * the prefix * * @return prefix */ String getPrefix(); @AllArgsConstructor @Getter enum Device implements WxMpApiUrl { /** * get_bind_device. */ DEVICE_GET_BIND_DEVICE(API_DEFAULT_HOST_URL, "/device/get_bind_device"), /** * get_openid. */ DEVICE_GET_OPENID(API_DEFAULT_HOST_URL, "/device/get_openid"), /** * compel_unbind. */ DEVICE_COMPEL_UNBIND(API_DEFAULT_HOST_URL, "/device/compel_unbind?"), /** * unbind. */ DEVICE_UNBIND(API_DEFAULT_HOST_URL, "/device/unbind?"), /** * compel_bind. */ DEVICE_COMPEL_BIND(API_DEFAULT_HOST_URL, "/device/compel_bind"), /** * bind. */ DEVICE_BIND(API_DEFAULT_HOST_URL, "/device/bind"), /** * authorize_device. */ DEVICE_AUTHORIZE_DEVICE(API_DEFAULT_HOST_URL, "/device/authorize_device"), /** * getqrcode. */ DEVICE_GETQRCODE(API_DEFAULT_HOST_URL, "/device/getqrcode"), /** * transmsg. */ DEVICE_TRANSMSG(API_DEFAULT_HOST_URL, "/device/transmsg"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum OAuth2 implements WxMpApiUrl { /** * 用code换取oauth2的access token. */ OAUTH2_ACCESS_TOKEN_URL(API_DEFAULT_HOST_URL, "/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code"), /** * 刷新oauth2的access token. */ OAUTH2_REFRESH_TOKEN_URL(API_DEFAULT_HOST_URL, "/sns/oauth2/refresh_token?appid=%s&grant_type=refresh_token&refresh_token=%s"), /** * 用oauth2获取用户信息. */ OAUTH2_USERINFO_URL(API_DEFAULT_HOST_URL, "/sns/userinfo?access_token=%s&openid=%s&lang=%s"), /** * 验证oauth2的access token是否有效. */ OAUTH2_VALIDATE_TOKEN_URL(API_DEFAULT_HOST_URL, "/sns/auth?access_token=%s&openid=%s"), /** * oauth2授权的url连接. */ CONNECT_OAUTH2_AUTHORIZE_URL(OPEN_DEFAULT_HOST_URL, "/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=%s&state=%s&connect_redirect=1#wechat_redirect"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum Other implements WxMpApiUrl { /** * 获取access_token. */ GET_ACCESS_TOKEN_URL(API_DEFAULT_HOST_URL, "/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s"), /** * 获取稳定版 access_token. */ GET_STABLE_ACCESS_TOKEN_URL(API_DEFAULT_HOST_URL, "/cgi-bin/stable_token"), /** * 获得各种类型的ticket. */ GET_TICKET_URL(API_DEFAULT_HOST_URL, "/cgi-bin/ticket/getticket?type="), /** * 长链接转短链接接口. */ SHORTURL_API_URL(API_DEFAULT_HOST_URL, "/cgi-bin/shorturl"), /** * 语义查询接口. */ SEMANTIC_SEMPROXY_SEARCH_URL(API_DEFAULT_HOST_URL, "/semantic/semproxy/search"), /** * 获取微信服务器IP地址. */ GET_CALLBACK_IP_URL(API_DEFAULT_HOST_URL, "/cgi-bin/getcallbackip"), /** * 网络检测. */ NETCHECK_URL(API_DEFAULT_HOST_URL, "/cgi-bin/callback/check"), /** * 第三方使用网站应用授权登录的url. */ QRCONNECT_URL(OPEN_DEFAULT_HOST_URL, "/connect/qrconnect?appid=%s&redirect_uri=%s&response_type=code&scope=%s&state=%s#wechat_redirect"), /** * 获取公众号的自动回复规则. */ GET_CURRENT_AUTOREPLY_INFO_URL(API_DEFAULT_HOST_URL, "/cgi-bin/get_current_autoreply_info"), /** * 公众号调用或第三方平台帮公众号调用对公众号的所有api调用(包括第三方帮其调用)次数进行清零. */ CLEAR_QUOTA_URL(API_DEFAULT_HOST_URL, "/cgi-bin/clear_quota"), /** * 短key托管(生成短key的url) */ GEN_SHORTEN_URL(API_DEFAULT_HOST_URL, "/cgi-bin/shorten/gen"), /** * 短key解析(解析短key的url) */ FETCH_SHORTEN_URL(API_DEFAULT_HOST_URL, "/cgi-bin/shorten/fetch"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum Marketing implements WxMpApiUrl { /** * sets add. */ USER_ACTION_SETS_ADD(API_DEFAULT_HOST_URL, "/marketing/user_action_sets/add?version=v1.0"), /** * get. */ USER_ACTION_SETS_GET(API_DEFAULT_HOST_URL, "/marketing/user_action_sets/get"), /** * add. */ USER_ACTIONS_ADD(API_DEFAULT_HOST_URL, "/marketing/user_actions/add?version=v1.0"), /** * get. */ WECHAT_AD_LEADS_GET(API_DEFAULT_HOST_URL, "/marketing/wechat_ad_leads/get"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum Menu implements WxMpApiUrl { /** * get_current_selfmenu_info. */ GET_CURRENT_SELFMENU_INFO(API_DEFAULT_HOST_URL, "/cgi-bin/get_current_selfmenu_info"), /** * trymatch. */ MENU_TRYMATCH(API_DEFAULT_HOST_URL, "/cgi-bin/menu/trymatch"), /** * get. */ MENU_GET(API_DEFAULT_HOST_URL, "/cgi-bin/menu/get"), /** * delconditional. */ MENU_DELCONDITIONAL(API_DEFAULT_HOST_URL, "/cgi-bin/menu/delconditional"), /** * delete. */ MENU_DELETE(API_DEFAULT_HOST_URL, "/cgi-bin/menu/delete"), /** * create. */ MENU_CREATE(API_DEFAULT_HOST_URL, "/cgi-bin/menu/create"), /** * addconditional. */ MENU_ADDCONDITIONAL(API_DEFAULT_HOST_URL, "/cgi-bin/menu/addconditional"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum Qrcode implements WxMpApiUrl { /** * create. */ QRCODE_CREATE(API_DEFAULT_HOST_URL, "/cgi-bin/qrcode/create"), /** * showqrcode. */ SHOW_QRCODE(MP_DEFAULT_HOST_URL, "/cgi-bin/showqrcode"), /** * showqrcode. */ SHOW_QRCODE_WITH_TICKET(MP_DEFAULT_HOST_URL, "/cgi-bin/showqrcode?ticket=%s"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum ShakeAround implements WxMpApiUrl { /** * getshakeinfo. */ SHAKEAROUND_USER_GETSHAKEINFO(API_DEFAULT_HOST_URL, "/shakearound/user/getshakeinfo"), /** * add. */ SHAKEAROUND_PAGE_ADD(API_DEFAULT_HOST_URL, "/shakearound/page/add"), /** * bindpage. */ SHAKEAROUND_DEVICE_BINDPAGE(API_DEFAULT_HOST_URL, "/shakearound/device/bindpage"), /** * search. */ SHAKEAROUND_RELATION_SEARCH(API_DEFAULT_HOST_URL, "/shakearound/relation/search"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum SubscribeMsg implements WxMpApiUrl { /** * subscribemsg. */ SUBSCRIBE_MESSAGE_AUTHORIZE_URL(MP_DEFAULT_HOST_URL, "/mp/subscribemsg?action=get_confirm&appid=%s&scene=%d&template_id=%s&redirect_url=%s&reserved=%s#wechat_redirect"), /** * subscribe once. */ SEND_MESSAGE_ONCE_URL(API_DEFAULT_HOST_URL, "/cgi-bin/message/template/subscribe"), /** * 订阅通知消息发送. */ SEND_SUBSCRIBE_MESSAGE_URL(API_DEFAULT_HOST_URL, "/cgi-bin/message/subscribe/bizsend"), /** * 获取模板标题下的关键词列表. */ GET_PUB_TEMPLATE_TITLE_LIST_URL(API_DEFAULT_HOST_URL, "/wxaapi/newtmpl/getpubtemplatetitles"), /** * 获取模板标题下的关键词列表. */ GET_PUB_TEMPLATE_KEY_WORDS_BY_ID_URL(API_DEFAULT_HOST_URL, "/wxaapi/newtmpl/getpubtemplatekeywords"), /** * 组合模板并添加至账号下的个人模板库. */ TEMPLATE_ADD_URL(API_DEFAULT_HOST_URL, "/wxaapi/newtmpl/addtemplate"), /** * 获取当前账号下的个人模板列表. */ TEMPLATE_LIST_URL(API_DEFAULT_HOST_URL, "/wxaapi/newtmpl/gettemplate"), /** * 删除账号下的某个模板. */ TEMPLATE_DEL_URL(API_DEFAULT_HOST_URL, "/wxaapi/newtmpl/deltemplate"), /** * 获取小程序账号的类目 */ GET_CATEGORY_URL(API_DEFAULT_HOST_URL, "/wxaapi/newtmpl/getcategory"), UNIFORM_MSG_SEND_URL(API_DEFAULT_HOST_URL, "/cgi-bin/message/wxopen/template/uniform_send"), ACTIVITY_ID_CREATE_URL(API_DEFAULT_HOST_URL, "/cgi-bin/message/wxopen/activityid/create"), UPDATABLE_MSG_SEND_URL(API_DEFAULT_HOST_URL, "/cgi-bin/message/wxopen/updatablemsg/send"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum TemplateMsg implements WxMpApiUrl { /** * send. */ MESSAGE_TEMPLATE_SEND(API_DEFAULT_HOST_URL, "/cgi-bin/message/template/send"), /** * api_set_industry. */ TEMPLATE_API_SET_INDUSTRY(API_DEFAULT_HOST_URL, "/cgi-bin/template/api_set_industry"), /** * get_industry. */ TEMPLATE_GET_INDUSTRY(API_DEFAULT_HOST_URL, "/cgi-bin/template/get_industry"), /** * api_add_template. */ TEMPLATE_API_ADD_TEMPLATE(API_DEFAULT_HOST_URL, "/cgi-bin/template/api_add_template"), /** * get_all_private_template. */ TEMPLATE_GET_ALL_PRIVATE_TEMPLATE(API_DEFAULT_HOST_URL, "/cgi-bin/template/get_all_private_template"), /** * del_private_template. */ TEMPLATE_DEL_PRIVATE_TEMPLATE(API_DEFAULT_HOST_URL, "/cgi-bin/template/del_private_template"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum UserBlacklist implements WxMpApiUrl { /** * getblacklist. */ GETBLACKLIST(API_DEFAULT_HOST_URL, "/cgi-bin/tags/members/getblacklist"), /** * batchblacklist. */ BATCHBLACKLIST(API_DEFAULT_HOST_URL, "/cgi-bin/tags/members/batchblacklist"), /** * batchunblacklist. */ BATCHUNBLACKLIST(API_DEFAULT_HOST_URL, "/cgi-bin/tags/members/batchunblacklist"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum UserTag implements WxMpApiUrl { /** * create. */ TAGS_CREATE(API_DEFAULT_HOST_URL, "/cgi-bin/tags/create"), /** * get. */ TAGS_GET(API_DEFAULT_HOST_URL, "/cgi-bin/tags/get"), /** * update. */ TAGS_UPDATE(API_DEFAULT_HOST_URL, "/cgi-bin/tags/update"), /** * delete. */ TAGS_DELETE(API_DEFAULT_HOST_URL, "/cgi-bin/tags/delete"), /** * get. */ TAG_GET(API_DEFAULT_HOST_URL, "/cgi-bin/user/tag/get"), /** * batchtagging. */ TAGS_MEMBERS_BATCHTAGGING(API_DEFAULT_HOST_URL, "/cgi-bin/tags/members/batchtagging"), /** * batchuntagging. */ TAGS_MEMBERS_BATCHUNTAGGING(API_DEFAULT_HOST_URL, "/cgi-bin/tags/members/batchuntagging"), /** * getidlist. */ TAGS_GETIDLIST(API_DEFAULT_HOST_URL, "/cgi-bin/tags/getidlist"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum Wifi implements WxMpApiUrl { /** * list. */ BIZWIFI_SHOP_LIST(API_DEFAULT_HOST_URL, "/bizwifi/shop/list"), /** * get. */ BIZWIFI_SHOP_GET(API_DEFAULT_HOST_URL, "/bizwifi/shop/get"), /** * upadte. */ BIZWIFI_SHOP_UPDATE(API_DEFAULT_HOST_URL, "/bizwifi/shop/update"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum AiOpen implements WxMpApiUrl { /** * translatecontent. */ TRANSLATE_URL(API_DEFAULT_HOST_URL, "/cgi-bin/media/voice/translatecontent?lfrom=%s&lto=%s"), /** * addvoicetorecofortext. */ VOICE_UPLOAD_URL(API_DEFAULT_HOST_URL, "/cgi-bin/media/voice/addvoicetorecofortext?format=%s&voice_id=%s&lang=%s"), /** * queryrecoresultfortext. */ VOICE_QUERY_RESULT_URL(API_DEFAULT_HOST_URL, "/cgi-bin/media/voice/queryrecoresultfortext"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum Ocr implements WxMpApiUrl { /** * 身份证识别. */ IDCARD(API_DEFAULT_HOST_URL, "/cv/ocr/idcard?img_url=%s"), FILEIDCARD(API_DEFAULT_HOST_URL, "/cv/ocr/idcard"), /** * 银行卡OCR识别 */ BANK_CARD(API_DEFAULT_HOST_URL, "/cv/ocr/bankcard?img_url=%s"), /** * 银行卡OCR识别(文件) */ FILE_BANK_CARD(API_DEFAULT_HOST_URL, "/cv/ocr/bankcard"), /** * 行驶证OCR识别 */ DRIVING(API_DEFAULT_HOST_URL, "/cv/ocr/driving?img_url=%s"), /** * 行驶证OCR识别(文件) */ FILE_DRIVING(API_DEFAULT_HOST_URL, "/cv/ocr/driving"), /** * 驾驶证OCR识别 */ DRIVING_LICENSE(API_DEFAULT_HOST_URL, "/cv/ocr/drivinglicense?img_url=%s"), /** * 驾驶证OCR识别(文件) */ FILE_DRIVING_LICENSE(API_DEFAULT_HOST_URL, "/cv/ocr/drivinglicense"), /** * 营业执照OCR识别 */ BIZ_LICENSE(API_DEFAULT_HOST_URL, "/cv/ocr/bizlicense?img_url=%s"), /** * 营业执照OCR识别(文件) */ FILE_BIZ_LICENSE(API_DEFAULT_HOST_URL, "/cv/ocr/bizlicense"), /** * 通用印刷体OCR识别 */ COMM(API_DEFAULT_HOST_URL, "/cv/ocr/comm?img_url=%s"), /** * 通用印刷体OCR识别(文件) */ FILE_COMM(API_DEFAULT_HOST_URL, "/cv/ocr/comm"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum Card implements WxMpApiUrl { /** * create. */ CARD_CREATE(API_DEFAULT_HOST_URL, "/card/create"), /** * get. */ CARD_GET(API_DEFAULT_HOST_URL, "/card/get"), /** * wx_card. */ CARD_GET_TICKET(API_DEFAULT_HOST_URL, "/cgi-bin/ticket/getticket?type=wx_card"), /** * decrypt. */ CARD_CODE_DECRYPT(API_DEFAULT_HOST_URL, "/card/code/decrypt"), /** * get. */ CARD_CODE_GET(API_DEFAULT_HOST_URL, "/card/code/get"), /** * consume. */ CARD_CODE_CONSUME(API_DEFAULT_HOST_URL, "/card/code/consume"), /** * mark. */ CARD_CODE_MARK(API_DEFAULT_HOST_URL, "/card/code/mark"), /** * set. */ CARD_TEST_WHITELIST(API_DEFAULT_HOST_URL, "/card/testwhitelist/set"), /** * create. */ CARD_QRCODE_CREATE(API_DEFAULT_HOST_URL, "/card/qrcode/create"), /** * create. */ CARD_LANDING_PAGE_CREATE(API_DEFAULT_HOST_URL, "/card/landingpage/create"), /** * 将用户的卡券设置为失效状态. */ CARD_CODE_UNAVAILABLE(API_DEFAULT_HOST_URL, "/card/code/unavailable"), /** * 卡券删除. */ CARD_DELETE(API_DEFAULT_HOST_URL, "/card/delete"), /** * 导入code接口. */ CARD_CODE_DEPOSIT(API_DEFAULT_HOST_URL, "/card/code/deposit"), /** * 查询导入code数目接口 */ CARD_CODE_DEPOSIT_COUNT(API_DEFAULT_HOST_URL, "/card/code/getdepositcount"), /** * 核查code接口 */ CARD_CODE_CHECKCODE(API_DEFAULT_HOST_URL, "/card/code/checkcode"), /** * 图文消息群发卡券 */ CARD_MPNEWS_GETHTML(API_DEFAULT_HOST_URL, "/card/mpnews/gethtml"), /** * 修改库存接口 */ CARD_MODIFY_STOCK(API_DEFAULT_HOST_URL, "/card/modifystock"), /** * 更改Code接口 */ CARD_CODE_UPDATE(API_DEFAULT_HOST_URL, "/card/code/update"), /** * 设置买单接口 */ CARD_PAYCELL_SET(API_DEFAULT_HOST_URL, "/card/paycell/set"), /** * 设置自助核销接口 */ CARD_SELF_CONSUME_CELL_SET(API_DEFAULT_HOST_URL, "/card/selfconsumecell/set"), /** * 获取用户已领取卡券接口 */ CARD_USER_CARD_LIST(API_DEFAULT_HOST_URL, "/card/user/getcardlist"), ; private final String prefix; private final String path; } @AllArgsConstructor @Getter enum DataCube implements WxMpApiUrl { /** * getusersummary. */ GET_USER_SUMMARY(API_DEFAULT_HOST_URL, "/datacube/getusersummary"), /** * getusercumulate. */ GET_USER_CUMULATE(API_DEFAULT_HOST_URL, "/datacube/getusercumulate"), /** * getarticlesummary. */ GET_ARTICLE_SUMMARY(API_DEFAULT_HOST_URL, "/datacube/getarticlesummary"), /** * getarticletotal. */ GET_ARTICLE_TOTAL(API_DEFAULT_HOST_URL, "/datacube/getarticletotal"), /** * getuserread. */ GET_USER_READ(API_DEFAULT_HOST_URL, "/datacube/getuserread"), /** * getuserreadhour. */ GET_USER_READ_HOUR(API_DEFAULT_HOST_URL, "/datacube/getuserreadhour"), /** * getusershare. */ GET_USER_SHARE(API_DEFAULT_HOST_URL, "/datacube/getusershare"), /** * getusersharehour. */ GET_USER_SHARE_HOUR(API_DEFAULT_HOST_URL, "/datacube/getusersharehour"), /** * getupstreammsg. */ GET_UPSTREAM_MSG(API_DEFAULT_HOST_URL, "/datacube/getupstreammsg"), /** * getupstreammsghour. */ GET_UPSTREAM_MSG_HOUR(API_DEFAULT_HOST_URL, "/datacube/getupstreammsghour"), /** * getupstreammsgweek. */ GET_UPSTREAM_MSG_WEEK(API_DEFAULT_HOST_URL, "/datacube/getupstreammsgweek"), /** * getupstreammsgmonth. */ GET_UPSTREAM_MSG_MONTH(API_DEFAULT_HOST_URL, "/datacube/getupstreammsgmonth"), /** * getupstreammsgdist. */ GET_UPSTREAM_MSG_DIST(API_DEFAULT_HOST_URL, "/datacube/getupstreammsgdist"), /** * getupstreammsgdistweek. */ GET_UPSTREAM_MSG_DIST_WEEK(API_DEFAULT_HOST_URL, "/datacube/getupstreammsgdistweek"), /** * getupstreammsgdistmonth. */ GET_UPSTREAM_MSG_DIST_MONTH(API_DEFAULT_HOST_URL, "/datacube/getupstreammsgdistmonth"), /** * getinterfacesummary. */ GET_INTERFACE_SUMMARY(API_DEFAULT_HOST_URL, "/datacube/getinterfacesummary"), /** * getinterfacesummaryhour. */ GET_INTERFACE_SUMMARY_HOUR(API_DEFAULT_HOST_URL, "/datacube/getinterfacesummaryhour"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum Kefu implements WxMpApiUrl { /** * send. */ MESSAGE_CUSTOM_SEND(API_DEFAULT_HOST_URL, "/cgi-bin/message/custom/send"), /** * getkflist. */ GET_KF_LIST(API_DEFAULT_HOST_URL, "/cgi-bin/customservice/getkflist"), /** * getonlinekflist. */ GET_ONLINE_KF_LIST(API_DEFAULT_HOST_URL, "/cgi-bin/customservice/getonlinekflist"), /** * add. */ KFACCOUNT_ADD(API_DEFAULT_HOST_URL, "/customservice/kfaccount/add"), /** * update. */ KFACCOUNT_UPDATE(API_DEFAULT_HOST_URL, "/customservice/kfaccount/update"), /** * inviteworker. */ KFACCOUNT_INVITE_WORKER(API_DEFAULT_HOST_URL, "/customservice/kfaccount/inviteworker"), /** * uploadheadimg. */ KFACCOUNT_UPLOAD_HEAD_IMG(API_DEFAULT_HOST_URL, "/customservice/kfaccount/uploadheadimg?kf_account=%s"), /** * del kfaccount. */ KFACCOUNT_DEL(API_DEFAULT_HOST_URL, "/customservice/kfaccount/del?kf_account=%s"), /** * create. */ KFSESSION_CREATE(API_DEFAULT_HOST_URL, "/customservice/kfsession/create"), /** * close. */ KFSESSION_CLOSE(API_DEFAULT_HOST_URL, "/customservice/kfsession/close"), /** * getsession. */ KFSESSION_GET_SESSION(API_DEFAULT_HOST_URL, "/customservice/kfsession/getsession?openid=%s"), /** * getsessionlist. */ KFSESSION_GET_SESSION_LIST(API_DEFAULT_HOST_URL, "/customservice/kfsession/getsessionlist?kf_account=%s"), /** * getwaitcase. */ KFSESSION_GET_WAIT_CASE(API_DEFAULT_HOST_URL, "/customservice/kfsession/getwaitcase"), /** * getmsglist. */ MSG_RECORD_LIST(API_DEFAULT_HOST_URL, "/customservice/msgrecord/getmsglist"), /** * typing. */ CUSTOM_TYPING(API_DEFAULT_HOST_URL, "/cgi-bin/message/custom/typing"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum MassMessage implements WxMpApiUrl { /** * 上传群发用的图文消息. */ MEDIA_UPLOAD_NEWS_URL(API_DEFAULT_HOST_URL, "/cgi-bin/media/uploadnews"), /** * 上传群发用的视频. */ MEDIA_UPLOAD_VIDEO_URL(API_DEFAULT_HOST_URL, "/cgi-bin/media/uploadvideo"), /** * 分组群发消息. */ MESSAGE_MASS_SENDALL_URL(API_DEFAULT_HOST_URL, "/cgi-bin/message/mass/sendall"), /** * 按openId列表群发消息. */ MESSAGE_MASS_SEND_URL(API_DEFAULT_HOST_URL, "/cgi-bin/message/mass/send"), /** * 群发消息预览接口. */ MESSAGE_MASS_PREVIEW_URL(API_DEFAULT_HOST_URL, "/cgi-bin/message/mass/preview"), /** * 删除群发接口. */ MESSAGE_MASS_DELETE_URL(API_DEFAULT_HOST_URL, "/cgi-bin/message/mass/delete"), /** * 获取群发速度. */ MESSAGE_MASS_SPEED_GET_URL(API_DEFAULT_HOST_URL, "/cgi-bin/message/mass/speed/get"), /** * 设置群发速度. */ MESSAGE_MASS_SPEED_SET_URL(API_DEFAULT_HOST_URL, "/cgi-bin/message/mass/speed/set"), /** * 查询群发消息发送状态【订阅号与服务号认证后均可用】 */ MESSAGE_MASS_GET_URL(API_DEFAULT_HOST_URL, "/cgi-bin/message/mass/get"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum Material implements WxMpApiUrl { /** * get. */ MEDIA_GET_URL(API_DEFAULT_HOST_URL, "/cgi-bin/media/get"), /** * jssdk media get. */ JSSDK_MEDIA_GET_URL(API_DEFAULT_HOST_URL, "/cgi-bin/media/get/jssdk"), /** * upload. */ MEDIA_UPLOAD_URL(API_DEFAULT_HOST_URL, "/cgi-bin/media/upload?type=%s"), /** * uploadimg. */ IMG_UPLOAD_URL(API_DEFAULT_HOST_URL, "/cgi-bin/media/uploadimg"), /** * add_material. */ MATERIAL_ADD_URL(API_DEFAULT_HOST_URL, "/cgi-bin/material/add_material?type=%s"), /** * add_news. */ NEWS_ADD_URL(API_DEFAULT_HOST_URL, "/cgi-bin/material/add_news"), /** * get_material. */ MATERIAL_GET_URL(API_DEFAULT_HOST_URL, "/cgi-bin/material/get_material"), /** * update_news. */ NEWS_UPDATE_URL(API_DEFAULT_HOST_URL, "/cgi-bin/material/update_news"), /** * del_material. */ MATERIAL_DEL_URL(API_DEFAULT_HOST_URL, "/cgi-bin/material/del_material"), /** * get_materialcount. */ MATERIAL_GET_COUNT_URL(API_DEFAULT_HOST_URL, "/cgi-bin/material/get_materialcount"), /** * batchget_material. */ MATERIAL_BATCHGET_URL(API_DEFAULT_HOST_URL, "/cgi-bin/material/batchget_material"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum MemberCard implements WxMpApiUrl { /** * create. */ MEMBER_CARD_CREATE(API_DEFAULT_HOST_URL, "/card/create"), /** * activate. */ MEMBER_CARD_ACTIVATE(API_DEFAULT_HOST_URL, "/card/membercard/activate"), /** * get userinfo. */ MEMBER_CARD_USER_INFO_GET(API_DEFAULT_HOST_URL, "/card/membercard/userinfo/get"), /** * updateuser. */ MEMBER_CARD_UPDATE_USER(API_DEFAULT_HOST_URL, "/card/membercard/updateuser"), /** * 会员卡激活之微信开卡接口(wx_activate=true情况调用). */ MEMBER_CARD_ACTIVATE_USER_FORM(API_DEFAULT_HOST_URL, "/card/membercard/activateuserform/set"), /** * 获取会员卡开卡插件参数. */ MEMBER_CARD_ACTIVATE_URL(API_DEFAULT_HOST_URL, "/card/membercard/activate/geturl"), /** * 会员卡信息更新. */ MEMBER_CARD_UPDATE(API_DEFAULT_HOST_URL, "/card/update"), /** * 跳转型会员卡开卡字段. * 获取用户提交资料(wx_activate=true情况调用),开发者根据activate_ticket获取到用户填写的信息 */ MEMBER_CARD_ACTIVATE_TEMP_INFO(API_DEFAULT_HOST_URL, "/card/membercard/activatetempinfo/get"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum Store implements WxMpApiUrl { /** * getwxcategory. */ POI_GET_WX_CATEGORY_URL(API_DEFAULT_HOST_URL, "/cgi-bin/poi/getwxcategory"), /** * updatepoi. */ POI_UPDATE_URL(API_DEFAULT_HOST_URL, "/cgi-bin/poi/updatepoi"), /** * getpoilist. */ POI_LIST_URL(API_DEFAULT_HOST_URL, "/cgi-bin/poi/getpoilist"), /** * delpoi. */ POI_DEL_URL(API_DEFAULT_HOST_URL, "/cgi-bin/poi/delpoi"), /** * getpoi. */ POI_GET_URL(API_DEFAULT_HOST_URL, "/cgi-bin/poi/getpoi"), /** * addpoi. */ POI_ADD_URL(API_DEFAULT_HOST_URL, "/cgi-bin/poi/addpoi"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum User implements WxMpApiUrl { /** * batchget. */ USER_INFO_BATCH_GET_URL(API_DEFAULT_HOST_URL, "/cgi-bin/user/info/batchget"), /** * get. */ USER_GET_URL(API_DEFAULT_HOST_URL, "/cgi-bin/user/get"), /** * info. */ USER_INFO_URL(API_DEFAULT_HOST_URL, "/cgi-bin/user/info"), /** * updateremark. */ USER_INFO_UPDATE_REMARK_URL(API_DEFAULT_HOST_URL, "/cgi-bin/user/info/updateremark"), /** * changeopenid. */ USER_CHANGE_OPENID_URL(API_DEFAULT_HOST_URL, "/cgi-bin/changeopenid"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum Comment implements WxMpApiUrl { /** * 打开已群发文章评论. */ OPEN(API_DEFAULT_HOST_URL, "/cgi-bin/comment/open"), /** * 关闭已群发文章评论. */ CLOSE(API_DEFAULT_HOST_URL, "/cgi-bin/comment/close"), /** * 查看指定文章的评论数据. */ LIST(API_DEFAULT_HOST_URL, "/cgi-bin/comment/list"), /** * 将评论标记精选. */ MARK_ELECT(API_DEFAULT_HOST_URL, "/cgi-bin/comment/markelect"), /** * 将评论取消精选. */ UNMARK_ELECT(API_DEFAULT_HOST_URL, "/cgi-bin/comment/unmarkelect"), /** * 删除评论. */ DELETE(API_DEFAULT_HOST_URL, "/cgi-bin/comment/delete"), /** * 回复评论. */ REPLY_ADD(API_DEFAULT_HOST_URL, "/cgi-bin/comment/reply/add"), /** * 删除回复. */ REPLY_DELETE(API_DEFAULT_HOST_URL, "/cgi-bin/comment/reply/delete"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum ImgProc implements WxMpApiUrl { /** * 二维码/条码识别 */ QRCODE(API_DEFAULT_HOST_URL, "/cv/img/qrcode?img_url=%s"), /** * 二维码/条码识别(文件) */ FILE_QRCODE(API_DEFAULT_HOST_URL, "/cv/img/qrcode"), /** * 图片高清化 */ SUPER_RESOLUTION(API_DEFAULT_HOST_URL, "/cv/img/superresolution?img_url=%s"), /** * 图片高清化(文件) */ FILE_SUPER_RESOLUTION(API_DEFAULT_HOST_URL, "/cv/img/superresolution"), /** * 图片智能裁剪 */ AI_CROP(API_DEFAULT_HOST_URL, "/cv/img/aicrop?img_url=%s&ratios=%s"), /** * 图片智能裁剪(文件) */ FILE_AI_CROP(API_DEFAULT_HOST_URL, "/cv/img/aicrop?ratios=%s"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum Invoice implements WxMpApiUrl { /** * 获取用户开票授权地址 */ GET_AUTH_URL(API_DEFAULT_HOST_URL, "/card/invoice/getauthurl"), /** * 获取用户开票授权信息 */ GET_AUTH_DATA(API_DEFAULT_HOST_URL, "/card/invoice/getauthdata"), /** * 拒绝为用户开票 */ REJECT_INSERT(API_DEFAULT_HOST_URL, "/card/invoice/rejectinsert"), /** * 开票 */ MAKE_OUT_INVOICE(API_DEFAULT_HOST_URL, "/card/invoice/makeoutinvoice"), /** * 发票冲红 */ CLEAR_OUT_INVOICE(API_DEFAULT_HOST_URL, "/card/invoice/clearoutinvoice"), /** * 查询发票信息 */ QUERY_INVOICE_INFO(API_DEFAULT_HOST_URL, "/card/invoice/queryinvoceinfo"), /** * 设置商户信息联系 */ SET_CONTACT_SET_BIZ_ATTR(API_DEFAULT_HOST_URL, "/card/invoice/setbizattr?action=set_contact"), /** * 获取商户联系信息 */ GET_CONTACT_SET_BIZ_ATTR(API_DEFAULT_HOST_URL, "/card/invoice/setbizattr?action=get_contact"), /** * 设置授权页面字段 */ SET_AUTH_FIELD_SET_BIZ_ATTR(API_DEFAULT_HOST_URL, "/card/invoice/setbizattr?action=set_auth_field"), /** * 获取授权页面字段 */ GET_AUTH_FIELD_SET_BIZ_ATTR(API_DEFAULT_HOST_URL, "/card/invoice/setbizattr?action=get_auth_field"), /** * 设置关联商户 */ SET_PAY_MCH_SET_BIZ_ATTR(API_DEFAULT_HOST_URL, "/card/invoice/setbizattr?action=set_pay_mch"), /** * 获取关联商户 */ GET_PAY_MCH_SET_BIZ_ATTR(API_DEFAULT_HOST_URL, "/card/invoice/setbizattr?action=get_pay_mch"), /** * 报销方查询报销发票信息 */ GET_INVOICE_INFO(API_DEFAULT_HOST_URL, "/card/invoice/reimburse/getinvoiceinfo"), /** * 报销方批量查询报销发票信息 */ GET_INVOICE_BATCH(API_DEFAULT_HOST_URL, "/card/invoice/reimburse/getinvoicebatch"), /** * 报销方更新发票状态 */ UPDATE_INVOICE_STATUS(API_DEFAULT_HOST_URL, "/card/invoice/reimburse/updateinvoicestatus"), /** * 报销方批量更新发票状态 */ UPDATE_STATUS_BATCH(API_DEFAULT_HOST_URL, "/card/invoice/reimburse/updatestatusbatch"), ; private final String prefix; private final String path; } /** * 对话能力 */ @AllArgsConstructor @Getter enum Guide implements WxMpApiUrl { /** * 添加顾问 */ ADD_GUIDE(API_DEFAULT_HOST_URL, "/cgi-bin/guide/addguideacct"), /** * 修改顾问 */ UPDATE_GUIDE(API_DEFAULT_HOST_URL, "/cgi-bin/guide/updateguideacct"), /** * 获取顾问信息 */ GET_GUIDE(API_DEFAULT_HOST_URL, "/cgi-bin/guide/getguideacct"), /** * 删除顾问 */ DEL_GUIDE(API_DEFAULT_HOST_URL, "/cgi-bin/guide/delguideacct"), /** * 获取服务号顾问列表 */ LIST_GUIDE(API_DEFAULT_HOST_URL, "/cgi-bin/guide/getguideacctlist"), /** * 生成顾问二维码 */ CREATE_QR_CODE(API_DEFAULT_HOST_URL, "/cgi-bin/guide/guidecreateqrcode"), /** * 获取顾问聊天记录 */ GET_GUIDE_CHAT_RECORD(API_DEFAULT_HOST_URL, "/cgi-bin/guide/getguidebuyerchatrecord"), /** * 设置快捷回复与关注自动回复 */ SET_GUIDE_CONFIG(API_DEFAULT_HOST_URL, "/cgi-bin/guide/setguideconfig"), /** * 获取快捷回复与关注自动回复 */ GET_GUIDE_CONFIG(API_DEFAULT_HOST_URL, "/cgi-bin/guide/getguideconfig"), /** * 为服务号设置敏感词与离线自动回复 */ SET_GUIDE_ACCT_CONFIG(API_DEFAULT_HOST_URL, "/cgi-bin/guide/setguideacctconfig"), /** * 获取服务号敏感词与离线自动回复 */ GET_GUIDE_ACCT_CONFIG(API_DEFAULT_HOST_URL, "/cgi-bin/guide/getguideacctconfig"), /** * 允许微信用户复制小程序页面路径 */ PUSH_SHOW_WX_PATH_MENU(API_DEFAULT_HOST_URL, "/cgi-bin/guide/pushshowwxapathmenu"), /** * 新建顾问分组 */ NEW_GUIDE_GROUP(API_DEFAULT_HOST_URL, "/cgi-bin/guide/newguidegroup"), /** * 获取服务号下所有顾问分组的列表 */ GET_GUIDE_GROUP_LIST(API_DEFAULT_HOST_URL, "/cgi-bin/guide/getguidegrouplist"), /** * 获取指定顾问分组内顾问信息 */ GET_GROUP_GUIDE_INFO(API_DEFAULT_HOST_URL, "/cgi-bin/guide/getgroupinfo"),
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
true
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/AiLangType.java
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/enums/AiLangType.java
package me.chanjar.weixin.mp.enums; import lombok.Getter; /** * <pre> * AI开放接口里的语言类型,目前只支持两种:中文和英文 * Created by BinaryWang on 2018/6/10. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ @Getter public enum AiLangType { /** * 中文 汉语. */ zh_CN("zh_CN"), /** * 英文 英语. */ en_US("en_US"); private final String code; AiLangType(String code) { this.code = code; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/test/java/me/chanjar/weixin/qidian/api/WxMpJsAPITest.java
weixin-java-qidian/src/test/java/me/chanjar/weixin/qidian/api/WxMpJsAPITest.java
package me.chanjar.weixin.qidian.api; import com.google.inject.Inject; import me.chanjar.weixin.common.util.crypto.SHA1; import me.chanjar.weixin.qidian.api.test.ApiTestModule; import org.testng.Assert; import org.testng.annotations.Guice; import org.testng.annotations.Test; /** * 测试jsapi ticket接口 * * @author chanjarster */ @Test @Guice(modules = ApiTestModule.class) public class WxMpJsAPITest { @Inject protected WxQidianService wxService; public void test() { long timestamp = 1419835025L; String url = "http://omstest.vmall.com:23568/thirdparty/wechat/vcode/gotoshare?quantity=1&batchName=MATE7"; String noncestr = "82693e11-b9bc-448e-892f-f5289f46cd0f"; String jsapiTicket = "bxLdikRXVbTPdHSM05e5u4RbEYQn7pNQMPrfzl8lJNb1foLDa3HIwI3BRMkQmSO_5F64VFa75uURcq6Uz7QHgA"; String result = SHA1.genWithAmple( "jsapi_ticket=" + jsapiTicket, "noncestr=" + noncestr, "timestamp=" + timestamp, "url=" + url ); Assert.assertEquals(result, "c6f04b64d6351d197b71bd23fb7dd2d44c0db486"); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/test/java/me/chanjar/weixin/qidian/api/WxMpBusyRetryTest.java
weixin-java-qidian/src/test/java/me/chanjar/weixin/qidian/api/WxMpBusyRetryTest.java
package me.chanjar.weixin.qidian.api; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.http.RequestExecutor; import me.chanjar.weixin.qidian.api.impl.WxQidianServiceHttpClientImpl; import org.testng.annotations.*; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; @Test @Slf4j public class WxMpBusyRetryTest { @DataProvider(name = "getService") public Object[][] getService() { WxQidianService service = new WxQidianServiceHttpClientImpl() { @Override public synchronized <T, E> T executeInternal( RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { log.info("Executed"); throw new WxErrorException("something"); } }; service.setMaxRetryTimes(3); service.setRetrySleepMillis(500); return new Object[][]{{service}}; } @Test(dataProvider = "getService", expectedExceptions = RuntimeException.class) public void testRetry(WxQidianService service) throws WxErrorException { service.execute(null, (String)null, null); } @Test(dataProvider = "getService") public void testRetryInThreadPool(final WxQidianService service) throws InterruptedException, ExecutionException { // 当线程池中的线程复用的时候,还是能保证相同的重试次数 ExecutorService executorService = Executors.newFixedThreadPool(1); Runnable runnable = () -> { try { System.out.println("====================="); System.out.println(Thread.currentThread().getName() + ": testRetry"); service.execute(null, (String)null, null); } catch (WxErrorException e) { throw new WxRuntimeException(e); } catch (RuntimeException e) { // OK } }; Future<?> submit1 = executorService.submit(runnable); Future<?> submit2 = executorService.submit(runnable); submit1.get(); submit2.get(); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/test/java/me/chanjar/weixin/qidian/api/test/ApiTestModule.java
weixin-java-qidian/src/test/java/me/chanjar/weixin/qidian/api/test/ApiTestModule.java
package me.chanjar.weixin.qidian.api.test; import java.io.IOException; import java.io.InputStream; import java.util.concurrent.locks.ReentrantLock; import com.google.inject.Binder; import com.google.inject.Module; import com.thoughtworks.xstream.XStream; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.xml.XStreamInitializer; import me.chanjar.weixin.qidian.api.WxQidianService; import me.chanjar.weixin.qidian.api.impl.WxQidianServiceHttpClientImpl; import me.chanjar.weixin.qidian.config.WxQidianConfigStorage; @Slf4j public class ApiTestModule implements Module { private static final String TEST_CONFIG_XML = "test-config.xml"; @Override public void configure(Binder binder) { try (InputStream inputStream = ClassLoader.getSystemResourceAsStream(TEST_CONFIG_XML)) { if (inputStream == null) { throw new WxRuntimeException("测试配置文件【" + TEST_CONFIG_XML + "】未找到,请参照test-config-sample.xml文件生成"); } TestConfigStorage config = this.fromXml(TestConfigStorage.class, inputStream); config.setAccessTokenLock(new ReentrantLock()); WxQidianService mpService = new WxQidianServiceHttpClientImpl(); mpService.setWxMpConfigStorage(config); mpService.addConfigStorage("another", config); binder.bind(WxQidianConfigStorage.class).toInstance(config); binder.bind(WxQidianService.class).toInstance(mpService); } catch (IOException e) { log.error(e.getMessage(), e); } } @SuppressWarnings("unchecked") private <T> T fromXml(Class<T> clazz, InputStream is) { XStream xstream = XStreamInitializer.getInstance(); xstream.alias("xml", clazz); xstream.processAnnotations(clazz); return (T) xstream.fromXML(is); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/test/java/me/chanjar/weixin/qidian/api/test/TestConfigStorage.java
weixin-java-qidian/src/test/java/me/chanjar/weixin/qidian/api/test/TestConfigStorage.java
package me.chanjar.weixin.qidian.api.test; import com.thoughtworks.xstream.annotations.XStreamAlias; import me.chanjar.weixin.qidian.config.impl.WxQidianDefaultConfigImpl; import org.apache.commons.lang3.builder.ToStringBuilder; import java.util.concurrent.locks.Lock; @XStreamAlias("xml") public class TestConfigStorage extends WxQidianDefaultConfigImpl { private String openid; private String kfAccount; private String qrconnectRedirectUrl; private String templateId; private String keyPath; public String getKeyPath() { return keyPath; } public void setKeyPath(String keyPath) { this.keyPath = keyPath; } public String getOpenid() { return this.openid; } public void setOpenid(String openid) { this.openid = openid; } @Override public String toString() { return ToStringBuilder.reflectionToString(this); } public String getKfAccount() { return this.kfAccount; } public void setKfAccount(String kfAccount) { this.kfAccount = kfAccount; } public String getQrconnectRedirectUrl() { return this.qrconnectRedirectUrl; } public void setQrconnectRedirectUrl(String qrconnectRedirectUrl) { this.qrconnectRedirectUrl = qrconnectRedirectUrl; } @Override public String getTemplateId() { return this.templateId; } @Override public void setTemplateId(String templateId) { this.templateId = templateId; } public void setAccessTokenLock(Lock lock) { super.accessTokenLock = lock; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/test/java/me/chanjar/weixin/qidian/api/impl/BaseWxQidianServiceImplTest.java
weixin-java-qidian/src/test/java/me/chanjar/weixin/qidian/api/impl/BaseWxQidianServiceImplTest.java
package me.chanjar.weixin.qidian.api.impl; import com.google.common.collect.Sets; import com.google.inject.Inject; import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.bean.WxJsapiSignature; import me.chanjar.weixin.common.bean.WxNetCheckResult; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.qidian.api.WxQidianService; import me.chanjar.weixin.qidian.api.test.ApiTestModule; import me.chanjar.weixin.qidian.util.WxQidianConfigStorageHolder; import org.testng.Assert; import org.testng.annotations.Guice; import org.testng.annotations.Test; import java.util.Arrays; import static org.assertj.core.api.Assertions.assertThat; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; /** * <pre> * Created by BinaryWang on 2019/3/29. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ @Test @Guice(modules = ApiTestModule.class) public class BaseWxQidianServiceImplTest { @Inject private WxQidianService wxService; @Test public void testSwitchover() { assertTrue(this.wxService.switchover("another")); assertThat(WxQidianConfigStorageHolder.get()).isEqualTo("another"); assertFalse(this.wxService.switchover("whatever")); assertFalse(this.wxService.switchover("default")); } @Test public void testSwitchoverTo() throws WxErrorException { assertThat(this.wxService.switchoverTo("another").getAccessToken()).isNotEmpty(); assertThat(WxQidianConfigStorageHolder.get()).isEqualTo("another"); } @Test public void testNetCheck() throws WxErrorException { WxNetCheckResult result = this.wxService.netCheck(WxConsts.NetCheckArgs.ACTIONALL, WxConsts.NetCheckArgs.OPERATORDEFAULT); Assert.assertNotNull(result); } @Test public void testGetCallbackIP() throws WxErrorException { String[] ipArray = this.wxService.getCallbackIP(); System.out.println(Arrays.toString(ipArray)); Assert.assertNotNull(ipArray); Assert.assertNotEquals(ipArray.length, 0); } public void testShortUrl() throws WxErrorException { String shortUrl = this.wxService.shortUrl("http://www.baidu.com/test?access_token=123"); assertThat(shortUrl).isNotEmpty(); System.out.println(shortUrl); } @Test(expectedExceptions = WxErrorException.class) public void testShortUrl_with_exceptional_url() throws WxErrorException { this.wxService.shortUrl("http://www.baidu.com/test?redirect_count=1&access_token=123"); } @Test public void refreshAccessTokenDuplicatelyTest() throws InterruptedException { // 测试多线程刷新accessToken时是否重复刷新 wxService.getWxMpConfigStorage().expireAccessToken(); final Set<String> set = Sets.newConcurrentHashSet(); Runnable r = () -> { try { String accessToken = wxService.getAccessToken(); set.add(accessToken); } catch (WxErrorException e) { e.printStackTrace(); } }; final int threadNumber = 10; ExecutorService executorService = Executors.newFixedThreadPool(threadNumber); for ( int i = 0; i < threadNumber; i++ ) { executorService.submit(r); } executorService.shutdown(); boolean isTerminated = executorService.awaitTermination(15, TimeUnit.SECONDS); System.out.println("isTerminated: " + isTerminated); System.out.println("times of refreshing accessToken: " + set.size()); assertEquals(set.size(), 1); } @Test public void testCheckSignature() { } @Test public void testGetTicket() { } @Test public void testTestGetTicket() { } @Test public void testGetJsapiTicket() { } @Test public void testTestGetJsapiTicket() { } @Test public void testCreateJsapiSignature() throws WxErrorException { final WxJsapiSignature jsapiSignature = this.wxService.createJsapiSignature("http://www.baidu.com"); assertThat(jsapiSignature).isNotNull(); assertThat(jsapiSignature.getSignature()).isNotNull(); System.out.println(jsapiSignature); } @Test public void testGetAccessToken() { } @Test public void testSemanticQuery() { } @Test public void testOauth2buildAuthorizationUrl() { } @Test public void testBuildQrConnectUrl() { } @Test public void testOauth2getAccessToken() { } @Test public void testOauth2refreshAccessToken() { } @Test public void testOauth2getUserInfo() { } @Test public void testOauth2validateAccessToken() { } @Test public void testGetCurrentAutoReplyInfo() { } @Test public void testClearQuota() { } @Test public void testGet() { } @Test public void testTestGet() { } @Test public void testPost() { } @Test public void testTestPost() { } @Test public void testExecute() { } @Test public void testTestExecute() { } @Test public void testExecuteInternal() { } @Test public void testGetWxMpConfigStorage() { } @Test public void testSetWxMpConfigStorage() { } @Test public void testSetMultiConfigStorages() { } @Test public void testTestSetMultiConfigStorages() { } @Test public void testAddConfigStorage() { } @Test public void testRemoveConfigStorage() { } @Test public void testSetRetrySleepMillis() { } @Test public void testSetMaxRetryTimes() { } @Test public void testGetKefuService() { } @Test public void testGetMaterialService() { } @Test public void testGetMenuService() { } @Test public void testGetUserService() { } @Test public void testGetUserTagService() { } @Test public void testGetQrcodeService() { } @Test public void testGetCardService() { } @Test public void testGetDataCubeService() { } @Test public void testGetBlackListService() { } @Test public void testGetStoreService() { } @Test public void testGetTemplateMsgService() { } @Test public void testGetSubscribeMsgService() { } @Test public void testGetDeviceService() { } @Test public void testGetShakeService() { } @Test public void testGetMemberCardService() { } @Test public void testGetRequestHttp() { } @Test public void testGetMassMessageService() { } @Test public void testSetKefuService() { } @Test public void testSetMaterialService() { } @Test public void testSetMenuService() { } @Test public void testSetUserService() { } @Test public void testSetTagService() { } @Test public void testSetQrCodeService() { } @Test public void testSetCardService() { } @Test public void testSetStoreService() { } @Test public void testSetDataCubeService() { } @Test public void testSetBlackListService() { } @Test public void testSetTemplateMsgService() { } @Test public void testSetDeviceService() { } @Test public void testSetShakeService() { } @Test public void testSetMemberCardService() { } @Test public void testSetMassMessageService() { } @Test public void testGetAiOpenService() { } @Test public void testSetAiOpenService() { } @Test public void testGetWifiService() { } @Test public void testGetOcrService() { } @Test public void testGetMarketingService() { } @Test public void testSetMarketingService() { } @Test public void testSetOcrService() { } @Test public void testGetCommentService() { } @Test public void testSetCommentService() { } @Test public void testGetImgProcService() { } @Test public void testSetImgProcService() { } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/test/java/me/chanjar/weixin/qidian/api/impl/WxQidianDialServiceImplTest.java
weixin-java-qidian/src/test/java/me/chanjar/weixin/qidian/api/impl/WxQidianDialServiceImplTest.java
package me.chanjar.weixin.qidian.api.impl; import java.util.List; import java.util.Optional; import com.google.inject.Inject; import org.testng.Assert; import org.testng.annotations.Guice; import org.testng.annotations.Test; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.qidian.api.WxQidianService; import me.chanjar.weixin.qidian.api.test.ApiTestModule; import me.chanjar.weixin.qidian.bean.call.GetSwitchBoardListResponse; import me.chanjar.weixin.qidian.bean.dial.IVRDialRequest; import me.chanjar.weixin.qidian.bean.dial.IVRDialResponse; import me.chanjar.weixin.qidian.bean.dial.IVRListResponse; import me.chanjar.weixin.qidian.bean.dial.Ivr; @Test @Guice(modules = ApiTestModule.class) @Slf4j public class WxQidianDialServiceImplTest { @Inject private WxQidianService wxService; @Test public void dial() throws WxErrorException { // ivr IVRListResponse iVRListResponse = this.wxService.getDialService().getIVRList(); Assert.assertEquals(iVRListResponse.getErrcode(), new Integer(0)); log.info("ivr size:" + iVRListResponse.getNode().size()); Optional<Ivr> optional = iVRListResponse.getNode().stream().filter(o -> o.getIvr_name().equals("自动接听需求测试")) .findFirst(); Assert.assertTrue(optional.isPresent()); Ivr ivr = optional.get(); String ivr_id = ivr.getIvr_id(); // ivr_id = "433"; // switch GetSwitchBoardListResponse getSwitchBoardListResponse = this.wxService.getCallDataService().getSwitchBoardList(); Assert.assertEquals(getSwitchBoardListResponse.getErrcode(), new Integer(0)); log.info("switch size:" + getSwitchBoardListResponse.getData().switchBoards().size()); List<String> switchBoards = getSwitchBoardListResponse.getData().switchBoards(); // ivrdial IVRDialRequest ivrDial = new IVRDialRequest(); ivrDial.setPhone_number("18434399105"); // ivrDial.setPhone_number("13811768266"); ivrDial.setIvr_id(ivr_id); ivrDial.setCorp_phone_list(switchBoards); IVRDialResponse ivrDialResponse = this.wxService.getDialService().ivrDial(ivrDial); Assert.assertEquals(ivrDialResponse.getCode(), new Integer(0)); log.info(ivrDialResponse.getCallid()); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/util/WxQidianConfigStorageHolder.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/util/WxQidianConfigStorageHolder.java
package me.chanjar.weixin.qidian.util; /** * @author alegria * created on 2020年12月26日 */ public class WxQidianConfigStorageHolder { private static final ThreadLocal<String> THREAD_LOCAL = ThreadLocal.withInitial(() -> "default"); public static String get() { return THREAD_LOCAL.get(); } public static void set(String label) { THREAD_LOCAL.set(label); } /** * 此方法需要用户根据自己程序代码,在适当位置手动触发调用,本SDK里无法判断调用时机 */ public static void remove() { THREAD_LOCAL.remove(); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/util/json/WxQidianGsonBuilder.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/util/json/WxQidianGsonBuilder.java
package me.chanjar.weixin.qidian.util.json; import com.google.gson.ExclusionStrategy; import com.google.gson.FieldAttributes; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; import java.io.File; /** * @author someone */ public class WxQidianGsonBuilder { private static final GsonBuilder INSTANCE = new GsonBuilder(); static { INSTANCE.disableHtmlEscaping(); INSTANCE.setExclusionStrategies(new ExclusionStrategy() { @Override public boolean shouldSkipField(FieldAttributes fieldAttributes) { return false; } @Override public boolean shouldSkipClass(Class<?> aClass) { return aClass == File.class || aClass == ApacheHttpClientBuilder.class; } }); } public static Gson create() { return INSTANCE.create(); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/WxQidianService.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/WxQidianService.java
package me.chanjar.weixin.qidian.api; import java.util.Map; import com.google.gson.JsonObject; import me.chanjar.weixin.common.bean.WxJsapiSignature; import me.chanjar.weixin.common.bean.WxNetCheckResult; import me.chanjar.weixin.common.enums.TicketType; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.service.WxService; import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; import me.chanjar.weixin.common.util.http.RequestExecutor; import me.chanjar.weixin.common.util.http.RequestHttp; import me.chanjar.weixin.qidian.config.WxQidianConfigStorage; import me.chanjar.weixin.qidian.enums.WxQidianApiUrl; /** * 腾讯企点API的Service. * * @author alegria */ public interface WxQidianService extends WxService { /** * <pre> * 验证消息的确来自微信服务器. * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421135319&token=&lang=zh_CN * </pre> * * @param timestamp 时间戳 * @param nonce 随机串 * @param signature 签名 * @return 是否验证通过 boolean */ boolean checkSignature(String timestamp, String nonce, String signature); /** * 获取access_token, 不强制刷新access_token. * * @return token access token * @throws WxErrorException . * @see #getAccessToken(boolean) #getAccessToken(boolean) */ String getAccessToken() throws WxErrorException; /** * <pre> * 获取access_token,本方法线程安全. * 且在多线程同时刷新时只刷新一次,避免超出2000次/日的调用次数上限 * * 另:本service的所有方法都会在access_token过期时调用此方法 * * 程序员在非必要情况下尽量不要主动调用此方法 * * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140183&token=&lang=zh_CN * </pre> * * @param forceRefresh 是否强制刷新 * @return token access token * @throws WxErrorException . */ String getAccessToken(boolean forceRefresh) throws WxErrorException; /** * 获得ticket,不强制刷新ticket. * * @param type ticket 类型 * @return ticket ticket * @throws WxErrorException . * @see #getTicket(TicketType, boolean) #getTicket(TicketType, boolean) */ String getTicket(TicketType type) throws WxErrorException; /** * <pre> * 获得ticket. * 获得时会检查 Token是否过期,如果过期了,那么就刷新一下,否则就什么都不干 * </pre> * * @param type ticket类型 * @param forceRefresh 强制刷新 * @return ticket ticket * @throws WxErrorException . */ String getTicket(TicketType type, boolean forceRefresh) throws WxErrorException; /** * 获得jsapi_ticket,不强制刷新jsapi_ticket. * * @return jsapi ticket * @throws WxErrorException . * @see #getJsapiTicket(boolean) #getJsapiTicket(boolean) */ String getJsapiTicket() throws WxErrorException; /** * <pre> * 获得jsapi_ticket. * 获得时会检查jsapiToken是否过期,如果过期了,那么就刷新一下,否则就什么都不干 * * 详情请见:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN * </pre> * * @param forceRefresh 强制刷新 * @return jsapi ticket * @throws WxErrorException . */ String getJsapiTicket(boolean forceRefresh) throws WxErrorException; /** * <pre> * 创建调用jsapi时所需要的签名. * * 详情请见:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN * </pre> * * @param url 地址 * @return 生成的签名对象 wx jsapi signature * @throws WxErrorException . */ WxJsapiSignature createJsapiSignature(String url) throws WxErrorException; /** * <pre> * 长链接转短链接接口. * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=长链接转短链接接口 * </pre> * * @param longUrl 长url * @return 生成的短地址 string * @throws WxErrorException . */ String shortUrl(String longUrl) throws WxErrorException; /** * <pre> * 构造第三方使用网站应用授权登录的url. * 详情请见: <a href= "https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419316505&token=&lang=zh_CN">网站应用微信登录开发指南</a> * URL格式为:https://open.weixin.qq.com/connect/qrconnect?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect * </pre> * * @param redirectUri 用户授权完成后的重定向链接,无需urlencode, 方法内会进行encode * @param scope 应用授权作用域,拥有多个作用域用逗号(,)分隔,网页应用目前仅填写snsapi_login即可 * @param state 非必填,用于保持请求和回调的状态,授权请求后原样带回给第三方。该参数可用于防止csrf攻击(跨站请求伪造攻击),建议第三方带上该参数,可设置为简单的随机数加session进行校验 * @return url string */ String buildQrConnectUrl(String redirectUri, String scope, String state); /** * <pre> * 获取微信服务器IP地址 * http://mp.weixin.qq.com/wiki/0/2ad4b6bfd29f30f71d39616c2a0fcedc.html * </pre> * * @return 微信服务器ip地址数组 string [ ] * @throws WxErrorException . */ String[] getCallbackIP() throws WxErrorException; /** * <pre> * 网络检测 * https://mp.weixin.qq.com/wiki?t=resource/res_main&id=21541575776DtsuT * 为了帮助开发者排查回调连接失败的问题,提供这个网络检测的API。它可以对开发者URL做域名解析,然后对所有IP进行一次ping操作,得到丢包率和耗时。 * </pre> * * @param action 执行的检测动作 * @param operator 指定平台从某个运营商进行检测 * @return 检测结果 wx net check result * @throws WxErrorException . */ WxNetCheckResult netCheck(String action, String operator) throws WxErrorException; /** * <pre> * 公众号调用或第三方平台帮公众号调用对公众号的所有api调用(包括第三方帮其调用)次数进行清零: * HTTP调用:https://api.weixin.qq.com/cgi-bin/clear_quota?access_token=ACCESS_TOKEN * 接口文档地址:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433744592 * * </pre> * * @param appid 公众号的APPID * @throws WxErrorException the wx error exception */ void clearQuota(String appid) throws WxErrorException; /** * <pre> * Service没有实现某个API的时候,可以用这个, * 比{@link #get}和{@link #post}方法更灵活,可以自己构造RequestExecutor用来处理不同的参数和不同的返回类型。 * 可以参考,{@link MediaUploadRequestExecutor}的实现方法 * </pre> * * @param <T> the type parameter * @param <E> the type parameter * @param executor 执行器 * @param url 接口地址 * @param data 参数数据 * @return 结果 t * @throws WxErrorException 异常 */ <T, E> T execute(RequestExecutor<T, E> executor, String url, E data) throws WxErrorException; /** * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求. * * @param url 请求接口地址 * @param queryParam 参数 * @return 接口响应字符串 string * @throws WxErrorException 异常 */ String get(WxQidianApiUrl url, String queryParam) throws WxErrorException; /** * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求. * * @param url 请求接口地址 * @param postData 请求参数json值 * @return 接口响应字符串 string * @throws WxErrorException 异常 */ String post(WxQidianApiUrl url, String postData) throws WxErrorException; /** * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求. * * @param url 请求接口地址 * @param jsonObject 请求参数json对象 * @return 接口响应字符串 string * @throws WxErrorException 异常 */ String post(WxQidianApiUrl url, JsonObject jsonObject) throws WxErrorException; /** * <pre> * Service没有实现某个API的时候,可以用这个, * 比{@link #get}和{@link #post}方法更灵活,可以自己构造RequestExecutor用来处理不同的参数和不同的返回类型。 * 可以参考,{@link MediaUploadRequestExecutor}的实现方法 * </pre> * * @param <T> the type parameter * @param <E> the type parameter * @param executor 执行器 * @param url 接口地址 * @param data 参数数据 * @return 结果 t * @throws WxErrorException 异常 */ <T, E> T execute(RequestExecutor<T, E> executor, WxQidianApiUrl url, E data) throws WxErrorException; /** * 设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试. * * @param retrySleepMillis 默认:1000ms */ void setRetrySleepMillis(int retrySleepMillis); /** * <pre> * 设置当微信系统响应系统繁忙时,最大重试次数. * 默认:5次 * </pre> * * @param maxRetryTimes 最大重试次数 */ void setMaxRetryTimes(int maxRetryTimes); /** * 获取WxMpConfigStorage 对象. * * @return WxMpConfigStorage wx mp config storage */ WxQidianConfigStorage getWxMpConfigStorage(); /** * 设置 {@link WxQidianConfigStorage} 的实现. 兼容老版本 * * @param wxConfigProvider . */ void setWxMpConfigStorage(WxQidianConfigStorage wxConfigProvider); /** * Map里 加入新的 {@link WxQidianConfigStorage},适用于动态添加新的微信公众号配置. * * @param mpId 公众号id * @param configStorage 新的微信配置 */ void addConfigStorage(String mpId, WxQidianConfigStorage configStorage); /** * 从 Map中 移除 {@link String mpId} 所对应的 * {@link WxQidianConfigStorage},适用于动态移除微信公众号配置. * * @param mpId 对应公众号的标识 */ void removeConfigStorage(String mpId); /** * 注入多个 {@link WxQidianConfigStorage} 的实现. 并为每个 {@link WxQidianConfigStorage} * 赋予不同的 {@link String mpId} 值 随机采用一个{@link String mpId}进行Http初始化操作 * * @param configStorages WxMpConfigStorage map */ void setMultiConfigStorages(Map<String, WxQidianConfigStorage> configStorages); /** * 注入多个 {@link WxQidianConfigStorage} 的实现. 并为每个 {@link WxQidianConfigStorage} * 赋予不同的 {@link String label} 值 * * @param configStorages WxMpConfigStorage map * @param defaultMpId 设置一个{@link WxQidianConfigStorage} 所对应的{@link String * mpId}进行Http初始化 */ void setMultiConfigStorages(Map<String, WxQidianConfigStorage> configStorages, String defaultMpId); /** * 进行相应的公众号切换. * * @param mpId 公众号标识 * @return 切换是否成功 boolean */ boolean switchover(String mpId); /** * 进行相应的公众号切换. * * @param mpId 公众号标识 * @return 切换成功 ,则返回当前对象,方便链式调用,否则抛出异常 */ WxQidianService switchoverTo(String mpId); /** * 初始化http请求对象. */ void initHttp(); /** * 获取RequestHttp对象. * * @return RequestHttp对象 request http */ RequestHttp<?, ?> getRequestHttp(); WxQidianDialService getDialService(); WxQidianCallDataService getCallDataService(); }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/WxQidianDialService.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/WxQidianDialService.java
package me.chanjar.weixin.qidian.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.qidian.bean.dial.IVRDialRequest; import me.chanjar.weixin.qidian.bean.dial.IVRDialResponse; import me.chanjar.weixin.qidian.bean.dial.IVRListResponse; /** * 基础话务相关操作接口. * * @author alegria */ public interface WxQidianDialService { IVRDialResponse ivrDial(IVRDialRequest ivrDial) throws WxErrorException; IVRListResponse getIVRList() throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/WxQidianCallDataService.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/WxQidianCallDataService.java
package me.chanjar.weixin.qidian.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.qidian.bean.call.GetSwitchBoardListResponse; /** * 通话数据相关操作接口. * * @author alegria */ public interface WxQidianCallDataService { public GetSwitchBoardListResponse getSwitchBoardList() throws WxErrorException; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianServiceOkHttpImpl.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianServiceOkHttpImpl.java
package me.chanjar.weixin.qidian.api.impl; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.http.HttpClientType; import me.chanjar.weixin.common.util.http.okhttp.DefaultOkHttpClientBuilder; import me.chanjar.weixin.common.util.http.okhttp.OkHttpProxyInfo; import me.chanjar.weixin.qidian.config.WxQidianConfigStorage; import okhttp3.*; import java.io.IOException; import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import static me.chanjar.weixin.qidian.enums.WxQidianApiUrl.Other.GET_ACCESS_TOKEN_URL; /** * okhttp实现. * * @author someone */ public class WxQidianServiceOkHttpImpl extends BaseWxQidianServiceImpl<OkHttpClient, OkHttpProxyInfo> { private OkHttpClient httpClient; private OkHttpProxyInfo httpProxy; @Override public OkHttpClient getRequestHttpClient() { return httpClient; } @Override public OkHttpProxyInfo getRequestHttpProxy() { return httpProxy; } @Override public HttpClientType getRequestType() { return HttpClientType.OK_HTTP; } @Override public String getAccessToken(boolean forceRefresh) throws WxErrorException { final WxQidianConfigStorage config = this.getWxMpConfigStorage(); if (!config.isAccessTokenExpired() && !forceRefresh) { return config.getAccessToken(); } Lock lock = config.getAccessTokenLock(); boolean locked = false; try { do { locked = lock.tryLock(100, TimeUnit.MILLISECONDS); if (!forceRefresh && !config.isAccessTokenExpired()) { return config.getAccessToken(); } } while (!locked); String url = String.format(GET_ACCESS_TOKEN_URL.getUrl(config), config.getAppId(), config.getSecret()); Request request = new Request.Builder().url(url).get().build(); Response response = getRequestHttpClient().newCall(request).execute(); return this.extractAccessToken(Objects.requireNonNull(response.body()).string()); } catch (IOException | InterruptedException e) { throw new WxRuntimeException(e); } finally { if (locked) { lock.unlock(); } } } @Override public void initHttp() { WxQidianConfigStorage wxMpConfigStorage = getWxMpConfigStorage(); // 设置代理 if (wxMpConfigStorage.getHttpProxyHost() != null && wxMpConfigStorage.getHttpProxyPort() > 0) { httpProxy = OkHttpProxyInfo.httpProxy(wxMpConfigStorage.getHttpProxyHost(), wxMpConfigStorage.getHttpProxyPort(), wxMpConfigStorage.getHttpProxyUsername(), wxMpConfigStorage.getHttpProxyPassword()); OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder(); clientBuilder.proxy(getRequestHttpProxy().getProxy()); // 设置授权 clientBuilder.proxyAuthenticator(new Authenticator() { @Override public Request authenticate(Route route, Response response) throws IOException { String credential = Credentials.basic(httpProxy.getProxyUsername(), httpProxy.getProxyPassword()); return response.request().newBuilder().header("Proxy-Authorization", credential).build(); } }); httpClient = clientBuilder.build(); } else { httpClient = DefaultOkHttpClientBuilder.get().build(); } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianDialServiceImpl.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianDialServiceImpl.java
package me.chanjar.weixin.qidian.api.impl; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.qidian.api.WxQidianDialService; import me.chanjar.weixin.qidian.api.WxQidianService; import me.chanjar.weixin.qidian.bean.dial.IVRDialRequest; import me.chanjar.weixin.qidian.bean.dial.IVRDialResponse; import me.chanjar.weixin.qidian.bean.dial.IVRListResponse; import static me.chanjar.weixin.qidian.enums.WxQidianApiUrl.Dial.GET_IVR_LIST; import static me.chanjar.weixin.qidian.enums.WxQidianApiUrl.Dial.IVR_DIAL; /** * Created by Binary Wang on 2016/7/21. * * @author Binary Wang */ @Slf4j @RequiredArgsConstructor public class WxQidianDialServiceImpl implements WxQidianDialService { private final WxQidianService wxQidianService; @Override public IVRDialResponse ivrDial(IVRDialRequest ivrDial) throws WxErrorException { String json = ivrDial.toJson(); log.debug("IVR外呼:{}", json); String result = this.wxQidianService.post(IVR_DIAL, json); log.debug("创建菜单:{},结果:{}", json, result); return IVRDialResponse.fromJson(result); } @Override public IVRListResponse getIVRList() throws WxErrorException { String result = this.wxQidianService.get(GET_IVR_LIST, null); return IVRListResponse.fromJson(result); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianServiceJoddHttpImpl.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianServiceJoddHttpImpl.java
package me.chanjar.weixin.qidian.api.impl; import jodd.http.HttpConnectionProvider; import jodd.http.HttpRequest; import jodd.http.ProxyInfo; import jodd.http.net.SocketHttpConnectionProvider; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.http.HttpClientType; import me.chanjar.weixin.qidian.config.WxQidianConfigStorage; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import static me.chanjar.weixin.qidian.enums.WxQidianApiUrl.Other.GET_ACCESS_TOKEN_URL; /** * jodd-http方式实现. * * @author someone */ public class WxQidianServiceJoddHttpImpl extends BaseWxQidianServiceImpl<HttpConnectionProvider, ProxyInfo> { private HttpConnectionProvider httpClient; private ProxyInfo httpProxy; @Override public HttpConnectionProvider getRequestHttpClient() { return httpClient; } @Override public ProxyInfo getRequestHttpProxy() { return httpProxy; } @Override public HttpClientType getRequestType() { return HttpClientType.JODD_HTTP; } @Override public void initHttp() { WxQidianConfigStorage configStorage = this.getWxMpConfigStorage(); if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) { httpProxy = new ProxyInfo(ProxyInfo.ProxyType.HTTP, configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort(), configStorage.getHttpProxyUsername(), configStorage.getHttpProxyPassword()); } httpClient = new SocketHttpConnectionProvider(); } @Override public String getAccessToken(boolean forceRefresh) throws WxErrorException { final WxQidianConfigStorage config = this.getWxMpConfigStorage(); if (!config.isAccessTokenExpired() && !forceRefresh) { return config.getAccessToken(); } Lock lock = config.getAccessTokenLock(); boolean locked = false; try { do { locked = lock.tryLock(100, TimeUnit.MILLISECONDS); if (!forceRefresh && !config.isAccessTokenExpired()) { return config.getAccessToken(); } } while (!locked); String url = String.format(GET_ACCESS_TOKEN_URL.getUrl(config), config.getAppId(), config.getSecret()); HttpRequest request = HttpRequest.get(url); if (this.getRequestHttpProxy() != null) { SocketHttpConnectionProvider provider = new SocketHttpConnectionProvider(); provider.useProxy(getRequestHttpProxy()); request.withConnectionProvider(provider); } return this.extractAccessToken(request.send().bodyText()); } catch (InterruptedException e) { throw new WxRuntimeException(e); } finally { if (locked) { lock.unlock(); } } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianServiceHttpComponentsImpl.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianServiceHttpComponentsImpl.java
package me.chanjar.weixin.qidian.api.impl; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.http.HttpClientType; import me.chanjar.weixin.common.util.http.hc.BasicResponseHandler; import me.chanjar.weixin.common.util.http.hc.DefaultHttpComponentsClientBuilder; import me.chanjar.weixin.common.util.http.hc.HttpComponentsClientBuilder; import me.chanjar.weixin.qidian.config.WxQidianConfigStorage; import org.apache.hc.client5.http.classic.methods.HttpGet; import org.apache.hc.client5.http.config.RequestConfig; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.core5.http.HttpHost; import java.io.IOException; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import static me.chanjar.weixin.qidian.enums.WxQidianApiUrl.Other.GET_ACCESS_TOKEN_URL; /** * apache http client5 方式实现. * * @author altusea */ public class WxQidianServiceHttpComponentsImpl extends BaseWxQidianServiceImpl<CloseableHttpClient, HttpHost> { private CloseableHttpClient httpClient; private HttpHost httpProxy; @Override public CloseableHttpClient getRequestHttpClient() { return httpClient; } @Override public HttpHost getRequestHttpProxy() { return httpProxy; } @Override public HttpClientType getRequestType() { return HttpClientType.HTTP_COMPONENTS; } @Override public void initHttp() { WxQidianConfigStorage configStorage = this.getWxMpConfigStorage(); HttpComponentsClientBuilder apacheHttpClientBuilder = DefaultHttpComponentsClientBuilder.get(); apacheHttpClientBuilder.httpProxyHost(configStorage.getHttpProxyHost()) .httpProxyPort(configStorage.getHttpProxyPort()).httpProxyUsername(configStorage.getHttpProxyUsername()) .httpProxyPassword(configStorage.getHttpProxyPassword().toCharArray()); if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) { this.httpProxy = new HttpHost(configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort()); } this.httpClient = apacheHttpClientBuilder.build(); } @Override public String getAccessToken(boolean forceRefresh) throws WxErrorException { final WxQidianConfigStorage config = this.getWxMpConfigStorage(); if (!config.isAccessTokenExpired() && !forceRefresh) { return config.getAccessToken(); } Lock lock = config.getAccessTokenLock(); boolean locked = false; try { do { locked = lock.tryLock(100, TimeUnit.MILLISECONDS); if (!forceRefresh && !config.isAccessTokenExpired()) { return config.getAccessToken(); } } while (!locked); String url = String.format(GET_ACCESS_TOKEN_URL.getUrl(config), config.getAppId(), config.getSecret()); try { HttpGet httpGet = new HttpGet(url); if (this.getRequestHttpProxy() != null) { RequestConfig requestConfig = RequestConfig.custom().setProxy(this.getRequestHttpProxy()).build(); httpGet.setConfig(requestConfig); } String responseContent = getRequestHttpClient().execute(httpGet, BasicResponseHandler.INSTANCE); return this.extractAccessToken(responseContent); } catch (IOException e) { throw new WxRuntimeException(e); } } catch (InterruptedException e) { throw new WxRuntimeException(e); } finally { if (locked) { lock.unlock(); } } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/BaseWxQidianServiceImpl.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/BaseWxQidianServiceImpl.java
package me.chanjar.weixin.qidian.api.impl; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.api.WxConsts; import me.chanjar.weixin.common.bean.*; import me.chanjar.weixin.common.enums.TicketType; import me.chanjar.weixin.common.enums.WxType; import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.executor.CommonUploadRequestExecutor; import me.chanjar.weixin.common.util.DataUtils; import me.chanjar.weixin.common.util.RandomUtils; import me.chanjar.weixin.common.util.crypto.SHA1; import me.chanjar.weixin.common.util.http.*; import me.chanjar.weixin.common.util.json.GsonParser; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import me.chanjar.weixin.qidian.api.WxQidianCallDataService; import me.chanjar.weixin.qidian.api.WxQidianDialService; import me.chanjar.weixin.qidian.api.WxQidianService; import me.chanjar.weixin.qidian.config.WxQidianConfigStorage; import me.chanjar.weixin.qidian.enums.WxQidianApiUrl; import me.chanjar.weixin.qidian.util.WxQidianConfigStorageHolder; import org.apache.commons.lang3.StringUtils; import java.io.IOException; import java.util.Map; import java.util.concurrent.locks.Lock; import static me.chanjar.weixin.qidian.enums.WxQidianApiUrl.Other.*; /** * 基础实现类. * * @author someone */ @Slf4j public abstract class BaseWxQidianServiceImpl<H, P> implements WxQidianService, RequestHttp<H, P> { @Getter private final WxQidianDialService dialService = new WxQidianDialServiceImpl(this); @Getter private final WxQidianCallDataService callDataService = new WxQidianCallDataServiceImpl(this); private Map<String, WxQidianConfigStorage> configStorageMap; private int retrySleepMillis = 1000; private int maxRetryTimes = 5; @Override public boolean checkSignature(String timestamp, String nonce, String signature) { try { return SHA1.gen(this.getWxMpConfigStorage().getToken(), timestamp, nonce).equals(signature); } catch (Exception e) { log.error("Checking signature failed, and the reason is :{}", e.getMessage()); return false; } } @Override public String getTicket(TicketType type) throws WxErrorException { return this.getTicket(type, false); } @Override public String getTicket(TicketType type, boolean forceRefresh) throws WxErrorException { if (forceRefresh) { this.getWxMpConfigStorage().expireTicket(type); } if (this.getWxMpConfigStorage().isTicketExpired(type)) { Lock lock = this.getWxMpConfigStorage().getTicketLock(type); lock.lock(); try { if (this.getWxMpConfigStorage().isTicketExpired(type)) { String responseContent = execute(SimpleGetRequestExecutor.create(this), GET_TICKET_URL.getUrl(this.getWxMpConfigStorage()) + type.getCode(), null); JsonObject tmpJsonObject = GsonParser.parse(responseContent); String jsapiTicket = tmpJsonObject.get("ticket").getAsString(); int expiresInSeconds = tmpJsonObject.get("expires_in").getAsInt(); this.getWxMpConfigStorage().updateTicket(type, jsapiTicket, expiresInSeconds); } } finally { lock.unlock(); } } return this.getWxMpConfigStorage().getTicket(type); } @Override public String getJsapiTicket() throws WxErrorException { return this.getJsapiTicket(false); } @Override public String getJsapiTicket(boolean forceRefresh) throws WxErrorException { return this.getTicket(TicketType.JSAPI, forceRefresh); } @Override public WxJsapiSignature createJsapiSignature(String url) throws WxErrorException { long timestamp = System.currentTimeMillis() / 1000; String randomStr = RandomUtils.getRandomStr(); String jsapiTicket = getJsapiTicket(false); String signature = SHA1.genWithAmple("jsapi_ticket=" + jsapiTicket, "noncestr=" + randomStr, "timestamp=" + timestamp, "url=" + url); WxJsapiSignature jsapiSignature = new WxJsapiSignature(); jsapiSignature.setAppId(this.getWxMpConfigStorage().getAppId()); jsapiSignature.setTimestamp(timestamp); jsapiSignature.setNonceStr(randomStr); jsapiSignature.setUrl(url); jsapiSignature.setSignature(signature); return jsapiSignature; } @Override public String getAccessToken() throws WxErrorException { return getAccessToken(false); } @Override public String shortUrl(String longUrl) throws WxErrorException { if (longUrl.contains("&access_token=")) { throw new WxErrorException("要转换的网址中存在非法字符{&access_token=}," + "会导致微信接口报错,属于微信bug,请调整地址,否则不建议使用此方法!"); } JsonObject o = new JsonObject(); o.addProperty("action", "long2short"); o.addProperty("long_url", longUrl); String responseContent = this.post(SHORTURL_API_URL, o.toString()); return GsonParser.parse(responseContent).get("short_url").getAsString(); } @Override public String buildQrConnectUrl(String redirectUri, String scope, String state) { return String.format(QRCONNECT_URL.getUrl(this.getWxMpConfigStorage()), this.getWxMpConfigStorage().getAppId(), URIUtil.encodeURIComponent(redirectUri), scope, StringUtils.trimToEmpty(state)); } @Override public String[] getCallbackIP() throws WxErrorException { String responseContent = this.get(GET_CALLBACK_IP_URL, null); JsonObject tmpJsonObject = GsonParser.parse(responseContent); JsonArray ipList = tmpJsonObject.get("ip_list").getAsJsonArray(); String[] ipArray = new String[ipList.size()]; for (int i = 0; i < ipList.size(); i++) { ipArray[i] = ipList.get(i).getAsString(); } return ipArray; } @Override public WxNetCheckResult netCheck(String action, String operator) throws WxErrorException { JsonObject o = new JsonObject(); o.addProperty("action", action); o.addProperty("check_operator", operator); String responseContent = this.post(NETCHECK_URL, o.toString()); return WxNetCheckResult.fromJson(responseContent); } @Override public void clearQuota(String appid) throws WxErrorException { JsonObject o = new JsonObject(); o.addProperty("appid", appid); this.post(CLEAR_QUOTA_URL, o.toString()); } @Override public String get(String url, String queryParam) throws WxErrorException { return execute(SimpleGetRequestExecutor.create(this), url, queryParam); } @Override public String get(WxQidianApiUrl url, String queryParam) throws WxErrorException { return this.get(url.getUrl(this.getWxMpConfigStorage()), queryParam); } @Override public String post(String url, String postData) throws WxErrorException { return execute(SimplePostRequestExecutor.create(this), url, postData); } @Override public String post(WxQidianApiUrl url, String postData) throws WxErrorException { return this.post(url.getUrl(this.getWxMpConfigStorage()), postData); } @Override public String post(WxQidianApiUrl url, JsonObject jsonObject) throws WxErrorException { return this.post(url.getUrl(this.getWxMpConfigStorage()), jsonObject.toString()); } @Override public String post(String url, ToJson obj) throws WxErrorException { return this.post(url, obj.toJson()); } @Override public String upload(String url, CommonUploadParam param) throws WxErrorException { RequestExecutor<String, CommonUploadParam> executor = CommonUploadRequestExecutor.create(getRequestHttp()); return this.execute(executor, url, param); } @Override public String post(String url, JsonObject jsonObject) throws WxErrorException { return this.post(url, jsonObject.toString()); } @Override public String post(String url, Object obj) throws WxErrorException { return this.execute(SimplePostRequestExecutor.create(this), url, WxGsonBuilder.create().toJson(obj)); } @Override public <T, E> T execute(RequestExecutor<T, E> executor, WxQidianApiUrl url, E data) throws WxErrorException { return this.execute(executor, url.getUrl(this.getWxMpConfigStorage()), data); } /** * 向微信端发送请求,在这里执行的策略是当发生access_token过期时才去刷新,然后重新执行请求,而不是全局定时请求. */ @Override public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { int retryTimes = 0; do { try { return this.executeInternal(executor, uri, data); } catch (WxErrorException e) { if (retryTimes + 1 > this.maxRetryTimes) { log.warn("重试达到最大次数【{}】", maxRetryTimes); // 最后一次重试失败后,直接抛出异常,不再等待 throw new WxRuntimeException("微信服务端异常,超出重试次数"); } WxError error = e.getError(); // -1 系统繁忙, 1000ms后重试 if (error.getErrorCode() == -1) { int sleepMillis = this.retrySleepMillis * (1 << retryTimes); try { log.warn("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1); Thread.sleep(sleepMillis); } catch (InterruptedException e1) { throw new WxRuntimeException(e1); } } else { throw e; } } } while (retryTimes++ < this.maxRetryTimes); log.warn("重试达到最大次数【{}】", this.maxRetryTimes); throw new WxRuntimeException("微信服务端异常,超出重试次数"); } protected <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { E dataForLog = DataUtils.handleDataWithSecret(data); if (uri.contains("access_token=")) { throw new IllegalArgumentException("uri参数中不允许有access_token: " + uri); } String accessToken = getAccessToken(false); String uriWithAccessToken = uri + (uri.contains("?") ? "&" : "?") + "access_token=" + accessToken; try { T result = executor.execute(uriWithAccessToken, data, WxType.MP); log.debug("\n【请求地址】: {}\n【请求参数】:{}\n【响应数据】:{}", uriWithAccessToken, dataForLog, result); return result; } catch (WxErrorException e) { WxError error = e.getError(); if (WxConsts.ACCESS_TOKEN_ERROR_CODES.contains(error.getErrorCode())) { // 强制设置wxMpConfigStorage它的access token过期了,这样在下一次请求里就会刷新access token Lock lock = this.getWxMpConfigStorage().getAccessTokenLock(); lock.lock(); try { if (StringUtils.equals(this.getWxMpConfigStorage().getAccessToken(), accessToken)) { this.getWxMpConfigStorage().expireAccessToken(); } } catch (Exception ex) { this.getWxMpConfigStorage().expireAccessToken(); } finally { lock.unlock(); } if (this.getWxMpConfigStorage().autoRefreshToken()) { log.warn("即将重新获取新的access_token,错误代码:{},错误信息:{}", error.getErrorCode(), error.getErrorMsg()); return this.execute(executor, uri, data); } } if (error.getErrorCode() != 0) { log.error("\n【请求地址】: {}\n【请求参数】:{}\n【错误信息】:{}", uriWithAccessToken, dataForLog, error); throw new WxErrorException(error, e); } return null; } catch (IOException e) { log.error("\n【请求地址】: {}\n【请求参数】:{}\n【异常信息】:{}", uriWithAccessToken, dataForLog, e.getMessage()); throw new WxErrorException(e); } } @Override public WxQidianConfigStorage getWxMpConfigStorage() { if (this.configStorageMap.size() == 1) { // 只有一个公众号,直接返回其配置即可 return this.configStorageMap.values().iterator().next(); } return this.configStorageMap.get(WxQidianConfigStorageHolder.get()); } protected String extractAccessToken(String resultContent) throws WxErrorException { WxQidianConfigStorage config = this.getWxMpConfigStorage(); WxError error = WxError.fromJson(resultContent, WxType.MP); if (error.getErrorCode() != 0) { throw new WxErrorException(error); } WxAccessToken accessToken = WxAccessToken.fromJson(resultContent); config.updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); return config.getAccessToken(); } @Override public void setWxMpConfigStorage(WxQidianConfigStorage wxConfigProvider) { final String defaultMpId = wxConfigProvider.getAppId(); this.setMultiConfigStorages(ImmutableMap.of(defaultMpId, wxConfigProvider), defaultMpId); } @Override public void setMultiConfigStorages(Map<String, WxQidianConfigStorage> configStorages) { this.setMultiConfigStorages(configStorages, configStorages.keySet().iterator().next()); } @Override public void setMultiConfigStorages(Map<String, WxQidianConfigStorage> configStorages, String defaultMpId) { this.configStorageMap = Maps.newHashMap(configStorages); WxQidianConfigStorageHolder.set(defaultMpId); this.initHttp(); } @Override public void addConfigStorage(String mpId, WxQidianConfigStorage configStorages) { synchronized (this) { if (this.configStorageMap == null) { this.setWxMpConfigStorage(configStorages); } else { this.configStorageMap.put(mpId, configStorages); } } } @Override public void removeConfigStorage(String mpId) { synchronized (this) { if (this.configStorageMap.size() == 1) { this.configStorageMap.remove(mpId); log.warn("已删除最后一个公众号配置:{},须立即使用setWxMpConfigStorage或setMultiConfigStorages添加配置", mpId); return; } if (WxQidianConfigStorageHolder.get().equals(mpId)) { this.configStorageMap.remove(mpId); final String defaultMpId = this.configStorageMap.keySet().iterator().next(); WxQidianConfigStorageHolder.set(defaultMpId); log.warn("已删除默认公众号配置,公众号【{}】被设为默认配置", defaultMpId); return; } this.configStorageMap.remove(mpId); } } @Override public WxQidianService switchoverTo(String mpId) { if (this.configStorageMap.containsKey(mpId)) { WxQidianConfigStorageHolder.set(mpId); return this; } throw new WxRuntimeException(String.format("无法找到对应【%s】的公众号配置信息,请核实!", mpId)); } @Override public boolean switchover(String mpId) { if (this.configStorageMap.containsKey(mpId)) { WxQidianConfigStorageHolder.set(mpId); return true; } log.error("无法找到对应【{}】的公众号配置信息,请核实!", mpId); return false; } @Override public void setRetrySleepMillis(int retrySleepMillis) { this.retrySleepMillis = retrySleepMillis; } @Override public void setMaxRetryTimes(int maxRetryTimes) { this.maxRetryTimes = maxRetryTimes; } @Override public RequestHttp<H, P> getRequestHttp() { return this; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianServiceImpl.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianServiceImpl.java
package me.chanjar.weixin.qidian.api.impl; /** * <pre> * 默认接口实现类,使用apache httpclient实现 * Created by Binary Wang on 2017-5-27. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public class WxQidianServiceImpl extends WxQidianServiceHttpClientImpl { }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianCallDataServiceImpl.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianCallDataServiceImpl.java
package me.chanjar.weixin.qidian.api.impl; import static me.chanjar.weixin.qidian.enums.WxQidianApiUrl.CallData.GET_SWITCH_BOARD_LIST; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.qidian.api.WxQidianCallDataService; import me.chanjar.weixin.qidian.api.WxQidianService; import me.chanjar.weixin.qidian.bean.call.GetSwitchBoardListResponse; @Slf4j @RequiredArgsConstructor public class WxQidianCallDataServiceImpl implements WxQidianCallDataService { private final WxQidianService wxQidianService; @Override public GetSwitchBoardListResponse getSwitchBoardList() throws WxErrorException { String result = this.wxQidianService.get(GET_SWITCH_BOARD_LIST, null); return GetSwitchBoardListResponse.fromJson(result); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianServiceHttpClientImpl.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/api/impl/WxQidianServiceHttpClientImpl.java
package me.chanjar.weixin.qidian.api.impl; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxRuntimeException; import me.chanjar.weixin.common.util.http.HttpClientType; import me.chanjar.weixin.common.util.http.apache.ApacheBasicResponseHandler; import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder; import me.chanjar.weixin.qidian.config.WxQidianConfigStorage; import org.apache.http.HttpHost; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import java.io.IOException; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import static me.chanjar.weixin.qidian.enums.WxQidianApiUrl.Other.GET_ACCESS_TOKEN_URL; /** * apache http client方式实现. * * @author someone */ public class WxQidianServiceHttpClientImpl extends BaseWxQidianServiceImpl<CloseableHttpClient, HttpHost> { private CloseableHttpClient httpClient; private HttpHost httpProxy; @Override public CloseableHttpClient getRequestHttpClient() { return httpClient; } @Override public HttpHost getRequestHttpProxy() { return httpProxy; } @Override public HttpClientType getRequestType() { return HttpClientType.APACHE_HTTP; } @Override public void initHttp() { WxQidianConfigStorage configStorage = this.getWxMpConfigStorage(); ApacheHttpClientBuilder apacheHttpClientBuilder = configStorage.getApacheHttpClientBuilder(); if (null == apacheHttpClientBuilder) { apacheHttpClientBuilder = DefaultApacheHttpClientBuilder.get(); } apacheHttpClientBuilder.httpProxyHost(configStorage.getHttpProxyHost()) .httpProxyPort(configStorage.getHttpProxyPort()).httpProxyUsername(configStorage.getHttpProxyUsername()) .httpProxyPassword(configStorage.getHttpProxyPassword()); if (configStorage.getHttpProxyHost() != null && configStorage.getHttpProxyPort() > 0) { this.httpProxy = new HttpHost(configStorage.getHttpProxyHost(), configStorage.getHttpProxyPort()); } this.httpClient = apacheHttpClientBuilder.build(); } @Override public String getAccessToken(boolean forceRefresh) throws WxErrorException { final WxQidianConfigStorage config = this.getWxMpConfigStorage(); if (!config.isAccessTokenExpired() && !forceRefresh) { return config.getAccessToken(); } Lock lock = config.getAccessTokenLock(); boolean locked = false; try { do { locked = lock.tryLock(100, TimeUnit.MILLISECONDS); if (!forceRefresh && !config.isAccessTokenExpired()) { return config.getAccessToken(); } } while (!locked); String url = String.format(GET_ACCESS_TOKEN_URL.getUrl(config), config.getAppId(), config.getSecret()); try { HttpGet httpGet = new HttpGet(url); if (this.getRequestHttpProxy() != null) { RequestConfig requestConfig = RequestConfig.custom().setProxy(this.getRequestHttpProxy()).build(); httpGet.setConfig(requestConfig); } String responseContent = getRequestHttpClient().execute(httpGet, ApacheBasicResponseHandler.INSTANCE); return this.extractAccessToken(responseContent); } catch (IOException e) { throw new WxRuntimeException(e); } } catch (InterruptedException e) { throw new WxRuntimeException(e); } finally { if (locked) { lock.unlock(); } } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/WxQidianHostConfig.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/WxQidianHostConfig.java
package me.chanjar.weixin.qidian.bean; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; /** * 企点接口地址域名部分的自定义设置信息. * * @author alegria * created on 2020-12-24 */ @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WxQidianHostConfig { public static final String API_DEFAULT_HOST_URL = "https://api.weixin.qq.com"; public static final String OPEN_DEFAULT_HOST_URL = "https://open.weixin.qq.com"; public static final String QIDIAN_DEFAULT_HOST_URL = "https://api.qidian.qq.com"; /** * 对应于:https://api.weixin.qq.com */ private String apiHost; /** * 对应于:https://open.weixin.qq.com */ private String openHost; /** * 对应于:https://api.qidian.qq.com */ private String qidianHost; public static String buildUrl(WxQidianHostConfig hostConfig, String prefix, String path) { if (hostConfig == null) { return prefix + path; } if (hostConfig.getApiHost() != null && prefix.equals(API_DEFAULT_HOST_URL)) { return hostConfig.getApiHost() + path; } if (hostConfig.getQidianHost() != null && prefix.equals(QIDIAN_DEFAULT_HOST_URL)) { return hostConfig.getQidianHost() + path; } if (hostConfig.getOpenHost() != null && prefix.equals(OPEN_DEFAULT_HOST_URL)) { return hostConfig.getOpenHost() + path; } return prefix + path; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/call/SwitchBoard.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/call/SwitchBoard.java
package me.chanjar.weixin.qidian.bean.call; import lombok.Data; @Data public class SwitchBoard { private String switchboard; private String createTime; private Boolean callinStatus; private Boolean calloutStatus; private String spName; private String cityName; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/call/GetSwitchBoardListResponse.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/call/GetSwitchBoardListResponse.java
package me.chanjar.weixin.qidian.bean.call; import lombok.Data; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import me.chanjar.weixin.qidian.bean.common.QidianResponse; @Data public class GetSwitchBoardListResponse extends QidianResponse { private SwitchBoardList data; public static GetSwitchBoardListResponse fromJson(String result) { return WxGsonBuilder.create().fromJson(result, GetSwitchBoardListResponse.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/call/SwitchBoardList.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/call/SwitchBoardList.java
package me.chanjar.weixin.qidian.bean.call; import java.util.List; import java.util.stream.Collectors; import lombok.Data; @Data public class SwitchBoardList { private List<SwitchBoard> records; public List<String> switchBoards() { return records.stream().map(SwitchBoard::getSwitchboard).collect(Collectors.toList()); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/common/QidianResponse.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/common/QidianResponse.java
package me.chanjar.weixin.qidian.bean.common; import lombok.Data; import java.util.HashMap; import java.util.Map; @Data public class QidianResponse { private static Map<Integer, String> errorCodesMap = new HashMap<Integer, String>() { private static final long serialVersionUID = 1125349909878104934L; { put(-1, "系统繁忙"); put(0, "请求成功"); put(40001, "获取access_token时AppSecret错误,或者access_token无效"); put(40002, "不合法的凭证类型"); put(40003, "不合法的OpenID"); put(40004, "不合法的媒体文件类型"); put(40005, "不合法的文件类型"); put(40006, "不合法的文件大小"); put(40007, "不合法的媒体文件id"); put(40008, "不合法的消息类型"); put(40009, "不合法的图片文件大小"); put(40010, "不合法的语音文件大小"); put(40011, "不合法的视频文件大小"); put(40012, "不合法的缩略图文件大小"); put(40013, "不合法的APPID"); put(40014, "不合法的access_token"); put(40015, "不合法的菜单类型"); put(40016, "不合法的按钮个数"); put(40017, "不合法的按钮个数"); put(40018, "不合法的按钮名字长度"); put(40019, "不合法的按钮KEY长度"); put(40020, "不合法的按钮URL长度"); put(40021, "不合法的菜单版本号"); put(40022, "不合法的子菜单级数"); put(40023, "不合法的子菜单按钮个数"); put(40024, "不合法的子菜单按钮类型"); put(40025, "不合法的子菜单按钮名字长度"); put(40026, "不合法的子菜单按钮KEY长度"); put(40027, "不合法的子菜单按钮URL长度"); put(40028, "不合法的自定义菜单使用用户"); put(40029, "不合法的oauth_code"); put(40030, "不合法的refresh_token"); put(40031, "不合法的openid列表"); put(40032, "不合法的openid列表长度"); put(40033, "不合法的请求字符,不能包含\\uxxxx格式的字符"); put(40035, "不合法的参数"); put(40038, "不合法的请求格式"); put(40039, "不合法的URL长度"); put(40050, "不合法的分组id"); put(40051, "分组名字不合法"); put(41001, "缺少access_token参数"); put(41002, "缺少appid参数"); put(41003, "缺少refresh_token参数"); put(41004, "缺少secret参数"); put(41005, "缺少多媒体文件数据"); put(41006, "缺少media_id参数"); put(41007, "缺少子菜单数据"); put(41008, "缺少oauth code"); put(41009, "缺少openid"); put(42001, "access_token超时"); put(42002, "refresh_token超时"); put(42003, "oauth_code超时"); put(43001, "需要GET请求"); put(43002, "需要POST请求"); put(43003, "需要HTTPS请求"); put(43004, "需要接收者关注"); put(43005, "需要好友关系"); put(44001, "多媒体文件为空"); put(44002, "POST的数据包为空"); put(44003, "图文消息内容为空"); put(44004, "文本消息内容为空"); put(45001, "多媒体文件大小超过限制"); put(45002, "消息内容超过限制"); put(45003, "标题字段超过限制"); put(45004, "描述字段超过限制"); put(45005, "链接字段超过限制"); put(45006, "图片链接字段超过限制"); put(45007, "语音播放时间超过限制"); put(45008, "图文消息超过限制"); put(45009, "接口调用超过限制"); put(45010, "创建菜单个数超过限制"); put(45015, "回复时间超过限制"); put(45016, "系统分组,不允许修改"); put(45017, "分组名字过长"); put(45018, "分组数量超过上限"); put(46001, "不存在媒体数据"); put(46002, "不存在的菜单版本"); put(46003, "不存在的菜单数据"); put(46004, "不存在的用户"); put(47001, "解析JSON/XML内容错误"); put(48001, "api功能未授权"); put(50001, "用户未授权该api"); } }; private Integer code = 0; private String msg; private Integer errcode = 0; private String errmsg = "ok"; private String errmsgChinese; public String getErrmsgChinese() { if (errcode != null && errmsgChinese == null) { errmsgChinese = errorCodesMap.get(errcode); } return errmsgChinese; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/dial/IVRListResponse.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/dial/IVRListResponse.java
package me.chanjar.weixin.qidian.bean.dial; import lombok.Data; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import me.chanjar.weixin.qidian.bean.common.QidianResponse; import java.util.List; @Data public class IVRListResponse extends QidianResponse { private List<Ivr> node; public static IVRListResponse fromJson(String json) { return WxGsonBuilder.create().fromJson(json, IVRListResponse.class); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/dial/Ivr.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/dial/Ivr.java
package me.chanjar.weixin.qidian.bean.dial; import lombok.Data; @Data public class Ivr { private String ivr_id; private String ivr_name; }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/dial/IVRDialResponse.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/dial/IVRDialResponse.java
package me.chanjar.weixin.qidian.bean.dial; import lombok.Data; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import me.chanjar.weixin.qidian.bean.common.QidianResponse; import me.chanjar.weixin.qidian.util.json.WxQidianGsonBuilder; @Data public class IVRDialResponse extends QidianResponse { private String callid; public static IVRDialResponse fromJson(String json) { return WxGsonBuilder.create().fromJson(json, IVRDialResponse.class); } @Override public String toString() { return WxQidianGsonBuilder.create().toJson(this); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/dial/IVRDialRequest.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/bean/dial/IVRDialRequest.java
package me.chanjar.weixin.qidian.bean.dial; import lombok.Data; import me.chanjar.weixin.common.util.json.WxGsonBuilder; import java.io.Serializable; import java.util.List; @Data public class IVRDialRequest implements Serializable { private static final long serialVersionUID = -5552935329136465927L; private String phone_number; private String ivr_id; private List<String> corp_phone_list; private Integer loc_pref_on = 1; private List<String> backup_corp_phone_list; private Boolean skip_restrict = false; @Override public String toString() { return this.toJson(); } public String toJson() { return WxGsonBuilder.create().toJson(this); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/config/WxQidianConfigStorage.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/config/WxQidianConfigStorage.java
package me.chanjar.weixin.qidian.config; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.enums.TicketType; import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; import me.chanjar.weixin.qidian.bean.WxQidianHostConfig; import java.io.File; import java.util.concurrent.locks.Lock; /** * 微信客户端配置存储. * * @author chanjarster */ public interface WxQidianConfigStorage { /** * Gets access token. * * @return the access token */ String getAccessToken(); /** * Gets access token lock. * * @return the access token lock */ Lock getAccessTokenLock(); /** * Is access token expired boolean. * * @return the boolean */ boolean isAccessTokenExpired(); /** * 强制将access token过期掉. */ void expireAccessToken(); /** * 应该是线程安全的. * * @param accessToken 要更新的WxAccessToken对象 */ void updateAccessToken(WxAccessToken accessToken); /** * 应该是线程安全的. * * @param accessToken 新的accessToken值 * @param expiresInSeconds 过期时间,以秒为单位 */ void updateAccessToken(String accessToken, int expiresInSeconds); /** * Gets ticket. * * @param type the type * @return the ticket */ String getTicket(TicketType type); /** * Gets ticket lock. * * @param type the type * @return the ticket lock */ Lock getTicketLock(TicketType type); /** * Is ticket expired boolean. * * @param type the type * @return the boolean */ boolean isTicketExpired(TicketType type); /** * 强制将ticket过期掉. * * @param type the type */ void expireTicket(TicketType type); /** * 更新ticket. * 应该是线程安全的 * * @param type ticket类型 * @param ticket 新的ticket值 * @param expiresInSeconds 过期时间,以秒为单位 */ void updateTicket(TicketType type, String ticket, int expiresInSeconds); /** * Gets app id. * * @return the app id */ String getAppId(); /** * Gets secret. * * @return the secret */ String getSecret(); /** * Gets token. * * @return the token */ String getToken(); /** * Gets aes key. * * @return the aes key */ String getAesKey(); /** * Gets template id. * * @return the template id */ String getTemplateId(); /** * Gets expires time. * * @return the expires time */ long getExpiresTime(); /** * Gets oauth 2 redirect uri. * * @return the oauth 2 redirect uri */ String getOauth2redirectUri(); /** * Gets http proxy host. * * @return the http proxy host */ String getHttpProxyHost(); /** * Gets http proxy port. * * @return the http proxy port */ int getHttpProxyPort(); /** * Gets http proxy username. * * @return the http proxy username */ String getHttpProxyUsername(); /** * Gets http proxy password. * * @return the http proxy password */ String getHttpProxyPassword(); /** * Gets tmp dir file. * * @return the tmp dir file */ File getTmpDirFile(); /** * http client builder. * * @return ApacheHttpClientBuilder apache http client builder */ ApacheHttpClientBuilder getApacheHttpClientBuilder(); /** * 是否自动刷新token. * * @return the boolean */ boolean autoRefreshToken(); /** * 得到微信接口地址域名部分的自定义设置信息. * * @return the host config */ WxQidianHostConfig getHostConfig(); /** * 设置微信接口地址域名部分的自定义设置信息. * * @param hostConfig host config */ void setHostConfig(WxQidianHostConfig hostConfig); }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/config/impl/WxQidianRedisConfigImpl.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/config/impl/WxQidianRedisConfigImpl.java
package me.chanjar.weixin.qidian.config.impl; import lombok.Data; import lombok.EqualsAndHashCode; import me.chanjar.weixin.common.enums.TicketType; import me.chanjar.weixin.common.redis.WxRedisOps; import java.util.concurrent.TimeUnit; /** * 基于Redis的微信配置provider. * * <pre> * 使用说明:本实现仅供参考,并不完整, * 比如为减少项目依赖,未加入redis分布式锁的实现,如有需要请自行实现。 * </pre> * * @author nickwong */ @Data @EqualsAndHashCode(callSuper = false) public class WxQidianRedisConfigImpl extends WxQidianDefaultConfigImpl { private static final long serialVersionUID = -988502871997239733L; private static final String ACCESS_TOKEN_KEY_TPL = "%s:access_token:%s"; private static final String TICKET_KEY_TPL = "%s:ticket:key:%s:%s"; private static final String LOCK_KEY_TPL = "%s:lock:%s:"; private final WxRedisOps redisOps; private final String keyPrefix; private String accessTokenKey; private String lockKey; public WxQidianRedisConfigImpl(WxRedisOps redisOps, String keyPrefix) { this.redisOps = redisOps; this.keyPrefix = keyPrefix; } /** * 每个公众号生成独有的存储key. */ @Override public void setAppId(String appId) { super.setAppId(appId); this.accessTokenKey = String.format(ACCESS_TOKEN_KEY_TPL, this.keyPrefix, appId); this.lockKey = String.format(LOCK_KEY_TPL, this.keyPrefix, appId); accessTokenLock = this.redisOps.getLock(lockKey.concat("accessTokenLock")); jsapiTicketLock = this.redisOps.getLock(lockKey.concat("jsapiTicketLock")); sdkTicketLock = this.redisOps.getLock(lockKey.concat("sdkTicketLock")); cardApiTicketLock = this.redisOps.getLock(lockKey.concat("cardApiTicketLock")); } private String getTicketRedisKey(TicketType type) { return String.format(TICKET_KEY_TPL, this.keyPrefix, appId, type.getCode()); } @Override public String getAccessToken() { return redisOps.getValue(this.accessTokenKey); } @Override public boolean isAccessTokenExpired() { Long expire = redisOps.getExpire(this.accessTokenKey); return expire == null || expire < 2; } @Override public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) { redisOps.setValue(this.accessTokenKey, accessToken, expiresInSeconds - 200, TimeUnit.SECONDS); } @Override public void expireAccessToken() { redisOps.expire(this.accessTokenKey, 0, TimeUnit.SECONDS); } @Override public String getTicket(TicketType type) { return redisOps.getValue(this.getTicketRedisKey(type)); } @Override public boolean isTicketExpired(TicketType type) { return redisOps.getExpire(this.getTicketRedisKey(type)) < 2; } @Override public synchronized void updateTicket(TicketType type, String jsapiTicket, int expiresInSeconds) { redisOps.setValue(this.getTicketRedisKey(type), jsapiTicket, expiresInSeconds - 200, TimeUnit.SECONDS); } @Override public void expireTicket(TicketType type) { redisOps.expire(this.getTicketRedisKey(type), 0, TimeUnit.SECONDS); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/config/impl/WxQidianRedissonConfigImpl.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/config/impl/WxQidianRedissonConfigImpl.java
package me.chanjar.weixin.qidian.config.impl; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; import me.chanjar.weixin.common.enums.TicketType; import me.chanjar.weixin.common.redis.RedissonWxRedisOps; import me.chanjar.weixin.common.redis.WxRedisOps; import org.redisson.api.RedissonClient; import java.util.concurrent.TimeUnit; /** * @author wuxingye * created on 2020/6/12 */ @EqualsAndHashCode(callSuper = true) @Data public class WxQidianRedissonConfigImpl extends WxQidianDefaultConfigImpl { private static final long serialVersionUID = -5139855123878455556L; private static final String ACCESS_TOKEN_KEY_TPL = "%s:access_token:%s"; private static final String TICKET_KEY_TPL = "%s:ticket:key:%s:%s"; private static final String LOCK_KEY_TPL = "%s:lock:%s:"; private final WxRedisOps redisOps; private final String keyPrefix; private String accessTokenKey; private String lockKey; public WxQidianRedissonConfigImpl(@NonNull RedissonClient redissonClient, String keyPrefix) { this(new RedissonWxRedisOps(redissonClient), keyPrefix); } public WxQidianRedissonConfigImpl(@NonNull RedissonClient redissonClient) { this(redissonClient, null); } private WxQidianRedissonConfigImpl(@NonNull WxRedisOps redisOps, String keyPrefix) { this.redisOps = redisOps; this.keyPrefix = keyPrefix; } /** * 每个公众号生成独有的存储key. */ @Override public void setAppId(String appId) { super.setAppId(appId); this.accessTokenKey = String.format(ACCESS_TOKEN_KEY_TPL, this.keyPrefix, appId); this.lockKey = String.format(LOCK_KEY_TPL, this.keyPrefix, appId); accessTokenLock = this.redisOps.getLock(lockKey.concat("accessTokenLock")); jsapiTicketLock = this.redisOps.getLock(lockKey.concat("jsapiTicketLock")); sdkTicketLock = this.redisOps.getLock(lockKey.concat("sdkTicketLock")); cardApiTicketLock = this.redisOps.getLock(lockKey.concat("cardApiTicketLock")); } private String getTicketRedisKey(TicketType type) { return String.format(TICKET_KEY_TPL, this.keyPrefix, appId, type.getCode()); } @Override public String getAccessToken() { return redisOps.getValue(this.accessTokenKey); } @Override public boolean isAccessTokenExpired() { Long expire = redisOps.getExpire(this.accessTokenKey); return expire == null || expire < 2; } @Override public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) { redisOps.setValue(this.accessTokenKey, accessToken, expiresInSeconds - 200, TimeUnit.SECONDS); } @Override public void expireAccessToken() { redisOps.expire(this.accessTokenKey, 0, TimeUnit.SECONDS); } @Override public String getTicket(TicketType type) { return redisOps.getValue(this.getTicketRedisKey(type)); } @Override public boolean isTicketExpired(TicketType type) { return redisOps.getExpire(this.getTicketRedisKey(type)) < 2; } @Override public synchronized void updateTicket(TicketType type, String jsapiTicket, int expiresInSeconds) { redisOps.setValue(this.getTicketRedisKey(type), jsapiTicket, expiresInSeconds - 200, TimeUnit.SECONDS); } @Override public void expireTicket(TicketType type) { redisOps.expire(this.getTicketRedisKey(type), 0, TimeUnit.SECONDS); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/config/impl/WxQidianDefaultConfigImpl.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/config/impl/WxQidianDefaultConfigImpl.java
package me.chanjar.weixin.qidian.config.impl; import lombok.Data; import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.enums.TicketType; import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder; import me.chanjar.weixin.qidian.bean.WxQidianHostConfig; import me.chanjar.weixin.qidian.config.WxQidianConfigStorage; import me.chanjar.weixin.qidian.util.json.WxQidianGsonBuilder; import java.io.File; import java.io.Serializable; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; /** * 基于内存的微信配置provider,在实际生产环境中应该将这些配置持久化. * * @author chanjarster */ @Data public class WxQidianDefaultConfigImpl implements WxQidianConfigStorage, Serializable { private static final long serialVersionUID = -6646519023303395185L; protected volatile String appId; protected volatile String secret; protected volatile String token; protected volatile String templateId; protected volatile String accessToken; protected volatile String aesKey; protected volatile long expiresTime; protected volatile String oauth2redirectUri; protected volatile String httpProxyHost; protected volatile int httpProxyPort; protected volatile String httpProxyUsername; protected volatile String httpProxyPassword; protected volatile String jsapiTicket; protected volatile long jsapiTicketExpiresTime; protected volatile String sdkTicket; protected volatile long sdkTicketExpiresTime; protected volatile String cardApiTicket; protected volatile long cardApiTicketExpiresTime; protected volatile Lock accessTokenLock = new ReentrantLock(); protected volatile Lock jsapiTicketLock = new ReentrantLock(); protected volatile Lock sdkTicketLock = new ReentrantLock(); protected volatile Lock cardApiTicketLock = new ReentrantLock(); protected volatile File tmpDirFile; protected volatile ApacheHttpClientBuilder apacheHttpClientBuilder; private WxQidianHostConfig hostConfig = null; @Override public boolean isAccessTokenExpired() { return System.currentTimeMillis() > this.expiresTime; } @Override public synchronized void updateAccessToken(WxAccessToken accessToken) { updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn()); } @Override public synchronized void updateAccessToken(String accessToken, int expiresInSeconds) { this.accessToken = accessToken; this.expiresTime = System.currentTimeMillis() + (expiresInSeconds - 200) * 1000L; } @Override public void expireAccessToken() { this.expiresTime = 0; } @Override public String getTicket(TicketType type) { switch (type) { case SDK: return this.sdkTicket; case JSAPI: return this.jsapiTicket; case WX_CARD: return this.cardApiTicket; default: return null; } } public void setTicket(TicketType type, String ticket) { switch (type) { case JSAPI: this.jsapiTicket = ticket; break; case WX_CARD: this.cardApiTicket = ticket; break; case SDK: this.sdkTicket = ticket; break; default: } } @Override public Lock getTicketLock(TicketType type) { switch (type) { case SDK: return this.sdkTicketLock; case JSAPI: return this.jsapiTicketLock; case WX_CARD: return this.cardApiTicketLock; default: return null; } } @Override public boolean isTicketExpired(TicketType type) { switch (type) { case SDK: return System.currentTimeMillis() > this.sdkTicketExpiresTime; case JSAPI: return System.currentTimeMillis() > this.jsapiTicketExpiresTime; case WX_CARD: return System.currentTimeMillis() > this.cardApiTicketExpiresTime; default: return false; } } @Override public synchronized void updateTicket(TicketType type, String ticket, int expiresInSeconds) { switch (type) { case JSAPI: this.jsapiTicket = ticket; // 预留200秒的时间 this.jsapiTicketExpiresTime = System.currentTimeMillis() + (expiresInSeconds - 200) * 1000L; break; case WX_CARD: this.cardApiTicket = ticket; // 预留200秒的时间 this.cardApiTicketExpiresTime = System.currentTimeMillis() + (expiresInSeconds - 200) * 1000L; break; case SDK: this.sdkTicket = ticket; // 预留200秒的时间 this.sdkTicketExpiresTime = System.currentTimeMillis() + (expiresInSeconds - 200) * 1000L; break; default: } } @Override public void expireTicket(TicketType type) { switch (type) { case JSAPI: this.jsapiTicketExpiresTime = 0; break; case WX_CARD: this.cardApiTicketExpiresTime = 0; break; case SDK: this.sdkTicketExpiresTime = 0; break; default: } } @Override public String toString() { return WxQidianGsonBuilder.create().toJson(this); } @Override public boolean autoRefreshToken() { return true; } @Override public WxQidianHostConfig getHostConfig() { return this.hostConfig; } @Override public void setHostConfig(WxQidianHostConfig hostConfig) { this.hostConfig = hostConfig; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/enums/WxQidianApiUrl.java
weixin-java-qidian/src/main/java/me/chanjar/weixin/qidian/enums/WxQidianApiUrl.java
package me.chanjar.weixin.qidian.enums; import lombok.AllArgsConstructor; import lombok.Getter; import me.chanjar.weixin.qidian.bean.WxQidianHostConfig; import me.chanjar.weixin.qidian.config.WxQidianConfigStorage; import static me.chanjar.weixin.qidian.bean.WxQidianHostConfig.*; /** * <pre> * 腾讯企点接口api地址 * Created by alegria on 2020年12月26日. * </pre> */ public interface WxQidianApiUrl { /** * 得到api完整地址. * * @param config 微信公众号配置 * @return api地址 */ default String getUrl(WxQidianConfigStorage config) { WxQidianHostConfig hostConfig = null; if (config != null) { hostConfig = config.getHostConfig(); } return buildUrl(hostConfig, this.getPrefix(), this.getPath()); } /** * the path * * @return path */ String getPath(); /** * the prefix * * @return prefix */ String getPrefix(); @AllArgsConstructor @Getter enum OAuth2 implements WxQidianApiUrl { /** * 用code换取oauth2的access token. */ OAUTH2_ACCESS_TOKEN_URL(API_DEFAULT_HOST_URL, "/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code"), /** * 刷新oauth2的access token. */ OAUTH2_REFRESH_TOKEN_URL(API_DEFAULT_HOST_URL, "/sns/oauth2/refresh_token?appid=%s&grant_type=refresh_token&refresh_token=%s"), /** * 用oauth2获取用户信息. */ OAUTH2_USERINFO_URL(API_DEFAULT_HOST_URL, "/sns/userinfo?access_token=%s&openid=%s&lang=%s"), /** * 验证oauth2的access token是否有效. */ OAUTH2_VALIDATE_TOKEN_URL(API_DEFAULT_HOST_URL, "/sns/auth?access_token=%s&openid=%s"), /** * oauth2授权的url连接. */ CONNECT_OAUTH2_AUTHORIZE_URL(OPEN_DEFAULT_HOST_URL, "/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=%s&state=%s&connect_redirect=1#wechat_redirect"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum Other implements WxQidianApiUrl { /** * 获取access_token. */ GET_ACCESS_TOKEN_URL(QIDIAN_DEFAULT_HOST_URL, "/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s"), /** * 获得各种类型的ticket. */ GET_TICKET_URL(API_DEFAULT_HOST_URL, "/cgi-bin/ticket/getticket?type="), /** * 长链接转短链接接口. */ SHORTURL_API_URL(API_DEFAULT_HOST_URL, "/cgi-bin/shorturl"), /** * 语义查询接口. */ SEMANTIC_SEMPROXY_SEARCH_URL(API_DEFAULT_HOST_URL, "/semantic/semproxy/search"), /** * 获取微信服务器IP地址. */ GET_CALLBACK_IP_URL(API_DEFAULT_HOST_URL, "/cgi-bin/getcallbackip"), /** * 网络检测. */ NETCHECK_URL(API_DEFAULT_HOST_URL, "/cgi-bin/callback/check"), /** * 第三方使用网站应用授权登录的url. */ QRCONNECT_URL(OPEN_DEFAULT_HOST_URL, "/connect/qrconnect?appid=%s&redirect_uri=%s&response_type=code&scope=%s&state=%s#wechat_redirect"), /** * 获取公众号的自动回复规则. */ GET_CURRENT_AUTOREPLY_INFO_URL(API_DEFAULT_HOST_URL, "/cgi-bin/get_current_autoreply_info"), /** * 公众号调用或第三方平台帮公众号调用对公众号的所有api调用(包括第三方帮其调用)次数进行清零. */ CLEAR_QUOTA_URL(API_DEFAULT_HOST_URL, "/cgi-bin/clear_quota"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum Dial implements WxQidianApiUrl { /** * IVR外呼. */ IVR_DIAL(QIDIAN_DEFAULT_HOST_URL, "/cgi-bin/call/dial/ivrdial"), /** * 拉取IVR列表. */ GET_IVR_LIST(QIDIAN_DEFAULT_HOST_URL, "/cgi-bin/call/dial/getivrlist"); private final String prefix; private final String path; } @AllArgsConstructor @Getter enum CallData implements WxQidianApiUrl { /** * 总机号列表拉取. */ GET_SWITCH_BOARD_LIST(QIDIAN_DEFAULT_HOST_URL, "/cgi-bin/call/callData/getswitchboardlist"); private final String prefix; private final String path; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/util/SignUtilsTest.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/util/SignUtilsTest.java
package com.github.binarywang.wxpay.util; import org.testng.annotations.*; import com.google.common.base.Splitter; import static com.github.binarywang.wxpay.constant.WxPayConstants.SignType.HMAC_SHA256; import static org.testng.Assert.*; /** * <pre> * 测试中使用的测试数据参考的是官方文档,地址: * https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=4_3 * Created by BinaryWang on 2017/9/2. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ public class SignUtilsTest { /** * Test create sign. * * @throws Exception the exception */ @Test public void testCreateSign() throws Exception { String signKey = "192006250b4c09247ec02edce69f6a2d"; String message = "appid=wxd930ea5d5a258f4f&body=test&device_info=1000&mch_id=10000100&nonce_str=ibuaiVcKdpRxkhJA"; assertEquals(SignUtils.createSign((Splitter.on("&").withKeyValueSeparator("=").split(message)), null, signKey, null), "9A0A8659F005D6984697E2CA0A9CF3B7"); } /** * Test create sign hmacsha 256. * * @throws Exception the exception */ @Test public void testCreateSign_HMACSHA256() throws Exception { String signKey = "192006250b4c09247ec02edce69f6a2d"; final String message = "appid=wxd930ea5d5a258f4f&body=test&device_info=1000&mch_id=10000100&nonce_str=ibuaiVcKdpRxkhJA"; String sign = SignUtils.createSign(Splitter.on("&").withKeyValueSeparator("=").split(message), HMAC_SHA256, signKey, null); assertEquals(sign, "6A9AE1657590FD6257D693A078E1C3E4BB6BA4DC30B23E0EE2496E54170DACD6"); } /** * Test check sign. * * @throws Exception the exception */ @Test public void testCheckSign() throws Exception { } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/BusinessOperationTransferServiceTest.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/BusinessOperationTransferServiceTest.java
package com.github.binarywang.wxpay.service; import com.github.binarywang.wxpay.bean.transfer.*; import com.github.binarywang.wxpay.config.WxPayConfig; import com.github.binarywang.wxpay.constant.WxPayConstants; import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static org.assertj.core.api.Assertions.assertThat; /** * 运营工具-商家转账API测试 * * @author WxJava Team */ public class BusinessOperationTransferServiceTest { private WxPayService wxPayService; @BeforeClass public void setup() { WxPayConfig config = new WxPayConfig(); config.setAppId("test_app_id"); config.setMchId("test_mch_id"); wxPayService = new WxPayServiceImpl(); wxPayService.setConfig(config); } @Test public void testServiceInitialization() { BusinessOperationTransferService service = this.wxPayService.getBusinessOperationTransferService(); assertThat(service).isNotNull(); } @Test public void testRequestBuilder() { BusinessOperationTransferRequest request = BusinessOperationTransferRequest.newBuilder() .appid("test_app_id") .outBillNo("OT" + System.currentTimeMillis()) .operationSceneId(WxPayConstants.OperationSceneId.OPERATION_CASH_MARKETING) .openid("test_openid") .transferAmount(100) .transferRemark("测试转账") .userRecvPerception(WxPayConstants.UserRecvPerception.CASH_MARKETING.CASH) .build(); assertThat(request.getAppid()).isEqualTo("test_app_id"); assertThat(request.getOperationSceneId()).isEqualTo(WxPayConstants.OperationSceneId.OPERATION_CASH_MARKETING); assertThat(request.getTransferAmount()).isEqualTo(100); assertThat(request.getTransferRemark()).isEqualTo("测试转账"); } @Test public void testQueryRequestBuilder() { BusinessOperationTransferQueryRequest request = BusinessOperationTransferQueryRequest.newBuilder() .outBillNo("OT123456789") .appid("test_app_id") .build(); assertThat(request.getOutBillNo()).isEqualTo("OT123456789"); assertThat(request.getAppid()).isEqualTo("test_app_id"); } @Test public void testConstants() { // 测试运营工具转账场景ID常量 assertThat(WxPayConstants.OperationSceneId.OPERATION_CASH_MARKETING).isEqualTo("2001"); assertThat(WxPayConstants.OperationSceneId.OPERATION_COMMISSION).isEqualTo("2002"); assertThat(WxPayConstants.OperationSceneId.OPERATION_PROMOTION).isEqualTo("2003"); } @Test public void testResultClasses() { // 测试结果类的基本功能 BusinessOperationTransferResult result = new BusinessOperationTransferResult(); result.setOutBillNo("test_out_bill_no"); result.setTransferBillNo("test_transfer_bill_no"); result.setTransferState("SUCCESS"); assertThat(result.getOutBillNo()).isEqualTo("test_out_bill_no"); assertThat(result.getTransferBillNo()).isEqualTo("test_transfer_bill_no"); assertThat(result.getTransferState()).isEqualTo("SUCCESS"); BusinessOperationTransferQueryResult queryResult = new BusinessOperationTransferQueryResult(); queryResult.setOperationSceneId("2001"); queryResult.setTransferAmount(100); assertThat(queryResult.getOperationSceneId()).isEqualTo("2001"); assertThat(queryResult.getTransferAmount()).isEqualTo(100); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EntPayServiceImplTest.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EntPayServiceImplTest.java
package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.bean.entpay.*; import com.github.binarywang.wxpay.constant.WxPayConstants.CheckNameOption; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.google.inject.Inject; import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.Guice; import org.testng.annotations.Test; import java.util.concurrent.TimeUnit; /** * <pre> * 企业付款测试类. * Created by BinaryWang on 2017/12/19. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ @Test @Guice(modules = ApiTestModule.class) @Slf4j public class EntPayServiceImplTest { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Inject private WxPayService payService; /** * Test ent pay. * * @throws WxPayException the wx pay exception */ @Test public void testEntPay() throws WxPayException { EntPayRequest request = EntPayRequest.newBuilder() .partnerTradeNo("Eb6Aep7uVTdbkJqrP4") .openid("ojOQA0y9o-Eb6Aep7uVTdbkJqrP5") .amount(100) .spbillCreateIp("10.10.10.10") .checkName(CheckNameOption.NO_CHECK) .description("描述信息") .build(); log.info(this.payService.getEntPayService().entPay(request).toString()); } /** * Test query ent pay. * * @throws WxPayException the wx pay exception */ @Test public void testQueryEntPay() throws WxPayException { log.info(this.payService.getEntPayService().queryEntPay("11212121").toString()); } /** * Test get public key. * * @throws Exception the exception */ @Test public void testGetPublicKey() throws Exception { log.info(this.payService.getEntPayService().getPublicKey()); } /** * Test pay bank. * * @throws Exception the exception */ @Test public void testPayBank() throws Exception { EntPayBankResult result = this.payService.getEntPayService().payBank(EntPayBankRequest.builder() .bankCode("aa") .amount(1) .encBankNo("1") .encTrueName("2") .partnerTradeNo("3") .description("11") .build()); log.info(result.toString()); } /** * Test query pay bank. * * @throws Exception the exception */ @Test public void testQueryPayBank() throws Exception { log.info(this.payService.getEntPayService().queryPayBank("123").toString()); } /** * 发送企业红包 * * @throws Exception the exception */ @Test public void testSendEnterpriseRedpack() { EntPayRedpackRequest request = new EntPayRedpackRequest(); request.setMchId("1"); //商户单号 request.setMchBillNo(request.getMchId() + "20191202" + "1"); //企业微信corpid即为此appId request.setWxAppId("1"); // request.setSenderName("1"); // request.setSenderHeaderMediaId("2"); request.setAgentId("1"); request.setReOpenid("1"); //目前企业微信api红包最低1块钱 request.setTotalAmount(1000); request.setWishing("1"); request.setActName("1"); request.setRemark("1"); EntPayRedpackResult redpackResult = null; try { redpackResult = this.payService.getEntPayService().sendEnterpriseRedpack(request); } catch (WxPayException e) { } log.info(redpackResult.toString()); } /** * 查询企业红包 * * @throws Exception */ @Test public void testQueryEnterpriseRedpack() throws Exception { while (true) { EntPayRedpackQueryRequest request = new EntPayRedpackQueryRequest(); request.setAppid("1"); request.setMchId("1"); request.setMchBillNo("1"); try { EntPayRedpackQueryResult result = this.payService.getEntPayService().queryEnterpriseRedpack(request); log.info(result.toString()); } catch (Exception e) { } TimeUnit.SECONDS.sleep(3); } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/OverseasWxPayExample.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/OverseasWxPayExample.java
package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3GlobalRequest; import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result; import com.github.binarywang.wxpay.bean.result.enums.GlobalTradeTypeEnum; import com.github.binarywang.wxpay.config.WxPayConfig; import com.github.binarywang.wxpay.constant.WxPayConstants; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import me.chanjar.weixin.common.util.RandomUtils; /** * 境外微信支付使用示例 * Example usage for overseas WeChat Pay * * @author Binary Wang */ public class OverseasWxPayExample { /** * 境外微信支付JSAPI下单示例 * Example for overseas WeChat Pay JSAPI order creation */ public void createOverseasJsapiOrder(WxPayService payService) throws WxPayException { // 创建境外支付请求对象 WxPayUnifiedOrderV3GlobalRequest request = new WxPayUnifiedOrderV3GlobalRequest(); // 设置基础订单信息 request.setOutTradeNo(RandomUtils.getRandomStr()); // 商户订单号 request.setDescription("境外商品购买"); // 商品描述 request.setNotifyUrl("https://your-domain.com/notify"); // 支付通知地址 // 设置金额信息 WxPayUnifiedOrderV3GlobalRequest.Amount amount = new WxPayUnifiedOrderV3GlobalRequest.Amount(); amount.setCurrency(WxPayConstants.CurrencyType.CNY); // 币种 amount.setTotal(100); // 金额,单位为分 request.setAmount(amount); // 设置支付者信息 WxPayUnifiedOrderV3GlobalRequest.Payer payer = new WxPayUnifiedOrderV3GlobalRequest.Payer(); payer.setOpenid("用户的openid"); // 用户openid request.setPayer(payer); // 设置境外支付必需的参数 request.setTradeType("JSAPI"); // 交易类型 request.setMerchantCategoryCode("5812"); // 商户类目代码,境外商户必填 // 可选:设置场景信息 WxPayUnifiedOrderV3GlobalRequest.SceneInfo sceneInfo = new WxPayUnifiedOrderV3GlobalRequest.SceneInfo(); sceneInfo.setPayerClientIp("用户IP地址"); request.setSceneInfo(sceneInfo); // 调用境外支付接口 WxPayUnifiedOrderV3Result.JsapiResult result = payService.createOrderV3Global( GlobalTradeTypeEnum.JSAPI, request ); // 返回的result包含前端需要的支付参数 System.out.println("支付参数:" + result); } /** * 境外微信支付APP下单示例 * Example for overseas WeChat Pay APP order creation */ public void createOverseasAppOrder(WxPayService payService) throws WxPayException { WxPayUnifiedOrderV3GlobalRequest request = new WxPayUnifiedOrderV3GlobalRequest(); // 设置基础信息 request.setOutTradeNo(RandomUtils.getRandomStr()); request.setDescription("境外APP商品购买"); request.setNotifyUrl("https://your-domain.com/notify"); // 设置金额 WxPayUnifiedOrderV3GlobalRequest.Amount amount = new WxPayUnifiedOrderV3GlobalRequest.Amount(); amount.setCurrency(WxPayConstants.CurrencyType.CNY); amount.setTotal(200); // 2元 request.setAmount(amount); // APP支付不需要设置payer.openid,但需要设置空的payer对象 request.setPayer(new WxPayUnifiedOrderV3GlobalRequest.Payer()); // 境外支付必需参数 request.setTradeType("APP"); request.setMerchantCategoryCode("5812"); // 调用境外APP支付接口 WxPayUnifiedOrderV3Result.AppResult result = payService.createOrderV3Global( GlobalTradeTypeEnum.APP, request ); System.out.println("APP支付参数:" + result); } /** * 境外微信支付NATIVE下单示例 * Example for overseas WeChat Pay NATIVE order creation */ public void createOverseasNativeOrder(WxPayService payService) throws WxPayException { WxPayUnifiedOrderV3GlobalRequest request = new WxPayUnifiedOrderV3GlobalRequest(); request.setOutTradeNo(RandomUtils.getRandomStr()); request.setDescription("境外扫码支付"); request.setNotifyUrl("https://your-domain.com/notify"); // 设置金额 WxPayUnifiedOrderV3GlobalRequest.Amount amount = new WxPayUnifiedOrderV3GlobalRequest.Amount(); amount.setCurrency(WxPayConstants.CurrencyType.CNY); amount.setTotal(300); // 3元 request.setAmount(amount); // NATIVE支付不需要设置payer.openid request.setPayer(new WxPayUnifiedOrderV3GlobalRequest.Payer()); // 境外支付必需参数 request.setTradeType("NATIVE"); request.setMerchantCategoryCode("5812"); // 调用境外NATIVE支付接口 String result = payService.createOrderV3Global( GlobalTradeTypeEnum.NATIVE, request ); System.out.println("NATIVE支付二维码链接:" + result); } /** * 配置示例 * Configuration example */ public WxPayConfig createOverseasConfig() { WxPayConfig config = new WxPayConfig(); // 基础配置 config.setAppId("你的AppId"); config.setMchId("你的境外商户号"); config.setMchKey("你的商户密钥"); config.setNotifyUrl("https://your-domain.com/notify"); // 境外支付使用的是全球API,在代码中会自动使用 https://apihk.mch.weixin.qq.com 作为基础URL // 无需额外设置payBaseUrl,方法内部会自动处理 // V3相关配置(境外支付也使用V3接口) config.setPrivateKeyPath("你的私钥文件路径"); config.setCertSerialNo("你的商户证书序列号"); config.setApiV3Key("你的APIv3密钥"); return config; } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PartnerTransferServiceImplTest.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/PartnerTransferServiceImplTest.java
package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.bean.ecommerce.FundBalanceResult; import com.github.binarywang.wxpay.bean.ecommerce.enums.SpAccountTypeEnum; import com.github.binarywang.wxpay.bean.marketing.transfer.*; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.inject.Inject; import lombok.extern.slf4j.Slf4j; import org.testng.annotations.Guice; import org.testng.annotations.Test; import javax.crypto.BadPaddingException; import java.io.InputStream; /** * 批量转账到零钱(服务商) * * @author xiaoqiang * created on 2021/12/9 */ @Slf4j @Test @Guice(modules = ApiTestModule.class) public class PartnerTransferServiceImplTest { @Inject private WxPayService wxPayService; private static final Gson GSON = new GsonBuilder().create(); @Test public void batchTransfer() throws WxPayException { String requestParamStr = "{\"sub_mchid\":\"1608*****1\",\"authorization_type\":\"FUND_AUTHORIZATION_TYPE\",\"out_batch_no\":\"202108241345*****4618387\",\"batch_name\":\"用户提现批次单2021-12-13_13_45_50\",\"batch_remark\":\"用户>提现\",\"total_amount\":30,\"total_num\":1,\"transfer_detail_list\":[{\"out_detail_no\":\"DN202112131345506240631640467671\",\"transfer_amount\":30,\"transfer_remark\":\"钱包提现\",\"openid\":\"oUaIE6PdSuBpsHAOtvf_jsgtqu5I\",\"user_name\":\"Q2FoOMuf1Ulsab+j0nObLjkIZAUZan8Z7RaEU5qOjv1RUq5ImuqqAqoQZ4f/zD5CMxuLD7lM1TIdGIvrvO8pe2YOwoUdRxiRzDX+Z0Rsy5Y9QqEiuHHK1JTR7vC18eKp0a4PlY7K4jUl49jG0QE+6gOG83Cqj3Z9dupPor94fPRUM/ZIzF293ONgSJW1iuHkd6g7EHTpizHZ/r5XcT+qh*************************kqjtVkT3GiuDXmMA8d/hO85uY50ItNNa5Ov8kmJbLCgFreoS49LUEwj/yuDap6F4g\\u003d\\u003d\"}],\"sp_appid\":\"wx6aa************ef\",\"transfer_purpose\":\"OTHERS\"}"; PartnerTransferRequest request = GSON.fromJson(requestParamStr, PartnerTransferRequest.class); PartnerTransferResult partnerTransferResult = wxPayService.getPartnerTransferService().batchTransfer(request); log.info(partnerTransferResult.toString()); } @Test public void queryBatchByBatchId() throws WxPayException { BatchNumberRequest request = new BatchNumberRequest(); request.setBatchId("1030000071100999991182020050700019480001"); request.setNeedQueryDetail(true); request.setDetailStatus("ALL"); BatchNumberResult batchResult = wxPayService.getPartnerTransferService().queryBatchByBatchId(request); log.info(batchResult.toString()); } @Test public void queryBatchDetailByWeChat() throws WxPayException, BadPaddingException { String batchId = "1030000071100999991182020050700019480001"; String detailId = "1040000071100999991182020050700019500100"; BatchDetailsResult batchResult = wxPayService.getPartnerTransferService().queryBatchDetailByWeChat(batchId, detailId); log.info(batchResult.toString()); } @Test public void queryBatchByOutBatchNo() throws WxPayException { MerchantBatchRequest request = new MerchantBatchRequest(); request.setOutBatchNo("10300000************0019480001"); request.setDetailStatus("ALL"); request.setNeedQueryDetail(true); BatchNumberResult batchResult = wxPayService.getPartnerTransferService().queryBatchByOutBatchNo(request); log.info(batchResult.toString()); } @Test public void queryBatchDetailByMch() throws WxPayException, BadPaddingException { String outBatchNo = "10300000************0019480001"; String outDetailNo = "10***********0019480001"; BatchDetailsResult batchResult = wxPayService.getPartnerTransferService().queryBatchDetailByMch(outBatchNo, outDetailNo); log.info(batchResult.toString()); } @Test public void receiptBill() throws WxPayException { ReceiptBillRequest request = new ReceiptBillRequest(); request.setOutBatchNo("10300000************0019480001"); BillReceiptResult batchResult = wxPayService.getPartnerTransferService().receiptBill(request); log.info(batchResult.toString()); } @Test public void queryBillReceipt() throws WxPayException { String outBatchNo = "10300000************0019480001"; BillReceiptResult batchResult = wxPayService.getPartnerTransferService().queryBillReceipt(outBatchNo); log.info(batchResult.toString()); } @Test public void transferElectronic() throws WxPayException { ElectronicReceiptsRequest request = new ElectronicReceiptsRequest(); request.setAcceptType("BATCH_TRANSFER"); request.setOutBatchNo("GD2021011610162610BBdkkIwcu3"); request.setOutDetailNo("mx0911231610162610v4CNkO4HAf"); ElectronicReceiptsResult batchResult = wxPayService.getPartnerTransferService().transferElectronic(request); log.info(batchResult.toString()); } @Test public void queryTransferElectronicResult() throws WxPayException { ElectronicReceiptsRequest request = new ElectronicReceiptsRequest(); request.setAcceptType("BATCH_TRANSFER"); request.setOutBatchNo("GD2021011610162610BBdkkIwcu3"); request.setOutDetailNo("mx0911231610162610v4CNkO4HAf"); ElectronicReceiptsResult batchResult = wxPayService.getPartnerTransferService().queryTransferElectronicResult(request); log.info(batchResult.toString()); } @Test public void transferDownload() throws WxPayException { String url = "https://api.mch.weixin.qq.com/v3/billdownload/file?token=xxx"; InputStream batchResult = wxPayService.getPartnerTransferService().transferDownload(url); log.info(batchResult.toString()); } @Test public void fundBalance() throws WxPayException { FundBalanceResult batchResult = wxPayService.getPartnerTransferService().fundBalance(SpAccountTypeEnum.BASIC); log.info(batchResult.toString()); } @Test public void spDayEndBalance() { String date = "2020-09-11"; FundBalanceResult batchResult = wxPayService.getPartnerTransferService().spDayEndBalance(SpAccountTypeEnum.BASIC, date); log.info(batchResult.toString()); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/CustomDeclarationServiceImplTest.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/CustomDeclarationServiceImplTest.java
package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.bean.customs.*; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.CustomDeclarationService; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.inject.Inject; import lombok.extern.slf4j.Slf4j; import org.testng.annotations.Guice; import org.testng.annotations.Test; @Slf4j @Test @Guice(modules = ApiTestModule.class) public class CustomDeclarationServiceImplTest { private static final Gson GSON = new GsonBuilder().create(); @Inject private WxPayService wxPayService; @Test public void testDeclare() throws WxPayException { CustomDeclarationService customDeclarationService = new CustomDeclarationServiceImpl(wxPayService); String requestParamStr = "{\"appid\":\"wx4275b35dac8f1bde\",\"mchid\":\"1623887211\",\"out_trade_no\":\"schiff32205031811186126779176\",\"transaction_id\":\"4200001480202205035540107159\",\"customs\":\"NINGBO\",\"merchant_customs_no\":\"4401230148\"}"; DeclarationRequest request = GSON.fromJson(requestParamStr, DeclarationRequest.class); DeclarationResult result = customDeclarationService.declare(request); System.out.println("result = " + result); } @Test public void testQuery() throws WxPayException { CustomDeclarationService customDeclarationService = new CustomDeclarationServiceImpl(wxPayService); String requestParamStr = "{\"appid\":\"wx4275b35dac8f1bde\",\"mchid\":\"1623887211\",\"order_type\":\"transaction_id\",\"order_no\":\"4200001480202205035540107159\",\"customs\":\"NINGBO\",\"offset\":\"0\",\"limit\":\"20\"}"; DeclarationQueryRequest request = GSON.fromJson(requestParamStr, DeclarationQueryRequest.class); DeclarationQueryResult result = customDeclarationService.query(request); System.out.println("result = " + result); } @Test public void testVerifyCertificate() throws WxPayException { CustomDeclarationService customDeclarationService = new CustomDeclarationServiceImpl(wxPayService); String requestParamStr = "{\"appid\":\"wx4275b35dac8f1bde\",\"mchid\":\"1623887211\",\"out_trade_no\":\"schiff32205031811186126779176\",\"transaction_id\":\"4200001480202205035540107159\",\"customs\":\"NINGBO\",\"merchant_customs_no\":\"4401230148\",\"certificate_type\":\"IDCARD\",\"certificate_id\":\"430223199101264838\",\"certificate_name\":\"易株强\"}"; VerifyCertificateRequest request = GSON.fromJson(requestParamStr, VerifyCertificateRequest.class); VerifyCertificateResult result = customDeclarationService.verifyCertificate(request); System.out.println("result = " + result); } @Test public void testModify() throws WxPayException { CustomDeclarationService customDeclarationService = new CustomDeclarationServiceImpl(wxPayService); String requestParamStr = "{\"appid\":\"wx4275b35dac8f1bde\",\"mchid\":\"1623887211\",\"out_trade_no\":\"schiff32205031811186126779176\",\"transaction_id\":\"4200001480202205035540107159\",\"customs\":\"NINGBO\",\"merchant_customs_no\":\"4401230148\"}"; DeclarationRequest request = GSON.fromJson(requestParamStr, DeclarationRequest.class); DeclarationResult result = customDeclarationService.modify(request); System.out.println("result = " + result); } @Test public void testRedeclare() throws WxPayException { CustomDeclarationService customDeclarationService = new CustomDeclarationServiceImpl(wxPayService); String requestParamStr = "{\"appid\":\"wx4275b35dac8f1bde\",\"mchid\":\"1623887211\",\"out_trade_no\":\"schiff32205031811186126779176\",\"transaction_id\":\"4200001480202205035540107159\",\"customs\":\"NINGBO\",\"merchant_customs_no\":\"4401230148\"}"; RedeclareRequest request = GSON.fromJson(requestParamStr, RedeclareRequest.class); RedeclareResult result = customDeclarationService.redeclare(request); System.out.println("result = " + result); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxDepositServiceTest.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxDepositServiceTest.java
package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.bean.request.*; import com.github.binarywang.wxpay.bean.result.*; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.google.inject.Inject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.Guice; import org.testng.annotations.Test; /** * <pre> * 微信押金支付测试 * </pre> * * @author Binary Wang * created on 2024-09-24 */ @Test @Guice(modules = ApiTestModule.class) public class WxDepositServiceTest { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Inject private WxPayService payService; /** * 测试押金下单 */ @Test public void testUnifiedOrder() throws WxPayException { WxDepositUnifiedOrderRequest request = WxDepositUnifiedOrderRequest.newBuilder() .body("共享单车押金") .outTradeNo("D" + System.currentTimeMillis()) .totalFee(99) .spbillCreateIp("192.168.1.1") .notifyUrl("https://example.com/wxpay/notify") .tradeType("JSAPI") .openid("test_openid_123") .build(); try { WxDepositUnifiedOrderResult result = this.payService.getWxDepositService().unifiedOrder(request); logger.info("押金下单结果: {}", result); } catch (WxPayException e) { logger.error("押金下单失败", e); // For demo purposes, just log the error - tests need proper WeChat credentials to run } } /** * 测试查询押金订单 */ @Test public void testQueryOrder() throws WxPayException { WxDepositOrderQueryRequest request = WxDepositOrderQueryRequest.newBuilder() .outTradeNo("D1695559200000") .build(); try { WxDepositOrderQueryResult result = this.payService.getWxDepositService().queryOrder(request); logger.info("押金订单查询结果: {}", result); } catch (WxPayException e) { logger.error("押金订单查询失败", e); // For demo purposes, just log the error - tests need proper WeChat credentials to run } } /** * 测试押金消费 */ @Test public void testConsume() throws WxPayException { WxDepositConsumeRequest request = WxDepositConsumeRequest.newBuilder() .transactionId("1217752501201407033233368018") .outTradeNo("C" + System.currentTimeMillis()) .consumeFee(10) .consumeDesc("单车使用费") .build(); try { WxDepositConsumeResult result = this.payService.getWxDepositService().consume(request); logger.info("押金消费结果: {}", result); } catch (WxPayException e) { logger.error("押金消费失败", e); // For demo purposes, just log the error - tests need proper WeChat credentials to run } } /** * 测试押金撤销 */ @Test public void testUnfreeze() throws WxPayException { WxDepositUnfreezeRequest request = WxDepositUnfreezeRequest.newBuilder() .transactionId("1217752501201407033233368018") .outTradeNo("U" + System.currentTimeMillis()) .unfreezeFee(99) .unfreezeDesc("用户主动取消") .build(); try { WxDepositUnfreezeResult result = this.payService.getWxDepositService().unfreeze(request); logger.info("押金撤销结果: {}", result); } catch (WxPayException e) { logger.error("押金撤销失败", e); // For demo purposes, just log the error - tests need proper WeChat credentials to run } } /** * 测试押金退款 */ @Test public void testRefund() throws WxPayException { WxDepositRefundRequest request = WxDepositRefundRequest.newBuilder() .transactionId("1217752501201407033233368018") .outRefundNo("R" + System.currentTimeMillis()) .refundFee(50) .refundDesc("部分退款") .build(); try { WxDepositRefundResult result = this.payService.getWxDepositService().refund(request); logger.info("押金退款结果: {}", result); } catch (WxPayException e) { logger.error("押金退款失败", e); // For demo purposes, just log the error - tests need proper WeChat credentials to run } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/RealNameServiceImplTest.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/RealNameServiceImplTest.java
package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.bean.realname.RealNameRequest; import com.github.binarywang.wxpay.bean.realname.RealNameResult; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.google.inject.Inject; import lombok.extern.slf4j.Slf4j; import org.testng.annotations.Guice; import org.testng.annotations.Test; /** * <pre> * 实名验证测试类. * </pre> * * @author <a href="https://github.com/binarywang">Binary Wang</a> */ @Test @Guice(modules = ApiTestModule.class) @Slf4j public class RealNameServiceImplTest { @Inject private WxPayService payService; /** * 测试查询用户实名认证信息. * * @throws WxPayException the wx pay exception */ @Test public void testQueryRealName() throws WxPayException { RealNameRequest request = RealNameRequest.newBuilder() .openid("oUpF8uMuAJO_M2pxb1Q9zNjWeS6o") .build(); RealNameResult result = this.payService.getRealNameService().queryRealName(request); log.info("实名认证查询结果:{}", result); } /** * 测试查询用户实名认证信息(简化方法). * * @throws WxPayException the wx pay exception */ @Test public void testQueryRealNameSimple() throws WxPayException { RealNameResult result = this.payService.getRealNameService() .queryRealName("oUpF8uMuAJO_M2pxb1Q9zNjWeS6o"); log.info("实名认证查询结果:{}", result); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/BusinessCircleServiceImplTest.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/BusinessCircleServiceImplTest.java
package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.bean.businesscircle.BusinessCircleNotifyData; import com.github.binarywang.wxpay.bean.businesscircle.PaidResult; import com.github.binarywang.wxpay.bean.businesscircle.PointsNotifyRequest; import com.github.binarywang.wxpay.bean.businesscircle.RefundResult; import com.github.binarywang.wxpay.bean.ecommerce.SignatureHeader; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.inject.Inject; import lombok.extern.slf4j.Slf4j; import org.testng.annotations.Guice; import org.testng.annotations.Test; /** * <pre> * 智慧商圈测试类 * </pre> * * @author thinsstar */ @Slf4j @Test @Guice(modules = ApiTestModule.class) public class BusinessCircleServiceImplTest { @Inject private WxPayService wxPayService; private static final Gson GSON = new GsonBuilder().create(); @Test public void testNotifyPointsV3() throws WxPayException { PointsNotifyRequest request = new PointsNotifyRequest(); String subMchid = "商圈商户ID"; String transactionId = "微信订单号"; String appId = "公众号id"; String openId = "微信openid"; request.setSubMchid(subMchid); request.setTransactionId(transactionId); request.setAppid(appId); request.setOpenid(openId); request.setEarnPoints(true); request.setIncreasedPoints(10); request.setPointsUpdateTime("2021-03-03T13:29:35.120+08:00"); wxPayService.getBusinessCircleService().notifyPoints(request); } @Test public void testDecryptPaidNotifyDataResource() throws WxPayException { SignatureHeader header = new SignatureHeader(); header.setSerialNo("Wechatpay-Serial"); header.setTimeStamp("Wechatpay-Timestamp"); header.setNonce("Wechatpay-Nonce"); header.setSigned("Wechatpay-Signature"); String data = "body"; BusinessCircleNotifyData notifyData = wxPayService.getBusinessCircleService().parseNotifyData(data, header); PaidResult result = wxPayService.getBusinessCircleService().decryptPaidNotifyDataResource(notifyData); log.info("result: {}", GSON.toJson(result)); } @Test public void testDecryptRefundNotifyDataResource() throws WxPayException { SignatureHeader header = new SignatureHeader(); header.setSerialNo("Wechatpay-Serial"); header.setTimeStamp("Wechatpay-Timestamp"); header.setNonce("Wechatpay-Nonce"); header.setSigned("Wechatpay-Signature"); String data = "body"; BusinessCircleNotifyData notifyData = wxPayService.getBusinessCircleService().parseNotifyData(data, header); RefundResult result = wxPayService.getBusinessCircleService().decryptRefundNotifyDataResource(notifyData); log.info("result: {}", GSON.toJson(result)); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/SubscriptionBillingServiceImplTest.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/SubscriptionBillingServiceImplTest.java
package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.bean.subscriptionbilling.*; import com.github.binarywang.wxpay.service.SubscriptionBillingService; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.google.inject.Inject; import org.testng.annotations.Guice; import org.testng.annotations.Test; /** * 微信支付预约扣费服务测试类 * <p> * 注意:由于预约扣费功能需要用户授权和实际的签约关系, * 这些测试主要用于验证接口调用的正确性,而不是功能的完整性。 * 实际测试需要在具有有效签约关系的环境中进行。 * </p> * * @author Binary Wang */ @Test(enabled = false) // 默认关闭,需要实际环境配置才能测试 @Guice(modules = ApiTestModule.class) public class SubscriptionBillingServiceImplTest { @Inject private WxPayService wxPayService; @Test public void testScheduleSubscription() { try { SubscriptionBillingService service = this.wxPayService.getSubscriptionBillingService(); SubscriptionScheduleRequest request = new SubscriptionScheduleRequest(); request.setOutTradeNo("test_subscription_" + System.currentTimeMillis()); request.setOpenid("test_openid"); request.setDescription("测试预约扣费"); request.setScheduleTime("2024-09-01T10:00:00+08:00"); SubscriptionAmount amount = new SubscriptionAmount(); amount.setTotal(100); // 1元,单位分 amount.setCurrency("CNY"); request.setAmount(amount); BillingPlan billingPlan = new BillingPlan(); billingPlan.setPlanType("MONTHLY"); billingPlan.setPeriod(1); billingPlan.setTotalCount(12); request.setBillingPlan(billingPlan); SubscriptionScheduleResult result = service.scheduleSubscription(request); System.out.println("预约扣费结果:" + result.toString()); assert result.getSubscriptionId() != null; assert "SCHEDULED".equals(result.getStatus()); } catch (Exception e) { // 预期会因为测试环境没有有效的签约关系而失败 System.out.println("预约扣费测试异常(预期):" + e.getMessage()); } } @Test public void testQuerySubscription() { try { SubscriptionBillingService service = this.wxPayService.getSubscriptionBillingService(); SubscriptionQueryResult result = service.querySubscription("test_subscription_id"); System.out.println("查询预约扣费结果:" + result.toString()); } catch (Exception e) { // 预期会因为测试数据不存在而失败 System.out.println("查询预约扣费测试异常(预期):" + e.getMessage()); } } @Test public void testCancelSubscription() { try { SubscriptionBillingService service = this.wxPayService.getSubscriptionBillingService(); SubscriptionCancelRequest request = new SubscriptionCancelRequest(); request.setSubscriptionId("test_subscription_id"); request.setCancelReason("测试取消"); SubscriptionCancelResult result = service.cancelSubscription(request); System.out.println("取消预约扣费结果:" + result.toString()); assert "CANCELLED".equals(result.getStatus()); } catch (Exception e) { // 预期会因为测试数据不存在而失败 System.out.println("取消预约扣费测试异常(预期):" + e.getMessage()); } } @Test public void testInstantBilling() { try { SubscriptionBillingService service = this.wxPayService.getSubscriptionBillingService(); SubscriptionInstantBillingRequest request = new SubscriptionInstantBillingRequest(); request.setOutTradeNo("test_instant_" + System.currentTimeMillis()); request.setOpenid("test_openid"); request.setDescription("测试立即扣费"); SubscriptionAmount amount = new SubscriptionAmount(); amount.setTotal(100); // 1元,单位分 amount.setCurrency("CNY"); request.setAmount(amount); SubscriptionInstantBillingResult result = service.instantBilling(request); System.out.println("立即扣费结果:" + result.toString()); assert result.getTransactionId() != null; } catch (Exception e) { // 预期会因为测试环境没有有效的签约关系而失败 System.out.println("立即扣费测试异常(预期):" + e.getMessage()); } } @Test public void testQueryTransactions() { try { SubscriptionBillingService service = this.wxPayService.getSubscriptionBillingService(); SubscriptionTransactionQueryRequest request = new SubscriptionTransactionQueryRequest(); request.setOpenid("test_openid"); request.setBeginTime("2024-08-01T00:00:00+08:00"); request.setEndTime("2024-08-31T23:59:59+08:00"); request.setLimit(20); request.setOffset(0); SubscriptionTransactionQueryResult result = service.queryTransactions(request); System.out.println("查询扣费记录结果:" + result.toString()); assert result.getTotalCount() != null; } catch (Exception e) { // 预期会因为测试环境数据问题而失败 System.out.println("查询扣费记录测试异常(预期):" + e.getMessage()); } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ComplaintServiceImplTest.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ComplaintServiceImplTest.java
package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.bean.complaint.*; import com.github.binarywang.wxpay.bean.media.ImageUploadResult; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.google.inject.Inject; import lombok.extern.slf4j.Slf4j; import org.testng.annotations.Guice; import org.testng.annotations.Test; import javax.crypto.BadPaddingException; import java.io.File; import java.io.IOException; /** * <pre> * 消费者投诉2.0 测试类 * </pre> * * @author <a href="https://gitee.com/jeequan/jeepay">jmdhappy</a> */ @Test @Slf4j @Guice(modules = ApiTestModule.class) public class ComplaintServiceImplTest { @Inject private WxPayService payService; private static final String complaintId = "200231020220320120496109901"; /** * 查询投诉单列表API * * @throws WxPayException */ @Test public void testQueryComplaints() throws WxPayException, BadPaddingException { ComplaintRequest request = ComplaintRequest .newBuilder() .offset(0) .limit(10) .beginDate("2022-03-01") .endDate("2022-03-20") .complaintedMchid(this.payService.getConfig().getMchId()) .build(); log.info(this.payService.getComplaintsService().queryComplaints(request).toString()); } /** * 查询投诉单详情API * * @throws WxPayException */ @Test public void testGetComplaint() throws WxPayException, BadPaddingException { ComplaintDetailRequest request = ComplaintDetailRequest .newBuilder() .complaintId(complaintId) .build(); log.info(this.payService.getComplaintsService().getComplaint(request).toString()); } /** * 查询投诉协商历史API * * @throws WxPayException */ @Test public void testQueryNegotiationHistorys() throws WxPayException { NegotiationHistoryRequest request = NegotiationHistoryRequest .newBuilder() .complaintId(complaintId) .offset(0) .limit(20) .build(); log.info(this.payService.getComplaintsService().queryNegotiationHistorys(request).toString()); } /** * 创建投诉通知回调地址API * * @throws WxPayException */ @Test public void testAddComplaintNotifyUrl() throws WxPayException { ComplaintNotifyUrlRequest request = ComplaintNotifyUrlRequest .newBuilder() .url("https://jeepay.natapp4.cc") .build(); log.info(this.payService.getComplaintsService().addComplaintNotifyUrl(request).toString()); } /** * 查询投诉通知回调地址API * * @throws WxPayException */ @Test public void testGetComplaintNotifyUrl() throws WxPayException { log.info(this.payService.getComplaintsService().getComplaintNotifyUrl().toString()); } /** * 更新投诉通知回调地址API * * @throws WxPayException */ @Test public void testUpdateComplaintNotifyUrl() throws WxPayException { ComplaintNotifyUrlRequest request = ComplaintNotifyUrlRequest .newBuilder() .url("https://jeepay1.natapp4.cc") .build(); log.info(this.payService.getComplaintsService().updateComplaintNotifyUrl(request).toString()); } /** * 删除投诉通知回调地址API * * @throws WxPayException */ @Test public void testDeleteComplaintNotifyUrl() throws WxPayException { this.payService.getComplaintsService().deleteComplaintNotifyUrl(); } /** * 提交回复API * * @throws WxPayException */ @Test public void testSubmitResponse() throws WxPayException { ResponseRequest request = ResponseRequest .newBuilder() .complaintId(complaintId) .complaintedMchid(this.payService.getConfig().getMchId()) .responseContent("测试投诉接口1233,正在处理,不要炸鸡") //.jumpUrl("https://www.baidu.com") //.jumpUrlText("问题解决方案") .build(); this.payService.getComplaintsService().submitResponse(request); } /** * 反馈处理完成API * * @throws WxPayException */ @Test public void testComplete() throws WxPayException { CompleteRequest request = CompleteRequest .newBuilder() .complaintId(complaintId) .complaintedMchid(this.payService.getConfig().getMchId()) .build(); this.payService.getComplaintsService().complete(request); } /** * 商户上传反馈图片API * * @throws WxPayException * @throws IOException */ @Test public void testUploadResponseImage() throws WxPayException, IOException { String filePath = "你的图片文件的路径地址"; // String filePath="WxJava/images/banners/wiki.jpg"; File file = new File(filePath); ImageUploadResult imageUploadResult = this.payService.getComplaintsService().uploadResponseImage(file); imageUploadResult.getMediaId(); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MarketingMediaServiceImplTest.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MarketingMediaServiceImplTest.java
package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.bean.media.MarketingImageUploadResult; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.google.inject.Inject; import lombok.extern.slf4j.Slf4j; import org.testng.annotations.Guice; import org.testng.annotations.Test; import java.io.File; import java.io.IOException; /** * <pre> * 营销专用媒体文件上传测试类 * </pre> * * @author thinsstar */ @Slf4j @Test @Guice(modules = ApiTestModule.class) public class MarketingMediaServiceImplTest { @Inject private WxPayService wxPayService; @Test public void testMarketingImageUploadV3() throws WxPayException, IOException { String filePath = "你的图片文件的路径地址"; File file = new File(filePath); MarketingImageUploadResult imageUploadResult = wxPayService.getMarketingMediaService().imageUploadV3(file); String mediaUrl = imageUploadResult.getMediaUrl(); log.info("mediaUrl:[{}]", mediaUrl); File file2 = new File(filePath); MarketingImageUploadResult imageUploadResult2 = wxPayService.getMarketingMediaService().imageUploadV3(file2); String mediaUrl2 = imageUploadResult2.getMediaUrl(); log.info("mediaUrl2:[{}]", mediaUrl2); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/RedpackServiceImplTest.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/RedpackServiceImplTest.java
package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.bean.request.WxPaySendMiniProgramRedpackRequest; import com.github.binarywang.wxpay.bean.request.WxPaySendRedpackRequest; import com.github.binarywang.wxpay.bean.result.WxPayRedpackQueryResult; import com.github.binarywang.wxpay.bean.result.WxPaySendMiniProgramRedpackResult; import com.github.binarywang.wxpay.bean.result.WxPaySendRedpackResult; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.github.binarywang.wxpay.testbase.XmlWxPayConfig; import com.google.inject.Inject; import lombok.extern.slf4j.Slf4j; import org.testng.annotations.Guice; import org.testng.annotations.Test; /** * 测试类. * * @author <a href="https://github.com/binarywang">Binary Wang</a> * created on 2019-12-26 */ @Slf4j @Test @Guice(modules = ApiTestModule.class) public class RedpackServiceImplTest { @Inject private WxPayService payService; @Test public void testSendRedpack() throws Exception { WxPaySendRedpackRequest request = new WxPaySendRedpackRequest(); request.setActName("abc"); request.setClientIp("aaa"); request.setMchBillNo("aaaa"); request.setWishing("what"); request.setSendName("111"); request.setTotalAmount(1); request.setTotalNum(1); request.setReOpenid(((XmlWxPayConfig) this.payService.getConfig()).getOpenid()); WxPaySendRedpackResult redpackResult = this.payService.getRedpackService().sendRedpack(request); log.info(redpackResult.toString()); } @Test public void testQueryRedpack() throws Exception { WxPayRedpackQueryResult redpackResult = this.payService.getRedpackService().queryRedpack("aaaa"); log.info(redpackResult.toString()); } @Test public void testSendMiniProgramRedpack() throws WxPayException { final WxPaySendMiniProgramRedpackResult result = this.payService.getRedpackService() .sendMiniProgramRedpack(new WxPaySendMiniProgramRedpackRequest() .setReOpenid("ojOQA0y9o-Eb6Aep7uVTdbkJqrP4") .setWishing("haha") .setMchBillNo("123") .setActName("11") .setSendName("111") .setTotalAmount(1)); System.out.println(result); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MiPayServiceImplTest.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MiPayServiceImplTest.java
package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.bean.mipay.MedInsOrdersRequest; import com.github.binarywang.wxpay.bean.mipay.MedInsOrdersResult; import com.github.binarywang.wxpay.bean.mipay.MedInsRefundNotifyRequest; import com.github.binarywang.wxpay.bean.notify.MiPayNotifyV3Result; import com.github.binarywang.wxpay.bean.notify.SignatureHeader; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.MiPayService; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.inject.Inject; import lombok.extern.slf4j.Slf4j; import org.testng.annotations.Guice; import org.testng.annotations.Test; /** * 医保接口测试 * @author xgl * @date 2025/12/20 10:04 */ @Slf4j @Test @Guice(modules = ApiTestModule.class) public class MiPayServiceImplTest { @Inject private WxPayService wxPayService; private static final Gson GSON = new GsonBuilder().create(); /** * 医保自费混合收款下单测试 * @throws WxPayException */ @Test public void medInsOrders() throws WxPayException { String requestParamStr = "{\"mix_pay_type\":\"CASH_AND_INSURANCE\",\"order_type\":\"REG_PAY\",\"appid\":\"wxdace645e0bc2cXXX\",\"sub_appid\":\"wxdace645e0bc2cXXX\",\"sub_mchid\":\"1900008XXX\",\"openid\":\"o4GgauInH_RCEdvrrNGrntXDuXXX\",\"sub_openid\":\"o4GgauInH_RCEdvrrNGrntXDuXXX\",\"payer\":{\"name\":\"张三\",\"id_digest\":\"09eb26e839ff3a2e3980352ae45ef09e\",\"card_type\":\"ID_CARD\"},\"pay_for_relatives\":false,\"relative\":{\"name\":\"张三\",\"id_digest\":\"09eb26e839ff3a2e3980352ae45ef09e\",\"card_type\":\"ID_CARD\"},\"out_trade_no\":\"202204022005169952975171534816\",\"serial_no\":\"1217752501201\",\"pay_order_id\":\"ORD530100202204022006350000021\",\"pay_auth_no\":\"AUTH530100202204022006310000034\",\"geo_location\":\"102.682296,25.054260\",\"city_id\":\"530100\",\"med_inst_name\":\"北大医院\",\"med_inst_no\":\"1217752501201407033233368318\",\"med_ins_order_create_time\":\"2015-05-20T13:29:35+08:00\",\"total_fee\":202000,\"med_ins_gov_fee\":100000,\"med_ins_self_fee\":45000,\"med_ins_other_fee\":5000,\"med_ins_cash_fee\":50000,\"wechat_pay_cash_fee\":42000,\"cash_add_detail\":[{\"cash_add_fee\":2000,\"cash_add_type\":\"FREIGHT\"}],\"cash_reduce_detail\":[{\"cash_reduce_fee\":10000,\"cash_reduce_type\":\"DEFAULT_REDUCE_TYPE\"}],\"callback_url\":\"https://www.weixin.qq.com/wxpay/pay.php\",\"prepay_id\":\"wx201410272009395522657a690389285100\",\"passthrough_request_content\":\"{\\\"payAuthNo\\\":\\\"AUTH****\\\",\\\"payOrdId\\\":\\\"ORD****\\\",\\\"setlLatlnt\\\":\\\"118.096435,24.485407\\\"}\",\"extends\":\"{}\",\"attach\":\"{}\",\"channel_no\":\"AAGN9uhZc5EGyRdairKW7Qnu\",\"med_ins_test_env\":false}"; MedInsOrdersRequest request = GSON.fromJson(requestParamStr, MedInsOrdersRequest.class); MiPayService miPayService = wxPayService.getMiPayService(); MedInsOrdersResult result = miPayService.medInsOrders(request); log.info(result.toString()); } /** * 使用医保自费混合订单号查看下单结果测试 * @throws WxPayException */ @Test public void getMedInsOrderByMixTradeNo() throws WxPayException { // 测试用的医保自费混合订单号和医疗机构商户号 String mixTradeNo = "202204022005169952975171534816"; String subMchid = "1900000109"; MiPayService miPayService = wxPayService.getMiPayService(); MedInsOrdersResult result = miPayService.getMedInsOrderByMixTradeNo(mixTradeNo, subMchid); log.info(result.toString()); } /** * 使用从业机构订单号查看下单结果测试 * @throws WxPayException */ @Test public void getMedInsOrderByOutTradeNo() throws WxPayException { // 测试用的从业机构订单号和医疗机构商户号 String outTradeNo = "202204022005169952975171534816"; String subMchid = "1900000109"; MiPayService miPayService = wxPayService.getMiPayService(); MedInsOrdersResult result = miPayService.getMedInsOrderByOutTradeNo(outTradeNo, subMchid); log.info(result.toString()); } /** * 解析医保混合收款成功通知测试 * @throws WxPayException */ @Test public void parseMiPayNotifyV3Result() throws WxPayException { // 模拟的医保混合收款成功通知数据 String notifyData = "{\"id\":\"EV-202401011234567890\",\"create_time\":\"2024-01-01T12:34:56+08:00\",\"event_type\":\"MEDICAL_INSURANCE.SUCCESS\",\"summary\":\"医保混合收款成功\",\"resource_type\":\"encrypt-resource\",\"resource\":{\"algorithm\":\"AEAD_AES_256_GCM\",\"ciphertext\":\"encrypted_data\",\"associated_data\":\"\",\"nonce\":\"random_string\"}}"; // 模拟的签名信息 String signature = "test_signature"; String timestamp = "1234567890"; String nonce = "test_nonce"; String serial = "test_serial"; MiPayService miPayService = wxPayService.getMiPayService(); SignatureHeader header = SignatureHeader.builder() .signature(signature) .timeStamp(timestamp) .nonce(nonce) .serial(serial) .build(); try { // 调用解析方法,预期会失败,因为是模拟数据 MiPayNotifyV3Result result = miPayService.parseMiPayNotifyV3Result(notifyData, header); log.info("解析结果:{}", result); } catch (WxPayException e) { // 预期会抛出异常,因为是模拟数据,签名验证和解密都会失败 log.info("预期的异常:{}", e.getMessage()); } } /** * 医保退款通知测试 * @throws WxPayException */ @Test public void medInsRefundNotify() throws WxPayException { // 测试用的医保自费混合订单号 String mixTradeNo = "202204022005169952975171534816"; // 模拟的医保退款通知请求数据 String requestParamStr = "{\"sub_mchid\":\"1900008XXX\",\"med_refund_total_fee\":45000,\"med_refund_gov_fee\":45000,\"med_refund_self_fee\":45000,\"med_refund_other_fee\":45000,\"refund_time\":\"2015-05-20T13:29:35+08:00\",\"out_refund_no\":\"R202204022005169952975171534816\"}"; // 解析请求参数 MedInsRefundNotifyRequest request = GSON.fromJson(requestParamStr, MedInsRefundNotifyRequest.class); MiPayService miPayService = wxPayService.getMiPayService(); try { // 调用医保退款通知方法,预期会失败,因为是模拟数据 miPayService.medInsRefundNotify(request,mixTradeNo); log.info("医保退款通知调用成功"); } catch (WxPayException e) { // 预期会抛出异常,因为是模拟数据 log.info("预期的异常:{}", e.getMessage()); } } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImplTest.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/EcommerceServiceImplTest.java
package com.github.binarywang.wxpay.service.impl; import com.google.common.collect.Lists; import com.github.binarywang.wxpay.bean.ecommerce.*; import com.github.binarywang.wxpay.bean.ecommerce.enums.SpAccountTypeEnum; import com.github.binarywang.wxpay.bean.ecommerce.enums.TradeTypeEnum; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.google.gson.GsonBuilder; import com.google.inject.Inject; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.util.RandomUtils; import org.testng.annotations.Guice; import org.testng.annotations.Test; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Arrays; @Slf4j @Test @Guice(modules = ApiTestModule.class) public class EcommerceServiceImplTest { @Inject private WxPayService wxPayService; @Test public void testNotifySign() { //通知报文主体 String notifyData = ""; //请求头 Wechatpay-Timestamp String timeStamp = ""; //请求头 Wechatpay-Nonce String nonce = ""; //请求头 Wechatpay-Signature String signed = ""; //请求头 Wechatpay-Serial String serialNo = ""; SignatureHeader header = new SignatureHeader(); header.setNonce(nonce); header.setSerialNo(serialNo); header.setTimeStamp(timeStamp); header.setSigned(signed); String beforeSign = String.format("%s\n%s\n%s\n", header.getTimeStamp(), header.getNonce(), notifyData); boolean signResult = wxPayService.getConfig().getVerifier().verify(header.getSerialNo(), beforeSign.getBytes(StandardCharsets.UTF_8), header.getSigned()); log.info("签名结果:{} \nheader:{} \ndata:{}", signResult, header, notifyData); } @Test public void testCombinePay() throws WxPayException { String outTradeNo = RandomUtils.getRandomStr(); String notifyUrl = "https://api.qq.com/"; System.out.println("outTradeNo = " + outTradeNo); CombineTransactionsRequest request = new CombineTransactionsRequest(); request.setCombineAppid(""); request.setCombineMchid(""); request.setCombineOutTradeNo(outTradeNo); request.setNotifyUrl(notifyUrl); CombineTransactionsRequest.CombinePayerInfo payerInfo = new CombineTransactionsRequest.CombinePayerInfo(); payerInfo.setOpenid(""); request.setCombinePayerInfo(payerInfo); //构建金额信息 CombineTransactionsRequest.Amount requestAmount = new CombineTransactionsRequest.Amount(); //设置币种信息 requestAmount.setCurrency("CNY"); //设置金额 requestAmount.setTotalAmount(1); CombineTransactionsRequest.SubOrders subOrder1 = new CombineTransactionsRequest.SubOrders(); //设置 子单商户号 mchId 和 combine_mchId 取值一样 subOrder1.setMchid(""); String subOrderNo1 = outTradeNo + "1"; subOrder1.setAttach(subOrderNo1); subOrder1.setOutTradeNo(subOrderNo1); subOrder1.setDescription("订单1"); subOrder1.setAmount(requestAmount); CombineTransactionsRequest.SubOrders subOrder2 = new CombineTransactionsRequest.SubOrders(); //设置 子单商户号 mchId 和 combine_mchId 取值一样 subOrder2.setMchid(""); String subOrderNo2 = outTradeNo + "2"; subOrder2.setAttach(subOrderNo2); subOrder2.setOutTradeNo(subOrderNo2); subOrder2.setSubMchid(""); subOrder2.setDescription("订单2"); subOrder2.setAmount(requestAmount); request.setSubOrders(Arrays.asList(subOrder1, subOrder2)); TransactionsResult result = wxPayService.getEcommerceService().combine(TradeTypeEnum.JSAPI, request); System.out.println("result = " + result); } @Test public void testQueryPartnerTransactions() throws WxPayException { PartnerTransactionsQueryRequest request = new PartnerTransactionsQueryRequest(); //服务商商户号 request.setSpMchid(""); //二级商户号 request.setSubMchid(""); //商户订单号 request.setOutTradeNo(""); //微信订单号 request.setTransactionId(""); PartnerTransactionsResult result = wxPayService.getEcommerceService().queryPartnerTransactions(request); System.out.println("result = " + result); } @Test public void testSubNowBalance() throws WxPayException { String subMchid = ""; wxPayService.getEcommerceService().subNowBalance(subMchid); } @Test public void testSubNowBalanceWithAccountType() throws WxPayException { String subMchid = ""; wxPayService.getEcommerceService().subNowBalance(subMchid, SpAccountTypeEnum.BASIC); } @Test public void testAddReceivers() throws WxPayException { ProfitSharingReceiverRequest request = new ProfitSharingReceiverRequest(); request.setAppid("wx8888888888888888"); request.setType("MERCHANT_ID"); request.setAccount("190001001"); request.setName("张三网络公司"); request.setRelationType("SUPPLIER"); ProfitSharingReceiverResult result = wxPayService.getEcommerceService().addReceivers(request); System.out.println("result = " + result); } @Test public void testSubDayEndBalance() throws WxPayException { String subMchid = ""; String date = ""; wxPayService.getEcommerceService().subDayEndBalance(subMchid, date); } @Test public void testCreatedAccountCancelApplication() throws WxPayException { AccountCancelApplicationsRequest request = new AccountCancelApplicationsRequest(); request.setSubMchid(""); request.setOutApplyNo(""); request.setApplicationInfo(Lists.newArrayList()); AccountCancelApplicationsResult result = wxPayService.getEcommerceService().createdAccountCancelApplication(request); log.info("请求参数:{} 响应结果:{}", request, result); } @Test public void testGetAccountCancelApplication() throws WxPayException { String request = "申请单号"; AccountCancelApplicationsResult result = wxPayService.getEcommerceService().getAccountCancelApplication(request); log.info("请求参数:{} 响应结果:{}", request, result); } @Test public void testUploadMediaAccountCancelApplication() throws WxPayException, IOException { AccountCancelApplicationsMediaResult result = wxPayService.getEcommerceService() .uploadMediaAccountCancelApplication(new File("src\\test\\resources\\mm.jpeg")); log.info("响应结果:{}", result); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImplTest.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MerchantTransferServiceImplTest.java
package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.bean.merchanttransfer.*; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.inject.Inject; import lombok.extern.slf4j.Slf4j; import org.testng.annotations.Guice; import org.testng.annotations.Test; /** * 商家转账到零钱(直连商户) * @author glz * created on 2022/6/11 */ @Slf4j @Test @Guice(modules = ApiTestModule.class) public class MerchantTransferServiceImplTest { @Inject private WxPayService wxPayService; private static final Gson GSON = new GsonBuilder().create(); @Test public void createTransfer() throws WxPayException { String requestParamStr = "{\"out_batch_no\":\"p11lfk2020042013\",\"batch_name\":\"xxx\",\"batch_remark\":\"xxx\",\"total_amount\":30,\"total_num\":1,\"transfer_detail_list\":[{\"out_detail_no\":\"x23zy545Bd5436\",\"transfer_amount\":30,\"transfer_remark\":\"5586提款\",\"openid\":\"or1b65DLMUir7F-_vLwKlutmm3qw\",\"user_name\":\"xxx\"}]}"; TransferCreateRequest request = GSON.fromJson(requestParamStr, TransferCreateRequest.class); TransferCreateResult result = wxPayService.getMerchantTransferService().createTransfer(request); log.info(result.toString()); } @Test public void queryWxBatches() throws WxPayException { String requestParamStr = "{\"batch_id\":\"xxx\",\"need_query_detail\":true,\"offset\":0,\"limit\":20,\"detail_status\":\"ALL\"}"; WxBatchesQueryRequest request = GSON.fromJson(requestParamStr, WxBatchesQueryRequest.class); log.info("request:{}",request); BatchesQueryResult result = wxPayService.getMerchantTransferService().queryWxBatches(request); log.info(result.toString()); } @Test public void queryWxDetails() throws WxPayException { String requestParamStr = "{\"batch_id\":\"xxx\",\"detail_id\":\"xxx\"}"; WxDetailsQueryRequest request = GSON.fromJson(requestParamStr, WxDetailsQueryRequest.class); DetailsQueryResult result = wxPayService.getMerchantTransferService().queryWxDetails(request); log.info(result.toString()); } @Test public void queryMerchantBatches() throws WxPayException { String requestParamStr = "{\"out_batch_no\":\"p11lfk2020042013\",\"need_query_detail\":true,\"offset\":0,\"limit\":20,\"detail_status\":\"ALL\"}"; MerchantBatchesQueryRequest request = GSON.fromJson(requestParamStr, MerchantBatchesQueryRequest.class); BatchesQueryResult result = wxPayService.getMerchantTransferService().queryMerchantBatches(request); log.info(result.toString()); } @Test public void queryMerchantDetails() throws WxPayException { String requestParamStr = "{\"out_detail_no\":\"x23zy545Bd5436\",\"out_batch_no\":\"p11lfk2020042013\"}"; MerchantDetailsQueryRequest request = GSON.fromJson(requestParamStr, MerchantDetailsQueryRequest.class); DetailsQueryResult result = wxPayService.getMerchantTransferService().queryMerchantDetails(request); log.info(result.toString()); } @Test public void applyElectronicBill() throws WxPayException { String requestParamStr = "{\"out_batch_no\":\"p11lfk2020042013\"}"; ElectronicBillApplyRequest request = GSON.fromJson(requestParamStr, ElectronicBillApplyRequest.class); ElectronicBillResult result = wxPayService.getMerchantTransferService().applyElectronicBill(request); log.info(result.toString()); } @Test public void queryElectronicBill() throws WxPayException { String outBatchNo = "p11lfk2020042013"; ElectronicBillResult result = wxPayService.getMerchantTransferService().queryElectronicBill(outBatchNo); log.info(result.toString()); } @Test public void applyDetailElectronicBill() throws WxPayException { String requestParamStr = "{\"accept_type\":\"BATCH_TRANSFER\",\"out_batch_no\":\"p11lfk2020042013\",\"out_detail_no\":\"x23zy545Bd5436\"}"; DetailElectronicBillRequest request = GSON.fromJson(requestParamStr, DetailElectronicBillRequest.class); DetailElectronicBillResult result = wxPayService.getMerchantTransferService().applyDetailElectronicBill(request); log.info(result.toString()); } @Test public void queryDetailElectronicBill() throws WxPayException { String requestParamStr = "{\"accept_type\":\"BATCH_TRANSFER\",\"out_batch_no\":\"p11lfk2020042013\",\"out_detail_no\":\"x23zy545Bd5436\"}"; DetailElectronicBillRequest request = GSON.fromJson(requestParamStr, DetailElectronicBillRequest.class); DetailElectronicBillResult result = wxPayService.getMerchantTransferService().queryDetailElectronicBill(request); log.info(result.toString()); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false
binarywang/WxJava
https://github.com/binarywang/WxJava/blob/84b5c4d2d0774f800237634e5d0336f53c004fe3/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MarketingFavorServiceImplTest.java
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/MarketingFavorServiceImplTest.java
package com.github.binarywang.wxpay.service.impl; import com.github.binarywang.wxpay.bean.marketing.*; import com.github.binarywang.wxpay.bean.marketing.enums.StockTypeEnum; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.MarketingFavorService; import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.testbase.ApiTestModule; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.inject.Inject; import lombok.extern.slf4j.Slf4j; import org.testng.annotations.Guice; import org.testng.annotations.Test; import java.util.Collections; /** * <pre> * 营销工具代金券测试类 * </pre> * * @author thinsstar */ @Slf4j @Test @Guice(modules = ApiTestModule.class) public class MarketingFavorServiceImplTest { @Inject private WxPayService wxPayService; private static final Gson GSON = new GsonBuilder().create(); private final String stockId = "批次id"; private final String appId = "公众号id"; private final String openId = "微信openid"; @Test public void testCreateFavorStocksV3() throws WxPayException { FavorStocksCreateRequest request = new FavorStocksCreateRequest(); request.setStockName("测试代金券"); request.setComment("测试代金券备注"); request.setBelongMerchant(wxPayService.getConfig().getMchId()); request.setAvailableBeginTime("2021-02-05T00:00:00.000+08:00"); request.setAvailableEndTime("2021-03-31T00:00:00.000+08:00"); request.setNoCash(false); request.setStockType(StockTypeEnum.NORMAL); request.setOutRequestNo(wxPayService.getConfig().getMchId() + "20210204" + "1234567890"); //发放规则 FavorStocksCreateRequest.StockUseRule stockUseRule = new FavorStocksCreateRequest.StockUseRule(); stockUseRule.setMaxCoupons(5); stockUseRule.setMaxCouponsPerUser(5); stockUseRule.setNaturalPersonLimit(true); stockUseRule.setPreventApiAbuse(false); stockUseRule.setMaxAmount(50); request.setStockUseRule(stockUseRule); //样式设置 // FavorStocksCreateRequest.PatternInfo patternInfo = new FavorStocksCreateRequest.PatternInfo(); // request.setPatternInfo(patternInfo); //核销规则 FavorStocksCreateRequest.CouponUseRule couponUseRule = new FavorStocksCreateRequest.CouponUseRule(); FavorStocksCreateRequest.FixedNormalCoupon fixedNormalCoupon = new FavorStocksCreateRequest.FixedNormalCoupon(); fixedNormalCoupon.setCouponAmount(10); fixedNormalCoupon.setTransactionMinimum(11); couponUseRule.setFixedNormalCoupon(fixedNormalCoupon); couponUseRule.setCombineUse(true); couponUseRule.setAvailableMerchants(Collections.singletonList(wxPayService.getConfig().getMchId())); request.setCouponUseRule(couponUseRule); FavorStocksCreateResult result = wxPayService.getMarketingFavorService().createFavorStocksV3(request); String stockId = result.getStockId(); log.info("stockId: [{}]", stockId); } @Test public void testCreateFavorCouponsV3() throws WxPayException { MarketingFavorService marketingFavorService = new MarketingFavorServiceImpl(wxPayService); FavorCouponsCreateRequest request = new FavorCouponsCreateRequest(); request.setStockCreatorMchid(wxPayService.getConfig().getMchId()); request.setStockId(stockId); request.setAppid(appId); request.setOutRequestNo(wxPayService.getConfig().getMchId() + "20210204" + "1234567890"); FavorCouponsCreateResult result = wxPayService.getMarketingFavorService().createFavorCouponsV3(openId, request); log.info("result: {}", GSON.toJson(result)); } @Test public void testStartFavorStocksV3() throws WxPayException { FavorStocksSetRequest request = new FavorStocksSetRequest(); request.setStockCreatorMchid(wxPayService.getConfig().getMchId()); FavorStocksStartResult result = wxPayService.getMarketingFavorService().startFavorStocksV3(stockId, request); log.info("result: {}", GSON.toJson(result)); } @Test public void testQueryFavorStocksV3() throws WxPayException { FavorStocksQueryRequest request = new FavorStocksQueryRequest(); request.setOffset(0); request.setLimit(10); request.setStockCreatorMchid(wxPayService.getConfig().getMchId()); FavorStocksQueryResult result = wxPayService.getMarketingFavorService().queryFavorStocksV3(request); log.info("result: {}", GSON.toJson(result)); } @Test public void testGetFavorStocksV3() throws WxPayException { FavorStocksGetResult result = wxPayService.getMarketingFavorService().getFavorStocksV3(stockId, wxPayService.getConfig().getMchId()); log.info("result: {}", GSON.toJson(result)); } @Test public void testGetFavorCouponsV3() throws WxPayException { FavorCouponsGetResult result = wxPayService.getMarketingFavorService().getFavorCouponsV3("20387541242", appId, openId); log.info("result: {}", GSON.toJson(result)); } @Test public void testGetFavorStocksMerchantsV3() throws WxPayException { FavorStocksMerchantsGetResult result = wxPayService.getMarketingFavorService().getFavorStocksMerchantsV3(stockId, wxPayService.getConfig().getMchId(), 0, 50); log.info("result: {}", GSON.toJson(result)); } @Test public void testGetFavorStocksItemsV3() throws WxPayException { FavorStocksItemsGetResult result = wxPayService.getMarketingFavorService().getFavorStocksItemsV3(stockId, wxPayService.getConfig().getMchId(), 0, 100); log.info("result: {}", GSON.toJson(result)); } @Test public void testQueryFavorCouponsV3() throws WxPayException { FavorCouponsQueryRequest request = new FavorCouponsQueryRequest(); request.setAppid(appId); request.setOpenid(openId); request.setAvailableMchid(wxPayService.getConfig().getMchId()); FavorCouponsQueryResult result = wxPayService.getMarketingFavorService().queryFavorCouponsV3(request); log.info("result: {}", GSON.toJson(result)); } @Test public void testGetFavorStocksUseFlowV3() throws WxPayException { FavorStocksFlowGetResult result = wxPayService.getMarketingFavorService().getFavorStocksUseFlowV3(stockId); log.info("result: {}", GSON.toJson(result)); } @Test public void testGetFavorStocksRefundFlowV3() throws WxPayException { FavorStocksFlowGetResult result = wxPayService.getMarketingFavorService().getFavorStocksRefundFlowV3(stockId); log.info("result: {}", GSON.toJson(result)); } @Test public void testSaveFavorCallbacksV3() throws WxPayException { FavorCallbacksSaveRequest request = new FavorCallbacksSaveRequest(); request.setMchid(wxPayService.getConfig().getMchId()); request.setNotifyUrl("你的回调地址"); request.setSwitchBool(false); FavorCallbacksSaveResult result = wxPayService.getMarketingFavorService().saveFavorCallbacksV3(request); log.info("result: {}", GSON.toJson(result)); } @Test public void testPauseFavorStocksV3() throws WxPayException { FavorStocksSetRequest request = new FavorStocksSetRequest(); request.setStockCreatorMchid(wxPayService.getConfig().getMchId()); FavorStocksPauseResult result = wxPayService.getMarketingFavorService().pauseFavorStocksV3(stockId, request); log.info("result: {}", GSON.toJson(result)); } @Test public void testRestartFavorStocksV3() throws WxPayException { FavorStocksSetRequest request = new FavorStocksSetRequest(); request.setStockCreatorMchid(wxPayService.getConfig().getMchId()); FavorStocksRestartResult result = wxPayService.getMarketingFavorService().restartFavorStocksV3(stockId, request); log.info("result: {}", GSON.toJson(result)); } }
java
Apache-2.0
84b5c4d2d0774f800237634e5d0336f53c004fe3
2026-01-04T14:46:39.499027Z
false