ShakeAroundApi.cs 106 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169
  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. 文件名:ShakeAroundApi.cs
  17. 文件功能描述:摇一摇周边接口
  18. 创建标识:Senparc - 20150512
  19. 修改标识:Senparc - 20160216
  20. 修改描述:添加 查询设备与页面的关联关系 接口
  21. 修改标识:Senparc - 20160424
  22. 修改描述:v13.7.5 添加 ShakeAroundApi.DeviceApplyStatus 接口
  23. 修改标识:Senparc - 20160520
  24. 修改描述:添加批量查询页面统计数据接口,新增分组接口,编辑分组信息接口,删除分组接口,查询分组列表接口,
  25. 查询分组详情接口,添加设备到分组接口,从分组中移除设备接口,创建红包活动接口,录入红包信息接口,
  26. 设置红包活动抽奖开关接口,红包查询接口
  27. 修改标识:Senparc - 20160520
  28. 修改描述:修改批量查询设备统计数据接口
  29. 修改标识:Senparc 20160719
  30. 修改描述:增加其接口的异步方法
  31. 修改标识:Senparc 20160823
  32. 修改描述:modify DeletePage,DeletePageAsync中的方法中的参数,即longn []pageIds改为long pageId
  33. 修改标识:Senparc 20170110
  34. 修改描述:将lastSeen参数调整为long类型
  35. 修改标识:Senparc 20170509
  36. 修改描述:v14.4.7 修改 GroupGetAdddevice 数据结构
  37. 修改标识:Senparc - 20170707
  38. 修改描述:v14.5.1 完善异步方法async/await
  39. 修改标识:Senparc - 20180522
  40. 修改描述:v14.5.1 完善异步方法async/await
  41. 修改标识:Senparc - 20190129
  42. 修改描述:统一 CommonJsonSend.Send<T>() 方法请求接口
  43. ----------------------------------------------------------------*/
  44. /*
  45. API:http://mp.weixin.qq.com/wiki/15/b9e012f917e3484b7ed02771156411f3.html
  46. */
  47. using System;
  48. using System.Collections.Generic;
  49. using System.Threading.Tasks;
  50. using Senparc.Weixin.Entities;
  51. using Senparc.CO2NET.HttpUtility;
  52. using Senparc.Weixin.MP.AdvancedAPIs.ShakeAround;
  53. using Senparc.Weixin.MP.CommonAPIs;
  54. using System.Linq;
  55. using Senparc.CO2NET.Extensions;
  56. using Senparc.NeuChar;
  57. using Senparc.Weixin.CommonAPIs;
  58. namespace Senparc.Weixin.MP.AdvancedAPIs
  59. {
  60. /// <summary>
  61. /// 摇一摇周边接口
  62. /// </summary>
  63. public static class ShakeAroundApi
  64. {
  65. #region 同步方法
  66. /// <summary>
  67. /// 申请开通功能
  68. /// </summary>
  69. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  70. /// <param name="data"></param>
  71. /// <param name="industry_Id"></param>
  72. /// <param name="timeOut"></param>
  73. /// <returns></returns>
  74. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.Register", true)]
  75. public static RegisterResultJson Register(string accessTokenOrAppId, RegisterData data, IndustryId industry_Id, int timeOut = Config.TIME_OUT)
  76. {
  77. return ApiHandlerWapper.TryCommonApi(accessToken =>
  78. {
  79. string url = string.Format(Config.ApiMpHost + "/shakearound/account/register?access_token={0}", accessToken.AsUrlData());
  80. data.industry_id = RegisterData.ConvertIndustryId(industry_Id);
  81. return CommonJsonSend.Send<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  82. }, accessTokenOrAppId);
  83. }
  84. /// <summary>
  85. /// 查询审核状态
  86. /// </summary>
  87. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  88. /// <returns></returns>
  89. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GetAuditStatus", true)]
  90. public static GetAuditStatusResultJson GetAuditStatus(string accessTokenOrAppId)
  91. {
  92. return ApiHandlerWapper.TryCommonApi(accessToken =>
  93. {
  94. string url = string.Format(Config.ApiMpHost + "/shakearound/account/auditstatus?access_token={0}", accessToken.AsUrlData());
  95. return CommonJsonSend.Send<GetAuditStatusResultJson>(null, url, null, CommonJsonSendType.GET);
  96. }, accessTokenOrAppId);
  97. }
  98. /// <summary>
  99. /// 申请设备ID
  100. /// </summary>
  101. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  102. /// <param name="quantity">申请的设备ID的数量,单次新增设备超过500个,需走人工审核流程</param>
  103. /// <param name="applyReason">申请理由,不超过100个字</param>
  104. /// <param name="comment">备注,不超过15个汉字或30个英文字母</param>
  105. /// <param name="poiId">设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。</param>
  106. /// <param name="timeOut"></param>
  107. /// <returns></returns>
  108. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceApply", true)]
  109. public static DeviceApplyResultJson DeviceApply(string accessTokenOrAppId, int quantity, string applyReason, string comment = null, long? poiId = null, int timeOut = Config.TIME_OUT)
  110. {
  111. return ApiHandlerWapper.TryCommonApi(accessToken =>
  112. {
  113. string url = string.Format(Config.ApiMpHost + "/shakearound/device/applyid?access_token={0}", accessToken.AsUrlData());
  114. var data = new
  115. {
  116. quantity = quantity,
  117. apply_reason = applyReason,
  118. comment = comment,
  119. poi_id = poiId
  120. };
  121. return CommonJsonSend.Send<DeviceApplyResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  122. }, accessTokenOrAppId);
  123. }
  124. /// <summary>
  125. /// 查询设备ID申请审核状态
  126. /// 接口说明 查询设备ID申请的审核状态。若单次申请的设备ID数量小于等于500个,系统会进行快速审核;若单次申请的设备ID数量大于500个,则在三个工作日内完成审核。
  127. /// </summary>
  128. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  129. /// <param name="appId">批次ID,申请设备ID时所返回的批次ID</param>
  130. /// <param name="timeOut"></param>
  131. /// <returns></returns>
  132. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceApplyStatus", true)]
  133. public static GetDeviceStatusResultJson DeviceApplyStatus(string accessTokenOrAppId, long appId, int timeOut = Config.TIME_OUT)
  134. {
  135. return ApiHandlerWapper.TryCommonApi(accessToken =>
  136. {
  137. string url = string.Format(Config.ApiMpHost + "/shakearound/device/applystatus?access_token={0}", accessToken.AsUrlData());
  138. var data = new
  139. {
  140. apply_id = appId,
  141. };
  142. return CommonJsonSend.Send<GetDeviceStatusResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  143. }, accessTokenOrAppId);
  144. }
  145. /// <summary>
  146. /// 编辑设备信息
  147. /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
  148. /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息。
  149. /// </summary>
  150. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  151. /// <param name="deviceId">设备编号</param>
  152. /// <param name="uuId"></param>
  153. /// <param name="major"></param>
  154. /// <param name="minor"></param>
  155. /// <param name="comment"></param>
  156. /// <param name="timeOut"></param>
  157. /// <returns></returns>
  158. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceUpdate", true)]
  159. public static WxJsonResult DeviceUpdate(string accessTokenOrAppId, long deviceId, string uuId, long major, long minor, string comment, int timeOut = Config.TIME_OUT)
  160. {
  161. return ApiHandlerWapper.TryCommonApi(accessToken =>
  162. {
  163. string url = string.Format(Config.ApiMpHost + "/shakearound/device/update?access_token={0}", accessToken.AsUrlData());
  164. var data = new
  165. {
  166. device_identifier = new
  167. {
  168. device_id = deviceId,
  169. uuid = uuId,
  170. major = major,
  171. minor = minor
  172. },
  173. comment = comment
  174. };
  175. return CommonJsonSend.Send<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
  176. }, accessTokenOrAppId);
  177. }
  178. /// <summary>
  179. /// 配置设备与门店的关联关系
  180. /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
  181. /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息。
  182. /// </summary>
  183. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  184. /// <param name="deviceId">设备编号</param>
  185. /// <param name="uuid"></param>
  186. /// <param name="major"></param>
  187. /// <param name="minor"></param>
  188. /// <param name="poiId">Poi_id 的说明改为:设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。</param>
  189. /// <param name="type">为1时,关联的门店和设备归属于同一公众账号;为2时,关联的门店为其他公众账号的门店。不填默认为1</param>
  190. /// <param name="timeOut"></param>
  191. /// <param name="poiAppid">当Type为2时,必填 关联门店所归属的公众账号的APPID</param>
  192. /// <returns></returns>
  193. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceBindLocatoin", true)]
  194. public static WxJsonResult DeviceBindLocatoin(string accessTokenOrAppId, long deviceId, string uuid, long major, long minor, long poiId, string poiAppid, int type = 1, int timeOut = Config.TIME_OUT)
  195. {
  196. return ApiHandlerWapper.TryCommonApi(accessToken =>
  197. {
  198. string url = string.Format(Config.ApiMpHost + "/shakearound/device/bindlocation?access_token={0}", accessToken.AsUrlData());
  199. var data = type == 2
  200. ? new
  201. {
  202. device_identifier = new
  203. {
  204. device_id = deviceId,
  205. uuid = uuid,
  206. major = major,
  207. minor = minor
  208. },
  209. poi_id = poiId,
  210. type = type,
  211. poi_appid = poiAppid
  212. } as object
  213. : new
  214. {
  215. device_identifier = new
  216. {
  217. device_id = deviceId,
  218. uuid = uuid,
  219. major = major,
  220. minor = minor
  221. },
  222. poi_id = poiId
  223. } as object;
  224. return CommonJsonSend.Send<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
  225. }, accessTokenOrAppId);
  226. }
  227. /// <summary>
  228. /// 配置设备与其他门店的关联关系
  229. /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
  230. /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息。
  231. /// </summary>
  232. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  233. /// <param name="deviceId">设备编号</param>
  234. /// <param name="uuid"></param>
  235. /// <param name="major"></param>
  236. /// <param name="minor"></param>
  237. /// <param name="poiId">Poi_id 的说明改为:设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。</param>
  238. /// <param name="timeOut"></param>
  239. /// <param name="type">为1时,关联的门店和设备归属于同一公众账号;为2时,关联的门店为其他公众账号的门店。不填默认为1</param>
  240. /// <returns></returns>
  241. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceBindLocatoin", true)]
  242. public static WxJsonResult DeviceBindLocatoin(string accessTokenOrAppId, long deviceId, string uuid, long major, long minor, long poiId, int timeOut = Config.TIME_OUT)
  243. {
  244. return ApiHandlerWapper.TryCommonApi(accessToken =>
  245. {
  246. string url = string.Format(Config.ApiMpHost + "/shakearound/device/bindlocation?access_token={0}", accessToken.AsUrlData());
  247. var data = new
  248. {
  249. device_identifier = new
  250. {
  251. device_id = deviceId,
  252. uuid = uuid,
  253. major = major,
  254. minor = minor
  255. },
  256. poi_id = poiId
  257. };
  258. return CommonJsonSend.Send<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
  259. }, accessTokenOrAppId);
  260. }
  261. #region 查询设备列表
  262. /// <summary>
  263. /// 查询设备列表Api url
  264. /// </summary>
  265. private static string searchDeviceUrl = Config.ApiMpHost + "/shakearound/device/search?access_token={0}";
  266. /// <summary>
  267. /// 根据指定的设备Id查询设备列表
  268. /// </summary>
  269. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  270. /// <param name="deviceIdentifiers">设备Id列表</param>
  271. /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
  272. /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息。
  273. /// <param name="timeOut"></param>
  274. /// <returns></returns>
  275. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchDeviceById", true)]
  276. public static DeviceSearchResultJson SearchDeviceById(string accessTokenOrAppId, List<DeviceApply_Data_Device_Identifiers> deviceIdentifiers, int timeOut = Config.TIME_OUT)
  277. {
  278. return ApiHandlerWapper.TryCommonApi(accessToken =>
  279. {
  280. var data = new
  281. {
  282. device_identifiers = deviceIdentifiers
  283. };
  284. return CommonJsonSend.Send<DeviceSearchResultJson>(accessToken, searchDeviceUrl, data, CommonJsonSendType.POST, timeOut);
  285. }, accessTokenOrAppId);
  286. }
  287. /// <summary>
  288. /// 根据分页查询或者指定范围查询设备列表
  289. /// </summary>
  290. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  291. /// <param name="lastSeen">前一次查询列表末尾的设备ID,第一次查询lastSeen为0</param>
  292. /// <param name="count">待查询的设备数量,不能超过50个</param>
  293. /// <param name="timeOut"></param>
  294. /// <returns></returns>
  295. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchDeviceByRange", true)]
  296. public static DeviceSearchResultJson SearchDeviceByRange(string accessTokenOrAppId, int lastSeen, int count, int timeOut = Config.TIME_OUT)
  297. {
  298. return ApiHandlerWapper.TryCommonApi(accessToken =>
  299. {
  300. var data = new
  301. {
  302. last_seen = lastSeen,
  303. count = count
  304. };
  305. return CommonJsonSend.Send<DeviceSearchResultJson>(accessToken, searchDeviceUrl, data, CommonJsonSendType.POST, timeOut);
  306. }, accessTokenOrAppId);
  307. }
  308. /// <summary>
  309. /// 根据批次ID查询设备列表
  310. /// </summary>
  311. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  312. /// <param name="applyId">批次ID,申请设备ID时所返回的批次ID</param>
  313. /// <param name="lastSeen">前一次查询列表末尾的设备ID,第一次查询lastSeen为0</param>
  314. /// <param name="count">待查询的设备数量,不能超过50个</param>
  315. /// <param name="timeOut"></param>
  316. /// <returns></returns>
  317. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchDeviceByApplyId", true)]
  318. public static DeviceSearchResultJson SearchDeviceByApplyId(string accessTokenOrAppId, long applyId, long lastSeen, int count, int timeOut = Config.TIME_OUT)
  319. {
  320. return ApiHandlerWapper.TryCommonApi(accessToken =>
  321. {
  322. var data = new
  323. {
  324. apply_id = applyId,
  325. last_seen = lastSeen,
  326. count = count
  327. };
  328. return CommonJsonSend.Send<DeviceSearchResultJson>(accessToken, searchDeviceUrl, data, CommonJsonSendType.POST, timeOut);
  329. }, accessTokenOrAppId);
  330. }
  331. #endregion
  332. /// <summary>
  333. /// 上传图片素材
  334. /// 上传在摇一摇页面展示的图片素材,素材保存在微信侧服务器上。 格式限定为:jpg,jpeg,png,gif,图片大小建议120px*120 px,限制不超过200 px *200 px,图片需为正方形。
  335. /// </summary>
  336. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  337. /// <param name="file"></param>
  338. /// <param name="timeOut"></param>
  339. /// <returns></returns>
  340. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.UploadImage", true)]
  341. public static UploadImageResultJson UploadImage(string accessTokenOrAppId, string file, int timeOut = Config.TIME_OUT)
  342. {
  343. return ApiHandlerWapper.TryCommonApi(accessToken =>
  344. {
  345. var url = string.Format(Config.ApiMpHost + "/shakearound/material/add?access_token={0}", accessToken.AsUrlData());
  346. var fileDictionary = new Dictionary<string, string>();
  347. fileDictionary["media"] = file;
  348. return Post.PostFileGetJson<UploadImageResultJson>(url, null, fileDictionary, null, timeOut: timeOut);
  349. }, accessTokenOrAppId);
  350. }
  351. /// <summary>
  352. /// 新增页面
  353. /// </summary>
  354. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  355. /// <param name="title">在摇一摇页面展示的主标题,不超过6个字</param>
  356. /// <param name="description">在摇一摇页面展示的副标题,不超过7个字</param>
  357. /// <param name="pageUrl">点击页面跳转链接</param>
  358. /// <param name="iconUrl">在摇一摇页面展示的图片。图片需先上传至微信侧服务器,用“素材管理-上传图片素材”接口上传图片,返回的图片URL再配置在此处</param>
  359. /// <param name="comment">页面的备注信息,不超过15个字</param>
  360. /// <param name="timeOut"></param>
  361. /// <returns></returns>
  362. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.AddPage", true)]
  363. public static AddPageResultJson AddPage(string accessTokenOrAppId, string title, string description, string pageUrl,
  364. string iconUrl, string comment = null, int timeOut = Config.TIME_OUT)
  365. {
  366. return ApiHandlerWapper.TryCommonApi(accessToken =>
  367. {
  368. var url = string.Format(Config.ApiMpHost + "/shakearound/page/add?access_token={0}", accessToken.AsUrlData());
  369. var data = new
  370. {
  371. title = title,
  372. description = description,
  373. page_url = pageUrl,
  374. comment = comment,
  375. icon_url = iconUrl
  376. };
  377. return CommonJsonSend.Send<AddPageResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  378. }, accessTokenOrAppId);
  379. }
  380. /// <summary>
  381. /// 编辑页面信息
  382. /// </summary>
  383. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  384. /// <param name="pageId">摇周边页面唯一ID</param>
  385. /// <param name="title">在摇一摇页面展示的主标题,不超过6个字</param>
  386. /// <param name="description">在摇一摇页面展示的副标题,不超过7个字</param>
  387. /// <param name="pageUrl">点击页面跳转链接</param>
  388. /// <param name="iconUrl">在摇一摇页面展示的图片。图片需先上传至微信侧服务器,用“素材管理-上传图片素材”接口上传图片,返回的图片URL再配置在此处</param>
  389. /// <param name="comment">页面的备注信息,不超过15个字</param>
  390. /// <param name="timeOut"></param>
  391. /// <returns></returns>
  392. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.UpdatePage", true)]
  393. public static UpdatePageResultJson UpdatePage(string accessTokenOrAppId, long pageId, string title, string description, string pageUrl,
  394. string iconUrl, string comment = null, int timeOut = Config.TIME_OUT)
  395. {
  396. return ApiHandlerWapper.TryCommonApi(accessToken =>
  397. {
  398. var url = string.Format(Config.ApiMpHost + "/shakearound/page/update?access_token={0}", accessToken.AsUrlData());
  399. var data = new
  400. {
  401. page_id = pageId,
  402. title = title,
  403. description = description,
  404. page_url = pageUrl,
  405. comment = comment,
  406. icon_url = iconUrl
  407. };
  408. return CommonJsonSend.Send<UpdatePageResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  409. }, accessTokenOrAppId);
  410. }
  411. #region 查询页面列表
  412. private static string searchPageUrl =
  413. Config.ApiMpHost + "/shakearound/page/search?access_token={0}";
  414. /// <summary>
  415. /// 根据页面Id查询页面列表
  416. /// </summary>
  417. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  418. /// <param name="pageIds">指定页面的Id数组</param>
  419. /// <param name="timeOut"></param>
  420. /// <returns></returns>
  421. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchPagesByPageId", true)]
  422. public static SearchPagesResultJson SearchPagesByPageId(string accessTokenOrAppId, long[] pageIds,
  423. int timeOut = Config.TIME_OUT)
  424. {
  425. return ApiHandlerWapper.TryCommonApi(accessToken =>
  426. {
  427. var data = new
  428. {
  429. page_ids = pageIds
  430. };
  431. return CommonJsonSend.Send<SearchPagesResultJson>(accessToken, searchPageUrl, data, CommonJsonSendType.POST,
  432. timeOut);
  433. }, accessTokenOrAppId);
  434. }
  435. /// <summary>
  436. /// 根据分页或者指定范围查询页面列表
  437. /// </summary>
  438. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  439. /// <param name="begin"></param>
  440. /// <param name="count"></param>
  441. /// <param name="timeOut"></param>
  442. /// <returns></returns>
  443. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchPagesByRange", true)]
  444. public static SearchPagesResultJson SearchPagesByRange(string accessTokenOrAppId, int begin, int count,
  445. int timeOut = Config.TIME_OUT)
  446. {
  447. return ApiHandlerWapper.TryCommonApi(accessToken =>
  448. {
  449. var data = new
  450. {
  451. begin = begin,
  452. count = count
  453. };
  454. return CommonJsonSend.Send<SearchPagesResultJson>(accessToken, searchPageUrl, data, CommonJsonSendType.POST,
  455. timeOut);
  456. }, accessTokenOrAppId);
  457. }
  458. #endregion
  459. /// <summary>
  460. /// 删除页面
  461. /// </summary>
  462. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  463. /// <param name="pageId">指定页面的Id数组</param>
  464. /// <param name="timeOut"></param>
  465. /// <returns></returns>
  466. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeletePage", true)]
  467. public static WxJsonResult DeletePage(string accessTokenOrAppId, long pageId, int timeOut = Config.TIME_OUT)
  468. {
  469. return ApiHandlerWapper.TryCommonApi(accessToken =>
  470. {
  471. var url = string.Format(Config.ApiMpHost + "/shakearound/page/delete?access_token={0}", accessToken.AsUrlData());
  472. var data = new
  473. {
  474. page_id = pageId
  475. };
  476. return CommonJsonSend.Send<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
  477. }, accessTokenOrAppId);
  478. }
  479. /// <summary>
  480. /// 配置设备与页面的关联关系
  481. /// 配置设备与页面的关联关系。支持建立或解除关联关系,也支持新增页面或覆盖页面等操作。配置完成后,在此设备的信号范围内,即可摇出关联的页面信息。若设备配置多个页面,则随机出现页面信息。一个设备最多可配置30个关联页面。
  482. /// </summary>
  483. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  484. /// <param name="deviceIdentifier"></param>
  485. /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
  486. /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息
  487. /// <param name="pageIds"></param>
  488. /// <param name="bindType">关联操作标志位, 0为解除关联关系,1为建立关联关系</param>
  489. /// <param name="appendType">新增操作标志位, 0为覆盖,1为新增</param>
  490. /// <param name="timeOut"></param>
  491. /// <returns></returns>
  492. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.BindPage", true)]
  493. public static WxJsonResult BindPage(string accessTokenOrAppId, DeviceApply_Data_Device_Identifiers deviceIdentifier, long[] pageIds, ShakeAroundBindType bindType, ShakeAroundAppendType appendType, int timeOut = Config.TIME_OUT)
  494. {
  495. return ApiHandlerWapper.TryCommonApi(accessToken =>
  496. {
  497. var url = string.Format(Config.ApiMpHost + "/shakearound/device/bindpage?access_token={0}", accessToken.AsUrlData());
  498. var data = new
  499. {
  500. device_identifier = deviceIdentifier,
  501. page_ids = pageIds,
  502. bind = (int)bindType,
  503. append = (int)appendType
  504. };
  505. return CommonJsonSend.Send<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
  506. }, accessTokenOrAppId);
  507. }
  508. /// <summary>
  509. /// 查询设备的关联关系
  510. /// </summary>
  511. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  512. /// <param name="deviceIdentifier">指定的设备</param>
  513. /// <param name="timeOut"></param>
  514. /// <returns></returns>
  515. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.RelationSearch", true)]
  516. public static RelationSearchResultJson RelationSearch(string accessTokenOrAppId, DeviceApply_Data_Device_Identifiers deviceIdentifier, int timeOut = Config.TIME_OUT)
  517. {
  518. return ApiHandlerWapper.TryCommonApi(accessToken =>
  519. {
  520. var url = string.Format(Config.ApiMpHost + "/shakearound/relation/search?access_token={0}", accessToken.AsUrlData());
  521. var data = new
  522. {
  523. type = 1,
  524. device_identifier = deviceIdentifier
  525. };
  526. return CommonJsonSend.Send<RelationSearchResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  527. }, accessTokenOrAppId);
  528. }
  529. /// <summary>
  530. /// 查询页面的关联关系
  531. /// </summary>
  532. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  533. /// <param name="pageId">指定的页面id</param>
  534. /// <param name="begin">关联关系列表的起始索引值</param>
  535. /// <param name="count">待查询的关联关系数量,不能超过50个</param>
  536. /// <param name="timeOut"></param>
  537. /// <returns></returns>
  538. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.RelationSearch", true)]
  539. public static RelationSearchResultJson RelationSearch(string accessTokenOrAppId, long pageId, int begin, int count, int timeOut = Config.TIME_OUT)
  540. {
  541. return ApiHandlerWapper.TryCommonApi(accessToken =>
  542. {
  543. var url = string.Format(Config.ApiMpHost + "/shakearound/relation/search?access_token={0}", accessToken.AsUrlData());
  544. var data = new
  545. {
  546. type = 2,
  547. page_id = pageId,
  548. begin = begin,
  549. count = count
  550. };
  551. return CommonJsonSend.Send<RelationSearchResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  552. }, accessTokenOrAppId);
  553. }
  554. /// <summary>
  555. /// 获取摇周边的设备及用户信息
  556. /// </summary>
  557. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  558. /// <param name="ticket">摇周边业务的ticket,可在摇到的URL中得到,ticket生效时间为30分钟,每一次摇都会重新生成新的ticket</param>
  559. /// <param name="needPoi">是否需要返回门店poi_id,传1则返回,否则不返回</param>
  560. /// <param name="timeOut"></param>
  561. /// <returns></returns>
  562. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GetShakeInfo", true)]
  563. public static GetShakeInfoResultJson GetShakeInfo(string accessTokenOrAppId, string ticket, int needPoi = 1,
  564. int timeOut = Config.TIME_OUT)
  565. {
  566. return ApiHandlerWapper.TryCommonApi(accessToken =>
  567. {
  568. var url = string.Format(Config.ApiMpHost + "/shakearound/user/getshakeinfo?access_token={0}", accessToken.AsUrlData());
  569. var data = new
  570. {
  571. ticket = ticket,
  572. need_poi = needPoi
  573. };
  574. return CommonJsonSend.Send<GetShakeInfoResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  575. }, accessTokenOrAppId);
  576. }
  577. /// <summary>
  578. /// 以设备为维度的数据统计接口
  579. /// </summary>
  580. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  581. /// <param name="deviceIdentifier">指定页面的设备ID</param>
  582. /// 设备编号,若填了UUID、major、minor,即可不填设备编号,二者选其一
  583. /// UUID、major、minor,三个信息需填写完成,若填了设备编辑,即可不填此信息,二者选其一
  584. /// <param name="beginDate">起始日期时间戳,最长时间跨度为30天</param>
  585. /// <param name="endDate">结束日期时间戳,最长时间跨度为30天</param>
  586. /// <param name="timeOut"></param>
  587. /// <returns></returns>
  588. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.StatisticsByDevice", true)]
  589. public static StatisticsResultJson StatisticsByDevice(string accessTokenOrAppId,
  590. DeviceApply_Data_Device_Identifiers deviceIdentifier, long beginDate, long endDate,
  591. int timeOut = Config.TIME_OUT)
  592. {
  593. return ApiHandlerWapper.TryCommonApi(accessToken =>
  594. {
  595. var url = string.Format(Config.ApiMpHost + "/shakearound/statistics/device?access_token={0}", accessToken.AsUrlData());
  596. var data = new
  597. {
  598. device_identifier = deviceIdentifier,
  599. begin_date = beginDate,
  600. end_date = endDate
  601. };
  602. return CommonJsonSend.Send<StatisticsResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  603. }, accessTokenOrAppId);
  604. }
  605. /// <summary>
  606. /// 以页面为维度的数据统计接口
  607. /// </summary>
  608. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  609. /// <param name="pageId">指定页面的设备ID</param>
  610. /// <param name="beginDate">起始日期时间戳,最长时间跨度为30天</param>
  611. /// <param name="endDate">结束日期时间戳,最长时间跨度为30天</param>
  612. /// <param name="timeOut"></param>
  613. /// <returns></returns>
  614. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.StatisticsByPage", true)]
  615. public static StatisticsResultJson StatisticsByPage(string accessTokenOrAppId,
  616. long pageId, long beginDate, long endDate,
  617. int timeOut = Config.TIME_OUT)
  618. {
  619. return ApiHandlerWapper.TryCommonApi(accessToken =>
  620. {
  621. var url = string.Format(Config.ApiMpHost + "/shakearound/statistics/page?access_token={0}", accessToken.AsUrlData());
  622. var data = new
  623. {
  624. page_id = pageId,
  625. begin_date = beginDate,
  626. end_date = endDate
  627. };
  628. return CommonJsonSend.Send<StatisticsResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  629. }, accessTokenOrAppId);
  630. }
  631. /// <summary>
  632. /// 批量查询设备统计数据接口
  633. /// </summary>
  634. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  635. /// <param name="date">指定查询日期时间戳,单位为秒</param>
  636. /// <param name="pageIndex">指定查询的结果页序号;返回结果按摇周边人数降序排序,每50条记录为一页</param>
  637. /// <param name="timeOut"></param>
  638. /// <returns></returns>
  639. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceList", true)]
  640. public static DeviceListResultJson DeviceList(string accessTokenOrAppId, long date, string pageIndex, int timeOut = Config.TIME_OUT)
  641. {
  642. return ApiHandlerWapper.TryCommonApi(accessToken =>
  643. {
  644. var url = string.Format(Config.ApiMpHost + "/shakearound/statistics/devicelist?access_token={0}", accessToken.AsUrlData());
  645. var data = new
  646. {
  647. date = date,
  648. page_index = pageIndex
  649. };
  650. return CommonJsonSend.Send<DeviceListResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  651. }, accessTokenOrAppId);
  652. }
  653. /// <summary>
  654. /// 批量查询页面统计数据接口
  655. /// </summary>
  656. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  657. /// <param name="date">指定查询日期时间戳,单位为秒</param>
  658. /// <param name="pageIndex">指定查询的结果页序号;返回结果按摇周边人数降序排序,每50条记录为一页</param>
  659. /// <param name="timeOut"></param>
  660. /// <returns></returns>
  661. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.PageList", true)]
  662. public static PageListResultJson PageList(string accessTokenOrAppId, long date, int pageIndex, int timeOut = Config.TIME_OUT)
  663. {
  664. return ApiHandlerWapper.TryCommonApi(accessToken =>
  665. {
  666. var url = string.Format(Config.ApiMpHost + "/shakearound/statistics/pagelist?access_token={0}", accessToken.AsUrlData());
  667. var data = new
  668. {
  669. date = date,
  670. page_index = pageIndex
  671. };
  672. return CommonJsonSend.Send<PageListResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  673. }, accessTokenOrAppId);
  674. }
  675. /// <summary>
  676. /// 新增分组
  677. /// </summary>
  678. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  679. /// <param name="groupName">分组名称,不超过100汉字或200个英文字母</param>
  680. /// <param name="timeOut"></param>
  681. /// <returns></returns>
  682. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupAdd", true)]
  683. public static GroupAddResultJson GroupAdd(string accessTokenOrAppId, string groupName, int timeOut = Config.TIME_OUT)
  684. {
  685. return ApiHandlerWapper.TryCommonApi(accessToken =>
  686. {
  687. var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/add?access_token={0}", accessToken.AsUrlData());
  688. var data = new
  689. {
  690. group_name = groupName
  691. };
  692. return CommonJsonSend.Send<GroupAddResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  693. }, accessTokenOrAppId);
  694. }
  695. /// <summary>
  696. /// 编辑分组信息
  697. /// </summary>
  698. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  699. /// <param name="groupid">分组唯一标识,全局唯一</param>
  700. /// <param name="groupName">分组名称,不超过100汉字或200个英文字母</param>
  701. /// <param name="timeOut"></param>
  702. /// <returns></returns>
  703. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupUpdate", true)]
  704. public static RegisterResultJson GroupUpdate(string accessTokenOrAppId, string groupid, string groupName, int timeOut = Config.TIME_OUT)
  705. {
  706. return ApiHandlerWapper.TryCommonApi(accessToken =>
  707. {
  708. var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/update?access_token={0}", accessToken.AsUrlData());
  709. var data = new
  710. {
  711. group_id = groupid,
  712. group_name = groupName
  713. };
  714. return CommonJsonSend.Send<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  715. }, accessTokenOrAppId);
  716. }
  717. /// <summary>
  718. /// 删除分组
  719. /// </summary>
  720. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  721. /// <param name="groupId">分组唯一标识,全局唯一</param>
  722. /// <param name="timeOut"></param>
  723. /// <returns></returns>
  724. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupDelete", true)]
  725. public static RegisterResultJson GroupDelete(string accessTokenOrAppId, string groupId, int timeOut = Config.TIME_OUT)
  726. {
  727. return ApiHandlerWapper.TryCommonApi(accessToken =>
  728. {
  729. var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/delete?access_token={0}", accessToken.AsUrlData());
  730. var data = new
  731. {
  732. group_id = groupId
  733. };
  734. return CommonJsonSend.Send<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  735. }, accessTokenOrAppId);
  736. }
  737. /// <summary>
  738. /// 查询分组列表
  739. /// </summary>
  740. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  741. /// <param name="begin">分组列表的起始索引值</param>
  742. /// <param name="count">待查询的分组数量,不能超过1000个</param>
  743. /// <returns></returns>
  744. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupGetList", true)]
  745. public static GroupGetListResultJson GroupGetList(string accessTokenOrAppId, int begin, int count, int timeOut = Config.TIME_OUT)
  746. {
  747. return ApiHandlerWapper.TryCommonApi(accessToken =>
  748. {
  749. var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/getlist?access_token={0}", accessToken.AsUrlData());
  750. var data = new
  751. {
  752. begin = begin,
  753. count = count
  754. };
  755. return CommonJsonSend.Send<GroupGetListResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  756. }, accessTokenOrAppId);
  757. }
  758. /// <summary>
  759. /// 查询分组详情
  760. /// </summary>
  761. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  762. /// <param name="groupId">分组唯一标识,全局唯一</param>
  763. /// <param name="begin">分组列表的起始索引值</param>
  764. /// <param name="count">待查询的分组数量,不能超过1000个</param>
  765. /// <returns></returns>
  766. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupGetDetail", true)]
  767. public static GroupGetDetailResultJson GroupGetDetail(string accessTokenOrAppId, string groupId, int begin, int count, int timeOut = Config.TIME_OUT)
  768. {
  769. return ApiHandlerWapper.TryCommonApi(accessToken =>
  770. {
  771. var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/getdetail?access_token={0}", accessToken.AsUrlData());
  772. var data = new
  773. {
  774. group_id = groupId,
  775. begin = begin,
  776. count = count
  777. };
  778. return CommonJsonSend.Send<GroupGetDetailResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  779. }, accessTokenOrAppId);
  780. }
  781. /// <summary>
  782. /// 添加设备到分组
  783. /// </summary>
  784. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  785. /// <param name="groupId">分组唯一标识,全局唯一</param>
  786. /// <param name="deviceIdentifier">分组列表的起始索引值</param>
  787. /// <returns></returns>
  788. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupGetAdddevice", true)]
  789. public static RegisterResultJson GroupGetAdddevice(string accessTokenOrAppId, string groupId, List<DeviceApply_Data_Device_Identifiers> deviceIdentifiers, int timeOut = Config.TIME_OUT)
  790. {
  791. return ApiHandlerWapper.TryCommonApi(accessToken =>
  792. {
  793. var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/adddevice?access_token={0}", accessToken.AsUrlData());
  794. object data = new
  795. {
  796. group_id = groupId,
  797. device_identifiers = deviceIdentifiers.Select(item =>
  798. {
  799. object itemData = null;
  800. if (!item.device_id.HasValue)
  801. {
  802. /* UUID、major、minor,三个信息需填写完成,
  803. * 若填了设备编号,即可不填此信息,二者选其一
  804. */
  805. itemData = new
  806. {
  807. uuid = item.uuid,
  808. major = item.major,
  809. minor = item.minor
  810. };
  811. }
  812. else
  813. {
  814. /*设备编号,若填了UUID、major、minor,
  815. * 即可不填设备编号,二者选其一
  816. */
  817. itemData = new
  818. {
  819. device_id = item.device_id
  820. };
  821. }
  822. return itemData;
  823. })
  824. };
  825. return CommonJsonSend.Send<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  826. }, accessTokenOrAppId);
  827. }
  828. /// <summary>
  829. /// 从分组中移除设备
  830. /// </summary>
  831. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  832. /// <param name="groupId">分组唯一标识,全局唯一</param>
  833. /// <param name="deviceIdentifier">分组列表的起始索引值</param>
  834. /// <returns></returns>
  835. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupDeleteDevice", true)]
  836. public static RegisterResultJson GroupDeleteDevice(string accessTokenOrAppId, string groupId, DeviceApply_Data_Device_Identifiers deviceIdentifier, int timeOut = Config.TIME_OUT)
  837. {
  838. return ApiHandlerWapper.TryCommonApi(accessToken =>
  839. {
  840. var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/deletedevice?access_token={0}", accessToken.AsUrlData());
  841. var data = new object();
  842. if (!deviceIdentifier.device_id.HasValue)
  843. {
  844. data = new
  845. {
  846. group_id = groupId,
  847. uuid = deviceIdentifier.uuid,
  848. major = deviceIdentifier.major,
  849. minor = deviceIdentifier.minor
  850. };
  851. }
  852. else
  853. {
  854. data = new
  855. {
  856. group_id = groupId,
  857. device_id = deviceIdentifier.device_id.Value
  858. };
  859. }
  860. return CommonJsonSend.Send<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  861. }, accessTokenOrAppId);
  862. }
  863. /// <summary>
  864. /// 创建红包活动
  865. /// </summary>
  866. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  867. /// <param name="title">抽奖活动名称(选择使用模板时,也作为摇一摇消息主标题),最长6个汉字,12个英文字母。</param>
  868. /// <param name="desc">抽奖活动描述(选择使用模板时,也作为摇一摇消息副标题),最长7个汉字,14个英文字母。</param>
  869. /// <param name="onoff">抽奖开关。0关闭,1开启,默认为1</param>
  870. /// <param name="beginTime"> 抽奖活动开始时间,unix时间戳,单位秒</param>
  871. /// <param name="expireTime"> 抽奖活动结束时间,unix时间戳,单位秒,红包活动有效期最长为91天</param>
  872. /// <param name="sponsorAppid">红包提供商户公众号的appid,需与预下单中的公众账号appid(wxappid)一致</param>
  873. /// <param name="total">红包总数,红包总数是录入红包ticket总数的上限,因此红包总数应该大于等于预下单时红包ticket总数。</param>
  874. /// <param name="jumpUrl">红包关注界面后可以跳转到第三方自定义的页面</param>
  875. /// <param name="key">开发者自定义的key,用来生成活动抽奖接口的签名参数,长度32位。使用方式见sign生成规则</param>
  876. /// <param name="timeOut">请求超时时间</param>
  877. /// <returns></returns>
  878. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.AddLotteryInfo", true)]
  879. public static AddLotteryInfoResultJson AddLotteryInfo(string accessTokenOrAppId, string title, string desc, int onoff, long beginTime, long expireTime, string sponsorAppid, long total, string jumpUrl, string key, int timeOut = Config.TIME_OUT)
  880. {
  881. return ApiHandlerWapper.TryCommonApi(accessToken =>
  882. {
  883. var url = string.Format(Config.ApiMpHost + "/shakearound/lottery/addlotteryinfo?access_token={0}", accessToken.AsUrlData());
  884. var data = new
  885. {
  886. title = title,
  887. desc = desc,
  888. onoff = onoff,
  889. begin_time = beginTime,
  890. expire_time = expireTime,
  891. sponsor_appid = sponsorAppid,
  892. total = total,
  893. jumpurl = jumpUrl,
  894. key = key
  895. };
  896. return CommonJsonSend.Send<AddLotteryInfoResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  897. }, accessTokenOrAppId);
  898. }
  899. /// <summary>
  900. /// 录入红包信息
  901. /// </summary>
  902. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  903. /// <param name="lotteryId">红包抽奖id,来自addlotteryinfo返回的lottery_id</param>
  904. /// <param name="mchid">红包提供者的商户号,,需与预下单中的商户号mch_id一致</param>
  905. /// <param name="sponsorAppid">红包提供商户公众号的appid,需与预下单中的公众账号appid(wxappid)一致</param>
  906. /// <param name="prizeInfoList">红包ticket列表,如果红包数较多,可以一次传入多个红包,批量调用该接口设置红包信息。每次请求传入的红包个数上限为100</param>
  907. /// <param name="timeOut"></param>
  908. /// <returns></returns>
  909. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SetPrizeBucket", true)]
  910. public static SetPrizeBucketResultJson SetPrizeBucket(string accessTokenOrAppId, string lotteryId, string mchid, string sponsorAppid, PrizeInfoList prizeInfoList, int timeOut = Config.TIME_OUT)
  911. {
  912. return ApiHandlerWapper.TryCommonApi(accessToken =>
  913. {
  914. var url = string.Format(Config.ApiMpHost + "/shakearound/lottery/setprizebucket?access_token={0}", accessToken.AsUrlData());
  915. var data = new
  916. {
  917. lottery_id = lotteryId,
  918. mchid = mchid,
  919. sponsorapp_id = sponsorAppid,
  920. prizeinfolist = prizeInfoList
  921. };
  922. return CommonJsonSend.Send<SetPrizeBucketResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  923. }, accessTokenOrAppId);
  924. }
  925. /// <summary>
  926. ///设置红包活动抽奖开关
  927. /// </summary>
  928. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  929. /// <param name="lotteryId">红包抽奖id,来自addlotteryinfo返回的lottery_id</param>
  930. /// <param name="onOff">活动抽奖开关,0:关闭,1:开启</param>
  931. /// <param name="timeOut"></param>
  932. /// <returns></returns>
  933. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SetLotterySwitch", true)]
  934. public static WxJsonResult SetLotterySwitch(string accessTokenOrAppId, string lotteryId, int onOff, int timeOut = Config.TIME_OUT)
  935. {
  936. return ApiHandlerWapper.TryCommonApi(accessToken =>
  937. {
  938. var url = string.Format(Config.ApiMpHost + "/shakearound/lottery/setlotteryswitch?access_token={0}", accessToken.AsUrlData());
  939. var data = new
  940. {
  941. lottery_id = lotteryId,
  942. onoff = onOff
  943. };
  944. return CommonJsonSend.Send<WxJsonResult>(null, url, data, CommonJsonSendType.GET, timeOut);
  945. }, accessTokenOrAppId);
  946. }
  947. /// <summary>
  948. ///红包查询接口
  949. /// </summary>
  950. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  951. /// <param name="lotteryId">红包抽奖id,来自addlotteryinfo返回的lottery_id</param>
  952. /// <param name="timeOut"></param>
  953. /// <returns></returns>
  954. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.QueryLottery", true)]
  955. public static QueryLotteryJsonResult QueryLottery(string accessTokenOrAppId, string lotteryId, int timeOut = Config.TIME_OUT)
  956. {
  957. return ApiHandlerWapper.TryCommonApi(accessToken =>
  958. {
  959. var url = string.Format(Config.ApiMpHost + "/shakearound/lottery/querylottery?access_token={0}", accessToken.AsUrlData());
  960. var data = new
  961. {
  962. lottery_id = lotteryId
  963. };
  964. return CommonJsonSend.Send<QueryLotteryJsonResult>(null, url, data, CommonJsonSendType.GET, timeOut);
  965. }, accessTokenOrAppId);
  966. }
  967. #endregion
  968. #if !NET35 && !NET40
  969. #region 异步方法
  970. /// <summary>
  971. /// 【异步方法】申请开通功能
  972. /// </summary>
  973. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  974. /// <param name="data"></param>
  975. /// <param name="industry_Id"></param>
  976. /// <param name="timeOut"></param>
  977. /// <returns></returns>
  978. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.RegisterAsync", true)]
  979. public static async Task<RegisterResultJson> RegisterAsync(string accessTokenOrAppId, RegisterData data, IndustryId industry_Id, int timeOut = Config.TIME_OUT)
  980. {
  981. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  982. {
  983. string url = string.Format(Config.ApiMpHost + "/shakearound/account/register?access_token={0}", accessToken.AsUrlData());
  984. data.industry_id = RegisterData.ConvertIndustryId(industry_Id);
  985. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  986. }, accessTokenOrAppId);
  987. }
  988. /// <summary>
  989. /// 【异步方法】查询审核状态
  990. /// </summary>
  991. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  992. /// <returns></returns>
  993. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GetAuditStatusAsync", true)]
  994. public static async Task<GetAuditStatusResultJson> GetAuditStatusAsync(string accessTokenOrAppId)
  995. {
  996. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  997. {
  998. string url = string.Format(Config.ApiMpHost + "/shakearound/account/auditstatus?access_token={0}", accessToken.AsUrlData());
  999. return await CommonJsonSend.SendAsync<GetAuditStatusResultJson>(null, url, null, CommonJsonSendType.GET);
  1000. }, accessTokenOrAppId);
  1001. }
  1002. /// <summary>
  1003. /// 【异步方法】申请设备ID
  1004. /// </summary>
  1005. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1006. /// <param name="quantity">申请的设备ID的数量,单次新增设备超过500个,需走人工审核流程</param>
  1007. /// <param name="applyReason">申请理由,不超过100个字</param>
  1008. /// <param name="comment">备注,不超过15个汉字或30个英文字母</param>
  1009. /// <param name="poiId">设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。</param>
  1010. /// <param name="timeOut"></param>
  1011. /// <returns></returns>
  1012. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceApplyAsync", true)]
  1013. public static async Task<DeviceApplyResultJson> DeviceApplyAsync(string accessTokenOrAppId, int quantity, string applyReason, string comment = null, long? poiId = null, int timeOut = Config.TIME_OUT)
  1014. {
  1015. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1016. {
  1017. string url = string.Format(Config.ApiMpHost + "/shakearound/device/applyid?access_token={0}", accessToken.AsUrlData());
  1018. var data = new
  1019. {
  1020. quantity = quantity,
  1021. apply_reason = applyReason,
  1022. comment = comment,
  1023. poi_id = poiId
  1024. };
  1025. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<DeviceApplyResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1026. }, accessTokenOrAppId);
  1027. }
  1028. /// <summary>
  1029. /// 【异步方法】查询设备ID申请审核状态
  1030. /// 接口说明 查询设备ID申请的审核状态。若单次申请的设备ID数量小于等于500个,系统会进行快速审核;若单次申请的设备ID数量大于500个,则在三个工作日内完成审核。
  1031. /// </summary>
  1032. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1033. /// <param name="appId">批次ID,申请设备ID时所返回的批次ID</param>
  1034. /// <param name="timeOut"></param>
  1035. /// <returns></returns>
  1036. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceApplyStatusAsync", true)]
  1037. public static async Task<GetDeviceStatusResultJson> DeviceApplyStatusAsync(string accessTokenOrAppId, long appId, int timeOut = Config.TIME_OUT)
  1038. {
  1039. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1040. {
  1041. string url = string.Format(Config.ApiMpHost + "/shakearound/device/applystatus?access_token={0}", accessToken.AsUrlData());
  1042. var data = new
  1043. {
  1044. apply_id = appId,
  1045. };
  1046. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetDeviceStatusResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1047. }, accessTokenOrAppId);
  1048. }
  1049. /// <summary>
  1050. /// 【异步方法】编辑设备信息
  1051. /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
  1052. /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息。
  1053. /// </summary>
  1054. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1055. /// <param name="deviceId">设备编号</param>
  1056. /// <param name="uuId"></param>
  1057. /// <param name="major"></param>
  1058. /// <param name="minor"></param>
  1059. /// <param name="comment"></param>
  1060. /// <param name="timeOut"></param>
  1061. /// <returns></returns>
  1062. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceUpdateAsync", true)]
  1063. public static async Task<WxJsonResult> DeviceUpdateAsync(string accessTokenOrAppId, long deviceId, string uuId, long major, long minor, string comment, int timeOut = Config.TIME_OUT)
  1064. {
  1065. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1066. {
  1067. string url = string.Format(Config.ApiMpHost + "/shakearound/device/update?access_token={0}", accessToken.AsUrlData());
  1068. var data = new
  1069. {
  1070. device_identifier = new
  1071. {
  1072. device_id = deviceId,
  1073. uuid = uuId,
  1074. major = major,
  1075. minor = minor
  1076. },
  1077. comment = comment
  1078. };
  1079. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
  1080. }, accessTokenOrAppId);
  1081. }
  1082. /// <summary>
  1083. /// 【异步方法】配置设备与门店的关联关系
  1084. /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
  1085. /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息。
  1086. /// </summary>
  1087. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1088. /// <param name="deviceId">设备编号</param>
  1089. /// <param name="uuid"></param>
  1090. /// <param name="major"></param>
  1091. /// <param name="minor"></param>
  1092. /// <param name="poiId">Poi_id 的说明改为:设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。</param>
  1093. /// <param name="type">为1时,关联的门店和设备归属于同一公众账号;为2时,关联的门店为其他公众账号的门店。不填默认为1</param>
  1094. /// <param name="timeOut"></param>
  1095. /// <param name="poiAppid">当Type为2时,必填 关联门店所归属的公众账号的APPID</param>
  1096. /// <returns></returns>
  1097. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceBindLocatoinAsync", true)]
  1098. public static async Task<WxJsonResult> DeviceBindLocatoinAsync(string accessTokenOrAppId, long deviceId, string uuid, long major, long minor, long poiId, string poiAppid, int type = 1, int timeOut = Config.TIME_OUT)
  1099. {
  1100. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1101. {
  1102. string url = string.Format(Config.ApiMpHost + "/shakearound/device/bindlocation?access_token={0}", accessToken.AsUrlData());
  1103. var data = type == 2
  1104. ? new
  1105. {
  1106. device_identifier = new
  1107. {
  1108. device_id = deviceId,
  1109. uuid = uuid,
  1110. major = major,
  1111. minor = minor
  1112. },
  1113. poi_id = poiId,
  1114. type = type,
  1115. poi_appid = poiAppid
  1116. } as object
  1117. : new
  1118. {
  1119. device_identifier = new
  1120. {
  1121. device_id = deviceId,
  1122. uuid = uuid,
  1123. major = major,
  1124. minor = minor
  1125. },
  1126. poi_id = poiId
  1127. } as object;
  1128. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
  1129. }, accessTokenOrAppId);
  1130. }
  1131. /// <summary>
  1132. /// 【异步方法】配置设备与其他门店的关联关系
  1133. /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
  1134. /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息。
  1135. /// </summary>
  1136. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1137. /// <param name="deviceId">设备编号</param>
  1138. /// <param name="uuid"></param>
  1139. /// <param name="major"></param>
  1140. /// <param name="minor"></param>
  1141. /// <param name="poiId">Poi_id 的说明改为:设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。</param>
  1142. /// <param name="timeOut"></param>
  1143. /// <param name="type">为1时,关联的门店和设备归属于同一公众账号;为2时,关联的门店为其他公众账号的门店。不填默认为1</param>
  1144. /// <returns></returns>
  1145. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceBindLocatoinAsync", true)]
  1146. public static async Task<WxJsonResult> DeviceBindLocatoinAsync(string accessTokenOrAppId, long deviceId, string uuid, long major, long minor, long poiId, int timeOut = Config.TIME_OUT)
  1147. {
  1148. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1149. {
  1150. string url = string.Format(Config.ApiMpHost + "/shakearound/device/bindlocation?access_token={0}", accessToken.AsUrlData());
  1151. var data = new
  1152. {
  1153. device_identifier = new
  1154. {
  1155. device_id = deviceId,
  1156. uuid = uuid,
  1157. major = major,
  1158. minor = minor
  1159. },
  1160. poi_id = poiId
  1161. };
  1162. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
  1163. }, accessTokenOrAppId);
  1164. }
  1165. #region 查询设备列表
  1166. /// <summary>
  1167. /// 【异步方法】查询设备列表Api url
  1168. /// </summary>
  1169. // private static string searchDeviceUrl = Config.ApiMpHost + "/shakearound/device/search?access_token={0}";
  1170. /// <summary>
  1171. /// 根据指定的设备Id查询设备列表
  1172. /// </summary>
  1173. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1174. /// <param name="deviceIdentifiers">设备Id列表</param>
  1175. /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
  1176. /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息。
  1177. /// <param name="timeOut"></param>
  1178. /// <returns></returns>
  1179. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchDeviceByIdAsync", true)]
  1180. public static async Task<DeviceSearchResultJson> SearchDeviceByIdAsync(string accessTokenOrAppId, List<DeviceApply_Data_Device_Identifiers> deviceIdentifiers, int timeOut = Config.TIME_OUT)
  1181. {
  1182. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1183. {
  1184. var data = new
  1185. {
  1186. device_identifiers = deviceIdentifiers
  1187. };
  1188. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<DeviceSearchResultJson>(accessToken, searchDeviceUrl, data, CommonJsonSendType.POST, timeOut);
  1189. }, accessTokenOrAppId);
  1190. }
  1191. /// <summary>
  1192. /// 【异步方法】根据分页查询或者指定范围查询设备列表
  1193. /// </summary>
  1194. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1195. /// <param name="begin"></param>
  1196. /// <param name="count"></param>
  1197. /// <param name="timeOut"></param>
  1198. /// <returns></returns>
  1199. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchDeviceByRangeAsync", true)]
  1200. public static async Task<DeviceSearchResultJson> SearchDeviceByRangeAsync(string accessTokenOrAppId, int begin, int count, int timeOut = Config.TIME_OUT)
  1201. {
  1202. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1203. {
  1204. var data = new
  1205. {
  1206. begin = begin,
  1207. count = count
  1208. };
  1209. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<DeviceSearchResultJson>(accessToken, searchDeviceUrl, data, CommonJsonSendType.POST, timeOut);
  1210. }, accessTokenOrAppId);
  1211. }
  1212. /// <summary>
  1213. /// 【异步方法】根据批次ID查询设备列表
  1214. /// </summary>
  1215. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1216. /// <param name="applyId"></param>
  1217. /// <param name="begin"></param>
  1218. /// <param name="count"></param>
  1219. /// <param name="timeOut"></param>
  1220. /// <returns></returns>
  1221. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchDeviceByApplyIdAsync", true)]
  1222. public static async Task<DeviceSearchResultJson> SearchDeviceByApplyIdAsync(string accessTokenOrAppId, long applyId, int begin, int count, int timeOut = Config.TIME_OUT)
  1223. {
  1224. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1225. {
  1226. var data = new
  1227. {
  1228. apply_id = applyId,
  1229. begin = begin,
  1230. count = count
  1231. };
  1232. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<DeviceSearchResultJson>(accessToken, searchDeviceUrl, data, CommonJsonSendType.POST, timeOut);
  1233. }, accessTokenOrAppId);
  1234. }
  1235. #endregion
  1236. /// <summary>
  1237. /// 【异步方法】上传图片素材
  1238. /// 上传在摇一摇页面展示的图片素材,素材保存在微信侧服务器上。 格式限定为:jpg,jpeg,png,gif,图片大小建议120px*120 px,限制不超过200 px *200 px,图片需为正方形。
  1239. /// </summary>
  1240. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1241. /// <param name="file"></param>
  1242. /// <param name="timeOut"></param>
  1243. /// <returns></returns>
  1244. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.UploadImageAsync", true)]
  1245. public static async Task<UploadImageResultJson> UploadImageAsync(string accessTokenOrAppId, string file, int timeOut = Config.TIME_OUT)
  1246. {
  1247. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1248. {
  1249. var url = string.Format(Config.ApiMpHost + "/shakearound/material/add?access_token={0}", accessToken.AsUrlData());
  1250. var fileDictionary = new Dictionary<string, string>();
  1251. fileDictionary["media"] = file;
  1252. return await Post.PostFileGetJsonAsync<UploadImageResultJson>(url, null, fileDictionary, null, timeOut: timeOut);
  1253. }, accessTokenOrAppId);
  1254. }
  1255. /// <summary>
  1256. /// 【异步方法】新增页面
  1257. /// </summary>
  1258. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1259. /// <param name="title">在摇一摇页面展示的主标题,不超过6个字</param>
  1260. /// <param name="description">在摇一摇页面展示的副标题,不超过7个字</param>
  1261. /// <param name="pageUrl">点击页面跳转链接</param>
  1262. /// <param name="iconUrl">在摇一摇页面展示的图片。图片需先上传至微信侧服务器,用“素材管理-上传图片素材”接口上传图片,返回的图片URL再配置在此处</param>
  1263. /// <param name="comment">页面的备注信息,不超过15个字</param>
  1264. /// <param name="timeOut"></param>
  1265. /// <returns></returns>
  1266. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.AddPageAsync", true)]
  1267. public static async Task<AddPageResultJson> AddPageAsync(string accessTokenOrAppId, string title, string description, string pageUrl,
  1268. string iconUrl, string comment = null, int timeOut = Config.TIME_OUT)
  1269. {
  1270. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1271. {
  1272. var url = string.Format(Config.ApiMpHost + "/shakearound/page/add?access_token={0}", accessToken.AsUrlData());
  1273. var data = new
  1274. {
  1275. title = title,
  1276. description = description,
  1277. page_url = pageUrl,
  1278. comment = comment,
  1279. icon_url = iconUrl
  1280. };
  1281. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AddPageResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1282. }, accessTokenOrAppId);
  1283. }
  1284. /// <summary>
  1285. /// 【异步方法】编辑页面信息
  1286. /// </summary>
  1287. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1288. /// <param name="pageId">摇周边页面唯一ID</param>
  1289. /// <param name="title">在摇一摇页面展示的主标题,不超过6个字</param>
  1290. /// <param name="description">在摇一摇页面展示的副标题,不超过7个字</param>
  1291. /// <param name="pageUrl">点击页面跳转链接</param>
  1292. /// <param name="iconUrl">在摇一摇页面展示的图片。图片需先上传至微信侧服务器,用“素材管理-上传图片素材”接口上传图片,返回的图片URL再配置在此处</param>
  1293. /// <param name="comment">页面的备注信息,不超过15个字</param>
  1294. /// <param name="timeOut"></param>
  1295. /// <returns></returns>
  1296. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.UpdatePageAsync", true)]
  1297. public static async Task<UpdatePageResultJson> UpdatePageAsync(string accessTokenOrAppId, long pageId, string title, string description, string pageUrl,
  1298. string iconUrl, string comment = null, int timeOut = Config.TIME_OUT)
  1299. {
  1300. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1301. {
  1302. var url = string.Format(Config.ApiMpHost + "/shakearound/page/update?access_token={0}", accessToken.AsUrlData());
  1303. var data = new
  1304. {
  1305. page_id = pageId,
  1306. title = title,
  1307. description = description,
  1308. page_url = pageUrl,
  1309. comment = comment,
  1310. icon_url = iconUrl
  1311. };
  1312. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<UpdatePageResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1313. }, accessTokenOrAppId);
  1314. }
  1315. #region 查询页面列表
  1316. /*private static string searchPageUrl =Config.ApiMpHost + "/shakearound/page/search?access_token={0}";*/
  1317. /// <summary>
  1318. /// 【异步方法】根据页面Id查询页面列表
  1319. /// </summary>
  1320. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1321. /// <param name="pageIds">指定页面的Id数组</param>
  1322. /// <param name="timeOut"></param>
  1323. /// <returns></returns>
  1324. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchPagesByPageIdAsync", true)]
  1325. public static async Task<SearchPagesResultJson> SearchPagesByPageIdAsync(string accessTokenOrAppId, long[] pageIds,
  1326. int timeOut = Config.TIME_OUT)
  1327. {
  1328. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1329. {
  1330. var data = new
  1331. {
  1332. page_ids = pageIds
  1333. };
  1334. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<SearchPagesResultJson>(accessToken, searchPageUrl, data, CommonJsonSendType.POST,
  1335. timeOut);
  1336. }, accessTokenOrAppId);
  1337. }
  1338. /// <summary>
  1339. /// 【异步方法】根据分页或者指定范围查询页面列表
  1340. /// </summary>
  1341. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1342. /// <param name="lastSeen"></param>
  1343. /// <param name="count"></param>
  1344. /// <param name="timeOut"></param>
  1345. /// <returns></returns>
  1346. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchPagesByRangeAsync", true)]
  1347. public static async Task<SearchPagesResultJson> SearchPagesByRangeAsync(string accessTokenOrAppId, long lastSeen, int count,
  1348. int timeOut = Config.TIME_OUT)
  1349. {
  1350. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1351. {
  1352. var data = new
  1353. {
  1354. last_seen = lastSeen,
  1355. count = count
  1356. };
  1357. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<SearchPagesResultJson>(accessToken, searchPageUrl, data, CommonJsonSendType.POST,
  1358. timeOut);
  1359. }, accessTokenOrAppId);
  1360. }
  1361. #endregion
  1362. /// <summary>
  1363. /// 【异步方法】删除页面
  1364. /// </summary>
  1365. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1366. /// <param name="pageId">指定页面的Id数组</param>
  1367. /// <param name="timeOut"></param>
  1368. /// <returns></returns>
  1369. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeletePageAsync", true)]
  1370. public static async Task<WxJsonResult> DeletePageAsync(string accessTokenOrAppId, long pageId, int timeOut = Config.TIME_OUT)
  1371. {
  1372. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1373. {
  1374. var url = string.Format(Config.ApiMpHost + "/shakearound/page/delete?access_token={0}", accessToken.AsUrlData());
  1375. var data = new
  1376. {
  1377. page_id = pageId
  1378. };
  1379. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
  1380. }, accessTokenOrAppId);
  1381. }
  1382. /// <summary>
  1383. /// 【异步方法】配置设备与页面的关联关系
  1384. /// 配置设备与页面的关联关系。支持建立或解除关联关系,也支持新增页面或覆盖页面等操作。配置完成后,在此设备的信号范围内,即可摇出关联的页面信息。若设备配置多个页面,则随机出现页面信息。一个设备最多可配置30个关联页面。
  1385. /// </summary>
  1386. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1387. /// <param name="deviceIdentifier"></param>
  1388. /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
  1389. /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息
  1390. /// <param name="pageIds"></param>
  1391. /// <param name="bindType">关联操作标志位, 0为解除关联关系,1为建立关联关系</param>
  1392. /// <param name="appendType">新增操作标志位, 0为覆盖,1为新增</param>
  1393. /// <param name="timeOut"></param>
  1394. /// <returns></returns>
  1395. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.BindPageAsync", true)]
  1396. public static async Task<WxJsonResult> BindPageAsync(string accessTokenOrAppId, DeviceApply_Data_Device_Identifiers deviceIdentifier, long[] pageIds, ShakeAroundBindType bindType, ShakeAroundAppendType appendType, int timeOut = Config.TIME_OUT)
  1397. {
  1398. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1399. {
  1400. var url = string.Format(Config.ApiMpHost + "/shakearound/device/bindpage?access_token={0}", accessToken.AsUrlData());
  1401. var data = new
  1402. {
  1403. device_identifier = deviceIdentifier,
  1404. page_ids = pageIds,
  1405. bind = (int)bindType,
  1406. append = (int)appendType
  1407. };
  1408. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
  1409. }, accessTokenOrAppId);
  1410. }
  1411. /// <summary>
  1412. /// 【异步方法】查询设备的关联关系
  1413. /// </summary>
  1414. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1415. /// <param name="deviceIdentifier">指定的设备</param>
  1416. /// <param name="timeOut"></param>
  1417. /// <returns></returns>
  1418. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.RelationSearchAsync", true)]
  1419. public static async Task<RelationSearchResultJson> RelationSearchAsync(string accessTokenOrAppId, DeviceApply_Data_Device_Identifiers deviceIdentifier, int timeOut = Config.TIME_OUT)
  1420. {
  1421. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1422. {
  1423. var url = string.Format(Config.ApiMpHost + "/shakearound/relation/search?access_token={0}", accessToken.AsUrlData());
  1424. var data = new
  1425. {
  1426. type = 1,
  1427. device_identifier = deviceIdentifier
  1428. };
  1429. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<RelationSearchResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1430. }, accessTokenOrAppId);
  1431. }
  1432. /// <summary>
  1433. /// 【异步方法】查询页面的关联关系
  1434. /// </summary>
  1435. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1436. /// <param name="pageId">指定的页面id</param>
  1437. /// <param name="begin">关联关系列表的起始索引值</param>
  1438. /// <param name="count">待查询的关联关系数量,不能超过50个</param>
  1439. /// <param name="timeOut"></param>
  1440. /// <returns></returns>
  1441. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.RelationSearchAsync", true)]
  1442. public static async Task<RelationSearchResultJson> RelationSearchAsync(string accessTokenOrAppId, long pageId, int begin, int count, int timeOut = Config.TIME_OUT)
  1443. {
  1444. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1445. {
  1446. var url = string.Format(Config.ApiMpHost + "/shakearound/relation/search?access_token={0}", accessToken.AsUrlData());
  1447. var data = new
  1448. {
  1449. type = 2,
  1450. page_id = pageId,
  1451. begin = begin,
  1452. count = count
  1453. };
  1454. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<RelationSearchResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1455. }, accessTokenOrAppId);
  1456. }
  1457. /// <summary>
  1458. /// 【异步方法】获取摇周边的设备及用户信息
  1459. /// </summary>
  1460. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1461. /// <param name="ticket">摇周边业务的ticket,可在摇到的URL中得到,ticket生效时间为30分钟,每一次摇都会重新生成新的ticket</param>
  1462. /// <param name="needPoi">是否需要返回门店poi_id,传1则返回,否则不返回</param>
  1463. /// <param name="timeOut"></param>
  1464. /// <returns></returns>
  1465. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GetShakeInfoAsync", true)]
  1466. public static async Task<GetShakeInfoResultJson> GetShakeInfoAsync(string accessTokenOrAppId, string ticket, int needPoi = 1,
  1467. int timeOut = Config.TIME_OUT)
  1468. {
  1469. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1470. {
  1471. var url = string.Format(Config.ApiMpHost + "/shakearound/user/getshakeinfo?access_token={0}", accessToken.AsUrlData());
  1472. var data = new
  1473. {
  1474. ticket = ticket,
  1475. need_poi = needPoi
  1476. };
  1477. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetShakeInfoResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1478. }, accessTokenOrAppId);
  1479. }
  1480. /// <summary>
  1481. /// 【异步方法】以设备为维度的数据统计接口
  1482. /// </summary>
  1483. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1484. /// <param name="deviceIdentifier">指定页面的设备ID</param>
  1485. /// 设备编号,若填了UUID、major、minor,即可不填设备编号,二者选其一
  1486. /// UUID、major、minor,三个信息需填写完成,若填了设备编辑,即可不填此信息,二者选其一
  1487. /// <param name="beginDate">起始日期时间戳,最长时间跨度为30天</param>
  1488. /// <param name="endDate">结束日期时间戳,最长时间跨度为30天</param>
  1489. /// <param name="timeOut"></param>
  1490. /// <returns></returns>
  1491. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.StatisticsByDeviceAsync", true)]
  1492. public static async Task<StatisticsResultJson> StatisticsByDeviceAsync(string accessTokenOrAppId,
  1493. DeviceApply_Data_Device_Identifiers deviceIdentifier, long beginDate, long endDate,
  1494. int timeOut = Config.TIME_OUT)
  1495. {
  1496. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1497. {
  1498. var url = string.Format(Config.ApiMpHost + "/shakearound/statistics/device?access_token={0}", accessToken.AsUrlData());
  1499. var data = new
  1500. {
  1501. device_identifier = deviceIdentifier,
  1502. begin_date = beginDate,
  1503. end_date = endDate
  1504. };
  1505. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<StatisticsResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1506. }, accessTokenOrAppId);
  1507. }
  1508. /// <summary>
  1509. /// 【异步方法】以页面为维度的数据统计接口
  1510. /// </summary>
  1511. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1512. /// <param name="pageId">指定页面的设备ID</param>
  1513. /// <param name="beginDate">起始日期时间戳,最长时间跨度为30天</param>
  1514. /// <param name="endDate">结束日期时间戳,最长时间跨度为30天</param>
  1515. /// <param name="timeOut"></param>
  1516. /// <returns></returns>
  1517. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.StatisticsByPageAsync", true)]
  1518. public static async Task<StatisticsResultJson> StatisticsByPageAsync(string accessTokenOrAppId,
  1519. long pageId, long beginDate, long endDate,
  1520. int timeOut = Config.TIME_OUT)
  1521. {
  1522. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1523. {
  1524. var url = string.Format(Config.ApiMpHost + "/shakearound/statistics/page?access_token={0}", accessToken.AsUrlData());
  1525. var data = new
  1526. {
  1527. page_id = pageId,
  1528. begin_date = beginDate,
  1529. end_date = endDate
  1530. };
  1531. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<StatisticsResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1532. }, accessTokenOrAppId);
  1533. }
  1534. /// <summary>
  1535. /// 【异步方法】批量查询设备统计数据接口
  1536. /// </summary>
  1537. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1538. /// <param name="date">指定查询日期时间戳,单位为秒</param>
  1539. /// <param name="pageIndex">指定查询的结果页序号;返回结果按摇周边人数降序排序,每50条记录为一页</param>
  1540. /// <param name="timeOut"></param>
  1541. /// <returns></returns>
  1542. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceListAsync", true)]
  1543. public static async Task<DeviceListResultJson> DeviceListAsync(string accessTokenOrAppId, long date, string pageIndex, int timeOut = Config.TIME_OUT)
  1544. {
  1545. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1546. {
  1547. var url = string.Format(Config.ApiMpHost + "/shakearound/statistics/devicelist?access_token={0}", accessToken.AsUrlData());
  1548. var data = new
  1549. {
  1550. date = date,
  1551. page_index = pageIndex
  1552. };
  1553. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<DeviceListResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1554. }, accessTokenOrAppId);
  1555. }
  1556. /// <summary>
  1557. /// 【异步方法】批量查询页面统计数据接口
  1558. /// </summary>
  1559. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1560. /// <param name="date">指定查询日期时间戳,单位为秒</param>
  1561. /// <param name="pageIndex">指定查询的结果页序号;返回结果按摇周边人数降序排序,每50条记录为一页</param>
  1562. /// <param name="timeOut"></param>
  1563. /// <returns></returns>
  1564. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.PageListAsync", true)]
  1565. public static async Task<PageListResultJson> PageListAsync(string accessTokenOrAppId, long date, int pageIndex, int timeOut = Config.TIME_OUT)
  1566. {
  1567. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1568. {
  1569. var url = string.Format(Config.ApiMpHost + "/shakearound/statistics/pagelist?access_token={0}", accessToken.AsUrlData());
  1570. var data = new
  1571. {
  1572. date = date,
  1573. page_index = pageIndex
  1574. };
  1575. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<PageListResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1576. }, accessTokenOrAppId);
  1577. }
  1578. /// <summary>
  1579. /// 【异步方法】新增分组
  1580. /// </summary>
  1581. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1582. /// <param name="groupName">分组名称,不超过100汉字或200个英文字母</param>
  1583. /// <param name="timeOut"></param>
  1584. /// <returns></returns>
  1585. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupAddAsync", true)]
  1586. public static async Task<GroupAddResultJson> GroupAddAsync(string accessTokenOrAppId, string groupName, int timeOut = Config.TIME_OUT)
  1587. {
  1588. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1589. {
  1590. var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/add?access_token={0}", accessToken.AsUrlData());
  1591. var data = new
  1592. {
  1593. group_name = groupName
  1594. };
  1595. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GroupAddResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1596. }, accessTokenOrAppId);
  1597. }
  1598. /// <summary>
  1599. /// 【异步方法】编辑分组信息
  1600. /// </summary>
  1601. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1602. /// <param name="groupid">分组唯一标识,全局唯一</param>
  1603. /// <param name="groupName">分组名称,不超过100汉字或200个英文字母</param>
  1604. /// <param name="timeOut"></param>
  1605. /// <returns></returns>
  1606. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupUpdateAsync", true)]
  1607. public static async Task<RegisterResultJson> GroupUpdateAsync(string accessTokenOrAppId, string groupid, string groupName, int timeOut = Config.TIME_OUT)
  1608. {
  1609. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1610. {
  1611. var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/update?access_token={0}", accessToken.AsUrlData());
  1612. var data = new
  1613. {
  1614. group_id = groupid,
  1615. group_name = groupName
  1616. };
  1617. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1618. }, accessTokenOrAppId);
  1619. }
  1620. /// <summary>
  1621. /// 【异步方法】删除分组
  1622. /// </summary>
  1623. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1624. /// <param name="groupId">分组唯一标识,全局唯一</param>
  1625. /// <param name="timeOut"></param>
  1626. /// <returns></returns>
  1627. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupDeleteAsync", true)]
  1628. public static async Task<RegisterResultJson> GroupDeleteAsync(string accessTokenOrAppId, string groupId, int timeOut = Config.TIME_OUT)
  1629. {
  1630. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1631. {
  1632. var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/delete?access_token={0}", accessToken.AsUrlData());
  1633. var data = new
  1634. {
  1635. group_id = groupId
  1636. };
  1637. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1638. }, accessTokenOrAppId);
  1639. }
  1640. /// <summary>
  1641. /// 【异步方法】查询分组列表
  1642. /// </summary>
  1643. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1644. /// <param name="begin">分组列表的起始索引值</param>
  1645. /// <param name="count">待查询的分组数量,不能超过1000个</param>
  1646. /// <returns></returns>
  1647. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupGetListAsync", true)]
  1648. public static async Task<GroupGetListResultJson> GroupGetListAsync(string accessTokenOrAppId, int begin, int count, int timeOut = Config.TIME_OUT)
  1649. {
  1650. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1651. {
  1652. var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/getlist?access_token={0}", accessToken.AsUrlData());
  1653. var data = new
  1654. {
  1655. begin = begin,
  1656. count = count
  1657. };
  1658. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GroupGetListResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1659. }, accessTokenOrAppId);
  1660. }
  1661. /// <summary>
  1662. /// 【异步方法】查询分组详情
  1663. /// </summary>
  1664. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1665. /// <param name="groupId">分组唯一标识,全局唯一</param>
  1666. /// <param name="begin">分组列表的起始索引值</param>
  1667. /// <param name="count">待查询的分组数量,不能超过1000个</param>
  1668. /// <returns></returns>
  1669. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupGetDetailAsync", true)]
  1670. public static async Task<GroupGetDetailResultJson> GroupGetDetailAsync(string accessTokenOrAppId, string groupId, int begin, int count, int timeOut = Config.TIME_OUT)
  1671. {
  1672. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1673. {
  1674. var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/getdetail?access_token={0}", accessToken.AsUrlData());
  1675. var data = new
  1676. {
  1677. group_id = groupId,
  1678. begin = begin,
  1679. count = count
  1680. };
  1681. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GroupGetDetailResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1682. }, accessTokenOrAppId);
  1683. }
  1684. /// <summary>
  1685. /// 【异步方法】添加设备到分组
  1686. /// </summary>
  1687. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1688. /// <param name="groupId">分组唯一标识,全局唯一</param>
  1689. /// <param name="deviceIdentifiers">分组列表的起始索引值</param>
  1690. /// <returns></returns>
  1691. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupGetAdddeviceAsync", true)]
  1692. public static async Task<RegisterResultJson> GroupGetAdddeviceAsync(string accessTokenOrAppId, string groupId, List<DeviceApply_Data_Device_Identifiers> deviceIdentifiers, int timeOut = Config.TIME_OUT)
  1693. {
  1694. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1695. {
  1696. var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/adddevice?access_token={0}", accessToken.AsUrlData());
  1697. object data = new
  1698. {
  1699. group_id = groupId,
  1700. device_identifiers = deviceIdentifiers.Select(item =>
  1701. {
  1702. object itemData = null;
  1703. if (!item.device_id.HasValue)
  1704. {
  1705. /* UUID、major、minor,三个信息需填写完成,
  1706. * 若填了设备编号,即可不填此信息,二者选其一
  1707. */
  1708. itemData = new
  1709. {
  1710. uuid = item.uuid,
  1711. major = item.major,
  1712. minor = item.minor
  1713. };
  1714. }
  1715. else
  1716. {
  1717. /*设备编号,若填了UUID、major、minor,
  1718. * 即可不填设备编号,二者选其一
  1719. */
  1720. itemData = new
  1721. {
  1722. device_id = item.device_id
  1723. };
  1724. }
  1725. return itemData;
  1726. })
  1727. };
  1728. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1729. }, accessTokenOrAppId);
  1730. }
  1731. /// <summary>
  1732. /// 【异步方法】从分组中移除设备
  1733. /// </summary>
  1734. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1735. /// <param name="groupId">分组唯一标识,全局唯一</param>
  1736. /// <param name="deviceIdentifier">分组列表的起始索引值</param>
  1737. /// <returns></returns>
  1738. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupDeleteDeviceAsync", true)]
  1739. public static async Task<RegisterResultJson> GroupDeleteDeviceAsync(string accessTokenOrAppId, string groupId, DeviceApply_Data_Device_Identifiers deviceIdentifier, int timeOut = Config.TIME_OUT)
  1740. {
  1741. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1742. {
  1743. var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/deletedevice?access_token={0}", accessToken.AsUrlData());
  1744. var data = new object();
  1745. if (!deviceIdentifier.device_id.HasValue)
  1746. {
  1747. data = new
  1748. {
  1749. group_id = groupId,
  1750. uuid = deviceIdentifier.uuid,
  1751. major = deviceIdentifier.major,
  1752. minor = deviceIdentifier.minor
  1753. };
  1754. }
  1755. else
  1756. {
  1757. data = new
  1758. {
  1759. group_id = groupId,
  1760. device_id = deviceIdentifier.device_id.Value
  1761. };
  1762. }
  1763. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1764. }, accessTokenOrAppId);
  1765. }
  1766. /// <summary>
  1767. /// 【异步方法】创建红包活动
  1768. /// </summary>
  1769. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1770. /// <param name="title">抽奖活动名称(选择使用模板时,也作为摇一摇消息主标题),最长6个汉字,12个英文字母。</param>
  1771. /// <param name="desc">抽奖活动描述(选择使用模板时,也作为摇一摇消息副标题),最长7个汉字,14个英文字母。</param>
  1772. /// <param name="onoff">抽奖开关。0关闭,1开启,默认为1</param>
  1773. /// <param name="beginTime"> 抽奖活动开始时间,unix时间戳,单位秒</param>
  1774. /// <param name="expireTime"> 抽奖活动结束时间,unix时间戳,单位秒,红包活动有效期最长为91天</param>
  1775. /// <param name="sponsorAppid">红包提供商户公众号的appid,需与预下单中的公众账号appid(wxappid)一致</param>
  1776. /// <param name="total">红包总数,红包总数是录入红包ticket总数的上限,因此红包总数应该大于等于预下单时红包ticket总数。</param>
  1777. /// <param name="jumpUrl">红包关注界面后可以跳转到第三方自定义的页面</param>
  1778. /// <param name="key">开发者自定义的key,用来生成活动抽奖接口的签名参数,长度32位。使用方式见sign生成规则</param>
  1779. /// <param name="timeOut">请求超时时间</param>
  1780. /// <returns></returns>
  1781. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.AddLotteryInfoAsync", true)]
  1782. public static async Task<AddLotteryInfoResultJson> AddLotteryInfoAsync(string accessTokenOrAppId, string title, string desc, int onoff, long beginTime, long expireTime, string sponsorAppid, long total, string jumpUrl, string key, int timeOut = Config.TIME_OUT)
  1783. {
  1784. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1785. {
  1786. var url = string.Format(Config.ApiMpHost + "/shakearound/lottery/addlotteryinfo?access_token={0}", accessToken.AsUrlData());
  1787. var data = new
  1788. {
  1789. title = title,
  1790. desc = desc,
  1791. onoff = onoff,
  1792. begin_time = beginTime,
  1793. expire_time = expireTime,
  1794. sponsor_appid = sponsorAppid,
  1795. total = total,
  1796. jumpurl = jumpUrl,
  1797. key = key
  1798. };
  1799. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AddLotteryInfoResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1800. }, accessTokenOrAppId);
  1801. }
  1802. /// <summary>
  1803. /// 【异步方法】录入红包信息
  1804. /// </summary>
  1805. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1806. /// <param name="lotteryId">红包抽奖id,来自addlotteryinfo返回的lottery_id</param>
  1807. /// <param name="mchid">红包提供者的商户号,,需与预下单中的商户号mch_id一致</param>
  1808. /// <param name="sponsorAppid">红包提供商户公众号的appid,需与预下单中的公众账号appid(wxappid)一致</param>
  1809. /// <param name="prizeInfoList">红包ticket列表,如果红包数较多,可以一次传入多个红包,批量调用该接口设置红包信息。每次请求传入的红包个数上限为100</param>
  1810. /// <param name="timeOut"></param>
  1811. /// <returns></returns>
  1812. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SetPrizeBucketAsync", true)]
  1813. public static async Task<SetPrizeBucketResultJson> SetPrizeBucketAsync(string accessTokenOrAppId, string lotteryId, string mchid, string sponsorAppid, PrizeInfoList prizeInfoList, int timeOut = Config.TIME_OUT)
  1814. {
  1815. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1816. {
  1817. var url = string.Format(Config.ApiMpHost + "/shakearound/lottery/setprizebucket?access_token={0}", accessToken.AsUrlData());
  1818. var data = new
  1819. {
  1820. lottery_id = lotteryId,
  1821. mchid = mchid,
  1822. sponsorapp_id = sponsorAppid,
  1823. prizeinfolist = prizeInfoList
  1824. };
  1825. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<SetPrizeBucketResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
  1826. }, accessTokenOrAppId);
  1827. }
  1828. /// <summary>
  1829. ///【异步方法】设置红包活动抽奖开关
  1830. /// </summary>
  1831. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1832. /// <param name="lotteryId">红包抽奖id,来自addlotteryinfo返回的lottery_id</param>
  1833. /// <param name="onOff">活动抽奖开关,0:关闭,1:开启</param>
  1834. /// <param name="timeOut"></param>
  1835. /// <returns></returns>
  1836. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SetLotterySwitchAsync", true)]
  1837. public static async Task<WxJsonResult> SetLotterySwitchAsync(string accessTokenOrAppId, string lotteryId, int onOff, int timeOut = Config.TIME_OUT)
  1838. {
  1839. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1840. {
  1841. var url = string.Format(Config.ApiMpHost + "/shakearound/lottery/setlotteryswitch?access_token={0}", accessToken.AsUrlData());
  1842. var data = new
  1843. {
  1844. lottery_id = lotteryId,
  1845. onoff = onOff
  1846. };
  1847. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, url, data, CommonJsonSendType.GET, timeOut);
  1848. }, accessTokenOrAppId);
  1849. }
  1850. /// <summary>
  1851. ///【异步方法】红包查询接口
  1852. /// </summary>
  1853. /// <param name="accessTokenOrAppId">调用接口凭证</param>
  1854. /// <param name="lotteryId">红包抽奖id,来自addlotteryinfo返回的lottery_id</param>
  1855. /// <param name="timeOut"></param>
  1856. /// <returns></returns>
  1857. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.QueryLotteryAsync", true)]
  1858. public static async Task<QueryLotteryJsonResult> QueryLotteryAsync(string accessTokenOrAppId, string lotteryId, int timeOut = Config.TIME_OUT)
  1859. {
  1860. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1861. {
  1862. var url = string.Format(Config.ApiMpHost + "/shakearound/lottery/querylottery?access_token={0}", accessToken.AsUrlData());
  1863. var data = new
  1864. {
  1865. lottery_id = lotteryId
  1866. };
  1867. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<QueryLotteryJsonResult>(null, url, data, CommonJsonSendType.GET, timeOut);
  1868. }, accessTokenOrAppId);
  1869. }
  1870. #endregion
  1871. #endif
  1872. }
  1873. }