WiFiApi.cs 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119
  1. #region Apache License Version 2.0
  2. /*----------------------------------------------------------------
  3. Copyright 2019 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
  4. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
  5. except in compliance with the License. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software distributed under the
  8. License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  9. either express or implied. See the License for the specific language governing permissions
  10. and limitations under the License.
  11. Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md
  12. ----------------------------------------------------------------*/
  13. #endregion Apache License Version 2.0
  14. /*----------------------------------------------------------------
  15. Copyright (C) 2019 Senparc
  16. 文件名:WiFiApi.cs
  17. 文件功能描述:微信连WiFi接口
  18. 创建标识:Senparc - 20150709
  19. 修改标识:Senparc - 20160506
  20. 修改描述:添加“获取公众号连网URL”接口(GetConnectUrl)
  21. 修改标识:Senparc - 20160511
  22. 修改描述:WiFiApi.AddDevice去掉bssid参数
  23. 修改标识:Senparc - 20160520
  24. 修改描述:添加获取Wi-Fi门店列表接口,查询门店Wi-Fi信息接口,修改门店网络信息接口,清空门店网络及设备接口,
  25. 添加portal型设备接口,设置微信首页欢迎语接口,设置连网完成页接口,设置门店卡券投放信息接口,
  26. 查询门店卡券投放信息接口,第三方平台获取开插件wifi_token接口
  27. 修改标识:Senparc - 20160719
  28. 修改描述:增加其接口的异步方法
  29. 修改标识:Senparc - 20170707
  30. 修改描述:v14.5.1 完善异步方法async/await
  31. ----------------------------------------------------------------*/
  32. /*
  33. 官方文档:http://mp.weixin.qq.com/wiki/10/6232005bdc497f7cf8e19d4e843c70d2.html
  34. */
  35. using System.Threading.Tasks;
  36. using Senparc.NeuChar;
  37. using Senparc.Weixin.CommonAPIs;
  38. using Senparc.Weixin.Entities;
  39. using Senparc.Weixin.Helpers;
  40. using Senparc.Weixin.MP.AdvancedAPIs.WiFi;
  41. using Senparc.Weixin.MP.CommonAPIs;
  42. namespace Senparc.Weixin.MP.AdvancedAPIs
  43. {
  44. /// <summary>
  45. ///
  46. /// </summary>
  47. public static class WiFiApi
  48. {
  49. #region 同步方法
  50. /// <summary>
  51. /// 获取Wi-Fi门店列表
  52. /// </summary>
  53. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  54. /// <param name="pageIndex">分页下标,默认从1开始</param>
  55. /// <param name="pageSize">每页的个数,默认10个,最大20个</param>
  56. /// <param name="timeOut"></param>
  57. /// <returns></returns>
  58. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.ShopList", true)]
  59. public static WiFiShopListJsonResult ShopList(string accessTokenOrAppId, int pageIndex = 1, int pageSize = 10, int timeOut = Config.TIME_OUT)
  60. {
  61. return ApiHandlerWapper.TryCommonApi(accessToken =>
  62. {
  63. string urlFormat = Config.ApiMpHost + "/bizwifi/shop/list?access_token={0}";
  64. var data = new
  65. {
  66. pageindex = pageIndex,
  67. pagesize = pageSize
  68. };
  69. return CommonJsonSend.Send<WiFiShopListJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  70. }, accessTokenOrAppId);
  71. }
  72. /// <summary>
  73. /// 查询门店Wi-Fi信息
  74. /// </summary>
  75. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  76. /// <param name="shopId">门店ID</param>
  77. /// <param name="pageindex">分页下标,默认从1开始</param>
  78. /// <param name="pagesize">每页的个数,默认10个,最大20个</param>
  79. /// <param name="timeOut"></param>
  80. /// <returns></returns>
  81. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.ShopGet", true)]
  82. public static WiFiShopGetJsonResult ShopGet(string accessTokenOrAppId, long shopId, int pageindex = 1, int pagesize = 10, int timeOut = Config.TIME_OUT)
  83. {
  84. return ApiHandlerWapper.TryCommonApi(accessToken =>
  85. {
  86. string urlFormat = Config.ApiMpHost + "/bizwifi/shop/get?access_token={0}";
  87. var data = new
  88. {
  89. shop_id = shopId,
  90. pageindex = pageindex,
  91. pagesize = pagesize
  92. };
  93. return CommonJsonSend.Send<WiFiShopGetJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  94. }, accessTokenOrAppId);
  95. }
  96. /// <summary>
  97. /// 修改门店网络信息
  98. /// </summary>
  99. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  100. /// <param name="shopId">门店ID</param>
  101. /// <param name="oldSsid">需要修改的ssid,当门店下有多个ssid时,必填</param>
  102. /// <param name="ssid">无线网络设备的ssid。32个字符以内;ssid支持中文,但可能因设备兼容性问题导致显示乱码,或无法连接等问题,相关风险自行承担!当门店下是portal型设备时,ssid必填;当门店下是密码型设备时,ssid选填,且ssid和密码必须有一个以大写字母“WX”开头</param>
  103. /// <param name="timeOut"></param>
  104. /// <returns></returns>
  105. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.ShopUpdate", true)]
  106. public static WxJsonResult ShopUpdate(string accessTokenOrAppId, long shopId, string oldSsid, string ssid, int timeOut = Config.TIME_OUT)
  107. {
  108. return ApiHandlerWapper.TryCommonApi(accessToken =>
  109. {
  110. string urlFormat = Config.ApiMpHost + "/bizwifi/shop/update?access_token={0}";
  111. var data = new
  112. {
  113. shop_id = shopId,
  114. old_ssid = oldSsid,
  115. ssid = ssid
  116. };
  117. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  118. }, accessTokenOrAppId);
  119. }
  120. /// <summary>
  121. /// 清空门店网络及设备
  122. /// </summary>
  123. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  124. /// <param name="shopId">门店ID</param>
  125. /// <param name="ssid">无线网络设备的ssid。若不填写ssid,默认为清空门店下所有设备;填写ssid则为清空该ssid下的所有设备</param>
  126. /// <param name="timeOut"></param>
  127. /// <returns></returns>
  128. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.ShopClean", true)]
  129. public static WxJsonResult ShopClean(string accessTokenOrAppId, long shopId, string ssid, int timeOut = Config.TIME_OUT)
  130. {
  131. return ApiHandlerWapper.TryCommonApi(accessToken =>
  132. {
  133. string urlFormat = Config.ApiMpHost + "/bizwifi/shop/clean?access_token={0}";
  134. var data = new object();
  135. if (string.IsNullOrEmpty(ssid))
  136. {
  137. data = new
  138. {
  139. shop_id = shopId
  140. };
  141. }
  142. else
  143. {
  144. data = new
  145. {
  146. shop_id = shopId,
  147. ssid = ssid
  148. };
  149. }
  150. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  151. }, accessTokenOrAppId);
  152. }
  153. /// <summary>
  154. /// 添加设备
  155. /// </summary>
  156. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  157. /// <param name="shopId">门店ID</param>
  158. /// <param name="ssid">无线网络设备的ssid,不能包含中文字符,必需是“WX”开头(“WX”为大写字母)</param>
  159. /// <param name="password">无线网络设备的密码,大于8个字符,不能包含中文字符</param>
  160. ///// <param name="bssid">无线网络设备无线mac地址,格式冒号分隔,字符长度17个,并且字母小写,例如:00:1f:7a:ad:5c:a8</param>
  161. /// <param name="timeOut"></param>
  162. /// <returns></returns>
  163. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.AddDevice", true)]
  164. public static WxJsonResult AddDevice(string accessTokenOrAppId, long shopId, string ssid, string password,
  165. /*string bssid,*/ int timeOut = Config.TIME_OUT)
  166. {
  167. return ApiHandlerWapper.TryCommonApi(accessToken =>
  168. {
  169. string urlFormat = Config.ApiMpHost + "/bizwifi/device/add?access_token={0}";
  170. var data = new
  171. {
  172. shop_id = shopId,
  173. ssid = ssid,
  174. password = password,
  175. //bssid = bssid,
  176. };
  177. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  178. }, accessTokenOrAppId);
  179. }
  180. /// <summary>
  181. /// 添加portal型设备
  182. /// </summary>
  183. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  184. /// <param name="shopId">门店ID</param>
  185. /// <param name="ssid">无线网络设备的ssid,限30个字符以内。ssid支持中文,但可能因设备兼容性问题导致显示乱码,或无法连接等问题,相关风险自行承担!</param>
  186. /// <param name="reset">重置secretkey,false-不重置,true-重置,默认为false</param>
  187. /// <param name="timeOut"></param>
  188. /// <returns></returns>
  189. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.WifeRegister", true)]
  190. public static WiFiRegisterJsonResult WifeRegister(string accessTokenOrAppId, long shopId, string ssid, string reset,
  191. int timeOut = Config.TIME_OUT)
  192. {
  193. return ApiHandlerWapper.TryCommonApi(accessToken =>
  194. {
  195. string urlFormat = Config.ApiMpHost + "/bizwifi/apportal/register?access_token={0}";
  196. var data = new
  197. {
  198. shop_id = shopId,
  199. ssid = ssid,
  200. reset = reset,
  201. };
  202. return CommonJsonSend.Send<WiFiRegisterJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  203. }, accessTokenOrAppId);
  204. }
  205. /// <summary>
  206. /// 查询设备
  207. /// </summary>
  208. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  209. /// <param name="pageIndex">分页下标,默认从1开始</param>
  210. /// <param name="pageSize">每页的个数,默认10个,最大20个</param>
  211. /// <param name="shopId">根据门店id查询</param>
  212. /// <param name="timeOut"></param>
  213. /// <returns></returns>
  214. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.GetDeviceList", true)]
  215. public static GetDeviceListResult GetDeviceList(string accessTokenOrAppId, int pageIndex = 1, int pageSize = 10,
  216. long? shopId = null, int timeOut = Config.TIME_OUT)
  217. {
  218. return ApiHandlerWapper.TryCommonApi(accessToken =>
  219. {
  220. string urlFormat = Config.ApiMpHost + "/bizwifi/device/list?access_token={0}";
  221. object data = new object();
  222. if (shopId.HasValue)
  223. {
  224. data = new
  225. {
  226. pageindex = pageIndex,
  227. pagesize = pageSize,
  228. shop_id = shopId,
  229. };
  230. }
  231. else
  232. {
  233. data = new
  234. {
  235. pageindex = pageIndex,
  236. pagesize = pageSize
  237. };
  238. }
  239. return CommonJsonSend.Send<GetDeviceListResult>(accessToken, urlFormat, data, timeOut: timeOut);
  240. }, accessTokenOrAppId);
  241. }
  242. /// <summary>
  243. /// 删除设备
  244. /// </summary>
  245. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  246. /// <param name="bssid">需要删除的无线网络设备无线mac地址,格式冒号分隔,字符长度17个,并且字母小写,例如:00:1f:7a:ad:5c:a8</param>
  247. /// <param name="timeOut"></param>
  248. /// <returns></returns>
  249. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.DeleteDevice", true)]
  250. public static WxJsonResult DeleteDevice(string accessTokenOrAppId, string bssid, int timeOut = Config.TIME_OUT)
  251. {
  252. return ApiHandlerWapper.TryCommonApi(accessToken =>
  253. {
  254. string urlFormat = Config.ApiMpHost + "/bizwifi/device/delete?access_token={0}";
  255. var data = new
  256. {
  257. bssid = bssid
  258. };
  259. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  260. }, accessTokenOrAppId);
  261. }
  262. /// <summary>
  263. /// 获取物料二维码
  264. /// </summary>
  265. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  266. /// <param name="shopId"></param>
  267. /// <param name="imgId"></param>
  268. /// <param name="timeOut"></param>
  269. /// <returns></returns>
  270. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.GetQrcode", true)]
  271. public static GetQrcodeResult GetQrcode(string accessTokenOrAppId, long shopId, int imgId,
  272. int timeOut = Config.TIME_OUT)
  273. {
  274. return ApiHandlerWapper.TryCommonApi(accessToken =>
  275. {
  276. string urlFormat = Config.ApiMpHost + "/bizwifi/qrcode/get?access_token={0}";
  277. var data = new
  278. {
  279. shop_id = shopId,
  280. img_id = imgId
  281. };
  282. return CommonJsonSend.Send<GetQrcodeResult>(accessToken, urlFormat, data, timeOut: timeOut);
  283. }, accessTokenOrAppId);
  284. }
  285. /// <summary>
  286. /// 设置商家主页
  287. /// 传入自定义链接则是使用自定义链接,否则使用默认模板
  288. /// </summary>
  289. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  290. /// <param name="shopId">门店ID</param>
  291. /// <param name="url">自定义链接(选择传入)</param>
  292. /// <param name="timeOut"></param>
  293. /// <returns></returns>
  294. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.SetHomePage", true)]
  295. public static WxJsonResult SetHomePage(string accessTokenOrAppId, long shopId, string url = null,
  296. int timeOut = Config.TIME_OUT)
  297. {
  298. return ApiHandlerWapper.TryCommonApi(accessToken =>
  299. {
  300. string urlFormat = Config.ApiMpHost + "/bizwifi/homepage/set?access_token={0}";
  301. var data = new object();
  302. if (string.IsNullOrEmpty(url))
  303. {
  304. data = new
  305. {
  306. shop_id = shopId,
  307. template_id = 0
  308. };
  309. }
  310. else
  311. {
  312. data = new
  313. {
  314. shop_id = shopId,
  315. template_id = 1,
  316. @struct = new
  317. {
  318. url = url
  319. }
  320. };
  321. }
  322. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  323. }, accessTokenOrAppId);
  324. }
  325. /// <summary>
  326. /// 查询商家主页
  327. /// </summary>
  328. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  329. /// <param name="shopId">查询的门店id</param>
  330. /// <param name="timeOut"></param>
  331. /// <returns></returns>
  332. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.GetHomePage", true)]
  333. public static GetHomePageResult GetHomePage(string accessTokenOrAppId, long shopId,
  334. int timeOut = Config.TIME_OUT)
  335. {
  336. return ApiHandlerWapper.TryCommonApi(accessToken =>
  337. {
  338. string urlFormat = Config.ApiMpHost + "/bizwifi/homepage/get?access_token={0}";
  339. var data = new
  340. {
  341. shop_id = shopId,
  342. };
  343. return CommonJsonSend.Send<GetHomePageResult>(accessToken, urlFormat, data, timeOut: timeOut);
  344. }, accessTokenOrAppId);
  345. }
  346. /// <summary>
  347. /// 设置微信首页欢迎语
  348. /// </summary>
  349. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  350. /// <param name="shopId">门店ID</param>
  351. /// <param name="barType">微信首页欢迎语的文本内容:0--欢迎光临+公众号名称;1--欢迎光临+门店名称;2--已连接+公众号名称+WiFi;3--已连接+门店名称+Wi-Fi。</param>
  352. /// <param name="timeOut"></param>
  353. /// <returns></returns>
  354. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.SetBar", true)]
  355. public static WxJsonResult SetBar(string accessTokenOrAppId, long shopId, int barType,
  356. int timeOut = Config.TIME_OUT)
  357. {
  358. return ApiHandlerWapper.TryCommonApi(accessToken =>
  359. {
  360. string urlFormat = Config.ApiMpHost + "/bizwifi/bar/set?access_token={0}";
  361. var data = new
  362. {
  363. shop_id = shopId,
  364. bar_type = barType
  365. };
  366. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  367. }, accessTokenOrAppId);
  368. }
  369. /// <summary>
  370. /// 设置连网完成页
  371. /// </summary>
  372. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  373. /// <param name="shopId">门店ID</param>
  374. /// <param name="finishPageUrl">连网完成页URL。</param>
  375. /// <param name="timeOut"></param>
  376. /// <returns></returns>
  377. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.SetFinishpage", true)]
  378. public static WxJsonResult SetFinishpage(string accessTokenOrAppId, long shopId, string finishPageUrl,
  379. int timeOut = Config.TIME_OUT)
  380. {
  381. return ApiHandlerWapper.TryCommonApi(accessToken =>
  382. {
  383. string urlFormat = Config.ApiMpHost + "/bizwifi/finishpage/set?access_token={0}";
  384. var data = new
  385. {
  386. shop_id = shopId,
  387. finishpage_url = finishPageUrl
  388. };
  389. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  390. }, accessTokenOrAppId);
  391. }
  392. /// <summary>
  393. /// 数据统计
  394. /// </summary>
  395. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  396. /// <param name="beginDate">起始日期时间,格式yyyy-mm-dd,最长时间跨度为30天</param>
  397. /// <param name="endDate">结束日期时间戳,格式yyyy-mm-dd,最长时间跨度为30天</param>
  398. /// <param name="shopId">按门店ID搜索,-1为总统计</param>
  399. /// <param name="timeOut"></param>
  400. /// <returns></returns>
  401. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.GetStatistics", true)]
  402. public static GetStatisticsResult GetStatistics(string accessTokenOrAppId, string beginDate, string endDate,
  403. long shopId = -1,
  404. int timeOut = Config.TIME_OUT)
  405. {
  406. return ApiHandlerWapper.TryCommonApi(accessToken =>
  407. {
  408. string urlFormat = Config.ApiMpHost + "/bizwifi/statistics/list?access_token={0}";
  409. var data = new
  410. {
  411. begin_date = beginDate,
  412. end_date = endDate,
  413. shop_id = shopId,
  414. };
  415. return CommonJsonSend.Send<GetStatisticsResult>(accessToken, urlFormat, data, timeOut: timeOut);
  416. }, accessTokenOrAppId);
  417. }
  418. /// <summary>
  419. /// 设置门店卡券投放信息
  420. /// </summary>
  421. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  422. /// <param name="shopId">门店ID,可设置为0,表示所有门店</param>
  423. /// <param name="cardId">卡券ID</param>
  424. /// <param name="cardDescribe">卡券描述,不能超过18个字符</param>
  425. ///<param name="starTime">卡券投放开始时间(单位是秒)</param>
  426. /// <param name="endTime">卡券投放结束时间(单位是秒)注:不能超过卡券的有效期时间</param>
  427. /// <param name="cardQuantity">卡券库存</param>
  428. /// <param name="timeOut"></param>
  429. /// <returns></returns>
  430. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.SetCouponPut", true)]
  431. public static WxJsonResult SetCouponPut(string accessTokenOrAppId, long shopId, string cardId, string cardDescribe, string starTime, string endTime, int cardQuantity,
  432. int timeOut = Config.TIME_OUT)
  433. {
  434. return ApiHandlerWapper.TryCommonApi(accessToken =>
  435. {
  436. string urlFormat = Config.ApiMpHost + "/bizwifi/couponput/set?access_token={0}";
  437. var data = new
  438. {
  439. shop_id = shopId,
  440. card_id = cardId,
  441. card_describe = cardDescribe,
  442. start_time = starTime,
  443. end_time = endTime,
  444. card_quantity = cardQuantity
  445. };
  446. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  447. }, accessTokenOrAppId);
  448. }
  449. /// <summary>
  450. /// 查询门店卡券投放信息
  451. /// </summary>
  452. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  453. /// <param name="shopId">门店ID,可设置为0,表示所有门店</param>
  454. /// <param name="timeOut"></param>
  455. /// <returns></returns>
  456. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.GetCouponPut", true)]
  457. public static WiFiGetCouponPutJsonResult GetCouponPut(string accessTokenOrAppId, long shopId, int timeOut = Config.TIME_OUT)
  458. {
  459. return ApiHandlerWapper.TryCommonApi(accessToken =>
  460. {
  461. string urlFormat = Config.ApiMpHost + "/bizwifi/couponput/get?access_token={0}";
  462. var data = new
  463. {
  464. shop_id = shopId
  465. };
  466. return CommonJsonSend.Send<WiFiGetCouponPutJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  467. }, accessTokenOrAppId);
  468. }
  469. /// <summary>
  470. /// 获取公众号连网URL
  471. /// </summary>
  472. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  473. /// <returns></returns>
  474. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.GetConnectUrl", true)]
  475. public static WiFiConnectUrlResultJson GetConnectUrl(string accessTokenOrAppId)
  476. {
  477. return ApiHandlerWapper.TryCommonApi(accessToken =>
  478. {
  479. string urlFormat = Config.ApiMpHost + "/bizwifi/account/get_connecturl?access_token={0}";
  480. return CommonJsonSend.Send<WiFiConnectUrlResultJson>(accessToken, urlFormat, null,
  481. CommonJsonSendType.GET);
  482. }, accessTokenOrAppId);
  483. }
  484. /// <summary>
  485. /// 第三方平台获取开插件wifi_token
  486. /// </summary>
  487. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  488. /// <param name="callBackUrl">回调URL,开通插件成功后的跳转页面。注:该参数域名必须与跳转进开通插件页面的页面域名保持一致,建议均采用第三方平台域名。</param>
  489. /// <param name="timeOut"></param>
  490. /// <returns></returns>
  491. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.OpenPluginToken", true)]
  492. public static WiFiOpenPluginTokenJsonResult OpenPluginToken(string accessTokenOrAppId, string callBackUrl, int timeOut = Config.TIME_OUT)
  493. {
  494. return ApiHandlerWapper.TryCommonApi(accessToken =>
  495. {
  496. string urlFormat = Config.ApiMpHost + "/bizwifi/openplugin/token?access_token={0}";
  497. var data = new
  498. {
  499. callback_url = callBackUrl
  500. };
  501. return CommonJsonSend.Send<WiFiOpenPluginTokenJsonResult>(accessToken, urlFormat, data, CommonJsonSendType.GET, timeOut: timeOut);
  502. }, accessTokenOrAppId);
  503. }
  504. #endregion
  505. #if !NET35 && !NET40
  506. #region 异步方法
  507. /// <summary>
  508. /// 【异步方法】获取Wi-Fi门店列表
  509. /// </summary>
  510. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  511. /// <param name="pageIndex">分页下标,默认从1开始</param>
  512. /// <param name="pageSize">每页的个数,默认10个,最大20个</param>
  513. /// <param name="timeOut"></param>
  514. /// <returns></returns>
  515. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.ShopListAsync", true)]
  516. public static async Task<WiFiShopListJsonResult> ShopListAsync(string accessTokenOrAppId, int pageIndex = 1, int pageSize = 10, int timeOut = Config.TIME_OUT)
  517. {
  518. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  519. {
  520. string urlFormat = Config.ApiMpHost + "/bizwifi/shop/list?access_token={0}";
  521. var data = new
  522. {
  523. pageindex = pageIndex,
  524. pagesize = pageSize
  525. };
  526. return await Senparc .Weixin .CommonAPIs .CommonJsonSend.SendAsync<WiFiShopListJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  527. }, accessTokenOrAppId);
  528. }
  529. /// <summary>
  530. /// 【异步方法】查询门店Wi-Fi信息
  531. /// </summary>
  532. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  533. /// <param name="shopId">门店ID</param>
  534. /// <param name="pageindex">分页下标,默认从1开始</param>
  535. /// <param name="pagesize">每页的个数,默认10个,最大20个</param>
  536. /// <param name="timeOut"></param>
  537. /// <returns></returns>
  538. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.ShopGetAsync", true)]
  539. public static async Task<WiFiShopGetJsonResult> ShopGetAsync(string accessTokenOrAppId, long shopId, int pageindex = 1, int pagesize = 10, int timeOut = Config.TIME_OUT)
  540. {
  541. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  542. {
  543. string urlFormat = Config.ApiMpHost + "/bizwifi/shop/get?access_token={0}";
  544. var data = new
  545. {
  546. shop_id = shopId,
  547. pageindex = pageindex,
  548. pagesize = pagesize
  549. };
  550. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WiFiShopGetJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  551. }, accessTokenOrAppId);
  552. }
  553. /// <summary>
  554. /// 【异步方法】修改门店网络信息
  555. /// </summary>
  556. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  557. /// <param name="shopId">门店ID</param>
  558. /// <param name="oldSsid">需要修改的ssid,当门店下有多个ssid时,必填</param>
  559. /// <param name="ssid">无线网络设备的ssid。32个字符以内;ssid支持中文,但可能因设备兼容性问题导致显示乱码,或无法连接等问题,相关风险自行承担!当门店下是portal型设备时,ssid必填;当门店下是密码型设备时,ssid选填,且ssid和密码必须有一个以大写字母“WX”开头</param>
  560. /// <param name="timeOut"></param>
  561. /// <returns></returns>
  562. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.ShopUpdateAsync", true)]
  563. public static async Task<WxJsonResult> ShopUpdateAsync(string accessTokenOrAppId, long shopId, string oldSsid, string ssid, int timeOut = Config.TIME_OUT)
  564. {
  565. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  566. {
  567. string urlFormat = Config.ApiMpHost + "/bizwifi/shop/update?access_token={0}";
  568. var data = new
  569. {
  570. shop_id = shopId,
  571. old_ssid = oldSsid,
  572. ssid = ssid
  573. };
  574. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  575. }, accessTokenOrAppId);
  576. }
  577. /// <summary>
  578. /// 【异步方法】清空门店网络及设备
  579. /// </summary>
  580. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  581. /// <param name="shopId">门店ID</param>
  582. /// <param name="ssid">无线网络设备的ssid。若不填写ssid,默认为清空门店下所有设备;填写ssid则为清空该ssid下的所有设备</param>
  583. /// <param name="timeOut"></param>
  584. /// <returns></returns>
  585. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.ShopCleanAsync", true)]
  586. public static async Task<WxJsonResult> ShopCleanAsync(string accessTokenOrAppId, long shopId, string ssid, int timeOut = Config.TIME_OUT)
  587. {
  588. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  589. {
  590. string urlFormat = Config.ApiMpHost + "/bizwifi/shop/clean?access_token={0}";
  591. var data = new object();
  592. if (string.IsNullOrEmpty(ssid))
  593. {
  594. data = new
  595. {
  596. shop_id = shopId
  597. };
  598. }
  599. else
  600. {
  601. data = new
  602. {
  603. shop_id = shopId,
  604. ssid = ssid
  605. };
  606. }
  607. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  608. }, accessTokenOrAppId);
  609. }
  610. /// <summary>
  611. /// 【异步方法】添加设备
  612. /// </summary>
  613. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  614. /// <param name="shopId">门店ID</param>
  615. /// <param name="ssid">无线网络设备的ssid,不能包含中文字符,必需是“WX”开头(“WX”为大写字母)</param>
  616. /// <param name="password">无线网络设备的密码,大于8个字符,不能包含中文字符</param>
  617. ///// <param name="bssid">无线网络设备无线mac地址,格式冒号分隔,字符长度17个,并且字母小写,例如:00:1f:7a:ad:5c:a8</param>
  618. /// <param name="timeOut"></param>
  619. /// <returns></returns>
  620. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.AddDeviceAsync", true)]
  621. public static async Task<WxJsonResult> AddDeviceAsync(string accessTokenOrAppId, long shopId, string ssid, string password,
  622. /*string bssid,*/ int timeOut = Config.TIME_OUT)
  623. {
  624. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  625. {
  626. string urlFormat = Config.ApiMpHost + "/bizwifi/device/add?access_token={0}";
  627. var data = new
  628. {
  629. shop_id = shopId,
  630. ssid = ssid,
  631. password = password,
  632. //bssid = bssid,
  633. };
  634. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  635. }, accessTokenOrAppId);
  636. }
  637. /// <summary>
  638. /// 【异步方法】添加portal型设备
  639. /// </summary>
  640. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  641. /// <param name="shopId">门店ID</param>
  642. /// <param name="ssid">无线网络设备的ssid,限30个字符以内。ssid支持中文,但可能因设备兼容性问题导致显示乱码,或无法连接等问题,相关风险自行承担!</param>
  643. /// <param name="reset">重置secretkey,false-不重置,true-重置,默认为false</param>
  644. /// <param name="timeOut"></param>
  645. /// <returns></returns>
  646. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.WifeRegisterAsync", true)]
  647. public static async Task<WiFiRegisterJsonResult> WifeRegisterAsync(string accessTokenOrAppId, long shopId, string ssid, string reset,
  648. int timeOut = Config.TIME_OUT)
  649. {
  650. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  651. {
  652. string urlFormat = Config.ApiMpHost + "/bizwifi/apportal/register?access_token={0}";
  653. var data = new
  654. {
  655. shop_id = shopId,
  656. ssid = ssid,
  657. reset = reset,
  658. };
  659. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WiFiRegisterJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  660. }, accessTokenOrAppId);
  661. }
  662. /// <summary>
  663. /// 【异步方法】查询设备
  664. /// </summary>
  665. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  666. /// <param name="pageIndex">分页下标,默认从1开始</param>
  667. /// <param name="pageSize">每页的个数,默认10个,最大20个</param>
  668. /// <param name="shopId">根据门店id查询</param>
  669. /// <param name="timeOut"></param>
  670. /// <returns></returns>
  671. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.GetDeviceListAsync", true)]
  672. public static async Task<GetDeviceListResult> GetDeviceListAsync(string accessTokenOrAppId, int pageIndex = 1, int pageSize = 10,
  673. long? shopId = null, int timeOut = Config.TIME_OUT)
  674. {
  675. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  676. {
  677. string urlFormat = Config.ApiMpHost + "/bizwifi/device/list?access_token={0}";
  678. object data = new object();
  679. if (shopId.HasValue)
  680. {
  681. data = new
  682. {
  683. pageindex = pageIndex,
  684. pagesize = pageSize,
  685. shop_id = shopId,
  686. };
  687. }
  688. else
  689. {
  690. data = new
  691. {
  692. pageindex = pageIndex,
  693. pagesize = pageSize
  694. };
  695. }
  696. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetDeviceListResult>(accessToken, urlFormat, data, timeOut: timeOut);
  697. }, accessTokenOrAppId);
  698. }
  699. /// <summary>
  700. /// 【异步方法】删除设备
  701. /// </summary>
  702. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  703. /// <param name="bssid">需要删除的无线网络设备无线mac地址,格式冒号分隔,字符长度17个,并且字母小写,例如:00:1f:7a:ad:5c:a8</param>
  704. /// <param name="timeOut"></param>
  705. /// <returns></returns>
  706. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.DeleteDeviceAsync", true)]
  707. public static async Task<WxJsonResult> DeleteDeviceAsync(string accessTokenOrAppId, string bssid, int timeOut = Config.TIME_OUT)
  708. {
  709. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  710. {
  711. string urlFormat = Config.ApiMpHost + "/bizwifi/device/delete?access_token={0}";
  712. var data = new
  713. {
  714. bssid = bssid
  715. };
  716. return await Senparc .Weixin .CommonAPIs .CommonJsonSend.SendAsync<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  717. }, accessTokenOrAppId);
  718. }
  719. /// <summary>
  720. /// 【异步方法】获取物料二维码
  721. /// </summary>
  722. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  723. /// <param name="shopId"></param>
  724. /// <param name="imgId"></param>
  725. /// <param name="timeOut"></param>
  726. /// <returns></returns>
  727. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.GetQrcodeAsync", true)]
  728. public static async Task<GetQrcodeResult> GetQrcodeAsync(string accessTokenOrAppId, long shopId, int imgId,
  729. int timeOut = Config.TIME_OUT)
  730. {
  731. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  732. {
  733. string urlFormat = Config.ApiMpHost + "/bizwifi/qrcode/get?access_token={0}";
  734. var data = new
  735. {
  736. shop_id = shopId,
  737. img_id = imgId
  738. };
  739. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetQrcodeResult>(accessToken, urlFormat, data, timeOut: timeOut);
  740. }, accessTokenOrAppId);
  741. }
  742. /// <summary>
  743. /// 【异步方法】设置商家主页
  744. /// 传入自定义链接则是使用自定义链接,否则使用默认模板
  745. /// </summary>
  746. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  747. /// <param name="shopId">门店ID</param>
  748. /// <param name="url">自定义链接(选择传入)</param>
  749. /// <param name="timeOut"></param>
  750. /// <returns></returns>
  751. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.SetHomePageAsync", true)]
  752. public static async Task<WxJsonResult> SetHomePageAsync(string accessTokenOrAppId, long shopId, string url = null,
  753. int timeOut = Config.TIME_OUT)
  754. {
  755. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  756. {
  757. string urlFormat = Config.ApiMpHost + "/bizwifi/homepage/set?access_token={0}";
  758. var data = new object();
  759. if (string.IsNullOrEmpty(url))
  760. {
  761. data = new
  762. {
  763. shop_id = shopId,
  764. template_id = 0
  765. };
  766. }
  767. else
  768. {
  769. data = new
  770. {
  771. shop_id = shopId,
  772. template_id = 1,
  773. @struct = new
  774. {
  775. url = url
  776. }
  777. };
  778. }
  779. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  780. }, accessTokenOrAppId);
  781. }
  782. /// <summary>
  783. ///【异步方法】 查询商家主页
  784. /// </summary>
  785. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  786. /// <param name="shopId">查询的门店id</param>
  787. /// <param name="timeOut"></param>
  788. /// <returns></returns>
  789. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.GetHomePageaAsync", true)]
  790. public static async Task<GetHomePageResult> GetHomePageaAsync(string accessTokenOrAppId, long shopId,
  791. int timeOut = Config.TIME_OUT)
  792. {
  793. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  794. {
  795. string urlFormat = Config.ApiMpHost + "/bizwifi/homepage/get?access_token={0}";
  796. var data = new
  797. {
  798. shop_id = shopId,
  799. };
  800. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetHomePageResult>(accessToken, urlFormat, data, timeOut: timeOut);
  801. }, accessTokenOrAppId);
  802. }
  803. /// <summary>
  804. ///【异步方法】 设置微信首页欢迎语
  805. /// </summary>
  806. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  807. /// <param name="shopId">门店ID</param>
  808. /// <param name="barType">微信首页欢迎语的文本内容:0--欢迎光临+公众号名称;1--欢迎光临+门店名称;2--已连接+公众号名称+WiFi;3--已连接+门店名称+Wi-Fi。</param>
  809. /// <param name="timeOut"></param>
  810. /// <returns></returns>
  811. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.SetBarAsync", true)]
  812. public static async Task<WxJsonResult> SetBarAsync(string accessTokenOrAppId, long shopId, int barType,
  813. int timeOut = Config.TIME_OUT)
  814. {
  815. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  816. {
  817. string urlFormat = Config.ApiMpHost + "/bizwifi/bar/set?access_token={0}";
  818. var data = new
  819. {
  820. shop_id = shopId,
  821. bar_type = barType
  822. };
  823. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  824. }, accessTokenOrAppId);
  825. }
  826. /// <summary>
  827. ///【异步方法】 设置连网完成页
  828. /// </summary>
  829. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  830. /// <param name="shopId">门店ID</param>
  831. /// <param name="finishPageUrl">连网完成页URL。</param>
  832. /// <param name="timeOut"></param>
  833. /// <returns></returns>
  834. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.SetFinishpageAsync", true)]
  835. public static async Task<WxJsonResult> SetFinishpageAsync(string accessTokenOrAppId, long shopId, string finishPageUrl,
  836. int timeOut = Config.TIME_OUT)
  837. {
  838. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  839. {
  840. string urlFormat = Config.ApiMpHost + "/bizwifi/finishpage/set?access_token={0}";
  841. var data = new
  842. {
  843. shop_id = shopId,
  844. finishpage_url = finishPageUrl
  845. };
  846. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  847. }, accessTokenOrAppId);
  848. }
  849. /// <summary>
  850. /// 【异步方法】数据统计
  851. /// </summary>
  852. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  853. /// <param name="beginDate">起始日期时间,格式yyyy-mm-dd,最长时间跨度为30天</param>
  854. /// <param name="endDate">结束日期时间戳,格式yyyy-mm-dd,最长时间跨度为30天</param>
  855. /// <param name="shopId">按门店ID搜索,-1为总统计</param>
  856. /// <param name="timeOut"></param>
  857. /// <returns></returns>
  858. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.GetStatisticsAsync", true)]
  859. public static async Task<GetStatisticsResult> GetStatisticsAsync(string accessTokenOrAppId, string beginDate, string endDate,
  860. long shopId = -1,
  861. int timeOut = Config.TIME_OUT)
  862. {
  863. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  864. {
  865. string urlFormat = Config.ApiMpHost + "/bizwifi/statistics/list?access_token={0}";
  866. var data = new
  867. {
  868. begin_date = beginDate,
  869. end_date = endDate,
  870. shop_id = shopId,
  871. };
  872. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetStatisticsResult>(accessToken, urlFormat, data, timeOut: timeOut);
  873. }, accessTokenOrAppId);
  874. }
  875. /// <summary>
  876. ///【异步方法】 设置门店卡券投放信息
  877. /// </summary>
  878. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  879. /// <param name="shopId">门店ID,可设置为0,表示所有门店</param>
  880. /// <param name="cardId">卡券ID</param>
  881. /// <param name="cardDescribe">卡券描述,不能超过18个字符</param>
  882. ///<param name="starTime">卡券投放开始时间(单位是秒)</param>
  883. /// <param name="endTime">卡券投放结束时间(单位是秒)注:不能超过卡券的有效期时间</param>
  884. /// <param name="cardQuantity">卡券库存</param>
  885. /// <param name="timeOut"></param>
  886. /// <returns></returns>
  887. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.SetCouponPutAsync", true)]
  888. public static async Task<WxJsonResult> SetCouponPutAsync(string accessTokenOrAppId, long shopId, string cardId, string cardDescribe, string starTime, string endTime, int cardQuantity,
  889. int timeOut = Config.TIME_OUT)
  890. {
  891. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  892. {
  893. string urlFormat = Config.ApiMpHost + "/bizwifi/couponput/set?access_token={0}";
  894. var data = new
  895. {
  896. shop_id = shopId,
  897. card_id = cardId,
  898. card_describe = cardDescribe,
  899. start_time = starTime,
  900. end_time = endTime,
  901. card_quantity = cardQuantity
  902. };
  903. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  904. }, accessTokenOrAppId);
  905. }
  906. /// <summary>
  907. /// 【异步方法】查询门店卡券投放信息
  908. /// </summary>
  909. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  910. /// <param name="shopId">门店ID,可设置为0,表示所有门店</param>
  911. /// <param name="timeOut"></param>
  912. /// <returns></returns>
  913. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.GetCouponPutAsync", true)]
  914. public static async Task<WiFiGetCouponPutJsonResult> GetCouponPutAsync(string accessTokenOrAppId, long shopId, int timeOut = Config.TIME_OUT)
  915. {
  916. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  917. {
  918. string urlFormat = Config.ApiMpHost + "/bizwifi/couponput/get?access_token={0}";
  919. var data = new
  920. {
  921. shop_id = shopId
  922. };
  923. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WiFiGetCouponPutJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  924. }, accessTokenOrAppId);
  925. }
  926. /// <summary>
  927. ///【异步方法】 获取公众号连网URL
  928. /// </summary>
  929. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  930. /// <returns></returns>
  931. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.GetConnectUrlAsync", true)]
  932. public static async Task<WiFiConnectUrlResultJson> GetConnectUrlAsync(string accessTokenOrAppId)
  933. {
  934. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  935. {
  936. string urlFormat = Config.ApiMpHost + "/bizwifi/account/get_connecturl?access_token={0}";
  937. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WiFiConnectUrlResultJson>(accessToken, urlFormat, null,
  938. CommonJsonSendType.GET);
  939. }, accessTokenOrAppId);
  940. }
  941. /// <summary>
  942. /// 【异步方法】第三方平台获取开插件wifi_token
  943. /// </summary>
  944. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  945. /// <param name="callBackUrl">回调URL,开通插件成功后的跳转页面。注:该参数域名必须与跳转进开通插件页面的页面域名保持一致,建议均采用第三方平台域名。</param>
  946. /// <param name="timeOut"></param>
  947. /// <returns></returns>
  948. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "WiFiApi.OpenPluginTokenAsync", true)]
  949. public static async Task<WiFiOpenPluginTokenJsonResult> OpenPluginTokenAsync(string accessTokenOrAppId, string callBackUrl, int timeOut = Config.TIME_OUT)
  950. {
  951. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  952. {
  953. string urlFormat = Config.ApiMpHost + "/bizwifi/openplugin/token?access_token={0}";
  954. var data = new
  955. {
  956. callback_url = callBackUrl
  957. };
  958. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WiFiOpenPluginTokenJsonResult>(accessToken, urlFormat, data, CommonJsonSendType.GET, timeOut: timeOut);
  959. }, accessTokenOrAppId);
  960. }
  961. #endregion
  962. #endif
  963. }
  964. }