StoreApi.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. #region Apache License Version 2.0
  2. /*----------------------------------------------------------------
  3. Copyright 2018 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) 2018 Senparc
  16. 文件名:StoreApi.cs
  17. 文件功能描述:门店接口
  18. 创建标识:Senparc - 20180927
  19. ----------------------------------------------------------------*/
  20. using Senparc.CO2NET.Extensions;
  21. using Senparc.NeuChar;
  22. using Senparc.Weixin.CommonAPIs;
  23. using Senparc.Weixin.Entities;
  24. using System.Threading.Tasks;
  25. namespace Senparc.Weixin.MP.AdvancedAPIs
  26. {
  27. /// <summary>
  28. /// 门店接口
  29. /// </summary>
  30. public static class StoreApi
  31. {
  32. #region 同步方法
  33. /// <summary>
  34. /// 拉取门店小程序类目
  35. /// </summary>
  36. /// <param name="accessTokenOrAppId"></param>
  37. /// <param name="timeOut"></param>
  38. /// <returns></returns>
  39. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetMerchantCategory", true)]
  40. public static GetMerchantCategoryResultJson GetMerchantCategory(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  41. {
  42. return ApiHandlerWapper.TryCommonApi(accessToken =>
  43. {
  44. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_merchant_category?access_token={0}", accessToken.AsUrlData());
  45. return CommonJsonSend.Send<GetMerchantCategoryResultJson>(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
  46. }, accessTokenOrAppId);
  47. }
  48. /// <summary>
  49. /// 创建门店小程序
  50. /// </summary>
  51. /// <param name="accessTokenOrAppId"></param>
  52. /// <param name="data"></param>
  53. /// <param name="timeOut"></param>
  54. /// <returns></returns>
  55. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.ApplyMerchant", true)]
  56. public static WxJsonResult ApplyMerchant(string accessTokenOrAppId, ApplyMerchantData data, int timeOut = Config.TIME_OUT)
  57. {
  58. return ApiHandlerWapper.TryCommonApi(accessToken =>
  59. {
  60. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/apply_merchant?access_token={0}", accessToken.AsUrlData());
  61. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  62. }, accessTokenOrAppId);
  63. }
  64. /// <summary>
  65. /// 查询门店小程序审核结果
  66. /// </summary>
  67. /// <param name="accessTokenOrAppId"></param>
  68. /// <param name="timeOut"></param>
  69. /// <returns></returns>
  70. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetMerchantAuditInfo", true)]
  71. public static GetMerchantAuditInfoResultJson GetMerchantAuditInfo(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  72. {
  73. return ApiHandlerWapper.TryCommonApi(accessToken =>
  74. {
  75. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_merchant_audit_info?access_token={0}", accessToken.AsUrlData());
  76. return CommonJsonSend.Send<GetMerchantAuditInfoResultJson>(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
  77. }, accessTokenOrAppId);
  78. }
  79. /// <summary>
  80. /// 修改门店小程序信息
  81. /// </summary>
  82. /// <param name="accessTokenOrAppId"></param>
  83. /// <param name="headingMediaid"></param>
  84. /// <param name="intro"></param>
  85. /// <param name="timeOut"></param>
  86. /// <returns></returns>
  87. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.ModifyMerchant", true)]
  88. public static WxJsonResult ModifyMerchant(string accessTokenOrAppId, string headingMediaid, string intro, int timeOut = Config.TIME_OUT)
  89. {
  90. return ApiHandlerWapper.TryCommonApi(accessToken =>
  91. {
  92. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/modify_merchant?access_token={0}", accessToken.AsUrlData());
  93. var data = new
  94. {
  95. headimg_mediaid = headingMediaid,
  96. intro
  97. };
  98. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  99. }, accessTokenOrAppId);
  100. }
  101. /// <summary>
  102. /// 从腾讯地图拉取省市区信息
  103. /// </summary>
  104. /// <param name="accessTokenOrAppId"></param>
  105. /// <param name="timeOut"></param>
  106. /// <returns></returns>
  107. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetDistrict", true)]
  108. public static GetDistrictResultJson GetDistrict(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  109. {
  110. return ApiHandlerWapper.TryCommonApi(accessToken =>
  111. {
  112. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_district?access_token={0}", accessToken.AsUrlData());
  113. return CommonJsonSend.Send<GetDistrictResultJson>(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
  114. }, accessTokenOrAppId);
  115. }
  116. /// <summary>
  117. /// 在腾讯地图中搜索门店
  118. /// </summary>
  119. /// <param name="accessTokenOrAppId"></param>
  120. /// <param name="districtId"></param>
  121. /// <param name="keyword"></param>
  122. /// <param name="timeOut"></param>
  123. /// <returns></returns>
  124. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.SearchMapPoi", true)]
  125. public static SearchMapPoiResultJson SearchMapPoi(string accessTokenOrAppId, string districtId, string keyword, int timeOut = Config.TIME_OUT)
  126. {
  127. return ApiHandlerWapper.TryCommonApi(accessToken =>
  128. {
  129. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/search_map_poi?access_token={0}", accessToken.AsUrlData());
  130. var data = new
  131. {
  132. districtid = districtId,
  133. keyword
  134. };
  135. return CommonJsonSend.Send<SearchMapPoiResultJson>(null, urlFormat, data, timeOut: timeOut);
  136. }, accessTokenOrAppId);
  137. }
  138. /// <summary>
  139. /// 在腾讯地图中创建门店
  140. /// </summary>
  141. /// <param name="accessTokenOrAppId"></param>
  142. /// <param name="data"></param>
  143. /// <param name="timeOut"></param>
  144. /// <returns></returns>
  145. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.CreateMapPoi", true)]
  146. public static CreateMapPoiResultJson CreateMapPoi(string accessTokenOrAppId, CreateMapPoiData data, int timeOut = Config.TIME_OUT)
  147. {
  148. return ApiHandlerWapper.TryCommonApi(accessToken =>
  149. {
  150. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/create_map_poi?access_token={0}", accessToken.AsUrlData());
  151. return CommonJsonSend.Send<CreateMapPoiResultJson>(null, urlFormat, data, timeOut: timeOut);
  152. }, accessTokenOrAppId);
  153. }
  154. /// <summary>
  155. /// 添加门店
  156. /// </summary>
  157. /// <param name="accessTokenOrAppId"></param>
  158. /// <param name="data"></param>
  159. /// <param name="timeOut"></param>
  160. /// <returns></returns>
  161. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.AddStore", true)]
  162. public static AddStoreResultJson AddStore(string accessTokenOrAppId, AddStoreData data, int timeOut = Config.TIME_OUT)
  163. {
  164. return ApiHandlerWapper.TryCommonApi(accessToken =>
  165. {
  166. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/add_store?access_token={0}", accessToken.AsUrlData());
  167. return CommonJsonSend.Send<AddStoreResultJson>(null, urlFormat, data, timeOut: timeOut);
  168. }, accessTokenOrAppId);
  169. }
  170. /// <summary>
  171. /// 更新门店信息
  172. /// </summary>
  173. /// <param name="accessTokenOrAppId"></param>
  174. /// <param name="data"></param>
  175. /// <param name="timeOut"></param>
  176. /// <returns></returns>
  177. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.UpdateStore", true)]
  178. public static UpdateStoreResultJson UpdateStore(string accessTokenOrAppId, UpdateStoreData data, int timeOut = Config.TIME_OUT)
  179. {
  180. return ApiHandlerWapper.TryCommonApi(accessToken =>
  181. {
  182. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/update_store?access_token={0}", accessToken.AsUrlData());
  183. return CommonJsonSend.Send<UpdateStoreResultJson>(null, urlFormat, data, timeOut: timeOut);
  184. }, accessTokenOrAppId);
  185. }
  186. /// <summary>
  187. /// 获取单个门店信息
  188. /// </summary>
  189. /// <param name="accessTokenOrAppId"></param>
  190. /// <param name="poiId"></param>
  191. /// <param name="timeOut"></param>
  192. /// <returns></returns>
  193. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetStoreInfo", true)]
  194. public static GetStoreInfoResultJson GetStoreInfo(string accessTokenOrAppId, string poiId, int timeOut = Config.TIME_OUT)
  195. {
  196. return ApiHandlerWapper.TryCommonApi(accessToken =>
  197. {
  198. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_store_info?access_token={0}", accessToken.AsUrlData());
  199. var data = new
  200. {
  201. poi_id = poiId
  202. };
  203. return CommonJsonSend.Send<GetStoreInfoResultJson>(null, urlFormat, data, timeOut: timeOut);
  204. }, accessTokenOrAppId);
  205. }
  206. /// <summary>
  207. /// 获取门店信息列表
  208. /// </summary>
  209. /// <param name="accessTokenOrAppId"></param>
  210. /// <param name="offset"></param>
  211. /// <param name="limit"></param>
  212. /// <param name="timeOut"></param>
  213. /// <returns></returns>
  214. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetStoreList", true)]
  215. public static GetStoreListResultJson GetStoreList(string accessTokenOrAppId, int offset, int limit, int timeOut = Config.TIME_OUT)
  216. {
  217. return ApiHandlerWapper.TryCommonApi(accessToken =>
  218. {
  219. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_store_list?access_token={0}", accessToken.AsUrlData());
  220. var data = new
  221. {
  222. offset = offset,
  223. limit = limit
  224. };
  225. return CommonJsonSend.Send<GetStoreListResultJson>(null, urlFormat, data, timeOut: timeOut);
  226. }, accessTokenOrAppId);
  227. }
  228. /// <summary>
  229. /// 删除门店
  230. /// </summary>
  231. /// <param name="accessTokenOrAppId"></param>
  232. /// <param name="poiId"></param>
  233. /// <param name="timeOut"></param>
  234. /// <returns></returns>
  235. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.DelStore", true)]
  236. public static WxJsonResult DelStore(string accessTokenOrAppId, string poiId, int timeOut = Config.TIME_OUT)
  237. {
  238. return ApiHandlerWapper.TryCommonApi(accessToken =>
  239. {
  240. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/del_store?access_token={0}", accessToken.AsUrlData());
  241. var data = new
  242. {
  243. poi_id = poiId
  244. };
  245. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  246. }, accessTokenOrAppId);
  247. }
  248. /// <summary>
  249. /// 获取门店小程序配置的卡券
  250. /// </summary>
  251. /// <param name="accessTokenOrAppId"></param>
  252. /// <param name="poiId"></param>
  253. /// <param name="timeOut"></param>
  254. /// <returns></returns>
  255. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetStoreCard", true)]
  256. public static GetStoreCardResultJson GetStoreCard(string accessTokenOrAppId, string poiId, int timeOut = Config.TIME_OUT)
  257. {
  258. return ApiHandlerWapper.TryCommonApi(accessToken =>
  259. {
  260. var urlFormat = string.Format(Config.ApiMpHost + "/card/storewxa/get?access_token={0}", accessToken.AsUrlData());
  261. var data = new
  262. {
  263. poi_id = poiId
  264. };
  265. return CommonJsonSend.Send<GetStoreCardResultJson>(null, urlFormat, data, timeOut: timeOut);
  266. }, accessTokenOrAppId);
  267. }
  268. /// <summary>
  269. /// 设置门店小程序配置的卡券
  270. /// </summary>
  271. /// <param name="accessTokenOrAppId"></param>
  272. /// <param name="poiId"></param>
  273. /// <param name="cardId"></param>
  274. /// <param name="timeOut"></param>
  275. /// <returns></returns>
  276. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.SetStoreCard", true)]
  277. public static WxJsonResult SetStoreCard(string accessTokenOrAppId, string poiId, string cardId, int timeOut = Config.TIME_OUT)
  278. {
  279. return ApiHandlerWapper.TryCommonApi(accessToken =>
  280. {
  281. var urlFormat = string.Format(Config.ApiMpHost + "/card/storewxa/set?access_token={0}", accessToken.AsUrlData());
  282. var data = new
  283. {
  284. poi_id = poiId,
  285. card_id = cardId
  286. };
  287. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  288. }, accessTokenOrAppId);
  289. }
  290. #endregion
  291. #if !NET35 && !NET40
  292. #region 异步方法
  293. /// <summary>
  294. /// 【异步方法】拉取门店小程序类目
  295. /// </summary>
  296. /// <param name="accessTokenOrAppId"></param>
  297. /// <param name="timeOut"></param>
  298. /// <returns></returns>
  299. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetMerchantCategoryAsync", true)]
  300. public static async Task<GetMerchantCategoryResultJson> GetMerchantCategoryAsync(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  301. {
  302. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  303. {
  304. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_merchant_category?access_token={0}", accessToken.AsUrlData());
  305. return await CommonJsonSend.SendAsync<GetMerchantCategoryResultJson>(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
  306. }, accessTokenOrAppId);
  307. }
  308. /// <summary>
  309. /// 【异步方法】创建门店小程序
  310. /// </summary>
  311. /// <param name="accessTokenOrAppId"></param>
  312. /// <param name="data"></param>
  313. /// <param name="timeOut"></param>
  314. /// <returns></returns>
  315. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.ApplyMerchantAsync", true)]
  316. public static async Task<WxJsonResult> ApplyMerchantAsync(string accessTokenOrAppId, ApplyMerchantData data, int timeOut = Config.TIME_OUT)
  317. {
  318. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  319. {
  320. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/apply_merchant?access_token={0}", accessToken.AsUrlData());
  321. return await CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  322. }, accessTokenOrAppId);
  323. }
  324. /// <summary>
  325. /// 【异步方法】查询门店小程序审核结果
  326. /// </summary>
  327. /// <param name="accessTokenOrAppId"></param>
  328. /// <param name="timeOut"></param>
  329. /// <returns></returns>
  330. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetMerchantAuditInfoAsync", true)]
  331. public static async Task<GetMerchantAuditInfoResultJson> GetMerchantAuditInfoAsync(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  332. {
  333. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  334. {
  335. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_merchant_audit_info?access_token={0}", accessToken.AsUrlData());
  336. return await CommonJsonSend.SendAsync<GetMerchantAuditInfoResultJson>(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
  337. }, accessTokenOrAppId);
  338. }
  339. /// <summary>
  340. /// 【异步方法】修改门店小程序信息
  341. /// </summary>
  342. /// <param name="accessTokenOrAppId"></param>
  343. /// <param name="headingMediaid"></param>
  344. /// <param name="intro"></param>
  345. /// <param name="timeOut"></param>
  346. /// <returns></returns>
  347. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.ModifyMerchantAsync", true)]
  348. public static async Task<WxJsonResult> ModifyMerchantAsync(string accessTokenOrAppId, string headingMediaid, string intro, int timeOut = Config.TIME_OUT)
  349. {
  350. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  351. {
  352. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/modify_merchant?access_token={0}", accessToken.AsUrlData());
  353. var data = new
  354. {
  355. headimg_mediaid = headingMediaid,
  356. intro
  357. };
  358. return await CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  359. }, accessTokenOrAppId);
  360. }
  361. /// <summary>
  362. /// 【异步方法】从腾讯地图拉取省市区信息
  363. /// </summary>
  364. /// <param name="accessTokenOrAppId"></param>
  365. /// <param name="timeOut"></param>
  366. /// <returns></returns>
  367. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetDistrictAsync", true)]
  368. public static async Task<GetDistrictResultJson> GetDistrictAsync(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  369. {
  370. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  371. {
  372. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_district?access_token={0}", accessToken.AsUrlData());
  373. return await CommonJsonSend.SendAsync<GetDistrictResultJson>(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
  374. }, accessTokenOrAppId);
  375. }
  376. /// <summary>
  377. /// 【异步方法】在腾讯地图中搜索门店
  378. /// </summary>
  379. /// <param name="accessTokenOrAppId"></param>
  380. /// <param name="districtId"></param>
  381. /// <param name="keyword"></param>
  382. /// <param name="timeOut"></param>
  383. /// <returns></returns>
  384. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.SearchMapPoiAsync", true)]
  385. public static async Task<SearchMapPoiResultJson> SearchMapPoiAsync(string accessTokenOrAppId, string districtId, string keyword, int timeOut = Config.TIME_OUT)
  386. {
  387. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  388. {
  389. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/search_map_poi?access_token={0}", accessToken.AsUrlData());
  390. var data = new
  391. {
  392. districtid = districtId,
  393. keyword
  394. };
  395. return await CommonJsonSend.SendAsync<SearchMapPoiResultJson>(null, urlFormat, data, timeOut: timeOut);
  396. }, accessTokenOrAppId);
  397. }
  398. /// <summary>
  399. /// 【异步方法】在腾讯地图中创建门店
  400. /// </summary>
  401. /// <param name="accessTokenOrAppId"></param>
  402. /// <param name="data"></param>
  403. /// <param name="timeOut"></param>
  404. /// <returns></returns>
  405. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.CreateMapPoiAsync", true)]
  406. public static async Task<CreateMapPoiResultJson> CreateMapPoiAsync(string accessTokenOrAppId, CreateMapPoiData data, int timeOut = Config.TIME_OUT)
  407. {
  408. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  409. {
  410. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/create_map_poi?access_token={0}", accessToken.AsUrlData());
  411. return await CommonJsonSend.SendAsync<CreateMapPoiResultJson>(null, urlFormat, data, timeOut: timeOut);
  412. }, accessTokenOrAppId);
  413. }
  414. /// <summary>
  415. /// 【异步方法】添加门店
  416. /// </summary>
  417. /// <param name="accessTokenOrAppId"></param>
  418. /// <param name="data"></param>
  419. /// <param name="timeOut"></param>
  420. /// <returns></returns>
  421. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.AddStoreAsync", true)]
  422. public static async Task<AddStoreResultJson> AddStoreAsync(string accessTokenOrAppId, AddStoreData data, int timeOut = Config.TIME_OUT)
  423. {
  424. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  425. {
  426. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/add_store?access_token={0}", accessToken.AsUrlData());
  427. return await CommonJsonSend.SendAsync<AddStoreResultJson>(null, urlFormat, data, timeOut: timeOut);
  428. }, accessTokenOrAppId);
  429. }
  430. /// <summary>
  431. /// 【异步方法】更新门店信息
  432. /// </summary>
  433. /// <param name="accessTokenOrAppId"></param>
  434. /// <param name="data"></param>
  435. /// <param name="timeOut"></param>
  436. /// <returns></returns>
  437. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.UpdateStoreAsync", true)]
  438. public static async Task<UpdateStoreResultJson> UpdateStoreAsync(string accessTokenOrAppId, UpdateStoreData data, int timeOut = Config.TIME_OUT)
  439. {
  440. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  441. {
  442. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/update_store?access_token={0}", accessToken.AsUrlData());
  443. return await CommonJsonSend.SendAsync<UpdateStoreResultJson>(null, urlFormat, data, timeOut: timeOut);
  444. }, accessTokenOrAppId);
  445. }
  446. /// <summary>
  447. /// 【异步方法】获取单个门店信息
  448. /// </summary>
  449. /// <param name="accessTokenOrAppId"></param>
  450. /// <param name="poiId"></param>
  451. /// <param name="timeOut"></param>
  452. /// <returns></returns>
  453. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetStoreInfoAsync", true)]
  454. public static async Task<GetStoreInfoResultJson> GetStoreInfoAsync(string accessTokenOrAppId, string poiId, int timeOut = Config.TIME_OUT)
  455. {
  456. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  457. {
  458. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_store_info?access_token={0}", accessToken.AsUrlData());
  459. var data = new
  460. {
  461. poi_id = poiId
  462. };
  463. return await CommonJsonSend.SendAsync<GetStoreInfoResultJson>(null, urlFormat, data, timeOut: timeOut);
  464. }, accessTokenOrAppId);
  465. }
  466. /// <summary>
  467. /// 【异步方法】获取门店信息列表
  468. /// </summary>
  469. /// <param name="accessTokenOrAppId"></param>
  470. /// <param name="offset"></param>
  471. /// <param name="limit"></param>
  472. /// <param name="timeOut"></param>
  473. /// <returns></returns>
  474. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetStoreListAsync", true)]
  475. public static async Task<GetStoreListResultJson> GetStoreListAsync(string accessTokenOrAppId, int offset, int limit, int timeOut = Config.TIME_OUT)
  476. {
  477. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  478. {
  479. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_store_list?access_token={0}", accessToken.AsUrlData());
  480. var data = new
  481. {
  482. offset = offset,
  483. limit = limit
  484. };
  485. return await CommonJsonSend.SendAsync<GetStoreListResultJson>(null, urlFormat, data, timeOut: timeOut);
  486. }, accessTokenOrAppId);
  487. }
  488. /// <summary>
  489. /// 【异步方法】删除门店
  490. /// </summary>
  491. /// <param name="accessTokenOrAppId"></param>
  492. /// <param name="poiId"></param>
  493. /// <param name="timeOut"></param>
  494. /// <returns></returns>
  495. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.DelStoreAsync", true)]
  496. public static async Task<WxJsonResult> DelStoreAsync(string accessTokenOrAppId, string poiId, int timeOut = Config.TIME_OUT)
  497. {
  498. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  499. {
  500. var urlFormat = string.Format(Config.ApiMpHost + "/wxa/del_store?access_token={0}", accessToken.AsUrlData());
  501. var data = new
  502. {
  503. poi_id = poiId
  504. };
  505. return await CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  506. }, accessTokenOrAppId);
  507. }
  508. /// <summary>
  509. /// 【异步方法】获取门店小程序配置的卡券
  510. /// </summary>
  511. /// <param name="accessTokenOrAppId"></param>
  512. /// <param name="poiId"></param>
  513. /// <param name="timeOut"></param>
  514. /// <returns></returns>
  515. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetStoreCardAsync", true)]
  516. public static async Task<GetStoreCardResultJson> GetStoreCardAsync(string accessTokenOrAppId, string poiId, int timeOut = Config.TIME_OUT)
  517. {
  518. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  519. {
  520. var urlFormat = string.Format(Config.ApiMpHost + "/card/storewxa/get?access_token={0}", accessToken.AsUrlData());
  521. var data = new
  522. {
  523. poi_id = poiId
  524. };
  525. return await CommonJsonSend.SendAsync<GetStoreCardResultJson>(null, urlFormat, data, timeOut: timeOut);
  526. }, accessTokenOrAppId);
  527. }
  528. /// <summary>
  529. /// 设置门店小程序配置的卡券
  530. /// </summary>
  531. /// <param name="accessTokenOrAppId"></param>
  532. /// <param name="poiId"></param>
  533. /// <param name="cardId"></param>
  534. /// <param name="timeOut"></param>
  535. /// <returns></returns>
  536. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.SetStoreCardAsync", true)]
  537. public static async Task<WxJsonResult> SetStoreCardAsync(string accessTokenOrAppId, string poiId, string cardId, int timeOut = Config.TIME_OUT)
  538. {
  539. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  540. {
  541. var urlFormat = string.Format(Config.ApiMpHost + "/card/storewxa/set?access_token={0}", accessToken.AsUrlData());
  542. var data = new
  543. {
  544. poi_id = poiId,
  545. card_id = cardId
  546. };
  547. return await CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  548. }, accessTokenOrAppId);
  549. }
  550. #endregion
  551. #endif
  552. }
  553. }