|
|
@@ -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
|
}
|