Przeglądaj źródła

团组汇率 币种 Item (来源:团组汇率)
根据 团组Id And 业务类型(CTable)Id

leiy 1 rok temu
rodzic
commit
744bc7dacd

+ 166 - 1
OASystem/OASystem.Api/Controllers/BusinessController.cs

@@ -9,6 +9,7 @@ using OASystem.Domain.Entities.Business;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.Entities.Resource;
 using OASystem.Domain.ViewModels.Business;
+using OASystem.Domain.ViewModels.Financial;
 using OASystem.Domain.ViewModels.Groups;
 using OASystem.Infrastructure.Repositories.Business;
 using OASystem.Infrastructure.Repositories.Groups;
@@ -27,12 +28,15 @@ namespace OASystem.API.Controllers
         private readonly CommonBusRepository _busRep;
         private readonly SetDataRepository _setDataRep;
         private readonly DelegationInfoRepository _groupRep;
-        public BusinessController(IMapper mapper, CommonBusRepository busRep, SetDataRepository setDataRep, DelegationInfoRepository groupRep)
+        private readonly TeamRateRepository _teamRateRep;
+
+        public BusinessController( IMapper mapper, CommonBusRepository busRep, SetDataRepository setDataRep, DelegationInfoRepository groupRep, TeamRateRepository teamRateRep)
         {
             _mapper = mapper;
             _busRep = busRep;
             _setDataRep = setDataRep;
             _groupRep = groupRep;
+            _teamRateRep = teamRateRep;
         }
 
         #region 团组信息 团组详情
@@ -103,6 +107,129 @@ namespace OASystem.API.Controllers
             }
         }
 
+
+        /// <summary>
+        /// 团组汇率 币种 Item (来源:团组汇率)
+        /// 根据 团组Id And 业务类型(CTable)Id
+        /// </summary>
+        /// <param name="portType"> 1 Web 2 Android 3 Ios; </param>
+        /// <param name="diId"> 团组Id </param>
+        /// <param name="CTbale"> CTableType Id  </param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostGroupTeamRateByDiIdAndCTableId(int portType, int diId,int CTbale)
+        {
+            try
+            {
+                if (diId == 0)
+                {
+                    return Ok(JsonView(false, "请输入正确的团组Id!"));
+                }
+                if (CTbale == 0)
+                {
+                    return Ok(JsonView(false, "请输入正确的业务类型(CTable)Id!"));
+                }
+
+
+                if (portType == 1 || portType == 2 || portType == 3 )
+                {
+                    string teamRateInfoSql = string.Format(@"Select sd.Name,tr.* From Grp_TeamRate tr 
+                                                     Left Join Sys_SetData  sd On sd.IsDel=0 And sd.STid=16  And tr.CTable = sd.Id 
+                                                     Where tr.IsDel = 0 And tr.DiId = {0} And tr.CTable = {1}", diId,CTbale);
+
+                    var teamRateInfo = await _teamRateRep._sqlSugar.SqlQueryable<TeamRateInfoView>(teamRateInfoSql).ToListAsync();
+
+                    #region 团组汇率
+
+                    TeamRateModelGeneralView teamRateModels = new TeamRateModelGeneralView();
+
+
+                    List<SetDataInfoView> currencyDatas = new List<SetDataInfoView>();    
+                    #region 获取所有币种
+
+                    string sql = string.Format(@"select * from Sys_SetData where STid = {0} and isdel = 0", 66);
+                    var DBdata = await _setDataRep.GetListBySqlWithNolockAsync(sql);
+
+                    if (DBdata == null || DBdata.Count == 0)
+                    {
+                        return Ok(JsonView(false, "所有币种获取失败!"));
+                    }
+
+                    currencyDatas = DBdata.Select(x => new SetDataInfoView
+                    {
+                        Name = x.Name,
+                        Id = x.Id,
+                        Remark = x.Remark,
+                    }).ToList();
+
+                    #endregion
+
+                    foreach (TeamRateInfoView item in teamRateInfo)
+                    {
+                        TeamRateModelGeneralView teamRateModelInfo = new TeamRateModelGeneralView();
+
+                        teamRateModelInfo.Id = item.Id;
+                        teamRateModelInfo.CTableId = item.CTable;
+                        teamRateModelInfo.CTableName = item.Name;
+                        List<TeamRateDescAddCurrencyIdView> teamRateDescViews = new List<TeamRateDescAddCurrencyIdView>();
+
+                        #region 拆分remark里的汇率
+
+                        if (item.Remark.Contains("|"))
+                        {
+                            string[] currencyArr = item.Remark.Split("|");
+                            foreach (string currency in currencyArr)
+                            {
+                                string[] currency1 = currency.Split(":");
+                                string[] currency2 = currency1[0].Split("(");
+
+                                string currencyCode = currency2[1].Replace(")", "").TrimEnd();
+                                SetDataInfoView dataInfoView = new SetDataInfoView();
+                                dataInfoView = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault();
+                                int currencyId = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault().Id;
+                                TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
+                                {
+                                    CurrencyId = dataInfoView.Id,
+                                    CurrencyCode = currencyCode,
+                                    CurrencyName = currency2[0],
+                                    Rate = decimal.Parse(currency1[1]),
+                                };
+                                teamRateDescViews.Add(rateDescView);
+                            }
+                        }
+
+                        #endregion
+
+                        if (teamRateDescViews.Count > 0)
+                        {
+                            teamRateDescViews = teamRateDescViews.OrderBy(it => it.CurrencyId).ToList();
+                        }
+                        
+                        teamRateModelInfo.TeamRates = teamRateDescViews;
+                        teamRateModels = teamRateModelInfo;
+                    }
+
+                    #endregion
+
+                    return Ok(JsonView(true, "操作成功!", teamRateModels));
+
+                }
+                else
+                {
+                    return Ok(JsonView(false, "请输入正确的端口号! 1 Web 2 Android 3 Ios;"));
+                }
+
+
+
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, ex.Message));
+            }
+        }
+
+
         /// <summary>
         /// 根据团组Id币种Id及类型Id查询团组汇率
         /// </summary>
@@ -133,6 +260,44 @@ namespace OASystem.API.Controllers
         }
         #endregion
 
+        #region 查询页面操作权限
+
+        /// <summary>
+        /// 查询页面操作权限 根据 用户Id 及 页面ID
+        /// </summary>
+        /// <param name="userId">用户Id</param>
+        /// <param name="pageId">页面Id</param>
+        /// <param name="portType">端口类型</param>
+        /// <returns></returns>
+        [HttpGet, HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostPageOperationPermission(int userId,int pageId,int portType)
+        {
+            try
+            {
+
+
+
+                Result setData = await _setDataRep.GetSetDataBySTId(_setDataRep, 66); //币种类型
+                if (setData.Code == 0)
+                {
+                    return Ok(JsonView(true, "查询成功", setData.Data));
+                }
+                else
+                {
+                    return Ok(JsonView(false, setData.Msg));
+                }
+            }
+            catch (Exception)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
+
+        #endregion
+
+
         #region 会务物料单
 
         /// <summary>

+ 36 - 0
OASystem/OASystem.Domain/ViewModels/Financial/TeamRateView.cs

@@ -70,6 +70,42 @@ namespace OASystem.Domain.ViewModels.Financial
         public decimal Rate { get; set; }
 
     }
+
+    /// <summary>
+    /// 
+    /// </summary>
+    public class TeamRateDescAddCurrencyIdView: TeamRateDescView
+    {
+        /// <summary>
+        /// 币种Id
+        /// </summary>
+        public int CurrencyId { get; set; }
+
+    }
+
+    public class TeamRateModelGeneralView
+    {
+        /// <summary>
+        /// 汇率Id
+        /// </summary>
+        public int Id { get; set; }
+
+        /// <summary>
+        /// 汇率模块 Id
+        /// </summary>
+        public int CTableId { get; set; }
+
+        /// <summary>
+        /// 汇率模块
+        /// </summary>
+        public string? CTableName { get; set; }
+
+        /// <summary>
+        /// 汇率 List
+        /// </summary>
+        public List<TeamRateDescAddCurrencyIdView>? TeamRates { get; set; }
+    }
+
     #endregion
 
 }