From 55fb4752a6aa7d19ffbe2b24204b8b21dae7e868 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期一, 30 八月 2021 09:39:34 +0800
Subject: [PATCH] 工作没有交接完成的,不允许核准工资

---
 zhengcaioa/Services/HrSalaryService.cs |   78 ++++++++++++++++++++++++++++++---------
 1 files changed, 60 insertions(+), 18 deletions(-)

diff --git a/zhengcaioa/Services/HrSalaryService.cs b/zhengcaioa/Services/HrSalaryService.cs
index 7c06702..7d5fb4a 100644
--- a/zhengcaioa/Services/HrSalaryService.cs
+++ b/zhengcaioa/Services/HrSalaryService.cs
@@ -106,6 +106,15 @@
                 var updatepltRole = _context.HrSalaries.Where(c=>c.Id==dto.Id).SingleOrDefault();
                 if(updatepltRole!=null)
                 {
+                    //濡傛灉鏈夋湭瀹屾垚鐨勫伐浣滀氦鎺ワ紝涓嶈兘鏍稿噯宸ヨ祫
+                 var admAskJiaojies  =  _context.AdmAskJiaojies.Where(x => x.Creater == updatepltRole.Userid &&  x.RecStatus == "A" && x.ShenpiStatus == "D").ToList();
+                    if(admAskJiaojies!=null && admAskJiaojies.Count > 0)
+                    {
+                        resultEntity.Result = false;
+                        resultEntity.Message = "鏈夋湭瀹屾垚鐨勫伐浣滀氦鎺ワ紝涓嶈兘鏍稿噯宸ヨ祫";
+                        return resultEntity;
+                    }
+
                     //鏇存柊鐢佃瘽璐圭敤鐘舵��
                     var sim = _context.SimCost.Where(c => c.bill_year == updatepltRole.Year && c.bill_month <= updatepltRole.Month && c.user_id == updatepltRole.Userid && c.status == "0").ToList();
                     if(sim!=null)
@@ -136,19 +145,38 @@
                     //璁$畻棰勫彂宸ヨ祫
                     if (user.advancewages.HasValue && user.advancewages.Value>0)
                     {
+                        //涓婁竴娆$殑宸ヨ祫
+                        var bf= _context.HrSalaries.Where(c => c.Userid == user.Id && c.Islock== "Q" && c.RecStatus=="A").
+                            OrderByDescending(c=>c.Year).ThenByDescending(c=>c.Month).FirstOrDefault();
+
                         var pc = user.advancewages.Value;
                         if (sum_f - sum_k > pc)
                         {
-                            updatepltRole.Daozhanggongzi = sum_f - sum_k;                            
+                            updatepltRole.Daozhanggongzi = sum_f - sum_k;
+                            updatepltRole.Yufagongzi = 0;
+                            if(bf!=null)
+                            {
+                                updatepltRole.Yufagongziheji = bf.Yufagongziheji??0 - (updatepltRole.Daozhanggongzi-pc);
+                            }
+                            else
+                            {
+                                updatepltRole.Yufagongziheji = (pc - updatepltRole.Daozhanggongzi);
+                            }
                         }
                         else
                         {
                             //棰勫彂
                             updatepltRole.Daozhanggongzi = pc;
                             updatepltRole.Yufagongzi = pc - (sum_f - sum_k);
-                            updatepltRole.Yufagongziheji += updatepltRole.Yufagongzi;
+                            if (bf != null)
+                            {
+                                updatepltRole.Yufagongziheji =bf.Yufagongziheji??0+ updatepltRole.Yufagongzi;
+                            }
+                            else
+                            {
+                                updatepltRole.Yufagongziheji = updatepltRole.Yufagongzi;
+                            }
                         }
-
                     }
                     else
                     {
@@ -350,7 +378,7 @@
 
 
 
-            if (searchEntity.totalrows == 0)
+            //if (searchEntity.totalrows == 0)
                 searchEntity.totalrows = query.Count();
             var rolelist = query.Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList();
 
@@ -415,7 +443,7 @@
                           && (string.IsNullOrWhiteSpace(searchEntity.Usernumber) || f.Usernumber == searchEntity.Usernumber.Trim())
                             && (string.IsNullOrWhiteSpace(searchEntity.DeptId) || f.DeptId == searchEntity.DeptId.Trim())
                               && (string.IsNullOrWhiteSpace(searchEntity.UserName) || f.UserName.Contains(searchEntity.UserName.Trim()))
-                              && ( (a.Year == year && a.Month == month))
+                              && (string.IsNullOrWhiteSpace(searchEntity.YearMonth) || ( a.Year == year && a.Month == month ))
                          select new HrSalaryDTO
                          {
                              Id = a.Id,
@@ -488,7 +516,7 @@
 
 
 
-            if (searchEntity.totalrows == 0)
+            //if (searchEntity.totalrows == 0)
                 searchEntity.totalrows = query.Count();
             var rolelist = query.Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList();
             if(rolelist!=null && rolelist.Count>0)
@@ -696,7 +724,9 @@
                         temp.reason = model.reason;
                         temp.amount = model.amount;
                         temp.basis = model.basis;
-                        temp.sub_time = DateTime.Now;
+                        temp.shenpi_status = model.shenpi_status;
+
+
                     }
                     else
                     {
@@ -727,12 +757,20 @@
         /// <param name="id"></param>
         /// <param name="user"></param>
         /// <returns></returns>
-        public HrSalaryAppeal GetAppeal(string id,string user)
+        public HrSalaryAppeal GetAppeal(string id = "", string user = "", string salaryId = "")
         {
             HrSalaryAppeal hd = new HrSalaryAppeal();
             try
             {
-                hd = _context.HrSalaryAppeal.Where(e => e.salary_id == id && e.sub_user == user).SingleOrDefault();
+                if (!string.IsNullOrEmpty(salaryId))
+                {
+                    hd = _context.HrSalaryAppeal.Where(e => e.salary_id == salaryId && e.sub_user == user && e.status == "A").FirstOrDefault();
+                }
+                else
+                {
+                    hd = _context.HrSalaryAppeal.Where(e => e.id == id && e.status == "A").FirstOrDefault();
+                }
+               
             }
             catch (Exception er)
             {
@@ -762,14 +800,15 @@
             DateTime st = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date;
             DateTime et = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.AddMonths(1).AddSeconds(-1); 
             int month = 0;
-            if (!string.IsNullOrEmpty(searchEntity.searchDate))
+            if (!string.IsNullOrEmpty(searchEntity.searchDatestart))
             {
-                var times = searchEntity.searchDate.Split('|');
-                if (times.Length == 2)
-                {
-                    st = DateTime.Parse(times[0]);
-                    et= DateTime.Parse(times[1]);
-                }
+                st = DateTime.Parse(searchEntity.searchDatestart + "-01");
+                 
+            }
+            if (!string.IsNullOrEmpty(searchEntity.searchDateend))
+            {
+                et = DateTime.Parse(searchEntity.searchDateend + "-01");
+
             }
             var query = (from a in _context.HrSalaries where a.Year >= st.Year && a.Month >= st.Month && a.Year <= et.Year && a.Month <= et.Month select a);
 
@@ -780,7 +819,10 @@
                           && (string.IsNullOrWhiteSpace(searchEntity.Usernumber) || f.Usernumber == searchEntity.Usernumber.Trim())
                             && (string.IsNullOrWhiteSpace(searchEntity.DeptId) || f.DeptId == searchEntity.DeptId.Trim())
                               && (string.IsNullOrWhiteSpace(searchEntity.UserName) || f.UserName.Contains(searchEntity.UserName.Trim()))
-                         select new HrSalaryDTO
+
+                               && (string.IsNullOrWhiteSpace(searchEntity.UserId) || a.Userid.Contains(searchEntity.UserId.Trim()))
+
+                        select new HrSalaryDTO
                          {
                              Id = a.Id,
 
@@ -850,7 +892,7 @@
                          }).OrderByDescending(x => x.Modifytime).ToList();
 
 
-            if (searchEntity.totalrows == 0)
+            //if (searchEntity.totalrows == 0)
                 searchEntity.totalrows = list.Count();
             var rolelist = list.Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList();
             if (rolelist != null && rolelist.Count > 0)

--
Gitblit v1.9.1