Explorar el Código

新增团组聚合API测试接口及汇率数据健壮性处理

新增 GroupJuHeAPITest 接口用于团组聚合API测试,完善团组汇率初始化流程。优化 JuHeApiService 对异常汇率数据的处理,避免“-”或空值导致业务异常。调整部分 using 引用及注释,提升代码可读性。
Lyyyi hace 1 día
padre
commit
3ac50d5510

+ 18 - 0
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -52,6 +52,7 @@ using System.Text.Json;
 using System.Web;
 using static OASystem.API.OAMethodLib.JWTHelper;
 using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
+using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
 using Bookmark = Aspose.Words.Bookmark;
 using Cell = Aspose.Words.Tables.Cell;
 using Table = Aspose.Words.Tables.Table;
@@ -1900,6 +1901,23 @@ namespace OASystem.API.Controllers
             return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
         }
 
+        /// <summary>
+        /// 团组聚合API测试接口
+        /// </summary>
+        /// <param name="userId"></param>
+        /// <param name="groupId"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GroupJuHeAPITest(int userId,int groupId)
+        {
+
+            //添加默认币种
+            var currencyData = await GeneralMethod.PostGroupRateAddInit(userId, groupId);
+
+            return Ok(JsonView(true, $"操作成功!", currencyData.Data));
+        }
+
         /// <summary>
         /// 接团流程操作(增改)
         /// 安卓端使用 建团时添加客户名单

+ 0 - 1
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -571,7 +571,6 @@ namespace OASystem.API.OAMethodLib
 
         #region 建团按国家默认添加汇率 / 默认权限分配
 
-
         /// <summary>
         /// 团组汇率 
         /// 建团时 添加基础汇率 CNY

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

@@ -77,6 +77,13 @@ namespace OASystem.API.OAMethodLib.JuHeAPI
                                     if (!string.IsNullOrEmpty(rateDataStr))
                                     {
                                         ExchangeRateModel exchangeRate = JsonConvert.DeserializeObject<ExchangeRateModel>(rateDataStr);
+
+                                        exchangeRate.FBuyPri = HandleMinusValue(exchangeRate.FBuyPri);
+                                        exchangeRate.FSellPri = HandleMinusValue(exchangeRate.FSellPri);
+                                        exchangeRate.MBuyPri = HandleMinusValue(exchangeRate.MBuyPri);
+                                        exchangeRate.MSellPri = HandleMinusValue(exchangeRate.MSellPri);
+                                        exchangeRate.BankConversionPri = HandleMinusValue(exchangeRate.BankConversionPri);
+
                                         rateList.Add(exchangeRate);
                                     }
                                 }
@@ -97,7 +104,6 @@ namespace OASystem.API.OAMethodLib.JuHeAPI
                             result.Reason = string.Format("聚合APIError[Error_Code:{0} Resultcode:{1} Msg:{2}]",
                                 result.Error_code, result.Resultcode, result.Result);
                         }
-
                     }
                     else
                     {
@@ -119,6 +125,16 @@ namespace OASystem.API.OAMethodLib.JuHeAPI
             return result;
         }
 
+        /// <summary>
+        /// 处理金额带“-”的币种汇率信息
+        /// </summary>
+        /// <param name="input"></param>
+        /// <returns></returns>
+        private string HandleMinusValue(string? input)
+        {
+            return string.IsNullOrEmpty(input) || input.Contains("-") ? "1.00" : input;
+        }
+
         /// <summary>
         /// 获取汇率 Single
         /// </summary>
@@ -439,7 +455,6 @@ namespace OASystem.API.OAMethodLib.JuHeAPI
 
             return new JuHeAPIResult(-1, "世界时间接口请求失败!");
         }
-
         #endregion
     }
 }