Преглед изворни кода

出入境费用 - 移动端 --> op相关操作 新增 返回 参数 parentId

LEIYI пре 4 недеља
родитељ
комит
6da7bde22f

+ 44 - 14
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -11,11 +11,13 @@ using MySqlX.XDevAPI.Relational;
 using NetUV.Core.Handles;
 using NPOI.HSSF.UserModel;
 using NPOI.POIFS.Crypt.Dsig;
+using NPOI.POIFS.Properties;
 using NPOI.SS.Format;
 using NPOI.SS.Formula.Functions;
 using NPOI.SS.UserModel;
 using NPOI.SS.Util;
 using NPOI.XSSF.UserModel;
+using OASystem.API.Middlewares;
 using OASystem.API.OAMethodLib;
 using OASystem.API.OAMethodLib.APNs;
 using OASystem.API.OAMethodLib.File;
@@ -7405,6 +7407,7 @@ FROM
             var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
 
             var mobileInfo = new EnterExitCostMobileParentInfoView();
+            mobileInfo.DiId = dto.DiId;
             if (eecInfo == null) return Ok(mobileInfo);
 
             mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
@@ -7432,7 +7435,7 @@ FROM
             mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
             mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
             mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
-            mobileInfo.Currencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark);
+            mobileInfo.Currencys = (List<CurrencyInfo>)CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark);
             mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
             mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal);  //伙食费 2
             mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal);  //公杂费 3
@@ -7708,6 +7711,29 @@ FROM
             }
         }
 
+        /// <summary>
+        /// 验证出入境费用数据是否存在
+        /// 不存在添加
+        /// </summary>
+        /// <param name="diId"></param>
+        /// <param name="currUserId"></param>
+        /// <returns></returns>
+        /// <exception cref="CustomException"></exception>
+        private async Task<int> EnterExitCostVerifyIsNull(int diId,int currUserId)
+        {
+            var parentId = 0;
+
+            var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
+            if (info != null) parentId = info.Id;
+            else
+            {
+                int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId }).ExecuteReturnIdentityAsync();
+                if (addId < 1) throw new CustomException("出入境费用添加失败!");
+                parentId = addId;
+            }
+
+            return parentId;
+        }
 
         /// <summary>
         /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
@@ -7821,7 +7847,7 @@ FROM
             //汇率信息记录
             await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
 
-            return Ok(JsonView(true));
+            return Ok(JsonView(new { parentId = id }));
         }
 
         /// <summary>
@@ -7866,7 +7892,7 @@ FROM
                 if (upd < 1) return Ok(JsonView(false));
             }
 
-            return Ok(JsonView(true));
+            return Ok(JsonView(new { parentId = id }));
         }
 
         /// <summary>
@@ -7918,7 +7944,7 @@ FROM
                 if (upd < 1) return Ok(JsonView(false));
             }
 
-            return Ok(JsonView(true));
+            return Ok(JsonView(new { parentId = id }));
         }
 
         /// <summary>
@@ -7935,7 +7961,7 @@ FROM
 
             var info = _mapper.Map<Grp_EnterExitCost>(dto);
             info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
-            
+
             int id = dto.Id;
             if (id <= 0) //add 
             {
@@ -7968,7 +7994,7 @@ FROM
             //消息通知
             await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
 
-            return Ok(JsonView(new { itemTotal = info.InsidePay }));
+            return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
         }
 
         /// <summary>
@@ -8028,6 +8054,7 @@ FROM
 
             return Ok(JsonView(new
             {
+                parentId = id,
                 choiceTwoJJ = dto.ChoiceTwoJJ,
                 jjcItemTotal = jjcItemTotal,
                 choiceTwoGW = dto.ChoiceTwoGW,
@@ -8124,12 +8151,15 @@ FROM
             subInfo.DiId = dto.DiId;
 
             if (feeType == 3) subInfo.Type = 1;
-            else if (feeType == 4) subInfo.Type = 1;
-            else if (feeType == 5) subInfo.Type = 1;
-            else if (feeType == 6) subInfo.Type = 1;
+            else if (feeType == 4) subInfo.Type = 2;
+            else if (feeType == 5) subInfo.Type = 3;
+            else if (feeType == 6) subInfo.Type = 4;
 
             subInfo.CreateUserId = dto.CurrUserId;
 
+            int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
+            if (parentId < 1) return Ok(JsonView(false));
+
             //子表op
             if (subId < 1)
             {
@@ -8154,11 +8184,9 @@ FROM
            
             var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
 
-            //消息通知
-            var parentId = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First().Id;
             await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
 
-            return Ok(JsonView(new { itemTotal = itemTotal }));
+            return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
         }
 
         /// <summary>
@@ -8239,6 +8267,9 @@ FROM
             subInfo.Diid = dto.Diid;
             subInfo.CreateUserId = dto.CurrUserId;
 
+            int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
+            if (parentId < 1) return Ok(JsonView(false));
+
             #region 子表op
             if (subId < 1)//add
             {
@@ -8266,10 +8297,9 @@ FROM
             var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
 
             //消息通知
-            var parentId = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).First().Id;
             await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
 
-            return Ok(JsonView(new { itemTotal = itemTotal }));
+            return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
         }
 
         /// <summary>

+ 0 - 1
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -1362,7 +1362,6 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
 
         #region 商邀资料
 
-
         /// <summary>
         /// 商邀资料 基础数据源
         /// </summary>

+ 1 - 1
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -6172,7 +6172,7 @@ WHERE
         ///  团组数据统计
         ///  当前时间团组所在城市   
         /// </summary>
-        /// <param name="_dto"></param>
+        /// <param name="dto"></param>
         /// <returns></returns>
         [HttpPost("StatisticsNowCityOfGroup")]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]

+ 12 - 0
OASystem/OASystem.Api/Middlewares/CustomException.cs

@@ -0,0 +1,12 @@
+namespace OASystem.API.Middlewares
+{
+    /// <summary>
+    /// 自定义异常
+    /// </summary>
+    public class CustomException : Exception
+    {
+        public CustomException(string message) : base(message)
+        {
+        }
+    }
+}

+ 1 - 1
OASystem/OASystem.Domain/ViewModels/Groups/EnterExitCostView.cs

@@ -844,7 +844,7 @@ namespace OASystem.Domain.ViewModels.Groups
         ///  多个币种存储
         ///  存储方式: 美元(USD):6.2350|.......|墨西哥比索(MXN):1.0000
         /// </summary>
-        public List<CurrencyInfo>? Currencys { get; set; }
+        public List<CurrencyInfo> Currencys { get; set; } = new List<CurrencyInfo> { };
 
         #endregion