Browse Source

已收账单 文件下载 币种相关更改

leiy 9 months ago
parent
commit
328513ec61

+ 3 - 1
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -937,7 +937,9 @@ namespace OASystem.API.Controllers
                         string items = "";
                         foreach (var fr in _ForeignReceivables)
                         {
-                            items += fr.PriceName + "   " + fr.Currency + " " + fr.Price.ToString("#0.00") + " * " + fr.Count + " " + fr.Unit + " * " + fr.Rate + ".................. RMB " + fr.ItemSumPrice.ToString("#0.00") + "\n";
+                            var currInfo = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == fr.Currency).First();
+
+                            items += $"{fr.PriceName}   {currInfo?.Name} {fr.Price.ToString("#0.00")}  *  {fr.Count} {fr.Unit} * {fr.Rate}.................. RMB {fr.ItemSumPrice.ToString("#0.00")}\n";
                             sumPrice += fr.ItemSumPrice;
                         }
                         Bookmark mark = doc.Range.Bookmarks["PayItemContent"];

+ 25 - 57
OASystem/OASystem.Api/OAMethodLib/JuHeAPI/JuHeApiService.cs

@@ -4,6 +4,7 @@ using OASystem.Domain;
 using OASystem.Domain.Dtos.SmallFun;
 using OASystem.Domain.ViewModels.JuHeExchangeRate;
 using OASystem.Domain.ViewModels.SmallFun;
+using StackExchange.Redis;
 using System.DirectoryServices.Protocols;
 using System.Net.Http;
 using System.Net.Http.Json;
@@ -338,8 +339,10 @@ namespace OASystem.API.OAMethodLib.JuHeAPI
 
         #region 文本翻译
         /// <summary>
-        /// 获取汇率
+        /// 文本翻译
         /// </summary>
+        /// <param name="source">原文,数据类型为字符串,也可为数组(元素必须为字符串类型);每次请求的字符串长度之和尽量不要超过 </param>
+        /// <param name="trans_type">翻译方向:en2zh(英文-中文),zh2en(中文-英文),ja2zh(日文-中文),zh2ja(中文-日文),ko2zh(韩文-中文),zh2ko(中文-韩文)</param>
         /// <returns></returns>
         public async Task<JuHeAPIResult> GetTextTranslateAsync(string source,string trans_type = "zh2en")
         {
@@ -350,78 +353,43 @@ namespace OASystem.API.OAMethodLib.JuHeAPI
             #region 请求接口并存入缓存
             string url = string.Format("/finance/exchange/rmbquot");
 
-            try
-            {
-                var exchangeReq = await _httpClient
-                                        .PostAsync(url,
-                                         new FormUrlEncodedContent(new List<KeyValuePair<string, string>>()
-                                         {
+            var exchangeReq = await _httpClient
+                                    .PostAsync(url,
+                                     new FormUrlEncodedContent(new List<KeyValuePair<string, string>>()
+                                     {
                                              new KeyValuePair<string, string>("key",_appKey),//你申请的key 
-                                             new KeyValuePair<string, string>("source",source),   //两种格式(0或者1,默认为0)
-                                             new KeyValuePair<string, string>("trans_type",trans_type)    //(0:工商银行,1:招商银行,2:建设银行,3:中国银行,
-                                                                                         //4:交通银行,5:农业银行,默认为:0)
-                                         }));
-                if (exchangeReq.IsSuccessStatusCode)
-                {
-                    var stringResponse = await exchangeReq.Content.ReadAsStringAsync();
-
-                    result = System.Text.Json.JsonSerializer.Deserialize<JuHeAPIResult>(stringResponse,
-                    new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
-
-                    if (result.Resultcode == "200")
-                    {
-                        List<ExchangeRateModel> rateList = new List<ExchangeRateModel>();
-
-                        #region 处理数据类型
-                        JArray jar = JArray.Parse(result.Result.ToJson());
-                        for (int i = 0; i < jar.Count; i++)
-                        {
-                            JObject j = JObject.Parse(jar[i].ToString());
-                            for (int x = 1; x < j.Count + 1; x++)
-                            {
-                                string rateName = "data" + x;
-                                string rateDataStr = j[rateName].ToString();
-                                if (!string.IsNullOrEmpty(rateDataStr))
-                                {
-                                    ExchangeRateModel exchangeRate = JsonConvert.DeserializeObject<ExchangeRateModel>(rateDataStr);
-                                    rateList.Add(exchangeRate);
-                                }
-                            }
-                        }
-                        #endregion
+                                             new KeyValuePair<string, string>("source",source),   
+                                             new KeyValuePair<string, string>("trans_type",trans_type)    
 
+                                     }));
+            if (exchangeReq.IsSuccessStatusCode)
+            {
+                var stringResponse = await exchangeReq.Content.ReadAsStringAsync();
 
-                        TimeSpan ts = DateTime.Now.AddMinutes(120) - DateTime.Now; //设置redis 过期时间 120分钟
-                        await RedisRepository
-                            .RedisFactory
-                            .CreateRedisRepository()
-                            .StringSetAsync<string>("JuHeApiExchangeRate", rateList.ToJson(), ts);//string 存
-
-                        result.Result = rateList;
-                    }
-                    else
-                    {
-                        result.Reason = string.Format("聚合APIError[Error_Code:{0} Resultcode:{1} Msg:{2}]",
-                            result.Error_code, result.Resultcode, result.Result);
-                    }
+                result = System.Text.Json.JsonSerializer.Deserialize<JuHeAPIResult>(stringResponse,
+                new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
 
+                if (result.Resultcode == "200")
+                {
+                    string resStr = (string)result.Result.GetType().GetProperty("res").GetValue(result.Result, null);
+                    result.Result = resStr;
                 }
                 else
                 {
-                    result.Reason = "汇率接口请求失败!";
+                    result.Reason = string.Format("聚合APIError[Error_Code:{0} Resultcode:{1} Msg:{2}]",
+                        result.Error_code, result.Resultcode, result.Result);
                 }
             }
-            catch (Exception ex)
+            else
             {
-                result.Reason = ex.Message;
+                result.Reason = "汇率接口请求失败!";
             }
+
             #endregion
 
-           
             return result;
         }
 
-
         #endregion
     }
 }