Explorar el Código

团组模块 - 出入境费用-移动端 - OP --> 新增 3-7项复选框单个复选框更改

LEIYI hace 3 meses
padre
commit
db736f4bcc

+ 99 - 186
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -54,6 +54,7 @@ using System.Net.Http;
 using System.Reflection.PortableExecutable;
 using System.Security.Cryptography;
 using Ubiety.Dns.Core;
+using XAct;
 using static NPOI.POIFS.Crypt.CryptoFunctions;
 using static OASystem.API.OAMethodLib.JWTHelper;
 using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
@@ -7881,6 +7882,58 @@ FROM
             return Ok(JsonView(true));
         }
 
+        /// <summary>
+        /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
+        {
+            int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
+            var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
+
+            if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
+            if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
+            if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
+            if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
+
+            var checkboxInfo = new Grp_EnterExitCost() {
+                Id = id,
+                DiId = diId,
+                CreateUserId = currUserId
+            };
+
+            if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
+            else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
+            else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
+            else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
+            else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
+
+
+            if (id <= 0) //add 
+            {
+                checkboxInfo.CreateUserId = dto.CurrUserId;
+                var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
+
+                if (add < 1) return Ok(JsonView(false));
+            }
+            else //update
+            {
+                var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
+                    .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
+                    .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
+                    .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
+                    .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
+                    .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
+                    .Where(x => x.Id == id)
+                    .ExecuteCommandAsync();
+                if (upd < 1) return Ok(JsonView(false));
+            }
+
+            return Ok(JsonView(true));
+        }
+
         /// <summary>
         /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
         /// </summary>
@@ -8002,6 +8055,7 @@ FROM
         /// </summary>
         /// <returns></returns>
         [HttpPost]
+        [ApiExplorerSettings(IgnoreApi = true)]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
         {
@@ -8070,7 +8124,7 @@ FROM
         public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
         {
             var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
-            int parentId = dto.ParentId, subId = dto.SubId, feeType = dto.FeeType;
+            int subId = dto.SubId, feeType = dto.FeeType;
 
             if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
             if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
@@ -8078,113 +8132,42 @@ FROM
 
             if (!feeTypeIds.Contains(feeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
            
-            var parentInfo = new Grp_EnterExitCost();
-            parentInfo.Id = dto.ParentId;
-            parentInfo.CreateUserId = dto.CurrUserId;
-
-            if (feeType == 1) parentInfo.ChoiceThree = dto.IsSelect;
-            else if (feeType == 2) parentInfo.ChoiceFour = dto.IsSelect;
-            else if (feeType == 3) parentInfo.ChoiceFive = dto.IsSelect;
-            else if (feeType == 4) parentInfo.ChoiceSix = dto.IsSelect;
-
             var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
             subInfo.Id = subId;
+            subInfo.DiId = dto.DiId;
+            subInfo.Type = feeType;
             subInfo.CreateUserId = dto.CurrUserId;
 
-            _sqlSugar.BeginTran();
-            //表op
-            if (parentId < 1) //添加
+            
+            //子表op
+            if (subId < 1)
             {
-                var parentAdd = await _sqlSugar.Insertable(parentInfo).ExecuteCommandAsync();
-                if (parentAdd < 1)
-                {
-                    _sqlSugar.RollbackTran();
-                    return Ok(JsonView(false));
-                }
-
-                //子表op
-                if (subId < 1)
-                {
-                    var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
-                    if (subAdd < 1)
-                    {
-                        _sqlSugar.RollbackTran();
-                        return Ok(JsonView(false));
-                    }
-                }
-                else
-                {
-                    var subUpd = await _sqlSugar.Updateable(subInfo)
-                        .UpdateColumns(x => new
-                        {
-                            x.Days,
-                            x.NationalTravelFeeId,
-                            x.Cost,
-                            x.Currency,
-                            x.SubTotal
-                        })
-                        .WhereColumns(x => new { x.Id })
-                        .ExecuteCommandAsync();
-                    if (subUpd < 1)
-                    {
-                        _sqlSugar.RollbackTran();
-                        return Ok(JsonView(false));
-                    }
-                }
+                var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
+                if (subAdd < 1) return Ok(JsonView(false));
             }
             else
             {
-                var parentUpd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
-                    .SetColumnsIF(feeType == 1, it => it.ChoiceThree == dto.IsSelect)
-                    .SetColumnsIF(feeType == 2, it => it.ChoiceFour == dto.IsSelect)
-                    .SetColumnsIF(feeType == 3, it => it.ChoiceFive == dto.IsSelect)
-                    .SetColumnsIF(feeType == 4, it => it.ChoiceSix == dto.IsSelect)
-                    .Where(it => it.Id == parentId)
-                    .ExecuteCommandAsync();
-
-                if (parentUpd < 1)
-                {
-                    _sqlSugar.RollbackTran();
-                    return Ok(JsonView(false));
-                }
-
-                //子表op
-                if (subId < 1)
-                {
-                    var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
-                    if (subAdd < 1)
-                    {
-                        _sqlSugar.RollbackTran();
-                        return Ok(JsonView(false));
-                    }
-                }
-                else
-                {
-                    var subUpd = await _sqlSugar.Updateable(subInfo)
-                        .UpdateColumns(x => new
-                        {
-                            x.Days,
-                            x.NationalTravelFeeId,
-                            x.Cost,
-                            x.Currency,
-                            x.SubTotal
-                        })
-                        .WhereColumns(x => new { x.Id })
-                        .ExecuteCommandAsync();
-                    if (subUpd < 1)
+                var subUpd = await _sqlSugar.Updateable(subInfo)
+                    .UpdateColumns(x => new
                     {
-                        _sqlSugar.RollbackTran();
-                        return Ok(JsonView(false));
-                    }
-                }
+                        x.Days,
+                        x.NationalTravelFeeId,
+                        x.Cost,
+                        x.Currency,
+                        x.SubTotal
+                    })
+                    .WhereColumns(x => new { x.Id })
+                    .ExecuteCommandAsync();
+                if (subUpd < 1) return Ok(JsonView(false));
             }
-            _sqlSugar.CommitTran();
+           
             var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.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 { isSelect = dto.IsSelect, itemTotal = itemTotal }));
+            return Ok(JsonView(new { itemTotal = itemTotal }));
         }
 
         /// <summary>
@@ -8192,6 +8175,7 @@ FROM
         /// </summary>
         /// <returns></returns>
         [HttpPost]
+        [ApiExplorerSettings(IgnoreApi = true)]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
         {
@@ -8246,125 +8230,54 @@ FROM
         }
 
         /// <summary>
-        /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
+        /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
         /// </summary>
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
         {
-            int parentId = dto.ParentId, subId = dto.SubId;
+            int subId = dto.SubId;
             if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
             if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
             if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
 
-            var parentInfo = new Grp_EnterExitCost();
-            parentInfo.Id = parentId;
-            parentInfo.OtherExpenses_Checked = dto.IsSelect;
-            parentInfo.CreateUserId = dto.CurrUserId;
-
             var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
             subInfo.Id = subId;
+            subInfo.Diid = dto.Diid;
             subInfo.CreateUserId = dto.CurrUserId;
 
-            #region 主表op
-            _sqlSugar.BeginTran();
-            //主表op
-            if (parentId < 1)
+            #region 子表op
+            if (subId < 1)//add
             {
-                var parentAdd = await _sqlSugar.Insertable(parentInfo).ExecuteCommandAsync();
-                if (parentAdd < 1)
-                {
-                    _sqlSugar.RollbackTran();
-                    return Ok(JsonView(false));
-                }
-
-                #region 子表op
-                if (subId < 1)//add
-                {
-                    var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
-                    if (subAdd < 1)
-                    {
-                        _sqlSugar.RollbackTran();
-                        return Ok(JsonView(false));
-                    }
-                }
-                else //upd
-                {
-                    var subUpd = await _sqlSugar.Updateable(subInfo)
-                        .UpdateColumns(x => new
-                        {
-                            x.Index,
-                            x.SetDataId,
-                            x.Cost,
-                            x.Currency,
-                            x.SubTotal,
-                            x.Remark
-                        })
-                        .WhereColumns(x => new { x.Id })
-                        .ExecuteCommandAsync();
-                    if (subUpd < 1)
-                    {
-                        _sqlSugar.RollbackTran();
-                        return Ok(JsonView(false));
-                    }
-                }
-                #endregion
+                var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
+                if (subAdd < 1) return Ok(JsonView(false));
             }
-            else
+            else //upd
             {
-                var parentUpd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
-                    .SetColumns(it => it.OtherExpenses_Checked == dto.IsSelect)
-                    .Where(it => it.Id == parentId)
-                    .ExecuteCommandAsync();
-
-                if (parentUpd < 1)
-                {
-                    _sqlSugar.RollbackTran();
-                    return Ok(JsonView(false));
-                }
-
-                #region 子表op
-                if (subId < 1)//add
-                {
-                    var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
-                    if (subAdd < 1)
-                    {
-                        _sqlSugar.RollbackTran();
-                        return Ok(JsonView(false));
-                    }
-                }
-                else //upd
-                {
-                    var subUpd = await _sqlSugar.Updateable(subInfo)
-                        .UpdateColumns(x => new
-                        {
-                            x.Index,
-                            x.SetDataId,
-                            x.Cost,
-                            x.Currency,
-                            x.SubTotal,
-                            x.Remark
-                        })
-                        .WhereColumns(x => new { x.Id })
-                        .ExecuteCommandAsync();
-                    if (subUpd < 1)
+                var subUpd = await _sqlSugar.Updateable(subInfo)
+                    .UpdateColumns(x => new
                     {
-                        _sqlSugar.RollbackTran();
-                        return Ok(JsonView(false));
-                    }
-                }
-                #endregion
+                        x.Index,
+                        x.SetDataId,
+                        x.Cost,
+                        x.Currency,
+                        x.SubTotal,
+                        x.Remark
+                    })
+                    .WhereColumns(x => new { x.Id })
+                    .ExecuteCommandAsync();
+                if (subUpd < 1) return Ok(JsonView(false));
             }
-            _sqlSugar.CommitTran();
             #endregion
 
             var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).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 { isSelect = dto.IsSelect, itemTotal = itemTotal }));
+            return Ok(JsonView(new { itemTotal = itemTotal }));
         }
 
         /// <summary>

+ 26 - 11
OASystem/OASystem.Domain/Dtos/Groups/EnterExitCostDto.cs

@@ -541,6 +541,21 @@ namespace OASystem.Domain.Dtos.Groups
         public int OtherExpenses_Checked { get; set; }
     }
 
+
+    public class EnterExitCostMobileOpSingleCheckboxDto: PostEnterExitCostMobileUpdateDtoBase
+    {
+        /// <summary>
+        /// 子项复选框类型
+        /// 3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;
+        /// </summary>
+        public int ItemType { get; set; }
+
+        /// <summary>
+        /// 是否选中
+        /// 0 未选择 1 选中
+        /// </summary>
+        public int IsSelected { get; set; }
+    }
     public class PostEnterExitCostMobileOpStep1Dto : PostEnterExitCostMobileUpdateDtoBase
     {
         /// <summary>
@@ -672,13 +687,13 @@ namespace OASystem.Domain.Dtos.Groups
         /// <summary>
         /// 数据主表Id
         /// </summary>
-        public int ParentId { get; set; }
+        //public int ParentId { get; set; }
 
         /// <summary>
         /// 复选框
         /// 0 未选中 1 选中
         /// </summary>
-        public int IsSelect { get; set; }
+        //public int IsSelect { get; set; }
 
         /// <summary>
         /// 费用类型
@@ -742,16 +757,16 @@ namespace OASystem.Domain.Dtos.Groups
 
         public int CurrUserId { get; set; }
 
-        /// <summary>
-        /// 数据主表Id
-        /// </summary>
-        public int ParentId { get; set; }
+        ///// <summary>
+        ///// 数据主表Id
+        ///// </summary>
+        //public int ParentId { get; set; }
 
-        /// <summary>
-        /// 复选框
-        /// 0 未选中 1 选中
-        /// </summary>
-        public int IsSelect { get; set; }
+        ///// <summary>
+        ///// 复选框
+        ///// 0 未选中 1 选中
+        ///// </summary>
+        //public int IsSelect { get; set; }
 
     }