LEIYI 7 kuukautta sitten
vanhempi
commit
12f6200948

+ 8 - 126
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -807,26 +807,18 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> PostReceivablesDel(ForeignReceivablesDelDto dto)
         {
-            try
+            Result ffrData = await _ForForeignReceivablesRep.PostReceivablesDel(dto);
+            if (ffrData.Code != 0)
             {
-                Result ffrData = await _ForForeignReceivablesRep.PostReceivablesDel(dto);
-                if (ffrData.Code != 0)
-                {
-                    return Ok(JsonView(false, ffrData.Msg));
-                }
-                return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
-            }
-            catch (Exception ex)
-            {
-                return Ok(JsonView(false, ex.Message));
-                throw;
+                return Ok(JsonView(false, ffrData.Msg));
             }
+            return Ok(JsonView(true, ffrData.Msg, ffrData.Data));
         }
 
 
         /// <summary>
         /// 已收账单 
-        /// File Downloasd
+        /// File Download
         /// Init 
         /// </summary>
         /// <param name="dto"></param>
@@ -1369,119 +1361,9 @@ namespace OASystem.API.Controllers
         {
             if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId参数!"));
 
-            var _EnterExitCosts = await _sqlSugar.Queryable<Grp_EnterExitCost>()
-                                                .Where(it => it.IsDel == 0 && it.DiId == groupId)
-                                                .FirstAsync();
-            var _DayAndCosts = await _sqlSugar.Queryable<Grp_DayAndCost>()
-                                             .Where(it => it.IsDel == 0 && it.DiId == groupId)
-                                             .ToListAsync();
-            if (_EnterExitCosts == null) return Ok(JsonView(false, "该团组未填写出入境费用;"));
-
-            //数据源
-            var stayDatas = _DayAndCosts.Where(it => it.Type == 1).ToList();          //住宿费
-            var mealDatas = _DayAndCosts.Where(it => it.Type == 2).ToList();          //伙食费
-            var miscellaneousDatas = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
-            var tainDatas = _DayAndCosts.Where(it => it.Type == 4).ToList();          //培训费
-
-            //筛选 陪同人员 = 1
-            var groupClientList = await _sqlSugar.Queryable<Grp_TourClientList>()
-                                                 .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id)
-                                                 .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id)
-                                                 .LeftJoin<Sys_SetData>((tcl, dc, cc, sd) => tcl.ShippingSpaceTypeId == sd.Id)
-                                                 .Where(tcl => tcl.IsDel == 0 &&
-                                                               tcl.DiId == groupId &&
-                                                               tcl.IsAccompany == 1
-                                                        )
-                                                 .Select((tcl, dc, cc, sd) => new
-                                                 {
-                                                     DiId = tcl.DiId,
-                                                     CompanyId = cc.Id,
-                                                     CompanyName = cc.CompanyFullName,
-                                                     ClienId = dc.Id,
-                                                     ClientName = dc.FirstName + dc.LastName,
-                                                     SpaceId = tcl.ShippingSpaceTypeId,
-                                                     SpaceName = sd.Name
-                                                 })
-                                                 .ToListAsync();
-            if (groupClientList.Count < 1) return Ok(JsonView(false, "该团组未填写接团客户名单;"));
-
-            decimal domesticFeeTotal = 0.00M,        //境内费用
-                    economyClassFeeTotal = 0.00M,   //经济舱费用
-                    businessClassFeeTotal = 0.00M,  //公务舱费用
-                    firstClassFeeTotal = 0.00M,     //头等舱费用
-                    stayFeeTotal = 0.00M,           //住宿费
-                    mealsFeeTotal = 0.00M,          //餐食费
-                    miscellaneousFeeTotal = 0.00M,  //公杂费
-                    tainFeeTotal = 0.00M;           //培训费
-
-            //境内费用(其他费用)
-            if (_EnterExitCosts.ChoiceOne == 1) domesticFeeTotal = _EnterExitCosts.InsidePay;
-
-            //住宿费
-            if (_EnterExitCosts.ChoiceThree == 1) stayFeeTotal = stayDatas.Sum(x => x.SubTotal);
-
-            //伙食费
-            if (_EnterExitCosts.ChoiceFour == 1) mealsFeeTotal = mealDatas.Sum(x => x.SubTotal);
-
-            //公杂费
-            if (_EnterExitCosts.ChoiceFive == 1) miscellaneousFeeTotal = miscellaneousDatas.Sum(x => x.SubTotal);
-
-            //培训费
-            if (_EnterExitCosts.ChoiceSix == 1) tainFeeTotal = tainDatas.Sum(x => x.SubTotal);
-
-            decimal otherFeeTotal = domesticFeeTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
-            //国际旅费合计
-            //经济舱
-            if (_EnterExitCosts.SumJJC == 1) economyClassFeeTotal = _EnterExitCosts.OutsideJJPay + otherFeeTotal;
-            //公务舱
-            if (_EnterExitCosts.SumGWC == 1) businessClassFeeTotal = _EnterExitCosts.OutsideGWPay + otherFeeTotal;
-            //头等舱
-            if (_EnterExitCosts.SumTDC == 1) firstClassFeeTotal = _EnterExitCosts.OutsideTDPay + otherFeeTotal;
-
-            var groupClientListGroup = groupClientList.GroupBy(x => x.CompanyId);
-
-            var _view = new List<ProceedsReceivedNewView>();
-            foreach (var item in groupClientListGroup)
-            {
-                string companyName = item.FirstOrDefault().CompanyName;
-                var airTicketGroup = item.GroupBy(x => x.SpaceId);
-
-                foreach (var airTicket in airTicketGroup)
-                {
-                    int quantity = airTicket.Count();
-                    if (quantity > 0)
-                    {
-                        decimal price = 0.00M;
-                        string spaceName = airTicket.FirstOrDefault()?.SpaceName ?? string.Empty;
-                        if (spaceName.Equals("经济舱")) price = economyClassFeeTotal;
-                        else if (spaceName.Equals("公务舱")) price = businessClassFeeTotal;
-                        else if (spaceName.Equals("头等舱")) price = firstClassFeeTotal;
-
-                        if (price > 0)
-                        {
-                            decimal itemTotal = price * quantity;
-
-                            _view.Add(new ProceedsReceivedNewView()
-                            {
-                                Id = 0,
-                                CreateTime = DateTime.Now,
-                                Diid = groupId,
-                                PriceName = $"{companyName}-{spaceName}",
-                                Price = price,
-                                Count = quantity,
-                                Unit = "人",
-                                ItemSumPrice = itemTotal,
-                                Currency = 836,
-                                Rate = 1.0000M,
-                                AddingWay = 2,
-                                Remark = "由出入境费用导入费用",
-                            });
-                        }
-                    }
-                }
-            }
-
-            return Ok(JsonView(true, "操作成功", _view));
+            var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
+            var view = _mapper.Map<List<ProceedsReceivedNewView>>(data);
+            return Ok(JsonView(true, "操作成功", view));
         }
         #endregion
 

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

@@ -35,6 +35,7 @@ using System.Globalization;
 using System.IO;
 using System.Reflection.PortableExecutable;
 using Ubiety.Dns.Core;
+using static OASystem.API.OAMethodLib.JWTHelper;
 using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
 using Bookmark = Aspose.Words.Bookmark;
 using Cell = Aspose.Words.Tables.Cell;
@@ -6534,6 +6535,38 @@ FROM
             }
         }
 
+        /// <summary>
+        /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
+        /// 注:Get 请求Headers 加 Token
+        /// </summary>
+        /// <param name="groupId"></param>
+        /// <returns></returns>
+        [HttpGet("{groupId}")]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
+        {
+            var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
+            if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
+
+            var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
+            data.ForEach(x =>
+            {
+                x.CreateUserId = _currUserInfo.UserId;
+            });
+
+            if (data.Count > 0)
+            {
+                var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
+                if (add > 0)
+                {
+                    return Ok(JsonView(true, "操作成功!"));
+                }
+            }
+
+            return Ok(JsonView(false, "未操作!"));
+        }
+
+
         #endregion
 
         #region 签证费用录入

+ 38 - 39
OASystem/OASystem.Api/Controllers/PersonnelModuleController.cs

@@ -1796,9 +1796,9 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> GoodsList(GoodsListDTO dto)
+        public async Task<IActionResult> GoodsList(GoodsListDto dto)
         {
-            if (dto.PortType > 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
+            if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
             if (dto.PageIndex < 1 || dto.PageSize < 1) return Ok(JsonView(false, MsgTips.PageIndex));
 
             return Ok(await _goodsRep.GoodsList(dto));
@@ -1813,7 +1813,7 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> GoodsInfo(int portType, int id)
         {
-            if (portType > 1 || portType > 3) return Ok(JsonView(false, MsgTips.Port));
+            if (portType < 1 || portType > 3) return Ok(JsonView(false, MsgTips.Port));
             if (id < 1) return Ok(JsonView(false, MsgTips.Id));
 
             return Ok(await _goodsRep.GoodsInfo(portType, id));
@@ -1826,10 +1826,10 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> GoodsOP(GoodsOPDTO dto)
+        public async Task<IActionResult> GoodsOP(GoodsOpDto dto)
         {
-            var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
-            if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
+            var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
+            if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
 
             var validator = new GoodsOPDTOValidator();
             var validatorRes = await validator.ValidateAsync(dto);
@@ -1840,7 +1840,7 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, sb.ToString()));
             }
 
-            return Ok(await _goodsRep.GoodsOp(dto, _currUserInfo.UserId));
+            return Ok(await _goodsRep.GoodsOp(dto, currUserInfo.UserId));
         }
 
         /// <summary>
@@ -1854,10 +1854,10 @@ namespace OASystem.API.Controllers
         {
             if (id < 1) return Ok(JsonView(false, MsgTips.Id));
 
-            var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
-            if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
+            var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
+            if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
 
-            return Ok(await _goodsRep.GoodsDel(id, _currUserInfo.UserId));
+            return Ok(await _goodsRep.GoodsDel(id, currUserInfo.UserId));
         }
 
         /// <summary>
@@ -1867,9 +1867,9 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> GoodsStorageList(GoodsStorageListDTO dto)
+        public async Task<IActionResult> GoodsStorageList(GoodsStorageListDto dto)
         {
-            if (dto.PortType > 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
+            if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
             if (dto.PageIndex < 1 || dto.PageSize < 1) return Ok(JsonView(false, MsgTips.PageIndex));
 
             return Ok(await _goodsRep.GoodsStorageList(dto));
@@ -1884,7 +1884,7 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> GoodsStorageInfo([FromQuery] int portType, int id)
         {
-            if (portType > 1 || portType > 3) return Ok(JsonView(false, MsgTips.Port));
+            if (portType < 1 || portType > 3) return Ok(JsonView(false, MsgTips.Port));
             if (id < 1) return Ok(JsonView(false, MsgTips.Id));
 
             return Ok(await _goodsRep.GoodsStorageInfo(portType, id));
@@ -1924,12 +1924,12 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> GoodsStorageDel(int id)
         {
-            var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
-            if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
+            var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
+            if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
 
             if (id < 1) return Ok(JsonView(false, MsgTips.Id));
 
-            return Ok(await _goodsRep.GoodsStorageDel(id, _currUserInfo.UserId));
+            return Ok(await _goodsRep.GoodsStorageDel(id, currUserInfo.UserId));
         }
 
         /// <summary>
@@ -1941,7 +1941,7 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> GoodsReceiveList(GoodsReceiveListDTO dto)
         {
-            if (dto.PortType > 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
+            if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
             if (dto.PageIndex < 1 || dto.PageSize < 1) return Ok(JsonView(false, MsgTips.PageIndex));
 
             return Ok(await _goodsRep.GoodsReceiveList(dto));
@@ -1956,7 +1956,7 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> GoodsReceiveInfo([FromQuery] int portType, int id)
         {
-            if (portType > 1 || portType > 3) return Ok(JsonView(false, MsgTips.Port));
+            if (portType < 1 || portType > 3) return Ok(JsonView(false, MsgTips.Port));
             if (id < 1) return Ok(JsonView(false, MsgTips.Id));
 
             return Ok(await _goodsRep.GoodsReceiveInfo(portType, id));
@@ -1969,21 +1969,21 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> GoodsReceiveOP(GoodsReceiveOPDTO dto)
+        public async Task<IActionResult> GoodsReceiveOP(GoodsReceiveOpDto dto)
         {
-            var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
-            if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
+            var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
+            if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
 
-            var vadalitor = new GoodsReceiveOPDTOValidator();
-            var vadalitorRes = await vadalitor.ValidateAsync(dto);
-            if (!vadalitorRes.IsValid)
+            var validator = new GoodsReceiveOpDtoValidator();
+            var validatorRes = await validator.ValidateAsync(dto);
+            if (!validatorRes.IsValid)
             {
                 var sb = new StringBuilder();
-                foreach (var error in vadalitorRes.Errors) sb.AppendLine(error.ErrorMessage);
+                foreach (var error in validatorRes.Errors) sb.AppendLine(error.ErrorMessage);
                 return Ok(JsonView(false, sb.ToString()));
             }
 
-            return Ok(await _goodsRep.GoodsReceiveOp(dto, _currUserInfo.UserId));
+            return Ok(await _goodsRep.GoodsReceiveOp(dto, currUserInfo.UserId));
         }
 
         /// <summary>
@@ -1996,27 +1996,26 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> GoodsReceiveAudit(GoodsReceiveAuditDTO dto)
         {
-            var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
-            if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
+            var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
+            if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
 
-            var vadalitor = new GoodsReceiveAuditDTOValidator();
-            var vadalitorRes = await vadalitor.ValidateAsync(dto);
-            if (!vadalitorRes.IsValid)
+            var validator = new GoodsReceiveAuditDTOValidator();
+            var validatorRes = await validator.ValidateAsync(dto);
+            if (!validatorRes.IsValid)
             {
                 var sb = new StringBuilder();
-                foreach (var error in vadalitorRes.Errors) sb.AppendLine(error.ErrorMessage);
+                foreach (var error in validatorRes.Errors) sb.AppendLine(error.ErrorMessage);
                 return Ok(JsonView(false, sb.ToString()));
             }
             int[] idArray = dto.Label
                                 .Split(',')
                                 .Select(x =>
                                 {
-                                    int id;
-                                    if (int.TryParse(x, out id)) return id;
-                                    else return id;
+                                    if (int.TryParse(x, out var id)) return id; 
+                                    return id;
                                 })
                                 .ToArray();
-            return Ok(await _goodsRep.GoodsReceiveAudit(idArray, _currUserInfo.UserId, dto.AuditEnum));
+            return Ok(await _goodsRep.GoodsReceiveAudit(idArray, currUserInfo.UserId, dto.AuditEnum));
         }
 
         /// <summary>
@@ -2028,12 +2027,12 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> GoodsReceiveDel(int id)
         {
-            var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
-            if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
+            var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
+            if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
 
             if (id < 1) return Ok(JsonView(false, MsgTips.Id));
 
-            return Ok(await _goodsRep.GoodsReceiveDel(id, _currUserInfo.UserId));
+            return Ok(await _goodsRep.GoodsReceiveDel(id, currUserInfo.UserId));
         }
         #endregion
     }

+ 255 - 132
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -433,17 +433,17 @@ namespace OASystem.API.OAMethodLib
         /// <returns></returns>
         public static async Task<List<Web_ShareGroupInfoView>> PostOperationAuthReturnGroupInfosAsync(int userId, int CTable)
         {
-            List<Web_ShareGroupInfoView> _ShareGroupInfoViews = new List<Web_ShareGroupInfoView>();
-            var taskDatas = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(it => it.UId == userId && it.CTId == CTable && it.IsDel == 0).ToList();
+           var shareGroupInfoViews = new List<Web_ShareGroupInfoView>();
+            var taskData = _dirRep._sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(it => it.UId == userId && it.CTId == CTable && it.IsDel == 0).ToList();
 
-            if (taskDatas.Count < 1) return _ShareGroupInfoViews;
+            if (taskData.Count < 1) return shareGroupInfoViews;
 
-            string diIds = string.Join(",", taskDatas.Select(it => it.DIId).ToList());
-            string sql = string.Format(@"Select Id,TeamName,TourCode,ClientName,VisitCountry,VisitStartDate,VisitEndDate,VisitDays,VisitPNumber 
+            var diIds = string.Join(",", taskData.Select(it => it.DIId).ToList());
+            var sql = string.Format(@"Select Id,TeamName,TourCode,ClientName,VisitCountry,VisitStartDate,VisitEndDate,VisitDays,VisitPNumber 
                                             From Grp_DelegationInfo Where Id In({0}) And IsDel = 0 Order By Id Desc", diIds);
-            _ShareGroupInfoViews = await _dirRep._sqlSugar.SqlQueryable<Web_ShareGroupInfoView>(sql).ToListAsync();
+            shareGroupInfoViews = await _dirRep._sqlSugar.SqlQueryable<Web_ShareGroupInfoView>(sql).ToListAsync();
 
-            return _ShareGroupInfoViews;
+            return shareGroupInfoViews;
         }
 
         #endregion
@@ -589,7 +589,7 @@ namespace OASystem.API.OAMethodLib
                 return result;
             }
 
-            var userDatas = await _teamRateRep._sqlSugar
+            var usersData = await _teamRateRep._sqlSugar
                                               .Queryable<Sys_Users>()
                                               .LeftJoin<Sys_Department>((su, sd) => su.DepId == sd.Id && sd.IsDel == 0)
                                               .LeftJoin<Sys_JobPost>((su, sd, sjp) => su.JobPostId == sjp.Id && sjp.IsDel == 0)
@@ -606,9 +606,9 @@ namespace OASystem.API.OAMethodLib
                                               .ToListAsync();
 
             /*
-             * 76  酒店预订  --> 国交部门 酒店 岗位
+             * 76  酒店预订  --> 国交部门 酒店,主管 岗位
              * 77  行程  --> 国交部门 经理,主管 岗位
-             * 79  车/导游地接  --> 国交部门 OP 岗位
+             * 79  车/导游地接  --> 国交部门 OP,主管 岗位
              * 80  签证  --> 国交部门 签证 岗位
              * 81  邀请/公务活动 --> 国交部门 商邀 岗位
              * 82  团组客户保险 --> 国交部 经理,主管 岗位
@@ -617,11 +617,11 @@ namespace OASystem.API.OAMethodLib
              * 1015 超支费用,69 收款退还  --> 财务部门(ALL)岗位
              * 1015 超支费用  --> 国交部(ALL)岗位
              */
-            List<Grp_GroupsTaskAssignment> _GroupsTaskAssignments = new List<Grp_GroupsTaskAssignment>();
-            // 76  酒店预订  --> 国交部门(7) 酒店(25) 岗位 
-            _GroupsTaskAssignments.AddRange(
-                userDatas
-                .Where(it => it.DepId == 7 && it.JobPostId == 25)
+            var groupsTaskAssignments = new List<Grp_GroupsTaskAssignment>();
+            // 76  酒店预订  --> 国交部门(7) 酒店(25)、主管(22) 岗位 
+            groupsTaskAssignments.AddRange(
+                usersData
+                .Where(it => it.DepId == 7 && (it.JobPostId == 25 || it.JobPostId == 22))
                 .Select(it => new Grp_GroupsTaskAssignment()
                 {
                     DIId = diId,
@@ -632,8 +632,8 @@ namespace OASystem.API.OAMethodLib
             );
 
             // 77  行程  --> 国交部门(7) 经理(32),主管(22) 岗位
-            _GroupsTaskAssignments.AddRange(
-                userDatas
+            groupsTaskAssignments.AddRange(
+                usersData
                 .Where(it => it.DepId == 7 && (it.JobPostId == 22 || it.JobPostId == 32))
                 .Select(it => new Grp_GroupsTaskAssignment()
                 {
@@ -644,9 +644,9 @@ namespace OASystem.API.OAMethodLib
                 }).ToList()
             );
 
-            //79  车/导游地接  --> 国交部门(7) OP(28) 岗位
-            _GroupsTaskAssignments.AddRange(
-                userDatas.Where(it => it.DepId == 7 && it.JobPostId == 28)
+            //79  车/导游地接  --> 国交部门(7) OP(28)、主管(22) 岗位
+            groupsTaskAssignments.AddRange(
+                usersData.Where(it => it.DepId == 7 && (it.JobPostId == 22 || it.JobPostId == 28))
                 .Select(it => new Grp_GroupsTaskAssignment()
                 {
                     DIId = diId,
@@ -656,10 +656,9 @@ namespace OASystem.API.OAMethodLib
                 }).ToList()
             );
 
-
             //81  邀请/公务活动 --> 国交部门(7) 商邀(27) 岗位
-            _GroupsTaskAssignments.AddRange(
-                userDatas.Where(it => it.DepId == 7 && it.JobPostId == 27)
+            groupsTaskAssignments.AddRange(
+                usersData.Where(it => it.DepId == 7 && it.JobPostId == 27)
                 .Select(it => new Grp_GroupsTaskAssignment()
                 {
                     DIId = diId,
@@ -670,7 +669,7 @@ namespace OASystem.API.OAMethodLib
             );
 
             //2024年8月26日16点27分 “邀请公务活动分配给王鸽(UserID:149)”
-            _GroupsTaskAssignments.Add(
+            groupsTaskAssignments.Add(
                  new Grp_GroupsTaskAssignment()
                  {
                      DIId = diId,
@@ -680,10 +679,9 @@ namespace OASystem.API.OAMethodLib
                  }
             );
 
-
             //80  签证  --> 国交部门(7) 签证(26) 岗位
-            _GroupsTaskAssignments.AddRange(
-                userDatas
+            groupsTaskAssignments.AddRange(
+                usersData
                 .Where(it => it.DepId == 7 && it.JobPostId == 26)
                 .Select(it => new Grp_GroupsTaskAssignment()
                 {
@@ -694,13 +692,11 @@ namespace OASystem.API.OAMethodLib
                 }).ToList()
             );
 
-
             //82  团组客户保险 --> 国交部(7) 经理(32),主管(22) 岗位
             //2024-06-25 默认将保险权限分配给签证岗。 签证(26) 岗位
-
             List<int> insurancePositions = new List<int>() { 32, 22, 26 };
-            _GroupsTaskAssignments.AddRange(
-                userDatas
+            groupsTaskAssignments.AddRange(
+                usersData
                 .Where(it => it.DepId == 7 && insurancePositions.Contains(it.JobPostId))
                 .Select(it => new Grp_GroupsTaskAssignment()
                 {
@@ -711,10 +707,10 @@ namespace OASystem.API.OAMethodLib
                 }).ToList()
             );
 
-            //85  机票预订  --> 国交部门(7) 机票(24) 岗位
-            _GroupsTaskAssignments.AddRange(
-                userDatas
-                .Where(it => it.DepId == 7 && it.JobPostId == 24)
+            //85  机票预订  --> 国交部门(7) 机票(24),主管(22) 岗位
+            groupsTaskAssignments.AddRange(
+                usersData
+                .Where(it => it.DepId == 7 && (it.JobPostId == 22 || it.JobPostId == 24))
                 .Select(it => new Grp_GroupsTaskAssignment()
                 {
                     DIId = diId,
@@ -726,10 +722,10 @@ namespace OASystem.API.OAMethodLib
 
 
             //98  其他款项  --> 总经办部门(1) 总经理(1) 岗位/国交部门(7)(ALL) 岗位/财务部门(3)(ALL) 岗位/策划部门(5)(ALL) 岗位/人事部门(4) 采购(74) 岗位
-            List<int> depIds = new List<int>() { 7, 3, 5 };
-            List<int> jobIds = new List<int>() { 1, 74 };
-            _GroupsTaskAssignments.AddRange(
-                userDatas
+           var depIds = new List<int>() { 7, 3, 5 };
+           var jobIds = new List<int>() { 1, 74 };
+            groupsTaskAssignments.AddRange(
+                usersData
                 .Where(it => depIds.Contains(it.DepId) || jobIds.Contains(it.JobPostId))
                 .Select(it => new Grp_GroupsTaskAssignment()
                 {
@@ -741,7 +737,7 @@ namespace OASystem.API.OAMethodLib
             );
 
             //2024年8月26日16点27分 “其他款项分配给王鸽(UserID:149)”
-            _GroupsTaskAssignments.Add(new Grp_GroupsTaskAssignment()
+            groupsTaskAssignments.Add(new Grp_GroupsTaskAssignment()
             {
                 DIId = diId,
                 CTId = 98,
@@ -751,8 +747,8 @@ namespace OASystem.API.OAMethodLib
             );
 
             //1015 超支费用,285 收款退还  --> 财务部门(ALL)岗位
-            _GroupsTaskAssignments.AddRange(
-                userDatas
+            groupsTaskAssignments.AddRange(
+                usersData
                 .Where(it => it.DepId == 3)
                 .Select(it => new Grp_GroupsTaskAssignment()
                 {
@@ -763,8 +759,8 @@ namespace OASystem.API.OAMethodLib
                 }).ToList()
             );
 
-            _GroupsTaskAssignments.AddRange(
-               userDatas
+            groupsTaskAssignments.AddRange(
+                usersData
                .Where(it => it.DepId == 3)
                .Select(it => new Grp_GroupsTaskAssignment()
                {
@@ -776,8 +772,8 @@ namespace OASystem.API.OAMethodLib
            );
 
             //1015 超支费用  --> 国交部(ALL)岗位
-            _GroupsTaskAssignments.AddRange(
-              userDatas
+            groupsTaskAssignments.AddRange(
+                usersData
               .Where(it => it.DepId == 7)
               .Select(it => new Grp_GroupsTaskAssignment()
               {
@@ -788,9 +784,9 @@ namespace OASystem.API.OAMethodLib
               }).ToList()
           );
 
-            if (_GroupsTaskAssignments.Count > 0)
+            if (groupsTaskAssignments.Count > 0)
             {
-                var addId = _teamRateRep._sqlSugar.Insertable(_GroupsTaskAssignments).ExecuteCommand();
+                var addId = await _teamRateRep._sqlSugar.Insertable(groupsTaskAssignments).ExecuteCommandAsync();
             }
 
             result.Code = 0;
@@ -802,7 +798,6 @@ namespace OASystem.API.OAMethodLib
 
         #endregion
 
-
         #region 员工是否是市场部人员
 
         /// <summary>
@@ -824,6 +819,134 @@ namespace OASystem.API.OAMethodLib
 
         #endregion
 
+        #region 三公费用相关
+
+        /// <summary>
+        /// 三公费用导入首款账单数据
+        /// </summary>
+        /// <param name="groupId"></param>
+        /// <returns></returns>
+        public static async Task<List<Fin_ForeignReceivables>> ReceivablesImportFeeAsync(int groupId)
+        {
+            var data = new List<Fin_ForeignReceivables>();
+
+            var enterExitCosts = await _sqlSugar.Queryable<Grp_EnterExitCost>()
+                                                .Where(it => it.IsDel == 0 && it.DiId == groupId)
+                                                .FirstAsync();
+            var dayAndCosts = await _sqlSugar.Queryable<Grp_DayAndCost>()
+                                             .Where(it => it.IsDel == 0 && it.DiId == groupId)
+                                             .ToListAsync();
+            if (enterExitCosts == null) return data;
+
+            //数据源
+            var stayData = dayAndCosts.Where(it => it.Type == 1).ToList();          //住宿费
+            var mealData = dayAndCosts.Where(it => it.Type == 2).ToList();          //伙食费
+            var miscellaneousData =dayAndCosts.Where(it => it.Type == 3).ToList();  //公杂费
+            var trainData = dayAndCosts.Where(it => it.Type == 4).ToList();         //培训费
+
+            //筛选 陪同人员 = 1
+            var groupClientList = await _sqlSugar.Queryable<Grp_TourClientList>()
+                                                 .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id)
+                                                 .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id)
+                                                 .LeftJoin<Sys_SetData>((tcl, dc, cc, sd) => tcl.ShippingSpaceTypeId == sd.Id)
+                                                 .Where(tcl => tcl.IsDel == 0 &&
+                                                               tcl.DiId == groupId &&
+                                                               tcl.IsAccompany == 1
+                                                        )
+                                                 .Select((tcl, dc, cc, sd) => new
+                                                 {
+                                                     DiId = tcl.DiId,
+                                                     CompanyId = cc.Id,
+                                                     CompanyName = cc.CompanyFullName,
+                                                     ClienId = dc.Id,
+                                                     ClientName = dc.FirstName + dc.LastName,
+                                                     SpaceId = tcl.ShippingSpaceTypeId,
+                                                     SpaceName = sd.Name
+                                                 })
+                                                 .ToListAsync();
+            if (groupClientList.Count < 1) return data;
+
+            decimal domesticFeeTotal = 0.00M,        //境内费用
+                    economyClassFeeTotal = 0.00M,    //经济舱费用
+                    businessClassFeeTotal = 0.00M,   //公务舱费用
+                    firstClassFeeTotal = 0.00M,      //头等舱费用
+                    stayFeeTotal = 0.00M,            //住宿费
+                    mealsFeeTotal = 0.00M,           //餐食费
+                    miscellaneousFeeTotal = 0.00M,   //公杂费
+                    trainFeeTotal = 0.00M;           //培训费
+
+            //境内费用(其他费用)
+            if (enterExitCosts.ChoiceOne == 1) domesticFeeTotal = enterExitCosts.InsidePay;
+
+            //住宿费
+            if (enterExitCosts.ChoiceThree == 1) stayFeeTotal = stayData.Sum(x => x.SubTotal);
+
+            //伙食费
+            if (enterExitCosts.ChoiceFour == 1) mealsFeeTotal = mealData.Sum(x => x.SubTotal);
+
+            //公杂费
+            if (enterExitCosts.ChoiceFive == 1) miscellaneousFeeTotal = miscellaneousData.Sum(x => x.SubTotal);
+
+            //培训费
+            if (enterExitCosts.ChoiceSix == 1) trainFeeTotal = trainData.Sum(x => x.SubTotal);
+
+            decimal otherFeeTotal = domesticFeeTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainFeeTotal;
+            //国际旅费合计
+            //经济舱
+            if (enterExitCosts.SumJJC == 1) economyClassFeeTotal = enterExitCosts.OutsideJJPay + otherFeeTotal;
+            //公务舱
+            if (enterExitCosts.SumGWC == 1) businessClassFeeTotal = enterExitCosts.OutsideGWPay + otherFeeTotal;
+            //头等舱
+            if (enterExitCosts.SumTDC == 1) firstClassFeeTotal = enterExitCosts.OutsideTDPay + otherFeeTotal;
+
+            var groupClientListGroup = groupClientList.GroupBy(x => x.CompanyId);
+
+            foreach (var item in groupClientListGroup)
+            {
+                var companyName = item.FirstOrDefault().CompanyName;
+                var airTicketGroup = item.GroupBy(x => x.SpaceId);
+
+                foreach (var airTicket in airTicketGroup)
+                {
+                    int quantity = airTicket.Count();
+                    if (quantity > 0)
+                    {
+                        var price = 0.00M;
+                        var spaceName = airTicket.FirstOrDefault()?.SpaceName ?? string.Empty;
+                        if (spaceName.Equals("经济舱")) price = economyClassFeeTotal;
+                        else if (spaceName.Equals("公务舱")) price = businessClassFeeTotal;
+                        else if (spaceName.Equals("头等舱")) price = firstClassFeeTotal;
+
+                        if (price > 0)
+                        {
+                            decimal itemTotal = price * quantity;
+
+                            data.Add(new Fin_ForeignReceivables()
+                            {
+                                Id = 0,
+                                CreateTime = DateTime.Now,
+                                Diid = groupId,
+                                PriceName = $"{companyName}-{spaceName}",
+                                Price = price,
+                                Count = quantity,
+                                Unit = "人",
+                                ItemSumPrice = itemTotal,
+                                Currency = 836,
+                                Rate = 1.0000M,
+                                AddingWay = 2,
+                                Remark = "由出入境费用导入费用",
+                            });
+                        }
+                    }
+                }
+            }
+
+
+            return data;
+        }
+
+        #endregion
+
         #endregion
 
         #region 团组汇率
@@ -2988,19 +3111,19 @@ namespace OASystem.API.OAMethodLib
 
             try
             {
-                var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
-                var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
-                if (_EnterExitCosts == null)
+                var enterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
+                var dayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
+                if (enterExitCosts == null)
                 {
                     _view.Msg = @"该团组未填写出入境费用;";
                     return _view;
                 }
 
                 //数据源
-                List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
-                List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
-                List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
-                List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
+                List<Grp_DayAndCost> dac1 = dayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
+                List<Grp_DayAndCost> dac2 = dayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
+                List<Grp_DayAndCost> dac3 = dayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
+                List<Grp_DayAndCost> dac4 = dayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
 
                 var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
                 var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
@@ -3020,7 +3143,7 @@ namespace OASystem.API.OAMethodLib
                 var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
                 var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
                 var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
-                var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
+                var rateDatas = await enterExitCosts.CurrencyRemark.SplitExchangeRate();
 
 
                 _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
@@ -3043,51 +3166,51 @@ namespace OASystem.API.OAMethodLib
                         //利用键值对存放数据
                         Dictionary<string, string> dic = new Dictionary<string, string>();
 
-                        decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal);  // 住宿费
-                        decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal);  // 伙食费费
-                        decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal);  // 公杂费
-                        decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal);  // 培训费
+                        decimal stayFeeTotal = dayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal);  // 住宿费
+                        decimal mealsFeeTotal = dayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal);  // 伙食费费
+                        decimal miscellaneousFeeTotal = dayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal);  // 公杂费
+                        decimal tainFeeTotal = dayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal);  // 培训费
 
-                        decimal insidePayTotal = _EnterExitCosts.InsidePay;
+                        decimal insidePayTotal = enterExitCosts.InsidePay;
 
                         string row1_1 = "";
-                        if (_EnterExitCosts.Visa > 0)
+                        if (enterExitCosts.Visa > 0)
                         {
-                            //insidePayTotal += _EnterExitCosts.Visa;
-                            row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
-                            if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
+                            //insidePayTotal += enterExitCosts.Visa;
+                            row1_1 = $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 人民币/人";
+                            if (!string.IsNullOrEmpty(enterExitCosts.VisaRemark))
                             {
-                                row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark}";
+                                row1_1 += $"\t签证费用描述: {enterExitCosts.VisaRemark}";
                             }
                         }
 
                         string row1_2 = "";
-                        if (_EnterExitCosts.YiMiao > 0)
+                        if (enterExitCosts.YiMiao > 0)
                         {
-                            //insidePayTotal += _EnterExitCosts.YiMiao;
-                            row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
+                            //insidePayTotal += enterExitCosts.YiMiao;
+                            row1_2 += $"疫苗费:{enterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
                         }
-                        if (_EnterExitCosts.HeSuan > 0)
+                        if (enterExitCosts.HeSuan > 0)
                         {
-                            //insidePayTotal += _EnterExitCosts.HeSuan;
-                            row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
+                            //insidePayTotal += enterExitCosts.HeSuan;
+                            row1_2 += $"核酸检测费:{enterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
                         }
-                        if (_EnterExitCosts.Service > 0)
+                        if (enterExitCosts.Service > 0)
                         {
-                            //insidePayTotal += _EnterExitCosts.Service;
-                            row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
+                            //insidePayTotal += enterExitCosts.Service;
+                            row1_2 += $"服务费:{enterExitCosts.Service.ToString("#0.00")} 人民币/人";
                         }
 
                         string row1_3 = "";
-                        if (_EnterExitCosts.Safe > 0)
+                        if (enterExitCosts.Safe > 0)
                         {
-                            //insidePayTotal += _EnterExitCosts.Safe;
-                            row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
+                            //insidePayTotal += enterExitCosts.Safe;
+                            row1_3 += $"保险费:{enterExitCosts.Safe.ToString("#0.00")} 人民币/人";
                         }
-                        if (_EnterExitCosts.Ticket > 0)
+                        if (enterExitCosts.Ticket > 0)
                         {
-                            //insidePayTotal += _EnterExitCosts.Ticket;
-                            row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
+                            //insidePayTotal += enterExitCosts.Ticket;
+                            row1_3 += $"参展门票:{enterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
                         }
                         string row1 = "";
                         if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
@@ -3097,11 +3220,11 @@ namespace OASystem.API.OAMethodLib
                         dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
                         dic.Add("Row1Str", row1);
 
-                        dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
-                        dic.Add("OutsaideGW", _EnterExitCosts.OutsideGWPay.ToString("#0.00"));
-                        dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
-                        dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
-                        dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
+                        dic.Add("OutsideJJ", enterExitCosts.OutsideJJPay.ToString("#0.00"));
+                        dic.Add("OutsaideGW", enterExitCosts.OutsideGWPay.ToString("#0.00"));
+                        dic.Add("AirJJ", enterExitCosts.AirJJ.ToString("#0.00"));
+                        dic.Add("AirGW", enterExitCosts.AirGW.ToString("#0.00"));
+                        dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
                         dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
                         dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
 
@@ -3109,8 +3232,8 @@ namespace OASystem.API.OAMethodLib
                         dic.Add("SubGZF", miscellaneousFeeTotalStr);
                         //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
 
-                        decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
-                        decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideGWPay;
+                        decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + enterExitCosts.OutsideJJPay;
+                        decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + enterExitCosts.OutsideGWPay;
                         dic.Add("SubJJC", subJJC.ToString("#0.00"));
                         dic.Add("SubGWC", subGWC.ToString("#0.00"));
 
@@ -3446,12 +3569,12 @@ namespace OASystem.API.OAMethodLib
                         }
 
 
-                        dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
+                        dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
 
                         string otherFeeStr = "";
-                        if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
-                        if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
-                        if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
+                        if (enterExitCosts.Visa > 0) otherFeeStr += $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 元,";
+                        if (enterExitCosts.Safe > 0) otherFeeStr += $"保险费: {enterExitCosts.Safe.ToString("#0.00")} 元,";
+                        if (enterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {enterExitCosts.Ticket.ToString("#0.00")} 元,";
 
                         if (otherFeeStr.Length > 0)
                         {
@@ -3462,25 +3585,25 @@ namespace OASystem.API.OAMethodLib
                         }
 
                         //总计
-                        decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
+                        decimal allPrice = dac1totalPrice + dac2totalPrice + enterExitCosts.Visa + enterExitCosts.Safe + enterExitCosts.Ticket;
 
                         //国际旅费
                         string outsideJJ = "";
                         string allPriceJJ = "";
-                        if (_EnterExitCosts.SumJJC == 1)
+                        if (enterExitCosts.SumJJC == 1)
                         {
-                            outsideJJ = string.Format(@"经济舱:{0} 元/人", _EnterExitCosts.AirJJ.ToString("#0.00"));
-                            allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
+                            outsideJJ = string.Format(@"经济舱:{0} 元/人", enterExitCosts.AirJJ.ToString("#0.00"));
+                            allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + enterExitCosts.OutsideJJPay).ToString("#0.00"));
                         }
                         string outsideGW = "";
                         string allPriceGW = "";
-                        if (_EnterExitCosts.SumGWC == 1)
+                        if (enterExitCosts.SumGWC == 1)
                         {
-                            outsideGW = string.Format(@"公务舱:{0} 元/人", _EnterExitCosts.AirGW.ToString("#0.00"));
-                            allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
+                            outsideGW = string.Format(@"公务舱:{0} 元/人", enterExitCosts.AirGW.ToString("#0.00"));
+                            allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + enterExitCosts.OutsideGWPay).ToString("#0.00"));
                         }
 
-                        if (_EnterExitCosts.SumJJC == 1 || _EnterExitCosts.SumGWC == 1)
+                        if (enterExitCosts.SumJJC == 1 || enterExitCosts.SumGWC == 1)
                         {
                             string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
                             dic.Add("InTravelPrice", InTravelPriceStr);
@@ -3489,9 +3612,9 @@ namespace OASystem.API.OAMethodLib
                             dic.Add("FinalSumPrice", FinalSumPriceStr);
                         }
 
-                        //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
-                        //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
-                        //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
+                        //dic.Add("VisaPay", enterExitCosts.Visa.ToString("#0.00"));
+                        //dic.Add("SafePay", enterExitCosts.Safe.ToString("#0.00"));
+                        //dic.Add("YiMiao", enterExitCosts.YiMiao.ToString("#0.00"));
 
                         foreach (var key in dic.Keys)
                         {
@@ -3667,18 +3790,18 @@ namespace OASystem.API.OAMethodLib
 
                         designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
                         designer.SetDataSource("dac2totalPrice", dac2totalPrice);
-                        designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
-                        designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
+                        designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {enterExitCosts.CityTranffic.ToString("#0.00")} 元");
+                        designer.SetDataSource("sumCityTranffic", @$"{enterExitCosts.CityTranffic.ToString("#0.00")} ");
 
 
-                        string cell4Str = $"  4.国际旅费:经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人";
+                        string cell4Str = $"  4.国际旅费:经济舱:{enterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{enterExitCosts.AirGW.ToString("#0.00")} 元/人";
                         string cellStr = $"  5.其他费用(";
-                        if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
-                        if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
-                        if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
-                        if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
-                        if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
-                        if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
+                        if (enterExitCosts.Visa > 0) cellStr += $"签证费:{enterExitCosts.Visa.ToString("#0.00")}元,";
+                        if (enterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{enterExitCosts.YiMiao.ToString("#0.00")}元,";
+                        if (enterExitCosts.HeSuan > 0) cellStr += $"核酸费:{enterExitCosts.HeSuan.ToString("#0.00")}元,";
+                        if (enterExitCosts.Safe > 0) cellStr += $"保险费:{enterExitCosts.Safe.ToString("#0.00")}元,";
+                        if (enterExitCosts.Ticket > 0) cellStr += $"参展门票费:{enterExitCosts.Ticket.ToString("#0.00")}元,";
+                        if (enterExitCosts.Service > 0) cellStr += $"服务费:{enterExitCosts.Service.ToString("#0.00")}元,";
                         if (cellStr.Length > 8)
                         {
                             cellStr = cellStr.Substring(0, cellStr.Length - 1);
@@ -3686,11 +3809,11 @@ namespace OASystem.API.OAMethodLib
                         cellStr += ")";
 
 
-                        decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
-                        decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
+                        decimal otherFee = enterExitCosts.Visa + enterExitCosts.YiMiao + enterExitCosts.HeSuan + enterExitCosts.Safe + enterExitCosts.Ticket + enterExitCosts.Service;
+                        decimal s = dac1totalPrice + dac2totalPrice + enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay + otherFee;
 
                         decimal pxFee = dac4.Sum(it => it.Cost);
-                        decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
+                        decimal glvFee = enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay;
                         string celllastStr1 = "";
                         if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
                         if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
@@ -3702,8 +3825,8 @@ namespace OASystem.API.OAMethodLib
 
                         designer.SetDataSource("cell4Str", cell4Str);
                         designer.SetDataSource("cellStr", cellStr);
-                        designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
-                        designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
+                        designer.SetDataSource("cellSum", (enterExitCosts.Visa + enterExitCosts.Safe).ToString("#0.00"));
+                        designer.SetDataSource("cellSum4", (enterExitCosts.OutsideJJPay + enterExitCosts.OutsideGWPay).ToString("#0.00"));
                         designer.SetDataSource("celllastStr", celllastStr);
 
                         Workbook wb = designer.Workbook;
@@ -3879,17 +4002,17 @@ namespace OASystem.API.OAMethodLib
                         dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
                         decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
                         dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
-                        decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
+                        decimal cityTranfficFeeToatal = enterExitCosts.CityTranffic; //城市区间交通费
                         dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
                                                                                                   //其他费用
-                        decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
+                        decimal otherFeeTotal = enterExitCosts.Visa + enterExitCosts.Safe + enterExitCosts.Ticket + enterExitCosts.YiMiao + enterExitCosts.HeSuan + enterExitCosts.Service;
                         dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
 
                         //其他费用合计
                         decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
 
-                        decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
-                        decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
+                        decimal _jjcFeeToatal = enterExitCosts.AirJJ + _otherFeeTotal; //经济舱
+                        decimal _gwcFeeToatal = enterExitCosts.AirGW + _otherFeeTotal; //公务舱
 
                         //公务舱合计
 
@@ -3897,20 +4020,20 @@ namespace OASystem.API.OAMethodLib
 
                         string outsideJJ = "";
                         string allPriceJJ = "";
-                        if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
+                        if (enterExitCosts.SumJJC == 1 && enterExitCosts.SumGWC == 0)
                         {
-                            dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
+                            dic.Add("AirFeeTotal", enterExitCosts.AirJJ.ToString("#0.00"));
                             dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
                         }
-                        if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
+                        if (enterExitCosts.SumGWC == 1 && enterExitCosts.SumJJC == 0)
                         {
-                            dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
+                            dic.Add("AirFeeTotal", enterExitCosts.AirGW.ToString("#0.00"));
                             dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
                         }
 
-                        if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
+                        if (enterExitCosts.SumJJC == 1 && enterExitCosts.SumGWC == 1)
                         {
-                            string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
+                            string airFeeTotalStr = string.Format(@$"经济舱:{enterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{enterExitCosts.AirGW.ToString("#0.00")}");
                             dic.Add("AirFeeTotal", airFeeTotalStr);
                             string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
                             dic.Add("FeeTotal", feeTotalStr);
@@ -4157,12 +4280,12 @@ namespace OASystem.API.OAMethodLib
                             //}
                         }
 
-                        dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
+                        dic.Add("CityTranffic", enterExitCosts.CityTranffic.ToString("#0.00"));
 
                         string otherFeeStr = "";
-                        if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
-                        if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
-                        if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
+                        if (enterExitCosts.Visa > 0) otherFeeStr += $"签证费: {enterExitCosts.Visa.ToString("#0.00")} 元,";
+                        if (enterExitCosts.Safe > 0) otherFeeStr += $"保险费: {enterExitCosts.Safe.ToString("#0.00")} 元,";
+                        if (enterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {enterExitCosts.Ticket.ToString("#0.00")} 元,";
 
                         if (otherFeeStr.Length > 0)
                         {

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

@@ -78,6 +78,7 @@ namespace OASystem.API.OAMethodLib
             /// <returns></returns>
             public static TokenModelJwt SerializeJwt(string jwtStr)
             {
+                if (string.IsNullOrEmpty(jwtStr)) return null;
                 jwtStr = jwtStr.Replace("Bearer ", "");
                 if (string.IsNullOrEmpty(jwtStr)) return null;
                 var jwtHandler = new JwtSecurityTokenHandler();

+ 7 - 7
OASystem/OASystem.Domain/AutoMappers/_baseMappingProfile.cs

@@ -22,6 +22,7 @@ using OASystem.Domain.ViewModels.PersonnelModule;
 using OASystem.Domain.Entities.PersonnelModule;
 using OASystem.Domain.Dtos.PersonnelModule;
 using OASystem.Domain.Dtos.Statistics;
+using OASystem.Domain.ViewModels.Financial;
 
 namespace OASystem.Domain.AutoMappers
 {
@@ -163,9 +164,6 @@ namespace OASystem.Domain.AutoMappers
             CreateMap<Grp_CreditCardPayment, CreditCardView>();
             CreateMap<OpCustomersDto, Grp_Customers>();
             CreateMap<OpCustomersDto, Grp_CreditCardPayment>();
-            #region 保险费用
-
-            #endregion
 
             #region 签证提成录入
 
@@ -253,15 +251,17 @@ namespace OASystem.Domain.AutoMappers
             #endregion
             #endregion
 
-            #region Business
-            #endregion
-
             #region Financial
             CreateMap<AddDailyFeePaymentDto, Fin_DailyFeePayment>();
             CreateMap<AddDailyFeePaymentContentDto, Fin_DailyFeePaymentContent>();
             CreateMap<EditDailyFeePaymentDto, Fin_DailyFeePayment>();
             CreateMap<EditDailyFeePaymentContentDto, Fin_DailyFeePaymentContent>();
 
+            #region 收款账单
+
+
+            CreateMap<Fin_ForeignReceivables, ProceedsReceivedNewView>();
+            #endregion
             #endregion
 
             #region 人事 模块
@@ -279,7 +279,7 @@ namespace OASystem.Domain.AutoMappers
 
             #region 进销存
             CreateMap<GoodsStorageOpDto, Pm_GoodsStorage>();
-            CreateMap<GoodsReceiveOPDTO, Pm_GoodsReceive>();
+            CreateMap<GoodsReceiveOpDto, Pm_GoodsReceive>();
             #endregion
             #endregion
 

+ 8 - 8
OASystem/OASystem.Domain/Dtos/PersonnelModule/GoodsDTO.cs

@@ -11,7 +11,7 @@ namespace OASystem.Domain.Dtos.PersonnelModule
     /// <summary>
     /// 物品DTO
     /// </summary>
-    public class GoodsDTO
+    public class GoodsDto
     {
     }
 
@@ -20,7 +20,7 @@ namespace OASystem.Domain.Dtos.PersonnelModule
     /// <summary>
     /// 物品List DTO
     /// </summary>
-    public class GoodsListDTO : DtoBase
+    public class GoodsListDto : DtoBase
     {
         /// <summary>
         /// 类型Id
@@ -34,7 +34,7 @@ namespace OASystem.Domain.Dtos.PersonnelModule
     /// <summary>
     /// 物品 OP  DTO
     /// </summary>
-    public class GoodsOPDTO
+    public class GoodsOpDto
     {
         /// <summary>
         /// ID编号
@@ -63,7 +63,7 @@ namespace OASystem.Domain.Dtos.PersonnelModule
     /// 物品 OP  DTO
     /// Validator
     /// </summary>
-    public class GoodsOPDTOValidator : AbstractValidator<GoodsOPDTO>
+    public class GoodsOPDTOValidator : AbstractValidator<GoodsOpDto>
     {
         /// <summary>
         /// 初始化
@@ -85,7 +85,7 @@ namespace OASystem.Domain.Dtos.PersonnelModule
     /// <summary>
     /// 物品入库List DTO
     /// </summary>
-    public class GoodsStorageListDTO : DtoBase
+    public class GoodsStorageListDto : DtoBase
     {
         /// <summary>
         /// 物品Id
@@ -209,7 +209,7 @@ namespace OASystem.Domain.Dtos.PersonnelModule
     /// <summary>
     /// 物品领用 OP DTO
     /// </summary>
-    public class GoodsReceiveOPDTO
+    public class GoodsReceiveOpDto
     {
         /// <summary>
         /// ID
@@ -250,12 +250,12 @@ namespace OASystem.Domain.Dtos.PersonnelModule
     /// 物品领用 OP
     /// Validator
     /// </summary>
-    public class GoodsReceiveOPDTOValidator : AbstractValidator<GoodsReceiveOPDTO>
+    public class GoodsReceiveOpDtoValidator : AbstractValidator<GoodsReceiveOpDto>
     {
         /// <summary>
         /// 初始化
         /// </summary>
-        public GoodsReceiveOPDTOValidator()
+        public GoodsReceiveOpDtoValidator()
         {
             RuleFor(x => x.GoodsId).Must(x => x > 0).WithMessage("请传入有效的物品Id!");
             RuleFor(x => x.Quantity).Must(x => x > 0).WithMessage("请传入有效的物品数量!");

+ 7 - 0
OASystem/OASystem.Domain/Entities/PersonnelModule/Pm_GoodsReceive.cs

@@ -21,6 +21,13 @@ namespace OASystem.Domain.Entities.PersonnelModule
         [SugarColumn(ColumnDescription = "团组Id", IsNullable = true, ColumnDataType = "int")]
         public int GroupId { get; set; }
 
+        /// <summary>
+        /// 物资入库批次信息
+        /// {storageId:1,quantity:10}
+        /// </summary>
+        [SugarColumn(ColumnDescription = "物资入库批次信息", IsNullable = true, ColumnDataType = "varchar(200)")]
+        public string? GoodsStorageInfo { get; set; }
+
         /// <summary>
         /// 商品Id
         /// Pm_GoodsInfo Id

+ 24 - 2
OASystem/OASystem.Domain/ViewModels/PersonnelModule/GoodsInfoView.cs

@@ -57,9 +57,9 @@ namespace OASystem.Domain.ViewModels.PersonnelModule
         public int IsDel { get; set; }
     }
 
-
-    public class GoodsReceiveListView
+    public class GoodsReceiveView
     {
+
         public int Id { get; set; }
         public int GroupId { get; set; }
         public int GoodsId { get; set; }
@@ -74,6 +74,28 @@ namespace OASystem.Domain.ViewModels.PersonnelModule
         public DateTime AuditTime { get; set; }
         public string CreateUserName { get; set; }
         public DateTime CreateTime { get; set; }
+    }
+    /// <summary>
+    /// 
+    /// </summary>
+    public class GoodsReceiveListView: GoodsReceiveView
+    {
+    }
+    /// <summary>
+    /// 
+    /// </summary>
+    public class GoodsReceiveInfoView : GoodsReceiveView
+    {
+        public string GoodsStorageInfo { get; set; }
+        public object? QuantityInfos { get; set; }
+    }
 
+    /// <summary>
+    /// 
+    /// </summary>
+    public class GoodsReceiveLinkStorageView
+    {
+        public int StorageId { get; set; }
+        public decimal Quantity { get; set; }
     }
 }

+ 154 - 48
OASystem/OASystem.Infrastructure/Repositories/PersonnelModule/GoodsRepository.cs

@@ -1,8 +1,11 @@
 using AutoMapper;
+using EyeSoft.IO;
 using OASystem.Domain.Dtos.PersonnelModule;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.Entities.PersonnelModule;
 using OASystem.Domain.ViewModels.PersonnelModule;
+using System.Drawing;
+using Newtonsoft.Json;
 
 namespace OASystem.Infrastructure.Repositories.PersonnelModule
 {
@@ -75,7 +78,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
         /// </summary>
         /// <param name="dto"></param>
         /// <returns></returns>
-        public async Task<JsonView> GoodsList(GoodsListDTO dto)
+        public async Task<JsonView> GoodsList(GoodsListDto dto)
         {
             var ids = new List<int>();
             if (!string.IsNullOrEmpty(dto.TypeIds))
@@ -162,7 +165,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
         /// <param name="dto"></param>
         /// <param name="currUserId"></param>
         /// <returns></returns>
-        public async Task<JsonView> GoodsOp(GoodsOPDTO dto, int currUserId)
+        public async Task<JsonView> GoodsOp(GoodsOpDto dto, int currUserId)
         {
             var info = new Pm_GoodsInfo()
             {
@@ -274,19 +277,20 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
         /// </summary>
         /// <param name="dto"></param>
         /// <returns></returns>
-        public async Task<JsonView> GoodsStorageList(GoodsStorageListDTO dto)
+        public async Task<JsonView> GoodsStorageList(GoodsStorageListDto dto)
         {
             RefAsync<int> total = 0;
             var data = await _sqlSugar.Queryable<Pm_GoodsStorage>()
                                       .LeftJoin<Pm_GoodsInfo>((gs, gi) => gs.GoodsId == gi.Id)
                                       .LeftJoin<Sys_Users>((gs, gi, u) => gs.CreateUserId == u.Id)
-                                      .LeftJoin<Sys_Users>((gs, gi, u,u1) => gs.StorageUserId == u1.Id)
-                                      .Where((gs, gi, u,u1) => gs.IsDel == 0)
-                                      .WhereIF(dto.GoodsId > 0, (gs, gi, u,u1) => gs.GoodsId == dto.GoodsId)
+                                      .LeftJoin<Sys_Users>((gs, gi, u, u1) => gs.StorageUserId == u1.Id)
+                                      .Where((gs, gi, u, u1) => gs.IsDel == 0)
+                                      .WhereIF(dto.GoodsId > 0, (gs, gi, u, u1) => gs.GoodsId == dto.GoodsId)
                                       .Select((gs, gi, u, u1) => new
                                       {
                                           gs.Id,
                                           gs.GoodsId,
+                                          gs.BatchNo,
                                           GoodsName = gi.Name,
                                           gs.Quantity,
                                           gs.UnitPrice,
@@ -295,7 +299,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                                           gs.SupplierTel,
                                           gs.SupplierAddress,
                                           gs.SupplierSource,
-                                          StorageUserName=u1.CnName,
+                                          StorageUserName = u1.CnName,
                                           gs.StorageTime,
                                           CreateUserName = u.CnName,
                                           gs.CreateTime,
@@ -303,7 +307,6 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                                       .OrderByDescending(gs => gs.CreateTime)
                                       .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
 
-
             _jv.Code = StatusCodes.Status200OK;
             _jv.Data = data;
             _jv.Count = total;
@@ -336,9 +339,12 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                                           gs.SupplierTel,
                                           gs.SupplierAddress,
                                           gs.SupplierSource,
+                                          gs.ReceiveQuantity,
+                                          gs.StorageUserId,
                                           StorageUser = u1.CnName,
                                           gs.StorageTime,
                                           CreateUserName = u.CnName,
+                                          gs.CreateUserId,
                                           gs.CreateTime,
                                           gs.Remark
                                       })
@@ -360,7 +366,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
         {
             var info = _mapper.Map<Pm_GoodsStorage>(dto);
             info.CreateUserId = currUserId;
-            info.BatchNo = DateTime.Now.ToString("yyyyMMddHHmmss");
+            info.BatchNo = DateTime.Now.ToString("yyyyMMddHHmmssfff");
 
             decimal editAgoQuantity = 0.00M,
                     editAgoTotalPrice = 0.00M;
@@ -450,9 +456,9 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                                              .FirstAsync();
             if (storageInfo == null) return _jv;
 
-            decimal delAgoQauntity = storageInfo.Quantity,
+            decimal delAgoQuantity = storageInfo.Quantity,
                     delAgoTotalPrice = storageInfo.TotalPrice;
-            int goodsId = storageInfo.GoodsId;
+            var goodsId = storageInfo.GoodsId;
 
             _sqlSugar.BeginTran();
 
@@ -473,8 +479,8 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
             }
 
             var goodsInfo = await _sqlSugar.Queryable<Pm_GoodsInfo>().FirstAsync(x => x.Id == goodsId);
-            goodsInfo.SQ_Total = goodsInfo.SQ_Total - delAgoQauntity;
-            goodsInfo.StockQuantity = goodsInfo.StockQuantity - delAgoQauntity;
+            goodsInfo.SQ_Total = goodsInfo.SQ_Total - delAgoQuantity;
+            goodsInfo.StockQuantity = goodsInfo.StockQuantity - delAgoQuantity;
             goodsInfo.PriceTotal = goodsInfo.PriceTotal - delAgoTotalPrice;
             goodsInfo.LastUpdateUserId = userId;
             goodsInfo.LastUpdateTime = DateTime.Now;
@@ -559,26 +565,57 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                                       .LeftJoin<Sys_Users>((gr, gi, u1) => gr.AuditUserId == u1.Id)
                                       .LeftJoin<Sys_Users>((gr, gi, u1, u2) => gr.CreateUserId == u2.Id)
                                       .Where((gr, gi, u1, u2) => gr.IsDel == 0)
-                                      .WhereIF(id > 0, (gr, gi, u1, u2u) => gr.Id == id)
-                                      .Select((gr, gi, u1, u2) => new
+                                      .WhereIF(id > 0, (gr, gi, u1, u2) => gr.Id == id)
+                                      .Select((gr, gi, u1, u2) => new GoodsReceiveInfoView
                                       {
-                                          gr.Id,
-                                          gr.GroupId,
-                                          gr.GoodsId,
+                                          Id = gr.Id,
+                                          GroupId = gr.GroupId,
+                                          GoodsId = gr.GoodsId,
                                           GoodsName = gi.Name,
-                                          gr.Quantity,
-                                          gr.Reason,
-                                          gr.Remark,
-                                          gr.AuditStatus,
-                                          AuditStatusText = gr.AuditStatus.GetDescription(),
-                                          gr.AuditUserId,
+                                          Quantity = gr.Quantity,
+                                          Reason = gr.Reason,
+                                          Remark = gr.Remark,
+                                          GoodsStorageInfo = gr.GoodsStorageInfo,
+                                          AuditStatus = gr.AuditStatus,
+                                          AuditUserId = gr.AuditUserId,
                                           AuditUserName = u1.CnName,
-                                          gr.AuditTime,
+                                          AuditTime = gr.AuditTime,
                                           CreateUserName = u2.CnName,
-                                          gr.CreateTime
+                                          CreateTime = gr.CreateTime
                                       })
                                       .FirstAsync();
 
+            if (!string.IsNullOrEmpty(data.GoodsStorageInfo))
+            {
+                var subData = new List<dynamic>();
+                try
+                {
+                    var subData1 = JsonConvert.DeserializeObject<List<GoodsReceiveLinkStorageView>>(data.GoodsStorageInfo);
+                    if (subData1.Count > 0)
+                    {
+                        var storageIds = subData1.Select(x => x.StorageId).ToList();
+                        var storages = await _sqlSugar.Queryable<Pm_GoodsStorage>().Where(x => x.IsDel == 0 && storageIds.Contains(x.Id)) .ToListAsync();
+                        foreach (var item in subData1)
+                        {
+                            var storageInfo = storages.Find(x => x.Id == item.StorageId);
+                            if (storageInfo != null)
+                            {
+                                subData.Add(new
+                                {
+                                    BatchNo = storageInfo.BatchNo,
+                                    RecsiveQuantity = item.Quantity
+                                });
+                            }
+                        }
+                        data.QuantityInfos = data;
+                    }
+                }
+                catch (Exception e)
+                {
+                    Console.WriteLine(e);
+                }
+            }
+
             _jv.Code = StatusCodes.Status200OK;
             _jv.Data = data;
             _jv.Msg = $"操作成功";
@@ -591,7 +628,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
         /// <param name="dto"></param>
         /// <param name="currUserId"></param>
         /// <returns></returns>
-        public async Task<JsonView> GoodsReceiveOp(GoodsReceiveOPDTO dto, int currUserId)
+        public async Task<JsonView> GoodsReceiveOp(GoodsReceiveOpDto dto, int currUserId)
         {
             var info = _mapper.Map<Pm_GoodsReceive>(dto);
             info.CreateUserId = currUserId;
@@ -621,7 +658,7 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                 }
 
                 //物品数量验证
-                decimal editAfterQuantity = waitAuditQuantity - selectInfo.Quantity + info.Quantity;
+                var editAfterQuantity = waitAuditQuantity - selectInfo.Quantity + info.Quantity;
                 if (editAfterQuantity > stockQuantity)
                 {
                     _sqlSugar.RollbackTran();
@@ -689,36 +726,103 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
                                               .Where(x => x.IsDel == 0 && idArray.Contains(x.Id))
                                               .ToListAsync();
 
-            bool status = true;
+            var status = true;
             foreach (var id in idArray)
             {
+                //1.更改审核状态
                 var currInfo = receiveInfos.Find(x => x.Id == id);
                 var edit = await _sqlSugar.Updateable<Pm_GoodsReceive>()
-                                          .SetColumns(x => new Pm_GoodsReceive()
-                                          {
-                                              AuditStatus = auditEnum,
-                                              AuditUserId = userId,
-                                              AuditTime = DateTime.Now,
-                                          })
-                                          .Where(x => x.Id == id)
-                                          .ExecuteCommandAsync();
+                                             .SetColumns(x => new Pm_GoodsReceive()
+                                             {
+                                                 AuditStatus = auditEnum,
+                                                 AuditUserId = userId,
+                                                 AuditTime = DateTime.Now,
+                                             })
+                                             .Where(x => x.Id == id)
+                                             .ExecuteCommandAsync();
                 if (edit < 1) status = false;
 
+                if (auditEnum != GoodsAuditEnum.Approved) continue;
+
+                //2.更改库存
                 var goodsInfo = await _sqlSugar.Queryable<Pm_GoodsInfo>().Where(x => x.Id == currInfo.GoodsId).FirstAsync();
                 goodsInfo.StockQuantity = goodsInfo.StockQuantity - currInfo.Quantity;
+                goodsInfo.OQ_Total += currInfo.Quantity;
                 goodsInfo.LastUpdateTime = DateTime.Now;
                 goodsInfo.LastUpdateUserId = userId;
 
                 var editGoods = await _sqlSugar.Updateable<Pm_GoodsInfo>(goodsInfo)
-                                               .UpdateColumns(x => new
-                                               {
-                                                   x.StockQuantity,
-                                                   x.LastUpdateUserId,
-                                                   x.LastUpdateTime,
-                                               })
-                                               .Where(x => x.Id == id)
-                                               .ExecuteCommandAsync();
+                                                   .UpdateColumns(x => new
+                                                   {
+                                                       x.StockQuantity,
+                                                       x.OQ_Total,
+                                                       x.LastUpdateUserId,
+                                                       x.LastUpdateTime,
+                                                   })
+                                                   .Where(x => x.Id == id)
+                                                   .ExecuteCommandAsync();
+
                 if (editGoods < 1) status = false;
+
+                //3.入库批次关联领用人 更改批次库存
+                var goodsStorages = await _sqlSugar.Queryable<Pm_GoodsStorage>()
+                                                                    .Where(x => x.IsDel == 0 && 
+                                                                                             x.GoodsId == currInfo.GoodsId && 
+                                                                                             (x.Quantity - x.ReceiveQuantity) > 0
+                                                                     )
+                                                                    .OrderBy(x => x.CreateTime)
+                                                                    .ToListAsync();
+                var goodsReceiveInfos = new List<GoodsReceiveLinkStorageView>();
+                var batchStorageInfos = new List<Pm_GoodsStorage>();
+                var receiveQuantity = 0.00M; //领用总数量
+                foreach (var storage in goodsStorages)
+                {
+                    if (currInfo.Quantity == receiveQuantity) break;
+
+                    var thisBatchSurplusQuantity = storage.Quantity - storage.ReceiveQuantity;
+                    if (thisBatchSurplusQuantity <= 0.00M) continue;
+
+                    var thisBatchReceiveQuantity = 0.00M; //此批次领用数量
+                    const decimal unit = 0.50M;
+                    while (receiveQuantity < currInfo.Quantity)
+                    {
+                        if (thisBatchSurplusQuantity == thisBatchReceiveQuantity) break;
+
+                        thisBatchReceiveQuantity += unit;
+                        receiveQuantity += unit;
+                    }
+                    goodsReceiveInfos.Add(new GoodsReceiveLinkStorageView
+                    {
+                        StorageId = storage.Id,
+                        Quantity = thisBatchReceiveQuantity
+                    });
+                    storage.ReceiveQuantity += thisBatchReceiveQuantity;
+                    var storageUpd = storage;
+                    //storageUpd.ReceiveQuantity += thisBatchReceiveQuantity;
+                    batchStorageInfos.Add(storageUpd);
+                }
+                //3.1 更改批次库存
+                if (goodsReceiveInfos.Count > 0)
+                {
+                    var edit1 = await _sqlSugar.Updateable(batchStorageInfos)
+                                                   .UpdateColumns(x => x.ReceiveQuantity)
+                                                   .WhereColumns(x => x.Id)
+                                                   .ExecuteCommandAsync();
+                    if (edit1 < 1) status = false;
+                }
+
+                //3.2 添加入库批次关联领用人
+                if (goodsReceiveInfos.Count > 0)
+                {
+                    var edit1 = await _sqlSugar.Updateable<Pm_GoodsReceive>()
+                                                   .SetColumns(x => new Pm_GoodsReceive()
+                                                   {
+                                                       GoodsStorageInfo = JsonConvert.SerializeObject(goodsReceiveInfos)
+                                                   })
+                                                   .Where(x => x.Id == id)
+                                                   .ExecuteCommandAsync();
+                    if (edit1 < 1) status = false;
+                }
             }
 
             if (status)
@@ -733,12 +837,14 @@ namespace OASystem.Infrastructure.Repositories.PersonnelModule
             return _jv;
         }
 
+
+
+
         /// <summary>
         /// 物品领用 Del
         /// </summary>
-        /// <param name="idArray"></param>
-        /// <param name="userId"></param>
-        /// <param name="auditEnum"></param>
+        /// <param name="id"></param>
+        /// <param name="currUserId"></param>
         /// <returns></returns>
         public async Task<JsonView> GoodsReceiveDel(int id, int currUserId)
         {