11package me .chanjar .weixin .mp .api .impl ;
22
3- import java .io .File ;
4- import java .util .Date ;
5-
6- import org .slf4j .Logger ;
7- import org .slf4j .LoggerFactory ;
8-
93import com .google .gson .JsonObject ;
10-
114import me .chanjar .weixin .common .bean .result .WxError ;
125import me .chanjar .weixin .common .bean .result .WxMediaUploadResult ;
136import me .chanjar .weixin .common .exception .WxErrorException ;
1710import me .chanjar .weixin .mp .bean .WxMpCustomMessage ;
1811import me .chanjar .weixin .mp .bean .kefu .request .WxMpKfAccountRequest ;
1912import me .chanjar .weixin .mp .bean .kefu .request .WxMpKfSessionRequest ;
20- import me .chanjar .weixin .mp .bean .kefu .result .WxMpKfList ;
21- import me . chanjar . weixin . mp . bean . kefu . result . WxMpKfMsgList ;
22- import me . chanjar . weixin . mp . bean . kefu . result . WxMpKfOnlineList ;
23- import me . chanjar . weixin . mp . bean . kefu . result . WxMpKfSessionGetResult ;
24- import me . chanjar . weixin . mp . bean . kefu . result . WxMpKfSessionList ;
25- import me . chanjar . weixin . mp . bean . kefu . result . WxMpKfSessionWaitCaseList ;
13+ import me .chanjar .weixin .mp .bean .kefu .result .* ;
14+ import org . slf4j . Logger ;
15+ import org . slf4j . LoggerFactory ;
16+
17+ import java . io . File ;
18+ import java . util . Date ;
2619
2720/**
28- *
21+ *
2922 * @author Binary Wang
3023 *
3124 */
3225public class WxMpKefuServiceImpl implements WxMpKefuService {
3326 protected final Logger log = LoggerFactory
3427 .getLogger (WxMpKefuServiceImpl .class );
3528 private static final String API_URL_PREFIX = "https://api.weixin.qq.com/customservice" ;
29+ private static final String API_URL_PREFIX_WITH_CGI_BIN = "https://api.weixin.qq.com/cgi-bin/customservice" ;
3630 private WxMpService wxMpService ;
3731
3832 public WxMpKefuServiceImpl (WxMpService wxMpService ) {
@@ -44,26 +38,20 @@ public boolean customMessageSend(WxMpCustomMessage message)
4438 throws WxErrorException {
4539 String url = "https://api.weixin.qq.com/cgi-bin/message/custom/send" ;
4640 String responseContent = this .wxMpService .post (url , message .toJson ());
47- this .log .debug ("\n url:{}\n params:{}\n response:{}" , url , message .toJson (),
48- responseContent );
4941 return true ;
5042 }
5143
5244 @ Override
5345 public WxMpKfList kfList () throws WxErrorException {
54- String url = API_URL_PREFIX + "/getkflist" ;
46+ String url = API_URL_PREFIX_WITH_CGI_BIN + "/getkflist" ;
5547 String responseContent = this .wxMpService .get (url , null );
56- this .log .debug ("\n url:{}\n params:{}\n response:{}" , url , null ,
57- responseContent );
5848 return WxMpKfList .fromJson (responseContent );
5949 }
6050
6151 @ Override
6252 public WxMpKfOnlineList kfOnlineList () throws WxErrorException {
63- String url = API_URL_PREFIX + "/getonlinekflist" ;
53+ String url = API_URL_PREFIX_WITH_CGI_BIN + "/getonlinekflist" ;
6454 String responseContent = this .wxMpService .get (url , null );
65- this .log .debug ("\n url:{}\n params:{}\n response:{}" , url , null ,
66- responseContent );
6755 return WxMpKfOnlineList .fromJson (responseContent );
6856 }
6957
@@ -72,8 +60,6 @@ public boolean kfAccountAdd(WxMpKfAccountRequest request)
7260 throws WxErrorException {
7361 String url = API_URL_PREFIX + "/kfaccount/add" ;
7462 String responseContent = this .wxMpService .post (url , request .toJson ());
75- this .log .debug ("\n url:{}\n params:{}\n response:{}" , url , request .toJson (),
76- responseContent );
7763 return true ;
7864 }
7965
@@ -82,17 +68,13 @@ public boolean kfAccountUpdate(WxMpKfAccountRequest request)
8268 throws WxErrorException {
8369 String url = API_URL_PREFIX + "/kfaccount/update" ;
8470 String responseContent = this .wxMpService .post (url , request .toJson ());
85- this .log .debug ("\n url:{}\n params:{}\n response:{}" , url , request .toJson (),
86- responseContent );
8771 return true ;
8872 }
8973
9074 @ Override
9175 public boolean kfAccountInviteWorker (WxMpKfAccountRequest request ) throws WxErrorException {
9276 String url = API_URL_PREFIX + "/kfaccount/inviteworker" ;
9377 String responseContent = this .wxMpService .post (url , request .toJson ());
94- this .log .debug ("\n url:{}\n params:{}\n response:{}" , url , request .toJson (),
95- responseContent );
9678 return true ;
9779 }
9880
@@ -102,18 +84,13 @@ public boolean kfAccountUploadHeadImg(String kfAccount, File imgFile)
10284 String url = API_URL_PREFIX + "/kfaccount/uploadheadimg?kf_account=" + kfAccount ;
10385 WxMediaUploadResult responseContent = this .wxMpService
10486 .execute (new MediaUploadRequestExecutor (), url , imgFile );
105- this .log .debug ("\n url:{}\n params:{}&file:{}\n response:{}" , url , kfAccount ,
106- imgFile .getAbsolutePath (),
107- responseContent );
10887 return true ;
10988 }
11089
11190 @ Override
11291 public boolean kfAccountDel (String kfAccount ) throws WxErrorException {
11392 String url = API_URL_PREFIX + "/kfaccount/del?kf_account=" + kfAccount ;
11493 String responseContent = this .wxMpService .get (url , null );
115- this .log .debug ("\n url:{}\n params:{}\n response:{}" , url , null ,
116- responseContent );
11794 return true ;
11895 }
11996
@@ -123,8 +100,6 @@ public boolean kfSessionCreate(String openid, String kfAccount)
123100 WxMpKfSessionRequest request = new WxMpKfSessionRequest (kfAccount , openid );
124101 String url = API_URL_PREFIX + "/kfsession/create" ;
125102 String responseContent = this .wxMpService .post (url , request .toJson ());
126- this .log .debug ("\n url:{}\n params:{}\n response:{}" , url , request .toJson (),
127- responseContent );
128103 return true ;
129104 }
130105
@@ -134,8 +109,6 @@ public boolean kfSessionClose(String openid, String kfAccount)
134109 WxMpKfSessionRequest request = new WxMpKfSessionRequest (kfAccount , openid );
135110 String url = API_URL_PREFIX + "/kfsession/close" ;
136111 String responseContent = this .wxMpService .post (url , request .toJson ());
137- this .log .debug ("\n url:{}\n params:{}\n response:{}" , url , request .toJson (),
138- responseContent );
139112 return true ;
140113 }
141114
@@ -144,8 +117,6 @@ public WxMpKfSessionGetResult kfSessionGet(String openid)
144117 throws WxErrorException {
145118 String url = API_URL_PREFIX + "/kfsession/getsession?openid=" + openid ;
146119 String responseContent = this .wxMpService .get (url , null );
147- this .log .debug ("\n url:{}\n params:{}\n response:{}" , url , null ,
148- responseContent );
149120 return WxMpKfSessionGetResult .fromJson (responseContent );
150121 }
151122
@@ -154,8 +125,6 @@ public WxMpKfSessionList kfSessionList(String kfAccount)
154125 throws WxErrorException {
155126 String url = API_URL_PREFIX + "/kfsession/getsessionlist?kf_account=" + kfAccount ;
156127 String responseContent = this .wxMpService .get (url , null );
157- this .log .debug ("\n url:{}\n params:{}\n response:{}" , url , null ,
158- responseContent );
159128 return WxMpKfSessionList .fromJson (responseContent );
160129 }
161130
@@ -164,8 +133,6 @@ public WxMpKfSessionWaitCaseList kfSessionGetWaitCase()
164133 throws WxErrorException {
165134 String url = API_URL_PREFIX + "/kfsession/getwaitcase" ;
166135 String responseContent = this .wxMpService .get (url , null );
167- this .log .debug ("\n url:{}\n params:{}\n response:{}" , url , null ,
168- responseContent );
169136 return WxMpKfSessionWaitCaseList .fromJson (responseContent );
170137 }
171138
@@ -188,8 +155,7 @@ public WxMpKfMsgList kfMsgList(Date startTime, Date endTime, Long msgId, Integer
188155 param .addProperty ("number" , number ); //number 每次获取条数,最多10000条
189156
190157 String responseContent = this .wxMpService .post (url , param .toString ());
191- this .log .debug ("\n url:{}\n params:{}\n response:{}" , url , param .toString (),
192- responseContent );
158+
193159 return WxMpKfMsgList .fromJson (responseContent );
194160 }
195161
0 commit comments