From 9ff87793beacf5069c374b6e6274fa651179a7f3 Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期三, 25 九月 2024 13:27:33 +0800 Subject: [PATCH] 提交 --- cylsg/cylsg.Application/Orders/OrderCompanyAppService.cs | 244 +++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 218 insertions(+), 26 deletions(-) diff --git a/cylsg/cylsg.Application/Orders/OrderCompanyAppService.cs b/cylsg/cylsg.Application/Orders/OrderCompanyAppService.cs index 1a2bb2c..d001701 100644 --- a/cylsg/cylsg.Application/Orders/OrderCompanyAppService.cs +++ b/cylsg/cylsg.Application/Orders/OrderCompanyAppService.cs @@ -12,6 +12,7 @@ using System.Security.Claims; using System.Text; using System.Threading.Tasks; +using static SKIT.FlurlHttpClient.Wechat.Api.Models.CgibinAccountGetAccountBasicInfoResponse.Types; namespace cylsg.Application.Orders { @@ -49,10 +50,21 @@ PageResult<OrderDto> result = new PageResult<OrderDto>(); var orderRepository = new BaseRepository<Order>(); + var userCompanyRes = new BaseRepository<UserCompany>(); + + //鏌ヨ鍏徃鐨勬墍鏈夊憳宸ョ殑鎵�鏈夋嫑宸ヨ鍗� + var userCompany = await userCompanyRes.GetFirstAsync(x => x.UserId == userid && x.IsEn == true && x.IsDeleted == false); + if (userCompany == null) + { + throw Oops.Oh("浣犳病鏈夊叕鍙革紒"); + } + var userCompanies = await userCompanyRes.GetListAsync(x => x.Suppliercode == userCompany.Suppliercode && x.IsEn == true && x.IsDeleted == false); + var userids = userCompanies.Select(x => x.UserId).ToList(); + Expression<Func<Order, bool>> expression = t => true; expression = expression.And(t => t.IsDeleted == false && t.IsEn == true - && t.OrderUserId == userid); + && userids.Contains(t.OrderUserId)); //t.OrderUserId == userid if (!string.IsNullOrEmpty(page.OrderName)) { @@ -156,6 +168,13 @@ { throw Oops.Oh("鎷涘伐宸茬粡缁撴潫涓嶈兘淇敼锛�"); } + var orderBiddingRes = new BaseRepository<OrderBidding>(); + var count = await orderBiddingRes.CountAsync(x=>x.OrderId == orderDto.Id && x.IsEn == true && x.IsDeleted == true && x.IsSelected == true); + if (count > 0) + { + throw Oops.Oh("宸茬粡纭鎷涘伐浜哄憳锛屼笉鑳戒慨鏀癸紒"); + } + order.OrderName = orderDto.OrderName; order.WordStartTime = orderDto.WordStartTime; order.WordEndTime = orderDto.WordEndTime; @@ -263,6 +282,68 @@ + /// <summary> + /// 鍏徃鍙栨秷閫夋嫨宸ヤ汉 + /// </summary> + /// <returns></returns> + [Authorize] + [HttpPost] + public async Task<bool> saveQuXiao(QueRenDto queRenDto) + { + + var UserID = App.User?.FindFirstValue("UserID"); + int userid = 0; + string NickName = App.User?.FindFirstValue("NickName"); + if (!string.IsNullOrEmpty(UserID)) + { + userid = int.Parse(UserID); + } + + var orderBiddingRes = new BaseRepository<OrderBidding>(); + var orderRes = new BaseRepository<Order>(); + var orderBiddingDetailRes = new BaseRepository<OrderBiddingDetail>(); + + var orderBidding = await orderBiddingRes.GetByIdAsync(queRenDto.OrderBiddingId); + if (orderBidding == null || orderBidding.IsEn != true || orderBidding.IsDeleted == true) + { + throw Oops.Oh("璇ユ姇閫掑凡缁忔棤鏁堬紒"); + } + if (orderBidding.IsSelected != true) + { + throw Oops.Oh("璇ユ姇閫掓病鏈夌‘璁わ紝涓嶈兘鍙栨秷锛�"); + } + + var count = await orderBiddingDetailRes.CountAsync(x => x.OrderBiddingId == orderBidding.Id && x.IsEn == true && x.IsDeleted == false); + if (count>0) + { + throw Oops.Oh("璇ュ伐浜哄凡鏈夋墦鍗′俊鎭紝涓嶈兘鍙栨秷鎷涘伐锛�"); + } + + var order = await orderRes.GetByIdAsync(orderBidding.OrderId); + + + + bool res; + + orderBidding.IsSelected = false; + orderBidding.Selectedtime = null; + orderBidding.UpDataBy = NickName; + orderBidding.UpDataTime = DateTime.Now; + + + res = await orderBiddingRes.UpdateAsync(orderBidding); + if (!res) + { + throw Oops.Oh("鍙栨秷宸ヤ汉鎷涘伐澶辫触锛�"); + } + order.OrderStatus = 0; + res = await orderRes.UpdateAsync(order); + + return res; + } + + + /// <summary> /// 鏌ヨ鍏徃涓嬪伐浜虹殑鎵撳崱璁板綍 @@ -282,18 +363,27 @@ PageResult<OrderDakaDto> result = new PageResult<OrderDakaDto>(); var orderRepository = new BaseRepository<Order>(); + var userCompanyRes = new BaseRepository<UserCompany>(); + //鏌ヨ鍏徃鐨勬墍鏈夊憳宸ョ殑鎵�鏈夋嫑宸ヨ鍗� + var userCompany = await userCompanyRes.GetFirstAsync(x => x.UserId == userid && x.IsEn == true && x.IsDeleted == false); + if (userCompany == null) + { + throw Oops.Oh("浣犳病鏈夊叕鍙革紒"); + } + var userCompanies = await userCompanyRes.GetListAsync(x => x.Suppliercode == userCompany.Suppliercode && x.IsEn == true && x.IsDeleted == false); + var userids = userCompanies.Select(x => x.UserId).ToList(); RefAsync<int> total = 0; var orderBiddingDetailCheckRepository = new BaseRepository<OrderBiddingDetailCheck>(); - + var userWorkerRes = new BaseRepository<UserWorker>(); var data = await orderRepository.Context.Queryable<Order, OrderBidding, OrderBiddingDetail>((a, b, c) => new JoinQueryInfos(JoinType.Inner, a.Id == b.OrderId, JoinType.Inner, b.Id == c.OrderBiddingId )) .Where((a, b, c) => a.IsEn == true && a.IsDeleted == false && b.IsEn == true && b.IsDeleted == false && c.IsEn == true && c.IsDeleted == false - && b.IsSelected == true && a.OrderUserId == userid) + && b.IsSelected == true && userids.Contains(a.OrderUserId)) //a.OrderUserId == userid .WhereIF(page.WordDate.HasValue, (a, b, c) => (c.WorkDate == page.WordDate)) .WhereIF(page.IsJieSuan.HasValue && page.IsJieSuan == true, (a, b, c) => (c.IsShenPi == 2)) .WhereIF(page.IsJieSuan.HasValue && page.IsJieSuan == false, (a, b, c) => (c.IsShenPi < 2)) @@ -309,6 +399,7 @@ TodaySalary = c.TodaySalary, IsShenPi = c.IsShenPi, WorkCount = c.WorkCount, + WorkerUserId = b.WorkerUserId, }) .ToPageListAsync(page.PageIndex, page.PageSize, total); @@ -377,6 +468,13 @@ dakaDto.DakaMingxi = DakaMingxi; + + + var userWorker = await userWorkerRes.GetFirstAsync(x => x.UserId == dakaDto.WorkerUserId && x.IsEn == true && x.IsDeleted == false ); + if (userWorker != null) + { + dakaDto.WorkerUserName = userWorker.name; + } } @@ -463,36 +561,41 @@ } var userCompany = await userCompanyRes.GetFirstAsync(x => x.UserId == order.OrderUserId); - if(userCompany!=null && userCompany.IsTiXian == true) + + if (userCompany!=null ) { - //鎻掑叆鐢ㄦ埛鐨勭粨绠楅噾棰� - UserTiXianDetail userTiXianDetail = new UserTiXianDetail(); - userTiXianDetail.UserId = orderBidding.WorkerUserId; - userTiXianDetail.YiTiXianJine = TodaySalary; - userTiXianDetail.ZhiChuShouRu = (int)ZhiChuShouRus.shouru; - userTiXianDetail.Remark = "鎷涘伐璁㈠崟" + order.OrderName + orderBiddingDetail.WorkDate.Value.ToString("yyyy-MM-dd") + "宸ヨ祫缁撶畻"; - userTiXianDetail.UpDataBy = NickName; - userTiXianDetail.UpDataTime = DateTime.Now; - userTiXianDetail.CreateBy = NickName; - userTiXianDetail.CreateTime = DateTime.Now; - - res = await userTiXianDetailRes.InsertAsync(userTiXianDetail); - if (!res) + var userCompanies = await userCompanyRes.CountAsync(x => x.Suppliercode == userCompany.Suppliercode && x.IsEn == true && x.IsDeleted == false && x.IsTiXian == true); + if (userCompanies > 0) { - orderRes.Context.Ado.RollbackTran(); - throw Oops.Oh("缁撶畻澶辫触锛�"); - } - var userWorker = await userWorkerRes.GetFirstAsync(x => x.UserId == orderBidding.WorkerUserId); - if (userWorker != null) - { - var TiXianZonge = userWorker.TiXianZonge ?? 0; + //鎻掑叆鐢ㄦ埛鐨勭粨绠楅噾棰� + UserTiXianDetail userTiXianDetail = new UserTiXianDetail(); + userTiXianDetail.UserId = orderBidding.WorkerUserId; + userTiXianDetail.YiTiXianJine = TodaySalary; + userTiXianDetail.ZhiChuShouRu = (int)ZhiChuShouRus.shouru; + userTiXianDetail.Remark = userCompany.Suppliername + " " + orderBiddingDetail.WorkDate.Value.ToString("yyyy-MM-dd"); + userTiXianDetail.UpDataBy = NickName; + userTiXianDetail.UpDataTime = DateTime.Now; + userTiXianDetail.CreateBy = NickName; + userTiXianDetail.CreateTime = DateTime.Now; - userWorker.TiXianZonge = TiXianZonge + TodaySalary; - res = await userWorkerRes.UpdateAsync(userWorker); + res = await userTiXianDetailRes.InsertAsync(userTiXianDetail); if (!res) { orderRes.Context.Ado.RollbackTran(); throw Oops.Oh("缁撶畻澶辫触锛�"); + } + var userWorker = await userWorkerRes.GetFirstAsync(x => x.UserId == orderBidding.WorkerUserId); + if (userWorker != null) + { + var TiXianZonge = userWorker.TiXianZonge ?? 0; + + userWorker.TiXianZonge = TiXianZonge + TodaySalary; + res = await userWorkerRes.UpdateAsync(userWorker); + if (!res) + { + orderRes.Context.Ado.RollbackTran(); + throw Oops.Oh("缁撶畻澶辫触锛�"); + } } } } @@ -547,5 +650,94 @@ return res; } + + + + + /// <summary> + /// 鏌ヨ鍏徃涓嬫墍鏈夊憳宸� + /// </summary> + /// <param name="page"></param> + /// <returns></returns> + [Authorize] + [HttpPost] + public async Task<List<UserCompanyDto>> PostMystaffList() + { + var UserID = App.User?.FindFirstValue("UserID"); + int userid = 0; + if (!string.IsNullOrEmpty(UserID)) + { + userid = int.Parse(UserID); + } + + + var userCompanyRes = new BaseRepository<UserCompany>(); + var userRes = new BaseRepository<User>(); + + + var userCompany = await userCompanyRes.GetFirstAsync(x => x.UserId == userid && x.IsEn == true && x.IsDeleted == false); + if (userCompany == null) + { + throw Oops.Oh("浣犳病鏈夊叕鍙革紒"); + } + var userCompanies = await userCompanyRes.GetListAsync(x => x.Suppliercode == userCompany.Suppliercode && x.IsEn == true && x.IsDeleted == false); + + var datadtos = _mapper.Map<List<UserCompanyDto>>(userCompanies); + + foreach (var datadto in datadtos) + { + var user = await userRes.GetByIdAsync(datadto.UserId); + datadto.Nickname = user.Nickname; + } + + + return datadtos; + } + + + /// <summary> + /// 淇濆瓨鍏徃涓嬫墍鏈夊憳宸ユ槸鍚︾鐞嗗憳 + /// </summary> + /// <param name="staffAdminDto"></param> + /// <returns></returns> + [Authorize] + [HttpPost] + public async Task<bool> SaveStaffAdmin(StaffAdminDto staffAdminDto) + { + + var UserID = App.User?.FindFirstValue("UserID"); + int userid = 0; + string NickName = App.User?.FindFirstValue("NickName"); + if (!string.IsNullOrEmpty(UserID)) + { + userid = int.Parse(UserID); + } + var userCompanyRes = new BaseRepository<UserCompany>(); + + + var res = false; + + var userCompany = await userCompanyRes.GetByIdAsync(staffAdminDto.ComId); + if(staffAdminDto.IsAdmin == false) + { + var userCompanies = await userCompanyRes.CountAsync(x => x.Suppliercode == userCompany.Suppliercode && x.Id != userCompany.Id && x.IsAdmin == true && x.IsEn == true && x.IsDeleted == false); + if (userCompanies <= 0) + { + throw Oops.Oh("涓�涓叕鍙稿繀椤昏嚦灏戜竴涓鐞嗗憳锛�"); + } + } + + if (userCompany != null) + { + userCompany.IsAdmin = staffAdminDto.IsAdmin; + userCompany.UpDataBy = NickName; + userCompany.UpDataTime = DateTime.Now; + res = await userCompanyRes.UpdateAsync(userCompany); + } + + + + return res; + } } } -- Gitblit v1.9.1