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/Users/UserAppService.cs |   31 +++++++++++++++++++++++++++----
 1 files changed, 27 insertions(+), 4 deletions(-)

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;

--
Gitblit v1.9.1