55using Baidu . Aip . Ocr ;
66using Microsoft . Extensions . Options ;
77using Newtonsoft . Json . Linq ;
8+ using System . Collections . Generic ;
89
910namespace BootstrapBlazor . Components ;
1011
@@ -71,11 +72,11 @@ public Task<BaiduOcrResult<InvoiceEntity>> CheckVatInvoiceAsync(byte[] image, Ca
7172 protected async Task < string > GetAccessToken ( )
7273 {
7374 var client = HttpClientFactory . CreateClient ( ) ;
74- var para = new Dictionary < string , string > ( )
75+ var para = new List < KeyValuePair < string ? , string ? > > ( )
7576 {
76- { "grant_type" , "client_credentials" } ,
77- { "client_id" , Options . CurrentValue . ApiKey } ,
78- { "client_secret" , Options . CurrentValue . Secret }
77+ new ( "grant_type" , "client_credentials" ) ,
78+ new ( "client_id" , Options . CurrentValue . ApiKey ) ,
79+ new ( "client_secret" , Options . CurrentValue . Secret )
7980 } ;
8081
8182 var resp = await client . PostAsync ( "https://aip.baidubce.com/oauth/2.0/token" , new FormUrlEncodedContent ( para ) ) ;
@@ -102,21 +103,21 @@ public Task<BaiduOcrResult<InvoiceVerifyResult>> VerifyInvoiceAsync(string invoi
102103 var client = HttpClientFactory . CreateClient ( ) ;
103104
104105 // 拼装参数
105- var para = new Dictionary < string , string > ( )
106+ var para = new List < KeyValuePair < string ? , string ? > > ( )
106107 {
107- { "invoice_code" , invoiceCode } ,
108- { "invoice_num" , invoiceNum } ,
109- { "invoice_date" , invoiceDate } ,
110- { "invoice_type" , invoiceType } ,
108+ new ( "invoice_code" , invoiceCode ) ,
109+ new ( "invoice_num" , invoiceNum ) ,
110+ new ( "invoice_date" , invoiceDate ) ,
111+ new ( "invoice_type" , invoiceType ) ,
111112 } ;
112113
113114 if ( ! string . IsNullOrEmpty ( checkCode ) )
114115 {
115- para [ "check_code" ] = checkCode ;
116+ para . Add ( new ( "check_code" , checkCode ) ) ;
116117 }
117118 if ( ! string . IsNullOrEmpty ( totalAmount ) )
118119 {
119- para [ "total_amount" ] = totalAmount ;
120+ para . Add ( new ( "total_amount" , totalAmount ) ) ;
120121 }
121122
122123 // 提交数据
0 commit comments