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/Dtos/OrderDto.cs          |   46 +++++
 cylsg/cylsg.Application/Users/UserAppService.cs          |   31 +++
 cylsg/cylsg.Application/Orders/OrderCompanyAppService.cs |  244 +++++++++++++++++++++++++++---
 cylsg/cylsg.Application/LogoInController.cs              |    2 
 cylsg/cylsg.Application/Orders/OrderWorkerAppService.cs  |   87 ++++++++--
 cylsg/cylsg.Application/Users/Dtos/UserDto.cs            |   11 +
 cylsg/cylsg.Model/UserModel/UserCompany.cs               |    7 
 cylsg/cylsg.Application/Orders/Dtos/PageBaseSearch.cs    |   20 ++
 8 files changed, 400 insertions(+), 48 deletions(-)

diff --git a/cylsg/cylsg.Application/LogoInController.cs b/cylsg/cylsg.Application/LogoInController.cs
index 92d8070..b3a843a 100644
--- a/cylsg/cylsg.Application/LogoInController.cs
+++ b/cylsg/cylsg.Application/LogoInController.cs
@@ -99,7 +99,7 @@
 
                 };
 
-                await UserRes.EzInsertAsync(user);
+                user.Id = await UserRes.EzInsertReturnIdentityAsync(user);
 
                
             }
diff --git a/cylsg/cylsg.Application/Orders/Dtos/OrderDto.cs b/cylsg/cylsg.Application/Orders/Dtos/OrderDto.cs
index 93cef3f..ceee37f 100644
--- a/cylsg/cylsg.Application/Orders/Dtos/OrderDto.cs
+++ b/cylsg/cylsg.Application/Orders/Dtos/OrderDto.cs
@@ -24,6 +24,11 @@
         public int OrderUserId { get; set; }
 
         /// <summary>
+        /// 鎷涘伐鍏徃鍚嶇О
+        /// </summary>
+        public string OrderComName { get; set; }
+
+        /// <summary>
         /// 鎷涘伐鍚嶇О
         /// </summary>
         public string OrderName { get; set; }
@@ -477,6 +482,16 @@
         public decimal? WorkCount { get; set; }
 
         /// <summary>
+        /// 鐢ㄦ埛id
+        /// </summary>
+        public int WorkerUserId { get; set; }
+
+        /// <summary>
+        /// 鐢ㄦ埛id
+        /// </summary>
+        public string WorkerUserName { get; set; }
+
+        /// <summary>
         /// 褰撴棩宸ヨ祫
         /// </summary>
         public decimal? TodaySalary { get; set; }
@@ -497,6 +512,13 @@
         /// 鎵撳崱鏄庣粏
         /// </summary>
         public string DakaMingxi { get; set; }
+
+
+        /// <summary>
+        /// 鎷涘伐鍏徃鍚嶇О
+        /// </summary>
+        public string Suppliername { get; set; }
+        
 
     }
 
@@ -660,4 +682,28 @@
 
 
     }
+
+
+
+
+    /// <summary>
+    /// 淇敼鍏徃绠$悊鍛�
+    /// </summary>
+    public class StaffAdminDto
+    {
+        
+
+
+        /// <summary>
+        /// 鐢ㄦ埛鍏徃id
+        /// </summary>
+        public int ComId { get; set; }
+
+        /// <summary>
+        /// 鏄惁绠$悊鍛�
+        /// </summary>
+        public bool IsAdmin { get; set; }
+
+
+    }
 }
diff --git a/cylsg/cylsg.Application/Orders/Dtos/PageBaseSearch.cs b/cylsg/cylsg.Application/Orders/Dtos/PageBaseSearch.cs
index 35e3d5c..dd235e0 100644
--- a/cylsg/cylsg.Application/Orders/Dtos/PageBaseSearch.cs
+++ b/cylsg/cylsg.Application/Orders/Dtos/PageBaseSearch.cs
@@ -50,6 +50,11 @@
         public int TotalPage { get; set; }
 
 
+        /// <summary>
+        /// 鍚堣
+        /// </summary>
+        public decimal Heji { get; set; }
+
     }
 
 
@@ -90,8 +95,23 @@
         public DateTime? WordDate { get; set; }
 
         /// <summary>
+        /// 宸ヤ綔鏃ユ湡寮�濮�
+        /// </summary>
+        public DateTime? WordDateStart { get; set; }
+
+        /// <summary>
+        /// 宸ヤ綔鏃ユ湡缁撴潫
+        /// </summary>
+        public DateTime? WordDateEnd { get; set; }
+
+        /// <summary>
         /// 鏄惁缁撶畻
         /// </summary>
         public bool? IsJieSuan { get; set; }
+
+        /// <summary>
+        /// 鍏徃鍚嶇О
+        /// </summary>
+        public string Suppliername { get; set; }
     }
 }
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;
+        }
     }
 }
diff --git a/cylsg/cylsg.Application/Orders/OrderWorkerAppService.cs b/cylsg/cylsg.Application/Orders/OrderWorkerAppService.cs
index 76f27a1..ab236aa 100644
--- a/cylsg/cylsg.Application/Orders/OrderWorkerAppService.cs
+++ b/cylsg/cylsg.Application/Orders/OrderWorkerAppService.cs
@@ -6,6 +6,7 @@
 using EzTencentCloud;
 using Furion.LinqBuilder;
 using MapsterMapper;
+using Microsoft.IdentityModel.Tokens;
 using Org.BouncyCastle.Asn1.X509;
 using SqlSugar.Extensions;
 using System;
@@ -51,6 +52,7 @@
             Expression<Func<Order, bool>> expression = t => true;
 
             expression = expression.And(t => t.IsDeleted == false && t.IsEn == true && t.OrderStatus == 0);
+            expression = expression.And(t => t.WordStartTime >= DateTime.Now.Date.AddDays(-30));
             if (!string.IsNullOrEmpty(page.OrderName))
             {
                 expression = expression.And(t => t.OrderName.Contains(page.OrderName));
@@ -68,6 +70,7 @@
             var orderRepository = new BaseRepository<Order>();
 
             var orderBiddingRepository = new BaseRepository<OrderBidding>();
+            var userCompanyRepository = new BaseRepository<UserCompany>();
 
             var data = await orderRepository.Context.Queryable<Order>()
                     .Where(expression)
@@ -81,6 +84,11 @@
                 {
                     var orderBiddings = await orderBiddingRepository.CountAsync(x => x.OrderId == orderDto.Id && x.IsSelected == true && x.IsEn == true && x.IsDeleted == false);
                     orderDto.WorderCounted = orderBiddings;
+                    var userCompany = await userCompanyRepository.GetFirstAsync(x => x.UserId == orderDto.OrderUserId && x.IsDeleted == false && x.IsEn == true);
+                    if (userCompany != null)
+                    {
+                        orderDto.OrderComName = userCompany.Suppliername;
+                    }
                 }
 
             }
@@ -134,6 +142,7 @@
             
 
             var orderBiddingRepository = new BaseRepository<OrderBidding>();
+            var userCompanyRepository = new BaseRepository<UserCompany>();
 
             var data = await orderRepository.Context.Queryable<Order>()
                     .Where(expression)
@@ -170,6 +179,11 @@
                             orderDto.IsSelectedName = "鏈‘璁�";
                         }
                     }
+                    var userCompany = await userCompanyRepository.GetFirstAsync(x => x.UserId == orderDto.OrderUserId && x.IsDeleted == false && x.IsEn == true);
+                    if (userCompany != null)
+                    {
+                        orderDto.OrderComName = userCompany.Suppliername;
+                    }
                 }
 
             }
@@ -204,6 +218,7 @@
             OrderDto orderDto = new OrderDto();
             var orderRes = new BaseRepository<Order>();
             var orderBiddingRes = new BaseRepository<OrderBidding>();
+            var userWorkerRes = new BaseRepository<UserWorker>();
             var userRes = new BaseRepository<User>();
             var order = await orderRes.GetByIdAsync(orderid);
             orderDto = _mapper.Map<OrderDto>(order);
@@ -248,10 +263,15 @@
                     }
 
                     var user = await userRes.GetByIdAsync(orderBiddingDto.WorkerUserId);
+                   
                     if (user != null)
                     {
-                        orderBiddingDto.WorkerName = user.name;
                         orderBiddingDto.WorkerAvatar = user.Avatar;
+                    }
+                    var userWorker = await userWorkerRes.GetFirstAsync(x => x.UserId == orderBiddingDto.WorkerUserId && x.IsEn == true && x.IsDeleted == false);
+                    if (userWorker != null)
+                    {
+                        orderBiddingDto.WorkerName = userWorker.name;
                     }
 
                 }
@@ -519,17 +539,21 @@
 
             var orderBiddingDetailCheckRepository = new BaseRepository<OrderBiddingDetailCheck>();
 
-            var data = await orderRepository.Context.Queryable<Order, OrderBidding, OrderBiddingDetail>((a, b ,c) =>
+            var data = await orderRepository.Context.Queryable<Order, OrderBidding, OrderBiddingDetail ,UserCompany>((a, b ,c ,d) =>
                  new JoinQueryInfos(JoinType.Inner, a.Id == b.OrderId ,
-                 JoinType.Inner, b.Id == c.OrderBiddingId
+                 JoinType.Inner, b.Id == c.OrderBiddingId ,
+                  JoinType.Inner, a.OrderUserId == d.UserId 
                 ))
-                     .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 && b.WorkerUserId == 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))
-                        .OrderByDescending((a, b, c) => c.WorkDate)
-                      .Select((a, b, c) => new OrderDakaDto
+                     .Where((a, b, c, d) => a.IsEn == true && a.IsDeleted == false && b.IsEn == true && b.IsDeleted == false && c.IsEn == true && c.IsDeleted == false
+                     && b.IsSelected == true && b.WorkerUserId == userid && d.IsEn == true && d.IsDeleted == false )
+                      .WhereIF(page.WordDate.HasValue, (a, b, c, d) => (c.WorkDate == page.WordDate))
+                       .WhereIF(page.WordDateStart.HasValue, (a, b, c, d) => (c.WorkDate >= page.WordDateStart))
+                        .WhereIF(page.WordDateEnd.HasValue, (a, b, c, d) => (c.WorkDate <= page.WordDateEnd))
+                      .WhereIF(page.IsJieSuan.HasValue && page.IsJieSuan == true, (a, b, c, d) => (c.IsShenPi == 2))
+                        .WhereIF(page.IsJieSuan.HasValue && page.IsJieSuan == false, (a, b, c, d) => (c.IsShenPi < 2))
+                         .WhereIF(!string.IsNullOrEmpty(page.Suppliername), (a, b, c, d) =>d.Suppliername.Contains(page.Suppliername))
+                        .OrderByDescending((a, b, c, d) => c.WorkDate)
+                      .Select((a, b, c, d) => new OrderDakaDto
                       {
                           OrderBiddingDetailId = c.Id,
                           OrderName = a.OrderName,
@@ -540,10 +564,28 @@
                           TodaySalary = c.TodaySalary,
                           IsShenPi = c.IsShenPi,
                           WorkCount = c.WorkCount,
-
+                          Suppliername = d.Suppliername,
                       })
                      
                     .ToPageListAsync(page.PageIndex, page.PageSize, total);
+
+
+
+
+            var heji =  orderRepository.Context.Queryable<Order, OrderBidding, OrderBiddingDetail, UserCompany>((a, b, c, d) =>
+                new JoinQueryInfos(JoinType.Inner, a.Id == b.OrderId,
+                JoinType.Inner, b.Id == c.OrderBiddingId,
+                 JoinType.Inner, a.OrderUserId == d.UserId
+               ))
+                    .Where((a, b, c, d) => a.IsEn == true && a.IsDeleted == false && b.IsEn == true && b.IsDeleted == false && c.IsEn == true && c.IsDeleted == false
+                    && b.IsSelected == true && b.WorkerUserId == userid && d.IsEn == true && d.IsDeleted == false)
+                     .WhereIF(page.WordDate.HasValue, (a, b, c, d) => (c.WorkDate == page.WordDate))
+                      .WhereIF(page.WordDateStart.HasValue, (a, b, c, d) => (c.WorkDate >= page.WordDateStart))
+                       .WhereIF(page.WordDateEnd.HasValue, (a, b, c, d) => (c.WorkDate <= page.WordDateEnd))
+                     .WhereIF(page.IsJieSuan.HasValue && page.IsJieSuan == true, (a, b, c, d) => (c.IsShenPi == 2))
+                       .WhereIF(page.IsJieSuan.HasValue && page.IsJieSuan == false, (a, b, c, d) => (c.IsShenPi < 2))
+                        .WhereIF(!string.IsNullOrEmpty(page.Suppliername), (a, b, c, d) => d.Suppliername.Contains(page.Suppliername))
+                     .Sum((a, b, c, d) => c.TodaySalary);
 
             if (data != null && data.Count > 0)
             {
@@ -617,7 +659,7 @@
             result.PageIndex = page.PageIndex;
             result.PageSize = page.PageSize;
             result.TotalCount = total;
-
+            result.Heji = heji ?? 0;
             return result;
         }
 
@@ -649,7 +691,7 @@
             var orderBiddingDetailRes = new BaseRepository<OrderBiddingDetail>();
             var OrderBiddingDetailCheckRes = new BaseRepository<OrderBiddingDetailCheck>();
             var userRes = new BaseRepository<User>();
-
+            var userWorkerRes = new BaseRepository<UserWorker>();
 
             var orderBiddingDetail = await orderBiddingDetailRes.GetByIdAsync(dakaDetailDto.OrderBiddingDetailId);
             var orderBidding = await orderBiddingRes.GetByIdAsync(orderBiddingDetail.OrderBiddingId);
@@ -671,10 +713,13 @@
             var user = await userRes.GetByIdAsync(orderDakaMingxiDto.WorkerUserId);
             if (user != null)
             {
-                orderDakaMingxiDto.WorkerUserName = user.name;
                 orderDakaMingxiDto.WorkerUserAvatar = user.Avatar;
             }
-               
+            var userWorker = await userWorkerRes.GetFirstAsync(x => x.UserId == orderDakaMingxiDto.WorkerUserId && x.IsEn == true && x.IsDeleted == false);
+            if (userWorker != null)
+            {
+                orderDakaMingxiDto.WorkerUserName = userWorker.name;
+            }
 
 
             switch (orderDakaMingxiDto.IsShenPi)
@@ -773,8 +818,16 @@
 
             orderBiddingDetail.WorkTime = dakaDto.WorkTime;
             orderBiddingDetail.WorkCount = dakaDto.WorkCount;
-            orderBiddingDetail.TodaySalary = dakaDto.TodaySalary;
-            orderBiddingDetail.IsShenPi = 1;
+            if(order.WorkerType == (int)WorkerTypes.count)
+            {
+                orderBiddingDetail.TodaySalary = dakaDto.WorkCount * order.WorkPrice;
+            }
+            else
+            {
+                orderBiddingDetail.TodaySalary = dakaDto.TodaySalary;
+            }
+           
+            orderBiddingDetail.IsShenPi = (int)IsShenPis.tijiao;
             orderBiddingDetail.UpDataBy = NickName;
             orderBiddingDetail.UpDataTime = DateTime.Now;
             //orderBiddingDetail.CreateBy = NickName;
diff --git a/cylsg/cylsg.Application/Users/Dtos/UserDto.cs b/cylsg/cylsg.Application/Users/Dtos/UserDto.cs
index b2a6d83..effd240 100644
--- a/cylsg/cylsg.Application/Users/Dtos/UserDto.cs
+++ b/cylsg/cylsg.Application/Users/Dtos/UserDto.cs
@@ -189,5 +189,16 @@
         /// </summary>
         public bool? IsTiXian { get; set; }
 
+        /// <summary>
+        /// 鏄惁绠$悊鍛�
+        /// </summary>
+        public bool? IsAdmin { get; set; }
+
+
+        /// <summary>
+        /// 鏄电О
+        /// </summary>
+        public string Nickname { get; set; }
+
     }
 }
diff --git a/cylsg/cylsg.Application/Users/UserAppService.cs b/cylsg/cylsg.Application/Users/UserAppService.cs
index a3f0c08..6e4b107 100644
--- a/cylsg/cylsg.Application/Users/UserAppService.cs
+++ b/cylsg/cylsg.Application/Users/UserAppService.cs
@@ -117,9 +117,10 @@
 
             var userWorkerRes = new BaseRepository<UserWorker>();
             bool res;
-            if (userWorkerDto.Id > 0)
+            var userWorker1 = await userWorkerRes.GetFirstAsync(x => x.UserId == userid && x.IsEn == true && x.IsDeleted == false);
+            if (userWorker1!=null)
             {
-                var userWorker1 = await userWorkerRes.GetByIdAsync(userWorkerDto.Id);
+               //.GetByIdAsync(userWorkerDto.Id);
                 userWorker1.IdCardBack = userWorkerDto.IdCardBack;
                 userWorker1.IdCardFace = userWorkerDto.IdCardFace;
                 userWorker1.name = userWorkerDto.name;
@@ -206,9 +207,21 @@
 
             var userCompanyRes = new BaseRepository<UserCompany>();
             bool res;
-            if (userCompanyDto.Id > 0)
+            var userCompany1 = await userCompanyRes.GetFirstAsync(x=>x.UserId == userid && x.IsEn == true && x.IsDeleted == false);
+            if (userCompany1 != null)
             {
-                var userCompany1 = await userCompanyRes.GetByIdAsync(userCompanyDto.Id);
+                if(userCompany1.Suppliercode != userCompanyDto.Suppliercode)
+                {
+                    var count = await userCompanyRes.CountAsync(x => x.Suppliercode == userCompanyDto.Suppliercode && x.Id != userCompany1.Id && x.IsEn == true && x.IsDeleted == false);
+                    if (count > 0)
+                    {
+                        userCompany1.IsAdmin = false;
+                    }
+                    else
+                    {
+                        userCompany1.IsAdmin = true;
+                    }
+                }
                 userCompany1.BusinessLicense = userCompanyDto.BusinessLicense;
                 userCompany1.Suppliername = userCompanyDto.Suppliername;
                 userCompany1.Regtime = userCompanyDto.Regtime;
@@ -227,6 +240,16 @@
             }
             else
             {
+                var count = await userCompanyRes.CountAsync(x => x.Suppliercode == userCompanyDto.Suppliercode && x.IsEn == true && x.IsDeleted == false);
+                if (count > 0)
+                {
+                    userCompanyDto.IsAdmin = false;
+                }
+                else
+                {
+                    userCompanyDto.IsAdmin = true;
+                }
+
                 var userCompany = _mapper.Map<UserCompany>(userCompanyDto);
                 userCompany.UpDataBy = NickName;
                 userCompany.UpDataTime = DateTime.Now;
diff --git a/cylsg/cylsg.Model/UserModel/UserCompany.cs b/cylsg/cylsg.Model/UserModel/UserCompany.cs
index d90773c..c79b0ec 100644
--- a/cylsg/cylsg.Model/UserModel/UserCompany.cs
+++ b/cylsg/cylsg.Model/UserModel/UserCompany.cs
@@ -97,5 +97,12 @@
         /// </summary>
         [SugarColumn(ColumnDescription = "鏄惁鍙互鍏呭�硷紝宸ヤ汉鎻愮幇", IsNullable = true)]
         public bool? IsTiXian { get; set; }
+
+
+        /// <summary>
+        /// 鏄惁绠$悊鍛�
+        /// </summary>
+        [SugarColumn(ColumnDescription = "鏄惁绠$悊鍛�", IsNullable = true)]
+        public bool? IsAdmin { get; set; }
     }
 }

--
Gitblit v1.9.1