From c28a5cd5367ba6a0d210dc897fd9a7cf6e46e570 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期五, 03 二月 2023 09:40:06 +0800
Subject: [PATCH] 把会员系统和oa系统手机号相同的客户关联起来

---
 zhengcaioa/zhengcaioa/Timer/TimedBackgroundService.cs |   74 ++++++++++++++++++++++++++++++++++++
 1 files changed, 73 insertions(+), 1 deletions(-)

diff --git a/zhengcaioa/zhengcaioa/Timer/TimedBackgroundService.cs b/zhengcaioa/zhengcaioa/Timer/TimedBackgroundService.cs
index 0c1b434..f91384a 100644
--- a/zhengcaioa/zhengcaioa/Timer/TimedBackgroundService.cs
+++ b/zhengcaioa/zhengcaioa/Timer/TimedBackgroundService.cs
@@ -51,6 +51,8 @@
         private readonly IAskService _askService;
         private readonly IAdmEvaluateService _admEvaluateService;
         private readonly IExpertService _expertService;
+        private readonly zhengcaioaContext _context;
+        private readonly zcUserInfoN_dbContext _zcUsercontext;
 
         private readonly decimal jiabangongzibiaozhun = new decimal(21.5);
         public TimedBackgroundService(ILogger<TimedBackgroundService> logger, IServiceScopeFactory factory)
@@ -85,6 +87,8 @@
             _askService= factory.CreateScope().ServiceProvider.GetRequiredService<IAskService>();
             _admEvaluateService = factory.CreateScope().ServiceProvider.GetRequiredService<IAdmEvaluateService>();
             _expertService = factory.CreateScope().ServiceProvider.GetRequiredService<IExpertService>();
+            _context = factory.CreateScope().ServiceProvider.GetRequiredService<zhengcaioaContext>();
+            _zcUsercontext = factory.CreateScope().ServiceProvider.GetRequiredService<zcUserInfoN_dbContext>();
         }
         protected override async Task ExecuteAsync(CancellationToken stoppingToken)
         {
@@ -134,6 +138,15 @@
                         {
                             jisuangonglinggongzi();
                         }
+
+
+                        _logger.LogInformation("鎶婅秴杩�90澶╄繕娌℃湁杞寲鐨勬。妗堝鎴风殑涓氬姟缁忕悊褰掍负鏃�");
+                        this.ywjlguiling();
+                        _logger.LogInformation("鎶婅秴杩�90澶╄繕娌℃湁杞寲鐨勬。妗堝鎴风殑涓氬姟缁忕悊褰掍负鏃犳墽琛岀粨鏉�");
+
+                        _logger.LogInformation("鎶婁細鍛樼郴缁熷拰oa绯荤粺鎵嬫満鍙风浉鍚岀殑瀹㈡埛鍏宠仈璧锋潵");
+                        this.huiyuanguanlian();
+                        _logger.LogInformation("鎶婁細鍛樼郴缁熷拰oa绯荤粺鎵嬫満鍙风浉鍚岀殑瀹㈡埛鍏宠仈璧锋潵鎵ц缁撴潫");
                     }
                     catch (Exception ex)
                     {
@@ -205,6 +218,65 @@
             _logger.LogInformation("diwutian" + diwutian);
             _logger.LogInformation("DateTime.Now" + DateTime.Now.Date);
             return diwutian;
+        }
+
+
+        //鎶婅秴杩�90澶╄繕娌℃湁杞寲鐨勬。妗堝鎴风殑涓氬姟缁忕悊褰掍负鏃�
+        public void ywjlguiling()
+        {
+          var intentionCustomerDTOs  =  _intentionCustomerService.GetList().Where(x=>x.Ywjltime < DateTime.Now.AddDays(-90)).ToList();
+
+            foreach(var intentionCustomerDTO in intentionCustomerDTOs)
+            {
+                intentionCustomerDTO.Ywjl = null;
+                intentionCustomerDTO.Ywjltime = null;
+                _intentionCustomerService.save(intentionCustomerDTO);
+            }
+        }
+
+
+        //鎶婁細鍛樼郴缁熷拰oa绯荤粺鎵嬫満鍙风浉鍚岀殑瀹㈡埛鍏宠仈璧锋潵
+        public void huiyuanguanlian()
+        {
+            var cooperatecustomCustomers = _context.CooperatecustomCustomers.Where(x => x.RecStatus == "A" && x.HuiyuanId == null).ToList();
+            var frameworkUsers = _zcUsercontext.FrameworkUsers.Where(x => x.IsValid == true).ToList();
+            if (cooperatecustomCustomers != null && cooperatecustomCustomers.Count > 0)
+            {
+                foreach (var cooperatecustomCustomer in cooperatecustomCustomers)
+                {
+                    if (!string.IsNullOrEmpty(cooperatecustomCustomer.Tel))
+                    {
+                        var frameworkUser = frameworkUsers.Where(x => x.Itcode == cooperatecustomCustomer.Tel).FirstOrDefault();
+                        if (frameworkUser != null)
+                        {
+                            cooperatecustomCustomer.HuiyuanId = frameworkUser.Id.ToString();
+                        }
+                    }
+
+                }
+                _context.SaveChanges();
+            }
+
+
+
+            var intentionCustomers = _context.IntentionCustomers.Where(x => x.RecStatus == "A" && x.HuiyuanId == null).ToList();
+            if (intentionCustomers != null && intentionCustomers.Count > 0)
+            {
+                foreach (var intentionCustomer in intentionCustomers)
+                {
+                    if (!string.IsNullOrEmpty(intentionCustomer.Tel))
+                    {
+                        var frameworkUser = frameworkUsers.Where(x => x.Itcode == intentionCustomer.Tel).FirstOrDefault();
+                        if (frameworkUser != null)
+                        {
+                            intentionCustomer.HuiyuanId = frameworkUser.Id.ToString();
+                        }
+                    }
+
+                }
+                _context.SaveChanges();
+            }
+
         }
 
         //璁$畻鑰冨嫟
@@ -347,7 +419,7 @@
                         admSignInDTO = new AdmSignInDTO();
                     }
                     //鏌ヨ璇峰亣   璇峰亣鏃堕棿涓嶈兘閲嶅彔
-                    List<AdmAskLeaveDTO> admAskLeaveDTOMin = admAskLeaveDTOs.Where(x =>/*x.Lavetype != "2" &&*/  x.StratTime < dateminkaoqin.AddDays(1) && x.EndTime > dateminkaoqin).OrderByDescending(x=>x.Createtime).ToList();
+                    List<AdmAskLeaveDTO> admAskLeaveDTOMin = admAskLeaveDTOs.Where(x => x.Lavetype != "2" && x.StratTime < dateminkaoqin.AddDays(1) && x.EndTime > dateminkaoqin).OrderByDescending(x=>x.Createtime).ToList();
                     //鏌ヨ閿�鍋�   閿�鍋囨椂闂翠笉鑳介噸鍙�
                     List<AdmAskLeaveOffDTO> admAskLeaveOffDTOMin = admAskLeaveOffDTOs.Where(x => x.StratTime < dateminkaoqin.AddDays(1) && x.EndTime > dateminkaoqin).OrderByDescending(x => x.Createtime).ToList();
                    

--
Gitblit v1.9.1