123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169 |
- #region Apache License Version 2.0
- /*----------------------------------------------------------------
- Copyright 2019 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software distributed under the
- License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- either express or implied. See the License for the specific language governing permissions
- and limitations under the License.
- Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md
- ----------------------------------------------------------------*/
- #endregion Apache License Version 2.0
- /*----------------------------------------------------------------
- Copyright (C) 2019 Senparc
- 文件名:ShakeAroundApi.cs
- 文件功能描述:摇一摇周边接口
- 创建标识:Senparc - 20150512
- 修改标识:Senparc - 20160216
- 修改描述:添加 查询设备与页面的关联关系 接口
- 修改标识:Senparc - 20160424
- 修改描述:v13.7.5 添加 ShakeAroundApi.DeviceApplyStatus 接口
-
- 修改标识:Senparc - 20160520
- 修改描述:添加批量查询页面统计数据接口,新增分组接口,编辑分组信息接口,删除分组接口,查询分组列表接口,
- 查询分组详情接口,添加设备到分组接口,从分组中移除设备接口,创建红包活动接口,录入红包信息接口,
- 设置红包活动抽奖开关接口,红包查询接口
- 修改标识:Senparc - 20160520
- 修改描述:修改批量查询设备统计数据接口
- 修改标识:Senparc 20160719
- 修改描述:增加其接口的异步方法
-
- 修改标识:Senparc 20160823
- 修改描述:modify DeletePage,DeletePageAsync中的方法中的参数,即longn []pageIds改为long pageId
- 修改标识:Senparc 20170110
- 修改描述:将lastSeen参数调整为long类型
- 修改标识:Senparc 20170509
- 修改描述:v14.4.7 修改 GroupGetAdddevice 数据结构
- 修改标识:Senparc - 20170707
- 修改描述:v14.5.1 完善异步方法async/await
- 修改标识:Senparc - 20180522
- 修改描述:v14.5.1 完善异步方法async/await
- 修改标识:Senparc - 20190129
- 修改描述:统一 CommonJsonSend.Send<T>() 方法请求接口
- ----------------------------------------------------------------*/
- /*
- API:http://mp.weixin.qq.com/wiki/15/b9e012f917e3484b7ed02771156411f3.html
- */
- using System;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using Senparc.Weixin.Entities;
- using Senparc.CO2NET.HttpUtility;
- using Senparc.Weixin.MP.AdvancedAPIs.ShakeAround;
- using Senparc.Weixin.MP.CommonAPIs;
- using System.Linq;
- using Senparc.CO2NET.Extensions;
- using Senparc.NeuChar;
- using Senparc.Weixin.CommonAPIs;
- namespace Senparc.Weixin.MP.AdvancedAPIs
- {
- /// <summary>
- /// 摇一摇周边接口
- /// </summary>
- public static class ShakeAroundApi
- {
- #region 同步方法
- /// <summary>
- /// 申请开通功能
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="data"></param>
- /// <param name="industry_Id"></param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.Register", true)]
- public static RegisterResultJson Register(string accessTokenOrAppId, RegisterData data, IndustryId industry_Id, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- string url = string.Format(Config.ApiMpHost + "/shakearound/account/register?access_token={0}", accessToken.AsUrlData());
- data.industry_id = RegisterData.ConvertIndustryId(industry_Id);
- return CommonJsonSend.Send<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 查询审核状态
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GetAuditStatus", true)]
- public static GetAuditStatusResultJson GetAuditStatus(string accessTokenOrAppId)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- string url = string.Format(Config.ApiMpHost + "/shakearound/account/auditstatus?access_token={0}", accessToken.AsUrlData());
- return CommonJsonSend.Send<GetAuditStatusResultJson>(null, url, null, CommonJsonSendType.GET);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 申请设备ID
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="quantity">申请的设备ID的数量,单次新增设备超过500个,需走人工审核流程</param>
- /// <param name="applyReason">申请理由,不超过100个字</param>
- /// <param name="comment">备注,不超过15个汉字或30个英文字母</param>
- /// <param name="poiId">设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceApply", true)]
- public static DeviceApplyResultJson DeviceApply(string accessTokenOrAppId, int quantity, string applyReason, string comment = null, long? poiId = null, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- string url = string.Format(Config.ApiMpHost + "/shakearound/device/applyid?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- quantity = quantity,
- apply_reason = applyReason,
- comment = comment,
- poi_id = poiId
- };
- return CommonJsonSend.Send<DeviceApplyResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 查询设备ID申请审核状态
- /// 接口说明 查询设备ID申请的审核状态。若单次申请的设备ID数量小于等于500个,系统会进行快速审核;若单次申请的设备ID数量大于500个,则在三个工作日内完成审核。
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="appId">批次ID,申请设备ID时所返回的批次ID</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceApplyStatus", true)]
- public static GetDeviceStatusResultJson DeviceApplyStatus(string accessTokenOrAppId, long appId, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- string url = string.Format(Config.ApiMpHost + "/shakearound/device/applystatus?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- apply_id = appId,
- };
- return CommonJsonSend.Send<GetDeviceStatusResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 编辑设备信息
- /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
- /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息。
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="deviceId">设备编号</param>
- /// <param name="uuId"></param>
- /// <param name="major"></param>
- /// <param name="minor"></param>
- /// <param name="comment"></param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceUpdate", true)]
- public static WxJsonResult DeviceUpdate(string accessTokenOrAppId, long deviceId, string uuId, long major, long minor, string comment, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- string url = string.Format(Config.ApiMpHost + "/shakearound/device/update?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- device_identifier = new
- {
- device_id = deviceId,
- uuid = uuId,
- major = major,
- minor = minor
- },
- comment = comment
- };
- return CommonJsonSend.Send<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 配置设备与门店的关联关系
- /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
- /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息。
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="deviceId">设备编号</param>
- /// <param name="uuid"></param>
- /// <param name="major"></param>
- /// <param name="minor"></param>
- /// <param name="poiId">Poi_id 的说明改为:设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。</param>
- /// <param name="type">为1时,关联的门店和设备归属于同一公众账号;为2时,关联的门店为其他公众账号的门店。不填默认为1</param>
- /// <param name="timeOut"></param>
- /// <param name="poiAppid">当Type为2时,必填 关联门店所归属的公众账号的APPID</param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceBindLocatoin", true)]
- 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)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- string url = string.Format(Config.ApiMpHost + "/shakearound/device/bindlocation?access_token={0}", accessToken.AsUrlData());
- var data = type == 2
- ? new
- {
- device_identifier = new
- {
- device_id = deviceId,
- uuid = uuid,
- major = major,
- minor = minor
- },
- poi_id = poiId,
- type = type,
- poi_appid = poiAppid
- } as object
- : new
- {
- device_identifier = new
- {
- device_id = deviceId,
- uuid = uuid,
- major = major,
- minor = minor
- },
- poi_id = poiId
- } as object;
- return CommonJsonSend.Send<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 配置设备与其他门店的关联关系
- /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
- /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息。
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="deviceId">设备编号</param>
- /// <param name="uuid"></param>
- /// <param name="major"></param>
- /// <param name="minor"></param>
- /// <param name="poiId">Poi_id 的说明改为:设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。</param>
- /// <param name="timeOut"></param>
- /// <param name="type">为1时,关联的门店和设备归属于同一公众账号;为2时,关联的门店为其他公众账号的门店。不填默认为1</param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceBindLocatoin", true)]
- public static WxJsonResult DeviceBindLocatoin(string accessTokenOrAppId, long deviceId, string uuid, long major, long minor, long poiId, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- string url = string.Format(Config.ApiMpHost + "/shakearound/device/bindlocation?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- device_identifier = new
- {
- device_id = deviceId,
- uuid = uuid,
- major = major,
- minor = minor
- },
- poi_id = poiId
- };
- return CommonJsonSend.Send<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- #region 查询设备列表
- /// <summary>
- /// 查询设备列表Api url
- /// </summary>
- private static string searchDeviceUrl = Config.ApiMpHost + "/shakearound/device/search?access_token={0}";
- /// <summary>
- /// 根据指定的设备Id查询设备列表
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="deviceIdentifiers">设备Id列表</param>
- /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
- /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息。
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchDeviceById", true)]
- public static DeviceSearchResultJson SearchDeviceById(string accessTokenOrAppId, List<DeviceApply_Data_Device_Identifiers> deviceIdentifiers, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var data = new
- {
- device_identifiers = deviceIdentifiers
- };
- return CommonJsonSend.Send<DeviceSearchResultJson>(accessToken, searchDeviceUrl, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 根据分页查询或者指定范围查询设备列表
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="lastSeen">前一次查询列表末尾的设备ID,第一次查询lastSeen为0</param>
- /// <param name="count">待查询的设备数量,不能超过50个</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchDeviceByRange", true)]
- public static DeviceSearchResultJson SearchDeviceByRange(string accessTokenOrAppId, int lastSeen, int count, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var data = new
- {
- last_seen = lastSeen,
- count = count
- };
- return CommonJsonSend.Send<DeviceSearchResultJson>(accessToken, searchDeviceUrl, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 根据批次ID查询设备列表
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="applyId">批次ID,申请设备ID时所返回的批次ID</param>
- /// <param name="lastSeen">前一次查询列表末尾的设备ID,第一次查询lastSeen为0</param>
- /// <param name="count">待查询的设备数量,不能超过50个</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchDeviceByApplyId", true)]
- public static DeviceSearchResultJson SearchDeviceByApplyId(string accessTokenOrAppId, long applyId, long lastSeen, int count, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var data = new
- {
- apply_id = applyId,
- last_seen = lastSeen,
- count = count
- };
- return CommonJsonSend.Send<DeviceSearchResultJson>(accessToken, searchDeviceUrl, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- #endregion
- /// <summary>
- /// 上传图片素材
- /// 上传在摇一摇页面展示的图片素材,素材保存在微信侧服务器上。 格式限定为:jpg,jpeg,png,gif,图片大小建议120px*120 px,限制不超过200 px *200 px,图片需为正方形。
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="file"></param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.UploadImage", true)]
- public static UploadImageResultJson UploadImage(string accessTokenOrAppId, string file, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/material/add?access_token={0}", accessToken.AsUrlData());
- var fileDictionary = new Dictionary<string, string>();
- fileDictionary["media"] = file;
- return Post.PostFileGetJson<UploadImageResultJson>(url, null, fileDictionary, null, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 新增页面
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="title">在摇一摇页面展示的主标题,不超过6个字</param>
- /// <param name="description">在摇一摇页面展示的副标题,不超过7个字</param>
- /// <param name="pageUrl">点击页面跳转链接</param>
- /// <param name="iconUrl">在摇一摇页面展示的图片。图片需先上传至微信侧服务器,用“素材管理-上传图片素材”接口上传图片,返回的图片URL再配置在此处</param>
- /// <param name="comment">页面的备注信息,不超过15个字</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.AddPage", true)]
- public static AddPageResultJson AddPage(string accessTokenOrAppId, string title, string description, string pageUrl,
- string iconUrl, string comment = null, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/page/add?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- title = title,
- description = description,
- page_url = pageUrl,
- comment = comment,
- icon_url = iconUrl
- };
- return CommonJsonSend.Send<AddPageResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 编辑页面信息
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="pageId">摇周边页面唯一ID</param>
- /// <param name="title">在摇一摇页面展示的主标题,不超过6个字</param>
- /// <param name="description">在摇一摇页面展示的副标题,不超过7个字</param>
- /// <param name="pageUrl">点击页面跳转链接</param>
- /// <param name="iconUrl">在摇一摇页面展示的图片。图片需先上传至微信侧服务器,用“素材管理-上传图片素材”接口上传图片,返回的图片URL再配置在此处</param>
- /// <param name="comment">页面的备注信息,不超过15个字</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.UpdatePage", true)]
- public static UpdatePageResultJson UpdatePage(string accessTokenOrAppId, long pageId, string title, string description, string pageUrl,
- string iconUrl, string comment = null, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/page/update?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- page_id = pageId,
- title = title,
- description = description,
- page_url = pageUrl,
- comment = comment,
- icon_url = iconUrl
- };
- return CommonJsonSend.Send<UpdatePageResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- #region 查询页面列表
- private static string searchPageUrl =
- Config.ApiMpHost + "/shakearound/page/search?access_token={0}";
- /// <summary>
- /// 根据页面Id查询页面列表
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="pageIds">指定页面的Id数组</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchPagesByPageId", true)]
- public static SearchPagesResultJson SearchPagesByPageId(string accessTokenOrAppId, long[] pageIds,
- int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var data = new
- {
- page_ids = pageIds
- };
- return CommonJsonSend.Send<SearchPagesResultJson>(accessToken, searchPageUrl, data, CommonJsonSendType.POST,
- timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 根据分页或者指定范围查询页面列表
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="begin"></param>
- /// <param name="count"></param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchPagesByRange", true)]
- public static SearchPagesResultJson SearchPagesByRange(string accessTokenOrAppId, int begin, int count,
- int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var data = new
- {
- begin = begin,
- count = count
- };
- return CommonJsonSend.Send<SearchPagesResultJson>(accessToken, searchPageUrl, data, CommonJsonSendType.POST,
- timeOut);
- }, accessTokenOrAppId);
- }
- #endregion
- /// <summary>
- /// 删除页面
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="pageId">指定页面的Id数组</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeletePage", true)]
- public static WxJsonResult DeletePage(string accessTokenOrAppId, long pageId, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/page/delete?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- page_id = pageId
- };
- return CommonJsonSend.Send<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 配置设备与页面的关联关系
- /// 配置设备与页面的关联关系。支持建立或解除关联关系,也支持新增页面或覆盖页面等操作。配置完成后,在此设备的信号范围内,即可摇出关联的页面信息。若设备配置多个页面,则随机出现页面信息。一个设备最多可配置30个关联页面。
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="deviceIdentifier"></param>
- /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
- /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息
- /// <param name="pageIds"></param>
- /// <param name="bindType">关联操作标志位, 0为解除关联关系,1为建立关联关系</param>
- /// <param name="appendType">新增操作标志位, 0为覆盖,1为新增</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.BindPage", true)]
- public static WxJsonResult BindPage(string accessTokenOrAppId, DeviceApply_Data_Device_Identifiers deviceIdentifier, long[] pageIds, ShakeAroundBindType bindType, ShakeAroundAppendType appendType, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/device/bindpage?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- device_identifier = deviceIdentifier,
- page_ids = pageIds,
- bind = (int)bindType,
- append = (int)appendType
- };
- return CommonJsonSend.Send<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 查询设备的关联关系
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="deviceIdentifier">指定的设备</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.RelationSearch", true)]
- public static RelationSearchResultJson RelationSearch(string accessTokenOrAppId, DeviceApply_Data_Device_Identifiers deviceIdentifier, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/relation/search?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- type = 1,
- device_identifier = deviceIdentifier
- };
- return CommonJsonSend.Send<RelationSearchResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 查询页面的关联关系
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="pageId">指定的页面id</param>
- /// <param name="begin">关联关系列表的起始索引值</param>
- /// <param name="count">待查询的关联关系数量,不能超过50个</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.RelationSearch", true)]
- public static RelationSearchResultJson RelationSearch(string accessTokenOrAppId, long pageId, int begin, int count, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/relation/search?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- type = 2,
- page_id = pageId,
- begin = begin,
- count = count
- };
- return CommonJsonSend.Send<RelationSearchResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 获取摇周边的设备及用户信息
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="ticket">摇周边业务的ticket,可在摇到的URL中得到,ticket生效时间为30分钟,每一次摇都会重新生成新的ticket</param>
- /// <param name="needPoi">是否需要返回门店poi_id,传1则返回,否则不返回</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GetShakeInfo", true)]
- public static GetShakeInfoResultJson GetShakeInfo(string accessTokenOrAppId, string ticket, int needPoi = 1,
- int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/user/getshakeinfo?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- ticket = ticket,
- need_poi = needPoi
- };
- return CommonJsonSend.Send<GetShakeInfoResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 以设备为维度的数据统计接口
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="deviceIdentifier">指定页面的设备ID</param>
- /// 设备编号,若填了UUID、major、minor,即可不填设备编号,二者选其一
- /// UUID、major、minor,三个信息需填写完成,若填了设备编辑,即可不填此信息,二者选其一
- /// <param name="beginDate">起始日期时间戳,最长时间跨度为30天</param>
- /// <param name="endDate">结束日期时间戳,最长时间跨度为30天</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.StatisticsByDevice", true)]
- public static StatisticsResultJson StatisticsByDevice(string accessTokenOrAppId,
- DeviceApply_Data_Device_Identifiers deviceIdentifier, long beginDate, long endDate,
- int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/statistics/device?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- device_identifier = deviceIdentifier,
- begin_date = beginDate,
- end_date = endDate
- };
- return CommonJsonSend.Send<StatisticsResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 以页面为维度的数据统计接口
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="pageId">指定页面的设备ID</param>
- /// <param name="beginDate">起始日期时间戳,最长时间跨度为30天</param>
- /// <param name="endDate">结束日期时间戳,最长时间跨度为30天</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.StatisticsByPage", true)]
- public static StatisticsResultJson StatisticsByPage(string accessTokenOrAppId,
- long pageId, long beginDate, long endDate,
- int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/statistics/page?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- page_id = pageId,
- begin_date = beginDate,
- end_date = endDate
- };
- return CommonJsonSend.Send<StatisticsResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 批量查询设备统计数据接口
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="date">指定查询日期时间戳,单位为秒</param>
- /// <param name="pageIndex">指定查询的结果页序号;返回结果按摇周边人数降序排序,每50条记录为一页</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceList", true)]
- public static DeviceListResultJson DeviceList(string accessTokenOrAppId, long date, string pageIndex, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/statistics/devicelist?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- date = date,
- page_index = pageIndex
- };
- return CommonJsonSend.Send<DeviceListResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 批量查询页面统计数据接口
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="date">指定查询日期时间戳,单位为秒</param>
- /// <param name="pageIndex">指定查询的结果页序号;返回结果按摇周边人数降序排序,每50条记录为一页</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.PageList", true)]
- public static PageListResultJson PageList(string accessTokenOrAppId, long date, int pageIndex, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/statistics/pagelist?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- date = date,
- page_index = pageIndex
- };
- return CommonJsonSend.Send<PageListResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 新增分组
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="groupName">分组名称,不超过100汉字或200个英文字母</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupAdd", true)]
- public static GroupAddResultJson GroupAdd(string accessTokenOrAppId, string groupName, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/add?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- group_name = groupName
- };
- return CommonJsonSend.Send<GroupAddResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 编辑分组信息
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="groupid">分组唯一标识,全局唯一</param>
- /// <param name="groupName">分组名称,不超过100汉字或200个英文字母</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupUpdate", true)]
- public static RegisterResultJson GroupUpdate(string accessTokenOrAppId, string groupid, string groupName, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/update?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- group_id = groupid,
- group_name = groupName
- };
- return CommonJsonSend.Send<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 删除分组
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="groupId">分组唯一标识,全局唯一</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupDelete", true)]
- public static RegisterResultJson GroupDelete(string accessTokenOrAppId, string groupId, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/delete?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- group_id = groupId
- };
- return CommonJsonSend.Send<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 查询分组列表
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="begin">分组列表的起始索引值</param>
- /// <param name="count">待查询的分组数量,不能超过1000个</param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupGetList", true)]
- public static GroupGetListResultJson GroupGetList(string accessTokenOrAppId, int begin, int count, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/getlist?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- begin = begin,
- count = count
- };
- return CommonJsonSend.Send<GroupGetListResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 查询分组详情
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="groupId">分组唯一标识,全局唯一</param>
- /// <param name="begin">分组列表的起始索引值</param>
- /// <param name="count">待查询的分组数量,不能超过1000个</param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupGetDetail", true)]
- public static GroupGetDetailResultJson GroupGetDetail(string accessTokenOrAppId, string groupId, int begin, int count, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/getdetail?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- group_id = groupId,
- begin = begin,
- count = count
- };
- return CommonJsonSend.Send<GroupGetDetailResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 添加设备到分组
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="groupId">分组唯一标识,全局唯一</param>
- /// <param name="deviceIdentifier">分组列表的起始索引值</param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupGetAdddevice", true)]
- public static RegisterResultJson GroupGetAdddevice(string accessTokenOrAppId, string groupId, List<DeviceApply_Data_Device_Identifiers> deviceIdentifiers, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/adddevice?access_token={0}", accessToken.AsUrlData());
- object data = new
- {
- group_id = groupId,
- device_identifiers = deviceIdentifiers.Select(item =>
- {
- object itemData = null;
- if (!item.device_id.HasValue)
- {
- /* UUID、major、minor,三个信息需填写完成,
- * 若填了设备编号,即可不填此信息,二者选其一
- */
- itemData = new
- {
- uuid = item.uuid,
- major = item.major,
- minor = item.minor
- };
- }
- else
- {
- /*设备编号,若填了UUID、major、minor,
- * 即可不填设备编号,二者选其一
- */
- itemData = new
- {
- device_id = item.device_id
- };
- }
- return itemData;
- })
- };
- return CommonJsonSend.Send<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 从分组中移除设备
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="groupId">分组唯一标识,全局唯一</param>
- /// <param name="deviceIdentifier">分组列表的起始索引值</param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupDeleteDevice", true)]
- public static RegisterResultJson GroupDeleteDevice(string accessTokenOrAppId, string groupId, DeviceApply_Data_Device_Identifiers deviceIdentifier, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/deletedevice?access_token={0}", accessToken.AsUrlData());
- var data = new object();
- if (!deviceIdentifier.device_id.HasValue)
- {
- data = new
- {
- group_id = groupId,
- uuid = deviceIdentifier.uuid,
- major = deviceIdentifier.major,
- minor = deviceIdentifier.minor
- };
- }
- else
- {
- data = new
- {
- group_id = groupId,
- device_id = deviceIdentifier.device_id.Value
- };
- }
- return CommonJsonSend.Send<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 创建红包活动
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="title">抽奖活动名称(选择使用模板时,也作为摇一摇消息主标题),最长6个汉字,12个英文字母。</param>
- /// <param name="desc">抽奖活动描述(选择使用模板时,也作为摇一摇消息副标题),最长7个汉字,14个英文字母。</param>
- /// <param name="onoff">抽奖开关。0关闭,1开启,默认为1</param>
- /// <param name="beginTime"> 抽奖活动开始时间,unix时间戳,单位秒</param>
- /// <param name="expireTime"> 抽奖活动结束时间,unix时间戳,单位秒,红包活动有效期最长为91天</param>
- /// <param name="sponsorAppid">红包提供商户公众号的appid,需与预下单中的公众账号appid(wxappid)一致</param>
- /// <param name="total">红包总数,红包总数是录入红包ticket总数的上限,因此红包总数应该大于等于预下单时红包ticket总数。</param>
- /// <param name="jumpUrl">红包关注界面后可以跳转到第三方自定义的页面</param>
- /// <param name="key">开发者自定义的key,用来生成活动抽奖接口的签名参数,长度32位。使用方式见sign生成规则</param>
- /// <param name="timeOut">请求超时时间</param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.AddLotteryInfo", true)]
- 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)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/lottery/addlotteryinfo?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- title = title,
- desc = desc,
- onoff = onoff,
- begin_time = beginTime,
- expire_time = expireTime,
- sponsor_appid = sponsorAppid,
- total = total,
- jumpurl = jumpUrl,
- key = key
- };
- return CommonJsonSend.Send<AddLotteryInfoResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 录入红包信息
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="lotteryId">红包抽奖id,来自addlotteryinfo返回的lottery_id</param>
- /// <param name="mchid">红包提供者的商户号,,需与预下单中的商户号mch_id一致</param>
- /// <param name="sponsorAppid">红包提供商户公众号的appid,需与预下单中的公众账号appid(wxappid)一致</param>
- /// <param name="prizeInfoList">红包ticket列表,如果红包数较多,可以一次传入多个红包,批量调用该接口设置红包信息。每次请求传入的红包个数上限为100</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SetPrizeBucket", true)]
- public static SetPrizeBucketResultJson SetPrizeBucket(string accessTokenOrAppId, string lotteryId, string mchid, string sponsorAppid, PrizeInfoList prizeInfoList, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/lottery/setprizebucket?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- lottery_id = lotteryId,
- mchid = mchid,
- sponsorapp_id = sponsorAppid,
- prizeinfolist = prizeInfoList
- };
- return CommonJsonSend.Send<SetPrizeBucketResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- ///设置红包活动抽奖开关
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="lotteryId">红包抽奖id,来自addlotteryinfo返回的lottery_id</param>
- /// <param name="onOff">活动抽奖开关,0:关闭,1:开启</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SetLotterySwitch", true)]
- public static WxJsonResult SetLotterySwitch(string accessTokenOrAppId, string lotteryId, int onOff, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/lottery/setlotteryswitch?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- lottery_id = lotteryId,
- onoff = onOff
- };
- return CommonJsonSend.Send<WxJsonResult>(null, url, data, CommonJsonSendType.GET, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- ///红包查询接口
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="lotteryId">红包抽奖id,来自addlotteryinfo返回的lottery_id</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.QueryLottery", true)]
- public static QueryLotteryJsonResult QueryLottery(string accessTokenOrAppId, string lotteryId, int timeOut = Config.TIME_OUT)
- {
- return ApiHandlerWapper.TryCommonApi(accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/lottery/querylottery?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- lottery_id = lotteryId
- };
- return CommonJsonSend.Send<QueryLotteryJsonResult>(null, url, data, CommonJsonSendType.GET, timeOut);
- }, accessTokenOrAppId);
- }
- #endregion
- #if !NET35 && !NET40
- #region 异步方法
- /// <summary>
- /// 【异步方法】申请开通功能
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="data"></param>
- /// <param name="industry_Id"></param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.RegisterAsync", true)]
- public static async Task<RegisterResultJson> RegisterAsync(string accessTokenOrAppId, RegisterData data, IndustryId industry_Id, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- string url = string.Format(Config.ApiMpHost + "/shakearound/account/register?access_token={0}", accessToken.AsUrlData());
- data.industry_id = RegisterData.ConvertIndustryId(industry_Id);
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】查询审核状态
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GetAuditStatusAsync", true)]
- public static async Task<GetAuditStatusResultJson> GetAuditStatusAsync(string accessTokenOrAppId)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- string url = string.Format(Config.ApiMpHost + "/shakearound/account/auditstatus?access_token={0}", accessToken.AsUrlData());
- return await CommonJsonSend.SendAsync<GetAuditStatusResultJson>(null, url, null, CommonJsonSendType.GET);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】申请设备ID
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="quantity">申请的设备ID的数量,单次新增设备超过500个,需走人工审核流程</param>
- /// <param name="applyReason">申请理由,不超过100个字</param>
- /// <param name="comment">备注,不超过15个汉字或30个英文字母</param>
- /// <param name="poiId">设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceApplyAsync", true)]
- public static async Task<DeviceApplyResultJson> DeviceApplyAsync(string accessTokenOrAppId, int quantity, string applyReason, string comment = null, long? poiId = null, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- string url = string.Format(Config.ApiMpHost + "/shakearound/device/applyid?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- quantity = quantity,
- apply_reason = applyReason,
- comment = comment,
- poi_id = poiId
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<DeviceApplyResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】查询设备ID申请审核状态
- /// 接口说明 查询设备ID申请的审核状态。若单次申请的设备ID数量小于等于500个,系统会进行快速审核;若单次申请的设备ID数量大于500个,则在三个工作日内完成审核。
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="appId">批次ID,申请设备ID时所返回的批次ID</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceApplyStatusAsync", true)]
- public static async Task<GetDeviceStatusResultJson> DeviceApplyStatusAsync(string accessTokenOrAppId, long appId, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- string url = string.Format(Config.ApiMpHost + "/shakearound/device/applystatus?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- apply_id = appId,
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetDeviceStatusResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】编辑设备信息
- /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
- /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息。
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="deviceId">设备编号</param>
- /// <param name="uuId"></param>
- /// <param name="major"></param>
- /// <param name="minor"></param>
- /// <param name="comment"></param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceUpdateAsync", true)]
- public static async Task<WxJsonResult> DeviceUpdateAsync(string accessTokenOrAppId, long deviceId, string uuId, long major, long minor, string comment, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- string url = string.Format(Config.ApiMpHost + "/shakearound/device/update?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- device_identifier = new
- {
- device_id = deviceId,
- uuid = uuId,
- major = major,
- minor = minor
- },
- comment = comment
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】配置设备与门店的关联关系
- /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
- /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息。
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="deviceId">设备编号</param>
- /// <param name="uuid"></param>
- /// <param name="major"></param>
- /// <param name="minor"></param>
- /// <param name="poiId">Poi_id 的说明改为:设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。</param>
- /// <param name="type">为1时,关联的门店和设备归属于同一公众账号;为2时,关联的门店为其他公众账号的门店。不填默认为1</param>
- /// <param name="timeOut"></param>
- /// <param name="poiAppid">当Type为2时,必填 关联门店所归属的公众账号的APPID</param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceBindLocatoinAsync", true)]
- 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)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- string url = string.Format(Config.ApiMpHost + "/shakearound/device/bindlocation?access_token={0}", accessToken.AsUrlData());
- var data = type == 2
- ? new
- {
- device_identifier = new
- {
- device_id = deviceId,
- uuid = uuid,
- major = major,
- minor = minor
- },
- poi_id = poiId,
- type = type,
- poi_appid = poiAppid
- } as object
- : new
- {
- device_identifier = new
- {
- device_id = deviceId,
- uuid = uuid,
- major = major,
- minor = minor
- },
- poi_id = poiId
- } as object;
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】配置设备与其他门店的关联关系
- /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
- /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息。
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="deviceId">设备编号</param>
- /// <param name="uuid"></param>
- /// <param name="major"></param>
- /// <param name="minor"></param>
- /// <param name="poiId">Poi_id 的说明改为:设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。</param>
- /// <param name="timeOut"></param>
- /// <param name="type">为1时,关联的门店和设备归属于同一公众账号;为2时,关联的门店为其他公众账号的门店。不填默认为1</param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceBindLocatoinAsync", true)]
- public static async Task<WxJsonResult> DeviceBindLocatoinAsync(string accessTokenOrAppId, long deviceId, string uuid, long major, long minor, long poiId, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- string url = string.Format(Config.ApiMpHost + "/shakearound/device/bindlocation?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- device_identifier = new
- {
- device_id = deviceId,
- uuid = uuid,
- major = major,
- minor = minor
- },
- poi_id = poiId
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- #region 查询设备列表
- /// <summary>
- /// 【异步方法】查询设备列表Api url
- /// </summary>
- // private static string searchDeviceUrl = Config.ApiMpHost + "/shakearound/device/search?access_token={0}";
- /// <summary>
- /// 根据指定的设备Id查询设备列表
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="deviceIdentifiers">设备Id列表</param>
- /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
- /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息。
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchDeviceByIdAsync", true)]
- public static async Task<DeviceSearchResultJson> SearchDeviceByIdAsync(string accessTokenOrAppId, List<DeviceApply_Data_Device_Identifiers> deviceIdentifiers, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var data = new
- {
- device_identifiers = deviceIdentifiers
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<DeviceSearchResultJson>(accessToken, searchDeviceUrl, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】根据分页查询或者指定范围查询设备列表
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="begin"></param>
- /// <param name="count"></param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchDeviceByRangeAsync", true)]
- public static async Task<DeviceSearchResultJson> SearchDeviceByRangeAsync(string accessTokenOrAppId, int begin, int count, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var data = new
- {
- begin = begin,
- count = count
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<DeviceSearchResultJson>(accessToken, searchDeviceUrl, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】根据批次ID查询设备列表
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="applyId"></param>
- /// <param name="begin"></param>
- /// <param name="count"></param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchDeviceByApplyIdAsync", true)]
- public static async Task<DeviceSearchResultJson> SearchDeviceByApplyIdAsync(string accessTokenOrAppId, long applyId, int begin, int count, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var data = new
- {
- apply_id = applyId,
- begin = begin,
- count = count
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<DeviceSearchResultJson>(accessToken, searchDeviceUrl, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- #endregion
- /// <summary>
- /// 【异步方法】上传图片素材
- /// 上传在摇一摇页面展示的图片素材,素材保存在微信侧服务器上。 格式限定为:jpg,jpeg,png,gif,图片大小建议120px*120 px,限制不超过200 px *200 px,图片需为正方形。
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="file"></param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.UploadImageAsync", true)]
- public static async Task<UploadImageResultJson> UploadImageAsync(string accessTokenOrAppId, string file, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/material/add?access_token={0}", accessToken.AsUrlData());
- var fileDictionary = new Dictionary<string, string>();
- fileDictionary["media"] = file;
- return await Post.PostFileGetJsonAsync<UploadImageResultJson>(url, null, fileDictionary, null, timeOut: timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】新增页面
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="title">在摇一摇页面展示的主标题,不超过6个字</param>
- /// <param name="description">在摇一摇页面展示的副标题,不超过7个字</param>
- /// <param name="pageUrl">点击页面跳转链接</param>
- /// <param name="iconUrl">在摇一摇页面展示的图片。图片需先上传至微信侧服务器,用“素材管理-上传图片素材”接口上传图片,返回的图片URL再配置在此处</param>
- /// <param name="comment">页面的备注信息,不超过15个字</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.AddPageAsync", true)]
- public static async Task<AddPageResultJson> AddPageAsync(string accessTokenOrAppId, string title, string description, string pageUrl,
- string iconUrl, string comment = null, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/page/add?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- title = title,
- description = description,
- page_url = pageUrl,
- comment = comment,
- icon_url = iconUrl
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AddPageResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】编辑页面信息
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="pageId">摇周边页面唯一ID</param>
- /// <param name="title">在摇一摇页面展示的主标题,不超过6个字</param>
- /// <param name="description">在摇一摇页面展示的副标题,不超过7个字</param>
- /// <param name="pageUrl">点击页面跳转链接</param>
- /// <param name="iconUrl">在摇一摇页面展示的图片。图片需先上传至微信侧服务器,用“素材管理-上传图片素材”接口上传图片,返回的图片URL再配置在此处</param>
- /// <param name="comment">页面的备注信息,不超过15个字</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.UpdatePageAsync", true)]
- public static async Task<UpdatePageResultJson> UpdatePageAsync(string accessTokenOrAppId, long pageId, string title, string description, string pageUrl,
- string iconUrl, string comment = null, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/page/update?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- page_id = pageId,
- title = title,
- description = description,
- page_url = pageUrl,
- comment = comment,
- icon_url = iconUrl
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<UpdatePageResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- #region 查询页面列表
- /*private static string searchPageUrl =Config.ApiMpHost + "/shakearound/page/search?access_token={0}";*/
- /// <summary>
- /// 【异步方法】根据页面Id查询页面列表
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="pageIds">指定页面的Id数组</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchPagesByPageIdAsync", true)]
- public static async Task<SearchPagesResultJson> SearchPagesByPageIdAsync(string accessTokenOrAppId, long[] pageIds,
- int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var data = new
- {
- page_ids = pageIds
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<SearchPagesResultJson>(accessToken, searchPageUrl, data, CommonJsonSendType.POST,
- timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】根据分页或者指定范围查询页面列表
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="lastSeen"></param>
- /// <param name="count"></param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SearchPagesByRangeAsync", true)]
- public static async Task<SearchPagesResultJson> SearchPagesByRangeAsync(string accessTokenOrAppId, long lastSeen, int count,
- int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var data = new
- {
- last_seen = lastSeen,
- count = count
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<SearchPagesResultJson>(accessToken, searchPageUrl, data, CommonJsonSendType.POST,
- timeOut);
- }, accessTokenOrAppId);
- }
- #endregion
- /// <summary>
- /// 【异步方法】删除页面
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="pageId">指定页面的Id数组</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeletePageAsync", true)]
- public static async Task<WxJsonResult> DeletePageAsync(string accessTokenOrAppId, long pageId, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/page/delete?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- page_id = pageId
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】配置设备与页面的关联关系
- /// 配置设备与页面的关联关系。支持建立或解除关联关系,也支持新增页面或覆盖页面等操作。配置完成后,在此设备的信号范围内,即可摇出关联的页面信息。若设备配置多个页面,则随机出现页面信息。一个设备最多可配置30个关联页面。
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="deviceIdentifier"></param>
- /// 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
- /// UUID、major、minor,三个信息需填写完整,若填了设备编号,则可不填此信息
- /// <param name="pageIds"></param>
- /// <param name="bindType">关联操作标志位, 0为解除关联关系,1为建立关联关系</param>
- /// <param name="appendType">新增操作标志位, 0为覆盖,1为新增</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.BindPageAsync", true)]
- public static async Task<WxJsonResult> BindPageAsync(string accessTokenOrAppId, DeviceApply_Data_Device_Identifiers deviceIdentifier, long[] pageIds, ShakeAroundBindType bindType, ShakeAroundAppendType appendType, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/device/bindpage?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- device_identifier = deviceIdentifier,
- page_ids = pageIds,
- bind = (int)bindType,
- append = (int)appendType
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】查询设备的关联关系
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="deviceIdentifier">指定的设备</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.RelationSearchAsync", true)]
- public static async Task<RelationSearchResultJson> RelationSearchAsync(string accessTokenOrAppId, DeviceApply_Data_Device_Identifiers deviceIdentifier, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/relation/search?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- type = 1,
- device_identifier = deviceIdentifier
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<RelationSearchResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】查询页面的关联关系
- /// </summary>
- /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
- /// <param name="pageId">指定的页面id</param>
- /// <param name="begin">关联关系列表的起始索引值</param>
- /// <param name="count">待查询的关联关系数量,不能超过50个</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.RelationSearchAsync", true)]
- public static async Task<RelationSearchResultJson> RelationSearchAsync(string accessTokenOrAppId, long pageId, int begin, int count, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/relation/search?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- type = 2,
- page_id = pageId,
- begin = begin,
- count = count
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<RelationSearchResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】获取摇周边的设备及用户信息
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="ticket">摇周边业务的ticket,可在摇到的URL中得到,ticket生效时间为30分钟,每一次摇都会重新生成新的ticket</param>
- /// <param name="needPoi">是否需要返回门店poi_id,传1则返回,否则不返回</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GetShakeInfoAsync", true)]
- public static async Task<GetShakeInfoResultJson> GetShakeInfoAsync(string accessTokenOrAppId, string ticket, int needPoi = 1,
- int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/user/getshakeinfo?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- ticket = ticket,
- need_poi = needPoi
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetShakeInfoResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】以设备为维度的数据统计接口
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="deviceIdentifier">指定页面的设备ID</param>
- /// 设备编号,若填了UUID、major、minor,即可不填设备编号,二者选其一
- /// UUID、major、minor,三个信息需填写完成,若填了设备编辑,即可不填此信息,二者选其一
- /// <param name="beginDate">起始日期时间戳,最长时间跨度为30天</param>
- /// <param name="endDate">结束日期时间戳,最长时间跨度为30天</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.StatisticsByDeviceAsync", true)]
- public static async Task<StatisticsResultJson> StatisticsByDeviceAsync(string accessTokenOrAppId,
- DeviceApply_Data_Device_Identifiers deviceIdentifier, long beginDate, long endDate,
- int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/statistics/device?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- device_identifier = deviceIdentifier,
- begin_date = beginDate,
- end_date = endDate
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<StatisticsResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】以页面为维度的数据统计接口
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="pageId">指定页面的设备ID</param>
- /// <param name="beginDate">起始日期时间戳,最长时间跨度为30天</param>
- /// <param name="endDate">结束日期时间戳,最长时间跨度为30天</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.StatisticsByPageAsync", true)]
- public static async Task<StatisticsResultJson> StatisticsByPageAsync(string accessTokenOrAppId,
- long pageId, long beginDate, long endDate,
- int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/statistics/page?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- page_id = pageId,
- begin_date = beginDate,
- end_date = endDate
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<StatisticsResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】批量查询设备统计数据接口
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="date">指定查询日期时间戳,单位为秒</param>
- /// <param name="pageIndex">指定查询的结果页序号;返回结果按摇周边人数降序排序,每50条记录为一页</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.DeviceListAsync", true)]
- public static async Task<DeviceListResultJson> DeviceListAsync(string accessTokenOrAppId, long date, string pageIndex, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/statistics/devicelist?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- date = date,
- page_index = pageIndex
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<DeviceListResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】批量查询页面统计数据接口
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="date">指定查询日期时间戳,单位为秒</param>
- /// <param name="pageIndex">指定查询的结果页序号;返回结果按摇周边人数降序排序,每50条记录为一页</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.PageListAsync", true)]
- public static async Task<PageListResultJson> PageListAsync(string accessTokenOrAppId, long date, int pageIndex, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/statistics/pagelist?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- date = date,
- page_index = pageIndex
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<PageListResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】新增分组
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="groupName">分组名称,不超过100汉字或200个英文字母</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupAddAsync", true)]
- public static async Task<GroupAddResultJson> GroupAddAsync(string accessTokenOrAppId, string groupName, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/add?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- group_name = groupName
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GroupAddResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】编辑分组信息
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="groupid">分组唯一标识,全局唯一</param>
- /// <param name="groupName">分组名称,不超过100汉字或200个英文字母</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupUpdateAsync", true)]
- public static async Task<RegisterResultJson> GroupUpdateAsync(string accessTokenOrAppId, string groupid, string groupName, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/update?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- group_id = groupid,
- group_name = groupName
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】删除分组
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="groupId">分组唯一标识,全局唯一</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupDeleteAsync", true)]
- public static async Task<RegisterResultJson> GroupDeleteAsync(string accessTokenOrAppId, string groupId, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/delete?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- group_id = groupId
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】查询分组列表
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="begin">分组列表的起始索引值</param>
- /// <param name="count">待查询的分组数量,不能超过1000个</param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupGetListAsync", true)]
- public static async Task<GroupGetListResultJson> GroupGetListAsync(string accessTokenOrAppId, int begin, int count, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/getlist?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- begin = begin,
- count = count
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GroupGetListResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】查询分组详情
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="groupId">分组唯一标识,全局唯一</param>
- /// <param name="begin">分组列表的起始索引值</param>
- /// <param name="count">待查询的分组数量,不能超过1000个</param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupGetDetailAsync", true)]
- public static async Task<GroupGetDetailResultJson> GroupGetDetailAsync(string accessTokenOrAppId, string groupId, int begin, int count, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/getdetail?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- group_id = groupId,
- begin = begin,
- count = count
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GroupGetDetailResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】添加设备到分组
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="groupId">分组唯一标识,全局唯一</param>
- /// <param name="deviceIdentifiers">分组列表的起始索引值</param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupGetAdddeviceAsync", true)]
- public static async Task<RegisterResultJson> GroupGetAdddeviceAsync(string accessTokenOrAppId, string groupId, List<DeviceApply_Data_Device_Identifiers> deviceIdentifiers, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/adddevice?access_token={0}", accessToken.AsUrlData());
- object data = new
- {
- group_id = groupId,
- device_identifiers = deviceIdentifiers.Select(item =>
- {
- object itemData = null;
- if (!item.device_id.HasValue)
- {
- /* UUID、major、minor,三个信息需填写完成,
- * 若填了设备编号,即可不填此信息,二者选其一
- */
- itemData = new
- {
- uuid = item.uuid,
- major = item.major,
- minor = item.minor
- };
- }
- else
- {
- /*设备编号,若填了UUID、major、minor,
- * 即可不填设备编号,二者选其一
- */
- itemData = new
- {
- device_id = item.device_id
- };
- }
- return itemData;
- })
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】从分组中移除设备
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="groupId">分组唯一标识,全局唯一</param>
- /// <param name="deviceIdentifier">分组列表的起始索引值</param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.GroupDeleteDeviceAsync", true)]
- public static async Task<RegisterResultJson> GroupDeleteDeviceAsync(string accessTokenOrAppId, string groupId, DeviceApply_Data_Device_Identifiers deviceIdentifier, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/device/group/deletedevice?access_token={0}", accessToken.AsUrlData());
- var data = new object();
- if (!deviceIdentifier.device_id.HasValue)
- {
- data = new
- {
- group_id = groupId,
- uuid = deviceIdentifier.uuid,
- major = deviceIdentifier.major,
- minor = deviceIdentifier.minor
- };
- }
- else
- {
- data = new
- {
- group_id = groupId,
- device_id = deviceIdentifier.device_id.Value
- };
- }
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<RegisterResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】创建红包活动
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="title">抽奖活动名称(选择使用模板时,也作为摇一摇消息主标题),最长6个汉字,12个英文字母。</param>
- /// <param name="desc">抽奖活动描述(选择使用模板时,也作为摇一摇消息副标题),最长7个汉字,14个英文字母。</param>
- /// <param name="onoff">抽奖开关。0关闭,1开启,默认为1</param>
- /// <param name="beginTime"> 抽奖活动开始时间,unix时间戳,单位秒</param>
- /// <param name="expireTime"> 抽奖活动结束时间,unix时间戳,单位秒,红包活动有效期最长为91天</param>
- /// <param name="sponsorAppid">红包提供商户公众号的appid,需与预下单中的公众账号appid(wxappid)一致</param>
- /// <param name="total">红包总数,红包总数是录入红包ticket总数的上限,因此红包总数应该大于等于预下单时红包ticket总数。</param>
- /// <param name="jumpUrl">红包关注界面后可以跳转到第三方自定义的页面</param>
- /// <param name="key">开发者自定义的key,用来生成活动抽奖接口的签名参数,长度32位。使用方式见sign生成规则</param>
- /// <param name="timeOut">请求超时时间</param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.AddLotteryInfoAsync", true)]
- 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)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/lottery/addlotteryinfo?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- title = title,
- desc = desc,
- onoff = onoff,
- begin_time = beginTime,
- expire_time = expireTime,
- sponsor_appid = sponsorAppid,
- total = total,
- jumpurl = jumpUrl,
- key = key
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<AddLotteryInfoResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- /// 【异步方法】录入红包信息
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="lotteryId">红包抽奖id,来自addlotteryinfo返回的lottery_id</param>
- /// <param name="mchid">红包提供者的商户号,,需与预下单中的商户号mch_id一致</param>
- /// <param name="sponsorAppid">红包提供商户公众号的appid,需与预下单中的公众账号appid(wxappid)一致</param>
- /// <param name="prizeInfoList">红包ticket列表,如果红包数较多,可以一次传入多个红包,批量调用该接口设置红包信息。每次请求传入的红包个数上限为100</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SetPrizeBucketAsync", true)]
- public static async Task<SetPrizeBucketResultJson> SetPrizeBucketAsync(string accessTokenOrAppId, string lotteryId, string mchid, string sponsorAppid, PrizeInfoList prizeInfoList, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/lottery/setprizebucket?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- lottery_id = lotteryId,
- mchid = mchid,
- sponsorapp_id = sponsorAppid,
- prizeinfolist = prizeInfoList
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<SetPrizeBucketResultJson>(null, url, data, CommonJsonSendType.POST, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- ///【异步方法】设置红包活动抽奖开关
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="lotteryId">红包抽奖id,来自addlotteryinfo返回的lottery_id</param>
- /// <param name="onOff">活动抽奖开关,0:关闭,1:开启</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.SetLotterySwitchAsync", true)]
- public static async Task<WxJsonResult> SetLotterySwitchAsync(string accessTokenOrAppId, string lotteryId, int onOff, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/lottery/setlotteryswitch?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- lottery_id = lotteryId,
- onoff = onOff
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, url, data, CommonJsonSendType.GET, timeOut);
- }, accessTokenOrAppId);
- }
- /// <summary>
- ///【异步方法】红包查询接口
- /// </summary>
- /// <param name="accessTokenOrAppId">调用接口凭证</param>
- /// <param name="lotteryId">红包抽奖id,来自addlotteryinfo返回的lottery_id</param>
- /// <param name="timeOut"></param>
- /// <returns></returns>
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "ShakeAroundApi.QueryLotteryAsync", true)]
- public static async Task<QueryLotteryJsonResult> QueryLotteryAsync(string accessTokenOrAppId, string lotteryId, int timeOut = Config.TIME_OUT)
- {
- return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
- {
- var url = string.Format(Config.ApiMpHost + "/shakearound/lottery/querylottery?access_token={0}", accessToken.AsUrlData());
- var data = new
- {
- lottery_id = lotteryId
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<QueryLotteryJsonResult>(null, url, data, CommonJsonSendType.GET, timeOut);
- }, accessTokenOrAppId);
- }
- #endregion
- #endif
- }
- }
|