InvoiceApi.cs 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396
  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. 文件名:InvoiceApi.cs
  17. 文件功能描述:电子发票接口
  18. 创建标识:Senparc - 20180927
  19. 修改标识:Senparc - 20180930
  20. 修改描述:添加设置支付后开票信息接口,查询支付后开票信息接口,设置授权页字段信息接口,查询授权页字段信息接口,查询开票信息,获取授权页链接
  21. 统一开票接口-开具蓝票,统一开票接口-发票冲红,统一开票接口-查询已开发票,设置商户联系方式,查询商户联系方式,获取自身的开票平台识别码
  22. 创建发票卡券模板,上传PDF,查询已上传的PDF文件,将电子发票卡券插入用户卡包,更新发票卡券状态,查询报销发票信息,批量查询报销发票信息
  23. 报销方更新发票状态,报销方批量更新发票状态
  24. 修改标识:Senparc - 20180930
  25. 修改描述:添加非税票据相关接口
  26. 修改标识:Senparc - 20181016
  27. 修改描述:修正批量查询报销发票信息接口返回值
  28. 修改标识:Senparc - 20181018
  29. 修改描述:【异步方法】批量查询报销发票信息接口去掉无意义参数,更新reimburseStatus为枚举值
  30. 修改标识:Senparc - 20181023
  31. 修改描述:修正发票信息实体,区分开票平台提交的发票信息实体与报销方获取的发票信息实体
  32. ----------------------------------------------------------------*/
  33. using Senparc.CO2NET.Extensions;
  34. using Senparc.CO2NET.HttpUtility;
  35. using Senparc.NeuChar;
  36. using Senparc.Weixin.CommonAPIs;
  37. using Senparc.Weixin.Entities;
  38. using Senparc.Weixin.MP.AdvancedAPIs.Media;
  39. using System.Collections.Generic;
  40. using System.Threading.Tasks;
  41. namespace Senparc.Weixin.MP.AdvancedAPIs
  42. {
  43. /// <summary>
  44. /// 电子发票接口
  45. /// </summary>
  46. public static class InvoiceApi
  47. {
  48. #region 同步方法
  49. #region 支付相关
  50. /// <summary>
  51. /// 设置支付后开票信息/关联商户号与开票平台
  52. /// </summary>
  53. /// <param name="accessTokenOrAppId"></param>
  54. /// <param name="payMchInfo"></param>
  55. /// <param name="timeOut"></param>
  56. /// <returns></returns>
  57. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.SetPayMch", true)]
  58. public static WxJsonResult SetPayMch(string accessTokenOrAppId, PayMchInfoData payMchInfo, int timeOut = Config.TIME_OUT)
  59. {
  60. return ApiHandlerWapper.TryCommonApi(accessToken =>
  61. {
  62. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/setbizattr?action=set_pay_mch&access_token={0}", accessToken.AsUrlData());
  63. var data = new
  64. {
  65. paymch_info = payMchInfo
  66. };
  67. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  68. }, accessTokenOrAppId);
  69. }
  70. /// <summary>
  71. /// 查询支付后开票信息接口/查询商户号与开票平台关联情况
  72. /// </summary>
  73. /// <param name="accessTokenOrAppId"></param>
  74. /// <param name="timeOut"></param>
  75. /// <returns></returns>
  76. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetPayMch", true)]
  77. public static GetPayMchResultJson GetPayMch(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  78. {
  79. return ApiHandlerWapper.TryCommonApi(accessToken =>
  80. {
  81. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/setbizattr?action=get_pay_mch&access_token={0}", accessToken.AsUrlData());
  82. var data = new { };
  83. return CommonJsonSend.Send<GetPayMchResultJson>(null, urlFormat, data, timeOut: timeOut);
  84. }, accessTokenOrAppId);
  85. }
  86. #endregion
  87. #region 授权相关
  88. /// <summary>
  89. /// 设置授权页字段信息接口
  90. /// </summary>
  91. /// <param name="accessTokenOrAppId"></param>
  92. /// <param name="authField"></param>
  93. /// <param name="timeOut"></param>
  94. /// <returns></returns>
  95. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.SetAuthField", true)]
  96. public static WxJsonResult SetAuthField(string accessTokenOrAppId, AuthFieldData authField, int timeOut = Config.TIME_OUT)
  97. {
  98. return ApiHandlerWapper.TryCommonApi(accessToken =>
  99. {
  100. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/setbizattr?action=set_auth_field&access_token={0}", accessToken.AsUrlData());
  101. var data = new
  102. {
  103. auth_field = authField
  104. };
  105. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  106. }, accessTokenOrAppId);
  107. }
  108. /// <summary>
  109. /// 查询授权页字段信息接口
  110. /// </summary>
  111. /// <param name="accessTokenOrAppId"></param>
  112. /// <param name="timeOut"></param>
  113. /// <returns></returns>
  114. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetAuthField", true)]
  115. public static AuthFieldResultJson GetAuthField(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  116. {
  117. return ApiHandlerWapper.TryCommonApi(accessToken =>
  118. {
  119. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/setbizattr?action=set_auth_field&access_token={0}", accessToken.AsUrlData());
  120. var data = new { };
  121. return CommonJsonSend.Send<AuthFieldResultJson>(null, urlFormat, data, timeOut: timeOut);
  122. }, accessTokenOrAppId);
  123. }
  124. /// <summary>
  125. /// 查询开票信息/查询授权完成状态
  126. /// </summary>
  127. /// <param name="accessTokenOrAppId"></param>
  128. /// <param name="orderId"></param>
  129. /// <param name="s_appId"></param>
  130. /// <param name="timeOut"></param>
  131. /// <returns></returns>
  132. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetAuthData", true)]
  133. public static AuthDataResultJson GetAuthData(string accessTokenOrAppId, string orderId, string s_appId, int timeOut = Config.TIME_OUT)
  134. {
  135. return ApiHandlerWapper.TryCommonApi(accessToken =>
  136. {
  137. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/getauthdata?access_token={0}", accessToken.AsUrlData());
  138. var data = new
  139. {
  140. order_id = orderId,
  141. s_appid = s_appId
  142. };
  143. return CommonJsonSend.Send<AuthDataResultJson>(null, urlFormat, data, timeOut: timeOut);
  144. }, accessTokenOrAppId);
  145. }
  146. /// <summary>
  147. /// 获取授权页链接
  148. /// </summary>
  149. /// <param name="accessTokenOrAppId"></param>
  150. /// <param name="data"></param>
  151. /// <param name="timeOut"></param>
  152. /// <returns></returns>
  153. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetAuthUrl", true)]
  154. public static AuthUrlResultJson GetAuthUrl(string accessTokenOrAppId, GetAuthUrlData data, int timeOut = Config.TIME_OUT)
  155. {
  156. return ApiHandlerWapper.TryCommonApi(accessToken =>
  157. {
  158. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/getauthurl?access_token={0}", accessToken.AsUrlData());
  159. return CommonJsonSend.Send<AuthUrlResultJson>(null, urlFormat, data, timeOut: timeOut);
  160. }, accessTokenOrAppId);
  161. }
  162. #endregion
  163. #region 统一开票接口
  164. /// <summary>
  165. /// 拒绝开票
  166. /// </summary>
  167. /// <param name="accessTokenOrAppId"></param>
  168. /// <param name="s_pappId"></param>
  169. /// <param name="orderId"></param>
  170. /// <param name="reason"></param>
  171. /// <param name="url"></param>
  172. /// <param name="timeOut"></param>
  173. /// <returns></returns>
  174. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.RejectInsert", true)]
  175. public static WxJsonResult RejectInsert(string accessTokenOrAppId, string s_pappId, string orderId, string reason, string url, int timeOut = Config.TIME_OUT)
  176. {
  177. return ApiHandlerWapper.TryCommonApi(accessToken =>
  178. {
  179. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/rejectinsert?access_token={0}", accessToken.AsUrlData());
  180. var data = new
  181. {
  182. s_pappid = s_pappId,
  183. orderid = orderId,
  184. reason = reason,
  185. url = url
  186. };
  187. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  188. }, accessTokenOrAppId);
  189. }
  190. /// <summary>
  191. /// 开具蓝票
  192. /// </summary>
  193. /// <param name="accessTokenOrAppId"></param>
  194. /// <param name="InvoiceInfo"></param>
  195. /// <param name="timeOut"></param>
  196. /// <returns></returns>
  197. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.MakeOutInvoice", true)]
  198. public static WxJsonResult MakeOutInvoice(string accessTokenOrAppId, MakeOutInvoiceData InvoiceInfo, int timeOut = Config.TIME_OUT)
  199. {
  200. return ApiHandlerWapper.TryCommonApi(accessToken =>
  201. {
  202. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/makeoutinvoice?access_token={0}", accessToken.AsUrlData());
  203. var data = new
  204. {
  205. invoiceinfo = InvoiceInfo
  206. };
  207. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  208. }, accessTokenOrAppId);
  209. }
  210. /// <summary>
  211. /// 发票冲红
  212. /// </summary>
  213. /// <param name="accessTokenOrAppId"></param>
  214. /// <param name="InvoiceInfo"></param>
  215. /// <param name="timeOut"></param>
  216. /// <returns></returns>
  217. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.ClearOutInvoice", true)]
  218. public static WxJsonResult ClearOutInvoice(string accessTokenOrAppId, ClearOutInvoiceData InvoiceInfo, int timeOut = Config.TIME_OUT)
  219. {
  220. return ApiHandlerWapper.TryCommonApi(accessToken =>
  221. {
  222. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/clearoutinvoice?access_token={0}", accessToken.AsUrlData());
  223. var data = new
  224. {
  225. invoiceinfo = InvoiceInfo
  226. };
  227. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  228. }, accessTokenOrAppId);
  229. }
  230. /// <summary>
  231. /// 查询已开发票
  232. /// </summary>
  233. /// <param name="accessTokenOrAppId"></param>
  234. /// <param name="fpqqlsh"></param>
  235. /// <param name="nsrsbh"></param>
  236. /// <param name="timeOut"></param>
  237. /// <returns></returns>
  238. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.QueryInvoice", true)]
  239. public static QueryInvoiceResultJson QueryInvoice(string accessTokenOrAppId, string fpqqlsh, string nsrsbh, int timeOut = Config.TIME_OUT)
  240. {
  241. return ApiHandlerWapper.TryCommonApi(accessToken =>
  242. {
  243. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/queryinvoceinfo?access_token={0}", accessToken.AsUrlData());
  244. var data = new
  245. {
  246. fpqqlsh = fpqqlsh,
  247. nsrsbh = nsrsbh
  248. };
  249. return CommonJsonSend.Send<QueryInvoiceResultJson>(null, urlFormat, data, timeOut: timeOut);
  250. }, accessTokenOrAppId);
  251. }
  252. #endregion
  253. #region 非税票据 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=21530623533CgUdj
  254. /// <summary>
  255. /// 将财政电子票据添加到用户微信卡包
  256. /// </summary>
  257. /// <param name="accessTokenOrAppId"></param>
  258. /// <param name="info"></param>
  259. /// <param name="timeOut"></param>
  260. /// <returns></returns>
  261. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.InsertBill", true)]
  262. public static InsertCardResultJson InsertBill(string accessTokenOrAppId, InsertCardToBagData info, int timeOut = Config.TIME_OUT)
  263. {
  264. return ApiHandlerWapper.TryCommonApi(accessToken =>
  265. {
  266. var urlFormat = string.Format(Config.ApiMpHost + "/nontax/insertbill?access_token={0}", accessToken.AsUrlData());
  267. var data = new
  268. {
  269. info
  270. };
  271. return CommonJsonSend.Send<InsertCardResultJson>(null, urlFormat, data, timeOut: timeOut);
  272. }, accessTokenOrAppId);
  273. }
  274. /// <summary>
  275. /// 创建财政电子票据接口
  276. /// </summary>
  277. /// <param name="accessTokenOrAppId"></param>
  278. /// <param name="invoiceInfo"></param>
  279. /// <param name="timeOut"></param>
  280. /// <returns></returns>
  281. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.CreateBillCard", true)]
  282. public static CreateCardResultJson CreateBillCard(string accessTokenOrAppId, InvoiceInfo invoiceInfo, int timeOut = Config.TIME_OUT)
  283. {
  284. return ApiHandlerWapper.TryCommonApi(accessToken =>
  285. {
  286. var urlFormat = string.Format(Config.ApiMpHost + "nontax/createbillcard?access_token={0}", accessToken.AsUrlData());
  287. var data = new
  288. {
  289. invoice_info = invoiceInfo
  290. };
  291. return CommonJsonSend.Send<CreateCardResultJson>(null, urlFormat, data, timeOut: timeOut);
  292. }, accessTokenOrAppId);
  293. }
  294. /// <summary>
  295. /// 获取授权页链接
  296. /// </summary>
  297. /// <param name="accessTokenOrAppId"></param>
  298. /// <param name="data"></param>
  299. /// <param name="timeOut"></param>
  300. /// <returns></returns>
  301. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetBillAuthUrl", true)]
  302. public static GetBillAuthUrlResultJson GetBillAuthUrl(string accessTokenOrAppId, GetBillAuthUrlData data, int timeOut = Config.TIME_OUT)
  303. {
  304. return ApiHandlerWapper.TryCommonApi(accessToken =>
  305. {
  306. var urlFormat = string.Format(Config.ApiMpHost + "/nontax/getbillauthurl?access_token={0}", accessToken.AsUrlData());
  307. return CommonJsonSend.Send<GetBillAuthUrlResultJson>(null, urlFormat, data, timeOut: timeOut);
  308. }, accessTokenOrAppId);
  309. }
  310. /// <summary>
  311. /// 更新电子票据状态
  312. /// </summary>
  313. /// <param name="accessTokenOrAppId"></param>
  314. /// <param name="cardId"></param>
  315. /// <param name="code"></param>
  316. /// <param name="reimburseStatus"></param>
  317. /// <param name="timeOut"></param>
  318. /// <returns></returns>
  319. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.UpdateStatus", true)]
  320. public static WxJsonResult UpdateStatus(string accessTokenOrAppId, string cardId, string code, Reimburse_Status reimburseStatus, int timeOut = Config.TIME_OUT)
  321. {
  322. return ApiHandlerWapper.TryCommonApi(accessToken =>
  323. {
  324. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/platform/updatestatus?access_token={0}", accessToken.AsUrlData());
  325. var data = new
  326. {
  327. card_id = cardId,
  328. code = code,
  329. reimburse_status = reimburseStatus.ToString()
  330. };
  331. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  332. }, accessTokenOrAppId);
  333. }
  334. #endregion
  335. /// <summary>
  336. /// 设置商户联系方式
  337. /// </summary>
  338. /// <param name="accessTokenOrAppId"></param>
  339. /// <param name="phone"></param>
  340. /// <param name="timeOut"></param>
  341. /// <returns></returns>
  342. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.SetContact", true)]
  343. public static WxJsonResult SetContact(string accessTokenOrAppId, string phone, int timeOut = Config.TIME_OUT)
  344. {
  345. return ApiHandlerWapper.TryCommonApi(accessToken =>
  346. {
  347. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/setbizattr?action=set_contact&access_token={0}", accessToken.AsUrlData());
  348. var data = new
  349. {
  350. contact = new
  351. {
  352. phone = phone,
  353. time_out = timeOut
  354. }
  355. };
  356. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  357. }, accessTokenOrAppId);
  358. }
  359. /// <summary>
  360. /// 查询商户联系方式
  361. /// </summary>
  362. /// <param name="accessTokenOrAppId"></param>
  363. /// <param name="timeOut"></param>
  364. /// <returns></returns>
  365. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetContact", true)]
  366. public static GetContactResultJson GetContact(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  367. {
  368. return ApiHandlerWapper.TryCommonApi(accessToken =>
  369. {
  370. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/setbizattr?action=get_contact&access_token={0}", accessToken.AsUrlData());
  371. var data = new { };
  372. return CommonJsonSend.Send<GetContactResultJson>(null, urlFormat, data, timeOut: timeOut);
  373. }, accessTokenOrAppId);
  374. }
  375. /// <summary>
  376. /// 查询报销发票信息
  377. /// </summary>
  378. /// <param name="accessTokenOrAppId"></param>
  379. /// <param name="cardId"></param>
  380. /// <param name="encryptCode"></param>
  381. /// <param name="timeOut"></param>
  382. /// <returns></returns>
  383. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetInvoiceInfo", true)]
  384. public static GetInvoiceInfoResultJson GetInvoiceInfo(string accessTokenOrAppId, string cardId, string encryptCode, int timeOut = Config.TIME_OUT)
  385. {
  386. return ApiHandlerWapper.TryCommonApi(accessToken =>
  387. {
  388. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/reimburse/getinvoiceinfo?access_token={0}", accessToken.AsUrlData());
  389. var data = new
  390. {
  391. card_id = cardId,
  392. encrypt_code = encryptCode
  393. };
  394. return CommonJsonSend.Send<GetInvoiceInfoResultJson>(null, urlFormat, data, timeOut: timeOut);
  395. }, accessTokenOrAppId);
  396. }
  397. /// <summary>
  398. /// 批量查询报销发票信息
  399. /// </summary>
  400. /// <param name="accessTokenOrAppId"></param>
  401. /// <param name="itemList"></param>
  402. /// <param name="timeOut"></param>
  403. /// <returns></returns>
  404. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetInvoiceListInfo", true)]
  405. public static GetInvoiceListResultJson GetInvoiceListInfo(string accessTokenOrAppId, List<InvoiceItem> itemList, int timeOut = Config.TIME_OUT)
  406. {
  407. return ApiHandlerWapper.TryCommonApi(accessToken =>
  408. {
  409. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/reimburse/getinvoicebatch?access_token={0}", accessToken.AsUrlData());
  410. var data = new
  411. {
  412. item_list = itemList
  413. };
  414. return CommonJsonSend.Send<GetInvoiceListResultJson>(null, urlFormat, data, timeOut: timeOut);
  415. }, accessTokenOrAppId);
  416. }
  417. /// <summary>
  418. /// 报销方更新发票状态
  419. /// </summary>
  420. /// <param name="accessTokenOrAppId"></param>
  421. /// <param name="cardId"></param>
  422. /// <param name="encryptCode"></param>
  423. /// <param name="reimburseStatus"></param>
  424. /// <param name="timeOut"></param>
  425. /// <returns></returns>
  426. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.UpdateInvoiceStatus", true)]
  427. public static WxJsonResult UpdateInvoiceStatus(string accessTokenOrAppId, string cardId, string encryptCode, Reimburse_Status reimburseStatus, int timeOut = Config.TIME_OUT)
  428. {
  429. return ApiHandlerWapper.TryCommonApi(accessToken =>
  430. {
  431. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/reimburse/updateinvoicestatus?access_token={0}", accessToken.AsUrlData());
  432. var data = new
  433. {
  434. card_id = cardId,
  435. encrypt_code = encryptCode,
  436. reimburse_status = reimburseStatus.ToString()
  437. };
  438. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  439. }, accessTokenOrAppId);
  440. }
  441. /// <summary>
  442. /// 报销方批量更新发票状态
  443. /// </summary>
  444. /// <param name="accessTokenOrAppId"></param>
  445. /// <param name="openId"></param>
  446. /// <param name="reimburseStatus"></param>
  447. /// <param name="itemList"></param>
  448. /// <param name="timeOut"></param>
  449. /// <returns></returns>
  450. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.UpdateInvoiceListStatus", true)]
  451. public static WxJsonResult UpdateInvoiceListStatus(string accessTokenOrAppId, string openId, Reimburse_Status reimburseStatus, List<InvoiceItem> itemList, int timeOut = Config.TIME_OUT)
  452. {
  453. return ApiHandlerWapper.TryCommonApi(accessToken =>
  454. {
  455. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/reimburse/updatestatusbatch?access_token={0}", accessToken.AsUrlData());
  456. var data = new
  457. {
  458. openid = openId,
  459. reimburse_status = reimburseStatus.ToString(),
  460. invoice_list = itemList
  461. };
  462. return CommonJsonSend.Send<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  463. }, accessTokenOrAppId);
  464. }
  465. #region 开票平台接口
  466. /// <summary>
  467. /// 获取自身的开票平台识别码/获取财政局s_pappid
  468. /// </summary>
  469. /// <param name="accessTokenOrAppId"></param>
  470. /// <param name="timeOut"></param>
  471. /// <returns></returns>
  472. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.SetUrl", true)]
  473. public static SetUrlResultJson SetUrl(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  474. {
  475. return ApiHandlerWapper.TryCommonApi(accessToken =>
  476. {
  477. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/seturl?access_token={0}", accessToken.AsUrlData());
  478. var data = new { };
  479. return CommonJsonSend.Send<SetUrlResultJson>(null, urlFormat, data, timeOut: timeOut);
  480. }, accessTokenOrAppId);
  481. }
  482. /// <summary>
  483. /// 创建发票卡券模板
  484. /// </summary>
  485. /// <param name="accessTokenOrAppId"></param>
  486. /// <param name="invoiceInfo"></param>
  487. /// <param name="timeOut"></param>
  488. /// <returns></returns>
  489. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.CreateCard", true)]
  490. public static CreateCardResultJson CreateCard(string accessTokenOrAppId, InvoiceInfo invoiceInfo, int timeOut = Config.TIME_OUT)
  491. {
  492. return ApiHandlerWapper.TryCommonApi(accessToken =>
  493. {
  494. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/platform/createcard?access_token={0}", accessToken.AsUrlData());
  495. var data = new
  496. {
  497. invoice_info = invoiceInfo
  498. };
  499. return CommonJsonSend.Send<CreateCardResultJson>(null, urlFormat, data, timeOut: timeOut);
  500. }, accessTokenOrAppId);
  501. }
  502. /// <summary>
  503. /// 上传PDF
  504. /// </summary>
  505. /// <param name="accessTokenOrAppId"></param>
  506. /// <param name="file"></param>
  507. /// <param name="timeOut"></param>
  508. /// <returns></returns>
  509. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.SetPdf", true)]
  510. public static SetPDFResultJson SetPdf(string accessTokenOrAppId, string file, int timeOut = Config.TIME_OUT)
  511. {
  512. return ApiHandlerWapper.TryCommonApi(accessToken =>
  513. {
  514. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/platform/setpdf?access_token={0}", accessToken.AsUrlData());
  515. var fileDictionary = new Dictionary<string, string>();
  516. fileDictionary["pdf"] = file;
  517. return Post.PostFileGetJson<SetPDFResultJson>(urlFormat, null, fileDictionary, null, timeOut: timeOut);
  518. }, accessTokenOrAppId);
  519. }
  520. /// <summary>
  521. /// 查询已上传的PDF文件
  522. /// </summary>
  523. /// <param name="accessTokenOrAppId"></param>
  524. /// <param name="s_mediaId"></param>
  525. /// <param name="timeOut"></param>
  526. /// <returns></returns>
  527. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetPdf", true)]
  528. public static GetPDFResultJson GetPdf(string accessTokenOrAppId, string s_mediaId, int timeOut = Config.TIME_OUT)
  529. {
  530. return ApiHandlerWapper.TryCommonApi(accessToken =>
  531. {
  532. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/platform/getpdf?action=get_url&access_token={0}", accessToken.AsUrlData());
  533. var data = new
  534. {
  535. action = "get_url",
  536. s_media_id = s_mediaId
  537. };
  538. return CommonJsonSend.Send<GetPDFResultJson>(null, urlFormat, data, timeOut: timeOut);
  539. }, accessTokenOrAppId);
  540. }
  541. /// <summary>
  542. /// 将电子发票卡券插入用户卡包
  543. /// </summary>
  544. /// <param name="accessTokenOrAppId"></param>
  545. /// <param name="info"></param>
  546. /// <param name="timeOut"></param>
  547. /// <returns></returns>
  548. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.InsertCardToBag", true)]
  549. public static InsertCardResultJson InsertCardToBag(string accessTokenOrAppId, InsertCardToBagData info, int timeOut = Config.TIME_OUT)
  550. {
  551. return ApiHandlerWapper.TryCommonApi(accessToken =>
  552. {
  553. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/insert?access_token={0}", accessToken.AsUrlData());
  554. var data = new
  555. {
  556. info
  557. };
  558. return CommonJsonSend.Send<InsertCardResultJson>(null, urlFormat, data, timeOut: timeOut);
  559. }, accessTokenOrAppId);
  560. }
  561. #endregion
  562. #region 微信极速开发票
  563. /// <summary>
  564. /// 将发票抬头信息录入到用户微信中
  565. /// </summary>
  566. /// <param name="accessTokenOrAppId"></param>
  567. /// <param name="data"></param>
  568. /// <param name="timeOut"></param>
  569. /// <returns></returns>
  570. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetUserTitleUrl", true)]
  571. public static GetUserTitleUrlResultJson GetUserTitleUrl(string accessTokenOrAppId, GetUserTitleUrlData data, int timeOut = Config.TIME_OUT)
  572. {
  573. return ApiHandlerWapper.TryCommonApi(accessToken =>
  574. {
  575. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/biz/getusertitleurl?access_token={0}", accessToken.AsUrlData());
  576. return CommonJsonSend.Send<GetUserTitleUrlResultJson>(null, urlFormat, data, timeOut: timeOut);
  577. }, accessTokenOrAppId);
  578. }
  579. /// <summary>
  580. /// 获取用户抬头(方式一):获取商户专属二维码,立在收银台
  581. /// </summary>
  582. /// <param name="accessTokenOrAppId"></param>
  583. /// <param name="attach"></param>
  584. /// <param name="bizName"></param>
  585. /// <param name="timeOut"></param>
  586. /// <returns></returns>
  587. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetSelectTitleUrl", true)]
  588. public static GetUserTitleUrlResultJson GetSelectTitleUrl(string accessTokenOrAppId, string attach, string bizName, int timeOut = Config.TIME_OUT)
  589. {
  590. return ApiHandlerWapper.TryCommonApi(accessToken =>
  591. {
  592. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/biz/getselecttitleurl?access_token={0}", accessToken.AsUrlData());
  593. var data = new
  594. {
  595. attach = attach,
  596. biz_name = bizName
  597. };
  598. return CommonJsonSend.Send<GetUserTitleUrlResultJson>(null, urlFormat, data, timeOut: timeOut);
  599. }, accessTokenOrAppId);
  600. }
  601. /// <summary>
  602. /// 获取用户抬头(方式二):商户扫描用户的发票抬头二维码
  603. /// </summary>
  604. /// <param name="accessTokenOrAppId"></param>
  605. /// <param name="scanText"></param>
  606. /// <param name="timeOut"></param>
  607. /// <returns></returns>
  608. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.ScanTitle", true)]
  609. public static ScanTitleResultJson ScanTitle(string accessTokenOrAppId, string scanText, int timeOut = Config.TIME_OUT)
  610. {
  611. return ApiHandlerWapper.TryCommonApi(accessToken =>
  612. {
  613. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/scantitle?access_token={0}", accessToken.AsUrlData());
  614. var data = new
  615. {
  616. scan_text = scanText
  617. };
  618. return CommonJsonSend.Send<ScanTitleResultJson>(null, urlFormat, data, timeOut: timeOut);
  619. }, accessTokenOrAppId);
  620. }
  621. #endregion
  622. #endregion
  623. #if !NET35 && !NET40
  624. #region 异步方法
  625. #region 支付相关
  626. /// <summary>
  627. /// 【异步方法】设置支付后开票信息
  628. /// </summary>
  629. /// <param name="accessTokenOrAppId"></param>
  630. /// <param name="payMchInfo"></param>
  631. /// <param name="timeOut"></param>
  632. /// <returns></returns>
  633. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.SetPayMchAsync", true)]
  634. public static async Task<WxJsonResult> SetPayMchAsync(string accessTokenOrAppId, PayMchInfoData payMchInfo, int timeOut = Config.TIME_OUT)
  635. {
  636. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  637. {
  638. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/setbizattr?action=set_pay_mch&access_token={0}", accessToken.AsUrlData());
  639. var data = new
  640. {
  641. paymch_info = payMchInfo
  642. };
  643. return await CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  644. }, accessTokenOrAppId);
  645. }
  646. /// <summary>
  647. /// 【异步方法】查询支付后开票信息接口
  648. /// </summary>
  649. /// <param name="accessTokenOrAppId"></param>
  650. /// <param name="timeOut"></param>
  651. /// <returns></returns>
  652. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetPayMchAsync", true)]
  653. public static async Task<GetPayMchResultJson> GetPayMchAsync(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  654. {
  655. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  656. {
  657. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/setbizattr?action=get_pay_mch&access_token={0}", accessToken.AsUrlData());
  658. var data = new { };
  659. return await CommonJsonSend.SendAsync<GetPayMchResultJson>(null, urlFormat, data, timeOut: timeOut);
  660. }, accessTokenOrAppId);
  661. }
  662. #endregion
  663. #region 授权相关
  664. /// <summary>
  665. /// 【异步方法】设置授权页字段信息接口
  666. /// </summary>
  667. /// <param name="accessTokenOrAppId"></param>
  668. /// <param name="authField"></param>
  669. /// <param name="timeOut"></param>
  670. /// <returns></returns>
  671. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.SetAuthFieldAsync", true)]
  672. public static async Task<WxJsonResult> SetAuthFieldAsync(string accessTokenOrAppId, AuthFieldData authField, int timeOut = Config.TIME_OUT)
  673. {
  674. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  675. {
  676. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/setbizattr?action=set_auth_field&access_token={0}", accessToken.AsUrlData());
  677. var data = new
  678. {
  679. auth_field = authField
  680. };
  681. return await CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  682. }, accessTokenOrAppId);
  683. }
  684. /// <summary>
  685. /// 【异步方法】查询授权页字段信息接口
  686. /// </summary>
  687. /// <param name="accessTokenOrAppId"></param>
  688. /// <param name="timeOut"></param>
  689. /// <returns></returns>
  690. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetAuthFieldAsync", true)]
  691. public static async Task<AuthFieldResultJson> GetAuthFieldAsync(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  692. {
  693. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  694. {
  695. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/setbizattr?action=set_auth_field&access_token={0}", accessToken.AsUrlData());
  696. var data = new { };
  697. return await CommonJsonSend.SendAsync<AuthFieldResultJson>(null, urlFormat, data, timeOut: timeOut);
  698. }, accessTokenOrAppId);
  699. }
  700. /// <summary>
  701. /// 【异步方法】查询开票信息/查询授权完成状态
  702. /// </summary>
  703. /// <param name="accessTokenOrAppId"></param>
  704. /// <param name="orderId"></param>
  705. /// <param name="s_appId"></param>
  706. /// <param name="timeOut"></param>
  707. /// <returns></returns>
  708. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetAuthDataAsync", true)]
  709. public static async Task<AuthDataResultJson> GetAuthDataAsync(string accessTokenOrAppId, string orderId, string s_appId, int timeOut = Config.TIME_OUT)
  710. {
  711. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  712. {
  713. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/getauthdata?access_token={0}", accessToken.AsUrlData());
  714. var data = new
  715. {
  716. order_id = orderId,
  717. s_appid = s_appId
  718. };
  719. return await CommonJsonSend.SendAsync<AuthDataResultJson>(null, urlFormat, data, timeOut: timeOut);
  720. }, accessTokenOrAppId);
  721. }
  722. /// <summary>
  723. /// 【异步方法】获取授权页链接
  724. /// </summary>
  725. /// <param name="accessTokenOrAppId"></param>
  726. /// <param name="data"></param>
  727. /// <param name="timeOut"></param>
  728. /// <returns></returns>
  729. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetAuthUrlAsync", true)]
  730. public static async Task<AuthUrlResultJson> GetAuthUrlAsync(string accessTokenOrAppId, GetAuthUrlData data, int timeOut = Config.TIME_OUT)
  731. {
  732. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  733. {
  734. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/getauthurl?access_token={0}", accessToken.AsUrlData());
  735. return await CommonJsonSend.SendAsync<AuthUrlResultJson>(null, urlFormat, data, timeOut: timeOut);
  736. }, accessTokenOrAppId);
  737. }
  738. #endregion
  739. #region 统一开票接口
  740. /// <summary>
  741. /// 【异步方法】拒绝开票
  742. /// </summary>
  743. /// <param name="accessTokenOrAppId"></param>
  744. /// <param name="s_pappId"></param>
  745. /// <param name="orderId"></param>
  746. /// <param name="reason"></param>
  747. /// <param name="url"></param>
  748. /// <param name="timeOut"></param>
  749. /// <returns></returns>
  750. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.RejectInsertAsync", true)]
  751. public static async Task<WxJsonResult> RejectInsertAsync(string accessTokenOrAppId, string s_pappId, string orderId, string reason, string url, int timeOut = Config.TIME_OUT)
  752. {
  753. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  754. {
  755. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/rejectinsert?access_token={0}", accessToken.AsUrlData());
  756. var data = new
  757. {
  758. s_pappid = s_pappId,
  759. orderid = orderId,
  760. reason = reason,
  761. url = url
  762. };
  763. return await CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  764. }, accessTokenOrAppId);
  765. }
  766. /// <summary>
  767. /// 【异步方法】开具蓝票
  768. /// </summary>
  769. /// <param name="accessTokenOrAppId"></param>
  770. /// <param name="InvoiceInfo"></param>
  771. /// <param name="timeOut"></param>
  772. /// <returns></returns>
  773. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.MakeOutInvoiceAsync", true)]
  774. public static async Task<WxJsonResult> MakeOutInvoiceAsync(string accessTokenOrAppId, MakeOutInvoiceData InvoiceInfo, int timeOut = Config.TIME_OUT)
  775. {
  776. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  777. {
  778. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/makeoutinvoice?access_token={0}", accessToken.AsUrlData());
  779. var data = new
  780. {
  781. invoiceinfo = InvoiceInfo
  782. };
  783. return await CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  784. }, accessTokenOrAppId);
  785. }
  786. /// <summary>
  787. /// 【异步方法】发票冲红
  788. /// </summary>
  789. /// <param name="accessTokenOrAppId"></param>
  790. /// <param name="InvoiceInfo"></param>
  791. /// <param name="timeOut"></param>
  792. /// <returns></returns>
  793. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.ClearOutInvoiceAsync", true)]
  794. public static async Task<WxJsonResult> ClearOutInvoiceAsync(string accessTokenOrAppId, ClearOutInvoiceData InvoiceInfo, int timeOut = Config.TIME_OUT)
  795. {
  796. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  797. {
  798. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/clearoutinvoice?access_token={0}", accessToken.AsUrlData());
  799. var data = new
  800. {
  801. invoiceinfo = InvoiceInfo
  802. };
  803. return await CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  804. }, accessTokenOrAppId);
  805. }
  806. /// <summary>
  807. /// 【异步方法】查询已开发票
  808. /// </summary>
  809. /// <param name="accessTokenOrAppId"></param>
  810. /// <param name="fpqqlsh"></param>
  811. /// <param name="nsrsbh"></param>
  812. /// <param name="timeOut"></param>
  813. /// <returns></returns>
  814. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.QueryInvoiceAsync", true)]
  815. public static async Task<QueryInvoiceResultJson> QueryInvoiceAsync(string accessTokenOrAppId, string fpqqlsh, string nsrsbh, int timeOut = Config.TIME_OUT)
  816. {
  817. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  818. {
  819. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/queryinvoceinfo?access_token={0}", accessToken.AsUrlData());
  820. var data = new
  821. {
  822. fpqqlsh = fpqqlsh,
  823. nsrsbh = nsrsbh
  824. };
  825. return await CommonJsonSend.SendAsync<QueryInvoiceResultJson>(null, urlFormat, data, timeOut: timeOut);
  826. }, accessTokenOrAppId);
  827. }
  828. #endregion
  829. #region 非税票据 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=21530623533CgUdj
  830. /// <summary>
  831. /// 【异步方法】将财政电子票据添加到用户微信卡包
  832. /// </summary>
  833. /// <param name="accessTokenOrAppId"></param>
  834. /// <param name="info"></param>
  835. /// <param name="timeOut"></param>
  836. /// <returns></returns>
  837. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.InsertBillAsync", true)]
  838. public static async Task<InsertCardResultJson> InsertBillAsync(string accessTokenOrAppId, InsertCardToBagData info, int timeOut = Config.TIME_OUT)
  839. {
  840. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  841. {
  842. var urlFormat = string.Format(Config.ApiMpHost + "/nontax/insertbill?access_token={0}", accessToken.AsUrlData());
  843. var data = new
  844. {
  845. info
  846. };
  847. return await CommonJsonSend.SendAsync<InsertCardResultJson>(null, urlFormat, data, timeOut: timeOut);
  848. }, accessTokenOrAppId);
  849. }
  850. /// <summary>
  851. /// 【异步方法】创建财政电子票据接口
  852. /// </summary>
  853. /// <param name="accessTokenOrAppId"></param>
  854. /// <param name="invoiceInfo"></param>
  855. /// <param name="timeOut"></param>
  856. /// <returns></returns>
  857. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.CreateBillCardAsync", true)]
  858. public static async Task<CreateCardResultJson> CreateBillCardAsync(string accessTokenOrAppId, InvoiceInfo invoiceInfo, int timeOut = Config.TIME_OUT)
  859. {
  860. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  861. {
  862. var urlFormat = string.Format(Config.ApiMpHost + "/nontax/createbillcard?access_token={0}", accessToken.AsUrlData());
  863. var data = new
  864. {
  865. invoice_info = invoiceInfo
  866. };
  867. return await CommonJsonSend.SendAsync<CreateCardResultJson>(null, urlFormat, data, timeOut: timeOut);
  868. }, accessTokenOrAppId);
  869. }
  870. /// <summary>
  871. /// 【异步方法】获取授权页链接
  872. /// </summary>
  873. /// <param name="accessTokenOrAppId"></param>
  874. /// <param name="data"></param>
  875. /// <param name="timeOut"></param>
  876. /// <returns></returns>
  877. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetBillAuthUrlAsync", true)]
  878. public static async Task<GetBillAuthUrlResultJson> GetBillAuthUrlAsync(string accessTokenOrAppId, GetBillAuthUrlData data, int timeOut = Config.TIME_OUT)
  879. {
  880. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  881. {
  882. var urlFormat = string.Format(Config.ApiMpHost + "/nontax/getbillauthurl?access_token={0}", accessToken.AsUrlData());
  883. return await CommonJsonSend.SendAsync<GetBillAuthUrlResultJson>(null, urlFormat, data, timeOut: timeOut);
  884. }, accessTokenOrAppId);
  885. }
  886. /// <summary>
  887. /// 【异步方法】更新电子票据状态
  888. /// </summary>
  889. /// <param name="accessTokenOrAppId"></param>
  890. /// <param name="cardId"></param>
  891. /// <param name="code"></param>
  892. /// <param name="reimburseStatus"></param>
  893. /// <param name="timeOut"></param>
  894. /// <returns></returns>
  895. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "CardApi.UpdateStatusAsync", true)]
  896. public static async Task<WxJsonResult> UpdateStatusAsync(string accessTokenOrAppId, string cardId, string code, Reimburse_Status reimburseStatus, int timeOut = Config.TIME_OUT)
  897. {
  898. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  899. {
  900. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/platform/updatestatus?access_token={0}", accessToken.AsUrlData());
  901. var data = new
  902. {
  903. card_id = cardId,
  904. code = code,
  905. reimburse_status = reimburseStatus.ToString()
  906. };
  907. return await CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  908. }, accessTokenOrAppId);
  909. }
  910. #endregion
  911. /// <summary>
  912. /// 【异步方法】设置商户联系方式
  913. /// </summary>
  914. /// <param name="accessTokenOrAppId"></param>
  915. /// <param name="phone"></param>
  916. /// <param name="timeOut"></param>
  917. /// <returns></returns>
  918. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.SetContactAsync", true)]
  919. public static async Task<WxJsonResult> SetContactAsync(string accessTokenOrAppId, string phone, int timeOut = Config.TIME_OUT)
  920. {
  921. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  922. {
  923. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/setbizattr?action=set_contact&access_token={0}", accessToken.AsUrlData());
  924. var data = new
  925. {
  926. contact = new
  927. {
  928. phone = phone,
  929. time_out = timeOut
  930. }
  931. };
  932. return await CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  933. }, accessTokenOrAppId);
  934. }
  935. /// <summary>
  936. /// 【异步方法】查询商户联系方式
  937. /// </summary>
  938. /// <param name="accessTokenOrAppId"></param>
  939. /// <param name="timeOut"></param>
  940. /// <returns></returns>
  941. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetContactAsync", true)]
  942. public static async Task<GetContactResultJson> GetContactAsync(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  943. {
  944. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  945. {
  946. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/setbizattr?action=get_contact&access_token={0}", accessToken.AsUrlData());
  947. var data = new { };
  948. return await CommonJsonSend.SendAsync<GetContactResultJson>(null, urlFormat, data, timeOut: timeOut);
  949. }, accessTokenOrAppId);
  950. }
  951. /// <summary>
  952. /// 【异步方法】查询报销发票信息
  953. /// </summary>
  954. /// <param name="accessTokenOrAppId"></param>
  955. /// <param name="cardId"></param>
  956. /// <param name="encryptCode"></param>
  957. /// <param name="timeOut"></param>
  958. /// <returns></returns>
  959. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetInvoiceInfoAsync", true)]
  960. public static async Task<GetInvoiceInfoResultJson> GetInvoiceInfoAsync(string accessTokenOrAppId, string cardId, string encryptCode, int timeOut = Config.TIME_OUT)
  961. {
  962. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  963. {
  964. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/reimburse/getinvoiceinfo?access_token={0}", accessToken.AsUrlData());
  965. var data = new
  966. {
  967. card_id = cardId,
  968. encrypt_code = encryptCode
  969. };
  970. return await CommonJsonSend.SendAsync<GetInvoiceInfoResultJson>(null, urlFormat, data, timeOut: timeOut);
  971. }, accessTokenOrAppId);
  972. }
  973. /// <summary>
  974. /// 【异步方法】批量查询报销发票信息
  975. /// </summary>
  976. /// <param name="accessTokenOrAppId"></param>
  977. /// <param name="itemList"></param>
  978. /// <param name="timeOut"></param>
  979. /// <returns></returns>
  980. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetInvoiceListInfoAsync", true)]
  981. public static async Task<GetInvoiceListResultJson> GetInvoiceListInfoAsync(string accessTokenOrAppId, List<InvoiceItem> itemList, int timeOut = Config.TIME_OUT)
  982. {
  983. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  984. {
  985. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/reimburse/getinvoicebatch?access_token={0}", accessToken.AsUrlData());
  986. var data = new
  987. {
  988. item_list = itemList
  989. };
  990. return await CommonJsonSend.SendAsync<GetInvoiceListResultJson>(null, urlFormat, data, timeOut: timeOut);
  991. }, accessTokenOrAppId);
  992. }
  993. /// <summary>
  994. /// 【异步方法】报销方更新发票状态
  995. /// </summary>
  996. /// <param name="accessTokenOrAppId"></param>
  997. /// <param name="cardId"></param>
  998. /// <param name="encryptCode"></param>
  999. /// <param name="reimburseStatus"></param>
  1000. /// <param name="timeOut"></param>
  1001. /// <returns></returns>
  1002. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.UpdateInvoiceStatusAsync", true)]
  1003. public static async Task<WxJsonResult> UpdateInvoiceStatusAsync(string accessTokenOrAppId, string cardId, string encryptCode, Reimburse_Status reimburseStatus, int timeOut = Config.TIME_OUT)
  1004. {
  1005. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1006. {
  1007. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/reimburse/updateinvoicestatus?access_token={0}", accessToken.AsUrlData());
  1008. var data = new
  1009. {
  1010. card_id = cardId,
  1011. encrypt_code = encryptCode,
  1012. reimburse_status = reimburseStatus.ToString()
  1013. };
  1014. return await CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1015. }, accessTokenOrAppId);
  1016. }
  1017. /// <summary>
  1018. /// 【异步方法】报销方批量更新发票状态
  1019. /// </summary>
  1020. /// <param name="accessTokenOrAppId"></param>
  1021. /// <param name="openId"></param>
  1022. /// <param name="reimburseStatus"></param>
  1023. /// <param name="itemList"></param>
  1024. /// <param name="timeOut"></param>
  1025. /// <returns></returns>
  1026. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.UpdateInvoiceListStatusAsync", true)]
  1027. public static async Task<WxJsonResult> UpdateInvoiceListStatusAsync(string accessTokenOrAppId, string openId, Reimburse_Status reimburseStatus, List<InvoiceItem> itemList, int timeOut = Config.TIME_OUT)
  1028. {
  1029. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1030. {
  1031. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/reimburse/updatestatusbatch?access_token={0}", accessToken.AsUrlData());
  1032. var data = new
  1033. {
  1034. openid = openId,
  1035. reimburse_status = reimburseStatus.ToString(),
  1036. invoice_list = itemList
  1037. };
  1038. return await CommonJsonSend.SendAsync<WxJsonResult>(null, urlFormat, data, timeOut: timeOut);
  1039. }, accessTokenOrAppId);
  1040. }
  1041. #region 开票平台接口
  1042. /// <summary>
  1043. /// 【异步方法】获取自身的开票平台识别码
  1044. /// </summary>
  1045. /// <param name="accessTokenOrAppId"></param>
  1046. /// <param name="timeOut"></param>
  1047. /// <returns></returns>
  1048. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.SetUrlAsync", true)]
  1049. public static async Task<SetUrlResultJson> SetUrlAsync(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
  1050. {
  1051. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1052. {
  1053. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/seturl?access_token={0}", accessToken.AsUrlData());
  1054. var data = new { };
  1055. return await CommonJsonSend.SendAsync<SetUrlResultJson>(null, urlFormat, data, timeOut: timeOut);
  1056. }, accessTokenOrAppId);
  1057. }
  1058. /// <summary>
  1059. /// 【异步方法】创建发票卡券模板
  1060. /// </summary>
  1061. /// <param name="accessTokenOrAppId"></param>
  1062. /// <param name="invoiceInfo"></param>
  1063. /// <param name="timeOut"></param>
  1064. /// <returns></returns>
  1065. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.CreateCardAsync", true)]
  1066. public static async Task<CreateCardResultJson> CreateCardAsync(string accessTokenOrAppId, InvoiceInfo invoiceInfo, int timeOut = Config.TIME_OUT)
  1067. {
  1068. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1069. {
  1070. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/platform/createcard?access_token={0}", accessToken.AsUrlData());
  1071. var data = new
  1072. {
  1073. invoice_info = invoiceInfo
  1074. };
  1075. return await CommonJsonSend.SendAsync<CreateCardResultJson>(null, urlFormat, data, timeOut: timeOut);
  1076. }, accessTokenOrAppId);
  1077. }
  1078. /// <summary>
  1079. /// 【异步方法】上传PDF
  1080. /// </summary>
  1081. /// <param name="accessTokenOrAppId"></param>
  1082. /// <param name="file"></param>
  1083. /// <param name="timeOut"></param>
  1084. /// <returns></returns>
  1085. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.SetPdfAsync", true)]
  1086. public static async Task<SetPDFResultJson> SetPdfAsync(string accessTokenOrAppId, string file, int timeOut = Config.TIME_OUT)
  1087. {
  1088. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1089. {
  1090. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/platform/setpdf?access_token={0}", accessToken.AsUrlData());
  1091. var fileDictionary = new Dictionary<string, string>();
  1092. fileDictionary["pdf"] = file;
  1093. return await Post.PostFileGetJsonAsync<SetPDFResultJson>(urlFormat, null, fileDictionary, null, timeOut: timeOut);
  1094. }, accessTokenOrAppId);
  1095. }
  1096. /// <summary>
  1097. /// 【异步方法】查询已上传的PDF文件
  1098. /// </summary>
  1099. /// <param name="accessTokenOrAppId"></param>
  1100. /// <param name="s_mediaId"></param>
  1101. /// <param name="timeOut"></param>
  1102. /// <returns></returns>
  1103. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetPdfAsync", true)]
  1104. public static async Task<GetPDFResultJson> GetPdfAsync(string accessTokenOrAppId, string s_mediaId, int timeOut = Config.TIME_OUT)
  1105. {
  1106. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1107. {
  1108. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/platform/getpdf?action=get_url&access_token={0}", accessToken.AsUrlData());
  1109. var data = new
  1110. {
  1111. action = "get_url",
  1112. s_media_id = s_mediaId
  1113. };
  1114. return await CommonJsonSend.SendAsync<GetPDFResultJson>(null, urlFormat, data, timeOut: timeOut);
  1115. }, accessTokenOrAppId);
  1116. }
  1117. /// <summary>
  1118. /// 【异步方法】将电子发票卡券插入用户卡包
  1119. /// </summary>
  1120. /// <param name="accessTokenOrAppId"></param>
  1121. /// <param name="info"></param>
  1122. /// <param name="timeOut"></param>
  1123. /// <returns></returns>
  1124. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.InsertCardToBagAsync", true)]
  1125. public static async Task<InsertCardResultJson> InsertCardToBagAsync(string accessTokenOrAppId, InsertCardToBagData info, int timeOut = Config.TIME_OUT)
  1126. {
  1127. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1128. {
  1129. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/insert?access_token={0}", accessToken.AsUrlData());
  1130. var data = new
  1131. {
  1132. info
  1133. };
  1134. return await CommonJsonSend.SendAsync<InsertCardResultJson>(null, urlFormat, data, timeOut: timeOut);
  1135. }, accessTokenOrAppId);
  1136. }
  1137. #endregion
  1138. #region 微信极速开发票
  1139. /// <summary>
  1140. /// 【异步方法】将发票抬头信息录入到用户微信中
  1141. /// </summary>
  1142. /// <param name="accessTokenOrAppId"></param>
  1143. /// <param name="data"></param>
  1144. /// <param name="timeOut"></param>
  1145. /// <returns></returns>
  1146. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetUserTitleUrlAsync", true)]
  1147. public static async Task<GetUserTitleUrlResultJson> GetUserTitleUrlAsync(string accessTokenOrAppId, GetUserTitleUrlData data, int timeOut = Config.TIME_OUT)
  1148. {
  1149. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1150. {
  1151. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/biz/getusertitleurl?access_token={0}", accessToken.AsUrlData());
  1152. return await CommonJsonSend.SendAsync<GetUserTitleUrlResultJson>(null, urlFormat, data, timeOut: timeOut);
  1153. }, accessTokenOrAppId);
  1154. }
  1155. /// <summary>
  1156. /// 【异步方法】获取用户抬头(方式一):获取商户专属二维码,立在收银台
  1157. /// </summary>
  1158. /// <param name="accessTokenOrAppId"></param>
  1159. /// <param name="attach"></param>
  1160. /// <param name="bizName"></param>
  1161. /// <param name="timeOut"></param>
  1162. /// <returns></returns>
  1163. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.GetSelectTitleUrlAsync", true)]
  1164. public static async Task<GetUserTitleUrlResultJson> GetSelectTitleUrlAsync(string accessTokenOrAppId, string attach, string bizName, int timeOut = Config.TIME_OUT)
  1165. {
  1166. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1167. {
  1168. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/biz/getselecttitleurl?access_token={0}", accessToken.AsUrlData());
  1169. var data = new
  1170. {
  1171. attach = attach,
  1172. biz_name = bizName
  1173. };
  1174. return await CommonJsonSend.SendAsync<GetUserTitleUrlResultJson>(null, urlFormat, data, timeOut: timeOut);
  1175. }, accessTokenOrAppId);
  1176. }
  1177. /// <summary>
  1178. /// 【异步方法】获取用户抬头(方式二):商户扫描用户的发票抬头二维码
  1179. /// </summary>
  1180. /// <param name="accessTokenOrAppId"></param>
  1181. /// <param name="scanText"></param>
  1182. /// <param name="timeOut"></param>
  1183. /// <returns></returns>
  1184. [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "InvoiceApi.ScanTitleAsync", true)]
  1185. public static async Task<ScanTitleResultJson> ScanTitleAsync(string accessTokenOrAppId, string scanText, int timeOut = Config.TIME_OUT)
  1186. {
  1187. return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
  1188. {
  1189. var urlFormat = string.Format(Config.ApiMpHost + "/card/invoice/scantitle?access_token={0}", accessToken.AsUrlData());
  1190. var data = new
  1191. {
  1192. scan_text = scanText
  1193. };
  1194. return await CommonJsonSend.SendAsync<ScanTitleResultJson>(null, urlFormat, data, timeOut: timeOut);
  1195. }, accessTokenOrAppId);
  1196. }
  1197. #endregion
  1198. #endregion
  1199. #endif
  1200. }
  1201. }