CardAPI.cs 237 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711
  1. #region Apache License Version 2.0
  2. /*----------------------------------------------------------------
  3. Copyright 2019 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
  4. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
  5. except in compliance with the License. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software distributed under the
  8. License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  9. either express or implied. See the License for the specific language governing permissions
  10. and limitations under the License.
  11. Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md
  12. ----------------------------------------------------------------*/
  13. #endregion Apache License Version 2.0
  14. /*----------------------------------------------------------------
  15. Copyright (C) 2019 Senparc
  16. 文件名:CardApi.cs
  17. 文件功能描述:卡券高级功能API
  18. 创建标识:Senparc - 20150211
  19. 修改标识:Senparc - 20150212
  20. 修改描述:整理接口
  21. 修改标识:Senparc - 20150303
  22. 修改描述:整理接口
  23. 修改标识:Senparc - 20150312
  24. 修改描述:开放代理请求超时时间
  25. 修改标识:Senparc - 20150512
  26. 修改描述:门店接口过期处理
  27. 修改标识:Senparc - 20150717
  28. 修改描述:增加获取用户已领取卡券、修改库存接口
  29. 修改标识:Senparc - 20160520
  30. 修改描述:增加开通券点账户接口,对优惠券批价,查询券点余额接口,确认兑换库存接口,查询订单详情接口,查询券点流水详情接口,Mark(占用)Code接口,
  31. 拉取卡券概况数据接口,获取免费券数据接口,拉取会员卡数据接口,设置自助核销接口,创建子商户接口,
  32. 卡券开放类目查询接口,拉取单个子商户信息接口,拉取子商户列表接口,更新子商户接口,拉取单个子商户信息接口 ,
  33. 批量拉取子商户信息接口,母商户资质申请接口,母商户资质审核查询接口,子商户资质申请接口,子商户资质审核查询接口
  34. 修改标识:hello2008zj - 20160422
  35. 修改描述:修改CreateQR接口,匹配最新的文档
  36. 修改标识:Senparc - 20160718
  37. 修改描述:增加其接口的异步方法
  38. 修改标识:Senparc - 20170527
  39. 修改描述:v14.4.10 CardApi.CardBatchGet()方法增加statusList参数
  40. 修改标识:Senparc - 20170707
  41. 修改描述:v14.5.1 完善异步方法async/await
  42. 修改标识:Senparc - 20170810
  43. 修改描述:v14.5.11 更新CardApi.CardBatchGet()方法的statusList参数传值
  44. 修改标识:Senparc - 20170810
  45. 修改描述:v14.8.14 CardApi.UpdateUser() 方法参数中重新加添 add_bonus 和 add_balance 两个参数
  46. 修改标识:Senparc - 20180526
  47. 修改描述:v14.8.14 CardApi.UpdateUser() 方法参数中重新加添 add_bonus 和 add_balance 两个参数
  48. 修改标识:Senparc - 20180928
  49. 修改描述:添加拉取单张会员卡数据接口
  50. 修改标识:Senparc - 20180929
  51. 修改描述:添加获取开卡插件参数接口,获取用户开卡时提交的信息(跳转型开卡组件)接口,创建-礼品卡货架接口查询-礼品卡货架信息接口
  52. 修改标识:Senparc - 20180930
  53. 修改描述:添加查询-礼品卡货架信息接口,修改-礼品卡货架信息接口,查询-礼品卡货架列表接口,下架-礼品卡货架接口,申请微信支付礼品卡权限接口绑定商户号到礼品卡小程序接口,上传小程序代码,
  54. 查询-单个礼品卡订单信息接口,查询-批量查询礼品卡订单信息接口,更新用户礼品卡信息接口,退款接口
  55. 修改标识:Senparc - 20181008
  56. 修改描述:添加设置支付后投放卡券接口,删除支付后投放卡券规则接口,查询支付后投放卡券规则详情接口,批量查询支付后投放卡券规则接口,增加支付即会员规则接口,删除支付即会员规则接口,
  57. 查询商户号支付即会员规则接口,创建支付后领取立减金活动接口,使用授权码换取公众号的授权信息,确认授权,获取授权方的账户信息
  58. ----------------------------------------------------------------*/
  59. /*
  60. API地址:http://mp.weixin.qq.com/wiki/9/d8a5f3b102915f30516d79b44fe665ed.html
  61. PDF下载:https://mp.weixin.qq.com/zh_CN/htmledition/comm_htmledition/res/cardticket/wx_card_document.zip
  62. */
  63. using System;
  64. using System.Collections.Generic;
  65. using System.Threading.Tasks;
  66. using Senparc.Weixin.Entities;
  67. using Senparc.Weixin.Helpers;
  68. using Senparc.Weixin.MP.AdvancedAPIs.Card;
  69. using Senparc.Weixin.MP.CommonAPIs;
  70. using Senparc.Weixin.HttpUtility;
  71. using Senparc.CO2NET.Extensions;
  72. using Senparc.CO2NET.Helpers.Serializers;
  73. using Senparc.NeuChar;
  74. using Senparc.Weixin.CommonAPIs;
  75. namespace Senparc.Weixin.MP.AdvancedAPIs
  76. {
  77. /// <summary>
  78. /// 卡券接口
  79. /// </summary>
  80. public static class CardApi
  81. {
  82. #region 同步方法
  83. /// <summary>
  84. /// 创建卡券
  85. /// </summary>
  86. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  87. /// <param name="cardInfo">创建卡券需要的数据,格式可以看CardCreateData.cs</param>
  88. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  89. /// <returns></returns>
  90. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CreateCard", true)]
  91. public static CardCreateResultJson CreateCard(string accessTokenOrAppId, BaseCardInfo cardInfo, int timeOut = Config.TIME_OUT)
  92. {
  93. return ApiHandlerWapper.TryCommonApi(accessToken =>
  94. {
  95. var urlFormat = string.Format(Config.ApiMpHost + "/card/create?access_token={0}", accessToken.AsUrlData());
  96. CardCreateInfo cardData = null;
  97. CardType cardType = cardInfo.GetCardType();
  98. switch (cardType)
  99. {
  100. case CardType.GENERAL_COUPON:
  101. cardData = new CardCreateInfo()
  102. {
  103. card = new Card_GeneralCoupon()
  104. {
  105. card_type = cardType.ToString(),
  106. general_coupon = cardInfo as Card_GeneralCouponData
  107. }
  108. };
  109. break;
  110. case CardType.GROUPON:
  111. cardData = new CardCreateInfo()
  112. {
  113. card = new Card_Groupon()
  114. {
  115. card_type = cardType.ToString(),
  116. groupon = cardInfo as Card_GrouponData
  117. }
  118. };
  119. break;
  120. case CardType.GIFT:
  121. cardData = new CardCreateInfo()
  122. {
  123. card = new Card_Gift()
  124. {
  125. card_type = cardType.ToString(),
  126. gift = cardInfo as Card_GiftData
  127. }
  128. };
  129. break;
  130. case CardType.CASH:
  131. cardData = new CardCreateInfo()
  132. {
  133. card = new Card_Cash()
  134. {
  135. card_type = cardType.ToString(),
  136. cash = cardInfo as Card_CashData
  137. }
  138. };
  139. break;
  140. case CardType.DISCOUNT:
  141. cardData = new CardCreateInfo()
  142. {
  143. card = new Card_DisCount()
  144. {
  145. card_type = cardType.ToString(),
  146. discount = cardInfo as Card_DisCountData
  147. }
  148. };
  149. break;
  150. case CardType.MEMBER_CARD:
  151. cardData = new CardCreateInfo()
  152. {
  153. card = new Card_MemberCard()
  154. {
  155. card_type = cardType.ToString(),
  156. member_card = cardInfo as Card_MemberCardData
  157. }
  158. };
  159. break;
  160. case CardType.SCENIC_TICKET:
  161. cardData = new CardCreateInfo()
  162. {
  163. card = new Card_ScenicTicket()
  164. {
  165. card_type = cardType.ToString(),
  166. scenic_ticket = cardInfo as Card_ScenicTicketData
  167. }
  168. };
  169. break;
  170. case CardType.MOVIE_TICKET:
  171. cardData = new CardCreateInfo()
  172. {
  173. card = new Card_MovieTicket()
  174. {
  175. card_type = cardType.ToString(),
  176. movie_ticket = cardInfo as Card_MovieTicketData
  177. }
  178. };
  179. break;
  180. case CardType.BOARDING_PASS:
  181. cardData = new CardCreateInfo()
  182. {
  183. card = new Card_BoardingPass()
  184. {
  185. card_type = cardType.ToString(),
  186. boarding_pass = cardInfo as Card_BoardingPassData
  187. }
  188. };
  189. break;
  190. case CardType.LUCKY_MONEY:
  191. cardData = new CardCreateInfo()
  192. {
  193. card = new Card_LuckyMoney()
  194. {
  195. card_type = cardType.ToString(),
  196. lucky_money = cardInfo as Card_LuckyMoneyData
  197. }
  198. };
  199. break;
  200. case CardType.MEETING_TICKET:
  201. cardData = new CardCreateInfo()
  202. {
  203. card = new Card_MeetingTicket()
  204. {
  205. card_type = cardType.ToString(),
  206. meeting_ticket = cardInfo as Card_MeetingTicketData
  207. }
  208. };
  209. break;
  210. default:
  211. break;
  212. }
  213. var jsonSetting = new JsonSetting(true, null,
  214. new List<Type>()
  215. {
  216. //typeof (Modify_Msg_Operation),
  217. //typeof (CardCreateInfo),
  218. typeof (Card_BaseInfoBase)//过滤Modify_Msg_Operation主要起作用的是这个
  219. });
  220. var result = CommonJsonSend.Send<CardCreateResultJson>(null, urlFormat, cardData, timeOut: timeOut,
  221. //针对特殊字段的null值进行过滤
  222. jsonSetting: jsonSetting);
  223. return result;
  224. }, accessTokenOrAppId);
  225. }
  226. ///// <summary>
  227. ///// 此接口已取消,微信直接提供了十四种色值供选择,详见:http://mp.weixin.qq.com/wiki/8/b7e310e7943f7763450eced91fa793b0.html#.E5.8D.A1.E5.88.B8.E5.9F.BA.E7.A1.80.E4.BF.A1.E6.81.AF.E5.AD.97.E6.AE.B5.EF.BC.88.E9.87.8D.E8.A6.81.EF.BC.89
  228. ///// 获取颜色列表接口
  229. ///// </summary>
  230. ///// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  231. ///// <param name="timeOut">代理请求超时时间(毫秒)</param>
  232. ///// <returns></returns>
  233. /// <summary>
  234. /// 开通券点账户接口
  235. /// </summary>
  236. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  237. /// <param name="timeOut"></param>
  238. /// <returns></returns>
  239. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.PayActive", true)]
  240. public static PayActiveResultJson PayActive(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  241. {
  242. return ApiHandlerWapper.TryCommonApi(accessToken =>
  243. {
  244. var urlFormat = string.Format(Config.ApiMpHost + "/card/pay/activate?access_token={0}", accessToken.AsUrlData());
  245. return CommonJsonSend.Send<PayActiveResultJson>(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
  246. }, accessTokenOrAppId);
  247. }
  248. /// <summary>
  249. /// 对优惠券批价
  250. /// </summary>
  251. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  252. ///<param name="cardId">需要来配置库存的card_id</param>
  253. /// <param name="quantity">本次需要兑换的库存数目</param>
  254. /// <param name="timeOut"></param>
  255. /// <returns></returns>
  256. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetpayPrice", true)]
  257. public static GetpayPriceResultJson GetpayPrice(string accessTokenOrAppId, string cardId, int quantity, int timeOut = Config.TIME_OUT)
  258. {
  259. return ApiHandlerWapper.TryCommonApi(accessToken =>
  260. {
  261. var urlFormat = string.Format(Config.ApiMpHost + "/card/pay/getpayprice?access_token={0}", accessToken.AsUrlData());
  262. var data = new
  263. {
  264. card_id = cardId,
  265. quantity = quantity
  266. };
  267. return CommonJsonSend.Send<GetpayPriceResultJson>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
  268. }, accessTokenOrAppId);
  269. }
  270. /// <summary>
  271. /// 查询券点余额接口
  272. /// </summary>
  273. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  274. /// <param name="timeOut"></param>
  275. /// <returns></returns>
  276. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetCoinsInfo", true)]
  277. public static GetCoinsInfoResultJson GetCoinsInfo(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  278. {
  279. return ApiHandlerWapper.TryCommonApi(accessToken =>
  280. {
  281. var urlFormat = string.Format(Config.ApiMpHost + "/card/pay/getcoinsinfo?access_token={0}", accessToken.AsUrlData());
  282. return CommonJsonSend.Send<GetCoinsInfoResultJson>(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
  283. }, accessTokenOrAppId);
  284. }
  285. /// <summary>
  286. ///确认兑换库存接口
  287. /// </summary>
  288. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  289. /// <param name="cardId">需要来兑换库存的card_id</param>
  290. /// <param name="quantity">本次需要兑换的库存数目</param>
  291. /// <param name="orderId">仅可以使用上面得到的订单号,保证批价有效性</param>
  292. /// <param name="timeOut"></param>
  293. /// <returns></returns>
  294. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.PayConfirm", true)]
  295. public static WxJsonResult PayConfirm(string accessTokenOrAppId, string cardId, int quantity, string orderId, int timeOut = Config.TIME_OUT)
  296. {
  297. return ApiHandlerWapper.TryCommonApi(accessToken =>
  298. {
  299. var urlFormat = string.Format(Config.ApiMpHost + "/card/pay/confirm?access_token={0}", accessToken.AsUrlData());
  300. var data = new
  301. {
  302. card_id = cardId,
  303. quantity = quantity,
  304. order_id = orderId
  305. };
  306. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
  307. }, accessTokenOrAppId);
  308. }
  309. /// <summary>
  310. ///充值券点接口
  311. /// </summary>
  312. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  313. /// <param name="coinCount">需要充值的券点数目,1点=1元</param>
  314. /// <param name="timeOut"></param>
  315. /// <returns></returns>
  316. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.PayRecharge", true)]
  317. public static PayRechargeResultJson PayRecharge(string accessTokenOrAppId, int coinCount, int timeOut = Config.TIME_OUT)
  318. {
  319. return ApiHandlerWapper.TryCommonApi(accessToken =>
  320. {
  321. var urlFormat = string.Format(Config.ApiMpHost + "/card/pay/recharge?access_token={0}", accessToken.AsUrlData());
  322. var data = new
  323. {
  324. coin_count = coinCount
  325. };
  326. return CommonJsonSend.Send<PayRechargeResultJson>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
  327. }, accessTokenOrAppId);
  328. }
  329. /// <summary>
  330. ///查询订单详情接口
  331. /// </summary>
  332. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  333. /// <param name="orderId">上一步中获得的订单号,作为一次交易的唯一凭证</param>
  334. /// <param name="timeOut"></param>
  335. /// <returns></returns>
  336. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.PayGetOrder", true)]
  337. public static PayGetOrderResultJson PayGetOrder(string accessTokenOrAppId, int orderId, int timeOut = Config.TIME_OUT)
  338. {
  339. return ApiHandlerWapper.TryCommonApi(accessToken =>
  340. {
  341. var urlFormat = string.Format(Config.ApiMpHost + "/card/pay/getorder?access_token={0}", accessToken.AsUrlData());
  342. var data = new
  343. {
  344. order_id = orderId
  345. };
  346. return CommonJsonSend.Send<PayGetOrderResultJson>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
  347. }, accessTokenOrAppId);
  348. }
  349. /// <summary>
  350. ///查询券点流水详情接口
  351. /// </summary>
  352. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  353. /// <param name="offset">分批查询的起点,默认为0</param>
  354. /// <param name="count">分批查询的数量</param>
  355. /// <param name="orderType">所要拉取的订单类型ORDER_TYPE_SYS_ADD 平台赠送 ORDER_TYPE_WXPAY 充值 ORDER_TYPE_REFUND 库存回退券点 ORDER_TYPE_REDUCE 券点兑换库存 ORDER_TYPE_SYS_REDUCE 平台扣减</param>
  356. /// <param name="norFilter">反选,不要拉取的订单</param>
  357. /// <param name="sortInfo">对结果排序</param>
  358. /// <param name="beginTime">批量查询订单的起始事件,为时间戳,默认1周前</param>
  359. /// <param name="endTime">批量查询订单的结束事件,为时间戳,默认为当前时间</param>
  360. /// <param name="timeOut"></param>
  361. /// <returns></returns>
  362. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetOrderList", true)]
  363. public static GetOrderListResultJson GetOrderList(string accessTokenOrAppId, int offset, int count, string orderType, NorFilter norFilter, SortInfo sortInfo, int beginTime, int endTime, int timeOut = Config.TIME_OUT)
  364. {
  365. return ApiHandlerWapper.TryCommonApi(accessToken =>
  366. {
  367. var urlFormat = string.Format(Config.ApiMpHost + "/card/pay/getorderlist?access_token={0}", accessToken.AsUrlData());
  368. var data = new
  369. {
  370. offset = offset,
  371. count = count,
  372. order_type = orderType,
  373. nor_filter = norFilter,
  374. sort_info = sortInfo,
  375. begin_time = beginTime,
  376. end_time = endTime
  377. };
  378. return CommonJsonSend.Send<GetOrderListResultJson>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
  379. }, accessTokenOrAppId);
  380. }
  381. /// <summary>
  382. /// 生成卡券二维码
  383. /// 获取二维码ticket 后,开发者可用ticket 换取二维码图片。换取指引参考:http://mp.weixin.qq.com/wiki/index.php?title=生成带参数的二维码
  384. /// </summary>
  385. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  386. /// <param name="cardId">卡券ID</param>
  387. /// <param name="code">指定卡券code 码,只能被领一次。use_custom_code 字段为true 的卡券必须填写,非自定义code 不必填写。</param>
  388. /// <param name="openId">指定领取者的openid,只有该用户能领取。bind_openid 字段为true 的卡券必须填写,非自定义openid 不必填写。</param>
  389. /// <param name="expireSeconds">指定二维码的有效时间,范围是60 ~ 1800 秒。不填默认为永久有效。</param>
  390. /// <param name="isUniqueCode">指定下发二维码,生成的二维码随机分配一个code,领取后不可再次扫描。填写true 或false。默认false。</param>
  391. /// <param name="outer_id">自定义应用场景ID(v13.7.3起支持)</param>
  392. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  393. /// <returns></returns>
  394. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CreateQR", true)]
  395. public static CreateQRResultJson CreateQR(string accessTokenOrAppId, string cardId, string code = null,
  396. string openId = null, string expireSeconds = null,
  397. bool isUniqueCode = false, string outer_id = null,
  398. int timeOut = Config.TIME_OUT)
  399. {
  400. return ApiHandlerWapper.TryCommonApi(accessToken =>
  401. {
  402. var urlFormat = string.Format(Config.ApiMpHost + "/card/qrcode/create?access_token={0}", accessToken.AsUrlData());
  403. var data = new
  404. {
  405. action_name = "QR_CARD",
  406. expire_seconds = expireSeconds,
  407. action_info = new
  408. {
  409. card = new
  410. {
  411. card_id = cardId,
  412. code = code,
  413. openid = openId,
  414. //expire_seconds = expireSeconds,
  415. is_unique_code = false,
  416. //balance = balance,
  417. outer_id = outer_id
  418. }
  419. }
  420. };
  421. //var jsonSettingne = new JsonSetting(true);
  422. var jsonSetting = new JsonSetting(true, null,
  423. new List<Type>()
  424. {
  425. //typeof (Modify_Msg_Operation),
  426. //typeof (CardCreateInfo),
  427. data.action_info.card.GetType()//过滤Modify_Msg_Operation主要起作用的是这个
  428. });
  429. return CommonJsonSend.Send<CreateQRResultJson>(null, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  430. }, accessTokenOrAppId);
  431. }
  432. /// <summary>
  433. /// 创建发行多个卡券的二维码
  434. /// </summary>
  435. /// <param name="accessTokenOrAppId"></param>
  436. /// <param name="cardIds"></param>
  437. /// <param name="code"></param>
  438. /// <param name="openId"></param>
  439. /// <param name="expireSeconds"></param>
  440. /// <param name="isUniqueCode"></param>
  441. /// <param name="outer_id"></param>
  442. /// <param name="timeOut"></param>
  443. /// <returns></returns>
  444. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CreateMultipleCardQR", true)]
  445. public static CreateQRResultJson CreateMultipleCardQR(string accessTokenOrAppId,
  446. string[] cardIds,
  447. string code = null,
  448. string openId = null,
  449. string expireSeconds = null,
  450. bool isUniqueCode = false,
  451. string outer_id = null,
  452. int timeOut = Config.TIME_OUT
  453. )
  454. {
  455. return ApiHandlerWapper.TryCommonApi(accessToken =>
  456. {
  457. string urlFormat = string.Format(Config.ApiMpHost + "/card/qrcode/create?access_token={0}",
  458. accessToken.AsUrlData());
  459. List<QR_CARD_INFO> cardlist = new List<QR_CARD_INFO>();
  460. foreach (string cardid in cardIds)
  461. {
  462. cardlist.Add(new QR_CARD_INFO()
  463. {
  464. card_id = cardid,
  465. openid = openId,
  466. is_unique_code = isUniqueCode,
  467. outer_id = outer_id
  468. });
  469. }
  470. var data = new
  471. {
  472. action_name = "QR_MULTIPLE_CARD",
  473. expire_seconds = expireSeconds,
  474. action_info = new
  475. {
  476. multiple_card = new
  477. {
  478. card_list = cardlist
  479. }
  480. }
  481. };
  482. //var jsonSettingne = new JsonSetting(true);
  483. JsonSetting jsonSetting = new JsonSetting(true,
  484. null,
  485. new List<Type>()
  486. {
  487. //typeof (Modify_Msg_Operation),
  488. //typeof (CardCreateInfo),
  489. data.action_info.multiple_card.GetType() //过滤Modify_Msg_Operation主要起作用的是这个
  490. });
  491. return CommonJsonSend.Send<CreateQRResultJson>(null,
  492. urlFormat,
  493. data,
  494. timeOut: timeOut,
  495. jsonSetting: jsonSetting);
  496. },
  497. accessTokenOrAppId);
  498. }
  499. /// <summary>
  500. /// 创建货架
  501. /// </summary>
  502. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  503. /// <param name="data"></param>
  504. /// <param name="timeOut"></param>
  505. /// <returns></returns>
  506. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.ShelfCreate", true)]
  507. public static ShelfCreateResultJson ShelfCreate(string accessTokenOrAppId, ShelfCreateData data, int timeOut = Config.TIME_OUT)
  508. {
  509. return ApiHandlerWapper.TryCommonApi(accessToken =>
  510. {
  511. var urlFormat = string.Format(Config.ApiMpHost + "/card/landingpage/create?access_token={0}", accessToken.AsUrlData());
  512. return CommonJsonSend.Send<ShelfCreateResultJson>(null, urlFormat, data, timeOut: timeOut);
  513. }, accessTokenOrAppId);
  514. }
  515. /// <summary>
  516. /// 导入code
  517. ///
  518. /// 新创建卡券情况
  519. /// 如果开发者打算新创建一张支持导入code模式的卡券,不同于以往的创建方式,建议开发者采用以下流程创建预存code模式卡券,否则会报错。
  520. /// 步骤一:创建预存模式卡券,将库存quantity初始值设置为0,并填入Deposit_Mode字段;
  521. /// 步骤二:待卡券通过审核后,调用导入code接口并核查code;
  522. /// 步骤三:调用修改库存接口,须令卡券库存小于或等于导入code的数目。(为了避免混乱建议设置为相等)
  523. ///
  524. /// 注: 1)单次调用接口传入code的数量上限为100个。
  525. /// 2)每一个 code 均不能为空串。
  526. /// 3)导入结束后系统会自动判断提供方设置库存与实际导入code的量是否一致。
  527. /// 4)导入失败支持重复导入,提示成功为止。
  528. /// </summary>
  529. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  530. /// <param name="cardId">需要进行导入code的卡券ID</param>
  531. /// <param name="codeList">需导入微信卡券后台的自定义code,上限为100个。</param>
  532. /// <param name="timeOut"></param>
  533. /// <returns></returns>
  534. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CodeDeposit", true)]
  535. public static WxJsonResult CodeDeposit(string accessTokenOrAppId, string cardId, string[] codeList, int timeOut = Config.TIME_OUT)
  536. {
  537. return ApiHandlerWapper.TryCommonApi(accessToken =>
  538. {
  539. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/deposit?access_token={0}", accessToken.AsUrlData());
  540. var data = new
  541. {
  542. card_id = cardId,
  543. code = codeList
  544. };
  545. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  546. }, accessTokenOrAppId);
  547. }
  548. /// <summary>
  549. /// 查询导入code数目
  550. /// </summary>
  551. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  552. /// <param name="cardId">进行导入code的卡券ID。</param>
  553. /// <param name="timeOut"></param>
  554. /// <returns></returns>
  555. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetDepositCount", true)]
  556. public static GetDepositCountResultJson GetDepositCount(string accessTokenOrAppId, string cardId, int timeOut = Config.TIME_OUT)
  557. {
  558. return ApiHandlerWapper.TryCommonApi(accessToken =>
  559. {
  560. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/getdepositcount?access_token={0}", accessToken.AsUrlData());
  561. var data = new
  562. {
  563. card_id = cardId,
  564. };
  565. return CommonJsonSend.Send<GetDepositCountResultJson>(null, urlFormat, data, timeOut: timeOut);
  566. }, accessTokenOrAppId);
  567. }
  568. /// <summary>
  569. /// 核查code
  570. /// </summary>
  571. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  572. /// <param name="cardId">进行导入code的卡券ID。</param>
  573. /// <param name="codeList">已经微信卡券后台的自定义code,上限为100个。</param>
  574. /// <param name="timeOut"></param>
  575. /// <returns></returns>
  576. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CheckCode", true)]
  577. public static CheckCodeResultJson CheckCode(string accessTokenOrAppId, string cardId, string[] codeList, int timeOut = Config.TIME_OUT)
  578. {
  579. return ApiHandlerWapper.TryCommonApi(accessToken =>
  580. {
  581. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/checkcode?access_token={0}", accessToken);
  582. var data = new
  583. {
  584. card_id = cardId,
  585. code = codeList
  586. };
  587. return CommonJsonSend.Send<CheckCodeResultJson>(null, urlFormat, data, timeOut: timeOut);
  588. }, accessTokenOrAppId);
  589. }
  590. /// <summary>
  591. /// 图文消息群发卡券
  592. /// </summary>
  593. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  594. /// <param name="cardId"></param>
  595. /// <param name="timeOut"></param>
  596. /// <returns></returns>
  597. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetHtml", true)]
  598. public static GetHtmlResultJson GetHtml(string accessTokenOrAppId, string cardId, int timeOut = Config.TIME_OUT)
  599. {
  600. return ApiHandlerWapper.TryCommonApi(accessToken =>
  601. {
  602. var urlFormat = string.Format(Config.ApiMpHost + "/card/mpnews/gethtml?access_token={0}", accessToken.AsUrlData());
  603. var data = new
  604. {
  605. card_id = cardId,
  606. };
  607. return CommonJsonSend.Send<GetHtmlResultJson>(null, urlFormat, data, timeOut: timeOut);
  608. }, accessTokenOrAppId);
  609. }
  610. /// <summary>
  611. /// Mark(占用)Code接口
  612. /// </summary>
  613. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  614. /// <param name="code">卡券的code码。</param>
  615. /// <param name="cardId">卡券的ID。</param>
  616. /// <param name="openId">用券用户的openid。</param>
  617. /// <param name="isMark">是否要mark(占用)这个code,填写true或者false,表示占用或解除占用。</param>
  618. /// <param name="timeOut"></param>
  619. /// <returns></returns>
  620. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CodeMark", true)]
  621. public static WxJsonResult CodeMark(string accessTokenOrAppId, string code, string cardId, string openId, string isMark, int timeOut = Config.TIME_OUT)
  622. {
  623. return ApiHandlerWapper.TryCommonApi(accessToken =>
  624. {
  625. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/mark?access_token={0}", accessToken.AsUrlData());
  626. var data = new
  627. {
  628. code = code,
  629. card_id = cardId,
  630. openid = openId,
  631. is_mark = isMark
  632. };
  633. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  634. }, accessTokenOrAppId);
  635. }
  636. /// <summary>
  637. /// 卡券消耗code
  638. /// </summary>
  639. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  640. /// <param name="code">要消耗的序列号</param>
  641. /// <param name="cardId">要消耗序列号所述的card_id,创建卡券时use_custom_code 填写true 时必填。非自定义code不必填写。</param>
  642. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  643. /// <returns></returns>
  644. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardConsume", true)]
  645. public static CardConsumeResultJson CardConsume(string accessTokenOrAppId, string code, string cardId = null, int timeOut = Config.TIME_OUT)
  646. {
  647. return ApiHandlerWapper.TryCommonApi(accessToken =>
  648. {
  649. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/consume?access_token={0}", accessToken.AsUrlData());
  650. var data = new
  651. {
  652. code = code,
  653. card_id = cardId
  654. };
  655. return CommonJsonSend.Send<CardConsumeResultJson>(null, urlFormat, data, timeOut: timeOut);
  656. }, accessTokenOrAppId);
  657. }
  658. /// <summary>
  659. /// code 解码接口
  660. /// code 解码接口支持两种场景:
  661. /// 1.商家获取choos_card_info 后,将card_id 和encrypt_code 字段通过解码接口,获取真实code。
  662. /// 2.卡券内跳转外链的签名中会对code 进行加密处理,通过调用解码接口获取真实code。
  663. /// </summary>
  664. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  665. /// <param name="encryptCode">通过choose_card_info 获取的加密字符串</param>
  666. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  667. /// <returns></returns>
  668. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardDecrypt", true)]
  669. public static CardDecryptResultJson CardDecrypt(string accessTokenOrAppId, string encryptCode, int timeOut = Config.TIME_OUT)
  670. {
  671. return ApiHandlerWapper.TryCommonApi(accessToken =>
  672. {
  673. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/decrypt?access_token={0}", accessToken.AsUrlData());
  674. var data = new
  675. {
  676. encrypt_code = encryptCode,
  677. };
  678. return CommonJsonSend.Send<CardDecryptResultJson>(null, urlFormat, data, timeOut: timeOut);
  679. }, accessTokenOrAppId);
  680. }
  681. /// <summary>
  682. /// 删除卡券
  683. /// </summary>
  684. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  685. /// <param name="cardId">卡券ID</param>
  686. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  687. /// <returns></returns>
  688. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardDelete", true)]
  689. public static CardDeleteResultJson CardDelete(string accessTokenOrAppId, string cardId, int timeOut = Config.TIME_OUT)
  690. {
  691. return ApiHandlerWapper.TryCommonApi(accessToken =>
  692. {
  693. var urlFormat = string.Format(Config.ApiMpHost + "/card/delete?access_token={0}", accessToken.AsUrlData());
  694. var data = new
  695. {
  696. card_id = cardId
  697. };
  698. return CommonJsonSend.Send<CardDeleteResultJson>(null, urlFormat, data, timeOut: timeOut);
  699. }, accessTokenOrAppId);
  700. }
  701. /// <summary>
  702. /// 查询code接口
  703. /// </summary>
  704. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  705. /// <param name="code"></param>
  706. /// <param name="cardId"></param>
  707. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  708. /// <returns></returns>
  709. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardGet", true)]
  710. public static CardGetResultJson CardGet(string accessTokenOrAppId, string code, string cardId = null, int timeOut = Config.TIME_OUT)
  711. {
  712. return ApiHandlerWapper.TryCommonApi(accessToken =>
  713. {
  714. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/get?access_token={0}", accessToken.AsUrlData());
  715. var data = new
  716. {
  717. code = code,
  718. card_id = cardId
  719. };
  720. return CommonJsonSend.Send<CardGetResultJson>(null, urlFormat, data, timeOut: timeOut);
  721. }, accessTokenOrAppId);
  722. }
  723. /// <summary>
  724. /// 批量查询卡列表
  725. /// </summary>
  726. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  727. /// <param name="offset">查询卡列表的起始偏移量,从0 开始,即offset: 5 是指从从列表里的第六个开始读取。</param>
  728. /// <param name="count">需要查询的卡片的数量(数量最大50)</param>
  729. /// <param name="statusList">状态列表</param>
  730. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  731. /// <returns></returns>
  732. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardBatchGet", true)]
  733. public static CardBatchGetResultJson CardBatchGet(string accessTokenOrAppId, int offset, int count, List<string> statusList, int timeOut = Config.TIME_OUT)
  734. {
  735. return ApiHandlerWapper.TryCommonApi(accessToken =>
  736. {
  737. var urlFormat = string.Format(Config.ApiMpHost + "/card/batchget?access_token={0}", accessToken.AsUrlData());
  738. var data = new
  739. {
  740. offset = offset,
  741. count = count,
  742. status_list = statusList
  743. };
  744. return CommonJsonSend.Send<CardBatchGetResultJson>(null, urlFormat, data, timeOut: timeOut);
  745. }, accessTokenOrAppId);
  746. }
  747. /// <summary>
  748. /// 查询卡券详情
  749. /// </summary>
  750. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  751. /// <param name="cardId"></param>
  752. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  753. /// <returns></returns>
  754. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardDetailGet", true)]
  755. public static CardDetailGetResultJson CardDetailGet(string accessTokenOrAppId, string cardId, int timeOut = Config.TIME_OUT)
  756. {
  757. return ApiHandlerWapper.TryCommonApi(accessToken =>
  758. {
  759. var urlFormat = string.Format(Config.ApiMpHost + "/card/get?access_token={0}", accessToken.AsUrlData());
  760. var data = new
  761. {
  762. card_id = cardId
  763. };
  764. return CommonJsonSend.Send<CardDetailGetResultJson>(null, urlFormat, data, timeOut: timeOut);
  765. }, accessTokenOrAppId);
  766. }
  767. /// <summary>
  768. /// 更改code
  769. /// </summary>
  770. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  771. /// <param name="code">卡券的code 编码</param>
  772. /// <param name="cardId">卡券ID</param>
  773. /// <param name="newCode">新的卡券code 编码</param>
  774. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  775. /// <returns></returns>
  776. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardChangeCode", true)]
  777. public static WxJsonResult CardChangeCode(string accessTokenOrAppId, string code, string cardId, string newCode, int timeOut = Config.TIME_OUT)
  778. {
  779. return ApiHandlerWapper.TryCommonApi(accessToken =>
  780. {
  781. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/update?access_token={0}", accessToken.AsUrlData());
  782. var data = new
  783. {
  784. code = code,
  785. card_id = cardId,
  786. new_code = newCode
  787. };
  788. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  789. }, accessTokenOrAppId);
  790. }
  791. /// <summary>
  792. /// 设置卡券失效接口
  793. /// </summary>
  794. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  795. /// <param name="code">需要设置为失效的code</param>
  796. /// <param name="cardId">自定义code 的卡券必填。非自定义code 的卡券不填。</param>
  797. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  798. /// <returns></returns>
  799. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardUnavailable", true)]
  800. public static WxJsonResult CardUnavailable(string accessTokenOrAppId, string code, string cardId = null, int timeOut = Config.TIME_OUT)
  801. {
  802. return ApiHandlerWapper.TryCommonApi(accessToken =>
  803. {
  804. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/unavailable?access_token={0}", accessToken.AsUrlData());
  805. var data = new
  806. {
  807. code = code,
  808. card_id = cardId
  809. };
  810. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  811. }, accessTokenOrAppId);
  812. }
  813. /// <summary>
  814. /// 拉取卡券概况数据接口
  815. /// </summary>
  816. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  817. /// <param name="beginDate">查询数据的起始时间。</param>
  818. /// <param name="endDate">查询数据的截至时间。</param>
  819. /// <param name="condSource">卡券来源,0为公众平台创建的卡券数据、1是API创建的卡券数据</param>
  820. /// <param name="timeOut"></param>
  821. /// <returns></returns>
  822. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetCardBizuinInfo", true)]
  823. public static GetCardBizuinInfoResultJson GetCardBizuinInfo(string accessTokenOrAppId, string beginDate, string endDate, int condSource, int timeOut = Config.TIME_OUT)
  824. {
  825. return ApiHandlerWapper.TryCommonApi(accessToken =>
  826. {
  827. var urlFormat = string.Format(Config.ApiMpHost + "/datacube/getcardbizuininfo?access_token={0}", accessToken.AsUrlData());
  828. var data = new
  829. {
  830. begin_date = beginDate,
  831. end_date = endDate,
  832. cond_source = condSource
  833. };
  834. return CommonJsonSend.Send<GetCardBizuinInfoResultJson>(null, urlFormat, data, timeOut: timeOut);
  835. }, accessTokenOrAppId);
  836. }
  837. /// <summary>
  838. /// 获取免费券数据接口
  839. /// </summary>
  840. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  841. /// <param name="beginDate">查询数据的起始时间。</param>
  842. /// <param name="endDate">查询数据的截至时间。</param>
  843. /// <param name="condSource">卡券来源,0为公众平台创建的卡券数据、1是API创建的卡券数据</param>
  844. /// <param name="cardId">卡券ID。填写后,指定拉出该卡券的相关数据。</param>
  845. /// <param name="timeOut"></param>
  846. /// <returns></returns>
  847. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetCardInfo", true)]
  848. public static GetCardInfoResultJson GetCardInfo(string accessTokenOrAppId, string beginDate, string endDate, int condSource, string cardId, int timeOut = Config.TIME_OUT)
  849. {
  850. return ApiHandlerWapper.TryCommonApi(accessToken =>
  851. {
  852. var urlFormat = string.Format(Config.ApiMpHost + "/datacube/getcardcardinfo?access_token={0}", accessToken.AsUrlData());
  853. var data = new
  854. {
  855. begin_date = beginDate,
  856. end_date = endDate,
  857. cond_source = condSource,
  858. card_id = cardId
  859. };
  860. return CommonJsonSend.Send<GetCardInfoResultJson>(null, urlFormat, data, timeOut: timeOut);
  861. }, accessTokenOrAppId);
  862. }
  863. /// <summary>
  864. /// 拉取会员卡数据接口
  865. /// </summary>
  866. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  867. /// <param name="beginDate">查询数据的起始时间。</param>
  868. /// <param name="endDate">查询数据的截至时间。</param>
  869. /// <param name="condSource">卡券来源,0为公众平台创建的卡券数据、1是API创建的卡券数据</param>
  870. /// <param name="timeOut"></param>
  871. /// <returns></returns>
  872. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetCardMemberCardInfo", true)]
  873. public static GetCardMemberCardInfoResultJson GetCardMemberCardInfo(string accessTokenOrAppId, string beginDate, string endDate, int condSource, int timeOut = Config.TIME_OUT)
  874. {
  875. return ApiHandlerWapper.TryCommonApi(accessToken =>
  876. {
  877. var urlFormat = string.Format(Config.ApiMpHost + "/datacube/getcardmembercardinfo?access_token={0}", accessToken.AsUrlData());
  878. var data = new
  879. {
  880. begin_date = beginDate,
  881. end_date = endDate,
  882. cond_source = condSource
  883. };
  884. return CommonJsonSend.Send<GetCardMemberCardInfoResultJson>(null, urlFormat, data, timeOut: timeOut);
  885. }, accessTokenOrAppId);
  886. }
  887. /// <summary>
  888. /// 拉取单张会员卡数据接口
  889. /// </summary>
  890. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  891. /// <param name="beginDate">查询数据的起始时间。</param>
  892. /// <param name="endDate">查询数据的截至时间。</param>
  893. /// <param name="cardId">卡券id</param>
  894. /// <param name="timeOut"></param>
  895. /// <returns></returns>
  896. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetCardMemberCardInfo", true)]
  897. public static GetCardMemberCardDetailResultJson GetCardMemberCardDetail(string accessTokenOrAppId, string beginDate, string endDate, string cardId, int timeOut = Config.TIME_OUT)
  898. {
  899. return ApiHandlerWapper.TryCommonApi(accessToken =>
  900. {
  901. var urlFormat = string.Format(Config.ApiMpHost + "/datacube/getcardmembercarddetail?access_token={0}", accessToken.AsUrlData());
  902. var data = new
  903. {
  904. begin_date = beginDate,
  905. end_date = endDate,
  906. card_id = cardId
  907. };
  908. return CommonJsonSend.Send<GetCardMemberCardDetailResultJson>(null, urlFormat, data, timeOut: timeOut);
  909. }, accessTokenOrAppId);
  910. }
  911. /// <summary>
  912. /// 更改卡券信息接口
  913. /// 支持更新部分通用字段及特殊卡券(会员卡、飞机票、电影票、红包)中特定字段的信息。
  914. /// </summary>
  915. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  916. /// <param name="cardType">卡券种类,会员卡、飞机票、电影票、红包中的一种</param>
  917. /// <param name="data">创建卡券需要的数据,格式可以看CardUpdateData.cs</param>
  918. /// <param name="cardId"></param>
  919. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  920. /// <returns></returns>
  921. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardUpdate", true)]
  922. public static WxJsonResult CardUpdate(string accessTokenOrAppId, CardType cardType, object data, string cardId = null, int timeOut = Config.TIME_OUT)
  923. {
  924. return ApiHandlerWapper.TryCommonApi(accessToken =>
  925. {
  926. var urlFormat = string.Format(Config.ApiMpHost + "/card/update?access_token={0}", accessToken.AsUrlData());
  927. BaseCardUpdateInfo cardData = null;
  928. switch (cardType)
  929. {
  930. case CardType.MEMBER_CARD:
  931. cardData = new CardUpdate_MemberCard()
  932. {
  933. card_id = cardId,
  934. member_card = data as Card_MemberCardUpdateData
  935. };
  936. break;
  937. case CardType.BOARDING_PASS:
  938. cardData = new CardUpdate_BoardingPass()
  939. {
  940. card_id = cardId,
  941. boarding_pass = data as Card_BoardingPassData
  942. };
  943. break;
  944. case CardType.MOVIE_TICKET:
  945. cardData = new CardUpdate_MovieTicket()
  946. {
  947. card_id = cardId,
  948. movie_ticket = data as Card_MovieTicketData
  949. };
  950. break;
  951. case CardType.SCENIC_TICKET:
  952. cardData = new CardUpdate_ScenicTicket()
  953. {
  954. card_id = cardId,
  955. scenic_ticket = data as Card_ScenicTicketData
  956. };
  957. break;
  958. default:
  959. break;
  960. }
  961. JsonSetting jsonSetting = new JsonSetting()
  962. {
  963. TypesToIgnoreNull = new List<Type>() { typeof(BaseUpdateInfo), typeof(BaseCardUpdateInfo) }
  964. };
  965. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, cardData, timeOut: timeOut, jsonSetting: jsonSetting);
  966. }, accessTokenOrAppId);
  967. }
  968. /// <summary>
  969. /// 设置测试用户白名单
  970. /// 由于卡券有审核要求,为方便公众号调试,可以设置一些测试帐号,这些帐号可以领取未通过审核的卡券,体验整个流程。
  971. ///注:同时支持“openid”、“username”两种字段设置白名单,总数上限为10 个。
  972. /// </summary>
  973. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  974. /// <param name="openIds">测试的openid 列表</param>
  975. /// <param name="userNames">测试的微信号列表</param>
  976. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  977. /// <returns></returns>
  978. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.AuthoritySet", true)]
  979. public static WxJsonResult AuthoritySet(string accessTokenOrAppId, string[] openIds, string[] userNames, int timeOut = Config.TIME_OUT)
  980. {
  981. return ApiHandlerWapper.TryCommonApi(accessToken =>
  982. {
  983. var urlFormat = string.Format(Config.ApiMpHost + "/card/testwhitelist/set?access_token={0}", accessToken.AsUrlData());
  984. var data = new
  985. {
  986. openid = openIds,
  987. username = userNames
  988. };
  989. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  990. }, accessTokenOrAppId);
  991. }
  992. /// <summary>
  993. /// 激活/绑定会员卡
  994. /// </summary>
  995. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  996. /// <param name="membershipNumber">必填,会员卡编号,作为序列号显示在用户的卡包里。</param>
  997. /// <param name="code">创建会员卡时获取的code</param>
  998. /// <param name="activateEndTime">激活后的有效截至时间。若不填写默认以创建时的 data_info 为准。Unix时间戳格式。</param>
  999. /// <param name="initBonus">初始积分,不填为0</param>
  1000. /// <param name="initBalance">初始余额,不填为0</param>
  1001. /// <param name="initCustomFieldValue1">创建时字段custom_field1定义类型的初始值,限制为4个汉字,12字节。</param>
  1002. /// <param name="initCustomFieldValue2">创建时字段custom_field2定义类型的初始值,限制为4个汉字,12字节。</param>
  1003. /// <param name="initCustomFieldValue3">创建时字段custom_field3定义类型的初始值,限制为4个汉字,12字节。</param>
  1004. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  1005. /// <param name="cardId"></param>
  1006. /// <param name="activateBeginTime">激活后的有效起始时间。若不填写默认以创建时的 data_info 为准。Unix时间戳格式。</param>
  1007. /// <returns></returns>
  1008. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.MemberCardActivate", true)]
  1009. public static WxJsonResult MemberCardActivate(string accessTokenOrAppId, string membershipNumber, string code, string cardId, string activateBeginTime = null, string activateEndTime = null, string initBonus = null,
  1010. string initBalance = null, string initCustomFieldValue1 = null, string initCustomFieldValue2 = null, string initCustomFieldValue3 = null, int timeOut = Config.TIME_OUT)
  1011. {
  1012. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1013. {
  1014. var urlFormat = string.Format(Config.ApiMpHost + "/card/membercard/activate?access_token={0}", accessToken.AsUrlData());
  1015. var data = new
  1016. {
  1017. init_bonus = initBonus,
  1018. init_balance = initBalance,
  1019. membership_number = membershipNumber,
  1020. code = code,
  1021. card_id = cardId,
  1022. activate_begin_time = activateBeginTime,
  1023. activate_end_time = activateEndTime,
  1024. init_custom_field_value1 = initCustomFieldValue1,
  1025. init_custom_field_value2 = initCustomFieldValue2,
  1026. init_custom_field_value3 = initCustomFieldValue3,
  1027. };
  1028. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1029. }, accessTokenOrAppId);
  1030. }
  1031. /// <summary>
  1032. /// 设置开卡字段接口
  1033. /// </summary>
  1034. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1035. /// <param name="data"></param>
  1036. /// <param name="timeOut"></param>
  1037. /// <returns></returns>
  1038. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.ActivateUserFormSet", true)]
  1039. public static WxJsonResult ActivateUserFormSet(string accessTokenOrAppId, ActivateUserFormSetData data, int timeOut = Config.TIME_OUT)
  1040. {
  1041. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1042. {
  1043. var urlFormat = string.Format(Config.ApiMpHost + "/card/membercard/activateuserform/set?access_token={0}", accessToken.AsUrlData());
  1044. JsonSetting jsonSetting = new JsonSetting()
  1045. {
  1046. TypesToIgnoreNull = new List<Type>() { typeof(ActivateUserFormSetData), typeof(BaseForm) }
  1047. };
  1048. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  1049. }, accessTokenOrAppId);
  1050. }
  1051. /// <summary>
  1052. /// 拉取会员信息接口
  1053. /// </summary>
  1054. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1055. /// <param name="cardId">CardID</param>
  1056. /// <param name="code">Code</param>
  1057. /// <param name="timeOut"></param>
  1058. /// <returns></returns>
  1059. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.UserinfoGet", true)]
  1060. public static UserinfoGetResult UserinfoGet(string accessTokenOrAppId, string cardId, string code, int timeOut = Config.TIME_OUT)
  1061. {
  1062. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1063. {
  1064. var urlFormat = string.Format(Config.ApiMpHost + "/card/membercard/userinfo/get?access_token={0}", accessToken);
  1065. return CommonJsonSend.Send<UserinfoGetResult>(null, urlFormat, new { card_id = cardId, code = code }, timeOut: timeOut);
  1066. }, accessTokenOrAppId);
  1067. }
  1068. /// <summary>
  1069. /// 设置跟随推荐接口
  1070. /// 有 使用消息配置卡券(cardCellData) 和 使用消息配置URL(urlCellData) 两种方式
  1071. /// 注意:cardCellData和urlCellData必须也只能选择一个,不可同时为空
  1072. /// </summary>
  1073. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1074. /// <param name="cardId">卡券ID</param>
  1075. /// <param name="cardCellData">使用消息配置卡券数据</param>
  1076. /// <param name="urlCellData">使用消息配置URL数据</param>
  1077. /// <param name="timeOut"></param>
  1078. /// <returns></returns>
  1079. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.RecommendSet", true)]
  1080. public static WxJsonResult RecommendSet(string accessTokenOrAppId, string cardId, CardCell cardCellData = null, UrlCell urlCellData = null, int timeOut = Config.TIME_OUT)
  1081. {
  1082. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1083. {
  1084. var urlFormat = string.Format(Config.ApiMpHost + "/card/update?access_token={0}", accessToken.AsUrlData());
  1085. var data = new
  1086. {
  1087. card_id = cardId,
  1088. member_card = new
  1089. {
  1090. modify_msg_operation = new
  1091. {
  1092. card_cell = cardCellData,
  1093. url_cell = urlCellData
  1094. }
  1095. }
  1096. };
  1097. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1098. }, accessTokenOrAppId);
  1099. }
  1100. /// <summary>
  1101. /// 设置微信买单接口
  1102. /// 注意:在调用买单接口之前,请开发者务必确认是否已经开通了微信支付以及对相应的cardid设置了门店,否则会报错
  1103. /// 错误码,0为正常;43008为商户没有开通微信支付权限
  1104. /// </summary>
  1105. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1106. /// <param name="cardId">卡券ID</param>
  1107. /// <param name="isOpen">是否开启买单功能,填true/false</param>
  1108. /// <param name="timeOut"></param>
  1109. /// <returns></returns>
  1110. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.PayCellSet", true)]
  1111. public static WxJsonResult PayCellSet(string accessTokenOrAppId, string cardId, bool isOpen, int timeOut = Config.TIME_OUT)
  1112. {
  1113. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1114. {
  1115. var urlFormat = string.Format(Config.ApiMpHost + "/card/paycell/set?access_token={0}", accessToken.AsUrlData());
  1116. var data = new
  1117. {
  1118. card_id = cardId,
  1119. is_open = isOpen
  1120. };
  1121. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1122. }, accessTokenOrAppId);
  1123. }
  1124. /// <summary>
  1125. /// 设置自助核销接口
  1126. /// 注意:设置自助核销的card_id必须已经配置了门店,否则会报错。
  1127. /// 错误码,0为正常;43008为商户没有开通微信支付权限
  1128. /// </summary>
  1129. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1130. /// <param name="cardId">卡券ID</param>
  1131. /// <param name="isOpen">是否开启自助核销功能,填true/false</param>
  1132. /// <param name="timeOut"></param>
  1133. /// <returns></returns>
  1134. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.SelfConsumecellSet", true)]
  1135. public static WxJsonResult SelfConsumecellSet(string accessTokenOrAppId, string cardId, bool isOpen, int timeOut = Config.TIME_OUT)
  1136. {
  1137. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1138. {
  1139. var urlFormat = string.Format(Config.ApiMpHost + "/card/selfconsumecell/set?access_token={0}", accessToken.AsUrlData());
  1140. var data = new
  1141. {
  1142. card_id = cardId,
  1143. is_open = isOpen
  1144. };
  1145. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1146. }, accessTokenOrAppId);
  1147. }
  1148. /// <summary>
  1149. /// 更新会员信息
  1150. /// </summary>
  1151. /// post数据:
  1152. /// 可以传入积分、余额的差值
  1153. /// {
  1154. /// "code": "12312313",
  1155. /// "card_id":"p1Pj9jr90_SQRaVqYI239Ka1erkI",
  1156. /// "record_bonus": "消费30元,获得3积分",
  1157. /// "add_bonus": 3,//可以传入积分增减的差值
  1158. /// "add_balance": -3000,//可以传入余额本次增减的差值
  1159. /// "record_balance": "购买焦糖玛琪朵一杯,扣除金额30元。",
  1160. /// "custom_field_value1": "xxxxx",
  1161. /// }
  1162. /// 或者直接传入积分、余额的全量值
  1163. ///
  1164. /// {
  1165. /// "code": "12312313",
  1166. /// "card_id":"p1Pj9jr90_SQRaVqYI239Ka1erkI",
  1167. /// "record_bonus": "消费30元,获得3积分",
  1168. /// "bonus": 3000,//可以传入第三方系统记录的积分全量值
  1169. /// "balance": 3000,//可以传入第三方系统记录的余额全量值
  1170. /// "record_balance": "购买焦糖玛琪朵一杯,扣除金额30元。",
  1171. /// "custom_field_value1": "xxxxx",
  1172. /// }
  1173. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1174. /// <param name="code">卡券Code码。</param>
  1175. /// <param name="cardId">卡券ID。</param>
  1176. /// <param name="addBonus">需要变更的积分,扣除积分用“-“表示。</param>
  1177. /// <param name="addBalance">需要变更的余额,扣除金额用“-”表示。单位为分。</param>
  1178. /// <param name="backgroundPicUrl">用户卡片的背景图片</param>
  1179. /// <param name="bonus">需要设置的积分全量值,传入的数值会直接显示,如果同时传入add_bonus和bonus,则前者无效。</param>
  1180. /// <param name="balance">需要设置的余额全量值,传入的数值会直接显示,如果同时传入add_balance和balance,则前者无效。</param>
  1181. /// <param name="recordBonus">商家自定义积分消耗记录,不超过14个汉字。</param>
  1182. /// <param name="recordBalance">商家自定义金额消耗记录,不超过14个汉字。</param>
  1183. /// <param name="customFieldValue1">创建时字段custom_field1定义类型的最新数值,限制为4个汉字,12字节。</param>
  1184. /// <param name="customFieldValue2">创建时字段custom_field2定义类型的最新数值,限制为4个汉字,12字节。</param>
  1185. /// <param name="customFieldValue3">创建时字段custom_field3定义类型的最新数值,限制为4个汉字,12字节。</param>
  1186. /// <param name="membershipNumber">会员号,wiki文档没有,经测算可以用,用于会员号设置错误后重新设置</param>
  1187. /// <param name="timeOut"></param>
  1188. /// <returns></returns>
  1189. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.UpdateUser", true)]
  1190. public static UpdateUserResultJson UpdateUser(string accessTokenOrAppId, string code, string cardId, int addBonus, int addBalance, string backgroundPicUrl = null,
  1191. int? bonus = null, int? balance = null, string recordBonus = null, string recordBalance = null, string customFieldValue1 = null,
  1192. string customFieldValue2 = null, string customFieldValue3 = null, string membershipNumber = null, int timeOut = Config.TIME_OUT)
  1193. {
  1194. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1195. {
  1196. var urlFormat = string.Format(Config.ApiMpHost + "/card/membercard/updateuser?access_token={0}", accessToken.AsUrlData());
  1197. var data = new
  1198. {
  1199. code = code,
  1200. card_id = cardId,
  1201. background_pic_url = backgroundPicUrl,
  1202. add_bonus = addBonus,//之前注释掉,现还原 ——Jeffrey Su 2018.1.21
  1203. bonus = bonus,
  1204. record_bonus = recordBonus,
  1205. add_balance = addBalance,//之前注释掉,现还原 ——Jeffrey Su 2018.1.21
  1206. balance = balance,
  1207. record_balance = recordBalance,
  1208. custom_field_value1 = customFieldValue1,
  1209. custom_field_value2 = customFieldValue2,
  1210. custom_field_value3 = customFieldValue3,
  1211. membership_number = membershipNumber
  1212. };
  1213. JsonSetting jsonSetting = new JsonSetting()
  1214. {
  1215. TypesToIgnoreNull = new List<Type>() { data.GetType() }
  1216. };
  1217. return CommonJsonSend.Send<UpdateUserResultJson>(null, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  1218. }, accessTokenOrAppId);
  1219. }
  1220. /// <summary>
  1221. /// 会员卡交易
  1222. /// </summary>
  1223. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1224. /// <param name="code">要消耗的序列号</param>
  1225. /// <param name="cardId">要消耗序列号所述的card_id。自定义code 的会员卡必填</param>
  1226. /// <param name="recordBonus">商家自定义积分消耗记录,不超过14 个汉字</param>
  1227. /// <param name="addBonus">需要变更的积分,扣除积分用“-“表</param>
  1228. /// <param name="addBalance">需要变更的余额,扣除金额用“-”表示。单位为分</param>
  1229. /// <param name="recordBalance">商家自定义金额消耗记录,不超过14 个汉字</param>
  1230. /// <param name="isNotifyBonus">积分变动时是否触发系统模板消息,默认为true</param>
  1231. /// <param name="isNotifyBalance">余额变动时是否触发系统模板消息,默认为true</param>
  1232. /// <param name="isNotifyCustomField1">自定义group1变动时是否触发系统模板消息,默认为false。</param>
  1233. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  1234. /// <returns></returns>
  1235. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.MemberCardDeal", true)]
  1236. public static MemberCardDealResultJson MemberCardDeal(string accessTokenOrAppId, string code, string cardId, string recordBonus, decimal addBonus, decimal addBalance, string recordBalance, bool isNotifyBonus = true, bool isNotifyBalance = true, bool isNotifyCustomField1 = false, int timeOut = Config.TIME_OUT)
  1237. {
  1238. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1239. {
  1240. var urlFormat = string.Format(Config.ApiMpHost + "/card/membercard/updateuser?access_token={0}", accessToken.AsUrlData());
  1241. var data = new
  1242. {
  1243. code = code,
  1244. card_id = cardId,
  1245. record_bonus = recordBonus,
  1246. add_bonus = addBonus,
  1247. add_balance = addBalance,
  1248. record_balance = recordBalance,
  1249. // notify_optional如果没有显式设置,接口默认为false。
  1250. notify_optional = new
  1251. {
  1252. is_notify_bonus = isNotifyBonus,
  1253. is_notify_balance = isNotifyBalance,
  1254. is_notify_custom_field1 = isNotifyCustomField1
  1255. }
  1256. };
  1257. return CommonJsonSend.Send<MemberCardDealResultJson>(null, urlFormat, data, timeOut: timeOut);
  1258. }, accessTokenOrAppId);
  1259. }
  1260. /// <summary>
  1261. /// 更新电影票
  1262. /// </summary>
  1263. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1264. /// <param name="code">电影票的序列号</param>
  1265. /// <param name="cardId">电影票card_id。自定义code 的电影票为必填,非自定义code 的电影票不必填。</param>
  1266. /// <param name="ticketClass">电影票的类别,如2D、3D</param>
  1267. /// <param name="showTime">电影放映时间对应的时间戳</param>
  1268. /// <param name="duration">放映时长,填写整数</param>
  1269. /// <param name="screeningRoom">该场电影的影厅信息</param>
  1270. /// <param name="seatNumbers">座位号</param>
  1271. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  1272. /// <returns></returns>
  1273. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.MovieCardUpdate", true)]
  1274. public static WxJsonResult MovieCardUpdate(string accessTokenOrAppId, string code, string cardId, string ticketClass, string showTime, int duration, string screeningRoom, string[] seatNumbers, int timeOut = Config.TIME_OUT)
  1275. {
  1276. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1277. {
  1278. var urlFormat = string.Format(Config.ApiMpHost + "/card/movieticket/updateuser?access_token={0}", accessToken.AsUrlData());
  1279. var data = new
  1280. {
  1281. code = code,
  1282. card_id = cardId,
  1283. ticket_class = ticketClass,
  1284. show_time = showTime,
  1285. duration = duration,
  1286. screening_room = screeningRoom,
  1287. seat_number = seatNumbers
  1288. };
  1289. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1290. }, accessTokenOrAppId);
  1291. }
  1292. /// <summary>
  1293. /// 飞机票在线选座
  1294. /// </summary>
  1295. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1296. /// <param name="code">飞机票的序列</param>
  1297. /// <param name="cardId">需办理值机的机票card_id。自定义code 的飞机票为必</param>
  1298. /// <param name="passengerName">乘客姓名,上限为15 个汉字</param>
  1299. /// <param name="classType">舱等,如头等舱等,上限为5 个汉字</param>
  1300. /// <param name="seat">乘客座位号</param>
  1301. /// <param name="etktBnr">电子客票号,上限为14 个数字</param>
  1302. /// <param name="qrcodeData">二维码数据。乘客用于值机的二维码字符串,微信会通过此数据为用户生成值机用的二维码</param>
  1303. /// <param name="isCancel">是否取消值机。填写true 或false。true 代表取消,如填写true 上述字段(如calss 等)均不做判断,机票返回未值机状态,乘客可重新值机。默认填写false</param>
  1304. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  1305. /// <returns></returns>
  1306. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.BoardingPassCheckIn", true)]
  1307. public static WxJsonResult BoardingPassCheckIn(string accessTokenOrAppId, string code, string cardId, string passengerName, string classType, string seat, string etktBnr, string qrcodeData, bool isCancel = false, int timeOut = Config.TIME_OUT)
  1308. {
  1309. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1310. {
  1311. var urlFormat = string.Format(Config.ApiMpHost + "/card/boardingpass/checkin?access_token={0}", accessToken.AsUrlData());
  1312. var data = new
  1313. {
  1314. code = code,
  1315. card_id = cardId,
  1316. passenger_name = passengerName,
  1317. @class = classType,
  1318. seat = seat,
  1319. etkt_bnr = etktBnr,
  1320. qrcode_data = qrcodeData,
  1321. is_cancel = isCancel
  1322. };
  1323. return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  1324. }, accessTokenOrAppId);
  1325. }
  1326. /// <summary>
  1327. /// 更新红包金额
  1328. /// </summary>
  1329. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1330. /// <param name="code">红包的序列号</param>
  1331. /// <param name="cardId">自定义code 的卡券必填。非自定义code 可不填。</param>
  1332. /// <param name="balance">红包余额</param>
  1333. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  1334. /// <returns></returns>
  1335. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.UpdateUserBalance", true)]
  1336. public static WxJsonResult UpdateUserBalance(string accessTokenOrAppId, string code, string cardId, decimal balance, int timeOut = Config.TIME_OUT)
  1337. {
  1338. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1339. {
  1340. var urlFormat = string.Format(Config.ApiMpHost + "/card/luckymoney/updateuserbalance?access_token={0}", accessToken.AsUrlData());
  1341. var data = new
  1342. {
  1343. code = code,
  1344. card_id = cardId,
  1345. balance = balance
  1346. };
  1347. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1348. }, accessTokenOrAppId);
  1349. }
  1350. /// <summary>
  1351. /// 更新会议门票接口
  1352. /// </summary>
  1353. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1354. /// <param name="code">用户的门票唯一序列号</param>
  1355. /// <param name="cardId">要更新门票序列号所述的card_id , 生成券时use_custom_code 填写true 时必填。</param>
  1356. /// <param name="zone">区域</param>
  1357. /// <param name="entrance">入口</param>
  1358. /// <param name="seatNumber">座位号</param>
  1359. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  1360. /// <returns></returns>
  1361. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.UpdateMeetingTicket", true)]
  1362. public static WxJsonResult UpdateMeetingTicket(string accessTokenOrAppId, string code, string cardId = null, string zone = null, string entrance = null, string seatNumber = null, int timeOut = Config.TIME_OUT)
  1363. {
  1364. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1365. {
  1366. var urlFormat = string.Format(Config.ApiMpHost + "/card/meetingticket/updateuser?access_token={0}", accessToken.AsUrlData());
  1367. var data = new
  1368. {
  1369. code = code,
  1370. card_id = cardId,
  1371. zone = zone,
  1372. entrance = entrance,
  1373. seat_number = seatNumber
  1374. };
  1375. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1376. }, accessTokenOrAppId);
  1377. }
  1378. /// <summary>
  1379. /// 创建子商户接口
  1380. /// </summary>
  1381. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1382. /// <param name="info">json结构</param>
  1383. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  1384. /// <returns></returns>
  1385. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.SubmerChantSubmit", true)]
  1386. public static SubmerChantSubmitJsonResult SubmerChantSubmit(string accessTokenOrAppId, InfoList info, int timeOut = Config.TIME_OUT)
  1387. {
  1388. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1389. {
  1390. var urlFormat = string.Format(Config.ApiMpHost + "/card/submerchant/submit?access_token={0}", accessToken.AsUrlData());
  1391. var data = new
  1392. {
  1393. info = info
  1394. };
  1395. return CommonJsonSend.Send<SubmerChantSubmitJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1396. }, accessTokenOrAppId);
  1397. }
  1398. /// <summary>
  1399. /// 卡券开放类目查询接口
  1400. /// </summary>
  1401. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1402. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  1403. /// <returns></returns>
  1404. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetApplyProtocol", true)]
  1405. public static GetApplyProtocolJsonResult GetApplyProtocol(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  1406. {
  1407. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1408. {
  1409. var url = string.Format(Config.ApiMpHost + "/card/getapplyprotocol?access_token={0}", accessToken.AsUrlData());
  1410. return CommonJsonSend.Send<GetApplyProtocolJsonResult>(null, url, null, CommonJsonSendType.GET, timeOut);
  1411. }, accessTokenOrAppId);
  1412. }
  1413. /// <summary>
  1414. ///拉取单个子商户信息接口
  1415. /// </summary>
  1416. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1417. /// <param name="appid"></param>
  1418. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  1419. /// <returns></returns>
  1420. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetCardMerchant", true)]
  1421. public static GetCardMerchantJsonResult GetCardMerchant(string accessTokenOrAppId, string appid, int timeOut = Config.TIME_OUT)
  1422. {
  1423. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1424. {
  1425. var url = string.Format(Config.ApiMpHost + "/cgi-bin/component/get_card_merchant?access_token={0}", accessToken.AsUrlData());
  1426. var data = new
  1427. {
  1428. appid = appid
  1429. };
  1430. return CommonJsonSend.Send<GetCardMerchantJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
  1431. }, accessTokenOrAppId);
  1432. }
  1433. /// <summary>
  1434. ///拉取子商户列表接口
  1435. /// </summary>
  1436. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1437. /// <param name="nextGet">获取子商户列表,注意最开始时为空。每次拉取20个子商户,下次拉取时填入返回数据中该字段的值,该值无实际意义。</param>
  1438. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  1439. /// <returns></returns>
  1440. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.BatchGetCardMerchant", true)]
  1441. public static BatchGetCardMerchantJsonResult BatchGetCardMerchant(string accessTokenOrAppId, string nextGet, int timeOut = Config.TIME_OUT)
  1442. {
  1443. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1444. {
  1445. var url = string.Format(Config.ApiMpHost + "/cgi-bin/component/batchget_card_merchant?access_token={0}", accessToken.AsUrlData());
  1446. var data = new
  1447. {
  1448. next_get = nextGet
  1449. };
  1450. return CommonJsonSend.Send<BatchGetCardMerchantJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
  1451. }, accessTokenOrAppId);
  1452. }
  1453. /// <summary>
  1454. /// 更新子商户接口
  1455. /// </summary>
  1456. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1457. /// <param name="info">json结构</param>
  1458. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  1459. /// <returns></returns>
  1460. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.SubmerChantUpdate", true)]
  1461. public static SubmerChantSubmitJsonResult SubmerChantUpdate(string accessTokenOrAppId, InfoList info, int timeOut = Config.TIME_OUT)
  1462. {
  1463. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1464. {
  1465. var urlFormat = string.Format(Config.ApiMpHost + "/card/submerchant/update?access_token={0}", accessToken.AsUrlData());
  1466. var data = new
  1467. {
  1468. info = info
  1469. };
  1470. return CommonJsonSend.Send<SubmerChantSubmitJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1471. }, accessTokenOrAppId);
  1472. }
  1473. /// <summary>
  1474. /// 拉取单个子商户信息接口
  1475. /// </summary>
  1476. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1477. /// <param name="merchantId">子商户id,一个母商户公众号下唯一。</param>
  1478. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  1479. /// <returns></returns>
  1480. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.SubmerChantGet", true)]
  1481. public static SubmerChantSubmitJsonResult SubmerChantGet(string accessTokenOrAppId, string merchantId, int timeOut = Config.TIME_OUT)
  1482. {
  1483. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1484. {
  1485. var urlFormat = string.Format(Config.ApiMpHost + "/card/submerchant/get?access_token={0}", accessToken.AsUrlData());
  1486. var data = new
  1487. {
  1488. merchant_id = merchantId
  1489. };
  1490. return CommonJsonSend.Send<SubmerChantSubmitJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1491. }, accessTokenOrAppId);
  1492. }
  1493. /// <summary>
  1494. /// 批量拉取子商户信息接口
  1495. /// </summary>
  1496. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1497. /// <param name="beginId">起始的子商户id,一个母商户公众号下唯一</param>
  1498. /// <param name="limit">拉取的子商户的个数,最大值为100</param>
  1499. /// <param name="status">json结构</param>
  1500. /// <param name="timeOut">子商户审核状态,填入后,只会拉出当前状态的子商户</param>
  1501. /// <returns></returns>
  1502. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.SubmerChantBatchGet", true)]
  1503. public static SubmerChantBatchGetJsonResult SubmerChantBatchGet(string accessTokenOrAppId, string beginId, int limit, string status, int timeOut = Config.TIME_OUT)
  1504. {
  1505. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1506. {
  1507. var urlFormat = string.Format(Config.ApiMpHost + "/card/submerchant/batchget?access_token={0}", accessToken.AsUrlData());
  1508. var data = new
  1509. {
  1510. begin_id = beginId,
  1511. limit = limit,
  1512. status = status
  1513. };
  1514. return CommonJsonSend.Send<SubmerChantBatchGetJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1515. }, accessTokenOrAppId);
  1516. }
  1517. /// <summary>
  1518. /// 母商户资质申请接口
  1519. /// </summary>
  1520. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1521. /// <param name="registerCapital">注册资本,数字,单位:分</param>
  1522. /// <param name="businessLicenseMediaid">营业执照扫描件的media_id</param>
  1523. /// <param name="taxRegistRationCertificateMediaid">税务登记证扫描件的media_id</param>
  1524. /// <param name="lastQuarterTaxListingMediaid">上个季度纳税清单扫描件media_id</param>
  1525. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  1526. /// <returns></returns>
  1527. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.AgentQualification", true)]
  1528. public static WxJsonResult AgentQualification(string accessTokenOrAppId, string registerCapital, string businessLicenseMediaid, string taxRegistRationCertificateMediaid, string lastQuarterTaxListingMediaid, int timeOut = Config.TIME_OUT)
  1529. {
  1530. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1531. {
  1532. var urlFormat = string.Format(Config.ApiMpHost + "/cgi-bin/component/upload_card_agent_qualification?access_token={0}", accessToken.AsUrlData());
  1533. var data = new
  1534. {
  1535. register_capital = registerCapital,
  1536. business_license_media_id = businessLicenseMediaid,
  1537. tax_registration_certificate_media_id = taxRegistRationCertificateMediaid,
  1538. last_quarter_tax_listing_media_id = lastQuarterTaxListingMediaid
  1539. };
  1540. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1541. }, accessTokenOrAppId);
  1542. }
  1543. /// <summary>
  1544. /// 母商户资质审核查询接口
  1545. /// </summary>
  1546. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1547. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  1548. /// <returns></returns>
  1549. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CheckAgentQualification", true)]
  1550. public static CheckQualificationJsonResult CheckAgentQualification(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  1551. {
  1552. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1553. {
  1554. var url = string.Format(Config.ApiMpHost + "/cgi-bin/component/check_card_agent_qualification?access_token={0}", accessToken.AsUrlData());
  1555. return CommonJsonSend.Send<CheckQualificationJsonResult>(null, url, null, CommonJsonSendType.GET, timeOut);
  1556. }, accessTokenOrAppId);
  1557. }
  1558. /// <summary>
  1559. /// 子商户资质申请接口
  1560. /// </summary>
  1561. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1562. /// <param name="appid">子商户公众号的appid</param>
  1563. /// <param name="name">子商户商户名,用于显示在卡券券面</param>
  1564. /// <param name="logoMediaid">子商户logo,用于显示在子商户卡券的券面</param>
  1565. /// <param name="businessLicenseMediaid">营业执照或个体工商户执照扫描件的media_id</param>
  1566. /// <param name="operatorIdCardMediaid">当子商户为个体工商户且无公章时,授权函须签名,并额外提交该个体工商户经营者身份证扫描件的media_id</param>
  1567. /// <param name="agreementFileMediaid">子商户与第三方签署的代理授权函的media_id</param>
  1568. /// <param name="primaryCategoryId">一级类目id</param>
  1569. /// <param name="secondaryCategoryId">二级类目id</param>
  1570. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  1571. /// <returns></returns>
  1572. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.MerchantQualification", true)]
  1573. public static WxJsonResult MerchantQualification(string accessTokenOrAppId, string appid, string name, string logoMediaid, string businessLicenseMediaid, string operatorIdCardMediaid, string agreementFileMediaid, string primaryCategoryId, string secondaryCategoryId, int timeOut = Config.TIME_OUT)
  1574. {
  1575. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1576. {
  1577. var urlFormat = string.Format(Config.ApiMpHost + "/cgi-bin/component/upload_card_merchant_qualification?access_token={0}", accessToken.AsUrlData());
  1578. var data = new
  1579. {
  1580. appid = appid,
  1581. name = name,
  1582. logo_meida_id = logoMediaid,
  1583. business_license_media_id = businessLicenseMediaid,
  1584. operator_id_card_media_id = operatorIdCardMediaid,
  1585. agreement_file_media_id = agreementFileMediaid,
  1586. primary_category_id = primaryCategoryId,
  1587. secondary_category_id = secondaryCategoryId
  1588. };
  1589. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1590. }, accessTokenOrAppId);
  1591. }
  1592. /// <summary>
  1593. /// 子商户资质审核查询接口
  1594. /// </summary>
  1595. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1596. /// <param name="appid"></param>
  1597. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  1598. /// <returns></returns>
  1599. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CheckMerchantQualification", true)]
  1600. public static CheckQualificationJsonResult CheckMerchantQualification(string accessTokenOrAppId, string appid, int timeOut = Config.TIME_OUT)
  1601. {
  1602. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1603. {
  1604. var url = string.Format(Config.ApiMpHost + "/cgi-bin/component/check_card_merchant_qualification?access_token={0}", accessToken.AsUrlData());
  1605. var data = new
  1606. {
  1607. appid = appid
  1608. };
  1609. return CommonJsonSend.Send<CheckQualificationJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
  1610. }, accessTokenOrAppId);
  1611. }
  1612. /// <summary>
  1613. /// 获取用户已领取卡券
  1614. /// </summary>
  1615. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1616. /// <param name="openId">需要查询的用户openid</param>
  1617. /// <param name="cardId">卡券ID。不填写时默认查询当前appid下的卡券。</param>
  1618. /// <param name="timeOut"></param>
  1619. /// <returns></returns>
  1620. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetCardList", true)]
  1621. public static GetCardListResultJson GetCardList(string accessTokenOrAppId, string openId, string cardId = null, int timeOut = Config.TIME_OUT)
  1622. {
  1623. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1624. {
  1625. var urlFormat = string.Format(Config.ApiMpHost + "/card/user/getcardlist?access_token={0}", accessToken.AsUrlData());
  1626. var data = new
  1627. {
  1628. openid = openId,
  1629. card_id = cardId,
  1630. };
  1631. return CommonJsonSend.Send<GetCardListResultJson>(null, urlFormat, data, timeOut: timeOut);
  1632. }, accessTokenOrAppId);
  1633. }
  1634. /// <summary>
  1635. /// 修改库存接口
  1636. /// </summary>
  1637. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  1638. /// <param name="cardId">卡券ID</param>
  1639. /// <param name="increaseStockValue">增加多少库存,支持不填或填0</param>
  1640. /// <param name="reduceStockValue">减少多少库存,可以不填或填0</param>
  1641. /// <param name="timeOut"></param>
  1642. /// <returns></returns>
  1643. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.ModifyStock", true)]
  1644. public static WxJsonResult ModifyStock(string accessTokenOrAppId, string cardId, int increaseStockValue = 0, int reduceStockValue = 0, int timeOut = Config.TIME_OUT)
  1645. {
  1646. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1647. {
  1648. var urlFormat = string.Format(Config.ApiMpHost + "/card/modifystock?access_token={0}", accessToken.AsUrlData());
  1649. var data = new
  1650. {
  1651. card_id = cardId,
  1652. increase_stock_value = increaseStockValue,
  1653. reduce_stock_value = reduceStockValue
  1654. };
  1655. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1656. }, accessTokenOrAppId);
  1657. }
  1658. /// <summary>
  1659. /// 获取开卡插件参数
  1660. /// </summary>
  1661. /// <param name="accessTokenOrAppId"></param>
  1662. /// <param name="cardId"></param>
  1663. /// <param name="outerStr"></param>
  1664. /// <param name="timeOut"></param>
  1665. /// <returns></returns>
  1666. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetCardUrl", true)]
  1667. public static Card_GetUrlResultJson GetCardUrl(string accessTokenOrAppId, string cardId, string outerStr, int timeOut = Config.TIME_OUT)
  1668. {
  1669. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1670. {
  1671. var urlFormat = string.Format(Config.ApiMpHost + "/card/membercard/activate/geturl?access_token={0}", accessToken.AsUrlData());
  1672. var data = new
  1673. {
  1674. card_id = cardId,
  1675. outer_str = outerStr
  1676. };
  1677. return CommonJsonSend.Send<Card_GetUrlResultJson>(null, urlFormat, data, timeOut: timeOut);
  1678. }, accessTokenOrAppId);
  1679. }
  1680. /// <summary>
  1681. /// 获取用户开卡时提交的信息(跳转型开卡组件)
  1682. /// </summary>
  1683. /// <param name="accessTokenOrAppId"></param>
  1684. /// <param name="activateTicket"></param>
  1685. /// <param name="timeOut"></param>
  1686. /// <returns></returns>
  1687. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetActivateTempInfo", true)]
  1688. public static GetActivateTempInfoResultJson GetActivateTempInfo(string accessTokenOrAppId, string activateTicket, int timeOut = Config.TIME_OUT)
  1689. {
  1690. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1691. {
  1692. var urlFormat = string.Format(Config.ApiMpHost + "/card/membercard/activatetempinfo/get?access_token={0}", accessToken.AsUrlData());
  1693. var data = new
  1694. {
  1695. activate_ticket = activateTicket
  1696. };
  1697. return CommonJsonSend.Send<GetActivateTempInfoResultJson>(null, urlFormat, data, timeOut: timeOut);
  1698. }, accessTokenOrAppId);
  1699. }
  1700. /// <summary>
  1701. /// 创建-礼品卡货架接口
  1702. /// </summary>
  1703. /// <param name="accessTokenOrAppId"></param>
  1704. /// <param name="data"></param>
  1705. /// <param name="timeOut"></param>
  1706. /// <returns></returns>
  1707. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.AddGiftCardPage", true)]
  1708. public static CardCreateResultJson AddGiftCardPage(string accessTokenOrAppId, GiftCardPageData data, int timeOut = Config.TIME_OUT)
  1709. {
  1710. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1711. {
  1712. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/page/add?access_token={0}", accessToken.AsUrlData());
  1713. return CommonJsonSend.Send<CardCreateResultJson>(null, urlFormat, data, timeOut: timeOut);
  1714. }, accessTokenOrAppId);
  1715. }
  1716. /// <summary>
  1717. /// 查询-礼品卡货架信息接口
  1718. /// </summary>
  1719. /// <param name="accessTokenOrAppId"></param>
  1720. /// <param name="pageId"></param>
  1721. /// <param name="timeOut"></param>
  1722. /// <returns></returns>
  1723. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetGiftCardPageInfo", true)]
  1724. public static GetGiftCardPageInfoResultJson GetGiftCardPageInfo(string accessTokenOrAppId, string pageId, int timeOut = Config.TIME_OUT)
  1725. {
  1726. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1727. {
  1728. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/page/get?access_token={0}", accessToken.AsUrlData());
  1729. var data = new
  1730. {
  1731. page_id = pageId
  1732. };
  1733. return CommonJsonSend.Send<GetGiftCardPageInfoResultJson>(null, urlFormat, data, timeOut: timeOut);
  1734. }, accessTokenOrAppId);
  1735. }
  1736. /// <summary>
  1737. /// 修改-礼品卡货架信息接口
  1738. /// </summary>
  1739. /// <param name="accessTokenOrAppId"></param>
  1740. /// <param name="data"></param>
  1741. /// <param name="timeOut"></param>
  1742. /// <returns></returns>
  1743. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.UpdateGiftCardPage", true)]
  1744. public static WxJsonResult UpdateGiftCardPage(string accessTokenOrAppId, GiftCardPageData data, int timeOut = Config.TIME_OUT)
  1745. {
  1746. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1747. {
  1748. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/page/add?access_token={0}", accessToken.AsUrlData());
  1749. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1750. }, accessTokenOrAppId);
  1751. }
  1752. /// <summary>
  1753. /// 查询-礼品卡货架列表接口
  1754. /// </summary>
  1755. /// <param name="accessTokenOrAppId"></param>
  1756. /// <param name="timeOut"></param>
  1757. /// <returns></returns>
  1758. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetGiftCardPageList", true)]
  1759. public static GetGiftCardPageListResultJson GetGiftCardPageList(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  1760. {
  1761. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1762. {
  1763. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/page/batchget?access_token={0}", accessToken.AsUrlData());
  1764. var data = new { };
  1765. return CommonJsonSend.Send<GetGiftCardPageListResultJson>(null, urlFormat, data, timeOut: timeOut);
  1766. }, accessTokenOrAppId);
  1767. }
  1768. /// <summary>
  1769. /// 下架-礼品卡货架接口
  1770. /// </summary>
  1771. /// <param name="accessTokenOrAppId"></param>
  1772. /// <param name="data"></param>
  1773. /// <param name="timeOut"></param>
  1774. /// <returns></returns>
  1775. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.DownGiftCardPage", true)]
  1776. public static DownGiftCardPageResultJson DownGiftCardPage(string accessTokenOrAppId, DownGiftCardPage data, int timeOut = Config.TIME_OUT)
  1777. {
  1778. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1779. {
  1780. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/maintain/set?access_token={0}", accessToken.AsUrlData());
  1781. return CommonJsonSend.Send<DownGiftCardPageResultJson>(null, urlFormat, data, timeOut: timeOut);
  1782. }, accessTokenOrAppId);
  1783. }
  1784. /// <summary>
  1785. /// 申请微信支付礼品卡权限接口
  1786. /// </summary>
  1787. /// <param name="accessTokenOrAppId"></param>
  1788. /// <param name="subId">微信支付子商户号</param>
  1789. /// <param name="timeOut"></param>
  1790. /// <returns></returns>
  1791. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.PayGiftCard", true)]
  1792. public static PayGiftCardResultJson PayGiftCard(string accessTokenOrAppId, string subId, int timeOut = Config.TIME_OUT)
  1793. {
  1794. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1795. {
  1796. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/pay/whitelist/add?access_token={0}", accessToken.AsUrlData());
  1797. var data = new
  1798. {
  1799. sub_mch_id = subId
  1800. };
  1801. return CommonJsonSend.Send<PayGiftCardResultJson>(null, urlFormat, data, timeOut: timeOut);
  1802. }, accessTokenOrAppId);
  1803. }
  1804. /// <summary>
  1805. /// 绑定商户号到礼品卡小程序接口
  1806. /// </summary>
  1807. /// <param name="accessTokenOrAppId"></param>
  1808. /// <param name="subId">微信支付子商户号</param>
  1809. /// <param name="wxaAppId"></param>
  1810. /// <param name="timeOut"></param>
  1811. /// <returns></returns>
  1812. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.BindToGiftCard", true)]
  1813. public static WxJsonResult BindToGiftCard(string accessTokenOrAppId, string subId, string wxaAppId, int timeOut = Config.TIME_OUT)
  1814. {
  1815. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1816. {
  1817. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/pay/submch/bind?access_token={0}", accessToken.AsUrlData());
  1818. var data = new
  1819. {
  1820. sub_mch_id = subId,
  1821. wxa_appid = wxaAppId
  1822. };
  1823. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1824. }, accessTokenOrAppId);
  1825. }
  1826. /// <summary>
  1827. /// 上传小程序代码
  1828. /// </summary>
  1829. /// <param name="accessTokenOrAppId"></param>
  1830. /// <param name="pageId"></param>
  1831. /// <param name="wxaAppId"></param>
  1832. /// <param name="timeOut"></param>
  1833. /// <returns></returns>
  1834. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.UploadWxaCode", true)]
  1835. public static WxJsonResult UploadWxaCode(string accessTokenOrAppId, string pageId, string wxaAppId, int timeOut = Config.TIME_OUT)
  1836. {
  1837. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1838. {
  1839. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/pay/wxa/set?access_token={0}", accessToken.AsUrlData());
  1840. var data = new
  1841. {
  1842. wxa_appid = wxaAppId,
  1843. page_id = pageId
  1844. };
  1845. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1846. }, accessTokenOrAppId);
  1847. }
  1848. /// <summary>
  1849. /// 查询-单个礼品卡订单信息接口
  1850. /// </summary>
  1851. /// <param name="accessTokenOrAppId"></param>
  1852. /// <param name="orderId">礼品卡订单号,商户可以通过购买成功的事件推送或者批量查询订单接口获得</param>
  1853. /// <param name="timeOut"></param>
  1854. /// <returns></returns>
  1855. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetGiftCardOrderInfo", true)]
  1856. public static GiftCardOrderItemResultJson GetGiftCardOrderInfo(string accessTokenOrAppId, string orderId, int timeOut = Config.TIME_OUT)
  1857. {
  1858. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1859. {
  1860. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/order/get?access_token={0}", accessToken.AsUrlData());
  1861. var data = new
  1862. {
  1863. order_id = orderId
  1864. };
  1865. return CommonJsonSend.Send<GiftCardOrderItemResultJson>(null, urlFormat, data, timeOut: timeOut);
  1866. }, accessTokenOrAppId);
  1867. }
  1868. /// <summary>
  1869. /// 查询-批量查询礼品卡订单信息接口
  1870. /// </summary>
  1871. /// <param name="accessTokenOrAppId"></param>
  1872. /// <param name="beginTime">查询的时间起点,十位时间戳(utc+8)</param>
  1873. /// <param name="endTime">查询的时间终点,十位时间戳(utc+8</param>
  1874. /// <param name="sortType">填"ASC" / "DESC",表示对订单创建时间进行“升 / 降”排序</param>
  1875. /// <param name="offSet">查询的订单偏移量,如填写100则表示从第100个订单开始拉取</param>
  1876. /// <param name="count">查询订单的数量,如offset填写100,count填写10,则表示查询第100个到第110个订单</param>
  1877. /// <param name="timeOut"></param>
  1878. /// <returns></returns>
  1879. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetGiftCardOrderListInfo", true)]
  1880. public static GiftCardOrderListResultJson GetGiftCardOrderListInfo(string accessTokenOrAppId, string beginTime, string endTime, SortType sortType, int offSet, int count, int timeOut = Config.TIME_OUT)
  1881. {
  1882. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1883. {
  1884. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/order/batchget?access_token={0}", accessToken.AsUrlData());
  1885. var data = new
  1886. {
  1887. begin_time = beginTime,
  1888. end_time = endTime,
  1889. sort_type = sortType,
  1890. offset = offSet,
  1891. count = count
  1892. };
  1893. return CommonJsonSend.Send<GiftCardOrderListResultJson>(null, urlFormat, data, timeOut: timeOut);
  1894. }, accessTokenOrAppId);
  1895. }
  1896. /// <summary>
  1897. /// 更新用户礼品卡信息接口
  1898. /// </summary>
  1899. /// <param name="accessTokenOrAppId"></param>
  1900. /// <param name="data"></param>
  1901. /// <param name="timeOut"></param>
  1902. /// <returns></returns>
  1903. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.UpdateUserGiftCard", true)]
  1904. public static UpdateUserGiftCardResultJson UpdateUserGiftCard(string accessTokenOrAppId, UpdateUserGiftCardData data, int timeOut = Config.TIME_OUT)
  1905. {
  1906. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1907. {
  1908. var urlFormat = string.Format(Config.ApiMpHost + "/card/generalcard/updateuser?access_token={0}", accessToken.AsUrlData());
  1909. return CommonJsonSend.Send<UpdateUserGiftCardResultJson>(null, urlFormat, data, timeOut: timeOut);
  1910. }, accessTokenOrAppId);
  1911. }
  1912. /// <summary>
  1913. /// 退款接口
  1914. /// </summary>
  1915. /// <param name="accessTokenOrAppId"></param>
  1916. /// <param name="orderId"></param>
  1917. /// <param name="timeOut"></param>
  1918. /// <returns></returns>
  1919. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.Refund", true)]
  1920. public static WxJsonResult Refund(string accessTokenOrAppId, string orderId, int timeOut = Config.TIME_OUT)
  1921. {
  1922. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1923. {
  1924. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/order/refund?access_token={0}", accessToken.AsUrlData());
  1925. var data = new
  1926. {
  1927. order_id = orderId
  1928. };
  1929. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1930. }, accessTokenOrAppId);
  1931. }
  1932. /// <summary>
  1933. /// 设置支付后投放卡券接口
  1934. /// </summary>
  1935. /// <param name="accessTokenOrAppId"></param>
  1936. /// <param name="data"></param>
  1937. /// <param name="timeOut"></param>
  1938. /// <returns></returns>
  1939. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.AddCardAfterPay", true)]
  1940. public static AddCardAfterPayResultJson AddCardAfterPay(string accessTokenOrAppId, AddCardAfterPayData data, int timeOut = Config.TIME_OUT)
  1941. {
  1942. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1943. {
  1944. var urlFormat = string.Format(Config.ApiMpHost + "/card/paygiftcard/add?access_token={0}", accessToken.AsUrlData());
  1945. return CommonJsonSend.Send<AddCardAfterPayResultJson>(null, urlFormat, data, timeOut: timeOut);
  1946. }, accessTokenOrAppId);
  1947. }
  1948. /// <summary>
  1949. /// 删除支付后投放卡券规则接口
  1950. /// </summary>
  1951. /// <param name="accessTokenOrAppId"></param>
  1952. /// <param name="ruleId"></param>
  1953. /// <param name="timeOut"></param>
  1954. /// <returns></returns>
  1955. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.DeleteAfterPayRule", true)]
  1956. public static WxJsonResult DeleteAfterPayRule(string accessTokenOrAppId, string ruleId, int timeOut = Config.TIME_OUT)
  1957. {
  1958. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1959. {
  1960. var urlFormat = string.Format(Config.ApiMpHost + "/card/paygiftcard/delete?access_token={0}", accessToken.AsUrlData());
  1961. var data = new
  1962. {
  1963. rule_id = ruleId
  1964. };
  1965. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1966. }, accessTokenOrAppId);
  1967. }
  1968. /// <summary>
  1969. /// 查询支付后投放卡券规则详情接口
  1970. /// </summary>
  1971. /// <param name="accessTokenOrAppId"></param>
  1972. /// <param name="ruleId"></param>
  1973. /// <param name="timeOut"></param>
  1974. /// <returns></returns>
  1975. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.AfterPay_GetById", true)]
  1976. public static AfterPay_GetByIdResultJson AfterPay_GetById(string accessTokenOrAppId, string ruleId, int timeOut = Config.TIME_OUT)
  1977. {
  1978. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1979. {
  1980. var urlFormat = string.Format(Config.ApiMpHost + "/card/paygiftcard/getbyid?access_token={0}", accessToken.AsUrlData());
  1981. var data = new
  1982. {
  1983. rule_id = ruleId
  1984. };
  1985. return CommonJsonSend.Send<AfterPay_GetByIdResultJson>(null, urlFormat, data, timeOut: timeOut);
  1986. }, accessTokenOrAppId);
  1987. }
  1988. /// <summary>
  1989. /// 批量查询支付后投放卡券规则接口
  1990. /// </summary>
  1991. /// <param name="accessTokenOrAppId"></param>
  1992. /// <param name="data"></param>
  1993. /// <param name="timeOut"></param>
  1994. /// <returns></returns>
  1995. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.AfterPay_BatchGet", true)]
  1996. public static AfterPay_BatchGetResultJson AfterPay_BatchGet(string accessTokenOrAppId, AfterPay_BatchGetData data, int timeOut = Config.TIME_OUT)
  1997. {
  1998. return ApiHandlerWapper.TryCommonApi(accessToken =>
  1999. {
  2000. var urlFormat = string.Format(Config.ApiMpHost + "/card/paygiftcard/batchget?access_token={0}", accessToken.AsUrlData());
  2001. return CommonJsonSend.Send<AfterPay_BatchGetResultJson>(null, urlFormat, data, timeOut: timeOut);
  2002. }, accessTokenOrAppId);
  2003. }
  2004. /// <summary>
  2005. /// 增加支付即会员规则接口
  2006. /// </summary>
  2007. /// <param name="accessTokenOrAppId"></param>
  2008. /// <param name="data"></param>
  2009. /// <param name="timeOut"></param>
  2010. /// <returns></returns>
  2011. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.AddPayMemberRule", true)]
  2012. public static AddPayMemberRuleResultJson AddPayMemberRule(string accessTokenOrAppId, AddPayMemberRuleData data, int timeOut = Config.TIME_OUT)
  2013. {
  2014. return ApiHandlerWapper.TryCommonApi(accessToken =>
  2015. {
  2016. var urlFormat = string.Format(Config.ApiMpHost + "/card/paygiftmembercard/add?access_token={0}", accessToken.AsUrlData());
  2017. return CommonJsonSend.Send<AddPayMemberRuleResultJson>(null, urlFormat, data, timeOut: timeOut);
  2018. }, accessTokenOrAppId);
  2019. }
  2020. /// <summary>
  2021. /// 删除支付即会员规则接口
  2022. /// </summary>
  2023. /// <param name="accessTokenOrAppId"></param>
  2024. /// <param name="data"></param>
  2025. /// <param name="timeOut"></param>
  2026. /// <returns></returns>
  2027. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.DeletePayMemberRule", true)]
  2028. public static DeletePayMemberRuleResultJson DeletePayMemberRule(string accessTokenOrAppId, DeletePayMemberRuleData data, int timeOut = Config.TIME_OUT)
  2029. {
  2030. return ApiHandlerWapper.TryCommonApi(accessToken =>
  2031. {
  2032. var urlFormat = string.Format(Config.ApiMpHost + "/card/paygiftmembercard/delete?access_token={0}", accessToken.AsUrlData());
  2033. return CommonJsonSend.Send<DeletePayMemberRuleResultJson>(null, urlFormat, data, timeOut: timeOut);
  2034. }, accessTokenOrAppId);
  2035. }
  2036. /// <summary>
  2037. /// 查询商户号支付即会员规则接口
  2038. /// </summary>
  2039. /// <param name="accessTokenOrAppId"></param>
  2040. /// <param name="mchId"></param>
  2041. /// <param name="timeOut"></param>
  2042. /// <returns></returns>
  2043. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetPayMemberRule", true)]
  2044. public static GetPayMemberRuleResultJson GetPayMemberRule(string accessTokenOrAppId, string mchId, int timeOut = Config.TIME_OUT)
  2045. {
  2046. return ApiHandlerWapper.TryCommonApi(accessToken =>
  2047. {
  2048. var urlFormat = string.Format(Config.ApiMpHost + "/card/paygiftmembercard/get?access_token={0}", accessToken.AsUrlData());
  2049. var data = new
  2050. {
  2051. mchid = mchId
  2052. };
  2053. return CommonJsonSend.Send<GetPayMemberRuleResultJson>(null, urlFormat, data, timeOut: timeOut);
  2054. }, accessTokenOrAppId);
  2055. }
  2056. /// <summary>
  2057. /// 创建支付后领取立减金活动接口
  2058. /// </summary>
  2059. /// <param name="accessTokenOrAppId"></param>
  2060. /// <param name="data"></param>
  2061. /// <param name="timeOut"></param>
  2062. /// <returns></returns>
  2063. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CreateActivity", true)]
  2064. public static CreateActivityResultJson CreateActivity(string accessTokenOrAppId, CreateActivityData data, int timeOut = Config.TIME_OUT)
  2065. {
  2066. return ApiHandlerWapper.TryCommonApi(accessToken =>
  2067. {
  2068. var urlFormat = string.Format(Config.ApiMpHost + "/card/mkt/activity/create?access_token={0}", accessToken.AsUrlData());
  2069. return CommonJsonSend.Send<CreateActivityResultJson>(null, urlFormat, data, timeOut: timeOut);
  2070. }, accessTokenOrAppId);
  2071. }
  2072. /// <summary>
  2073. /// 使用授权码换取公众号的授权信息
  2074. /// </summary>
  2075. /// <param name="accessTokenOrAppId"></param>
  2076. /// <param name="componentAppid"></param>
  2077. /// <param name="authorizationCode"></param>
  2078. /// <param name="timeOut"></param>
  2079. /// <returns></returns>
  2080. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.ApiQueryAuth", true)]
  2081. public static ApiQueryAuthResultJson ApiQueryAuth(string accessTokenOrAppId, string componentAppid, string authorizationCode, int timeOut = Config.TIME_OUT)
  2082. {
  2083. return ApiHandlerWapper.TryCommonApi(accessToken =>
  2084. {
  2085. var urlFormat = string.Format(Config.ApiMpHost + "/cgi-bin/component/api_query_auth?component_access_token={0}", accessToken.AsUrlData());
  2086. var data = new
  2087. {
  2088. component_appid = componentAppid,
  2089. authorization_code = authorizationCode
  2090. };
  2091. return CommonJsonSend.Send<ApiQueryAuthResultJson>(null, urlFormat, data, timeOut: timeOut);
  2092. }, accessTokenOrAppId);
  2093. }
  2094. /// <summary>
  2095. /// 确认授权
  2096. /// </summary>
  2097. /// <param name="accessTokenOrAppId"></param>
  2098. /// <param name="data"></param>
  2099. /// <param name="timeOut"></param>
  2100. /// <returns></returns>
  2101. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.ApiConfirmAuthorization", true)]
  2102. public static WxJsonResult ApiConfirmAuthorization(string accessTokenOrAppId, ApiConfirmAuthorizationData data, int timeOut = Config.TIME_OUT)
  2103. {
  2104. return ApiHandlerWapper.TryCommonApi(accessToken =>
  2105. {
  2106. var urlFormat = string.Format(Config.ApiMpHost + "/cgi-bin/component/api_confirm_authorization?component_access_token={0}", accessToken.AsUrlData());
  2107. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  2108. }, accessTokenOrAppId);
  2109. }
  2110. /// <summary>
  2111. /// 获取授权方的账户信息
  2112. /// </summary>
  2113. /// <param name="accessTokenOrAppId"></param>
  2114. /// <param name="componentAppid"></param>
  2115. /// <param name="authorizerAppid"></param>
  2116. /// <param name="timeOut"></param>
  2117. /// <returns></returns>
  2118. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.ApiGetAuthorizerInfo", true)]
  2119. public static ApiGetAuthorizerInfoResultJson ApiGetAuthorizerInfo(string accessTokenOrAppId, string componentAppid, string authorizerAppid, int timeOut = Config.TIME_OUT)
  2120. {
  2121. return ApiHandlerWapper.TryCommonApi(accessToken =>
  2122. {
  2123. var urlFormat = string.Format(Config.ApiMpHost + "/cgi-bin/component/api_get_authorizer_info?component_access_token={0}", accessToken.AsUrlData());
  2124. var data = new
  2125. {
  2126. component_appid = componentAppid,
  2127. authorizer_appid = authorizerAppid
  2128. };
  2129. return CommonJsonSend.Send<ApiGetAuthorizerInfoResultJson>(null, urlFormat, data, timeOut: timeOut);
  2130. }, accessTokenOrAppId);
  2131. }
  2132. #endregion
  2133. #if !NET35 && !NET40
  2134. #region 异步方法
  2135. /// <summary>
  2136. /// 【异步方法】创建卡券
  2137. /// </summary>
  2138. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2139. /// <param name="cardInfo">创建卡券需要的数据,格式可以看CardCreateData.cs</param>
  2140. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  2141. /// <returns></returns>
  2142. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CreateCardAsync", true)]
  2143. public static async Task<CardCreateResultJson> CreateCardAsync(string accessTokenOrAppId, BaseCardInfo cardInfo, int timeOut = Config.TIME_OUT)
  2144. {
  2145. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2146. {
  2147. var urlFormat = string.Format(Config.ApiMpHost + "/card/create?access_token={0}", accessToken.AsUrlData());
  2148. CardCreateInfo cardData = null;
  2149. CardType cardType = cardInfo.GetCardType();
  2150. switch (cardType)
  2151. {
  2152. case CardType.GENERAL_COUPON:
  2153. cardData = new CardCreateInfo()
  2154. {
  2155. card = new Card_GeneralCoupon()
  2156. {
  2157. card_type = cardType.ToString(),
  2158. general_coupon = cardInfo as Card_GeneralCouponData
  2159. }
  2160. };
  2161. break;
  2162. case CardType.GROUPON:
  2163. cardData = new CardCreateInfo()
  2164. {
  2165. card = new Card_Groupon()
  2166. {
  2167. card_type = cardType.ToString(),
  2168. groupon = cardInfo as Card_GrouponData
  2169. }
  2170. };
  2171. break;
  2172. case CardType.GIFT:
  2173. cardData = new CardCreateInfo()
  2174. {
  2175. card = new Card_Gift()
  2176. {
  2177. card_type = cardType.ToString(),
  2178. gift = cardInfo as Card_GiftData
  2179. }
  2180. };
  2181. break;
  2182. case CardType.CASH:
  2183. cardData = new CardCreateInfo()
  2184. {
  2185. card = new Card_Cash()
  2186. {
  2187. card_type = cardType.ToString(),
  2188. cash = cardInfo as Card_CashData
  2189. }
  2190. };
  2191. break;
  2192. case CardType.DISCOUNT:
  2193. cardData = new CardCreateInfo()
  2194. {
  2195. card = new Card_DisCount()
  2196. {
  2197. card_type = cardType.ToString(),
  2198. discount = cardInfo as Card_DisCountData
  2199. }
  2200. };
  2201. break;
  2202. case CardType.MEMBER_CARD:
  2203. cardData = new CardCreateInfo()
  2204. {
  2205. card = new Card_MemberCard()
  2206. {
  2207. card_type = cardType.ToString(),
  2208. member_card = cardInfo as Card_MemberCardData
  2209. }
  2210. };
  2211. break;
  2212. case CardType.SCENIC_TICKET:
  2213. cardData = new CardCreateInfo()
  2214. {
  2215. card = new Card_ScenicTicket()
  2216. {
  2217. card_type = cardType.ToString(),
  2218. scenic_ticket = cardInfo as Card_ScenicTicketData
  2219. }
  2220. };
  2221. break;
  2222. case CardType.MOVIE_TICKET:
  2223. cardData = new CardCreateInfo()
  2224. {
  2225. card = new Card_MovieTicket()
  2226. {
  2227. card_type = cardType.ToString(),
  2228. movie_ticket = cardInfo as Card_MovieTicketData
  2229. }
  2230. };
  2231. break;
  2232. case CardType.BOARDING_PASS:
  2233. cardData = new CardCreateInfo()
  2234. {
  2235. card = new Card_BoardingPass()
  2236. {
  2237. card_type = cardType.ToString(),
  2238. boarding_pass = cardInfo as Card_BoardingPassData
  2239. }
  2240. };
  2241. break;
  2242. case CardType.LUCKY_MONEY:
  2243. cardData = new CardCreateInfo()
  2244. {
  2245. card = new Card_LuckyMoney()
  2246. {
  2247. card_type = cardType.ToString(),
  2248. lucky_money = cardInfo as Card_LuckyMoneyData
  2249. }
  2250. };
  2251. break;
  2252. case CardType.MEETING_TICKET:
  2253. cardData = new CardCreateInfo()
  2254. {
  2255. card = new Card_MeetingTicket()
  2256. {
  2257. card_type = cardType.ToString(),
  2258. meeting_ticket = cardInfo as Card_MeetingTicketData
  2259. }
  2260. };
  2261. break;
  2262. default:
  2263. break;
  2264. }
  2265. var jsonSetting = new JsonSetting(true, null,
  2266. new List<Type>()
  2267. {
  2268. //typeof (Modify_Msg_Operation),
  2269. //typeof (CardCreateInfo),
  2270. typeof (Card_BaseInfoBase)//过滤Modify_Msg_Operation主要起作用的是这个
  2271. });
  2272. var result = Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<CardCreateResultJson>(null, urlFormat, cardData, timeOut: timeOut,
  2273. //针对特殊字段的null值进行过滤
  2274. jsonSetting: jsonSetting);
  2275. return await result;
  2276. }, accessTokenOrAppId);
  2277. }
  2278. ///// <summary>
  2279. ///// 此接口已取消,微信直接提供了十四种色值供选择,详见:http://mp.weixin.qq.com/wiki/8/b7e310e7943f7763450eced91fa793b0.html#.E5.8D.A1.E5.88.B8.E5.9F.BA.E7.A1.80.E4.BF.A1.E6.81.AF.E5.AD.97.E6.AE.B5.EF.BC.88.E9.87.8D.E8.A6.81.EF.BC.89
  2280. ///// 获取颜色列表接口
  2281. ///// </summary>
  2282. ///// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2283. ///// <param name="timeOut">代理请求超时时间(毫秒)</param>
  2284. ///// <returns></returns>
  2285. /// <summary>
  2286. /// 【异步方法】开通券点账户接口
  2287. /// </summary>
  2288. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2289. /// <param name="timeOut"></param>
  2290. /// <returns></returns>
  2291. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.PayActiveAsync", true)]
  2292. public static async Task<PayActiveResultJson> PayActiveAsync(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  2293. {
  2294. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2295. {
  2296. var urlFormat = string.Format(Config.ApiMpHost + "/card/pay/activate?access_token={0}", accessToken.AsUrlData());
  2297. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<PayActiveResultJson>(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
  2298. }, accessTokenOrAppId);
  2299. }
  2300. /// <summary>
  2301. /// 【异步方法】对优惠券批价
  2302. /// </summary>
  2303. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2304. ///<param name="cardId">需要来配置库存的card_id</param>
  2305. /// <param name="quantity">本次需要兑换的库存数目</param>
  2306. /// <param name="timeOut"></param>
  2307. /// <returns></returns>
  2308. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetpayPriceAsync", true)]
  2309. public static async Task<GetpayPriceResultJson> GetpayPriceAsync(string accessTokenOrAppId, string cardId, int quantity, int timeOut = Config.TIME_OUT)
  2310. {
  2311. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2312. {
  2313. var urlFormat = string.Format(Config.ApiMpHost + "/card/pay/getpayprice?access_token={0}", accessToken.AsUrlData());
  2314. var data = new
  2315. {
  2316. card_id = cardId,
  2317. quantity = quantity
  2318. };
  2319. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetpayPriceResultJson>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
  2320. }, accessTokenOrAppId);
  2321. }
  2322. /// <summary>
  2323. /// 【异步方法】查询券点余额接口
  2324. /// </summary>
  2325. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2326. /// <param name="timeOut"></param>
  2327. /// <returns></returns>
  2328. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetCoinsInfoAsync", true)]
  2329. public static async Task<GetCoinsInfoResultJson> GetCoinsInfoAsync(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  2330. {
  2331. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2332. {
  2333. var urlFormat = string.Format(Config.ApiMpHost + "/card/pay/getcoinsinfo?access_token={0}", accessToken.AsUrlData());
  2334. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetCoinsInfoResultJson>(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
  2335. }, accessTokenOrAppId);
  2336. }
  2337. /// <summary>
  2338. ///【异步方法】确认兑换库存接口
  2339. /// </summary>
  2340. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2341. /// <param name="cardId">需要来兑换库存的card_id</param>
  2342. /// <param name="quantity">本次需要兑换的库存数目</param>
  2343. /// <param name="orderId">仅可以使用上面得到的订单号,保证批价有效性</param>
  2344. /// <param name="timeOut"></param>
  2345. /// <returns></returns>
  2346. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.PayConfirmAsync", true)]
  2347. public static async Task<WxJsonResult> PayConfirmAsync(string accessTokenOrAppId, string cardId, int quantity, string orderId, int timeOut = Config.TIME_OUT)
  2348. {
  2349. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2350. {
  2351. var urlFormat = string.Format(Config.ApiMpHost + "/card/pay/confirm?access_token={0}", accessToken.AsUrlData());
  2352. var data = new
  2353. {
  2354. card_id = cardId,
  2355. quantity = quantity,
  2356. order_id = orderId
  2357. };
  2358. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
  2359. }, accessTokenOrAppId);
  2360. }
  2361. /// <summary>
  2362. ///【异步方法】充值券点接口
  2363. /// </summary>
  2364. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2365. /// <param name="coinCount">需要充值的券点数目,1点=1元</param>
  2366. /// <param name="timeOut"></param>
  2367. /// <returns></returns>
  2368. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.PayRechargeAsync", true)]
  2369. public static async Task<PayRechargeResultJson> PayRechargeAsync(string accessTokenOrAppId, int coinCount, int timeOut = Config.TIME_OUT)
  2370. {
  2371. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2372. {
  2373. var urlFormat = string.Format(Config.ApiMpHost + "/card/pay/recharge?access_token={0}", accessToken.AsUrlData());
  2374. var data = new
  2375. {
  2376. coin_count = coinCount
  2377. };
  2378. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<PayRechargeResultJson>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
  2379. }, accessTokenOrAppId);
  2380. }
  2381. /// <summary>
  2382. ///【异步方法】查询订单详情接口
  2383. /// </summary>
  2384. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2385. /// <param name="orderId">上一步中获得的订单号,作为一次交易的唯一凭证</param>
  2386. /// <param name="timeOut"></param>
  2387. /// <returns></returns>
  2388. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.PayGetOrderAsync", true)]
  2389. public static async Task<PayGetOrderResultJson> PayGetOrderAsync(string accessTokenOrAppId, int orderId, int timeOut = Config.TIME_OUT)
  2390. {
  2391. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2392. {
  2393. var urlFormat = string.Format(Config.ApiMpHost + "/card/pay/getorder?access_token={0}", accessToken.AsUrlData());
  2394. var data = new
  2395. {
  2396. order_id = orderId
  2397. };
  2398. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<PayGetOrderResultJson>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
  2399. }, accessTokenOrAppId);
  2400. }
  2401. /// <summary>
  2402. ///【异步方法】查询券点流水详情接口
  2403. /// </summary>
  2404. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2405. /// <param name="offset">分批查询的起点,默认为0</param>
  2406. /// <param name="count">分批查询的数量</param>
  2407. /// <param name="orderType">所要拉取的订单类型ORDER_TYPE_SYS_ADD 平台赠送 ORDER_TYPE_WXPAY 充值 ORDER_TYPE_REFUND 库存回退券点 ORDER_TYPE_REDUCE 券点兑换库存 ORDER_TYPE_SYS_REDUCE 平台扣减</param>
  2408. /// <param name="norFilter">反选,不要拉取的订单</param>
  2409. /// <param name="sortInfo">对结果排序</param>
  2410. /// <param name="beginTime">批量查询订单的起始事件,为时间戳,默认1周前</param>
  2411. /// <param name="endTime">批量查询订单的结束事件,为时间戳,默认为当前时间</param>
  2412. /// <param name="timeOut"></param>
  2413. /// <returns></returns>
  2414. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetOrderListAsync", true)]
  2415. public static async Task<GetOrderListResultJson> GetOrderListAsync(string accessTokenOrAppId, int offset, int count, string orderType, NorFilter norFilter, SortInfo sortInfo, int beginTime, int endTime, int timeOut = Config.TIME_OUT)
  2416. {
  2417. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2418. {
  2419. var urlFormat = string.Format(Config.ApiMpHost + "/card/pay/getorderlist?access_token={0}", accessToken.AsUrlData());
  2420. var data = new
  2421. {
  2422. offset = offset,
  2423. count = count,
  2424. order_type = orderType,
  2425. nor_filter = norFilter,
  2426. sort_info = sortInfo,
  2427. begin_time = beginTime,
  2428. end_time = endTime
  2429. };
  2430. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetOrderListResultJson>(null, urlFormat, data, CommonJsonSendType.POST, timeOut: timeOut);
  2431. }, accessTokenOrAppId);
  2432. }
  2433. /// <summary>
  2434. /// 【异步方法】生成卡券二维码
  2435. /// 获取二维码ticket 后,开发者可用ticket 换取二维码图片。换取指引参考:http://mp.weixin.qq.com/wiki/index.php?title=生成带参数的二维码
  2436. /// </summary>
  2437. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2438. /// <param name="cardId">卡券ID</param>
  2439. /// <param name="code">指定卡券code 码,只能被领一次。use_custom_code 字段为true 的卡券必须填写,非自定义code 不必填写。</param>
  2440. /// <param name="openId">指定领取者的openid,只有该用户能领取。bind_openid 字段为true 的卡券必须填写,非自定义openid 不必填写。</param>
  2441. /// <param name="expireSeconds">指定二维码的有效时间,范围是60 ~ 1800 秒。不填默认为永久有效。</param>
  2442. /// <param name="isUniqueCode">指定下发二维码,生成的二维码随机分配一个code,领取后不可再次扫描。填写true 或false。默认false。</param>
  2443. /// <param name="outer_id">自定义应用场景ID(v13.7.3起支持)</param>
  2444. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  2445. /// <returns></returns>
  2446. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CreateQRAsync", true)]
  2447. public static async Task<CreateQRResultJson> CreateQRAsync(string accessTokenOrAppId, string cardId, string code = null,
  2448. string openId = null, string expireSeconds = null,
  2449. bool isUniqueCode = false, string outer_id = null,
  2450. int timeOut = Config.TIME_OUT)
  2451. {
  2452. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2453. {
  2454. var urlFormat = string.Format(Config.ApiMpHost + "/card/qrcode/create?access_token={0}", accessToken.AsUrlData());
  2455. var data = new
  2456. {
  2457. action_name = "QR_CARD",
  2458. expire_seconds = expireSeconds,
  2459. action_info = new
  2460. {
  2461. card = new
  2462. {
  2463. card_id = cardId,
  2464. code = code,
  2465. openid = openId,
  2466. //expire_seconds = expireSeconds,
  2467. is_unique_code = false,
  2468. //balance = balance,
  2469. outer_id = outer_id
  2470. }
  2471. }
  2472. };
  2473. //var jsonSettingne = new JsonSetting(true);
  2474. var jsonSetting = new JsonSetting(true, null,
  2475. new List<Type>()
  2476. {
  2477. //typeof (Modify_Msg_Operation),
  2478. //typeof (CardCreateInfo),
  2479. data.action_info.card.GetType()//过滤Modify_Msg_Operation主要起作用的是这个
  2480. });
  2481. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<CreateQRResultJson>(null, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);
  2482. }, accessTokenOrAppId);
  2483. }
  2484. /// <summary>
  2485. /// 【异步方法】创建货架
  2486. /// </summary>
  2487. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2488. /// <param name="data"></param>
  2489. /// <param name="timeOut"></param>
  2490. /// <returns></returns>
  2491. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.ShelfCreateAsync", true)]
  2492. public static async Task<ShelfCreateResultJson> ShelfCreateAsync(string accessTokenOrAppId, ShelfCreateData data, int timeOut = Config.TIME_OUT)
  2493. {
  2494. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2495. {
  2496. var urlFormat = string.Format(Config.ApiMpHost + "/card/landingpage/create?access_token={0}", accessToken.AsUrlData());
  2497. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<ShelfCreateResultJson>(null, urlFormat, data, timeOut: timeOut);
  2498. }, accessTokenOrAppId);
  2499. }
  2500. /// <summary>
  2501. /// 【异步方法】导入code
  2502. ///
  2503. /// 新创建卡券情况
  2504. /// 如果开发者打算新创建一张支持导入code模式的卡券,不同于以往的创建方式,建议开发者采用以下流程创建预存code模式卡券,否则会报错。
  2505. /// 步骤一:创建预存模式卡券,将库存quantity初始值设置为0,并填入Deposit_Mode字段;
  2506. /// 步骤二:待卡券通过审核后,调用导入code接口并核查code;
  2507. /// 步骤三:调用修改库存接口,须令卡券库存小于或等于导入code的数目。(为了避免混乱建议设置为相等)
  2508. ///
  2509. /// 注: 1)单次调用接口传入code的数量上限为100个。
  2510. /// 2)每一个 code 均不能为空串。
  2511. /// 3)导入结束后系统会自动判断提供方设置库存与实际导入code的量是否一致。
  2512. /// 4)导入失败支持重复导入,提示成功为止。
  2513. /// </summary>
  2514. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2515. /// <param name="cardId">需要进行导入code的卡券ID</param>
  2516. /// <param name="codeList">需导入微信卡券后台的自定义code,上限为100个。</param>
  2517. /// <param name="timeOut"></param>
  2518. /// <returns></returns>
  2519. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CodeDepositAsync", true)]
  2520. public static async Task<WxJsonResult> CodeDepositAsync(string accessTokenOrAppId, string cardId, string[] codeList, int timeOut = Config.TIME_OUT)
  2521. {
  2522. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2523. {
  2524. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/deposit?access_token={0}", accessToken.AsUrlData());
  2525. var data = new
  2526. {
  2527. card_id = cardId,
  2528. code = codeList
  2529. };
  2530. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  2531. }, accessTokenOrAppId);
  2532. }
  2533. /// <summary>
  2534. /// 【异步方法】查询导入code数目
  2535. /// </summary>
  2536. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2537. /// <param name="cardId">进行导入code的卡券ID。</param>
  2538. /// <param name="timeOut"></param>
  2539. /// <returns></returns>
  2540. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetDepositCountAsync", true)]
  2541. public static async Task<GetDepositCountResultJson> GetDepositCountAsync(string accessTokenOrAppId, string cardId, int timeOut = Config.TIME_OUT)
  2542. {
  2543. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2544. {
  2545. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/getdepositcount?access_token={0}", accessToken.AsUrlData());
  2546. var data = new
  2547. {
  2548. card_id = cardId,
  2549. };
  2550. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetDepositCountResultJson>(null, urlFormat, data, timeOut: timeOut);
  2551. }, accessTokenOrAppId);
  2552. }
  2553. /// <summary>
  2554. /// 【异步方法】核查code
  2555. /// </summary>
  2556. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2557. /// <param name="cardId">进行导入code的卡券ID。</param>
  2558. /// <param name="codeList">已经微信卡券后台的自定义code,上限为100个。</param>
  2559. /// <param name="timeOut"></param>
  2560. /// <returns></returns>
  2561. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CheckCodeAsync", true)]
  2562. public static async Task<CheckCodeResultJson> CheckCodeAsync(string accessTokenOrAppId, string cardId, string[] codeList, int timeOut = Config.TIME_OUT)
  2563. {
  2564. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2565. {
  2566. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/checkcode?access_token={0}", accessToken);
  2567. var data = new
  2568. {
  2569. card_id = cardId,
  2570. code = codeList
  2571. };
  2572. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<CheckCodeResultJson>(null, urlFormat, data, timeOut: timeOut);
  2573. }, accessTokenOrAppId);
  2574. }
  2575. /// <summary>
  2576. /// 【异步方法】图文消息群发卡券
  2577. /// </summary>
  2578. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2579. /// <param name="cardId"></param>
  2580. /// <param name="timeOut"></param>
  2581. /// <returns></returns>
  2582. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetHtmlAsync", true)]
  2583. public static async Task<GetHtmlResultJson> GetHtmlAsync(string accessTokenOrAppId, string cardId, int timeOut = Config.TIME_OUT)
  2584. {
  2585. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2586. {
  2587. var urlFormat = string.Format(Config.ApiMpHost + "/card/mpnews/gethtml?access_token={0}", accessToken.AsUrlData());
  2588. var data = new
  2589. {
  2590. card_id = cardId,
  2591. };
  2592. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetHtmlResultJson>(null, urlFormat, data, timeOut: timeOut);
  2593. }, accessTokenOrAppId);
  2594. }
  2595. /// <summary>
  2596. /// 【异步方法】Mark(占用)Code接口
  2597. /// </summary>
  2598. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2599. /// <param name="code">卡券的code码。</param>
  2600. /// <param name="cardId">卡券的ID。</param>
  2601. /// <param name="openId">用券用户的openid。</param>
  2602. /// <param name="isMark">是否要mark(占用)这个code,填写true或者false,表示占用或解除占用。</param>
  2603. /// <param name="timeOut"></param>
  2604. /// <returns></returns>
  2605. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CodeMarkAsync", true)]
  2606. public static async Task<WxJsonResult> CodeMarkAsync(string accessTokenOrAppId, string code, string cardId, string openId, string isMark, int timeOut = Config.TIME_OUT)
  2607. {
  2608. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2609. {
  2610. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/mark?access_token={0}", accessToken.AsUrlData());
  2611. var data = new
  2612. {
  2613. code = code,
  2614. card_id = cardId,
  2615. openid = openId,
  2616. is_mark = isMark
  2617. };
  2618. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  2619. }, accessTokenOrAppId);
  2620. }
  2621. /// <summary>
  2622. /// 【异步方法】卡券消耗code
  2623. /// </summary>
  2624. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2625. /// <param name="code">要消耗的序列号</param>
  2626. /// <param name="cardId">要消耗序列号所述的card_id,创建卡券时use_custom_code 填写true 时必填。非自定义code不必填写。</param>
  2627. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  2628. /// <returns></returns>
  2629. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardConsumeAsync", true)]
  2630. public static async Task<CardConsumeResultJson> CardConsumeAsync(string accessTokenOrAppId, string code, string cardId = null, int timeOut = Config.TIME_OUT)
  2631. {
  2632. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2633. {
  2634. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/consume?access_token={0}", accessToken.AsUrlData());
  2635. var data = new
  2636. {
  2637. code = code,
  2638. card_id = cardId
  2639. };
  2640. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<CardConsumeResultJson>(null, urlFormat, data, timeOut: timeOut);
  2641. }, accessTokenOrAppId);
  2642. }
  2643. /// <summary>
  2644. /// 【异步方法】code 解码接口
  2645. /// code 解码接口支持两种场景:
  2646. /// 1.商家获取choos_card_info 后,将card_id 和encrypt_code 字段通过解码接口,获取真实code。
  2647. /// 2.卡券内跳转外链的签名中会对code 进行加密处理,通过调用解码接口获取真实code。
  2648. /// </summary>
  2649. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2650. /// <param name="encryptCode">通过choose_card_info 获取的加密字符串</param>
  2651. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  2652. /// <returns></returns>
  2653. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardDecryptAsync", true)]
  2654. public static async Task<CardDecryptResultJson> CardDecryptAsync(string accessTokenOrAppId, string encryptCode, int timeOut = Config.TIME_OUT)
  2655. {
  2656. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2657. {
  2658. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/decrypt?access_token={0}", accessToken.AsUrlData());
  2659. var data = new
  2660. {
  2661. encrypt_code = encryptCode,
  2662. };
  2663. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<CardDecryptResultJson>(null, urlFormat, data, timeOut: timeOut);
  2664. }, accessTokenOrAppId);
  2665. }
  2666. /// <summary>
  2667. /// 【异步方法】删除卡券
  2668. /// </summary>
  2669. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2670. /// <param name="cardId">卡券ID</param>
  2671. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  2672. /// <returns></returns>
  2673. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardDeleteAsync", true)]
  2674. public static async Task<CardDeleteResultJson> CardDeleteAsync(string accessTokenOrAppId, string cardId, int timeOut = Config.TIME_OUT)
  2675. {
  2676. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2677. {
  2678. var urlFormat = string.Format(Config.ApiMpHost + "/card/delete?access_token={0}", accessToken.AsUrlData());
  2679. var data = new
  2680. {
  2681. card_id = cardId
  2682. };
  2683. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<CardDeleteResultJson>(null, urlFormat, data, timeOut: timeOut);
  2684. }, accessTokenOrAppId);
  2685. }
  2686. /// <summary>
  2687. /// 【异步方法】查询code接口
  2688. /// </summary>
  2689. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2690. /// <param name="code"></param>
  2691. /// <param name="cardId"></param>
  2692. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  2693. /// <returns></returns>
  2694. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardGetAsync", true)]
  2695. public static async Task<CardGetResultJson> CardGetAsync(string accessTokenOrAppId, string code, string cardId = null, int timeOut = Config.TIME_OUT)
  2696. {
  2697. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2698. {
  2699. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/get?access_token={0}", accessToken.AsUrlData());
  2700. var data = new
  2701. {
  2702. code = code,
  2703. card_id = cardId
  2704. };
  2705. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<CardGetResultJson>(null, urlFormat, data, timeOut: timeOut);
  2706. }, accessTokenOrAppId);
  2707. }
  2708. /// <summary>
  2709. /// 【异步方法】批量查询卡列表
  2710. /// </summary>
  2711. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2712. /// <param name="offset">查询卡列表的起始偏移量,从0 开始,即offset: 5 是指从从列表里的第六个开始读取。</param>
  2713. /// <param name="count">需要查询的卡片的数量(数量最大50)</param>
  2714. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  2715. /// <returns></returns>
  2716. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardBatchGetAsync", true)]
  2717. public static async Task<CardBatchGetResultJson> CardBatchGetAsync(string accessTokenOrAppId, int offset, int count, List<string> statusList, int timeOut = Config.TIME_OUT)
  2718. {
  2719. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2720. {
  2721. var urlFormat = string.Format(Config.ApiMpHost + "/card/batchget?access_token={0}", accessToken.AsUrlData());
  2722. var data = new
  2723. {
  2724. offset = offset,
  2725. count = count,
  2726. status_list = statusList
  2727. };
  2728. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<CardBatchGetResultJson>(null, urlFormat, data, timeOut: timeOut);
  2729. }, accessTokenOrAppId);
  2730. }
  2731. /// <summary>
  2732. /// 【异步方法】查询卡券详情
  2733. /// </summary>
  2734. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2735. /// <param name="cardId"></param>
  2736. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  2737. /// <returns></returns>
  2738. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardDetailGetAsync", true)]
  2739. public static async Task<CardDetailGetResultJson> CardDetailGetAsync(string accessTokenOrAppId, string cardId, int timeOut = Config.TIME_OUT)
  2740. {
  2741. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2742. {
  2743. var urlFormat = string.Format(Config.ApiMpHost + "/card/get?access_token={0}", accessToken.AsUrlData());
  2744. var data = new
  2745. {
  2746. card_id = cardId
  2747. };
  2748. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<CardDetailGetResultJson>(null, urlFormat, data, timeOut: timeOut);
  2749. }, accessTokenOrAppId);
  2750. }
  2751. /// <summary>
  2752. /// 【异步方法】更改code
  2753. /// </summary>
  2754. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2755. /// <param name="code">卡券的code 编码</param>
  2756. /// <param name="cardId">卡券ID</param>
  2757. /// <param name="newCode">新的卡券code 编码</param>
  2758. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  2759. /// <returns></returns>
  2760. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardChangeCodeAsync", true)]
  2761. public static async Task<WxJsonResult> CardChangeCodeAsync(string accessTokenOrAppId, string code, string cardId, string newCode, int timeOut = Config.TIME_OUT)
  2762. {
  2763. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2764. {
  2765. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/update?access_token={0}", accessToken.AsUrlData());
  2766. var data = new
  2767. {
  2768. code = code,
  2769. card_id = cardId,
  2770. new_code = newCode
  2771. };
  2772. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  2773. }, accessTokenOrAppId);
  2774. }
  2775. /// <summary>
  2776. /// 【异步方法】设置卡券失效接口
  2777. /// </summary>
  2778. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2779. /// <param name="code">需要设置为失效的code</param>
  2780. /// <param name="cardId">自定义code 的卡券必填。非自定义code 的卡券不填。</param>
  2781. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  2782. /// <returns></returns>
  2783. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardUnavailableAsync", true)]
  2784. public static async Task<WxJsonResult> CardUnavailableAsync(string accessTokenOrAppId, string code, string cardId = null, int timeOut = Config.TIME_OUT)
  2785. {
  2786. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2787. {
  2788. var urlFormat = string.Format(Config.ApiMpHost + "/card/code/unavailable?access_token={0}", accessToken.AsUrlData());
  2789. var data = new
  2790. {
  2791. code = code,
  2792. card_id = cardId
  2793. };
  2794. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  2795. }, accessTokenOrAppId);
  2796. }
  2797. /// <summary>
  2798. /// 【异步方法】拉取卡券概况数据接口
  2799. /// </summary>
  2800. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2801. /// <param name="beginDate">查询数据的起始时间。</param>
  2802. /// <param name="endDate">查询数据的截至时间。</param>
  2803. /// <param name="condSource">卡券来源,0为公众平台创建的卡券数据、1是API创建的卡券数据</param>
  2804. /// <returns></returns>
  2805. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetCardBizuinInfoAsync", true)]
  2806. public static async Task<GetCardBizuinInfoResultJson> GetCardBizuinInfoAsync(string accessTokenOrAppId, string beginDate, string endDate, int condSource, int timeOut = Config.TIME_OUT)
  2807. {
  2808. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2809. {
  2810. var urlFormat = string.Format(Config.ApiMpHost + "/datacube/getcardbizuininfo?access_token={0}", accessToken.AsUrlData());
  2811. var data = new
  2812. {
  2813. begin_date = beginDate,
  2814. end_date = endDate,
  2815. cond_source = condSource
  2816. };
  2817. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetCardBizuinInfoResultJson>(null, urlFormat, data, timeOut: timeOut);
  2818. }, accessTokenOrAppId);
  2819. }
  2820. /// <summary>
  2821. /// 获取免费券数据接口
  2822. /// </summary>
  2823. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2824. /// <param name="beginDate">查询数据的起始时间。</param>
  2825. /// <param name="endDate">查询数据的截至时间。</param>
  2826. /// <param name="condSource">卡券来源,0为公众平台创建的卡券数据、1是API创建的卡券数据</param>
  2827. /// <param name="cardId">卡券ID。填写后,指定拉出该卡券的相关数据。</param>
  2828. /// <returns></returns>
  2829. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetCardInfoAsync", true)]
  2830. public static async Task<GetCardInfoResultJson> GetCardInfoAsync(string accessTokenOrAppId, string beginDate, string endDate, int condSource, string cardId, int timeOut = Config.TIME_OUT)
  2831. {
  2832. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2833. {
  2834. var urlFormat = string.Format(Config.ApiMpHost + "/datacube/getcardcardinfo?access_token={0}", accessToken.AsUrlData());
  2835. var data = new
  2836. {
  2837. begin_date = beginDate,
  2838. end_date = endDate,
  2839. cond_source = condSource,
  2840. card_id = cardId
  2841. };
  2842. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetCardInfoResultJson>(null, urlFormat, data, timeOut: timeOut);
  2843. }, accessTokenOrAppId);
  2844. }
  2845. /// <summary>
  2846. /// 【异步方法】拉取会员卡数据接口
  2847. /// </summary>
  2848. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2849. /// <param name="beginDate">查询数据的起始时间。</param>
  2850. /// <param name="endDate">查询数据的截至时间。</param>
  2851. /// <param name="condSource">卡券来源,0为公众平台创建的卡券数据、1是API创建的卡券数据</param>
  2852. /// <returns></returns>
  2853. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetCardMemberCardInfoAsync", true)]
  2854. public static async Task<GetCardMemberCardInfoResultJson> GetCardMemberCardInfoAsync(string accessTokenOrAppId, string beginDate, string endDate, int condSource, int timeOut = Config.TIME_OUT)
  2855. {
  2856. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2857. {
  2858. var urlFormat = string.Format(Config.ApiMpHost + "/datacube/getcardmembercardinfo?access_token={0}", accessToken.AsUrlData());
  2859. var data = new
  2860. {
  2861. begin_date = beginDate,
  2862. end_date = endDate,
  2863. cond_source = condSource
  2864. };
  2865. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetCardMemberCardInfoResultJson>(null, urlFormat, data, timeOut: timeOut);
  2866. }, accessTokenOrAppId);
  2867. }
  2868. /// <summary>
  2869. /// 【异步方法】拉取单张会员卡数据接口
  2870. /// </summary>
  2871. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2872. /// <param name="beginDate">查询数据的起始时间。</param>
  2873. /// <param name="endDate">查询数据的截至时间。</param>
  2874. /// <param name="cardId">卡券id</param>
  2875. /// <param name="timeOut"></param>
  2876. /// <returns></returns>
  2877. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetCardMemberCardInfo", true)]
  2878. public static async Task<GetCardMemberCardDetailResultJson> GetCardMemberCardDetailAsync(string accessTokenOrAppId, string beginDate, string endDate, string cardId, int timeOut = Config.TIME_OUT)
  2879. {
  2880. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2881. {
  2882. var urlFormat = string.Format(Config.ApiMpHost + "/datacube/getcardmembercarddetail?access_token={0}", accessToken.AsUrlData());
  2883. var data = new
  2884. {
  2885. begin_date = beginDate,
  2886. end_date = endDate,
  2887. card_id = cardId
  2888. };
  2889. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetCardMemberCardDetailResultJson>(null, urlFormat, data, timeOut: timeOut);
  2890. }, accessTokenOrAppId);
  2891. }
  2892. /// <summary>
  2893. /// 【异步方法】更改卡券信息接口
  2894. /// 支持更新部分通用字段及特殊卡券(会员卡、飞机票、电影票、红包)中特定字段的信息。
  2895. /// </summary>
  2896. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2897. /// <param name="cardType">卡券种类,会员卡、飞机票、电影票、红包中的一种</param>
  2898. /// <param name="data">创建卡券需要的数据,格式可以看CardUpdateData.cs</param>
  2899. /// <param name="cardId"></param>
  2900. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  2901. /// <returns></returns>
  2902. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CardUpdateAsync", true)]
  2903. public static async Task<WxJsonResult> CardUpdateAsync(string accessTokenOrAppId, CardType cardType, object data, string cardId = null, int timeOut = Config.TIME_OUT)
  2904. {
  2905. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2906. {
  2907. var urlFormat = string.Format(Config.ApiMpHost + "/card/update?access_token={0}", accessToken.AsUrlData());
  2908. BaseCardUpdateInfo cardData = null;
  2909. switch (cardType)
  2910. {
  2911. case CardType.MEMBER_CARD:
  2912. cardData = new CardUpdate_MemberCard()
  2913. {
  2914. card_id = cardId,
  2915. member_card = data as Card_MemberCardUpdateData
  2916. };
  2917. break;
  2918. case CardType.BOARDING_PASS:
  2919. cardData = new CardUpdate_BoardingPass()
  2920. {
  2921. card_id = cardId,
  2922. boarding_pass = data as Card_BoardingPassData
  2923. };
  2924. break;
  2925. case CardType.MOVIE_TICKET:
  2926. cardData = new CardUpdate_MovieTicket()
  2927. {
  2928. card_id = cardId,
  2929. movie_ticket = data as Card_MovieTicketData
  2930. };
  2931. break;
  2932. case CardType.SCENIC_TICKET:
  2933. cardData = new CardUpdate_ScenicTicket()
  2934. {
  2935. card_id = cardId,
  2936. scenic_ticket = data as Card_ScenicTicketData
  2937. };
  2938. break;
  2939. default:
  2940. break;
  2941. }
  2942. JsonSetting jsonSetting = new JsonSetting()
  2943. {
  2944. TypesToIgnoreNull = new List<Type>() { typeof(BaseUpdateInfo), typeof(BaseCardUpdateInfo) }
  2945. };
  2946. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, cardData, timeOut: timeOut, jsonSetting: jsonSetting);
  2947. }, accessTokenOrAppId);
  2948. }
  2949. /// <summary>
  2950. /// 【异步方法】设置测试用户白名单
  2951. /// 由于卡券有审核要求,为方便公众号调试,可以设置一些测试帐号,这些帐号可以领取未通过审核的卡券,体验整个流程。
  2952. ///注:同时支持“openid”、“username”两种字段设置白名单,总数上限为10 个。
  2953. /// </summary>
  2954. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2955. /// <param name="openIds">测试的openid 列表</param>
  2956. /// <param name="userNames">测试的微信号列表</param>
  2957. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  2958. /// <returns></returns>
  2959. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.AuthoritySetAsync", true)]
  2960. public static async Task<WxJsonResult> AuthoritySetAsync(string accessTokenOrAppId, string[] openIds, string[] userNames, int timeOut = Config.TIME_OUT)
  2961. {
  2962. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2963. {
  2964. var urlFormat = string.Format(Config.ApiMpHost + "/card/testwhitelist/set?access_token={0}", accessToken.AsUrlData());
  2965. var data = new
  2966. {
  2967. openid = openIds,
  2968. username = userNames
  2969. };
  2970. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  2971. }, accessTokenOrAppId);
  2972. }
  2973. /// <summary>
  2974. /// 【异步方法】激活/绑定会员卡
  2975. /// </summary>
  2976. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  2977. /// <param name="membershipNumber">必填,会员卡编号,作为序列号显示在用户的卡包里。</param>
  2978. /// <param name="code">创建会员卡时获取的code</param>
  2979. /// <param name="activateEndTime">激活后的有效截至时间。若不填写默认以创建时的 data_info 为准。Unix时间戳格式。</param>
  2980. /// <param name="initBonus">初始积分,不填为0</param>
  2981. /// <param name="initBalance">初始余额,不填为0</param>
  2982. /// <param name="initCustomFieldValue1">创建时字段custom_field1定义类型的初始值,限制为4个汉字,12字节。</param>
  2983. /// <param name="initCustomFieldValue2">创建时字段custom_field2定义类型的初始值,限制为4个汉字,12字节。</param>
  2984. /// <param name="initCustomFieldValue3">创建时字段custom_field3定义类型的初始值,限制为4个汉字,12字节。</param>
  2985. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  2986. /// <param name="cardId"></param>
  2987. /// <param name="activateBeginTime">激活后的有效起始时间。若不填写默认以创建时的 data_info 为准。Unix时间戳格式。</param>
  2988. /// <returns></returns>
  2989. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.MemberCardActivateAsync", true)]
  2990. public static async Task<WxJsonResult> MemberCardActivateAsync(string accessTokenOrAppId, string membershipNumber, string code, string cardId, string activateBeginTime = null, string activateEndTime = null, string initBonus = null,
  2991. string initBalance = null, string initCustomFieldValue1 = null, string initCustomFieldValue2 = null, string initCustomFieldValue3 = null, int timeOut = Config.TIME_OUT)
  2992. {
  2993. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  2994. {
  2995. var urlFormat = string.Format(Config.ApiMpHost + "/card/membercard/activate?access_token={0}", accessToken.AsUrlData());
  2996. var data = new
  2997. {
  2998. init_bonus = initBonus,
  2999. init_balance = initBalance,
  3000. membership_number = membershipNumber,
  3001. code = code,
  3002. card_id = cardId,
  3003. activate_begin_time = activateBeginTime,
  3004. activate_end_time = activateEndTime,
  3005. init_custom_field_value1 = initCustomFieldValue1,
  3006. init_custom_field_value2 = initCustomFieldValue2,
  3007. init_custom_field_value3 = initCustomFieldValue3,
  3008. };
  3009. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3010. }, accessTokenOrAppId);
  3011. }
  3012. /// <summary>
  3013. /// 【异步方法】设置开卡字段接口
  3014. /// </summary>
  3015. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3016. /// <param name="data"></param>
  3017. /// <param name="timeOut"></param>
  3018. /// <returns></returns>
  3019. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.ActivateUserFormSetAsync", true)]
  3020. public static async Task<WxJsonResult> ActivateUserFormSetAsync(string accessTokenOrAppId, ActivateUserFormSetData data, int timeOut = Config.TIME_OUT)
  3021. {
  3022. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3023. {
  3024. var urlFormat = string.Format(Config.ApiMpHost + "/card/membercard/activateuserform/set?access_token={0}", accessToken.AsUrlData());
  3025. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3026. }, accessTokenOrAppId);
  3027. }
  3028. /// <summary>
  3029. /// 【异步方法】拉取会员信息接口
  3030. /// </summary>
  3031. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3032. /// <param name="cardId">CardID</param>
  3033. /// <param name="code">Code</param>
  3034. /// <param name="timeOut"></param>
  3035. /// <returns></returns>
  3036. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.UserinfoGetAsync", true)]
  3037. public static async Task<UserinfoGetResult> UserinfoGetAsync(string accessTokenOrAppId, string cardId, string code, int timeOut = Config.TIME_OUT)
  3038. {
  3039. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3040. {
  3041. var urlFormat = string.Format(Config.ApiMpHost + "/card/membercard/userinfo/get?access_token={0}", accessToken);
  3042. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<UserinfoGetResult>(null, urlFormat, new { card_id = cardId, code = code }, timeOut: timeOut);
  3043. }, accessTokenOrAppId);
  3044. }
  3045. /// <summary>
  3046. /// 【异步方法】设置跟随推荐接口
  3047. /// 有 使用消息配置卡券(cardCellData) 和 使用消息配置URL(urlCellData) 两种方式
  3048. /// 注意:cardCellData和urlCellData必须也只能选择一个,不可同时为空
  3049. /// </summary>
  3050. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3051. /// <param name="cardId">卡券ID</param>
  3052. /// <param name="cardCellData">使用消息配置卡券数据</param>
  3053. /// <param name="urlCellData">使用消息配置URL数据</param>
  3054. /// <param name="timeOut"></param>
  3055. /// <returns></returns>
  3056. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.RecommendSetAsync", true)]
  3057. public static async Task<WxJsonResult> RecommendSetAsync(string accessTokenOrAppId, string cardId, CardCell cardCellData = null, UrlCell urlCellData = null, int timeOut = Config.TIME_OUT)
  3058. {
  3059. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3060. {
  3061. var urlFormat = string.Format(Config.ApiMpHost + "/card/update?access_token={0}", accessToken.AsUrlData());
  3062. var data = new
  3063. {
  3064. card_id = cardId,
  3065. member_card = new
  3066. {
  3067. modify_msg_operation = new
  3068. {
  3069. card_cell = cardCellData,
  3070. url_cell = urlCellData
  3071. }
  3072. }
  3073. };
  3074. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3075. }, accessTokenOrAppId);
  3076. }
  3077. /// <summary>
  3078. /// 【异步方法】设置微信买单接口
  3079. /// 注意:在调用买单接口之前,请开发者务必确认是否已经开通了微信支付以及对相应的cardid设置了门店,否则会报错
  3080. /// 错误码,0为正常;43008为商户没有开通微信支付权限
  3081. /// </summary>
  3082. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3083. /// <param name="cardId">卡券ID</param>
  3084. /// <param name="isOpen">是否开启买单功能,填true/false</param>
  3085. /// <param name="timeOut"></param>
  3086. /// <returns></returns>
  3087. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.PayCellSetAsync", true)]
  3088. public static async Task<WxJsonResult> PayCellSetAsync(string accessTokenOrAppId, string cardId, bool isOpen, int timeOut = Config.TIME_OUT)
  3089. {
  3090. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3091. {
  3092. var urlFormat = string.Format(Config.ApiMpHost + "/card/paycell/set?access_token={0}", accessToken.AsUrlData());
  3093. var data = new
  3094. {
  3095. card_id = cardId,
  3096. is_open = isOpen
  3097. };
  3098. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3099. }, accessTokenOrAppId);
  3100. }
  3101. /// <summary>
  3102. /// 【异步方法】设置自助核销接口
  3103. /// 注意:设置自助核销的card_id必须已经配置了门店,否则会报错。
  3104. /// 错误码,0为正常;43008为商户没有开通微信支付权限
  3105. /// </summary>
  3106. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3107. /// <param name="cardId">卡券ID</param>
  3108. /// <param name="isOpen">是否开启自助核销功能,填true/false</param>
  3109. /// <param name="timeOut"></param>
  3110. /// <returns></returns>
  3111. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.SelfConsumecellSetAsync", true)]
  3112. public static async Task<WxJsonResult> SelfConsumecellSetAsync(string accessTokenOrAppId, string cardId, bool isOpen, int timeOut = Config.TIME_OUT)
  3113. {
  3114. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3115. {
  3116. var urlFormat = string.Format(Config.ApiMpHost + "/card/selfconsumecell/set?access_token={0}", accessToken.AsUrlData());
  3117. var data = new
  3118. {
  3119. card_id = cardId,
  3120. is_open = isOpen
  3121. };
  3122. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3123. }, accessTokenOrAppId);
  3124. }
  3125. /// <summary>
  3126. /// 【异步方法】 更新会员信息
  3127. /// </summary>
  3128. /// post数据:
  3129. /// 可以传入积分、余额的差值
  3130. /// {
  3131. /// "code": "12312313",
  3132. /// "card_id":"p1Pj9jr90_SQRaVqYI239Ka1erkI",
  3133. /// "record_bonus": "消费30元,获得3积分",
  3134. /// "add_bonus": 3,//可以传入积分增减的差值
  3135. /// "add_balance": -3000,//可以传入余额本次增减的差值
  3136. /// "record_balance": "购买焦糖玛琪朵一杯,扣除金额30元。",
  3137. /// "custom_field_value1": "xxxxx",
  3138. /// }
  3139. /// 或者直接传入积分、余额的全量值
  3140. ///
  3141. /// {
  3142. /// "code": "12312313",
  3143. /// "card_id":"p1Pj9jr90_SQRaVqYI239Ka1erkI",
  3144. /// "record_bonus": "消费30元,获得3积分",
  3145. /// "bonus": 3000,//可以传入第三方系统记录的积分全量值
  3146. /// "balance": 3000,//可以传入第三方系统记录的余额全量值
  3147. /// "record_balance": "购买焦糖玛琪朵一杯,扣除金额30元。",
  3148. /// "custom_field_value1": "xxxxx",
  3149. /// }
  3150. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3151. /// <param name="code">卡券Code码。</param>
  3152. /// <param name="cardId">卡券ID。</param>
  3153. /// <param name="addBonus">需要变更的积分,扣除积分用“-“表示。</param>
  3154. /// <param name="addBalance">需要变更的余额,扣除金额用“-”表示。单位为分。</param>
  3155. /// <param name="backgroundPicUrl">用户卡片的背景图片</param>
  3156. /// <param name="bonus">需要设置的积分全量值,传入的数值会直接显示,如果同时传入add_bonus和bonus,则前者无效。</param>
  3157. /// <param name="balance">需要设置的余额全量值,传入的数值会直接显示,如果同时传入add_balance和balance,则前者无效。</param>
  3158. /// <param name="recordBonus">商家自定义积分消耗记录,不超过14个汉字。</param>
  3159. /// <param name="recordBalance">商家自定义金额消耗记录,不超过14个汉字。</param>
  3160. /// <param name="customFieldValue1">创建时字段custom_field1定义类型的最新数值,限制为4个汉字,12字节。</param>
  3161. /// <param name="customFieldValue2">创建时字段custom_field2定义类型的最新数值,限制为4个汉字,12字节。</param>
  3162. /// <param name="customFieldValue3">创建时字段custom_field3定义类型的最新数值,限制为4个汉字,12字节。</param>
  3163. /// <param name="timeOut"></param>
  3164. /// <returns></returns>
  3165. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.UpdateUserAsync", true)]
  3166. public static async Task<UpdateUserResultJson> UpdateUserAsync(string accessTokenOrAppId, string code, string cardId, int addBonus, int addBalance, string backgroundPicUrl = null,
  3167. int? bonus = null, int? balance = null, string recordBonus = null, string recordBalance = null, string customFieldValue1 = null,
  3168. string customFieldValue2 = null, string customFieldValue3 = null, int timeOut = Config.TIME_OUT)
  3169. {
  3170. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3171. {
  3172. var urlFormat = string.Format(Config.ApiMpHost + "/card/membercard/updateuser?access_token={0}", accessToken.AsUrlData());
  3173. var data = new
  3174. {
  3175. code = code,
  3176. card_id = cardId,
  3177. background_pic_url = backgroundPicUrl,
  3178. add_bonus = addBonus,
  3179. bonus = bonus,
  3180. record_bonus = recordBonus,
  3181. add_balance = addBalance,
  3182. balance = balance,
  3183. record_balance = recordBalance,
  3184. custom_field_value1 = customFieldValue1,
  3185. custom_field_value2 = customFieldValue2,
  3186. custom_field_value3 = customFieldValue3,
  3187. };
  3188. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<UpdateUserResultJson>(null, urlFormat, data, timeOut: timeOut);
  3189. }, accessTokenOrAppId);
  3190. }
  3191. /// <summary>
  3192. /// 【异步方法】会员卡交易
  3193. /// </summary>
  3194. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3195. /// <param name="code">要消耗的序列号</param>
  3196. /// <param name="cardId">要消耗序列号所述的card_id。自定义code 的会员卡必填</param>
  3197. /// <param name="recordBonus">商家自定义积分消耗记录,不超过14 个汉字</param>
  3198. /// <param name="addBonus">需要变更的积分,扣除积分用“-“表</param>
  3199. /// <param name="addBalance">需要变更的余额,扣除金额用“-”表示。单位为分</param>
  3200. /// <param name="recordBalance">商家自定义金额消耗记录,不超过14 个汉字</param>
  3201. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  3202. /// <returns></returns>
  3203. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.MemberCardDealAsync", true)]
  3204. public static async Task<MemberCardDealResultJson> MemberCardDealAsync(string accessTokenOrAppId, string code, string cardId, string recordBonus, decimal addBonus, decimal addBalance, string recordBalance, int timeOut = Config.TIME_OUT)
  3205. {
  3206. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3207. {
  3208. var urlFormat = string.Format(Config.ApiMpHost + "/card/membercard/updateuser?access_token={0}", accessToken.AsUrlData());
  3209. var data = new
  3210. {
  3211. code = code,
  3212. card_id = cardId,
  3213. record_bonus = recordBonus,
  3214. add_bonus = addBonus,
  3215. add_balance = addBalance,
  3216. record_balance = recordBalance,
  3217. };
  3218. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<MemberCardDealResultJson>(null, urlFormat, data, timeOut: timeOut);
  3219. }, accessTokenOrAppId);
  3220. }
  3221. /// <summary>
  3222. /// 【异步方法】更新电影票
  3223. /// </summary>
  3224. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3225. /// <param name="code">电影票的序列号</param>
  3226. /// <param name="cardId">电影票card_id。自定义code 的电影票为必填,非自定义code 的电影票不必填。</param>
  3227. /// <param name="ticketClass">电影票的类别,如2D、3D</param>
  3228. /// <param name="showTime">电影放映时间对应的时间戳</param>
  3229. /// <param name="duration">放映时长,填写整数</param>
  3230. /// <param name="screeningRoom">该场电影的影厅信息</param>
  3231. /// <param name="seatNumbers">座位号</param>
  3232. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  3233. /// <returns></returns>
  3234. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.MovieCardUpdateAsync", true)]
  3235. public static async Task<WxJsonResult> MovieCardUpdateAsync(string accessTokenOrAppId, string code, string cardId, string ticketClass, string showTime, int duration, string screeningRoom, string[] seatNumbers, int timeOut = Config.TIME_OUT)
  3236. {
  3237. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3238. {
  3239. var urlFormat = string.Format(Config.ApiMpHost + "/card/movieticket/updateuser?access_token={0}", accessToken.AsUrlData());
  3240. var data = new
  3241. {
  3242. code = code,
  3243. card_id = cardId,
  3244. ticket_class = ticketClass,
  3245. show_time = showTime,
  3246. duration = duration,
  3247. screening_room = screeningRoom,
  3248. seat_number = seatNumbers
  3249. };
  3250. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3251. }, accessTokenOrAppId);
  3252. }
  3253. /// <summary>
  3254. /// 【异步方法】飞机票在线选座
  3255. /// </summary>
  3256. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3257. /// <param name="code">飞机票的序列</param>
  3258. /// <param name="cardId">需办理值机的机票card_id。自定义code 的飞机票为必</param>
  3259. /// <param name="passengerName">乘客姓名,上限为15 个汉字</param>
  3260. /// <param name="classType">舱等,如头等舱等,上限为5 个汉字</param>
  3261. /// <param name="seat">乘客座位号</param>
  3262. /// <param name="etktBnr">电子客票号,上限为14 个数字</param>
  3263. /// <param name="qrcodeData">二维码数据。乘客用于值机的二维码字符串,微信会通过此数据为用户生成值机用的二维码</param>
  3264. /// <param name="isCancel">是否取消值机。填写true 或false。true 代表取消,如填写true 上述字段(如calss 等)均不做判断,机票返回未值机状态,乘客可重新值机。默认填写false</param>
  3265. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  3266. /// <returns></returns>
  3267. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.BoardingPassCheckInAsync", true)]
  3268. public static async Task<WxJsonResult> BoardingPassCheckInAsync(string accessTokenOrAppId, string code, string cardId, string passengerName, string classType, string seat, string etktBnr, string qrcodeData, bool isCancel = false, int timeOut = Config.TIME_OUT)
  3269. {
  3270. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3271. {
  3272. var urlFormat = string.Format(Config.ApiMpHost + "/card/boardingpass/checkin?access_token={0}", accessToken.AsUrlData());
  3273. var data = new
  3274. {
  3275. code = code,
  3276. card_id = cardId,
  3277. passenger_name = passengerName,
  3278. @class = classType,
  3279. seat = seat,
  3280. etkt_bnr = etktBnr,
  3281. qrcode_data = qrcodeData,
  3282. is_cancel = isCancel
  3283. };
  3284. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut);
  3285. }, accessTokenOrAppId);
  3286. }
  3287. /// <summary>
  3288. /// 【异步方法】更新红包金额
  3289. /// </summary>
  3290. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3291. /// <param name="code">红包的序列号</param>
  3292. /// <param name="cardId">自定义code 的卡券必填。非自定义code 可不填。</param>
  3293. /// <param name="balance">红包余额</param>
  3294. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  3295. /// <returns></returns>
  3296. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.UpdateUserBalanceAsync", true)]
  3297. public static async Task<WxJsonResult> UpdateUserBalanceAsync(string accessTokenOrAppId, string code, string cardId, decimal balance, int timeOut = Config.TIME_OUT)
  3298. {
  3299. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3300. {
  3301. var urlFormat = string.Format(Config.ApiMpHost + "/card/luckymoney/updateuserbalance?access_token={0}", accessToken.AsUrlData());
  3302. var data = new
  3303. {
  3304. code = code,
  3305. card_id = cardId,
  3306. balance = balance
  3307. };
  3308. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3309. }, accessTokenOrAppId);
  3310. }
  3311. /// <summary>
  3312. /// 【异步方法】更新会议门票接口
  3313. /// </summary>
  3314. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3315. /// <param name="code">用户的门票唯一序列号</param>
  3316. /// <param name="cardId">要更新门票序列号所述的card_id , 生成券时use_custom_code 填写true 时必填。</param>
  3317. /// <param name="zone">区域</param>
  3318. /// <param name="entrance">入口</param>
  3319. /// <param name="seatNumber">座位号</param>
  3320. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  3321. /// <returns></returns>
  3322. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.UpdateMeetingTicketAsync", true)]
  3323. public static async Task<WxJsonResult> UpdateMeetingTicketAsync(string accessTokenOrAppId, string code, string cardId = null, string zone = null, string entrance = null, string seatNumber = null, int timeOut = Config.TIME_OUT)
  3324. {
  3325. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3326. {
  3327. var urlFormat = string.Format(Config.ApiMpHost + "/card/meetingticket/updateuser?access_token={0}", accessToken.AsUrlData());
  3328. var data = new
  3329. {
  3330. code = code,
  3331. card_id = cardId,
  3332. zone = zone,
  3333. entrance = entrance,
  3334. seat_number = seatNumber
  3335. };
  3336. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3337. }, accessTokenOrAppId);
  3338. }
  3339. /// <summary>
  3340. /// 【异步方法】创建子商户接口
  3341. /// </summary>
  3342. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3343. /// <param name="info">json结构</param>
  3344. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  3345. /// <returns></returns>
  3346. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.SubmerChantSubmitAsync", true)]
  3347. public static async Task<SubmerChantSubmitJsonResult> SubmerChantSubmitAsync(string accessTokenOrAppId, InfoList info, int timeOut = Config.TIME_OUT)
  3348. {
  3349. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3350. {
  3351. var urlFormat = string.Format(Config.ApiMpHost + "/card/submerchant/submit?access_token={0}", accessToken.AsUrlData());
  3352. var data = new
  3353. {
  3354. info = info
  3355. };
  3356. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<SubmerChantSubmitJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3357. }, accessTokenOrAppId);
  3358. }
  3359. /// <summary>
  3360. /// 【异步方法】卡券开放类目查询接口
  3361. /// </summary>
  3362. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3363. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  3364. /// <returns></returns>
  3365. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetApplyProtocolAsync", true)]
  3366. public static async Task<GetApplyProtocolJsonResult> GetApplyProtocolAsync(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  3367. {
  3368. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3369. {
  3370. var url = string.Format(Config.ApiMpHost + "/card/getapplyprotocol?access_token={0}", accessToken.AsUrlData());
  3371. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetApplyProtocolJsonResult>(null, url, null, CommonJsonSendType.GET, timeOut);
  3372. }, accessTokenOrAppId);
  3373. }
  3374. /// <summary>
  3375. ///【异步方法】拉取单个子商户信息接口
  3376. /// </summary>
  3377. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3378. /// <param name="appid"></param>
  3379. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  3380. /// <returns></returns>
  3381. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetCardMerchantAsync", true)]
  3382. public static async Task<GetCardMerchantJsonResult> GetCardMerchantAsync(string accessTokenOrAppId, string appid, int timeOut = Config.TIME_OUT)
  3383. {
  3384. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3385. {
  3386. var url = string.Format(Config.ApiMpHost + "/cgi-bin/component/get_card_merchant?access_token={0}", accessToken.AsUrlData());
  3387. var data = new
  3388. {
  3389. appid = appid
  3390. };
  3391. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetCardMerchantJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
  3392. }, accessTokenOrAppId);
  3393. }
  3394. /// <summary>
  3395. ///【异步方法】拉取子商户列表接口
  3396. /// </summary>
  3397. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3398. /// <param name="nextGet">获取子商户列表,注意最开始时为空。每次拉取20个子商户,下次拉取时填入返回数据中该字段的值,该值无实际意义。</param>
  3399. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  3400. /// <returns></returns>
  3401. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.BatchGetCardMerchantAsync", true)]
  3402. public static async Task<BatchGetCardMerchantJsonResult> BatchGetCardMerchantAsync(string accessTokenOrAppId, string nextGet, int timeOut = Config.TIME_OUT)
  3403. {
  3404. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3405. {
  3406. var url = string.Format(Config.ApiMpHost + "/cgi-bin/component/batchget_card_merchant?access_token={0}", accessToken.AsUrlData());
  3407. var data = new
  3408. {
  3409. next_get = nextGet
  3410. };
  3411. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<BatchGetCardMerchantJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
  3412. }, accessTokenOrAppId);
  3413. }
  3414. /// <summary>
  3415. /// 【异步方法】 更新子商户接口
  3416. /// </summary>
  3417. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3418. /// <param name="info">json结构</param>
  3419. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  3420. /// <returns></returns>
  3421. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.SubmerChantUpdateAsync", true)]
  3422. public static async Task<SubmerChantSubmitJsonResult> SubmerChantUpdateAsync(string accessTokenOrAppId, InfoList info, int timeOut = Config.TIME_OUT)
  3423. {
  3424. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3425. {
  3426. var urlFormat = string.Format(Config.ApiMpHost + "/card/submerchant/update?access_token={0}", accessToken.AsUrlData());
  3427. var data = new
  3428. {
  3429. info = info
  3430. };
  3431. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<SubmerChantSubmitJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3432. }, accessTokenOrAppId);
  3433. }
  3434. /// <summary>
  3435. /// 【异步方法】拉取单个子商户信息接口
  3436. /// </summary>
  3437. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3438. /// <param name="merchantId">子商户id,一个母商户公众号下唯一。</param>
  3439. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  3440. /// <returns></returns>
  3441. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.SubmerChantGetAsync", true)]
  3442. public static async Task<SubmerChantSubmitJsonResult> SubmerChantGetAsync(string accessTokenOrAppId, string merchantId, int timeOut = Config.TIME_OUT)
  3443. {
  3444. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3445. {
  3446. var urlFormat = string.Format(Config.ApiMpHost + "/card/submerchant/get?access_token={0}", accessToken.AsUrlData());
  3447. var data = new
  3448. {
  3449. merchant_id = merchantId
  3450. };
  3451. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<SubmerChantSubmitJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3452. }, accessTokenOrAppId);
  3453. }
  3454. /// <summary>
  3455. /// 【异步方法】批量拉取子商户信息接口
  3456. /// </summary>
  3457. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3458. /// <param name="beginId">起始的子商户id,一个母商户公众号下唯一</param>
  3459. /// <param name="limit">拉取的子商户的个数,最大值为100</param>
  3460. /// <param name="status">json结构</param>
  3461. /// <param name="timeOut">子商户审核状态,填入后,只会拉出当前状态的子商户</param>
  3462. /// <returns></returns>
  3463. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.SubmerChantBatchGetAsync", true)]
  3464. public static async Task<SubmerChantBatchGetJsonResult> SubmerChantBatchGetAsync(string accessTokenOrAppId, string beginId, int limit, string status, int timeOut = Config.TIME_OUT)
  3465. {
  3466. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3467. {
  3468. var urlFormat = string.Format(Config.ApiMpHost + "/card/submerchant/batchget?access_token={0}", accessToken.AsUrlData());
  3469. var data = new
  3470. {
  3471. begin_id = beginId,
  3472. limit = limit,
  3473. status = status
  3474. };
  3475. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<SubmerChantBatchGetJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3476. }, accessTokenOrAppId);
  3477. }
  3478. /// <summary>
  3479. /// 【异步方法】母商户资质申请接口
  3480. /// </summary>
  3481. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3482. /// <param name="registerCapital">注册资本,数字,单位:分</param>
  3483. /// <param name="businessLicenseMediaid">营业执照扫描件的media_id</param>
  3484. /// <param name="taxRegistRationCertificateMediaid">税务登记证扫描件的media_id</param>
  3485. /// <param name="lastQuarterTaxListingMediaid">上个季度纳税清单扫描件media_id</param>
  3486. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  3487. /// <returns></returns>
  3488. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.AgentQualificationAsync", true)]
  3489. public static async Task<WxJsonResult> AgentQualificationAsync(string accessTokenOrAppId, string registerCapital, string businessLicenseMediaid, string taxRegistRationCertificateMediaid, string lastQuarterTaxListingMediaid, int timeOut = Config.TIME_OUT)
  3490. {
  3491. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3492. {
  3493. var urlFormat = string.Format(Config.ApiMpHost + "/cgi-bin/component/upload_card_agent_qualification?access_token={0}", accessToken.AsUrlData());
  3494. var data = new
  3495. {
  3496. register_capital = registerCapital,
  3497. business_license_media_id = businessLicenseMediaid,
  3498. tax_registration_certificate_media_id = taxRegistRationCertificateMediaid,
  3499. last_quarter_tax_listing_media_id = lastQuarterTaxListingMediaid
  3500. };
  3501. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3502. }, accessTokenOrAppId);
  3503. }
  3504. /// <summary>
  3505. /// 【异步方法】母商户资质审核查询接口
  3506. /// </summary>
  3507. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3508. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  3509. /// <returns></returns>
  3510. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CheckAgentQualificationAsync", true)]
  3511. public static async Task<CheckQualificationJsonResult> CheckAgentQualificationAsync(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  3512. {
  3513. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3514. {
  3515. var url = string.Format(Config.ApiMpHost + "/cgi-bin/component/check_card_agent_qualification?access_token={0}", accessToken.AsUrlData());
  3516. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<CheckQualificationJsonResult>(null, url, null, CommonJsonSendType.GET, timeOut);
  3517. }, accessTokenOrAppId);
  3518. }
  3519. /// <summary>
  3520. /// 【异步方法】子商户资质申请接口
  3521. /// </summary>
  3522. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3523. /// <param name="appid">子商户公众号的appid</param>
  3524. /// <param name="name">子商户商户名,用于显示在卡券券面</param>
  3525. /// <param name="logoMediaid">子商户logo,用于显示在子商户卡券的券面</param>
  3526. /// <param name="businessLicenseMediaid">营业执照或个体工商户执照扫描件的media_id</param>
  3527. /// <param name="operatorIdCardMediaid">当子商户为个体工商户且无公章时,授权函须签名,并额外提交该个体工商户经营者身份证扫描件的media_id</param>
  3528. /// <param name="agreementFileMediaid">子商户与第三方签署的代理授权函的media_id</param>
  3529. /// <param name="primaryCategoryId">一级类目id</param>
  3530. /// <param name="secondaryCategoryId">二级类目id</param>
  3531. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  3532. /// <returns></returns>
  3533. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.MerchantQualificationAsync", true)]
  3534. public static async Task<WxJsonResult> MerchantQualificationAsync(string accessTokenOrAppId, string appid, string name, string logoMediaid, string businessLicenseMediaid, string operatorIdCardMediaid, string agreementFileMediaid, string primaryCategoryId, string secondaryCategoryId, int timeOut = Config.TIME_OUT)
  3535. {
  3536. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3537. {
  3538. var urlFormat = string.Format(Config.ApiMpHost + "/cgi-bin/component/upload_card_merchant_qualification?access_token={0}", accessToken.AsUrlData());
  3539. var data = new
  3540. {
  3541. appid = appid,
  3542. name = name,
  3543. logo_meida_id = logoMediaid,
  3544. business_license_media_id = businessLicenseMediaid,
  3545. operator_id_card_media_id = operatorIdCardMediaid,
  3546. agreement_file_media_id = agreementFileMediaid,
  3547. primary_category_id = primaryCategoryId,
  3548. secondary_category_id = secondaryCategoryId
  3549. };
  3550. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3551. }, accessTokenOrAppId);
  3552. }
  3553. /// <summary>
  3554. /// 【异步方法】子商户资质审核查询接口
  3555. /// </summary>
  3556. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3557. /// <param name="appid"></param>
  3558. /// <param name="timeOut">代理请求超时时间(毫秒)</param>
  3559. /// <returns></returns>
  3560. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CheckMerchantQualificationAsync", true)]
  3561. public static async Task<CheckQualificationJsonResult> CheckMerchantQualificationAsync(string accessTokenOrAppId, string appid, int timeOut = Config.TIME_OUT)
  3562. {
  3563. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3564. {
  3565. var url = string.Format(Config.ApiMpHost + "/cgi-bin/component/check_card_merchant_qualification?access_token={0}", accessToken.AsUrlData());
  3566. var data = new
  3567. {
  3568. appid = appid
  3569. };
  3570. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<CheckQualificationJsonResult>(null, url, data, CommonJsonSendType.POST, timeOut);
  3571. }, accessTokenOrAppId);
  3572. }
  3573. /// <summary>
  3574. /// 【异步方法】获取用户已领取卡券
  3575. /// </summary>
  3576. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3577. /// <param name="openId">需要查询的用户openid</param>
  3578. /// <param name="cardId">卡券ID。不填写时默认查询当前appid下的卡券。</param>
  3579. /// <param name="timeOut"></param>
  3580. /// <returns></returns>
  3581. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetCardListAsync", true)]
  3582. public static async Task<GetCardListResultJson> GetCardListAsync(string accessTokenOrAppId, string openId, string cardId = null, int timeOut = Config.TIME_OUT)
  3583. {
  3584. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3585. {
  3586. var urlFormat = string.Format(Config.ApiMpHost + "/card/user/getcardlist?access_token={0}", accessToken.AsUrlData());
  3587. var data = new
  3588. {
  3589. openid = openId,
  3590. card_id = cardId,
  3591. };
  3592. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetCardListResultJson>(null, urlFormat, data, timeOut: timeOut);
  3593. }, accessTokenOrAppId);
  3594. }
  3595. /// <summary>
  3596. /// 【异步方法】修改库存接口
  3597. /// </summary>
  3598. /// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
  3599. /// <param name="cardId">卡券ID</param>
  3600. /// <param name="increaseStockValue">增加多少库存,支持不填或填0</param>
  3601. /// <param name="reduceStockValue">减少多少库存,可以不填或填0</param>
  3602. /// <param name="timeOut"></param>
  3603. /// <returns></returns>
  3604. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.ModifyStockAsync", true)]
  3605. public static async Task<WxJsonResult> ModifyStockAsync(string accessTokenOrAppId, string cardId, int increaseStockValue = 0, int reduceStockValue = 0, int timeOut = Config.TIME_OUT)
  3606. {
  3607. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3608. {
  3609. var urlFormat = string.Format(Config.ApiMpHost + "/card/modifystock?access_token={0}", accessToken.AsUrlData());
  3610. var data = new
  3611. {
  3612. card_id = cardId,
  3613. increase_stock_value = increaseStockValue,
  3614. reduce_stock_value = reduceStockValue
  3615. };
  3616. return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3617. }, accessTokenOrAppId);
  3618. }
  3619. /// <summary>
  3620. /// 【异步方法】获取开卡插件参数
  3621. /// </summary>
  3622. /// <param name="accessTokenOrAppId"></param>
  3623. /// <param name="cardId"></param>
  3624. /// <param name="outerStr"></param>
  3625. /// <param name="timeOut"></param>
  3626. /// <returns></returns>
  3627. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetCardUrlAsync", true)]
  3628. public static async Task<Card_GetUrlResultJson> GetCardUrlAsync(string accessTokenOrAppId, string cardId, string outerStr, int timeOut = Config.TIME_OUT)
  3629. {
  3630. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3631. {
  3632. var urlFormat = string.Format(Config.ApiMpHost + "/card/membercard/activate/geturl?access_token={0}", accessToken.AsUrlData());
  3633. var data = new
  3634. {
  3635. card_id = cardId,
  3636. outer_str = outerStr
  3637. };
  3638. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<Card_GetUrlResultJson>(null, urlFormat, data, timeOut: timeOut);
  3639. }, accessTokenOrAppId);
  3640. }
  3641. /// <summary>
  3642. /// 【异步方法】获取用户开卡时提交的信息(跳转型开卡组件)
  3643. /// </summary>
  3644. /// <param name="accessTokenOrAppId"></param>
  3645. /// <param name="activateTicket"></param>
  3646. /// <param name="timeOut"></param>
  3647. /// <returns></returns>
  3648. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetActivateTempInfoAsync", true)]
  3649. public static async Task<GetActivateTempInfoResultJson> GetActivateTempInfoAsync(string accessTokenOrAppId, string activateTicket, int timeOut = Config.TIME_OUT)
  3650. {
  3651. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3652. {
  3653. var urlFormat = string.Format(Config.ApiMpHost + "/card/membercard/activatetempinfo/get?access_token={0}", accessToken.AsUrlData());
  3654. var data = new
  3655. {
  3656. activate_ticket = activateTicket
  3657. };
  3658. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetActivateTempInfoResultJson>(null, urlFormat, data, timeOut: timeOut);
  3659. }, accessTokenOrAppId);
  3660. }
  3661. /// <summary>
  3662. /// 【异步方法】创建-礼品卡货架接口
  3663. /// </summary>
  3664. /// <param name="accessTokenOrAppId"></param>
  3665. /// <param name="data"></param>
  3666. /// <param name="timeOut"></param>
  3667. /// <returns></returns>
  3668. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.AddGiftCardPageAsync", true)]
  3669. public static async Task<CardCreateResultJson> AddGiftCardPageAsync(string accessTokenOrAppId, GiftCardPageData data, int timeOut = Config.TIME_OUT)
  3670. {
  3671. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3672. {
  3673. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/page/add?access_token={0}", accessToken.AsUrlData());
  3674. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<CardCreateResultJson>(null, urlFormat, data, timeOut: timeOut);
  3675. }, accessTokenOrAppId);
  3676. }
  3677. /// <summary>
  3678. /// 【异步方法】查询-礼品卡货架信息接口
  3679. /// </summary>
  3680. /// <param name="accessTokenOrAppId"></param>
  3681. /// <param name="pageId"></param>
  3682. /// <param name="timeOut"></param>
  3683. /// <returns></returns>
  3684. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetGiftCardPageInfoAsync", true)]
  3685. public static async Task<GetGiftCardPageInfoResultJson> GetGiftCardPageInfoAsync(string accessTokenOrAppId, string pageId, int timeOut = Config.TIME_OUT)
  3686. {
  3687. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3688. {
  3689. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/page/get?access_token={0}", accessToken.AsUrlData());
  3690. var data = new
  3691. {
  3692. page_id = pageId
  3693. };
  3694. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetGiftCardPageInfoResultJson>(null, urlFormat, data, timeOut: timeOut);
  3695. }, accessTokenOrAppId);
  3696. }
  3697. /// <summary>
  3698. /// 【异步方法】修改-礼品卡货架信息接口
  3699. /// </summary>
  3700. /// <param name="accessTokenOrAppId"></param>
  3701. /// <param name="data"></param>
  3702. /// <param name="timeOut"></param>
  3703. /// <returns></returns>
  3704. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.UpdateGiftCardPageAsync", true)]
  3705. public static async Task<WxJsonResult> UpdateGiftCardPageAsync(string accessTokenOrAppId, GiftCardPageData data, int timeOut = Config.TIME_OUT)
  3706. {
  3707. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3708. {
  3709. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/page/add?access_token={0}", accessToken.AsUrlData());
  3710. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3711. }, accessTokenOrAppId);
  3712. }
  3713. /// <summary>
  3714. /// 【异步方法】查询-礼品卡货架列表接口
  3715. /// </summary>
  3716. /// <param name="accessTokenOrAppId"></param>
  3717. /// <param name="timeOut"></param>
  3718. /// <returns></returns>
  3719. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetGiftCardPageListAsync", true)]
  3720. public static async Task<GetGiftCardPageListResultJson> GetGiftCardPageListAsync(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  3721. {
  3722. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3723. {
  3724. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/page/batchget?access_token={0}", accessToken.AsUrlData());
  3725. var data = new { };
  3726. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetGiftCardPageListResultJson>(null, urlFormat, data, timeOut: timeOut);
  3727. }, accessTokenOrAppId);
  3728. }
  3729. /// <summary>
  3730. /// 【异步方法】下架-礼品卡货架接口
  3731. /// </summary>
  3732. /// <param name="accessTokenOrAppId"></param>
  3733. /// <param name="data"></param>
  3734. /// <param name="timeOut"></param>
  3735. /// <returns></returns>
  3736. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.DownGiftCardPageAsync", true)]
  3737. public static async Task<DownGiftCardPageResultJson> DownGiftCardPageAsync(string accessTokenOrAppId, DownGiftCardPage data, int timeOut = Config.TIME_OUT)
  3738. {
  3739. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3740. {
  3741. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/maintain/set?access_token={0}", accessToken.AsUrlData());
  3742. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<DownGiftCardPageResultJson>(null, urlFormat, data, timeOut: timeOut);
  3743. }, accessTokenOrAppId);
  3744. }
  3745. /// <summary>
  3746. /// 【异步方法】申请微信支付礼品卡权限接口
  3747. /// </summary>
  3748. /// <param name="accessTokenOrAppId"></param>
  3749. /// <param name="subId">微信支付子商户号</param>
  3750. /// <param name="timeOut"></param>
  3751. /// <returns></returns>
  3752. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.PayGiftCardAsync", true)]
  3753. public static async Task<PayGiftCardResultJson> PayGiftCardAsync(string accessTokenOrAppId, string subId, int timeOut = Config.TIME_OUT)
  3754. {
  3755. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3756. {
  3757. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/pay/whitelist/add?access_token={0}", accessToken.AsUrlData());
  3758. var data = new
  3759. {
  3760. sub_mch_id = subId
  3761. };
  3762. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<PayGiftCardResultJson>(null, urlFormat, data, timeOut: timeOut);
  3763. }, accessTokenOrAppId);
  3764. }
  3765. /// <summary>
  3766. /// 【异步方法】绑定商户号到礼品卡小程序接口
  3767. /// </summary>
  3768. /// <param name="accessTokenOrAppId"></param>
  3769. /// <param name="subId">微信支付子商户号</param>
  3770. /// <param name="wxaAppId"></param>
  3771. /// <param name="timeOut"></param>
  3772. /// <returns></returns>
  3773. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.BindToGiftCardAsync", true)]
  3774. public static async Task<WxJsonResult> BindToGiftCardAsync(string accessTokenOrAppId, string subId, string wxaAppId, int timeOut = Config.TIME_OUT)
  3775. {
  3776. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3777. {
  3778. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/pay/submch/bind?access_token={0}", accessToken.AsUrlData());
  3779. var data = new
  3780. {
  3781. sub_mch_id = subId,
  3782. wxa_appid = wxaAppId
  3783. };
  3784. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3785. }, accessTokenOrAppId);
  3786. }
  3787. /// <summary>
  3788. /// 【异步方法】上传小程序代码
  3789. /// </summary>
  3790. /// <param name="accessTokenOrAppId"></param>
  3791. /// <param name="pageId"></param>
  3792. /// <param name="wxaAppId"></param>
  3793. /// <param name="timeOut"></param>
  3794. /// <returns></returns>
  3795. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.UploadWxaCodeAsync", true)]
  3796. public static async Task<WxJsonResult> UploadWxaCodeAsync(string accessTokenOrAppId, string pageId, string wxaAppId, int timeOut = Config.TIME_OUT)
  3797. {
  3798. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3799. {
  3800. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/pay/wxa/set?access_token={0}", accessToken.AsUrlData());
  3801. var data = new
  3802. {
  3803. wxa_appid = wxaAppId,
  3804. page_id = pageId
  3805. };
  3806. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3807. }, accessTokenOrAppId);
  3808. }
  3809. /// <summary>
  3810. /// 【异步方法】查询-单个礼品卡订单信息接口
  3811. /// </summary>
  3812. /// <param name="accessTokenOrAppId"></param>
  3813. /// <param name="orderId">礼品卡订单号,商户可以通过购买成功的事件推送或者批量查询订单接口获得</param>
  3814. /// <param name="timeOut"></param>
  3815. /// <returns></returns>
  3816. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetGiftCardOrderInfoAsync", true)]
  3817. public static async Task<GiftCardOrderItemResultJson> GetGiftCardOrderInfoAsync(string accessTokenOrAppId, string orderId, int timeOut = Config.TIME_OUT)
  3818. {
  3819. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3820. {
  3821. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/order/get?access_token={0}", accessToken.AsUrlData());
  3822. var data = new
  3823. {
  3824. order_id = orderId
  3825. };
  3826. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<GiftCardOrderItemResultJson>(null, urlFormat, data, timeOut: timeOut);
  3827. }, accessTokenOrAppId);
  3828. }
  3829. /// <summary>
  3830. /// 【异步方法】查询-批量查询礼品卡订单信息接口
  3831. /// </summary>
  3832. /// <param name="accessTokenOrAppId"></param>
  3833. /// <param name="beginTime">查询的时间起点,十位时间戳(utc+8)</param>
  3834. /// <param name="endTime">查询的时间终点,十位时间戳(utc+8</param>
  3835. /// <param name="sortType">填"ASC" / "DESC",表示对订单创建时间进行“升 / 降”排序</param>
  3836. /// <param name="offSet">查询的订单偏移量,如填写100则表示从第100个订单开始拉取</param>
  3837. /// <param name="count">查询订单的数量,如offset填写100,count填写10,则表示查询第100个到第110个订单</param>
  3838. /// <param name="timeOut"></param>
  3839. /// <returns></returns>
  3840. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetGiftCardOrderListInfoAsync", true)]
  3841. public static async Task<GiftCardOrderListResultJson> GetGiftCardOrderListInfoAsync(string accessTokenOrAppId, string beginTime, string endTime, SortType sortType, int offSet, int count, int timeOut = Config.TIME_OUT)
  3842. {
  3843. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3844. {
  3845. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/order/batchget?access_token={0}", accessToken.AsUrlData());
  3846. var data = new
  3847. {
  3848. begin_time = beginTime,
  3849. end_time = endTime,
  3850. sort_type = sortType,
  3851. offset = offSet,
  3852. count = count
  3853. };
  3854. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<GiftCardOrderListResultJson>(null, urlFormat, data, timeOut: timeOut);
  3855. }, accessTokenOrAppId);
  3856. }
  3857. /// <summary>
  3858. /// 【异步方法】更新用户礼品卡信息接口
  3859. /// </summary>
  3860. /// <param name="accessTokenOrAppId"></param>
  3861. /// <param name="data"></param>
  3862. /// <param name="timeOut"></param>
  3863. /// <returns></returns>
  3864. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.UpdateUserGiftCardAsync", true)]
  3865. public static async Task<UpdateUserGiftCardResultJson> UpdateUserGiftCardAsync(string accessTokenOrAppId, UpdateUserGiftCardData data, int timeOut = Config.TIME_OUT)
  3866. {
  3867. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3868. {
  3869. var urlFormat = string.Format(Config.ApiMpHost + "/card/generalcard/updateuser?access_token={0}", accessToken.AsUrlData());
  3870. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<UpdateUserGiftCardResultJson>(null, urlFormat, data, timeOut: timeOut);
  3871. }, accessTokenOrAppId);
  3872. }
  3873. /// <summary>
  3874. /// 【异步方法】退款接口
  3875. /// </summary>
  3876. /// <param name="accessTokenOrAppId"></param>
  3877. /// <param name="data"></param>
  3878. /// <param name="timeOut"></param>
  3879. /// <returns></returns>
  3880. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.RefundAsync", true)]
  3881. public static async Task<WxJsonResult> RefundAsync(string accessTokenOrAppId, string orderId, int timeOut = Config.TIME_OUT)
  3882. {
  3883. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3884. {
  3885. var urlFormat = string.Format(Config.ApiMpHost + "/card/giftcard/order/refund?access_token={0}", accessToken.AsUrlData());
  3886. var data = new
  3887. {
  3888. order_id = orderId
  3889. };
  3890. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3891. }, accessTokenOrAppId);
  3892. }
  3893. /// <summary>
  3894. /// 【异步方法】设置支付后投放卡券接口
  3895. /// </summary>
  3896. /// <param name="accessTokenOrAppId"></param>
  3897. /// <param name="data"></param>
  3898. /// <param name="timeOut"></param>
  3899. /// <returns></returns>
  3900. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.AddCardAfterPayAsync", true)]
  3901. public static async Task<AddCardAfterPayResultJson> AddCardAfterPayAsync(string accessTokenOrAppId, AddCardAfterPayData data, int timeOut = Config.TIME_OUT)
  3902. {
  3903. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3904. {
  3905. var urlFormat = string.Format(Config.ApiMpHost + "/card/paygiftcard/add?access_token={0}", accessToken.AsUrlData());
  3906. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<AddCardAfterPayResultJson>(null, urlFormat, data, timeOut: timeOut);
  3907. }, accessTokenOrAppId);
  3908. }
  3909. /// <summary>
  3910. /// 【异步方法】删除支付后投放卡券规则接口
  3911. /// </summary>
  3912. /// <param name="accessTokenOrAppId"></param>
  3913. /// <param name="ruleId"></param>
  3914. /// <param name="timeOut"></param>
  3915. /// <returns></returns>
  3916. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.DeleteAfterPayRuleAsync", true)]
  3917. public static async Task<WxJsonResult> DeleteAfterPayRuleAsync(string accessTokenOrAppId, string ruleId, int timeOut = Config.TIME_OUT)
  3918. {
  3919. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3920. {
  3921. var urlFormat = string.Format(Config.ApiMpHost + "/card/paygiftcard/delete?access_token={0}", accessToken.AsUrlData());
  3922. var data = new
  3923. {
  3924. rule_id = ruleId
  3925. };
  3926. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  3927. }, accessTokenOrAppId);
  3928. }
  3929. /// <summary>
  3930. /// 【异步方法】查询支付后投放卡券规则详情接口
  3931. /// </summary>
  3932. /// <param name="accessTokenOrAppId"></param>
  3933. /// <param name="ruleId"></param>
  3934. /// <param name="timeOut"></param>
  3935. /// <returns></returns>
  3936. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.AfterPay_GetByIdAsync", true)]
  3937. public static async Task<AfterPay_GetByIdResultJson> AfterPay_GetByIdAsync(string accessTokenOrAppId, string ruleId, int timeOut = Config.TIME_OUT)
  3938. {
  3939. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3940. {
  3941. var urlFormat = string.Format(Config.ApiMpHost + "/card/paygiftcard/getbyid?access_token={0}", accessToken.AsUrlData());
  3942. var data = new
  3943. {
  3944. rule_id = ruleId
  3945. };
  3946. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<AfterPay_GetByIdResultJson>(null, urlFormat, data, timeOut: timeOut);
  3947. }, accessTokenOrAppId);
  3948. }
  3949. /// <summary>
  3950. /// 【异步方法】批量查询支付后投放卡券规则接口
  3951. /// </summary>
  3952. /// <param name="accessTokenOrAppId"></param>
  3953. /// <param name="data"></param>
  3954. /// <param name="timeOut"></param>
  3955. /// <returns></returns>
  3956. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.AfterPay_BatchGetAsync", true)]
  3957. public static async Task<AfterPay_BatchGetResultJson> AfterPay_BatchGetAsync(string accessTokenOrAppId, AfterPay_BatchGetData data, int timeOut = Config.TIME_OUT)
  3958. {
  3959. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3960. {
  3961. var urlFormat = string.Format(Config.ApiMpHost + "/card/paygiftcard/batchget?access_token={0}", accessToken.AsUrlData());
  3962. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<AfterPay_BatchGetResultJson>(null, urlFormat, data, timeOut: timeOut);
  3963. }, accessTokenOrAppId);
  3964. }
  3965. /// <summary>
  3966. /// 【异步方法】增加支付即会员规则接口
  3967. /// </summary>
  3968. /// <param name="accessTokenOrAppId"></param>
  3969. /// <param name="data"></param>
  3970. /// <param name="timeOut"></param>
  3971. /// <returns></returns>
  3972. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.AddPayMemberRuleAsync", true)]
  3973. public static async Task<AddPayMemberRuleResultJson> AddPayMemberRuleAsync(string accessTokenOrAppId, AddPayMemberRuleData data, int timeOut = Config.TIME_OUT)
  3974. {
  3975. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3976. {
  3977. var urlFormat = string.Format(Config.ApiMpHost + "/card/paygiftmembercard/add?access_token={0}", accessToken.AsUrlData());
  3978. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<AddPayMemberRuleResultJson>(null, urlFormat, data, timeOut: timeOut);
  3979. }, accessTokenOrAppId);
  3980. }
  3981. /// <summary>
  3982. /// 【异步方法】删除支付即会员规则接口
  3983. /// </summary>
  3984. /// <param name="accessTokenOrAppId"></param>
  3985. /// <param name="data"></param>
  3986. /// <param name="timeOut"></param>
  3987. /// <returns></returns>
  3988. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.DeletePayMemberRuleAsync", true)]
  3989. public static async Task<DeletePayMemberRuleResultJson> DeletePayMemberRuleAsync(string accessTokenOrAppId, DeletePayMemberRuleData data, int timeOut = Config.TIME_OUT)
  3990. {
  3991. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  3992. {
  3993. var urlFormat = string.Format(Config.ApiMpHost + "/card/paygiftmembercard/delete?access_token={0}", accessToken.AsUrlData());
  3994. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<DeletePayMemberRuleResultJson>(null, urlFormat, data, timeOut: timeOut);
  3995. }, accessTokenOrAppId);
  3996. }
  3997. /// <summary>
  3998. /// 【异步方法】查询商户号支付即会员规则接口
  3999. /// </summary>
  4000. /// <param name="accessTokenOrAppId"></param>
  4001. /// <param name="mchId"></param>
  4002. /// <param name="timeOut"></param>
  4003. /// <returns></returns>
  4004. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.GetPayMemberRuleAsync", true)]
  4005. public static async Task<GetPayMemberRuleResultJson> GetPayMemberRuleAsync(string accessTokenOrAppId, string mchId, int timeOut = Config.TIME_OUT)
  4006. {
  4007. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  4008. {
  4009. var urlFormat = string.Format(Config.ApiMpHost + "/card/paygiftmembercard/get?access_token={0}", accessToken.AsUrlData());
  4010. var data = new
  4011. {
  4012. mchid = mchId
  4013. };
  4014. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetPayMemberRuleResultJson>(null, urlFormat, data, timeOut: timeOut);
  4015. }, accessTokenOrAppId);
  4016. }
  4017. /// <summary>
  4018. /// 【异步方法】创建支付后领取立减金活动接口
  4019. /// </summary>
  4020. /// <param name="accessTokenOrAppId"></param>
  4021. /// <param name="data"></param>
  4022. /// <param name="timeOut"></param>
  4023. /// <returns></returns>
  4024. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.CreateActivityAsync", true)]
  4025. public static async Task<CreateActivityResultJson> CreateActivityAsync(string accessTokenOrAppId, CreateActivityData data, int timeOut = Config.TIME_OUT)
  4026. {
  4027. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  4028. {
  4029. var urlFormat = string.Format(Config.ApiMpHost + "/card/mkt/activity/create?access_token={0}", accessToken.AsUrlData());
  4030. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<CreateActivityResultJson>(null, urlFormat, data, timeOut: timeOut);
  4031. }, accessTokenOrAppId);
  4032. }
  4033. /// <summary>
  4034. /// 【异步方法】使用授权码换取公众号的授权信息
  4035. /// </summary>
  4036. /// <param name="accessTokenOrAppId"></param>
  4037. /// <param name="componentAppid"></param>
  4038. /// <param name="authorizationCode"></param>
  4039. /// <param name="timeOut"></param>
  4040. /// <returns></returns>
  4041. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.ApiQueryAuthAsync", true)]
  4042. public static async Task<ApiQueryAuthResultJson> ApiQueryAuthAsync(string accessTokenOrAppId, string componentAppid, string authorizationCode, int timeOut = Config.TIME_OUT)
  4043. {
  4044. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  4045. {
  4046. var urlFormat = string.Format(Config.ApiMpHost + "/cgi-bin/component/api_query_auth?component_access_token={0}", accessToken.AsUrlData());
  4047. var data = new
  4048. {
  4049. component_appid = componentAppid,
  4050. authorization_code = authorizationCode
  4051. };
  4052. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<ApiQueryAuthResultJson>(null, urlFormat, data, timeOut: timeOut);
  4053. }, accessTokenOrAppId);
  4054. }
  4055. /// <summary>
  4056. /// 【异步方法】确认授权
  4057. /// </summary>
  4058. /// <param name="accessTokenOrAppId"></param>
  4059. /// <param name="data"></param>
  4060. /// <param name="timeOut"></param>
  4061. /// <returns></returns>
  4062. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.ApiConfirmAuthorizationAsync", true)]
  4063. public static async Task<WxJsonResult> ApiConfirmAuthorizationAsync(string accessTokenOrAppId, ApiConfirmAuthorizationData data, int timeOut = Config.TIME_OUT)
  4064. {
  4065. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  4066. {
  4067. var urlFormat = string.Format(Config.ApiMpHost + "/cgi-bin/component/api_confirm_authorization?component_access_token={0}", accessToken.AsUrlData());
  4068. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  4069. }, accessTokenOrAppId);
  4070. }
  4071. /// <summary>
  4072. /// 【异步方法】获取授权方的账户信息
  4073. /// </summary>
  4074. /// <param name="accessTokenOrAppId"></param>
  4075. /// <param name="componentAppid"></param>
  4076. /// <param name="authorizerAppid"></param>
  4077. /// <param name="timeOut"></param>
  4078. /// <returns></returns>
  4079. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.ApiGetAuthorizerInfoAsync", true)]
  4080. public static async Task<ApiGetAuthorizerInfoResultJson> ApiGetAuthorizerInfoAsync(string accessTokenOrAppId, string componentAppid, string authorizerAppid, int timeOut = Config.TIME_OUT)
  4081. {
  4082. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  4083. {
  4084. var urlFormat = string.Format(Config.ApiMpHost + "/cgi-bin/component/api_get_authorizer_info?component_access_token={0}", accessToken.AsUrlData());
  4085. var data = new
  4086. {
  4087. component_appid = componentAppid,
  4088. authorizer_appid = authorizerAppid
  4089. };
  4090. return await Weixin.CommonAPIs.CommonJsonSend.SendAsync<ApiGetAuthorizerInfoResultJson>(null, urlFormat, data, timeOut: timeOut);
  4091. }, accessTokenOrAppId);
  4092. }
  4093. #endregion
  4094. #region 门店接口已过期
  4095. ///// <summary>
  4096. ///// 批量导入门店信息
  4097. ///// </summary>
  4098. ///// <param name="accessToken"></param>
  4099. ///// <param name="data">门店数据</param>
  4100. ///// <param name="timeOut">代理请求超时时间(毫秒)</param>
  4101. ///// <returns></returns>
  4102. //public static StoreResultJson StoreBatchAdd(string accessToken, StoreLocationData data, int timeOut = Config.TIME_OUT)
  4103. //{
  4104. // var urlFormat = string.Format(Config.ApiMpHost + "/card/location/batchadd?access_token={0}", accessToken.AsUrlData());
  4105. // return CommonJsonSend.Send<StoreResultJson>(null, urlFormat, data, timeOut: timeOut);
  4106. //}
  4107. ///// <summary>
  4108. ///// 拉取门店列表
  4109. ///// </summary>
  4110. ///// <param name="accessToken"></param>
  4111. ///// <param name="offset">偏移量,0 开始</param>
  4112. ///// <param name="count">拉取数量</param>
  4113. ///// <param name="timeOut">代理请求超时时间(毫秒)</param>
  4114. ///// <returns></returns>
  4115. //public static StoreGetResultJson BatchGet(string accessToken, int offset, int count, int timeOut = Config.TIME_OUT)
  4116. //{
  4117. // var urlFormat = string.Format(Config.ApiMpHost + "/card/location/batchget?access_token={0}", accessToken.AsUrlData());
  4118. // var data = new
  4119. // {
  4120. // offset = offset,
  4121. // count = count
  4122. // };
  4123. // return CommonJsonSend.Send<StoreGetResultJson>(null, urlFormat, data, timeOut: timeOut);
  4124. //}
  4125. ///// <summary>
  4126. ///// 上传LOGO
  4127. ///// </summary>
  4128. ///// <param name="accessToken"></param>
  4129. ///// <param name="file">文件路径</param>
  4130. ///// <param name="timeOut"></param>
  4131. ///// <returns></returns>
  4132. //public static Card_UploadLogoResultJson UploadLogo(string accessToken, string file, int timeOut = Config.TIME_OUT)
  4133. //{
  4134. // var url = string.Format(Config.ApiMpHost + "/cgi-bin/media/uploadimg?access_token={0}", accessToken.AsUrlData());
  4135. // var fileDictionary = new Dictionary<string, string>();
  4136. // fileDictionary["media"] = file;
  4137. // return HttpUtility.Post.PostFileGetJson<Card_UploadLogoResultJson>(url, null, fileDictionary, null, timeOut: timeOut);
  4138. //}
  4139. #endregion
  4140. #endif
  4141. }
  4142. }