Sfoglia il codice sorgente

Merge branch 'master' of http://192.168.1.222:3000/zhengbingbing/ZLJ_API_V6.0

zhengbingbing 5 anni fa
parent
commit
abfb7bf62b

+ 121 - 12
代码/TVShoppingCallCenter_ZLJ/Controllers/ManagementCenter/ManagementCenterController.cs

@@ -3,6 +3,8 @@ using System.Collections.Generic;
3 3
 using System.Common;
4 4
 using System.IRepositories;
5 5
 using System.Linq;
6
+using System.Security.Claims;
7
+using System.Text;
6 8
 using System.Threading.Tasks;
7 9
 using Microsoft.AspNetCore.Mvc;
8 10
 using SqlSugar;
@@ -13,13 +15,14 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.ManagementCenter
13 15
     [Route("api/[controller]")]
14 16
     public class ManagementCenterController : BaseController
15 17
     {
16
-        private readonly ICus_VipInfoRepository _cus_vip_infoRepository;
17
-        private readonly ISys_UserAccountRepository _sys_useraccountRepository;
18
-        private readonly ISys_TaskManagementRepository _sys_taskmanagement_Repository;
19
-        private readonly ISys_DepartmentRepository _sys_departmentRepository;
20
-        public ManagementCenterController(ICus_VipInfoRepository cus_vip_infoRepository, ISys_TaskManagementRepository sys_taskmanagement_Repository, ISys_DepartmentRepository sys_departmentRepository,
21
-            ISys_UserAccountRepository sys_useraccountRepository)
18
+        private readonly IBus_OrderRepository _bus_OrderRepository;//订单
19
+        private readonly ICus_VipInfoRepository _cus_vip_infoRepository;//客户
20
+        private readonly ISys_UserAccountRepository _sys_useraccountRepository;//用户
21
+        private readonly ISys_TaskManagementRepository _sys_taskmanagement_Repository;//任务
22
+        private readonly ISys_DepartmentRepository _sys_departmentRepository;//部门
23
+        public ManagementCenterController(ICus_VipInfoRepository cus_vip_infoRepository, ISys_TaskManagementRepository sys_taskmanagement_Repository, ISys_DepartmentRepository sys_departmentRepository, ISys_UserAccountRepository sys_useraccountRepository,IBus_OrderRepository bus_OrderRepository)
22 24
         {
25
+            _bus_OrderRepository = bus_OrderRepository;
23 26
             _cus_vip_infoRepository = cus_vip_infoRepository;
24 27
             _sys_taskmanagement_Repository = sys_taskmanagement_Repository;
25 28
             _sys_departmentRepository = sys_departmentRepository;
@@ -34,17 +37,123 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.ManagementCenter
34 37
         public async Task<IActionResult> Realtimesales(string time)
35 38
         {
36 39
             if (string.IsNullOrEmpty(time))
37
-                time = DateTime.Now.ToString("yyyy-MM-dd");
38
-            var customer = _cus_vip_infoRepository.GetListALL(x => x.F_CreateOn >= DateTime.Parse(time + "00:00:00").AddDays (-1) && x.F_CreateOn <= DateTime.Parse(time + "23:59:59")).Result;
39
-            int newcustomer = customer .Select (x=>x.F_CreateOn >= DateTime.Parse(time + "00:00:00")&& x.F_CreateOn <= DateTime.Parse(time + "23:59:59")) != null ? customer .Select(x => x.F_CreateOn >= DateTime.Parse(time + "00:00:00") && x.F_CreateOn <= DateTime.Parse(time + "23:59:59")).Count ():0;//新增客户
40
-            int oldcustomer = customer.Select(x => x.F_CreateOn >= DateTime.Parse(time + "00:00:00").AddDays (-1) && x.F_CreateOn <= DateTime.Parse(time + "23:59:59").AddDays(-1)) != null ? customer.Select(x => x.F_CreateOn >= DateTime.Parse(time + "00:00:00").AddDays(-1) && x.F_CreateOn <= DateTime.Parse(time + "23:59:59").AddDays(-1)).Count() : 0;//昨日新增客户
40
+                time = DateTime.Now.ToString("yyyy-MM-dd"); 
41
+            var todaycustomer = _cus_vip_infoRepository.GetListALL(x => x.F_CreateOn >= DateTime.Parse(time + " 00:00:00") && x.F_CreateOn <= DateTime.Parse(time + " 23:59:59")).Result;//新增客户
42
+            var yesterday= _cus_vip_infoRepository.GetListALL(x => x.F_CreateOn >= DateTime.Parse(time + " 00:00:00").AddDays(-1) && x.F_CreateOn <= DateTime.Parse(time + " 23:59:59").AddDays(-1)).Result;//昨日新增客户
43
+            int newcustomer = todaycustomer != null ? todaycustomer.Count ():0;//新增客户
44
+            int oldcustomer = yesterday != null ? yesterday.Count() : 0;//昨日新增客户
41 45
             int newaftersale = 0;//售后订单量
42 46
             int oldaftersale = 0;//昨日订单量
43
-            int customerorder = 0;
47
+            List<IConditionalModel> conModels = new List<IConditionalModel>();
48
+            int newcustomers = 0;//新客户下单量
49
+            int oldcustomers = 0;//昨日新客户下单量
50
+            int newcustomerorder = 0;//老客户下单量
51
+            int oldcustomerorder = 0;//昨日老客户下单量
52
+            string vipid = "";
53
+            if (newcustomer>0)
54
+            {
55
+                string  F_VipId = "";
56
+                foreach (var it in todaycustomer)
57
+                {
58
+                    if (F_VipId == "")
59
+                        F_VipId = it.F_ID + "";
60
+                    else
61
+                        F_VipId +=","+ it.F_ID + "";
62
+                    if (vipid == "")
63
+                        vipid = it.F_ID + "";
64
+                    else
65
+                        vipid += "," + it.F_ID + "";
66
+                }
67
+                if (F_VipId == "")
68
+                    newcustomers = 0;
69
+                else 
70
+                newcustomers = _bus_OrderRepository.GetListALL(ConModels(DateTime .Parse (time), F_VipId,true ), " F_AddTime DESC").Result != null ? _bus_OrderRepository.GetListALL(ConModels(DateTime.Parse(time), F_VipId, true), " F_AddTime DESC").Result.Count : 0;
71
+            }
72
+            if (vipid == "")
73
+                newcustomerorder = 0;
74
+            else
75
+                newcustomerorder = _bus_OrderRepository.GetListALL(ConModels(DateTime.Parse(time), vipid, false), " F_AddTime DESC").Result != null ? _bus_OrderRepository.GetListALL(ConModels(DateTime.Parse(time), vipid, false), " F_AddTime DESC").Result.Count : 0;
76
+            if (oldcustomer > 0)
77
+            { 
78
+                string F_VipId = "";
79
+                foreach (var it in yesterday)
80
+                {
81
+                    if (F_VipId == "")
82
+                        F_VipId = it.F_ID + "";
83
+                    else
84
+                        F_VipId += "," + it.F_ID + "";
85
+                    if (vipid == "")
86
+                        vipid = it.F_ID + "";
87
+                    else
88
+                        vipid += "," + it.F_ID + "";
89
+                }
90
+                if (F_VipId == "")
91
+                    oldcustomers = 0;
92
+                else 
93
+                oldcustomers = _bus_OrderRepository.GetListALL(ConModels(DateTime.Parse(time).AddDays (-1), F_VipId, true), " F_AddTime DESC").Result != null ? _bus_OrderRepository.GetListALL(ConModels(DateTime.Parse(time).AddDays(-1), F_VipId,true), " F_AddTime DESC").Result.Count : 0;
94
+            }
95
+            if (vipid == "")
96
+                oldcustomerorder = 0;
97
+            else
98
+                oldcustomerorder = _bus_OrderRepository.GetListALL(ConModels(DateTime.Parse(time).AddDays(-1), vipid, false), " F_AddTime DESC").Result != null ? _bus_OrderRepository.GetListALL(ConModels(DateTime.Parse(time).AddDays(-1), vipid, false), " F_AddTime DESC").Result.Count : 0;
99
+            var obj = new
100
+            {
101
+                state = "success",
102
+                message = "成功",
103
+                 newcustomer,//新增客户
104
+                oldcustomer ,//昨日新增客户
105
+                newaftersale ,//售后订单量
106
+                oldaftersale,//昨日订单量
107
+                newcustomers,//新客户下单量
108
+                oldcustomers,//昨日新客户下单量
109
+                newcustomerorder,//老客户下单量
110
+                oldcustomerorder,//昨日老客户下单量
44 111
 
112
+            };
113
+            return Content(obj.ToJson());
114
+        }
115
+        private List<IConditionalModel> ConModels (DateTime time,string F_VipId,bool n )
116
+        {
117
+            List<IConditionalModel> conModels = new List<IConditionalModel>();
118
+            conModels.Add(new ConditionalModel() { FieldName = "F_State", ConditionalType = ConditionalType.GreaterThanOrEqual, FieldValue = "0" });
119
+            conModels.Add(new ConditionalModel() { FieldName = "F_AddTime", ConditionalType = ConditionalType.LessThanOrEqual, FieldValue = time.ToString("yyyy-MM-dd 23:59:59") });
120
+            conModels.Add(new ConditionalModel() { FieldName = "F_AddTime", ConditionalType = ConditionalType.GreaterThanOrEqual, FieldValue = time.ToString("yyyy-MM-dd 00:00:00") });
121
+            if (n )
122
+            {
123
+                conModels.Add(new ConditionalModel() { FieldName = "F_VipId", ConditionalType = ConditionalType.In, FieldValue = F_VipId });
124
+            }
125
+            else
126
+            {
127
+                conModels.Add(new ConditionalModel() { FieldName = "F_VipId", ConditionalType = ConditionalType.NotIn, FieldValue = F_VipId });
128
+            }
129
+            return conModels;
130
+        }
131
+        /// <summary>
132
+        /// 实时销售行为分析
133
+        /// </summary>
134
+        /// <param name="time"></param>
135
+        /// <returns></returns>
136
+        [HttpGet("totaltasks")]
137
+        public async Task<IActionResult> Totaltasks(string time)
138
+        {
139
+            if (string.IsNullOrEmpty(time))
140
+                time = DateTime.Now.ToString("yyyy-MM");
141
+            string user = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
142
+            int userid= _sys_useraccountRepository.GetSingle(x => x.F_UserCode  == user).Result!=null ? _sys_useraccountRepository.GetSingle(x => x.F_UserCode == user).Result.F_UserId:0;
143
+            if (userid > 0)
144
+            {
145
+                List<IConditionalModel> conModels = new List<IConditionalModel>();
146
+                conModels.Add(new ConditionalModel() { FieldName = "F_IsDelete", ConditionalType = ConditionalType.GreaterThanOrEqual, FieldValue = "0" });
147
+                conModels.Add(new ConditionalModel() { FieldName = "F_CreateTime", ConditionalType = ConditionalType.LessThanOrEqual, FieldValue = DateTime .Parse ( time).AddMonths (1).AddDays (-1).ToString("yyyy-MM-dd 23:59:59") });
148
+                conModels.Add(new ConditionalModel() { FieldName = "F_CreateTime", ConditionalType = ConditionalType.GreaterThanOrEqual, FieldValue = DateTime.Parse(time).ToString("yyyy-MM-01 00:00:00") });
149
+                return null;
150
+            }
151
+                else
152
+                return Error("查询失败");
45 153
 
46
-            return null;
47 154
         }
48 155
 
156
+
157
+
49 158
     }
50 159
 }

+ 23 - 27
代码/TVShoppingCallCenter_ZLJ/Controllers/MediaCente/MediaCenteController.cs

@@ -90,6 +90,7 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.MediaCente
90 90
          string user = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
91 91
             var model = new T_Sys_MediaCente();
92 92
             model =  Transformation(model, input, user, 0);
93
+            model.F_State = 0;
93 94
             var res = await _sys_mediacenter_Repository.Add(model);
94 95
             if (res > 0)
95 96
             {
@@ -231,7 +232,6 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.MediaCente
231 232
         {
232 233
             List<IConditionalModel> conModels = new List<IConditionalModel>();
233 234
             conModels.Add(new ConditionalModel() { FieldName = "F_State", ConditionalType = ConditionalType.Equal, FieldValue = ((int)EnumDelState.Enabled).ToString() });
234
-            conModels.Add(new ConditionalModel() { FieldName = "F_ParentId", ConditionalType = ConditionalType.Equal, FieldValue = pid.ToString() });
235 235
             var list_ModuleInfo = await _sys_areaRepository.GetListALL(conModels, "F_Code asc");
236 236
 
237 237
             var treeList = new List<TreeModel>();
@@ -244,7 +244,7 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.MediaCente
244 244
                 treeModel.parentid = item.F_ParentId.Value;
245 245
                 treeList.Add(treeModel);
246 246
             }
247
-            return Success("获取地区树成功", TreeRecursion(treeList,0));
247
+            return Success("获取地区树成功", TreeRecursion(treeList, pid));
248 248
         }
249 249
         /// <summary>
250 250
         /// 递归算法
@@ -377,37 +377,34 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.MediaCente
377 377
 
378 378
                 }
379 379
             }
380
-            if (type >0)
380
+            MediaCente.F_IsRemind = (int)it.F_IsRemind; //是否提醒
381
+            MediaCente.F_DeptId = it.F_DeptId; //提醒部门
382
+            string deptmsg = "";
383
+            if (!string.IsNullOrEmpty(it.F_DeptId))
381 384
             {
382
-                MediaCente.F_IsRemind = (int)it.F_IsRemind; //是否提醒
383
-                MediaCente.F_DeptId = it.F_DeptId; //提醒部门
384
-                string deptmsg = "";
385
-                if (!string .IsNullOrEmpty (it .F_DeptId ))
385
+                try
386 386
                 {
387
-                    try
388
-                    {
389
-                       
390
-                        string[] sprit = it.F_DeptId.Split(',');
391
-                        foreach (var iv in sprit)
392
-                        {
393
-                           
394
-                            if (deptmsg=="")
395
-                                deptmsg= _sys_departmentRepository.GetSingle(x => x.F_DeptId == int.Parse(iv)).Result != null ? _sys_departmentRepository.GetSingle(x => x.F_DeptId == int.Parse(iv)).Result.F_DeptName : "";
396
-                            else
397
-                                deptmsg= deptmsg+","+ _sys_departmentRepository.GetSingle(x => x.F_DeptId == int.Parse(iv)).Result != null ? _sys_departmentRepository.GetSingle(x => x.F_DeptId == int.Parse(iv)).Result.F_DeptName : "";
398 387
 
399
-                        }
400
-                      
401
-                    }
402
-                    catch
388
+                    string[] sprit = it.F_DeptId.Split(',');
389
+                    foreach (var iv in sprit)
403 390
                     {
404 391
 
392
+                        if (deptmsg == "")
393
+                            deptmsg = _sys_departmentRepository.GetSingle(x => x.F_DeptId == int.Parse(iv)).Result != null ? _sys_departmentRepository.GetSingle(x => x.F_DeptId == int.Parse(iv)).Result.F_DeptName : "";
394
+                        else
395
+                            deptmsg = deptmsg + "," + _sys_departmentRepository.GetSingle(x => x.F_DeptId == int.Parse(iv)).Result != null ? _sys_departmentRepository.GetSingle(x => x.F_DeptId == int.Parse(iv)).Result.F_DeptName : "";
396
+
405 397
                     }
406
-                   
398
+
399
+                }
400
+                catch
401
+                {
402
+
407 403
                 }
408
-                MediaCente.F_DeptName = deptmsg;
409
-                MediaCente.F_ReminderTime = it.F_ReminderTime; //提醒时间
404
+
410 405
             }
406
+            MediaCente.F_DeptName = deptmsg;
407
+            MediaCente.F_ReminderTime = it.F_ReminderTime; //提醒时间
411 408
             MediaCente.F_MediaChange = it.F_MediaChange; //媒体变更  ID
412 409
             if (type > 0)
413 410
             {
@@ -420,8 +417,7 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.MediaCente
420 417
                         PlanManagemenInput t_Sys_PlanManagemen = new PlanManagemenInput();
421 418
                         var planplay = _sys_planmanagemenRepository.GetSingle(x => x.F_Id == int.Parse(ib)).Result;
422 419
                         t_Sys_PlanManagemen.F_Type =(int ) planplay.F_Type;//0计划1媒体变更 
423
-                        t_Sys_PlanManagemen.F_State = planplay.F_State.ToString ();//状态
424
-                        t_Sys_PlanManagemen.F_ChangeType = (int)planplay.F_ChangeType;//变更类型字典
420
+                        t_Sys_PlanManagemen.F_ChangeType = planplay.F_ChangeType!=null ? (int )planplay.F_ChangeType:0 ;//变更类型字典
425 421
                         t_Sys_PlanManagemen.F_ChangeTypeName= _sys_dictionaryRepository.GetSingle(x => x.F_ValueId == planplay.F_ChangeType).Result.F_Value;//  /变更类型
426 422
                         t_Sys_PlanManagemen.F_ChangeTime = planplay.F_ChangeTime;//变更时间
427 423
                         t_Sys_PlanManagemen.F_Describe = planplay.F_Describe;//变更说明

+ 1 - 1
代码/TVShoppingCallCenter_ZLJ/Controllers/TaskManagement/TaskManagementController.cs

@@ -400,7 +400,7 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.TaskManagement
400 400
                     }
401 401
                     if (_sys_useraccountRepository.GetSingle(x => x.F_UserName == dr["任务人"].ToString()).Result != null)
402 402
                     {
403
-                        model.F_Tasker = _sys_useraccountRepository.GetSingle(x => x.F_UserName == dr["任务人"].ToString()).Result.F_UserId ;
403
+                        model.F_Tasker = _sys_useraccountRepository.GetSingle(x => x.F_UserName == dr["任务人"].ToString()).Result.F_UserId   ;
404 404
                       
405 405
                     }
406 406
                     else