From ee6a84f6abb6db65d6ffbbca65bfe4b808157678 Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Fri, 24 Jun 2016 15:24:07 +0800 Subject: [PATCH 01/26] no commit message --- .../sd4324530/fastweixin/api/BaseAPI.java | 12 +++--- .../sd4324530/fastweixin/api/CustomAPI.java | 30 +++++++++------ .../sd4324530/fastweixin/api/DataCubeAPI.java | 34 +++++++++++++---- .../sd4324530/fastweixin/api/JsAPI.java | 13 ++++--- .../sd4324530/fastweixin/api/MaterialAPI.java | 37 +++++++++++-------- .../sd4324530/fastweixin/api/MediaAPI.java | 36 +++++++++--------- .../sd4324530/fastweixin/api/MenuAPI.java | 17 +++++---- .../sd4324530/fastweixin/api/MessageAPI.java | 29 ++++++++++----- .../sd4324530/fastweixin/api/OauthAPI.java | 15 ++++---- .../sd4324530/fastweixin/api/QrcodeAPI.java | 15 ++++---- .../sd4324530/fastweixin/api/SystemAPI.java | 17 +++++---- .../sd4324530/fastweixin/api/TagAPI.java | 15 ++++---- .../fastweixin/api/TemplateMsgAPI.java | 15 ++++---- .../sd4324530/fastweixin/api/UserAPI.java | 24 +++++++----- 14 files changed, 182 insertions(+), 127 deletions(-) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/BaseAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/BaseAPI.java index 8baf84d..767dff3 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/BaseAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/BaseAPI.java @@ -1,14 +1,14 @@ package com.github.sd4324530.fastweixin.api; -import com.github.sd4324530.fastweixin.api.config.ApiConfig; +import java.io.File; +import java.util.List; + import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.CollectionUtil; import com.github.sd4324530.fastweixin.util.NetWorkCenter; - -import java.io.File; -import java.util.List; +import com.loogk.wx.model.WxConfig; /** * API基类,提供一些通用方法 @@ -21,14 +21,14 @@ public abstract class BaseAPI { protected static final String BASE_API_URL = "https://api.weixin.qq.com/"; - protected final ApiConfig config; + protected final WxConfig config; /** * 构造方法,设置apiConfig * * @param config 微信API配置对象 */ - protected BaseAPI(ApiConfig config) { + protected BaseAPI(WxConfig config) { this.config = config; } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java index ab79e22..dfae2bc 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java @@ -1,23 +1,31 @@ package com.github.sd4324530.fastweixin.api; -import com.github.sd4324530.fastweixin.api.config.ApiConfig; +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.github.sd4324530.fastweixin.api.entity.CustomAccount; import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.api.response.GetCustomAccountsResponse; import com.github.sd4324530.fastweixin.exception.WeixinException; -import com.github.sd4324530.fastweixin.message.*; +import com.github.sd4324530.fastweixin.message.Article; +import com.github.sd4324530.fastweixin.message.BaseMsg; +import com.github.sd4324530.fastweixin.message.ImageMsg; +import com.github.sd4324530.fastweixin.message.MusicMsg; +import com.github.sd4324530.fastweixin.message.NewsMsg; +import com.github.sd4324530.fastweixin.message.TextMsg; +import com.github.sd4324530.fastweixin.message.VideoMsg; +import com.github.sd4324530.fastweixin.message.VoiceMsg; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; import com.github.sd4324530.fastweixin.util.StrUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.loogk.wx.model.WxConfig; /** * 客服相关API @@ -29,7 +37,7 @@ public class CustomAPI extends BaseAPI { private static final Logger LOG = LoggerFactory.getLogger(CustomAPI.class); - public CustomAPI(ApiConfig config) { + public CustomAPI(WxConfig config) { super(config); } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/DataCubeAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/DataCubeAPI.java index c55dcab..bd566cb 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/DataCubeAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/DataCubeAPI.java @@ -1,18 +1,36 @@ package com.github.sd4324530.fastweixin.api; -import com.github.sd4324530.fastweixin.api.config.ApiConfig; -import com.github.sd4324530.fastweixin.api.response.*; -import com.github.sd4324530.fastweixin.util.BeanUtil; -import com.github.sd4324530.fastweixin.util.JSONUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.github.sd4324530.fastweixin.api.response.BaseResponse; +import com.github.sd4324530.fastweixin.api.response.GetArticleSummaryResponse; +import com.github.sd4324530.fastweixin.api.response.GetArticleTotalResponse; +import com.github.sd4324530.fastweixin.api.response.GetInterfaceSummaryHourResponse; +import com.github.sd4324530.fastweixin.api.response.GetInterfaceSummaryResponse; +import com.github.sd4324530.fastweixin.api.response.GetUpstreamMsgDistMonthResponse; +import com.github.sd4324530.fastweixin.api.response.GetUpstreamMsgDistResponse; +import com.github.sd4324530.fastweixin.api.response.GetUpstreamMsgDistWeekResponse; +import com.github.sd4324530.fastweixin.api.response.GetUpstreamMsgHourResponse; +import com.github.sd4324530.fastweixin.api.response.GetUpstreamMsgMonthResponse; +import com.github.sd4324530.fastweixin.api.response.GetUpstreamMsgResponse; +import com.github.sd4324530.fastweixin.api.response.GetUpstreamMsgWeekResponse; +import com.github.sd4324530.fastweixin.api.response.GetUserCumulateResponse; +import com.github.sd4324530.fastweixin.api.response.GetUserReadHourResponse; +import com.github.sd4324530.fastweixin.api.response.GetUserReadResponse; +import com.github.sd4324530.fastweixin.api.response.GetUserShareHourResponse; +import com.github.sd4324530.fastweixin.api.response.GetUserShareResponse; +import com.github.sd4324530.fastweixin.api.response.GetUserSummaryResponse; +import com.github.sd4324530.fastweixin.util.BeanUtil; +import com.github.sd4324530.fastweixin.util.JSONUtil; +import com.loogk.wx.model.WxConfig; + /** * 数据分析API * @@ -24,7 +42,7 @@ public class DataCubeAPI extends BaseAPI { private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); - public DataCubeAPI(ApiConfig config) { + public DataCubeAPI(WxConfig config) { super(config); } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/JsAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/JsAPI.java index 1f0ba16..500a2b6 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/JsAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/JsAPI.java @@ -1,14 +1,15 @@ package com.github.sd4324530.fastweixin.api; -import com.github.sd4324530.fastweixin.api.config.ApiConfig; +import java.util.UUID; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.GetSignatureResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JsApiUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.UUID; +import com.loogk.wx.model.WxConfig; /** * 微信js-sdk相关API @@ -18,7 +19,7 @@ public class JsAPI extends BaseAPI { private static final Logger LOG = LoggerFactory.getLogger(JsAPI.class); - public JsAPI(ApiConfig config) { + public JsAPI(WxConfig config) { super(config); } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/MaterialAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/MaterialAPI.java index 31efa4f..b121603 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/MaterialAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/MaterialAPI.java @@ -1,13 +1,13 @@ package com.github.sd4324530.fastweixin.api; -import com.github.sd4324530.fastweixin.api.config.ApiConfig; -import com.github.sd4324530.fastweixin.api.entity.Article; -import com.github.sd4324530.fastweixin.api.enums.MaterialType; -import com.github.sd4324530.fastweixin.api.enums.ResultType; -import com.github.sd4324530.fastweixin.api.response.*; -import com.github.sd4324530.fastweixin.util.JSONUtil; -import com.github.sd4324530.fastweixin.util.NetWorkCenter; -import com.github.sd4324530.fastweixin.util.StrUtil; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpStatus; @@ -23,13 +23,18 @@ import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.Charset; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.github.sd4324530.fastweixin.api.entity.Article; +import com.github.sd4324530.fastweixin.api.enums.MaterialType; +import com.github.sd4324530.fastweixin.api.enums.ResultType; +import com.github.sd4324530.fastweixin.api.response.BaseResponse; +import com.github.sd4324530.fastweixin.api.response.DownloadMaterialResponse; +import com.github.sd4324530.fastweixin.api.response.GetMaterialListResponse; +import com.github.sd4324530.fastweixin.api.response.GetMaterialTotalCountResponse; +import com.github.sd4324530.fastweixin.api.response.UploadMaterialResponse; +import com.github.sd4324530.fastweixin.util.JSONUtil; +import com.github.sd4324530.fastweixin.util.NetWorkCenter; +import com.github.sd4324530.fastweixin.util.StrUtil; +import com.loogk.wx.model.WxConfig; /** * @@ -43,7 +48,7 @@ public class MaterialAPI extends BaseAPI { private static final Logger LOG = LoggerFactory.getLogger(MaterialAPI.class); - public MaterialAPI(ApiConfig config) { + public MaterialAPI(WxConfig config) { super(config); } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/MediaAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/MediaAPI.java index bbd06aa..5b1d69f 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/MediaAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/MediaAPI.java @@ -1,14 +1,13 @@ package com.github.sd4324530.fastweixin.api; -import com.github.sd4324530.fastweixin.api.config.ApiConfig; -import com.github.sd4324530.fastweixin.api.entity.Article; -import com.github.sd4324530.fastweixin.api.enums.MediaType; -import com.github.sd4324530.fastweixin.api.enums.ResultType; -import com.github.sd4324530.fastweixin.api.response.*; -import com.github.sd4324530.fastweixin.util.JSONUtil; -import com.github.sd4324530.fastweixin.util.NetWorkCenter; -import com.github.sd4324530.fastweixin.util.StrUtil; -import com.github.sd4324530.fastweixin.util.StreamUtil; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.apache.http.Header; import org.apache.http.HttpStatus; import org.apache.http.client.config.RequestConfig; @@ -19,13 +18,16 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.github.sd4324530.fastweixin.api.entity.Article; +import com.github.sd4324530.fastweixin.api.enums.MediaType; +import com.github.sd4324530.fastweixin.api.response.BaseResponse; +import com.github.sd4324530.fastweixin.api.response.DownloadMediaResponse; +import com.github.sd4324530.fastweixin.api.response.UploadImgResponse; +import com.github.sd4324530.fastweixin.api.response.UploadMediaResponse; +import com.github.sd4324530.fastweixin.util.JSONUtil; +import com.github.sd4324530.fastweixin.util.NetWorkCenter; +import com.github.sd4324530.fastweixin.util.StreamUtil; +import com.loogk.wx.model.WxConfig; /** * 多媒体资源API @@ -36,7 +38,7 @@ public class MediaAPI extends BaseAPI { private static final Logger LOG = LoggerFactory.getLogger(MediaAPI.class); - public MediaAPI(ApiConfig config) { + public MediaAPI(WxConfig config) { super(config); } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/MenuAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/MenuAPI.java index e07ba71..eac9994 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/MenuAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/MenuAPI.java @@ -1,8 +1,14 @@ package com.github.sd4324530.fastweixin.api; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONPath; -import com.github.sd4324530.fastweixin.api.config.ApiConfig; import com.github.sd4324530.fastweixin.api.entity.Menu; import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; @@ -10,12 +16,7 @@ import com.github.sd4324530.fastweixin.api.response.GetMenuResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.CollectionUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.loogk.wx.model.WxConfig; /** * 菜单相关API @@ -28,7 +29,7 @@ public class MenuAPI extends BaseAPI { private static final Logger LOG = LoggerFactory.getLogger(MenuAPI.class); - public MenuAPI(ApiConfig config) { + public MenuAPI(WxConfig config) { super(config); } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/MessageAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/MessageAPI.java index f6296ac..739b44c 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/MessageAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/MessageAPI.java @@ -1,19 +1,28 @@ package com.github.sd4324530.fastweixin.api; -import com.github.sd4324530.fastweixin.api.config.ApiConfig; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.api.response.GetSendMessageResponse; -import com.github.sd4324530.fastweixin.message.*; +import com.github.sd4324530.fastweixin.message.Article; +import com.github.sd4324530.fastweixin.message.BaseMsg; +import com.github.sd4324530.fastweixin.message.ImageMsg; +import com.github.sd4324530.fastweixin.message.MpNewsMsg; +import com.github.sd4324530.fastweixin.message.MusicMsg; +import com.github.sd4324530.fastweixin.message.NewsMsg; +import com.github.sd4324530.fastweixin.message.TextMsg; +import com.github.sd4324530.fastweixin.message.VideoMsg; +import com.github.sd4324530.fastweixin.message.VoiceMsg; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.loogk.wx.model.WxConfig; /** * 消息相关API @@ -25,7 +34,7 @@ public class MessageAPI extends BaseAPI { private static final Logger LOG = LoggerFactory.getLogger(MessageAPI.class); - public MessageAPI(ApiConfig config) { + public MessageAPI(WxConfig config) { super(config); } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/OauthAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/OauthAPI.java index ee9f657..8334b45 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/OauthAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/OauthAPI.java @@ -1,6 +1,11 @@ package com.github.sd4324530.fastweixin.api; -import com.github.sd4324530.fastweixin.api.config.ApiConfig; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.github.sd4324530.fastweixin.api.enums.OauthScope; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.api.response.GetUserInfoResponse; @@ -8,11 +13,7 @@ import com.github.sd4324530.fastweixin.api.response.OauthGetTokenResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; import com.github.sd4324530.fastweixin.util.StrUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; +import com.loogk.wx.model.WxConfig; /** * 网页授权API @@ -23,7 +24,7 @@ public class OauthAPI extends BaseAPI { private static final Logger LOG = LoggerFactory.getLogger(OauthAPI.class); - public OauthAPI(ApiConfig config) { + public OauthAPI(WxConfig config) { super(config); } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/QrcodeAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/QrcodeAPI.java index 79aeb51..9bf2bf7 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/QrcodeAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/QrcodeAPI.java @@ -1,17 +1,18 @@ package com.github.sd4324530.fastweixin.api; -import com.github.sd4324530.fastweixin.api.config.ApiConfig; +import java.util.HashMap; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.github.sd4324530.fastweixin.api.enums.QrcodeType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.api.response.QrcodeResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; import com.github.sd4324530.fastweixin.util.StrUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.Map; +import com.loogk.wx.model.WxConfig; /** * 二维码相关API @@ -23,7 +24,7 @@ public class QrcodeAPI extends BaseAPI { private static final Logger LOG = LoggerFactory.getLogger(QrcodeAPI.class); - public QrcodeAPI(ApiConfig config) { + public QrcodeAPI(WxConfig config) { super(config); } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/SystemAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/SystemAPI.java index cc6cb6d..c6d77cc 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/SystemAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/SystemAPI.java @@ -1,18 +1,19 @@ package com.github.sd4324530.fastweixin.api; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; -import com.github.sd4324530.fastweixin.api.config.ApiConfig; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.util.CollectionUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; import com.github.sd4324530.fastweixin.util.StrUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.loogk.wx.model.WxConfig; /** * 系统API @@ -23,7 +24,7 @@ public class SystemAPI extends BaseAPI { private static final Logger LOG = LoggerFactory.getLogger(SystemAPI.class); - public SystemAPI(ApiConfig config) { + public SystemAPI(WxConfig config) { super(config); } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/TagAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/TagAPI.java index 899c82b..7b51626 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/TagAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/TagAPI.java @@ -1,6 +1,11 @@ package com.github.sd4324530.fastweixin.api; -import com.github.sd4324530.fastweixin.api.config.ApiConfig; +import java.util.HashMap; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.api.response.CreateTagResponse; @@ -8,11 +13,7 @@ import com.github.sd4324530.fastweixin.api.response.GetAllTagsResponse; import com.github.sd4324530.fastweixin.api.response.GetUsersResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.Map; +import com.loogk.wx.model.WxConfig; /** * 标签相关API @@ -28,7 +29,7 @@ public class TagAPI extends BaseAPI { * * @param config 微信API配置对象 */ - public TagAPI(ApiConfig config) { + public TagAPI(WxConfig config) { super(config); } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java index f84d0ea..101e64b 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java @@ -1,6 +1,11 @@ package com.github.sd4324530.fastweixin.api; -import com.github.sd4324530.fastweixin.api.config.ApiConfig; +import java.util.HashMap; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.github.sd4324530.fastweixin.api.entity.Industry; import com.github.sd4324530.fastweixin.api.entity.TemplateMsg; import com.github.sd4324530.fastweixin.api.enums.ResultType; @@ -9,11 +14,7 @@ import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.api.response.SendTemplateResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.Map; +import com.loogk.wx.model.WxConfig; /** * 模版消息 api @@ -21,7 +22,7 @@ import java.util.Map; public class TemplateMsgAPI extends BaseAPI { private static final Logger LOG = LoggerFactory.getLogger(CustomAPI.class); - public TemplateMsgAPI(ApiConfig config) { + public TemplateMsgAPI(WxConfig config) { super(config); } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/UserAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/UserAPI.java index 0e90ec4..9325871 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/UserAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/UserAPI.java @@ -1,20 +1,26 @@ package com.github.sd4324530.fastweixin.api; -import com.github.sd4324530.fastweixin.api.config.ApiConfig; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.github.sd4324530.fastweixin.api.entity.UserInfo; import com.github.sd4324530.fastweixin.api.enums.ResultType; -import com.github.sd4324530.fastweixin.api.response.*; +import com.github.sd4324530.fastweixin.api.response.BaseResponse; +import com.github.sd4324530.fastweixin.api.response.CreateGroupResponse; +import com.github.sd4324530.fastweixin.api.response.GetGroupsResponse; +import com.github.sd4324530.fastweixin.api.response.GetUserInfoListResponse; +import com.github.sd4324530.fastweixin.api.response.GetUserInfoResponse; +import com.github.sd4324530.fastweixin.api.response.GetUsersResponse; import com.github.sd4324530.fastweixin.exception.WeixinException; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.CollectionUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; import com.github.sd4324530.fastweixin.util.StrUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.loogk.wx.model.WxConfig; /** * 用户管理相关API @@ -26,7 +32,7 @@ public class UserAPI extends BaseAPI { private static final Logger LOG = LoggerFactory.getLogger(UserAPI.class); - public UserAPI(ApiConfig config) { + public UserAPI(WxConfig config) { super(config); } -- Gitee From 791ba4312c159ca04d9226c07e14cf756e3bd2c4 Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Mon, 27 Jun 2016 16:24:43 +0800 Subject: [PATCH 02/26] no commit message --- .../com/github/sd4324530/fastweixin/api/TagAPI.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/TagAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/TagAPI.java index 7b51626..53217e9 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/TagAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/TagAPI.java @@ -79,8 +79,10 @@ public class TagAPI extends BaseAPI { LOG.debug("编辑标签....."); String url = BASE_API_URL + "cgi-bin/tags/update?access_token=#"; Map param = new HashMap(); - param.put("id", tagId); - param.put("name", newTagName); + Map tag = new HashMap(); + tag.put("id", tagId); + tag.put("name", newTagName); + param.put("tag", tag); BaseResponse response = executePost(url, JSONUtil.toJson(param)); return ResultType.get(response.getErrcode()); } @@ -95,7 +97,9 @@ public class TagAPI extends BaseAPI { LOG.debug("删除标签....."); String url = BASE_API_URL + "cgi-bin/tags/delete?access_token=#"; Map param = new HashMap(); - param.put("id", tagId); + Map tag = new HashMap(); + tag.put("id", tagId); + param.put("tag", tag); BaseResponse response = executePost(url, JSONUtil.toJson(param)); return ResultType.get(response.getErrcode()); } -- Gitee From 3647ef511c6343988f9d5e142220bc64211cfdab Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Mon, 4 Jul 2016 10:56:58 +0800 Subject: [PATCH 03/26] no commit message --- .../sd4324530/fastweixin/api/BaseAPI.java | 2 +- .../sd4324530/fastweixin/api/CustomAPI.java | 2 +- .../sd4324530/fastweixin/api/DataCubeAPI.java | 2 +- .../sd4324530/fastweixin/api/JsAPI.java | 2 +- .../sd4324530/fastweixin/api/MaterialAPI.java | 2 +- .../sd4324530/fastweixin/api/MediaAPI.java | 2 +- .../sd4324530/fastweixin/api/MenuAPI.java | 2 +- .../sd4324530/fastweixin/api/MessageAPI.java | 2 +- .../sd4324530/fastweixin/api/OauthAPI.java | 2 +- .../sd4324530/fastweixin/api/QrcodeAPI.java | 2 +- .../sd4324530/fastweixin/api/SystemAPI.java | 2 +- .../sd4324530/fastweixin/api/TagAPI.java | 2 +- .../fastweixin/api/TemplateMsgAPI.java | 2 +- .../sd4324530/fastweixin/api/UserAPI.java | 2 +- .../fastweixin/api/config/WxConfig.java | 49 +++++++++++++++++++ .../sd4324530/fastweixin/FastweixinTest.java | 34 +++++++------ 16 files changed, 81 insertions(+), 30 deletions(-) create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/config/WxConfig.java diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/BaseAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/BaseAPI.java index 767dff3..eb4c0b1 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/BaseAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/BaseAPI.java @@ -3,12 +3,12 @@ package com.github.sd4324530.fastweixin.api; import java.io.File; import java.util.List; +import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.CollectionUtil; import com.github.sd4324530.fastweixin.util.NetWorkCenter; -import com.loogk.wx.model.WxConfig; /** * API基类,提供一些通用方法 diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java index dfae2bc..e665209 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java @@ -9,6 +9,7 @@ import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.entity.CustomAccount; import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; @@ -25,7 +26,6 @@ import com.github.sd4324530.fastweixin.message.VoiceMsg; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; import com.github.sd4324530.fastweixin.util.StrUtil; -import com.loogk.wx.model.WxConfig; /** * 客服相关API diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/DataCubeAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/DataCubeAPI.java index bd566cb..371a7c7 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/DataCubeAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/DataCubeAPI.java @@ -9,6 +9,7 @@ import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.api.response.GetArticleSummaryResponse; import com.github.sd4324530.fastweixin.api.response.GetArticleTotalResponse; @@ -29,7 +30,6 @@ import com.github.sd4324530.fastweixin.api.response.GetUserShareResponse; import com.github.sd4324530.fastweixin.api.response.GetUserSummaryResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; -import com.loogk.wx.model.WxConfig; /** * 数据分析API diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/JsAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/JsAPI.java index 500a2b6..4ffc94c 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/JsAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/JsAPI.java @@ -5,11 +5,11 @@ import java.util.UUID; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.GetSignatureResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JsApiUtil; -import com.loogk.wx.model.WxConfig; /** * 微信js-sdk相关API diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/MaterialAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/MaterialAPI.java index b121603..e7d3dfe 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/MaterialAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/MaterialAPI.java @@ -23,6 +23,7 @@ import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.entity.Article; import com.github.sd4324530.fastweixin.api.enums.MaterialType; import com.github.sd4324530.fastweixin.api.enums.ResultType; @@ -34,7 +35,6 @@ import com.github.sd4324530.fastweixin.api.response.UploadMaterialResponse; import com.github.sd4324530.fastweixin.util.JSONUtil; import com.github.sd4324530.fastweixin.util.NetWorkCenter; import com.github.sd4324530.fastweixin.util.StrUtil; -import com.loogk.wx.model.WxConfig; /** * diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/MediaAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/MediaAPI.java index 5b1d69f..639d41b 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/MediaAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/MediaAPI.java @@ -18,6 +18,7 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.entity.Article; import com.github.sd4324530.fastweixin.api.enums.MediaType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; @@ -27,7 +28,6 @@ import com.github.sd4324530.fastweixin.api.response.UploadMediaResponse; import com.github.sd4324530.fastweixin.util.JSONUtil; import com.github.sd4324530.fastweixin.util.NetWorkCenter; import com.github.sd4324530.fastweixin.util.StreamUtil; -import com.loogk.wx.model.WxConfig; /** * 多媒体资源API diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/MenuAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/MenuAPI.java index eac9994..ea43911 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/MenuAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/MenuAPI.java @@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONPath; +import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.entity.Menu; import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; @@ -16,7 +17,6 @@ import com.github.sd4324530.fastweixin.api.response.GetMenuResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.CollectionUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; -import com.loogk.wx.model.WxConfig; /** * 菜单相关API diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/MessageAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/MessageAPI.java index 739b44c..916e72c 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/MessageAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/MessageAPI.java @@ -8,6 +8,7 @@ import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.api.response.GetSendMessageResponse; @@ -22,7 +23,6 @@ import com.github.sd4324530.fastweixin.message.VideoMsg; import com.github.sd4324530.fastweixin.message.VoiceMsg; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; -import com.loogk.wx.model.WxConfig; /** * 消息相关API diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/OauthAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/OauthAPI.java index 8334b45..0065a76 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/OauthAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/OauthAPI.java @@ -6,6 +6,7 @@ import java.net.URLEncoder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.enums.OauthScope; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.api.response.GetUserInfoResponse; @@ -13,7 +14,6 @@ import com.github.sd4324530.fastweixin.api.response.OauthGetTokenResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; import com.github.sd4324530.fastweixin.util.StrUtil; -import com.loogk.wx.model.WxConfig; /** * 网页授权API diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/QrcodeAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/QrcodeAPI.java index 9bf2bf7..b9ae1f0 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/QrcodeAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/QrcodeAPI.java @@ -6,13 +6,13 @@ import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.enums.QrcodeType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.api.response.QrcodeResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; import com.github.sd4324530.fastweixin.util.StrUtil; -import com.loogk.wx.model.WxConfig; /** * 二维码相关API diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/SystemAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/SystemAPI.java index c6d77cc..c8a1935 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/SystemAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/SystemAPI.java @@ -9,11 +9,11 @@ import org.slf4j.LoggerFactory; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; +import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.util.CollectionUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; import com.github.sd4324530.fastweixin.util.StrUtil; -import com.loogk.wx.model.WxConfig; /** * 系统API diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/TagAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/TagAPI.java index 53217e9..56d33a4 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/TagAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/TagAPI.java @@ -6,6 +6,7 @@ import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.api.response.CreateTagResponse; @@ -13,7 +14,6 @@ import com.github.sd4324530.fastweixin.api.response.GetAllTagsResponse; import com.github.sd4324530.fastweixin.api.response.GetUsersResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; -import com.loogk.wx.model.WxConfig; /** * 标签相关API diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java index 101e64b..caa1db0 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java @@ -6,6 +6,7 @@ import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.entity.Industry; import com.github.sd4324530.fastweixin.api.entity.TemplateMsg; import com.github.sd4324530.fastweixin.api.enums.ResultType; @@ -14,7 +15,6 @@ import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.api.response.SendTemplateResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; -import com.loogk.wx.model.WxConfig; /** * 模版消息 api diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/UserAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/UserAPI.java index 9325871..1f1cca4 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/UserAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/UserAPI.java @@ -7,6 +7,7 @@ import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.entity.UserInfo; import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; @@ -20,7 +21,6 @@ import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.CollectionUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; import com.github.sd4324530.fastweixin.util.StrUtil; -import com.loogk.wx.model.WxConfig; /** * 用户管理相关API diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/config/WxConfig.java b/src/main/java/com/github/sd4324530/fastweixin/api/config/WxConfig.java new file mode 100644 index 0000000..d059f11 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/config/WxConfig.java @@ -0,0 +1,49 @@ +package com.github.sd4324530.fastweixin.api.config; + +public class WxConfig { + private String appid; + private String secret; + private String accessToken ; + private Long accessTokenTime ; + private String jsApiTicket ; + private Long jsApiTicketTime ; + + public String getAppid() { + return appid; + } + public void setAppid(String appid) { + this.appid = appid; + } + public String getSecret() { + return secret; + } + public void setSecret(String secret) { + this.secret = secret; + } + public String getAccessToken() { + return accessToken; + } + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + public Long getAccessTokenTime() { + return accessTokenTime; + } + public void setAccessTokenTime(Long accessTokenTime) { + this.accessTokenTime = accessTokenTime; + } + public String getJsApiTicket() { + return jsApiTicket; + } + public void setJsApiTicket(String jsApiTicket) { + this.jsApiTicket = jsApiTicket; + } + public Long getJsApiTicketTime() { + return jsApiTicketTime; + } + public void setJsApiTicketTime(Long jsApiTicketTime) { + this.jsApiTicketTime = jsApiTicketTime; + } + + +} diff --git a/src/test/java/com/github/sd4324530/fastweixin/FastweixinTest.java b/src/test/java/com/github/sd4324530/fastweixin/FastweixinTest.java index b854014..5d92b83 100644 --- a/src/test/java/com/github/sd4324530/fastweixin/FastweixinTest.java +++ b/src/test/java/com/github/sd4324530/fastweixin/FastweixinTest.java @@ -1,4 +1,4 @@ -package com.github.sd4324530.fastweixin; +/*package com.github.sd4324530.fastweixin; import com.github.sd4324530.fastweixin.api.*; import com.github.sd4324530.fastweixin.api.config.ApiConfig; @@ -10,15 +10,16 @@ import com.github.sd4324530.fastweixin.util.StrUtil; import org.apache.http.client.utils.DateUtils; import org.junit.Assert; import org.junit.Before; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*; import java.util.*; -/** +*//** * @author peiyu - */ + *//* public class FastweixinTest { private static final Logger LOG = LoggerFactory.getLogger(FastweixinTest.class); @@ -29,21 +30,21 @@ public class FastweixinTest { public void init() { // String appid = "wx8c33ff895df5d0d9"; // String secret = "0705aafac0bef944de4c485d71fce900"; - String appid = "wx337021cfcc3e32fb"; - String secret = "e244f1244f0ba2798546e0450d3045ea"; + String appid = "wx46840df74971f3be"; + String secret = "cb026f93a817d3d5dd5d0f93ebb74a5c"; config = new ApiConfig(appid, secret); TestConfigChangeHandle configChangeHandle = new TestConfigChangeHandle(); config.addHandle(configChangeHandle); } - /* + *AppID(应用ID)wx8c33ff895df5d0d9 *AppSecret(应用密钥)0705aafac0bef944de4c485d71fce900 - */ -// @Test + + @Test public void test() { - String appid = "wx8c33ff895df5d0d9"; - String secret = "0705aafac0bef944de4c485d71fce900"; + String appid = "wx46840df74971f3be"; + String secret = "cb026f93a817d3d5dd5d0f93ebb74a5c"; ApiConfig config = new ApiConfig(appid, secret); TestConfigChangeHandle configChangeHandle = new TestConfigChangeHandle(); config.addHandle(configChangeHandle); @@ -71,11 +72,11 @@ public class FastweixinTest { } - /** + *//** * 创建菜单 * * @param config API配置 - */ + *//* private void createMenu(ApiConfig config) { MenuAPI menuAPI = new MenuAPI(config); @@ -115,11 +116,11 @@ public class FastweixinTest { LOG.debug(resultType.toString()); } - /** + *//** * 获取关注者列表 * * @param config API配置 - */ + *//* public void getUserList(ApiConfig config) { UserAPI userAPI = new UserAPI(config); GetUsersResponse users = userAPI.getUsers(null); @@ -131,11 +132,11 @@ public class FastweixinTest { } } - /** + *//** * 获取用户信息 * * @param config API配置 - */ + *//* public void getUserInfo(ApiConfig config) { UserAPI userAPI = new UserAPI(config); GetUserInfoResponse userInfo = userAPI.getUserInfo("opZYwt-OS8WFxwU-colRzpu50eOQ"); @@ -385,3 +386,4 @@ public class FastweixinTest { menuAPI.deleteMenu(); } } +*/ \ No newline at end of file -- Gitee From 036ec905c0ddb88832f8fba74feebfd103094846 Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Mon, 4 Jul 2016 17:50:44 +0800 Subject: [PATCH 04/26] no commit message --- .../sd4324530/fastweixin/api/config/WxConfig.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/config/WxConfig.java b/src/main/java/com/github/sd4324530/fastweixin/api/config/WxConfig.java index d059f11..f202e0b 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/config/WxConfig.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/config/WxConfig.java @@ -1,7 +1,13 @@ package com.github.sd4324530.fastweixin.api.config; -public class WxConfig { - private String appid; +import java.io.Serializable; + +public class WxConfig implements Serializable{ + /** + * + */ + private static final long serialVersionUID = 1L; + private String appid; private String secret; private String accessToken ; private Long accessTokenTime ; -- Gitee From cc078d03408a645763fc68dd31c90bfe5423ed63 Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Thu, 14 Jul 2016 06:44:40 -0400 Subject: [PATCH 05/26] no commit message --- .../sd4324530/fastweixin/api/PoiAPI.java | 40 +++ .../fastweixin/api/entity/PoiModel.java | 257 ++++++++++++++++++ .../fastweixin/api/entity/PoiPhoto.java | 18 ++ .../fastweixin/message/req/EventType.java | 1 + 4 files changed, 316 insertions(+) create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/PoiAPI.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiModel.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiPhoto.java diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/PoiAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/PoiAPI.java new file mode 100644 index 0000000..67bbd55 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/PoiAPI.java @@ -0,0 +1,40 @@ +package com.github.sd4324530.fastweixin.api; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.github.sd4324530.fastweixin.api.config.WxConfig; +import com.github.sd4324530.fastweixin.api.entity.PoiModel; +import com.github.sd4324530.fastweixin.api.enums.ResultType; +import com.github.sd4324530.fastweixin.api.response.BaseResponse; +import com.github.sd4324530.fastweixin.util.BeanUtil; + +/** + * 门店相关API + * + * @author eric + * @since 1.2 + */ +public class PoiAPI extends BaseAPI { + + private static final Logger LOG = LoggerFactory.getLogger(PoiAPI.class); + + public PoiAPI(WxConfig config) { + super(config); + } + + /** + * 创建门店 + * + * @param PoiModel 门店对象 + * @return 调用结果 + */ + public ResultType createPoi(PoiModel poi) { + BeanUtil.requireNonNull(poi, "poi is null"); + String url = BASE_API_URL+"cgi-bin/poi/addpoi?access_token=#"; + BaseResponse response = executePost(url, "{\"business\":{\"base_info\":"+poi.toJsonString()+"}}"); + return ResultType.get(response.getErrcode()); + } + + +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiModel.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiModel.java new file mode 100644 index 0000000..b4ab705 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiModel.java @@ -0,0 +1,257 @@ +package com.github.sd4324530.fastweixin.api.entity; + +import java.util.List; + +import com.alibaba.fastjson.annotation.JSONField; + +/** + * 菜单对象,包含所有菜单按钮 + * + * @author peiyu + */ +public class PoiModel extends BaseModel { + + /** + * 商户自己的id,用于后续审核通过收到poi_id 的通知时,做对应关系。请商户自己保证唯一识别性 + */ + private String sid; + + /** + * 门店名称(仅为商户名,如:国美、麦当劳,不应包含地区、地址、分店名等信息,错误示例:北京国美) + 不能为空,15个汉字或30个英文字符内 + */ + @JSONField(name = "business_name") + private String businessName; + + /** + * 分店名称(不应包含地区信息,不应与门店名有重复,错误示例:北京王府井店) + 不超过10个字 + */ + @JSONField(name = "branch_name") + private String branchName; + + /** + * 门店所在的省份(直辖市填城市名,如:北京市) + */ + private String province; + + /** + * 门店所在的城市 + */ + private String city; + + /** + * 门店所在地区(东莞等没有“区”行政区划的城市,该字段可不必填写。其余城市必填。) + */ + private String district; + + /** + * 门店所在的详细街道地址(不要填写省市信息) + */ + private String address; + + /** + * 门店的电话(纯数字,区号、分机号均由“-”隔开) + */ + private String telephone; + + /** + * 门店的类型(不同级分类用“,”隔开,如:美食,川菜,火锅。详细分类参见附件:微信门店类目表) + */ + private String[] categories; + + /** + * 坐标类型,1 为火星坐标(目前只能选1) + */ + @JSONField(name = "offset_type") + private int offsetType; + + /** + * 门店所在地理位置的经度 + */ + private double longitude; + + /** + * 门店所在地理位置的纬度(经纬度均为火星坐标,最好选用腾讯地图标记的坐标) + */ + private double latitude; + +//---------------------------------以下为创建门店是非必填参数------------------------------------------- + + /** + * 图片列表,url 形式,可以有多张图片,尺寸为640*340px。必须为上一接口生成的url。图片内容不允许与门店不相关,不允许为二维码、员工合照(或模特肖像)、营业执照、无门店正门的街景、地图截图、公交地铁站牌、菜单截图等 + */ + @JSONField(name = "photo_list") + private List photoList; + + /** + * 推荐品,餐厅可为推荐菜;酒店为推荐套房;景点为推荐游玩景点等,针对自己行业的推荐内容 + */ + private String recommend; + + /** + * 特色服务,如免费wifi,免费停车,送货上门等商户能提供的特色功能或服务 + */ + private String special; + + /** + * 商户简介,主要介绍商户信息等 + */ + private String introduction; + + /** + * 营业时间,24 小时制表示,用“-”连接,如 8:00-20:00 + */ + @JSONField(name = "open_time") + private String openTime; + + /** + * 人均价格,大于0 的整数 + */ + @JSONField(name = "avg_price") + private int avgPrice; + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getBusinessName() { + return businessName; + } + + public void setBusinessName(String businessName) { + this.businessName = businessName; + } + + public String getBranchName() { + return branchName; + } + + public void setBranchName(String branchName) { + this.branchName = branchName; + } + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getTelephone() { + return telephone; + } + + public void setTelephone(String telephone) { + this.telephone = telephone; + } + + public String[] getCategories() { + return categories; + } + + public void setCategories(String[] categories) { + this.categories = categories; + } + + public int getOffsetType() { + return offsetType; + } + + public void setOffsetType(int offsetType) { + this.offsetType = offsetType; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public List getPhotoList() { + return photoList; + } + + public void setPhotoList(List photoList) { + this.photoList = photoList; + } + + public String getRecommend() { + return recommend; + } + + public void setRecommend(String recommend) { + this.recommend = recommend; + } + + public String getSpecial() { + return special; + } + + public void setSpecial(String special) { + this.special = special; + } + + public String getIntroduction() { + return introduction; + } + + public void setIntroduction(String introduction) { + this.introduction = introduction; + } + + public String getOpenTime() { + return openTime; + } + + public void setOpenTime(String openTime) { + this.openTime = openTime; + } + + public int getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(int avgPrice) { + this.avgPrice = avgPrice; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiPhoto.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiPhoto.java new file mode 100644 index 0000000..6802c16 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiPhoto.java @@ -0,0 +1,18 @@ +package com.github.sd4324530.fastweixin.api.entity; + +import com.alibaba.fastjson.annotation.JSONField; + +public class PoiPhoto extends BaseModel{ + + @JSONField(name = "photo_url") + private String photoUrl; + + public String getPhotoUrl() { + return photoUrl; + } + + public void setPhotoUrl(String photoUrl) { + this.photoUrl = photoUrl; + } + +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/message/req/EventType.java b/src/main/java/com/github/sd4324530/fastweixin/message/req/EventType.java index 2582d31..2041bae 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/message/req/EventType.java +++ b/src/main/java/com/github/sd4324530/fastweixin/message/req/EventType.java @@ -16,6 +16,7 @@ public final class EventType { public static final String LOCATIONSELECT = "location_select"; public static final String TEMPLATESENDJOBFINISH = "TEMPLATESENDJOBFINISH"; public static final String MASSSENDJOBFINISH="MASSSENDJOBFINISH"; + public static final String POICHECKNOTIFY = "poi_check_notify"; private EventType() { } -- Gitee From 4f998340744edf3f87256a5a0aae067ac7a87564 Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Fri, 15 Jul 2016 06:06:16 -0400 Subject: [PATCH 06/26] no commit message --- .../sd4324530/fastweixin/api/PoiAPI.java | 15 ++ .../api/entity/PoiForUpdateModel.java | 134 ++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiForUpdateModel.java diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/PoiAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/PoiAPI.java index 67bbd55..191f2b6 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/PoiAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/PoiAPI.java @@ -4,10 +4,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.github.sd4324530.fastweixin.api.config.WxConfig; +import com.github.sd4324530.fastweixin.api.entity.PoiForUpdateModel; import com.github.sd4324530.fastweixin.api.entity.PoiModel; import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; +import com.github.sd4324530.fastweixin.util.JSONUtil; /** * 门店相关API @@ -36,5 +38,18 @@ public class PoiAPI extends BaseAPI { return ResultType.get(response.getErrcode()); } + public ResultType updatePoi(PoiForUpdateModel pum){ + BeanUtil.requireNonNull(pum, "pum is null"); + String url = BASE_API_URL+"cgi-bin/poi/updatepoi?access_token=#"; + BaseResponse response = executePost(url, "{\"business\":{\"base_info\":"+pum.toJsonString()+"}}"); + return ResultType.get(response.getErrcode()); + } + + public ResultType deletePoi(String poiId){ + BeanUtil.requireNonNull(poiId, "poiId is null"); + String url = BASE_API_URL+"cgi-bin/poi/delpoi?access_token=#"; + BaseResponse response = executePost(url,JSONUtil.getJSONFromString(poiId).toJSONString()); + return ResultType.get(response.getErrcode()); + } } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiForUpdateModel.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiForUpdateModel.java new file mode 100644 index 0000000..8aaea58 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiForUpdateModel.java @@ -0,0 +1,134 @@ +package com.github.sd4324530.fastweixin.api.entity; + +import java.util.List; + +import com.alibaba.fastjson.annotation.JSONField; + +/** + * 菜单对象,包含所有菜单按钮 + * + * @author peiyu + */ +public class PoiForUpdateModel extends BaseModel { + + @JSONField(name = "poi_id") + private String poiId; + + /** + * 商户自己的id,用于后续审核通过收到poi_id 的通知时,做对应关系。请商户自己保证唯一识别性 + */ + private String sid; + + /** + * 门店的电话(纯数字,区号、分机号均由“-”隔开) + */ + private String telephone; + +//---------------------------------以下为创建门店是非必填参数------------------------------------------- + + /** + * 图片列表,url 形式,可以有多张图片,尺寸为640*340px。必须为上一接口生成的url。图片内容不允许与门店不相关,不允许为二维码、员工合照(或模特肖像)、营业执照、无门店正门的街景、地图截图、公交地铁站牌、菜单截图等 + */ + @JSONField(name = "photo_list") + private List photoList; + + /** + * 推荐品,餐厅可为推荐菜;酒店为推荐套房;景点为推荐游玩景点等,针对自己行业的推荐内容 + */ + private String recommend; + + /** + * 特色服务,如免费wifi,免费停车,送货上门等商户能提供的特色功能或服务 + */ + private String special; + + /** + * 商户简介,主要介绍商户信息等 + */ + private String introduction; + + /** + * 营业时间,24 小时制表示,用“-”连接,如 8:00-20:00 + */ + @JSONField(name = "open_time") + private String openTime; + + /** + * 人均价格,大于0 的整数 + */ + @JSONField(name = "avg_price") + private int avgPrice; + + public String getSid() { + return sid; + } + + public void setSid(String sid) { + this.sid = sid; + } + + public String getTelephone() { + return telephone; + } + + public void setTelephone(String telephone) { + this.telephone = telephone; + } + + public List getPhotoList() { + return photoList; + } + + public void setPhotoList(List photoList) { + this.photoList = photoList; + } + + public String getRecommend() { + return recommend; + } + + public void setRecommend(String recommend) { + this.recommend = recommend; + } + + public String getSpecial() { + return special; + } + + public void setSpecial(String special) { + this.special = special; + } + + public String getIntroduction() { + return introduction; + } + + public void setIntroduction(String introduction) { + this.introduction = introduction; + } + + public String getOpenTime() { + return openTime; + } + + public void setOpenTime(String openTime) { + this.openTime = openTime; + } + + public int getAvgPrice() { + return avgPrice; + } + + public void setAvgPrice(int avgPrice) { + this.avgPrice = avgPrice; + } + + public String getPoiId() { + return poiId; + } + + public void setPoiId(String poiId) { + this.poiId = poiId; + } + +} -- Gitee From d3219ae06f69247270d5423cfa3dbaa9017e095e Mon Sep 17 00:00:00 2001 From: TylerCheung Date: Sun, 28 Aug 2016 22:32:20 -0400 Subject: [PATCH 07/26] =?UTF-8?q?=E5=8D=A1=E5=8A=B5=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E3=80=81=E9=A2=84=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sd4324530/fastweixin/api/CardAPI.java | 71 ++++++ .../fastweixin/api/MessagePreviewAPI.java | 92 ++++++++ .../fastweixin/api/entity/Abstracts.java | 22 ++ .../fastweixin/api/entity/AdvancedInfo.java | 46 ++++ .../fastweixin/api/entity/BaseCard.java | 24 ++ .../fastweixin/api/entity/BaseInfo.java | 218 ++++++++++++++++++ .../sd4324530/fastweixin/api/entity/Card.java | 22 ++ .../sd4324530/fastweixin/api/entity/Cash.java | 29 +++ .../fastweixin/api/entity/DateInfo.java | 28 +++ .../fastweixin/api/entity/Discount.java | 20 ++ .../fastweixin/api/entity/GeneralCoupon.java | 19 ++ .../sd4324530/fastweixin/api/entity/Gift.java | 19 ++ .../fastweixin/api/entity/Groupon.java | 19 ++ .../sd4324530/fastweixin/api/entity/Sku.java | 12 + .../fastweixin/api/entity/TextImageList.java | 20 ++ .../fastweixin/api/entity/TimeLimit.java | 44 ++++ .../fastweixin/api/entity/UseCondition.java | 28 +++ .../fastweixin/api/enums/PreviewType.java | 48 ++++ .../api/response/CreateCardResponse.java | 22 ++ .../fastweixin/message/WxCardMsg.java | 19 ++ 20 files changed, 822 insertions(+) create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/MessagePreviewAPI.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/Abstracts.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/AdvancedInfo.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/BaseCard.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/BaseInfo.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/Card.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/Cash.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/DateInfo.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/Discount.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/GeneralCoupon.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/Gift.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/Groupon.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/Sku.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/TextImageList.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/TimeLimit.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/UseCondition.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/enums/PreviewType.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/response/CreateCardResponse.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/message/WxCardMsg.java diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java new file mode 100644 index 0000000..31ffb5e --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java @@ -0,0 +1,71 @@ +/** + * + */ +package com.github.sd4324530.fastweixin.api; + +import java.util.HashMap; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.github.sd4324530.fastweixin.api.config.WxConfig; +import com.github.sd4324530.fastweixin.api.entity.Card; +import com.github.sd4324530.fastweixin.api.response.BaseResponse; +import com.github.sd4324530.fastweixin.api.response.CreateCardResponse; +import com.github.sd4324530.fastweixin.util.JSONUtil; + +/** + * @author TylerChueng + * @see 微信卡券接口 + * {@linkplain 创建卡劵} + * {@linkplain 投放卡劵} + * {@linkplain 核销卡劵} + * + * @version 1.0 + */ +public class CardAPI extends BaseAPI { + + public CardAPI(WxConfig config) { + super(config); + } + + private static final Logger log = LoggerFactory.getLogger(CustomAPI.class); + + /** + * 卡劵创建 + * @param card 创建卡劵参数 + * @return 创建卡劵结果 + */ + public CreateCardResponse createCard(Card card){ + CreateCardResponse response = null; + String url = BASE_API_URL + "card/create?access_token=#"; + final Map params = new HashMap(); + params.put("card", card); + log.info("创建卡劵request开始>>>>>"); + String str = JSONUtil.toJson(params); + if("CASH".equalsIgnoreCase(card.getCard_type())){ + str = str.replace("\"base\"", "\"cash\""); + }else if("GROUPON".equalsIgnoreCase(card.getCard_type())){ + str = str.replace("\"base\"", "\"groupon\""); + }else if("DISCOUNT".equalsIgnoreCase(card.getCard_type())){ + str = str.replace("\"base\"", "\"discount\""); + }else if("GIFT".equalsIgnoreCase(card.getCard_type())){ + str = str.replace("\"base\"", "\"gift\""); + }else if("GENERAL_COUPON".equalsIgnoreCase(card.getCard_type())){ + str = str.replace("\"base\"", "\"general_coupon\""); + } + BaseResponse r = executePost(url, str); + log.info("创建卡劵响应>>>>>"); + String resultJson = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString(); + log.info("创建卡劵响应结果解析>>>>>"); + response = JSONUtil.toBean(resultJson, CreateCardResponse.class); + return response; + } + + public static void main(String[] args) { + String str = "{\"card\":{ \"base\":{ \"base_info\":{ \"bind_openid\":false, \"brand_name\":\"50元代金劵\", \"can_give_friend\":false, \"can_share\":false, \"code_type\":\"CODE_TYPE_QRCODE\", \"color\":\"Color050\", \"date_info\":{ \"begin_timestamp\":1472054400, \"end_timestamp\":1475164800, \"type\":\"DATE_TYPE_FIX_TIME_RANGE\" }, \"description\":\"发个代金劵玩玩,任性!\", \"get_limit\":0, \"logo_url\":\"http://img03.store.sogou.com/net/a/04/link?appid=5&w=710&url=http://mmbiz.qpic.cn/mmbiz/2plBIaySaLh2hMibpwtCoWhughlKswUXqkLSPP7RytL0GyF2gNLGVdibAsBicF32NicwoTic09gQvMrELRdV8FApzVQ/0?wx_fmt=png\", \"notice\":\"好的\", \"service_phone\":\"07558601111\", \"sku\":{ \"quantity\":1000 }, \"source\":\"Loogk\", \"title\":\"代金劵\", \"use_custom_code\":false }, \"least_cost\":1000, \"reduce_cost\":10000 }, \"card_type\":\"CASH\" } }"; + str=str.replace("\"base\"", "\"cash\""); + + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/MessagePreviewAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/MessagePreviewAPI.java new file mode 100644 index 0000000..5601c79 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/MessagePreviewAPI.java @@ -0,0 +1,92 @@ +package com.github.sd4324530.fastweixin.api; + +import java.util.HashMap; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.github.sd4324530.fastweixin.api.config.WxConfig; +import com.github.sd4324530.fastweixin.api.enums.ResultType; +import com.github.sd4324530.fastweixin.api.response.BaseResponse; +import com.github.sd4324530.fastweixin.message.BaseMsg; +import com.github.sd4324530.fastweixin.message.ImageMsg; +import com.github.sd4324530.fastweixin.message.TextMsg; +import com.github.sd4324530.fastweixin.message.VideoMsg; +import com.github.sd4324530.fastweixin.message.VoiceMsg; +import com.github.sd4324530.fastweixin.message.WxCardMsg; +import com.github.sd4324530.fastweixin.util.BeanUtil; +import com.github.sd4324530.fastweixin.util.JSONUtil; + +/** + * 预览接口API + * 通过该接口发送消息给指定用户,在手机端查看消息的样式和排版。 + * 为了满足第三方平台开发者的需求,在保留对openID预览能力的同时,增加了对指定微信号发送预览的能力 + * 但该能力每日调用次数有限制(100次),请勿滥用 + * @author TylerCheung + * @since 1.1 + */ +public class MessagePreviewAPI extends BaseAPI { + + private static final Logger LOG = LoggerFactory.getLogger(MessagePreviewAPI.class); + + public MessagePreviewAPI(WxConfig config) { + super(config); + } + + /** + * 预览接口发送预览信息给用户 + * + * @param openid 关注者ID + * @param message 消息对象,支持各种消息类型 + * @return 调用结果 + * @deprecated + */ + @Deprecated + public ResultType sendPreview(String openid, BaseMsg message,String msgtype) { + BeanUtil.requireNonNull(openid, "openid is null"); + BeanUtil.requireNonNull(msgtype, "msgtype is null"); + LOG.debug("发布客服消息......"); + String url = BASE_API_URL + "cgi-bin/message/mass/preview?access_token=#"; + final Map params = new HashMap(); + params.put("touser", openid); + if (message instanceof TextMsg) { + TextMsg msg = (TextMsg) message; + params.put("msgtype", "text"); + Map text = new HashMap(); + text.put("content", msg.getContent()); + params.put("text", text); + } else if (message instanceof ImageMsg) { + ImageMsg msg = (ImageMsg) message; + params.put("msgtype", "image"); + Map image = new HashMap(); + image.put("media_id", msg.getMediaId()); + params.put("image", image); + } else if (message instanceof VoiceMsg) { + VoiceMsg msg = (VoiceMsg) message; + params.put("msgtype", "voice"); + Map voice = new HashMap(); + voice.put("media_id", msg.getMediaId()); + params.put("voice", voice); + } else if (message instanceof VideoMsg) { + VideoMsg msg = (VideoMsg) message; + params.put("msgtype", "video"); + Map video = new HashMap(); + video.put("media_id", msg.getMediaId()); + video.put("thumb_media_id", msg.getMediaId()); + video.put("title", msg.getTitle()); + video.put("description", msg.getDescription()); + params.put("video", video); + } else if (message instanceof WxCardMsg) { + WxCardMsg msg = (WxCardMsg) message; + params.put("msgtype", "wxcard"); + Map wxcard = new HashMap(); + wxcard.put("card_id", msg.getCard_id()); + wxcard.put("card_ext", ""); + params.put("wxcard", wxcard); + } + BaseResponse response = executePost(url, JSONUtil.toJson(params)); + return ResultType.get(response.getErrcode()); + } + +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/Abstracts.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/Abstracts.java new file mode 100644 index 0000000..6e823ae --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/Abstracts.java @@ -0,0 +1,22 @@ +package com.github.sd4324530.fastweixin.api.entity; + +import java.util.List; + +public class Abstracts { + private String abstracts; + + private List icon_url_list; + + public void setAbstract(String abstracts){ + this.abstracts = abstracts; + } + public String getAbstract(){ + return this.abstracts; + } + public void setIcon_url_list(List icon_url_list){ + this.icon_url_list = icon_url_list; + } + public List getIcon_url_list(){ + return this.icon_url_list; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/AdvancedInfo.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/AdvancedInfo.java new file mode 100644 index 0000000..0693484 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/AdvancedInfo.java @@ -0,0 +1,46 @@ +package com.github.sd4324530.fastweixin.api.entity; + +import java.util.List; + +public class AdvancedInfo { + private UseCondition use_condition; + + private Abstracts abstracts; + + private List text_image_list; + + private List time_limit; + + private List business_service; + + public void setUse_condition(UseCondition use_condition){ + this.use_condition = use_condition; + } + public UseCondition getUse_condition(){ + return this.use_condition; + } + public void setAbstract(Abstracts abstracts){ + this.abstracts = abstracts; + } + public Abstracts getAbstract(){ + return this.abstracts; + } + public void setText_image_list(List text_image_list){ + this.text_image_list = text_image_list; + } + public List getText_image_list(){ + return this.text_image_list; + } + public void setTime_limit(List time_limit){ + this.time_limit = time_limit; + } + public List getTime_limit(){ + return this.time_limit; + } + public void setBusiness_service(List business_service){ + this.business_service = business_service; + } + public List getBusiness_service(){ + return this.business_service; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/BaseCard.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/BaseCard.java new file mode 100644 index 0000000..da9c261 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/BaseCard.java @@ -0,0 +1,24 @@ +package com.github.sd4324530.fastweixin.api.entity; + +import java.io.Serializable; + +public class BaseCard implements Serializable{ + private static final long serialVersionUID = 1L; + + private BaseInfo base_info; + + private AdvancedInfo advancedInfo; + + public void setBase_info(BaseInfo base_info){ + this.base_info = base_info; + } + public BaseInfo getBase_info(){ + return this.base_info; + } + public void setAdvanced_info(AdvancedInfo advancedInfo){ + this.advancedInfo = advancedInfo; + } + public AdvancedInfo getAdvanced_info(){ + return this.advancedInfo; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/BaseInfo.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/BaseInfo.java new file mode 100644 index 0000000..2327d53 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/BaseInfo.java @@ -0,0 +1,218 @@ +package com.github.sd4324530.fastweixin.api.entity; + +import java.util.List; + +public class BaseInfo { + private String logo_url; + + private String brand_name; + + private String code_type; + + private String title; + + private String color; + + private String notice; + + private String service_phone; + + private String description; + + private DateInfo date_info; + + private Sku sku; + + private int get_limit; + + private boolean use_custom_code; + + private boolean bind_openid; + + private boolean can_share; + + private boolean can_give_friend; + + private List location_id_list; + + private String center_title; + + private String center_sub_title; + + private String center_url; + + private String custom_url_name; + + private String custom_url; + + private String custom_url_sub_title; + + private String promotion_url_name; + + private String promotion_url; + + private String source; + + public void setLogo_url(String logo_url){ + this.logo_url = logo_url; + } + public String getLogo_url(){ + return this.logo_url; + } + public void setBrand_name(String brand_name){ + this.brand_name = brand_name; + } + public String getBrand_name(){ + return this.brand_name; + } + public void setCode_type(String code_type){ + this.code_type = code_type; + } + public String getCode_type(){ + return this.code_type; + } + public void setTitle(String title){ + this.title = title; + } + public String getTitle(){ + return this.title; + } + public void setColor(String color){ + this.color = color; + } + public String getColor(){ + return this.color; + } + public void setNotice(String notice){ + this.notice = notice; + } + public String getNotice(){ + return this.notice; + } + public void setService_phone(String service_phone){ + this.service_phone = service_phone; + } + public String getService_phone(){ + return this.service_phone; + } + public void setDescription(String description){ + this.description = description; + } + public String getDescription(){ + return this.description; + } + public void setDate_info(DateInfo date_info){ + this.date_info = date_info; + } + public DateInfo getDate_info(){ + return this.date_info; + } + public void setSku(Sku sku){ + this.sku = sku; + } + public Sku getSku(){ + return this.sku; + } + public void setGet_limit(int get_limit){ + this.get_limit = get_limit; + } + public int getGet_limit(){ + return this.get_limit; + } + public void setUse_custom_code(boolean use_custom_code){ + this.use_custom_code = use_custom_code; + } + public boolean getUse_custom_code(){ + if(!use_custom_code){ + use_custom_code = false; + } + return this.use_custom_code; + } + public void setBind_openid(boolean bind_openid){ + this.bind_openid = bind_openid; + } + public boolean getBind_openid(){ + if(!bind_openid){ + bind_openid = false; + } + return this.bind_openid; + } + public void setCan_share(boolean can_share){ + this.can_share = can_share; + } + public boolean getCan_share(){ + if(!can_share){ + can_share = false; + } + return this.can_share; + } + public void setCan_give_friend(boolean can_give_friend){ + this.can_give_friend = can_give_friend; + } + public boolean getCan_give_friend(){ + if(!can_give_friend){ + can_give_friend = false; + } + return this.can_give_friend; + } + public void setLocation_id_list(List location_id_list){ + this.location_id_list = location_id_list; + } + public List getLocation_id_list(){ + return this.location_id_list; + } + public void setCenter_title(String center_title){ + this.center_title = center_title; + } + public String getCenter_title(){ + return this.center_title; + } + public void setCenter_sub_title(String center_sub_title){ + this.center_sub_title = center_sub_title; + } + public String getCenter_sub_title(){ + return this.center_sub_title; + } + public void setCenter_url(String center_url){ + this.center_url = center_url; + } + public String getCenter_url(){ + return this.center_url; + } + public void setCustom_url_name(String custom_url_name){ + this.custom_url_name = custom_url_name; + } + public String getCustom_url_name(){ + return this.custom_url_name; + } + public void setCustom_url(String custom_url){ + this.custom_url = custom_url; + } + public String getCustom_url(){ + return this.custom_url; + } + public void setCustom_url_sub_title(String custom_url_sub_title){ + this.custom_url_sub_title = custom_url_sub_title; + } + public String getCustom_url_sub_title(){ + return this.custom_url_sub_title; + } + public void setPromotion_url_name(String promotion_url_name){ + this.promotion_url_name = promotion_url_name; + } + public String getPromotion_url_name(){ + return this.promotion_url_name; + } + public void setPromotion_url(String promotion_url){ + this.promotion_url = promotion_url; + } + public String getPromotion_url(){ + return this.promotion_url; + } + public void setSource(String source){ + this.source = source; + } + public String getSource(){ + return this.source; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/Card.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/Card.java new file mode 100644 index 0000000..464dc55 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/Card.java @@ -0,0 +1,22 @@ +package com.github.sd4324530.fastweixin.api.entity; + +public class Card extends BaseModel{ + private static final long serialVersionUID = 1L; + + private String card_type; + + private BaseCard base; + + public void setCard_type(String card_type){ + this.card_type = card_type; + } + public String getCard_type(){ + return this.card_type; + } + public BaseCard getBase() { + return base; + } + public void setBase(BaseCard base) { + this.base = base; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/Cash.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/Cash.java new file mode 100644 index 0000000..f689a1b --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/Cash.java @@ -0,0 +1,29 @@ +package com.github.sd4324530.fastweixin.api.entity; + +public class Cash extends BaseCard { + + /** + * + */ + private static final long serialVersionUID = 1L; + + private Integer least_cost; //代金劵专用,代金券专用,表示起用金额(单位为分),如果无起用门槛则填0 + + private Integer reduce_cost; //代金劵专用,代金券专用,表示减免金额。(单位为分) + + public Integer getLeast_cost() { + return least_cost; + } + + public void setLeast_cost(Integer least_cost) { + this.least_cost = least_cost; + } + + public Integer getReduce_cost() { + return reduce_cost; + } + + public void setReduce_cost(Integer reduce_cost) { + this.reduce_cost = reduce_cost; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/DateInfo.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/DateInfo.java new file mode 100644 index 0000000..0716a40 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/DateInfo.java @@ -0,0 +1,28 @@ +package com.github.sd4324530.fastweixin.api.entity; + +public class DateInfo { + private String type; + + private int begin_timestamp; + + private int end_timestamp; + + public void setType(String type){ + this.type = type; + } + public String getType(){ + return this.type; + } + public void setBegin_timestamp(int begin_timestamp){ + this.begin_timestamp = begin_timestamp; + } + public int getBegin_timestamp(){ + return this.begin_timestamp; + } + public void setEnd_timestamp(int end_timestamp){ + this.end_timestamp = end_timestamp; + } + public int getEnd_timestamp(){ + return this.end_timestamp; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/Discount.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/Discount.java new file mode 100644 index 0000000..333c48a --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/Discount.java @@ -0,0 +1,20 @@ +package com.github.sd4324530.fastweixin.api.entity; + +public class Discount extends BaseCard { + + /** + * + */ + private static final long serialVersionUID = 1L; + + private Integer discount; //折扣券专用,表示打折额度(百分比)。填30就是七折。 + + public Integer getDiscount() { + return discount; + } + + public void setDiscount(Integer discount) { + this.discount = discount; + } + +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/GeneralCoupon.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/GeneralCoupon.java new file mode 100644 index 0000000..ad0afe6 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/GeneralCoupon.java @@ -0,0 +1,19 @@ +package com.github.sd4324530.fastweixin.api.entity; + +public class GeneralCoupon extends BaseCard { + + /** + * + */ + private static final long serialVersionUID = 1L; + + private String default_detail; //max length(3072)优惠券专用,填写优惠详情 + + public String getDefault_detail() { + return default_detail; + } + + public void setDefault_detail(String default_detail) { + this.default_detail = default_detail; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/Gift.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/Gift.java new file mode 100644 index 0000000..7f0143d --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/Gift.java @@ -0,0 +1,19 @@ +package com.github.sd4324530.fastweixin.api.entity; + +public class Gift extends BaseCard { + + /** + * + */ + private static final long serialVersionUID = 1L; + + private String gift; //兑换券专用,填写兑换内容的名称 + + public String getGift() { + return gift; + } + + public void setGift(String gift) { + this.gift = gift; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/Groupon.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/Groupon.java new file mode 100644 index 0000000..19123f2 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/Groupon.java @@ -0,0 +1,19 @@ +package com.github.sd4324530.fastweixin.api.entity; + +public class Groupon extends BaseCard { + + /** + * + */ + private static final long serialVersionUID = 1L; + + private String deal_detail; //团购劵专用 + + public String getDeal_detail() { + return deal_detail; + } + + public void setDeal_detail(String deal_detail) { + this.deal_detail = deal_detail; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/Sku.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/Sku.java new file mode 100644 index 0000000..d685d3b --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/Sku.java @@ -0,0 +1,12 @@ +package com.github.sd4324530.fastweixin.api.entity; + +public class Sku { + private int quantity; + + public void setQuantity(int quantity){ + this.quantity = quantity; + } + public int getQuantity(){ + return this.quantity; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/TextImageList.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/TextImageList.java new file mode 100644 index 0000000..2659cc0 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/TextImageList.java @@ -0,0 +1,20 @@ +package com.github.sd4324530.fastweixin.api.entity; + +public class TextImageList { + private String image_url; + + private String text; + + public void setImage_url(String image_url){ + this.image_url = image_url; + } + public String getImage_url(){ + return this.image_url; + } + public void setText(String text){ + this.text = text; + } + public String getText(){ + return this.text; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/TimeLimit.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/TimeLimit.java new file mode 100644 index 0000000..2f5015e --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/TimeLimit.java @@ -0,0 +1,44 @@ +package com.github.sd4324530.fastweixin.api.entity; + +public class TimeLimit { + private String type; + + private int begin_hour; + + private int end_hour; + + private int begin_minute; + + private int end_minute; + + public void setType(String type){ + this.type = type; + } + public String getType(){ + return this.type; + } + public void setBegin_hour(int begin_hour){ + this.begin_hour = begin_hour; + } + public int getBegin_hour(){ + return this.begin_hour; + } + public void setEnd_hour(int end_hour){ + this.end_hour = end_hour; + } + public int getEnd_hour(){ + return this.end_hour; + } + public void setBegin_minute(int begin_minute){ + this.begin_minute = begin_minute; + } + public int getBegin_minute(){ + return this.begin_minute; + } + public void setEnd_minute(int end_minute){ + this.end_minute = end_minute; + } + public int getEnd_minute(){ + return this.end_minute; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/UseCondition.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/UseCondition.java new file mode 100644 index 0000000..d0803ef --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/UseCondition.java @@ -0,0 +1,28 @@ +package com.github.sd4324530.fastweixin.api.entity; + +public class UseCondition { + private String accept_category; + + private String reject_category; + + private boolean can_use_with_other_discount; + + public void setAccept_category(String accept_category){ + this.accept_category = accept_category; + } + public String getAccept_category(){ + return this.accept_category; + } + public void setReject_category(String reject_category){ + this.reject_category = reject_category; + } + public String getReject_category(){ + return this.reject_category; + } + public void setCan_use_with_other_discount(boolean can_use_with_other_discount){ + this.can_use_with_other_discount = can_use_with_other_discount; + } + public boolean getCan_use_with_other_discount(){ + return this.can_use_with_other_discount; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/enums/PreviewType.java b/src/main/java/com/github/sd4324530/fastweixin/api/enums/PreviewType.java new file mode 100644 index 0000000..be52469 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/enums/PreviewType.java @@ -0,0 +1,48 @@ +package com.github.sd4324530.fastweixin.api.enums; + +/** + * @author peiyu + */ +public enum PreviewType { + + /** + * 图片 + */ + IMAGE("image"), + + /** + * 语音 + */ + VOICE("voice"), + + /** + * 视频 + */ + VIDEO("video"), + + /** + * 缩略图 + */ + THUMB("thumb"), + + /** + * 图文消息 + */ + NEWS("news"), + + /** + * + */ + WXCARD("wxcard"); + + String value; + + PreviewType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/response/CreateCardResponse.java b/src/main/java/com/github/sd4324530/fastweixin/api/response/CreateCardResponse.java new file mode 100644 index 0000000..49f45fc --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/response/CreateCardResponse.java @@ -0,0 +1,22 @@ +package com.github.sd4324530.fastweixin.api.response; + +import com.alibaba.fastjson.annotation.JSONField; + +public class CreateCardResponse extends BaseResponse { + + private static final long serialVersionUID = 1L; + + @JSONField( name = "card_id") + private String cardId; + + public String getCardId() { + return cardId; + } + + public void setCardId(String cardId) { + this.cardId = cardId; + } + + + +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/message/WxCardMsg.java b/src/main/java/com/github/sd4324530/fastweixin/message/WxCardMsg.java new file mode 100644 index 0000000..f9e773d --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/message/WxCardMsg.java @@ -0,0 +1,19 @@ +package com.github.sd4324530.fastweixin.message; + +public class WxCardMsg extends BaseMsg { + + private String card_id; + + public WxCardMsg(String card_id) { + this.card_id = card_id; + } + + + public String getCard_id() { + return card_id; + } + + public void setCard_id(String card_id) { + this.card_id = card_id; + } +} -- Gitee From 4a870016cc7c1c2ac9ff8a8cd50df1b32aa172c6 Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Mon, 29 Aug 2016 06:54:15 -0400 Subject: [PATCH 08/26] no commit message --- .../sd4324530/fastweixin/api/MessagePreviewAPI.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/MessagePreviewAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/MessagePreviewAPI.java index 5601c79..aca3052 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/MessagePreviewAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/MessagePreviewAPI.java @@ -11,6 +11,7 @@ import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.message.BaseMsg; import com.github.sd4324530.fastweixin.message.ImageMsg; +import com.github.sd4324530.fastweixin.message.MpNewsMsg; import com.github.sd4324530.fastweixin.message.TextMsg; import com.github.sd4324530.fastweixin.message.VideoMsg; import com.github.sd4324530.fastweixin.message.VoiceMsg; @@ -84,7 +85,13 @@ public class MessagePreviewAPI extends BaseAPI { wxcard.put("card_id", msg.getCard_id()); wxcard.put("card_ext", ""); params.put("wxcard", wxcard); - } + } else if (message instanceof MpNewsMsg) { + MpNewsMsg msg = (MpNewsMsg) message; + params.put("msgtype", "mpnews"); + Map mpnews = new HashMap(); + mpnews.put("media_id", msg.getMediaId()); + params.put("mpnews", mpnews); + } BaseResponse response = executePost(url, JSONUtil.toJson(params)); return ResultType.get(response.getErrcode()); } -- Gitee From 4d0d40f37d8640e50348ebdddadd8aa3aad1b700 Mon Sep 17 00:00:00 2001 From: TylerCheung Date: Tue, 30 Aug 2016 04:06:57 -0400 Subject: [PATCH 09/26] =?UTF-8?q?=E5=8D=A1=E5=8A=B5=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=8E=A5=E6=94=B6=E7=AD=89=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sd4324530/fastweixin/api/CardAPI.java | 29 ++++++++----------- .../fastweixin/api/enums/CardType.java | 17 +++++++++++ .../fastweixin/message/req/EventType.java | 9 +++++- 3 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/enums/CardType.java diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java index 31ffb5e..a0d3a6e 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java @@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory; import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.entity.Card; +import com.github.sd4324530.fastweixin.api.enums.CardType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.api.response.CreateCardResponse; import com.github.sd4324530.fastweixin.util.JSONUtil; @@ -41,19 +42,19 @@ public class CardAPI extends BaseAPI { CreateCardResponse response = null; String url = BASE_API_URL + "card/create?access_token=#"; final Map params = new HashMap(); - params.put("card", card); + params.put(""+CardType.CARD.toLowerCase()+"", card); log.info("创建卡劵request开始>>>>>"); String str = JSONUtil.toJson(params); - if("CASH".equalsIgnoreCase(card.getCard_type())){ - str = str.replace("\"base\"", "\"cash\""); - }else if("GROUPON".equalsIgnoreCase(card.getCard_type())){ - str = str.replace("\"base\"", "\"groupon\""); - }else if("DISCOUNT".equalsIgnoreCase(card.getCard_type())){ - str = str.replace("\"base\"", "\"discount\""); - }else if("GIFT".equalsIgnoreCase(card.getCard_type())){ - str = str.replace("\"base\"", "\"gift\""); - }else if("GENERAL_COUPON".equalsIgnoreCase(card.getCard_type())){ - str = str.replace("\"base\"", "\"general_coupon\""); + if(CardType.CASH.equalsIgnoreCase(card.getCard_type())){ + str = str.replace("\""+CardType.BASE.toLowerCase()+"\"", "\""+CardType.CASH.toLowerCase()+"\""); + }else if(CardType.GROUPON.equalsIgnoreCase(card.getCard_type())){ + str = str.replace("\""+CardType.BASE.toLowerCase()+"\"", "\""+CardType.GROUPON.toLowerCase()+"\""); + }else if(CardType.DISCOUNT.equalsIgnoreCase(card.getCard_type())){ + str = str.replace("\""+CardType.BASE.toLowerCase()+"\"", "\""+CardType.DISCOUNT.toLowerCase()+"\""); + }else if(CardType.GIFT.equalsIgnoreCase(card.getCard_type())){ + str = str.replace("\""+CardType.BASE.toLowerCase()+"\"", "\""+CardType.GIFT.toLowerCase()+"\""); + }else if(CardType.GENERAL_COUPON.equalsIgnoreCase(card.getCard_type())){ + str = str.replace("\""+CardType.BASE.toLowerCase()+"\"", "\""+CardType.GENERAL_COUPON.toLowerCase()+"\""); } BaseResponse r = executePost(url, str); log.info("创建卡劵响应>>>>>"); @@ -62,10 +63,4 @@ public class CardAPI extends BaseAPI { response = JSONUtil.toBean(resultJson, CreateCardResponse.class); return response; } - - public static void main(String[] args) { - String str = "{\"card\":{ \"base\":{ \"base_info\":{ \"bind_openid\":false, \"brand_name\":\"50元代金劵\", \"can_give_friend\":false, \"can_share\":false, \"code_type\":\"CODE_TYPE_QRCODE\", \"color\":\"Color050\", \"date_info\":{ \"begin_timestamp\":1472054400, \"end_timestamp\":1475164800, \"type\":\"DATE_TYPE_FIX_TIME_RANGE\" }, \"description\":\"发个代金劵玩玩,任性!\", \"get_limit\":0, \"logo_url\":\"http://img03.store.sogou.com/net/a/04/link?appid=5&w=710&url=http://mmbiz.qpic.cn/mmbiz/2plBIaySaLh2hMibpwtCoWhughlKswUXqkLSPP7RytL0GyF2gNLGVdibAsBicF32NicwoTic09gQvMrELRdV8FApzVQ/0?wx_fmt=png\", \"notice\":\"好的\", \"service_phone\":\"07558601111\", \"sku\":{ \"quantity\":1000 }, \"source\":\"Loogk\", \"title\":\"代金劵\", \"use_custom_code\":false }, \"least_cost\":1000, \"reduce_cost\":10000 }, \"card_type\":\"CASH\" } }"; - str=str.replace("\"base\"", "\"cash\""); - - } } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/enums/CardType.java b/src/main/java/com/github/sd4324530/fastweixin/api/enums/CardType.java new file mode 100644 index 0000000..0117314 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/enums/CardType.java @@ -0,0 +1,17 @@ +package com.github.sd4324530.fastweixin.api.enums; + +/** + * 卡劵类别 + * @author Tyler + * + */ +public interface CardType { + public static final String CARD = "CARD"; + public static final String BASE = "BASE"; + public static final String GROUPON = "GROUPON"; + public static final String CASH = "CASH"; + public static final String DISCOUNT = "DISCOUNT"; + public static final String GIFT = "GIFT"; + public static final String GENERAL_COUPON = "GENERAL_COUPON"; + +} \ No newline at end of file diff --git a/src/main/java/com/github/sd4324530/fastweixin/message/req/EventType.java b/src/main/java/com/github/sd4324530/fastweixin/message/req/EventType.java index 2041bae..a8c365a 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/message/req/EventType.java +++ b/src/main/java/com/github/sd4324530/fastweixin/message/req/EventType.java @@ -16,7 +16,14 @@ public final class EventType { public static final String LOCATIONSELECT = "location_select"; public static final String TEMPLATESENDJOBFINISH = "TEMPLATESENDJOBFINISH"; public static final String MASSSENDJOBFINISH="MASSSENDJOBFINISH"; - public static final String POICHECKNOTIFY = "poi_check_notify"; + public static final String POICHECKNOTIFY = "poi_check_notify"; //门店审核通知 + public static final String CARD_PASS_CHECK = "card_pass_check"; //卡券通过审核 + public static final String CARD_NOT_PASS_CHECK = "card_not_pass_check"; //卡券未通过审核 + public static final String USER_GET_CARD = "user_get_card"; //领取事件,用户领取卡 + public static final String USER_DEL_CARD = "user_del_card"; //用户删除卡券 + public static final String USER_CONSUME_CARD = "user_consume_card"; //核销事件 + public static final String USER_PAY_FROM_PAY_CELL = "user_pay_from_pay_cell"; //微信买单事件 + private EventType() { } -- Gitee From 37ce132bed1547b40f5f0e6b85a98f6ee8ecfd68 Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Wed, 31 Aug 2016 02:44:06 -0400 Subject: [PATCH 10/26] no commit message --- .../sd4324530/fastweixin/api/PoiAPI.java | 10 +++++ .../fastweixin/api/entity/PoiList.java | 17 ++++++++ .../fastweixin/api/entity/PoiModel.java | 42 +++++++++++++++++++ .../api/response/GetPoiListResponse.java | 34 +++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiList.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/response/GetPoiListResponse.java diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/PoiAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/PoiAPI.java index 191f2b6..547cd2f 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/PoiAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/PoiAPI.java @@ -8,6 +8,7 @@ import com.github.sd4324530.fastweixin.api.entity.PoiForUpdateModel; import com.github.sd4324530.fastweixin.api.entity.PoiModel; import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; +import com.github.sd4324530.fastweixin.api.response.GetPoiListResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; @@ -51,5 +52,14 @@ public class PoiAPI extends BaseAPI { BaseResponse response = executePost(url,JSONUtil.getJSONFromString(poiId).toJSONString()); return ResultType.get(response.getErrcode()); } + + public GetPoiListResponse getPoiList(Integer begin,Integer limit){ + GetPoiListResponse response = null; + String url = BASE_API_URL+"cgi-bin/poi/getpoilist?access_token=#"; + BaseResponse r = executePost(url, "{\"begin\":"+begin+",\"limit\":"+limit+"}"); + String resultJson = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString(); + response = JSONUtil.toBean(resultJson, GetPoiListResponse.class); + return response; + } } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiList.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiList.java new file mode 100644 index 0000000..9f686a4 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiList.java @@ -0,0 +1,17 @@ +package com.github.sd4324530.fastweixin.api.entity; + +import com.alibaba.fastjson.annotation.JSONField; + +public class PoiList extends BaseModel{ + + @JSONField( name = "base_info") + private PoiModel poiModel; + + public PoiModel getPoiModel() { + return poiModel; + } + + public void setPoiModel(PoiModel poiModel) { + this.poiModel = poiModel; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiModel.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiModel.java index b4ab705..92810a8 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiModel.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/PoiModel.java @@ -110,6 +110,22 @@ public class PoiModel extends BaseModel { */ @JSONField(name = "avg_price") private int avgPrice; + + @JSONField(name = "poi_id") + private String poiId; + + + /** + * 门店状态,3审核通过,4审核拒绝 ,2审核中 + */ + @JSONField(name = "available_state") + private int availableState; + + + @JSONField(name = "update_status") + private int updateStatus; + + public String getSid() { return sid; @@ -254,4 +270,30 @@ public class PoiModel extends BaseModel { public void setAvgPrice(int avgPrice) { this.avgPrice = avgPrice; } + + public String getPoiId() { + return poiId; + } + + public void setPoiId(String poiId) { + this.poiId = poiId; + } + + public int getAvailableState() { + return availableState; + } + + public void setAvailableState(int availableState) { + this.availableState = availableState; + } + + public int getUpdateStatus() { + return updateStatus; + } + + public void setUpdateStatus(int updateStatus) { + this.updateStatus = updateStatus; + } + + } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/response/GetPoiListResponse.java b/src/main/java/com/github/sd4324530/fastweixin/api/response/GetPoiListResponse.java new file mode 100644 index 0000000..469eda0 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/response/GetPoiListResponse.java @@ -0,0 +1,34 @@ +package com.github.sd4324530.fastweixin.api.response; + +import java.util.List; + +import com.alibaba.fastjson.annotation.JSONField; +import com.github.sd4324530.fastweixin.api.entity.PoiList; + +public class GetPoiListResponse extends BaseResponse { + + private static final long serialVersionUID = 1L; + + @JSONField( name = "business_list") + private List poiList; + + @JSONField( name = "total_count") + private int totalCount; + + public List getPoiList() { + return poiList; + } + + public void setPoiList(List poiList) { + this.poiList = poiList; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + +} -- Gitee From 3a4ecd541e0566056bf979e9f3f40b65470d5327 Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Thu, 1 Sep 2016 00:31:25 -0400 Subject: [PATCH 11/26] no commit message --- .../sd4324530/fastweixin/api/CardAPI.java | 10 ++++++++++ .../api/response/GetCardHtmlResponse.java | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/response/GetCardHtmlResponse.java diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java index a0d3a6e..030780e 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java @@ -14,6 +14,7 @@ import com.github.sd4324530.fastweixin.api.entity.Card; import com.github.sd4324530.fastweixin.api.enums.CardType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.api.response.CreateCardResponse; +import com.github.sd4324530.fastweixin.api.response.GetCardHtmlResponse; import com.github.sd4324530.fastweixin.util.JSONUtil; /** @@ -63,4 +64,13 @@ public class CardAPI extends BaseAPI { response = JSONUtil.toBean(resultJson, CreateCardResponse.class); return response; } + + public GetCardHtmlResponse getHtml(String cardId){ + GetCardHtmlResponse response = null; + String url = BASE_API_URL + "card/mpnews/gethtml?access_token=#"; + BaseResponse r = executePost(url, "{\"card_id\":\""+cardId+"\"}"); + String resultJson = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString(); + response = JSONUtil.toBean(resultJson, GetCardHtmlResponse.class); + return response; + } } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/response/GetCardHtmlResponse.java b/src/main/java/com/github/sd4324530/fastweixin/api/response/GetCardHtmlResponse.java new file mode 100644 index 0000000..88b5c3a --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/response/GetCardHtmlResponse.java @@ -0,0 +1,17 @@ +package com.github.sd4324530.fastweixin.api.response; + +public class GetCardHtmlResponse extends BaseResponse { + + private static final long serialVersionUID = 1L; + + private String content; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + +} -- Gitee From 5e62d92cc6ac4788b7340326c56191e31f037bd7 Mon Sep 17 00:00:00 2001 From: TylerCheung Date: Thu, 1 Sep 2016 02:01:03 -0400 Subject: [PATCH 12/26] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=A2=E6=9C=8D?= =?UTF-8?q?=E5=8F=91=E9=80=81=E5=8D=A1=E5=8A=B5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sd4324530/fastweixin/api/CardAPI.java | 32 +++++++++++++++++++ .../sd4324530/fastweixin/api/CustomAPI.java | 7 ++++ .../sd4324530/fastweixin/api/MessageAPI.java | 7 ++++ .../api/response/GetSendMessageResponse.java | 7 +++- 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java index 030780e..2aa14d5 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java @@ -14,6 +14,10 @@ import com.github.sd4324530.fastweixin.api.entity.Card; import com.github.sd4324530.fastweixin.api.enums.CardType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.api.response.CreateCardResponse; +import com.github.sd4324530.fastweixin.api.response.GetSendMessageResponse; +import com.github.sd4324530.fastweixin.message.BaseMsg; +import com.github.sd4324530.fastweixin.message.WxCardMsg; +import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.api.response.GetCardHtmlResponse; import com.github.sd4324530.fastweixin.util.JSONUtil; @@ -65,6 +69,33 @@ public class CardAPI extends BaseAPI { return response; } + + /** + * 根据openId列表发送卡劵 + * 本方法调用需要账户为微信已认证账户 + * @param message 消息主体 + * @param openIds 群发用户,openId至少2个,否则不会执行 + * @return 群发结果 + */ + public GetSendMessageResponse sendDelivery(BaseMsg message, String[] openIds){ + BeanUtil.requireNonNull(message, "message is null"); + log.debug("群发消息......"); + String url = BASE_API_URL + "cgi-bin/message/mass/send?access_token=#"; + final Map params = new HashMap(); + if(message instanceof WxCardMsg){ + WxCardMsg msg = (WxCardMsg) message; + params.put("msgtype", "wxcard"); + Map wxcard = new HashMap(); + wxcard.put("card_id", msg.getCard_id()); + params.put("wxcard", wxcard); + params.put("touser", openIds); + } + BaseResponse response = executePost(url, JSONUtil.toJson(params)); + String resultJson = isSuccess(response.getErrcode()) ? response.getErrmsg() : response.toJsonString(); + return JSONUtil.toBean(resultJson, GetSendMessageResponse.class); + } + + public GetCardHtmlResponse getHtml(String cardId){ GetCardHtmlResponse response = null; String url = BASE_API_URL + "card/mpnews/gethtml?access_token=#"; @@ -73,4 +104,5 @@ public class CardAPI extends BaseAPI { response = JSONUtil.toBean(resultJson, GetCardHtmlResponse.class); return response; } + } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java index e665209..c5230a3 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java @@ -23,6 +23,7 @@ import com.github.sd4324530.fastweixin.message.NewsMsg; import com.github.sd4324530.fastweixin.message.TextMsg; import com.github.sd4324530.fastweixin.message.VideoMsg; import com.github.sd4324530.fastweixin.message.VoiceMsg; +import com.github.sd4324530.fastweixin.message.WxCardMsg; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; import com.github.sd4324530.fastweixin.util.StrUtil; @@ -108,6 +109,12 @@ public class CustomAPI extends BaseAPI { } news.put("articles", articles); params.put("news", news); + }else if (message instanceof WxCardMsg) { + WxCardMsg msg = (WxCardMsg) message; + params.put("msgtype", "wxcard"); + Map wxcard = new HashMap(); + wxcard.put("card_id", msg.getCard_id()); + params.put("wxcard", wxcard); } BaseResponse response = executePost(url, JSONUtil.toJson(params)); return ResultType.get(response.getErrcode()); diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/MessageAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/MessageAPI.java index 916e72c..2e35fba 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/MessageAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/MessageAPI.java @@ -21,6 +21,7 @@ import com.github.sd4324530.fastweixin.message.NewsMsg; import com.github.sd4324530.fastweixin.message.TextMsg; import com.github.sd4324530.fastweixin.message.VideoMsg; import com.github.sd4324530.fastweixin.message.VoiceMsg; +import com.github.sd4324530.fastweixin.message.WxCardMsg; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; @@ -87,6 +88,12 @@ public class MessageAPI extends BaseAPI { params.put("image", image); }else if(message instanceof VideoMsg){ // TODO 此处方法特别 + }else if(message instanceof WxCardMsg){ + WxCardMsg msg = (WxCardMsg) message; + params.put("msgtype", "wxcard"); + Map wxcard = new HashMap(); + wxcard.put("card_id", msg.getCard_id()); + params.put("wxcard", wxcard); } BaseResponse response = executePost(url, JSONUtil.toJson(params)); String resultJson = isSuccess(response.getErrcode()) ? response.getErrmsg() : response.toJsonString(); diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/response/GetSendMessageResponse.java b/src/main/java/com/github/sd4324530/fastweixin/api/response/GetSendMessageResponse.java index 6cbc22a..28e80b5 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/response/GetSendMessageResponse.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/response/GetSendMessageResponse.java @@ -13,7 +13,12 @@ import com.alibaba.fastjson.annotation.JSONField; */ public class GetSendMessageResponse extends BaseResponse { - @JSONField(name="msg_id") + /** + * + */ + private static final long serialVersionUID = 1L; + + @JSONField(name="msg_id") private String msgId; public String getMsgId() { -- Gitee From f145f350f8acc4d56468fa6aedfb3b4e4c81d84b Mon Sep 17 00:00:00 2001 From: TylerCheung Date: Fri, 2 Sep 2016 07:11:36 -0400 Subject: [PATCH 13/26] =?UTF-8?q?=E5=8D=A1=E5=88=B8=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E9=97=A8=E5=BA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sd4324530/fastweixin/api/CardAPI.java | 38 ++++++++++++++++- .../api/response/BatchgetCardResponse.java | 41 +++++++++++++++++++ 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/response/BatchgetCardResponse.java diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java index 2aa14d5..d9ac369 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java @@ -13,12 +13,13 @@ import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.entity.Card; import com.github.sd4324530.fastweixin.api.enums.CardType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; +import com.github.sd4324530.fastweixin.api.response.BatchgetCardResponse; import com.github.sd4324530.fastweixin.api.response.CreateCardResponse; +import com.github.sd4324530.fastweixin.api.response.GetCardHtmlResponse; import com.github.sd4324530.fastweixin.api.response.GetSendMessageResponse; import com.github.sd4324530.fastweixin.message.BaseMsg; import com.github.sd4324530.fastweixin.message.WxCardMsg; import com.github.sd4324530.fastweixin.util.BeanUtil; -import com.github.sd4324530.fastweixin.api.response.GetCardHtmlResponse; import com.github.sd4324530.fastweixin.util.JSONUtil; /** @@ -27,6 +28,7 @@ import com.github.sd4324530.fastweixin.util.JSONUtil; * {@linkplain 创建卡劵} * {@linkplain 投放卡劵} * {@linkplain 核销卡劵} + * {@linkplain 批量查询卡券列表 } * * @version 1.0 */ @@ -104,5 +106,37 @@ public class CardAPI extends BaseAPI { response = JSONUtil.toBean(resultJson, GetCardHtmlResponse.class); return response; } - + + /** + * 批量查询卡券列表,用来同步与官方数据一致性 + * @param offset 查询卡列表的起始偏移量,从0开始,即offset: 5是指从从列表里的第六个开始读取 + * @param count 需要查询的卡片的数量(数量最大50) + * @param statusList(“CARD_STATUS_NOT_VERIFY”, + 待审核; + “CARD_STATUS_VERIFY_FAIL”, + 审核失败; + “CARD_STATUS_VERIFY_OK”, + 通过审核; + “CARD_STATUS_DELETE”, + 卡券被商户删除; + “CARD_STATUS_DISPATCH”, + 在公众平台投放过的卡券;) + * @return + */ + public BatchgetCardResponse batchget(int offset,int count,String[] statusList){ + BatchgetCardResponse response = null; + String url = BASE_API_URL + "card/batchget?access_token=#"; + final Map params = new HashMap(); + params.put("offset", offset); + params.put("count", count); + params.put("status_list", statusList); + log.info("批量查询卡券列表request开始>>>>>"); + String str = JSONUtil.toJson(params); + BaseResponse r = executePost(url, str); + log.info("批量查询卡券列表响应>>>>>"); + String resultJson = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString(); + log.info("批量查询卡券列表响应结果解析>>>>>"); + response = JSONUtil.toBean(resultJson, BatchgetCardResponse.class); + return response; + } } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/response/BatchgetCardResponse.java b/src/main/java/com/github/sd4324530/fastweixin/api/response/BatchgetCardResponse.java new file mode 100644 index 0000000..8f84e72 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/response/BatchgetCardResponse.java @@ -0,0 +1,41 @@ +package com.github.sd4324530.fastweixin.api.response; + +import com.alibaba.fastjson.annotation.JSONField; + +public class BatchgetCardResponse extends BaseResponse { + + private static final long serialVersionUID = 1L; + + @JSONField( name = "total_num") + private Integer totalNum; + + @JSONField( name = "card_id_list") + private String[] cardIdList; + + @JSONField( name = "card_list") + private String[] cardList; + + public Integer getTotalNum() { + return totalNum; + } + + public void setTotalNum(Integer totalNum) { + this.totalNum = totalNum; + } + + public String[] getCardIdList() { + return cardIdList; + } + + public void setCardIdList(String[] cardIdList) { + this.cardIdList = cardIdList; + } + + public String[] getCardList() { + return cardList; + } + + public void setCardList(String[] cardList) { + this.cardList = cardList; + } +} -- Gitee From f7ec4c194cf74ff78340cce3e2ba1a6e688cb974 Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Fri, 2 Sep 2016 07:12:56 -0400 Subject: [PATCH 14/26] no commit message --- .../api/response/DownloadMediaResponse.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/response/DownloadMediaResponse.java b/src/main/java/com/github/sd4324530/fastweixin/api/response/DownloadMediaResponse.java index 0e4d173..0b0509b 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/response/DownloadMediaResponse.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/response/DownloadMediaResponse.java @@ -1,14 +1,15 @@ package com.github.sd4324530.fastweixin.api.response; -import com.github.sd4324530.fastweixin.util.StreamUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.github.sd4324530.fastweixin.util.StreamUtil; + /** * 下载多媒体资源响应对象 * @@ -44,7 +45,12 @@ public class DownloadMediaResponse extends BaseResponse { } } - /** + public byte[] getContent() { + return content; + } + + + /** * 如果成功,则可以靠这个方法将数据输出 * * @param out 调用者给的输出流 -- Gitee From facbf575acc018db4028558804fc2f1dde3a2c03 Mon Sep 17 00:00:00 2001 From: TylerCheung Date: Wed, 30 Nov 2016 23:36:53 -0500 Subject: [PATCH 15/26] no commit message --- .../sd4324530/fastweixin/api/entity/DateInfo.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/DateInfo.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/DateInfo.java index 0716a40..d307ec6 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/entity/DateInfo.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/DateInfo.java @@ -3,9 +3,9 @@ package com.github.sd4324530.fastweixin.api.entity; public class DateInfo { private String type; - private int begin_timestamp; + private long begin_timestamp; - private int end_timestamp; + private long end_timestamp; public void setType(String type){ this.type = type; @@ -13,16 +13,16 @@ public class DateInfo { public String getType(){ return this.type; } - public void setBegin_timestamp(int begin_timestamp){ + public void setBegin_timestamp(long begin_timestamp){ this.begin_timestamp = begin_timestamp; } - public int getBegin_timestamp(){ + public long getBegin_timestamp(){ return this.begin_timestamp; } - public void setEnd_timestamp(int end_timestamp){ + public void setEnd_timestamp(long end_timestamp){ this.end_timestamp = end_timestamp; } - public int getEnd_timestamp(){ + public long getEnd_timestamp(){ return this.end_timestamp; } } -- Gitee From 23ee3410227ca29d24cb56522e4a5ecfada8ed8d Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Sun, 19 Feb 2017 21:31:38 -0500 Subject: [PATCH 16/26] no commit message --- .../sd4324530/fastweixin/api/QrcodeAPI.java | 2 +- .../fastweixin/api/TemplateMsgAPI.java | 17 +++ .../api/response/PrivateTemplate.java | 105 ++++++++++++++++++ 3 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/response/PrivateTemplate.java diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/QrcodeAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/QrcodeAPI.java index b9ae1f0..ae5d0d4 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/QrcodeAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/QrcodeAPI.java @@ -51,7 +51,7 @@ public class QrcodeAPI extends BaseAPI { */ public QrcodeResponse createQrcode(QrcodeType actionName, String sceneId, String sceneStr, Integer expireSeconds) { BeanUtil.requireNonNull(actionName, "actionName is null"); - BeanUtil.requireNonNull(sceneId, "actionInfo is null"); + // BeanUtil.requireNonNull(sceneId, "actionInfo is null"); LOG.debug("创建二维码信息....."); diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java index caa1db0..0df780d 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/TemplateMsgAPI.java @@ -1,17 +1,20 @@ package com.github.sd4324530.fastweixin.api; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.alibaba.fastjson.JSON; import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.entity.Industry; import com.github.sd4324530.fastweixin.api.entity.TemplateMsg; import com.github.sd4324530.fastweixin.api.enums.ResultType; import com.github.sd4324530.fastweixin.api.response.AddTemplateResponse; import com.github.sd4324530.fastweixin.api.response.BaseResponse; +import com.github.sd4324530.fastweixin.api.response.PrivateTemplate; import com.github.sd4324530.fastweixin.api.response.SendTemplateResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JSONUtil; @@ -58,6 +61,20 @@ public class TemplateMsgAPI extends BaseAPI { return result; } + /** + * 获取已添加至帐号下所有模板列表 + * + * @return 所有模板 + */ + public List getAllPrivateTemplate() { + LOG.debug("获取已添加至帐号下所有模板列表......"); + String url = BASE_API_URL + "cgi-bin/template/get_all_private_template?access_token=#"; + BaseResponse r = executeGet(url); + String resultJson = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString(); + List templates = JSON.parseArray(JSONUtil.getJSONFromString(resultJson).get("template_list").toString(), PrivateTemplate.class); + return templates; + } + /** * 发送模版消息 * diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/response/PrivateTemplate.java b/src/main/java/com/github/sd4324530/fastweixin/api/response/PrivateTemplate.java new file mode 100644 index 0000000..c9d9981 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/response/PrivateTemplate.java @@ -0,0 +1,105 @@ +package com.github.sd4324530.fastweixin.api.response; + +import com.alibaba.fastjson.annotation.JSONField; +import com.github.sd4324530.fastweixin.api.entity.BaseModel; +/** + * 获取已添加至帐号下所有模板 + * @author wuwentao + */ +public class PrivateTemplate extends BaseModel { + + /** + * 模板ID + */ + @JSONField(name="template_id") + private String templateId; + + /** + * 模板标题 + */ + private String title; + + /** + * 模板所属行业的一级行业 + */ + @JSONField(name="primary_industry") + private String primaryIndustry; + + /** + * 模板所属行业的二级行业 + */ + @JSONField(name="deputy_industry") + private String deputyIndustry; + + /** + * 模板内容 + */ + private String content; + + /** + * 模板示例 + */ + private String example; + + /** + * 模板备注 + */ + private String remark; + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getPrimaryIndustry() { + return primaryIndustry; + } + + public void setPrimaryIndustry(String primaryIndustry) { + this.primaryIndustry = primaryIndustry; + } + + public String getDeputyIndustry() { + return deputyIndustry; + } + + public void setDeputyIndustry(String deputyIndustry) { + this.deputyIndustry = deputyIndustry; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getExample() { + return example; + } + + public void setExample(String example) { + this.example = example; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } + +} \ No newline at end of file -- Gitee From aba089a4cecffdbb66c5323b3cc32b537a622680 Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Tue, 7 Mar 2017 22:45:08 -0500 Subject: [PATCH 17/26] no commit message --- .../sd4324530/fastweixin/api/CardAPI.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java index d9ac369..00a1f86 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java @@ -139,4 +139,23 @@ public class CardAPI extends BaseAPI { response = JSONUtil.toBean(resultJson, BatchgetCardResponse.class); return response; } + + /** + * 核销卡券 + * @return 核销卡劵结果 + */ + public BaseResponse hexiao(String code){ + BaseResponse response = null; + String url = BASE_API_URL + "card/code/consume?access_token=#"; + final Map params = new HashMap(); + params.put("code", code); + log.info("核销卡劵request开始>>>>>"); + String str = JSONUtil.toJson(params); + BaseResponse r = executePost(url, str); + log.info("核销卡劵响应>>>>>"); + String resultJson = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString(); + log.info("核销卡劵响应结果解析>>>>>"); + response = JSONUtil.toBean(resultJson, BaseResponse.class); + return response; + } } -- Gitee From c0d3796c1f9ff844922f72e45080152311a0904d Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Sat, 1 Apr 2017 15:11:20 +0800 Subject: [PATCH 18/26] no commit message --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 8e048cb..58d3bc6 100644 --- a/pom.xml +++ b/pom.xml @@ -1,10 +1,10 @@ 4.0.0 - com.github.sd4324530 + com.loogk fastweixin + 1.0 https://github.com/sd4324530/fastweixin.git - 1.3.12-SNAPSHOT jar fastweixin quickly department weixin server -- Gitee From dbd82f19bd747ffd58774437a64c33d2a6f14282 Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Fri, 30 Jun 2017 16:51:36 +0800 Subject: [PATCH 19/26] no commit message --- .../sd4324530/fastweixin/api/CardAPI.java | 23 ++++++++ .../fastweixin/api/entity/CardStatus.java | 36 +++++++++++++ .../api/response/CardCheckStatusResponse.java | 52 +++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/entity/CardStatus.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/response/CardCheckStatusResponse.java diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java index 00a1f86..0bd1eee 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java @@ -14,6 +14,7 @@ import com.github.sd4324530.fastweixin.api.entity.Card; import com.github.sd4324530.fastweixin.api.enums.CardType; import com.github.sd4324530.fastweixin.api.response.BaseResponse; import com.github.sd4324530.fastweixin.api.response.BatchgetCardResponse; +import com.github.sd4324530.fastweixin.api.response.CardCheckStatusResponse; import com.github.sd4324530.fastweixin.api.response.CreateCardResponse; import com.github.sd4324530.fastweixin.api.response.GetCardHtmlResponse; import com.github.sd4324530.fastweixin.api.response.GetSendMessageResponse; @@ -158,4 +159,26 @@ public class CardAPI extends BaseAPI { response = JSONUtil.toBean(resultJson, BaseResponse.class); return response; } + + + /** + * 检查卡券状态 + * @return 是否可核销 + */ + public CardCheckStatusResponse checkCode(String code,String cardId){ + CardCheckStatusResponse response = null; + String url = BASE_API_URL + "card/code/get?access_token=#"; + final Map params = new HashMap(); + params.put("card_id", cardId); + params.put("code", code); + params.put("check_consume", true); + log.info("查询卡劵状态request开始>>>>>"); + String str = JSONUtil.toJson(params); + BaseResponse r = executePost(url, str); + log.info("查询卡劵状态响应>>>>>"); + String resultJson = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString(); + log.info("查询卡劵状态响应结果解析>>>>>"); + response = JSONUtil.toBean(resultJson, CardCheckStatusResponse.class); + return response; + } } diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/entity/CardStatus.java b/src/main/java/com/github/sd4324530/fastweixin/api/entity/CardStatus.java new file mode 100644 index 0000000..d7bcfe4 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/entity/CardStatus.java @@ -0,0 +1,36 @@ +package com.github.sd4324530.fastweixin.api.entity; + +public class CardStatus extends BaseModel{ + private static final long serialVersionUID = 1L; + + private String card_id; + + private String begin_time; + + private String end_time; + + public String getCard_id() { + return card_id; + } + + public void setCard_id(String card_id) { + this.card_id = card_id; + } + + public String getBegin_time() { + return begin_time; + } + + public void setBegin_time(String begin_time) { + this.begin_time = begin_time; + } + + public String getEnd_time() { + return end_time; + } + + public void setEnd_time(String end_time) { + this.end_time = end_time; + } + +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/response/CardCheckStatusResponse.java b/src/main/java/com/github/sd4324530/fastweixin/api/response/CardCheckStatusResponse.java new file mode 100644 index 0000000..b754aa3 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/response/CardCheckStatusResponse.java @@ -0,0 +1,52 @@ +package com.github.sd4324530.fastweixin.api.response; + +import com.alibaba.fastjson.annotation.JSONField; +import com.github.sd4324530.fastweixin.api.entity.CardStatus; + +public class CardCheckStatusResponse extends BaseResponse { + + private static final long serialVersionUID = 1L; + + private CardStatus card; + + private String openid; + + @JSONField( name = "can_consume") + private boolean canConsume; + + @JSONField( name = "user_card_status") + private String userCardStatus; + + public CardStatus getCard() { + return card; + } + + public void setCard(CardStatus card) { + this.card = card; + } + + public String getOpenid() { + return openid; + } + + public void setOpenid(String openid) { + this.openid = openid; + } + + public boolean isCanConsume() { + return canConsume; + } + + public void setCanConsume(boolean canConsume) { + this.canConsume = canConsume; + } + + public String getUserCardStatus() { + return userCardStatus; + } + + public void setUserCardStatus(String userCardStatus) { + this.userCardStatus = userCardStatus; + } + +} -- Gitee From a73cd5b3e40b5d0e826e521c231f548976539bcb Mon Sep 17 00:00:00 2001 From: TylerCheung Date: Tue, 4 Jul 2017 11:21:29 +0800 Subject: [PATCH 20/26] no commit message --- src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java index c5230a3..7daf31f 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/CustomAPI.java @@ -117,6 +117,7 @@ public class CustomAPI extends BaseAPI { params.put("wxcard", wxcard); } BaseResponse response = executePost(url, JSONUtil.toJson(params)); + LOG.debug("发布客服消息返回>>>>>>"+response); return ResultType.get(response.getErrcode()); } -- Gitee From eb82713080638f65987ed10d98ff44ab39a77063 Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Fri, 4 Aug 2017 12:34:48 +0800 Subject: [PATCH 21/26] no commit message --- .../sd4324530/fastweixin/api/config/WxConfig.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/config/WxConfig.java b/src/main/java/com/github/sd4324530/fastweixin/api/config/WxConfig.java index f202e0b..b2a74ff 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/config/WxConfig.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/config/WxConfig.java @@ -13,6 +13,8 @@ public class WxConfig implements Serializable{ private Long accessTokenTime ; private String jsApiTicket ; private Long jsApiTicketTime ; + private String apiTicket; + private Long apiTicketTime; public String getAppid() { return appid; @@ -50,6 +52,17 @@ public class WxConfig implements Serializable{ public void setJsApiTicketTime(Long jsApiTicketTime) { this.jsApiTicketTime = jsApiTicketTime; } - + public String getApiTicket() { + return apiTicket; + } + public void setApiTicket(String apiTicket) { + this.apiTicket = apiTicket; + } + public Long getApiTicketTime() { + return apiTicketTime; + } + public void setApiTicketTime(Long apiTicketTime) { + this.apiTicketTime = apiTicketTime; + } } -- Gitee From 30ac4b24fff5b66f1e23a2646cde80b619f5bd91 Mon Sep 17 00:00:00 2001 From: TylerCheung Date: Thu, 10 Aug 2017 11:29:23 +0800 Subject: [PATCH 22/26] =?UTF-8?q?JS-SDK=E5=8D=A1=E5=88=B8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=AD=BE=E5=90=8D=E6=96=B9=E5=BC=8F=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sd4324530/fastweixin/api/CardAPI.java | 2 +- .../sd4324530/fastweixin/util/JsApiUtil.java | 27 ++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java index 0bd1eee..f4a9400 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java @@ -39,7 +39,7 @@ public class CardAPI extends BaseAPI { super(config); } - private static final Logger log = LoggerFactory.getLogger(CustomAPI.class); + private static final Logger log = LoggerFactory.getLogger(CardAPI.class); /** * 卡劵创建 diff --git a/src/main/java/com/github/sd4324530/fastweixin/util/JsApiUtil.java b/src/main/java/com/github/sd4324530/fastweixin/util/JsApiUtil.java index 4f8c7e4..93048d2 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/util/JsApiUtil.java +++ b/src/main/java/com/github/sd4324530/fastweixin/util/JsApiUtil.java @@ -1,10 +1,14 @@ package com.github.sd4324530.fastweixin.util; -import com.github.sd4324530.fastweixin.message.aes.SHA1; - +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.TreeMap; +import com.github.sd4324530.fastweixin.message.aes.SHA1; + /** * @author daxiaoming */ @@ -32,5 +36,22 @@ public class JsApiUtil { } return SHA1.getSHA1HexString(sb.substring(1)); } - + + public static String sign(String apiTicket, long timestame,String nonceStr,String cardId) throws Exception { + Map paramMap = new TreeMap(); + paramMap.put(apiTicket,"api_ticket"); + paramMap.put(nonceStr,"nonce_str"); + paramMap.put(Long.toString(timestame),"timestamp"); + paramMap.put(cardId,"card_id"); + + Collection keySet = paramMap.keySet(); + List list = new ArrayList(keySet); + Collections.sort(list); + StringBuilder sb = new StringBuilder(); + for(int i=0;i Date: Thu, 10 Aug 2017 11:29:43 +0800 Subject: [PATCH 23/26] =?UTF-8?q?JS-SDK=E5=8D=A1=E5=88=B8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=AD=BE=E5=90=8D=E6=96=B9=E5=BC=8F=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sd4324530/fastweixin/api/JsAPI.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/JsAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/JsAPI.java index 4ffc94c..46f907e 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/JsAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/JsAPI.java @@ -1,5 +1,7 @@ package com.github.sd4324530.fastweixin.api; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; import org.slf4j.Logger; @@ -7,6 +9,8 @@ import org.slf4j.LoggerFactory; import com.github.sd4324530.fastweixin.api.config.WxConfig; import com.github.sd4324530.fastweixin.api.enums.ResultType; +import com.github.sd4324530.fastweixin.api.response.GetCardExtResponse; +import com.github.sd4324530.fastweixin.api.response.GetSignatureAndCardResponse; import com.github.sd4324530.fastweixin.api.response.GetSignatureResponse; import com.github.sd4324530.fastweixin.util.BeanUtil; import com.github.sd4324530.fastweixin.util.JsApiUtil; @@ -37,6 +41,20 @@ public class JsAPI extends BaseAPI { String nonceStr = UUID.randomUUID().toString().replaceAll("-", ""); return getSignature(nonceStr, timestame, url); } + + /** + * 获取js-sdk所需的签名,简化逻辑,包括卡券 + * @param url + * @return + */ + public GetSignatureAndCardResponse getSignatureAndCard(String url,String[] cardIds) { + BeanUtil.requireNonNull(url, "请传入当前网页的URL,不包含#及其后面部分"); + //当前时间的秒数 + long timestame = System.currentTimeMillis() / 1000; + //使用UUID来当随机字符串 + String nonceStr = UUID.randomUUID().toString().replaceAll("-", ""); + return getSignatureAndCard(nonceStr, timestame, url,cardIds); + } /** * 获取js-sdk所需的签名,给调用者最大的自由度,控制生成签名的参数 @@ -65,4 +83,42 @@ public class JsAPI extends BaseAPI { response.setErrcode(ResultType.SUCCESS.getCode().toString()); return response; } + + + public GetSignatureAndCardResponse getSignatureAndCard(String nonceStr, long timestame, String url,String[] cardIds) { + BeanUtil.requireNonNull(url, "请传入当前网页的URL,不包含#及其后面部分"); + GetSignatureAndCardResponse response = new GetSignatureAndCardResponse(); + String jsApiTicket = this.config.getJsApiTicket(); + String apiTicket = this.config.getApiTicket(); + String sign; + List cardExts = new ArrayList(); + try { + sign = JsApiUtil.sign(jsApiTicket, nonceStr, timestame, url); + for(String cardId:cardIds){ + //当前时间的秒数 + long ctimestame = System.currentTimeMillis() / 1000; + //使用UUID来当随机字符串 + String cnonceStr = UUID.randomUUID().toString().replaceAll("-", ""); + String ext = JsApiUtil.sign(apiTicket, ctimestame, cnonceStr, cardId); + GetCardExtResponse cardExt = new GetCardExtResponse(); + cardExt.setCardId(cardId); + cardExt.setCardExt(ext); + cardExt.setNoncestr(cnonceStr); + cardExt.setTimestamp(ctimestame); + cardExts.add(cardExt); + } + } catch (Exception e) { + LOG.error("获取签名异常:", e); + response.setErrcode(ResultType.OTHER_ERROR.getCode().toString()); + response.setErrmsg("获取签名异常"); + return response; + } + response.setNoncestr(nonceStr); + response.setSignature(sign); + response.setTimestamp(timestame); + response.setUrl(url); + response.setCardExts(cardExts); + response.setErrcode(ResultType.SUCCESS.getCode().toString()); + return response; + } } -- Gitee From 4e36f78fd66e2ecc92c181d4e9649ea3be8aaeb0 Mon Sep 17 00:00:00 2001 From: TylerCheung Date: Thu, 10 Aug 2017 11:32:34 +0800 Subject: [PATCH 24/26] =?UTF-8?q?JS-SDK=E5=8D=A1=E5=88=B8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=AD=BE=E5=90=8D=E6=96=B9=E5=BC=8F=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/response/GetCardExtResponse.java | 49 +++++++++++++++++++ .../response/GetSignatureAndCardResponse.java | 24 +++++++++ 2 files changed, 73 insertions(+) create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/response/GetCardExtResponse.java create mode 100644 src/main/java/com/github/sd4324530/fastweixin/api/response/GetSignatureAndCardResponse.java diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/response/GetCardExtResponse.java b/src/main/java/com/github/sd4324530/fastweixin/api/response/GetCardExtResponse.java new file mode 100644 index 0000000..b41d1d5 --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/response/GetCardExtResponse.java @@ -0,0 +1,49 @@ +package com.github.sd4324530.fastweixin.api.response; + +/** + * JS-SDK卡券添加参数类 + * @author Tyler + * + */ +public class GetCardExtResponse { + + private String cardId; + + private String cardExt; + + private String noncestr; + + private long timestamp; + + public String getCardId() { + return cardId; + } + + public void setCardId(String cardId) { + this.cardId = cardId; + } + + public String getCardExt() { + return cardExt; + } + + public void setCardExt(String cardExt) { + this.cardExt = cardExt; + } + + public String getNoncestr() { + return noncestr; + } + + public void setNoncestr(String noncestr) { + this.noncestr = noncestr; + } + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } +} diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/response/GetSignatureAndCardResponse.java b/src/main/java/com/github/sd4324530/fastweixin/api/response/GetSignatureAndCardResponse.java new file mode 100644 index 0000000..d7bea5b --- /dev/null +++ b/src/main/java/com/github/sd4324530/fastweixin/api/response/GetSignatureAndCardResponse.java @@ -0,0 +1,24 @@ +package com.github.sd4324530.fastweixin.api.response; + +import java.util.List; + +/** + * JS-SDK卡券添加参数类 + * @author Tyler + * + */ +public class GetSignatureAndCardResponse extends GetSignatureResponse { + + private static final long serialVersionUID = 1L; + + private List cardExts; + + public List getCardExts() { + return cardExts; + } + + public void setCardExts(List cardExts) { + this.cardExts = cardExts; + } + +} -- Gitee From 0dab7bc30be04b2eb70031709825b32156e76a29 Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Thu, 10 Aug 2017 11:41:47 +0800 Subject: [PATCH 25/26] no commit message --- .../sd4324530/fastweixin/util/NetWorkCenter.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/github/sd4324530/fastweixin/util/NetWorkCenter.java b/src/main/java/com/github/sd4324530/fastweixin/util/NetWorkCenter.java index 777083b..bc04a72 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/util/NetWorkCenter.java +++ b/src/main/java/com/github/sd4324530/fastweixin/util/NetWorkCenter.java @@ -1,6 +1,11 @@ package com.github.sd4324530.fastweixin.util; -import com.github.sd4324530.fastweixin.api.response.BaseResponse; +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.List; +import java.util.Map; + import org.apache.http.HttpEntity; import org.apache.http.HttpStatus; import org.apache.http.client.ClientProtocolException; @@ -16,16 +21,13 @@ import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.content.FileBody; import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.DefaultHttpRequestRetryHandler; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.List; -import java.util.Map; +import com.github.sd4324530.fastweixin.api.response.BaseResponse; /** * HTTP请求客户端操作类,基于org.apache.http.client包4.4.x版本实现 @@ -208,7 +210,7 @@ public final class NetWorkCenter { LOG.debug("-----------------请求地址:{}-----------------", url); //配置请求参数 RequestConfig config = RequestConfig.custom().setConnectionRequestTimeout(CONNECT_TIMEOUT).setConnectTimeout(CONNECT_TIMEOUT).setSocketTimeout(CONNECT_TIMEOUT).build(); - CloseableHttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(config).build(); + CloseableHttpClient client = HttpClientBuilder.create().setDefaultRequestConfig(config).setRetryHandler(new DefaultHttpRequestRetryHandler()).build(); HttpUriRequest request = null; switch (method) { case GET: -- Gitee From 52e892a44a5cbb0c7979256cde4afc1a8deb6a1e Mon Sep 17 00:00:00 2001 From: "eric.xu" <234448626@qq.com> Date: Thu, 12 Jul 2018 11:28:20 +0800 Subject: [PATCH 26/26] no commit message --- src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java | 2 ++ src/main/java/com/github/sd4324530/fastweixin/api/UserAPI.java | 1 + 2 files changed, 3 insertions(+) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java index f4a9400..e895f31 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/CardAPI.java @@ -109,6 +109,8 @@ public class CardAPI extends BaseAPI { } /** + * + * * 批量查询卡券列表,用来同步与官方数据一致性 * @param offset 查询卡列表的起始偏移量,从0开始,即offset: 5是指从从列表里的第六个开始读取 * @param count 需要查询的卡片的数量(数量最大50) diff --git a/src/main/java/com/github/sd4324530/fastweixin/api/UserAPI.java b/src/main/java/com/github/sd4324530/fastweixin/api/UserAPI.java index 1f1cca4..bab2caa 100644 --- a/src/main/java/com/github/sd4324530/fastweixin/api/UserAPI.java +++ b/src/main/java/com/github/sd4324530/fastweixin/api/UserAPI.java @@ -204,6 +204,7 @@ public class UserAPI extends BaseAPI { BaseResponse r = executeGet(url); String resultJson = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString(); response = JSONUtil.toBean(resultJson, GetUserInfoResponse.class); + LOG.debug("USER_INFO="+response.toJsonString()); return response; } -- Gitee