From 81ac184ee7fcf0a93eee4d2026edc91f3f3c0070 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期三, 28 十二月 2022 10:07:57 +0800
Subject: [PATCH] 意向客户的电话次数,展示

---
 zhengcaioa/zhengcaioa/appsettings.Development.json         |    2 
 zhengcaioa/DTO/IntentionCustomerDTO.cs                     |    5 ++
 zhengcaioa/Services/IntentionCustomerService.cs            |   51 +++++++++++++++++++++++--
 zhengcaioa/zhengcaioa/Views/IntentionCustomer/Index.cshtml |   14 ++++++
 4 files changed, 64 insertions(+), 8 deletions(-)

diff --git a/zhengcaioa/DTO/IntentionCustomerDTO.cs b/zhengcaioa/DTO/IntentionCustomerDTO.cs
index 828629e..6827f02 100644
--- a/zhengcaioa/DTO/IntentionCustomerDTO.cs
+++ b/zhengcaioa/DTO/IntentionCustomerDTO.cs
@@ -64,6 +64,9 @@
         public DateTime? Weixintime { get; set; }
         public string HuiyuanId { get; set; }
         public string Customertype { get; set; }
+
+        public int? Visittimes { get; set; }
+        public string Viscustomer { get; set; }
     }
 
     public class IntentionCustomerDTOSearch : SearchEntity
@@ -93,7 +96,7 @@
         public string ShifouDianhua { get; set; }
 
         public string Customertype { get; set; }
-        
 
+        public string Visittimes { get; set; }
     }
 }
diff --git a/zhengcaioa/Services/IntentionCustomerService.cs b/zhengcaioa/Services/IntentionCustomerService.cs
index 4d9b9a9..8a8d309 100644
--- a/zhengcaioa/Services/IntentionCustomerService.cs
+++ b/zhengcaioa/Services/IntentionCustomerService.cs
@@ -206,6 +206,13 @@
                // Yixiangtimeend = Yixiangtimeend.AddDays(1);
             }
 
+            int aaaa = 0;
+            if (!string.IsNullOrWhiteSpace(searchEntity.Visittimes))
+            {
+                int.TryParse(searchEntity.Visittimes, out aaaa);    
+            }
+
+
             var query = (from a in _context.IntentionCustomers
                      join b in listCode.Where(x => x.CodeTable == "IntentionCustomer" && x.CodeField == "khly")
                      on a.Khly equals b.CodeSn
@@ -227,7 +234,17 @@
                      join g in _context.Areas on a.City equals g.CodeId
                      join h in _context.Areas on a.AreaId equals h.CodeId
 
-                     where a.RecStatus == "A"
+
+                         join l in _context.IntentionVisits.Where(x => x.RecStatus == "A").GroupBy(q => new { q.Viscustomer }).Select(q => new
+                         {
+                             Viscustomer = q.Key.Viscustomer,
+                             Visittimes = q.Count(),
+                         })
+                           on a.Id equals l.Viscustomer
+                         into lsss
+                         from lll in lsss.DefaultIfEmpty()
+
+                         where a.RecStatus == "A"
                       && (string.IsNullOrWhiteSpace(searchEntity.Createtime) || (a.Createtime >= Createtimestart && a.Createtime <= Createtimeend))
                      && (string.IsNullOrWhiteSpace(searchEntity.Name) || a.Name.Contains(searchEntity.Name.Trim()))
                       && (string.IsNullOrWhiteSpace(searchEntity.Khly) || a.Khly == searchEntity.Khly.Trim())
@@ -243,6 +260,9 @@
                                 
                                     && (string.IsNullOrWhiteSpace(searchEntity.Yixiangtime) || (a.Yixiangtime >= Yixiangtimestart && a.Yixiangtime <= Yixiangtimeend))
                                       && (string.IsNullOrWhiteSpace(searchEntity.Yixiang) || ( a.Yixiang == searchEntity.Yixiang.Trim() && (a.Ywjl == null || a.Ywjl == searchEntity.YwjlYx) ))
+                                       && (aaaa <= 0 || lll.Visittimes >= aaaa)
+
+                                      
                                       //&& (string.IsNullOrWhiteSpace(searchEntity.Shifouweixin) || a.Shifoutianjiaweixin == searchEntity.Shifouweixin.Trim())
                          select new IntentionCustomerDTO
                      {
@@ -300,7 +320,8 @@
                                  DianxiaozhuanyuanName = fff.UserName,
                                  Zuijinzhuizongtime = a.Zuijinzhuizongtime,
                                  ZuijinzhuizongtimeName = a.Zuijinzhuizongtime.HasValue ? a.Zuijinzhuizongtime.Value.ToString("yyyy-MM-dd") : "",
-                             }
+                             Visittimes = lll.Visittimes,
+                         }
                     );
 
             if (!string.IsNullOrWhiteSpace(searchEntity.Shifouweixin))
@@ -319,12 +340,32 @@
                 }
                 
             }
-            
+            if (!string.IsNullOrWhiteSpace(searchEntity.Visittimes))
+            {
+                if (searchEntity.ShifouDianhua != "A")
+                {
+                    query = query.Where(a => a.Tel == null || a.Tel == "");
+                }
+                else
+                {
+                    query = query.Where(a => a.Tel != null && a.Tel != "");
+                }
 
-        //if (searchEntity.totalrows == 0)
+            }
+             
+
+            //if (searchEntity.totalrows == 0)
             searchEntity.totalrows = query.Count();
         var lianlist = query.OrderByDescending(x => x.Modifytime).Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList();
-        data.LoadData(searchEntity, lianlist);
+
+
+            //foreach (var intentionCustomerDTO in lianlist)
+            //{
+            //    intentionCustomerDTO.Visittimes = _context.IntentionVisits.Count(x => x.RecStatus == "A" && x.Viscustomer == intentionCustomerDTO.Id);
+            //}
+
+
+            data.LoadData(searchEntity, lianlist);
         return data;
     }
 
diff --git a/zhengcaioa/zhengcaioa/Views/IntentionCustomer/Index.cshtml b/zhengcaioa/zhengcaioa/Views/IntentionCustomer/Index.cshtml
index 6da8283..05077ac 100644
--- a/zhengcaioa/zhengcaioa/Views/IntentionCustomer/Index.cshtml
+++ b/zhengcaioa/zhengcaioa/Views/IntentionCustomer/Index.cshtml
@@ -43,6 +43,18 @@
             { label: '瀹㈡埛绫诲瀷', name: 'KhlxName', labtype: 'txt', hidden: false, width: 100},
             { label: '涓氬姟缁忕悊', name: 'YwjlName', labtype: 'txt', hidden: false, width: 100 },
             {
+                label: '璁块棶娆℃暟', name: 'Visittimes', labtype: 'txt', hidden: false, width: 100,
+                formatter: function (cellvalue, options, rowObject) {
+                    if (cellvalue == null) {
+                        return "0";
+                    } else {
+                        return cellvalue;
+                    }
+                   
+                }
+            },
+            
+            {
                 label: '瀹㈡埛璁块棶', name: 'Name111', labtype: 'txt', hidden: false, width: 100,
                 formatter: function (cellvalue, options, rowObject) {
                     return "<a  class='Fangwen' style='display: none;' onclick=\"OpenWindow('鏂板鎰忓悜瀹㈡埛鎷滆','98%','100%', '/IntentionVisit/Edit?id=&Viscustomer=" + rowObject.Id + "')\"  >瀹㈡埛璁块棶</a>";
@@ -65,8 +77,8 @@
             { label: '褰曞叆浜�', name: 'Creater', labtype: 'combox', hidden: false, data: JSON.parse(Creater), cwidth: '5%', cccwidth: '8%' },
             { label: '鏄惁鍔犲井淇�', name: 'Shifouweixin', labtype: 'combox', hidden: false, data: JSON.parse(shifou), cwidth: '5%', cccwidth: '8%' },
             { label: '鏄惁褰曞叆鐢佃瘽', name: 'ShifouDianhua', labtype: 'combox', hidden: false, data: JSON.parse(shifou), cwidth: '5%', cccwidth: '8%' },
+            { label: '璁块棶娆℃暟澶т簬', name: 'Visittimes', labtype: 'txt', hidden: false },
             
-
         ];
         var _pageAdd = function () {
             OpenWindow("鏂板鎰忓悜瀹㈡埛", "98%", "100%", "/IntentionCustomer/Edit/");
diff --git a/zhengcaioa/zhengcaioa/appsettings.Development.json b/zhengcaioa/zhengcaioa/appsettings.Development.json
index b219d0d..8bb28ea 100644
--- a/zhengcaioa/zhengcaioa/appsettings.Development.json
+++ b/zhengcaioa/zhengcaioa/appsettings.Development.json
@@ -1,6 +1,6 @@
 {
   "ConnectionStrings": {
-    "DefaultConnection": "server=.;database=zhengcaioa;uid=sa;pwd=123456;",
+    "DefaultConnection": "server=localhost;database=zhengcaioa;uid=sa;pwd=123456;",
     "zcwebConnection": "server=localhost;database=zcweb;uid=sa;pwd=123456;",
     "zcUserInfoNConnection": "server=localhost;database=zcUserInfoN_db;uid=sa;pwd=123456;",
     "WebCrawlerConnection": "server=localhost;database=WebCrawler;uid=sa;pwd=123456;"

--
Gitblit v1.9.1