Browse Source

新增 SmallFunController
OAMethodLib/JuHeApi
Domain> dtos/viewModel

leiy 1 year ago
parent
commit
bfb73c4aae

+ 39 - 35
OASystem/OASystem.Api/Controllers/SmallFunController.cs

@@ -1,9 +1,15 @@
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Options;
+using MySqlX.XDevAPI;
 using OASystem.API.OAMethodLib.JuHeAPI;
+using OASystem.Domain.Dtos.Groups;
+using OASystem.Domain.Dtos.SmallFun;
 using OASystem.Domain.ViewModels.JuHeExchangeRate;
+using SqlSugar;
 using System.Buffers;
+using System.Collections.Generic;
+using System.Collections.Immutable;
 using System.Collections.Specialized;
 using System.Text.Json;
 using System.Text.Json.Nodes;
@@ -19,65 +25,63 @@ namespace OASystem.API.Controllers
     public class SmallFunController : ControllerBase
     {
         private readonly IJuHeApiService _juHeApiService;
+        private readonly IConfiguration _config;
 
         /// <summary>
         /// 初始化
         /// </summary>
         /// <param name="juHeApiService"></param>
-        public SmallFunController(IJuHeApiService juHeApiService)
+        public SmallFunController(IJuHeApiService juHeApiService, IConfiguration config)
         {
             this._juHeApiService = juHeApiService;
+            this._config = config;
         }
 
 
         #region 聚合汇率相关
         /// <summary>
-        /// 获取汇率接口
+        /// 获取汇率币种
         /// </summary>
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> GeExchangeRate()
+        public async Task<IActionResult> GeRateCurrency()
         {
-            string rateDataString = await RedisRepository.RedisFactory
-                                                         .CreateRedisRepository()
-                                                         .StringGetAsync<string>("OA2023JuHeExchangeRate");//string 取
+            var rateCurrencyData = AppSettingsHelper.Get<RateCurrencyModel>("RateCurrency");
 
-            //if (string.IsNullOrEmpty(rateDataString))
-            //{
-                var rateData = await _juHeApiService.GetExchangeRateAsync();
-                if (rateData.Resultcode == "200" && rateData.Error_code == 0)
-                {
-                    var data = rateData.Result;
-
-                    System.Text.Json.JsonSerializer.Deserialize<ListDictionary>(data.ToJson());
-
-
-                    var node = JsonNode.Parse(data.ToJson());
-                    var responseData = System.Text.Json.JsonSerializer.Deserialize<Dictionary<string, dynamic>>(node);
-                //var responseData = System.Text.Json.JsonSerializer.Deserialize<ExchangeRateModel>(data);
-
-                //var responseData = JsonSerializer.Deserialize<Dictionary<string, dynamic>>(data);
-                //var node = JsonNode.Parse(data.ToJson());
-                //var myClass = node.GetValue<ExchangeRateModel>;
+            return Ok(JsonView(rateCurrencyData));
+        }
 
 
-                TimeSpan ts = DateTime.Now.AddMinutes(120) - DateTime.Now; //设置redis 过期时间 比 jwt 时间 快一分钟
-                    await RedisRepository.RedisFactory.CreateRedisRepository()
-                                                      .StringSetAsync<string>("OA2023JuHeExchangeRate", data.ToJson(), ts);//string 存
-                                                                                                                                                   //JsonObject.Create(data, ExchangeRateModel).ToJson();
-                }
-            //}
+        /// <summary>
+        /// 获取汇率费用
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GeExchangeRate(ExchangeRateDto rateDto)
+        {
+            #region 参数处理
+            if (string.IsNullOrEmpty(rateDto.CurrencyCodePer) || string.IsNullOrEmpty(rateDto.CurrencyCodeSuf))
+            {
+                return Ok(JsonView(false, "币种参数为空!"));
+            }
 
-           
+            if (rateDto.Money <= 0)
+            {
+                return Ok(JsonView(false, "转换金额 <= 0!"));
+            }
+            #endregion
 
-            return Ok(JsonView(true));
+            var result = await _juHeApiService.GetExchangeRateAsync(rateDto);
+            if (result.Code != 0 || result == null)
+            {
+                return Ok(JsonView(false, result.Msg));
+            }
+            return Ok(JsonView(result.Data));
         }
         #endregion
-        /// <summary>
-        /// 获取汇率
-        /// </summary>
-        /// <returns></returns>
+
 
 
     }

+ 0 - 139
OASystem/OASystem.Api/OAMethodLib/JuHeAPI/ExchangeRateTool.cs

@@ -1,139 +0,0 @@
-using System.Web;
-
-namespace OASystem.API.OAMethodLib.JuHeAPI
-{
-    /// <summary>
-    /// 集合接口 - 汇率转换tools
-    /// </summary>
-    public static class ExchangeRateTool
-    {
-        //初始化 appkey
-        static string appKey = "0f5429e9fbb8637c0ff3f14bbb42c732";
-
-        /// <summary>
-        /// Http (GET/POST)
-        /// </summary>
-        /// <param name="url">请求URL</param>
-        /// <param name="parameters">请求参数</param>
-        /// <param name="method">请求方法</param>
-        /// <returns>响应内容</returns>
-        static string SendRequest(string url, IDictionary<string, string> parameters, string method)
-        {
-            if (method.ToLower() == "post")
-            {
-                HttpWebRequest req = null;
-                HttpWebResponse rsp = null;
-                System.IO.Stream reqStream = null;
-                try
-                {
-                    req = (HttpWebRequest)WebRequest.Create(url);
-                    req.Method = method;
-                    req.KeepAlive = false;
-                    req.ProtocolVersion = HttpVersion.Version10;
-                    req.Timeout = 5000;
-                    req.ContentType = "application/x-www-form-urlencoded;charset=utf-8";
-                    byte[] postData = Encoding.UTF8.GetBytes(BuildQuery(parameters, "utf8"));
-                    reqStream = req.GetRequestStream();
-                    reqStream.Write(postData, 0, postData.Length);
-                    rsp = (HttpWebResponse)req.GetResponse();
-                    Encoding encoding = Encoding.GetEncoding(rsp.CharacterSet);
-                    return GetResponseAsString(rsp, encoding);
-                }
-                catch (Exception ex)
-                {
-                    return ex.Message;
-                }
-                finally
-                {
-                    if (reqStream != null) reqStream.Close();
-                    if (rsp != null) rsp.Close();
-                }
-            }
-            else
-            {
-                //创建请求
-                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url + "?" + BuildQuery(parameters, "utf8"));
-
-                //GET请求
-                request.Method = "GET";
-                request.ReadWriteTimeout = 5000;
-                request.ContentType = "text/html;charset=UTF-8";
-                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
-                Stream myResponseStream = response.GetResponseStream();
-                StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
-
-                //返回内容
-                string retString = myStreamReader.ReadToEnd();
-                return retString;
-            }
-        }
-
-        /// <summary>
-        /// 组装普通文本请求参数。
-        /// </summary>
-        /// <param name="parameters">Key-Value形式请求参数字典</param>
-        /// <returns>URL编码后的请求数据</returns>
-        static string BuildQuery(IDictionary<string, string> parameters, string encode)
-        {
-            StringBuilder postData = new StringBuilder();
-            bool hasParam = false;
-            IEnumerator<KeyValuePair<string, string>> dem = parameters.GetEnumerator();
-            while (dem.MoveNext())
-            {
-                string name = dem.Current.Key;
-                string value = dem.Current.Value;
-                // 忽略参数名或参数值为空的参数
-                if (!string.IsNullOrEmpty(name))//&& !string.IsNullOrEmpty(value)
-                {
-                    if (hasParam)
-                    {
-                        postData.Append("&");
-                    }
-                    postData.Append(name);
-                    postData.Append("=");
-                    if (encode == "gb2312")
-                    {
-                        postData.Append(HttpUtility.UrlEncode(value, Encoding.GetEncoding("gb2312")));
-                    }
-                    else if (encode == "utf8")
-                    {
-                        postData.Append(HttpUtility.UrlEncode(value, Encoding.UTF8));
-                    }
-                    else
-                    {
-                        postData.Append(value);
-                    }
-                    hasParam = true;
-                }
-            }
-            return postData.ToString();
-        }
-
-        /// <summary>
-        /// 把响应流转换为文本。
-        /// </summary>
-        /// <param name="rsp">响应流对象</param>
-        /// <param name="encoding">编码方式</param>
-        /// <returns>响应文本</returns>
-        static string GetResponseAsString(HttpWebResponse rsp, Encoding encoding)
-        {
-            System.IO.Stream stream = null;
-            StreamReader reader = null;
-            try
-            {
-                // 以字符流的方式读取HTTP响应
-                stream = rsp.GetResponseStream();
-                reader = new StreamReader(stream, encoding);
-                return reader.ReadToEnd();
-            }
-            finally
-            {
-                // 释放资源
-                if (reader != null) reader.Close();
-                if (stream != null) stream.Close();
-                if (rsp != null) rsp.Close();
-            }
-        }
-
-    }
-}

+ 15 - 1
OASystem/OASystem.Api/OAMethodLib/JuHeAPI/IJuHeApiService.cs

@@ -1,4 +1,5 @@
-using OASystem.Domain.ViewModels.JuHeExchangeRate;
+using OASystem.Domain.Dtos.SmallFun;
+using OASystem.Domain.ViewModels.JuHeExchangeRate;
 
 namespace OASystem.API.OAMethodLib.JuHeAPI
 {
@@ -12,5 +13,18 @@ namespace OASystem.API.OAMethodLib.JuHeAPI
         /// </summary>
         /// <returns></returns>
         Task<JuHeAPIResult> GetExchangeRateAsync();
+
+        /// <summary>
+        /// 获取汇率 Single
+        /// </summary>
+        /// <param name="currencyCode">币种code</param>
+        /// <returns></returns>
+        Task<Result> GetSingleRateAsync(string currencyCode);
+
+        /// <summary>
+        /// 获取汇率转换结果
+        /// </summary>
+        /// <returns></returns>
+        Task<Result> GetExchangeRateAsync(ExchangeRateDto dto);
     }
 }

+ 243 - 17
OASystem/OASystem.Api/OAMethodLib/JuHeAPI/JuHeApiService.cs

@@ -1,5 +1,10 @@
 using Dm;
+using Newtonsoft.Json;
+using OASystem.Domain;
+using OASystem.Domain.Dtos.SmallFun;
 using OASystem.Domain.ViewModels.JuHeExchangeRate;
+using OASystem.Domain.ViewModels.SmallFun;
+using System.DirectoryServices.Protocols;
 using System.Net.Http;
 using System.Net.Http.Json;
 using System.Text.Json;
@@ -25,44 +30,265 @@ namespace OASystem.API.OAMethodLib.JuHeAPI
         }
 
         /// <summary>
-        /// 汇率转换
+        /// 获取汇率
         /// </summary>
         /// <returns></returns>
-        /// <exception cref="NotImplementedException"></exception>
         public async Task<JuHeAPIResult> GetExchangeRateAsync()
         {
-            var result = new JuHeAPIResult() { Resultcode = "10000",Reason="未知错误" };
+            var result = new JuHeAPIResult() { Resultcode = "-2",Reason="未知错误" };
 
-            string url = string.Format("/finance/exchange/rmbquot");
+            string rateDataString = await RedisRepository.RedisFactory
+                                                         .CreateRedisRepository()
+                                                         .StringGetAsync<string>("JuHeApiExchangeRate");//string 取
 
-            try
+            if (string.IsNullOrEmpty(rateDataString))
             {
-                var exchangeReq = await _httpClient.PostAsync(url,
-                                    new FormUrlEncodedContent(new List<KeyValuePair<string, string>>()
-                                    {
+                #region 请求接口并存入缓存
+                string url = string.Format("/finance/exchange/rmbquot");
+
+                try
+                {
+                    var exchangeReq = await _httpClient.PostAsync(url,
+                                        new FormUrlEncodedContent(new List<KeyValuePair<string, string>>()
+                                        {
                                         new KeyValuePair<string, string>("key",_appKey),//你申请的key 
                                         new KeyValuePair<string, string>("type","0"),   //两种格式(0或者1,默认为0)
                                         new KeyValuePair<string, string>("bank","3")    //(0:工商银行,1:招商银行,2:建设银行,3:中国银行,
                                                                                         //4:交通银行,5:农业银行,默认为:0)
-                                    }));
-                if (exchangeReq.IsSuccessStatusCode)
+                                        }));
+                    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
+
+
+                            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);
+                        }
+
+                    }
+                    else
+                    {
+                        result.Reason = "汇率接口请求失败!";
+                    }
+                }
+                catch (Exception ex)
                 {
-                    var stringResponse = await exchangeReq.Content.ReadAsStringAsync();
+                    result.Reason = ex.Message;
+                }
+                #endregion
+
+            }
+            else
+            {
+                result.Resultcode = "200";
+                result.Result = JsonConvert.DeserializeObject<List<ExchangeRateModel>>(rateDataString);
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 获取汇率 Single
+        /// </summary>
+        /// <param name="currencyCode">币种code</param>
+        /// <returns></returns>
+        public async Task<Result> GetSingleRateAsync(string currencyCode)
+        {
+
+            var result = new Result() { Code = -2, Msg = "未知错误" };
+            if (currencyCode.ToUpper() == "CNY" )
+            {
+                return result;
+            }
 
-                    result = System.Text.Json.JsonSerializer.Deserialize<JuHeAPIResult>(stringResponse,
-                    new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
+            var resultData = await GetExchangeRateAsync();
+            var rateCurrencyData = AppSettingsHelper.Get<RateCurrencyModel>("RateCurrency");
+            var currencyModel = rateCurrencyData.Where(a => a.CurrencyCode == currencyCode).FirstOrDefault();
+            if (currencyModel != null)
+            {
+                if (resultData.Resultcode == "200")
+                {
+                    if (resultData.Result != null)
+                    {
+                        result.Code = 0;
+                        result.Data = ((List<ExchangeRateModel>)resultData.Result).Where(a => a.Name == currencyModel.CurrencyName).FirstOrDefault();
+                    }
                 }
                 else
                 {
-                    result.Reason = "汇率接口请求失败!";
+                    result.Msg = resultData.Reason;
+                }
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 获取汇率转换结果
+        /// </summary>
+        /// <returns></returns>
+        public async Task<Result> GetExchangeRateAsync(ExchangeRateDto dto)
+        {
+            var result = new Result() { Code = -2, Msg = "未知错误" };
+
+            var rateCurrencyData = AppSettingsHelper.Get<RateCurrencyModel>("RateCurrency");
+
+            if (dto.CurrencyCodePer.ToUpper() == "CNY")
+            {
+                var currencyModelSuf = rateCurrencyData.Where(a => a.CurrencyCode == dto.CurrencyCodeSuf).FirstOrDefault();
+                if (currencyModelSuf == null)
+                {
+                    result.Msg = "转换后币种未找到!";
+                    return result;
+                }
+                var rateModelSuf = await GetSingleRateAsync(currencyModelSuf.CurrencyCode);
+                if (rateModelSuf.Code != 0)
+                {
+                    result.Msg = rateModelSuf.Msg;
+                    return result;
+                }
+                if (string.IsNullOrEmpty(rateModelSuf.Data.FSellPri))
+                {
+                    result.Msg = string.Format("{0}({1})暂无汇率!", currencyModelSuf.CurrencyName, currencyModelSuf.CurrencyCode);
+                    return result;
                 }
+
+                decimal moneySuf = Convert.ToDecimal(rateModelSuf.Data.FSellPri) / 100 ; //fSellPri
+                decimal settlementMoney = dto.Money / moneySuf;
+                var rateView = new ExchangeRateView { 
+                    CurrencyCodePre = dto.CurrencyCodePer,
+                    CurrencyNamePre = "人民币",
+                    MoneyPre = dto.Money,
+                    CurrencyCodeSuf = dto.CurrencyCodeSuf,
+                    CurrencyNameSuf = currencyModelSuf.CurrencyName,
+                    MoneySuf = CommonFun.CutDecimalWithN( settlementMoney,4),
+                    UpdateTime = string.Format("{0} {1}", rateModelSuf.Data.Date, rateModelSuf.Data.Time)
+                };
+
+                result.Code = 0;
+                result.Msg = "成功!";
+                result.Data = rateView;
+                return result;
             }
-            catch (Exception ex)
+            else
             {
-                result.Reason = ex.Message;
+                var currencyModelPre = rateCurrencyData.Where(a => a.CurrencyCode == dto.CurrencyCodePer).FirstOrDefault();
+
+                if (currencyModelPre == null)
+                {
+                    result.Msg = "转换前币种未找到!";
+                    return result;
+                }
+
+                var rateModelPre = await GetSingleRateAsync(currencyModelPre.CurrencyCode);
+                if (rateModelPre.Code != 0)
+                {
+                    result.Msg = rateModelPre.Msg;
+                    return result;
+                }
+
+                if (string.IsNullOrEmpty(rateModelPre.Data.FSellPri))
+                {
+                    result.Msg = string.Format("{0}({1})暂无汇率!", currencyModelPre.CurrencyName, currencyModelPre.CurrencyCode);
+                    return result;
+                }
+
+                decimal moneyPre = (Convert.ToDecimal(rateModelPre.Data.FSellPri) / 100) * dto.Money; //fSellPri
+
+                if (dto.CurrencyCodeSuf.ToUpper() == "CNY")
+                {
+                    var rateView = new ExchangeRateView
+                    {
+                        CurrencyCodePre = dto.CurrencyCodePer,
+                        CurrencyNamePre = currencyModelPre.CurrencyName,
+                        MoneyPre = dto.Money,
+                        CurrencyCodeSuf = "CNY",
+                        CurrencyNameSuf = "人民币",
+                        MoneySuf = CommonFun.CutDecimalWithN(moneyPre, 4),
+                        UpdateTime = string.Format("{0} {1}", rateModelPre.Data.Date, rateModelPre.Data.Time)
+                    };
+
+                    result.Code = 0;
+                    result.Msg = "成功!";
+                    result.Data = rateView;
+                }
+                else
+                {
+                    var currencyModelSuf = rateCurrencyData.Where(a => a.CurrencyCode == dto.CurrencyCodeSuf).FirstOrDefault();
+
+                    if (currencyModelSuf == null)
+                    {
+                        result.Msg = "转换后币种未找到!";
+                        return result;
+                    }
+
+                    var rateModelSuf = await GetSingleRateAsync(currencyModelSuf.CurrencyCode);
+                    if (rateModelSuf.Code != 0)
+                    {
+                        result.Msg = rateModelSuf.Msg;
+                        return result;
+                    }
+                    if (string.IsNullOrEmpty(rateModelSuf.Data.FSellPri))
+                    {
+                        result.Msg = string.Format("{0}({1})暂无汇率!", currencyModelSuf.CurrencyName, currencyModelSuf.CurrencyCode);
+                        return result;
+                    }
+
+                    decimal moneySuf = Convert.ToDecimal(rateModelSuf.Data.FSellPri) / 100; //fSellPri
+
+                    decimal settlementMoney = moneyPre / moneySuf;
+                    var rateView = new ExchangeRateView
+                    {
+                        CurrencyCodePre = dto.CurrencyCodePer,
+                        CurrencyNamePre = currencyModelPre.CurrencyName,
+                        MoneyPre = dto.Money,
+                        CurrencyCodeSuf = dto.CurrencyCodeSuf,
+                        CurrencyNameSuf = currencyModelSuf.CurrencyName,
+                        MoneySuf = CommonFun.CutDecimalWithN(settlementMoney, 4),
+                        UpdateTime = string.Format("{0} {1}", rateModelSuf.Data.Date, rateModelSuf.Data.Time)
+                    };
+
+                    result.Code = 0;
+                    result.Msg = "成功!";
+                    result.Data = rateView;
+                }
             }
-            
+
             return result;
         }
+
     }
 }

+ 91 - 1
OASystem/OASystem.Api/appsettings.json

@@ -12,5 +12,95 @@
     "DefaultUser": "51",
     "Boss": "21",
     "FilterUser": "51,180"
-  }
+  },
+  "RateCurrency": [
+    {
+      "CurrencyName": "人民币",
+      "CurrencyCode": "CNY"
+    },
+    {
+      "CurrencyName": "美元",
+      "CurrencyCode": "USD"
+    },
+    {
+      "CurrencyName": "欧元",
+      "CurrencyCode": "EUR"
+    },
+    {
+      "CurrencyName": "港币",
+      "CurrencyCode": "HKD"
+    },
+    {
+      "CurrencyName": "日元",
+      "CurrencyCode": "JPY"
+    },
+    {
+      "CurrencyName": "英镑",
+      "CurrencyCode": "GBP"
+    },
+    {
+      "CurrencyName": "澳大利亚元",
+      "CurrencyCode": "AUD"
+    },
+    {
+      "CurrencyName": "加拿大元",
+      "CurrencyCode": "CAD"
+    },
+    {
+      "CurrencyName": "泰国铢",
+      "CurrencyCode": "THB"
+    },
+    {
+      "CurrencyName": "新加坡元",
+      "CurrencyCode": "SGD"
+    },
+    {
+      "CurrencyName": "瑞士法郎",
+      "CurrencyCode": "CHK"
+    },
+    {
+      "CurrencyName": "丹麦克朗",
+      "CurrencyCode": "DKK"
+    },
+    {
+      "CurrencyName": "澳门元",
+      "CurrencyCode": "MOP"
+    },
+    {
+      "CurrencyName": "林吉特",
+      "CurrencyCode": "MYR"
+    },
+    {
+      "CurrencyName": "挪威克朗",
+      "CurrencyCode": "NOK"
+    },
+    {
+      "CurrencyName": "新西兰元",
+      "CurrencyCode": "NZD"
+    },
+    {
+      "CurrencyName": "卢布",
+      "CurrencyCode": "RUB"
+    },
+    {
+      "CurrencyName": "瑞典克朗",
+      "CurrencyCode": "SEK"
+    },
+    {
+      "CurrencyName": "菲律宾比索",
+      "CurrencyCode": "PHP"
+    },
+    {
+      "CurrencyName": "新台币",
+      "CurrencyCode": "TWD"
+    },
+    {
+      "CurrencyName": "巴西雷亚尔",
+      "CurrencyCode": "BRL"
+    },
+    {
+      "CurrencyName": "韩国元",
+      "CurrencyCode": "ZAR"
+    }
+  ]
 }

+ 30 - 0
OASystem/OASystem.Domain/Dtos/SmallFun/ExchangeRateDto.cs

@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.SmallFun
+{
+    /// <summary>
+    /// 获取汇率 请求dto
+    /// </summary>
+    public class ExchangeRateDto:DtoBase
+    {
+        /// <summary>
+        /// 转换前币种Code
+        /// </summary>
+        public string CurrencyCodePer { get; set; }
+
+        /// <summary>
+        /// 转换后Code
+        /// </summary>
+        public string CurrencyCodeSuf { get; set; }
+
+        /// <summary>
+        /// 转换金额
+        /// </summary>
+        public decimal Money { get; set; }
+
+    }
+}

+ 18 - 2
OASystem/OASystem.Domain/ViewModels/JuHeExchangeRate/JuHeAPIResult.cs

@@ -69,6 +69,11 @@ namespace OASystem.Domain.ViewModels.JuHeExchangeRate
         /// </summary>
         public string? MBuyPri { get; set; }
 
+        /// <summary>
+        /// 现汇卖出价
+        /// </summary>
+        public string? FSellPri { get; set; }
+
         /// <summary>
         /// 现钞卖出价
         /// </summary>
@@ -91,8 +96,19 @@ namespace OASystem.Domain.ViewModels.JuHeExchangeRate
     }
 
 
-    public record AclRecord
+    /// <summary>
+    /// 汇率 币种Model
+    /// </summary>
+    public record RateCurrencyModel
     {
-        public Dictionary<string, StringCollection> ACL { get; set; }
+        /// <summary>
+        /// 币种名称
+        /// </summary>
+        public string CurrencyName { get; set; }
+
+        /// <summary>
+        /// 币种Code
+        /// </summary>
+        public string CurrencyCode{ get; set; }
     }
 }

+ 50 - 0
OASystem/OASystem.Domain/ViewModels/SmallFun/ExchangeRateView.cs

@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.SmallFun
+{
+    /// <summary>
+    /// 汇率
+    /// 返回视图
+    /// </summary>
+    public class ExchangeRateView
+    {
+        /// <summary>
+        /// 转换前币种
+        /// </summary>
+        public string CurrencyCodePre { get; set; }
+
+        /// <summary>
+        /// 转换前名称
+        /// </summary>
+        public string CurrencyNamePre { get; set; }
+
+        /// <summary>
+        /// 转换前金额
+        /// </summary>
+        public decimal MoneyPre { get; set; }
+
+        /// <summary>
+        /// 转换后币种
+        /// </summary>
+        public string CurrencyCodeSuf { get; set; }
+
+        /// <summary>
+        /// 转换后名称
+        /// </summary>
+        public string CurrencyNameSuf { get; set; }
+
+        /// <summary>
+        /// 转换后金额
+        /// </summary>
+        public decimal MoneySuf { get; set; }
+
+        /// <summary>
+        /// 更新时间
+        /// </summary>
+        public string? UpdateTime { get; set; }
+    }
+}

+ 38 - 0
OASystem/OASystem.Infrastructure/Tools/CommonFun.cs

@@ -196,4 +196,42 @@ public static class CommonFun
     }
 
     #endregion
+
+    #region decimal 截取
+    /// <summary>
+    /// 
+    /// </summary>
+    /// <param name="d"></param>
+    /// <param name="n"></param>
+    /// <returns></returns>
+    public static decimal CutDecimalWithN(decimal d, int n)
+    {
+        string strDecimal = d.ToString();
+        int index = strDecimal.IndexOf(".");
+        if (index == -1 || strDecimal.Length < index + n + 1)
+        {
+            strDecimal = string.Format("{0:F" + n + "}", d);
+        }
+        else
+        {
+            int length = index;
+            if (n != 0)
+            {
+                length = index + n + 1;
+            }
+            strDecimal = strDecimal.Substring(0, length);
+        }
+        return Decimal.Parse(strDecimal);
+    }
+
+    public static decimal CutDecimalWithN(decimal? d, int n)
+    {
+        if (d == null)
+        {
+            return Decimal.MinValue;
+        }
+        return CutDecimalWithN(Convert.ToDecimal(d), n);
+    }
+
+    #endregion
 }