From 8a286d8dd894be550bd0ce9fd859781f98478747 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期二, 20 七月 2021 15:15:04 +0800
Subject: [PATCH] 今日开发     客户资料。前端同步到后端  ,书城端和会员端都需要同步                  绩效管理  菜单修改                  绩效管理-我的报表,没有参与的大项,小项都不显示                  绩效管理-工作报表  批量查询,批量打印

---
 zhengcaioa/zhengcaioa/Timer/TimerGetShopUsersService.cs |  296 ++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 223 insertions(+), 73 deletions(-)

diff --git a/zhengcaioa/zhengcaioa/Timer/TimerGetShopUsersService.cs b/zhengcaioa/zhengcaioa/Timer/TimerGetShopUsersService.cs
index 859c2e8..3258c76 100644
--- a/zhengcaioa/zhengcaioa/Timer/TimerGetShopUsersService.cs
+++ b/zhengcaioa/zhengcaioa/Timer/TimerGetShopUsersService.cs
@@ -5,6 +5,7 @@
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
 using Microsoft.Extensions.Logging;
+using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using System;
 using System.Collections.Generic;
@@ -26,7 +27,8 @@
         private readonly IConfiguration _configuration;
         private readonly ILiaotianService _liaotianService;
         private readonly IHttpClientFactory _clientFactory;
-        private readonly IDtChannelArticleNewsService _dtChannelArticleNewsService;
+        private readonly ICooperatecustomCustomerService _cooperatecustomCustomerService;
+
 
         public TimerGetShopUsersService(ILogger<TimerGetShopUsersService> logger, IServiceScopeFactory factory)
         {
@@ -34,7 +36,9 @@
             _configuration = factory.CreateScope().ServiceProvider.GetRequiredService<IConfiguration>();
             _liaotianService = factory.CreateScope().ServiceProvider.GetRequiredService<ILiaotianService>();
             _clientFactory = factory.CreateScope().ServiceProvider.GetRequiredService<IHttpClientFactory>();
-            _dtChannelArticleNewsService = factory.CreateScope().ServiceProvider.GetRequiredService<IDtChannelArticleNewsService>();
+            _cooperatecustomCustomerService = factory.CreateScope().ServiceProvider.GetRequiredService<ICooperatecustomCustomerService>();
+
+
         }
 
         protected override async Task ExecuteAsync(CancellationToken stoppingToken)
@@ -49,7 +53,7 @@
                 _logger.LogInformation("TimerGetShopUsersService 寮�濮嬫墽琛�");
                 _logger.LogInformation(datenow.ToString("yyyy-MM-dd HH:mm:ss"));
                 //姣忎釜灏忔椂璁$畻涓�娆�
-                if (datenow.Hour <= DateTime.Now.Hour)
+                if (datenow.Hour == DateTime.Now.Hour)
                 //if (true)
                 {
 
@@ -80,17 +84,7 @@
         {
             base.Dispose();
         }
-        public   void ceshi()
-        {
-            DtChannelArticleNewsDTOSearch searchEntity = new DtChannelArticleNewsDTOSearch();
-            searchEntity.EndTime = DateTime.Parse("2021-07-15 12:06:30.893");
-            searchEntity.AddTime = DateTime.Parse("2021-07-01 12:06:30.893");
-            searchEntity.UserName = "yangjiameng";
-            searchEntity.CategoryId = 85;
-           var dtChannelArticleNewsDTOs =  _dtChannelArticleNewsService.GetList(searchEntity);
-
-            _logger.LogInformation("dtChannelArticleNewsDTOs锛�"+ dtChannelArticleNewsDTOs.Count);
-        }
+      
 
         public async Task huoquhuiyuanAsync()
         {
@@ -106,68 +100,17 @@
             resultEntity.Result = false;
 
 
-            //涔﹀煄
-            string result = string.Empty;
-            Uri getUrl = new Uri(Shuchengurl+ GetShopUsers+ "?start=2021-07-1&end=2021-07-12");
-
-            var httpClient = _clientFactory.CreateClient();
-            httpClient.Timeout = new TimeSpan(0, 0, 60);
-            var Result = await httpClient.GetAsync(getUrl);
-            result = Result.Content.ReadAsStringAsync().Result;
-
-
-            _logger.LogInformation("result:" + result);
-
-            //浼氬憳
-           
-            string result1 = string.Empty;
-            Uri postUrl = new Uri(huiyuanurl + GetDateFirstOrderUser);
-
-            JObject questions = new JObject();
-            questions.Add("start", "2021-07-12 12:36:30");
-            questions.Add("end", "2021-07-14 12:36:30");
-
-            string requestJson = questions.ToString();
-
-            using (HttpContent httpContent = new StringContent(requestJson))
-            {
-                httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
-
-                var httpClient1 = _clientFactory.CreateClient();
-                httpClient1.Timeout = new TimeSpan(0, 0, 60);
-                var Result1 = await httpClient1.PostAsync(postUrl, httpContent);
-                result1 = Result1.Content.ReadAsStringAsync().Result;
-            }
-
-            _logger.LogInformation("result1:" + result1);
 
 
 
 
-            string result2 = string.Empty;
-            Uri postUrl2 = new Uri(huiyuanurl + GetUserinfoAndRule);
 
-            JObject questions2 = new JObject();
-            questions2.Add("UserID", "248768ac-d083-462a-5bb4-08d940e7bc81");
-
-            string requestJson2 = questions2.ToString();
-
-            using (HttpContent httpContent = new StringContent(requestJson2))
-            {
-                httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
-
-                var httpClient2 = _clientFactory.CreateClient();
-                httpClient2.Timeout = new TimeSpan(0, 0, 60);
-                var Result2 = await httpClient2.PostAsync(postUrl2, httpContent);
-                result2 = Result2.Content.ReadAsStringAsync().Result;
-            }
-
-            _logger.LogInformation("result2:" + result2);
+          
 
 
 
-            using (TransactionScope scope = new TransactionScope())
-            {
+            //using (TransactionScope scope = new TransactionScope())
+            //{
                 //鑾峰彇鏈�鍚庢洿鏂版椂闂�
                 DateTime start = DateTime.Now.AddYears(-10);
                 DateTime end = DateTime.Now;
@@ -182,13 +125,220 @@
                 _logger.LogInformation("end:" + end);
 
 
-                //鑾峰彇瀹㈡埛骞朵笖淇濆瓨鍒板悎浣滃鎴�
+            //鑾峰彇瀹㈡埛骞朵笖淇濆瓨鍒板悎浣滃鎴�
+
+            #region 涔﹀煄
+            string result = string.Empty;
+                Uri getUrl = new Uri(Shuchengurl + GetShopUsers + "?start="+ start.ToString("yyyy-MM-dd HH:mm:ss") + "&end="+ end.ToString("yyyy-MM-dd HH:mm:ss"));
+
+                var httpClient = _clientFactory.CreateClient();
+                httpClient.Timeout = new TimeSpan(0, 0, 60);
+                var Result = await httpClient.GetAsync(getUrl);
+                result = Result.Content.ReadAsStringAsync().Result;
+
+
+                _logger.LogInformation("result:" + result);
+            JObject jobjectresult = (JObject)JsonConvert.DeserializeObject(result);
+
+            if (jobjectresult["code"] != null && jobjectresult["code"].ToString() == "1")
+            {
+                if(jobjectresult["returnObj"] != null && jobjectresult["returnObj"].ToString() != "")
+                {
+
+
+                    JArray hits = (JArray)jobjectresult["returnObj"];
+                    foreach (var hit in hits)
+                    {
+                        string id = hit["id"].ToString().ToLower();
+                        CooperatecustomCustomerDTO cooperatecustomCustomerDTO = _cooperatecustomCustomerService.GetList(id).FirstOrDefault();
+                        //濡傛灉涓嶅瓨鍦ㄥ叧鑱斿鎴�
+                        if (cooperatecustomCustomerDTO == null)
+                        {
+
+                            string result2 = string.Empty;
+                            Uri postUrl2 = new Uri(huiyuanurl + GetUserinfoAndRule);
+
+                            JObject questions2 = new JObject();
+                            questions2.Add("UserID", id);
+
+                            string requestJson2 = questions2.ToString();
+
+                            using (HttpContent httpContent = new StringContent(requestJson2))
+                            {
+                                httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+
+                                var httpClient2 = _clientFactory.CreateClient();
+                                httpClient2.Timeout = new TimeSpan(0, 0, 60);
+                                var Result2 = await httpClient2.PostAsync(postUrl2, httpContent);
+                                result2 = Result2.Content.ReadAsStringAsync().Result;
+                            }
+
+                            _logger.LogInformation("result2:" + result2);
+
+                            JObject jobjectresult2 = (JObject)JsonConvert.DeserializeObject(result2);
+                            if (jobjectresult2["code"] == null && jobjectresult2["code"].ToString() != "1")
+                            {
+                                throw new Exception(jobjectresult2["msg"].ToString());
+                            }
+
+                            JObject jobjectkehu = (JObject)jobjectresult2["data"];
+                            if (jobjectkehu["Name"] == null || jobjectkehu["Name"].ToString() == "")
+                            {
+                                throw new Exception("鏈壘鍒板搴旂殑浼氬憳锛�");
+                            }
+
+
+                            cooperatecustomCustomerDTO = _cooperatecustomCustomerService.GetList("", jobjectkehu["Name"].ToString()).FirstOrDefault();
+                            //濡傛灉涓嶅瓨鍦ㄥ綋鍓嶅悕瀛楃殑瀹㈡埛
+                            if (cooperatecustomCustomerDTO == null)
+                            {
+                                cooperatecustomCustomerDTO = new CooperatecustomCustomerDTO();
+                                cooperatecustomCustomerDTO.Name = jobjectkehu["Name"].ToString();
+                                cooperatecustomCustomerDTO.Tel = jobjectkehu["phonecode"].ToString();
+                                cooperatecustomCustomerDTO.Phone = jobjectkehu["phonecode"].ToString();
+
+                                cooperatecustomCustomerDTO.HuiyuanId = id;
+                                //cooperatecustomCustomerDTO.Remark = hit["personal"].ToString() + "涓嬪崟鏃堕棿" + hit["Firsttime"].ToString();
+                                cooperatecustomCustomerDTO.Khly = "01";
+                                cooperatecustomCustomerDTO.Creater = "1";
+                                cooperatecustomCustomerDTO.Createtime = DateTime.Now;
+                                cooperatecustomCustomerDTO.Modifier = cooperatecustomCustomerDTO.Creater;
+                                cooperatecustomCustomerDTO.Modifytime = cooperatecustomCustomerDTO.Createtime;
+
+                                cooperatecustomCustomerDTO.ShrName = hit["accept_name"].ToString();
+                                cooperatecustomCustomerDTO.ShrTel = hit["mobile"].ToString();
+                                cooperatecustomCustomerDTO.ShrAddress = hit["area"].ToString() + hit["address"].ToString();
+
+                                resultEntity = _cooperatecustomCustomerService.save(cooperatecustomCustomerDTO);
+                                if (!resultEntity.Result)
+                                {
+                                    throw new Exception("淇濆瓨鍚堜綔瀹㈡埛:" + cooperatecustomCustomerDTO.Name + "鍑洪敊锛�");
+                                }
+                            }
+                            else
+                            {
+                                cooperatecustomCustomerDTO.HuiyuanId = id;
+                                cooperatecustomCustomerDTO.ShrName = hit["accept_name"].ToString();
+                                cooperatecustomCustomerDTO.ShrTel = hit["mobile"].ToString();
+                                cooperatecustomCustomerDTO.ShrAddress = hit["area"].ToString() + hit["address"].ToString();
+                                resultEntity = _cooperatecustomCustomerService.save(cooperatecustomCustomerDTO);
+                                if (!resultEntity.Result)
+                                {
+                                    throw new Exception("淇濆瓨鍚堜綔瀹㈡埛:" + cooperatecustomCustomerDTO.Name + "鍑洪敊锛�");
+                                }
+                            }
+                        }
+                        else
+                        {
+                            cooperatecustomCustomerDTO.HuiyuanId = id;
+                            cooperatecustomCustomerDTO.ShrName = hit["accept_name"].ToString();
+                            cooperatecustomCustomerDTO.ShrTel = hit["mobile"].ToString();
+                            cooperatecustomCustomerDTO.ShrAddress = hit["area"].ToString() + hit["address"].ToString();
+                            resultEntity = _cooperatecustomCustomerService.save(cooperatecustomCustomerDTO);
+                            if (!resultEntity.Result)
+                            {
+                                throw new Exception("淇濆瓨鍚堜綔瀹㈡埛:" + cooperatecustomCustomerDTO.Name + "鍑洪敊锛�");
+                            }
+                        }
+
+                    }
+
+                }
+            }
+            else
+            {
+                throw new Exception(jobjectresult["error"].ToString());
+            }
 
 
 
+              
 
-                //淇濆瓨鏈�鍚庢洿鏂版椂闂�
-                if (ssss != null)
+            #endregion
+
+
+            #region 浼氬憳
+            string result1 = string.Empty;
+            Uri postUrl = new Uri(huiyuanurl + GetDateFirstOrderUser);
+
+            JObject questions = new JObject();
+            questions.Add("start", start.ToString("yyyy-MM-dd HH:mm:ss"));
+            questions.Add("end", end.ToString("yyyy-MM-dd HH:mm:ss"));
+
+            string requestJson = questions.ToString();
+
+            using (HttpContent httpContent = new StringContent(requestJson))
+            {
+                httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+
+                var httpClient1 = _clientFactory.CreateClient();
+                httpClient1.Timeout = new TimeSpan(0, 0, 60);
+                var Result1 = await httpClient1.PostAsync(postUrl, httpContent);
+                result1 = Result1.Content.ReadAsStringAsync().Result;
+            }
+
+            _logger.LogInformation("result1:" + result1);
+            JObject jobject = (JObject)JsonConvert.DeserializeObject(result1);
+
+            if (jobject["code"] != null && jobject["code"].ToString() == "1")
+            {
+                if (jobject["data"] != null && jobject["data"].ToString() != "")
+                {
+                    JArray hits = (JArray)jobject["data"];
+                    foreach (var hit in hits)
+                    {
+                        CooperatecustomCustomerDTO cooperatecustomCustomerDTO = _cooperatecustomCustomerService.GetList(hit["ID"].ToString()).FirstOrDefault();
+                        //濡傛灉涓嶅瓨鍦ㄥ叧鑱斿鎴�
+                        if (cooperatecustomCustomerDTO == null)
+                        {
+                            cooperatecustomCustomerDTO = _cooperatecustomCustomerService.GetList("", hit["Name"].ToString()).FirstOrDefault();
+                            //濡傛灉涓嶅瓨鍦ㄥ綋鍓嶅悕瀛楃殑瀹㈡埛
+                            if (cooperatecustomCustomerDTO == null)
+                            {
+                                cooperatecustomCustomerDTO = new CooperatecustomCustomerDTO();
+                                cooperatecustomCustomerDTO.Name = hit["Name"].ToString();
+                                cooperatecustomCustomerDTO.Tel = hit["PhoneCode"].ToString();
+                                cooperatecustomCustomerDTO.Phone = hit["PhoneCode"].ToString();
+
+                                cooperatecustomCustomerDTO.HuiyuanId = hit["ID"].ToString();
+                                cooperatecustomCustomerDTO.Remark = hit["personal"].ToString() + "涓嬪崟鏃堕棿" + hit["Firsttime"].ToString();
+                                cooperatecustomCustomerDTO.Khly = "01";
+                                cooperatecustomCustomerDTO.Creater = "1";
+                                cooperatecustomCustomerDTO.Createtime = DateTime.Now;
+                                cooperatecustomCustomerDTO.Modifier = cooperatecustomCustomerDTO.Creater;
+                                cooperatecustomCustomerDTO.Modifytime = cooperatecustomCustomerDTO.Createtime;
+
+                                resultEntity = _cooperatecustomCustomerService.save(cooperatecustomCustomerDTO);
+                                if (!resultEntity.Result)
+                                {
+                                    throw new Exception("淇濆瓨鍚堜綔瀹㈡埛:" + cooperatecustomCustomerDTO.Name + "鍑洪敊锛�");
+                                }
+                            }
+                            else
+                            {
+                                cooperatecustomCustomerDTO.HuiyuanId = hit["ID"].ToString();
+                                resultEntity = _cooperatecustomCustomerService.save(cooperatecustomCustomerDTO);
+                                if (!resultEntity.Result)
+                                {
+                                    throw new Exception("淇濆瓨鍚堜綔瀹㈡埛:" + cooperatecustomCustomerDTO.Name + "鍑洪敊锛�");
+                                }
+                            }
+                        }
+
+                    }
+                }
+                    
+            }
+            else
+            {
+                throw new Exception(jobject["msg"].ToString());
+            }
+
+            #endregion
+
+
+            //淇濆瓨鏈�鍚庢洿鏂版椂闂�
+            if (ssss != null)
                 {
                     ssss.Updatetime = end;
                 }
@@ -204,8 +354,8 @@
                     throw new Exception("淇濆瓨鏇存柊鏃堕棿鍑洪敊锛�");
                 }
 
-                scope.Complete();
-            }
+            //    scope.Complete();
+            //}
 
              
 

--
Gitblit v1.9.1