96009bc9
hexiaodong
hxd
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
using NCC.Common.Core.Manager;
using NCC.Common.Enum;
using NCC.Common.Extension;
using NCC.Common.Filter;
using NCC.Dependency;
using NCC.DynamicApiController;
using NCC.FriendlyException;
using NCC.Extend.Interfaces.LqXmzl;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
|
efde7d04
“wangming”
更新多个文件,删除不再使用的CSS...
|
16
|
using NCC.Extend.Entitys.lq_xmzl;
|
96009bc9
hexiaodong
hxd
|
17
|
using NCC.Extend.Entitys.Dto.LqXmzl;
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
18
19
20
21
22
23
|
using NCC.Extend.Entitys.lq_kd_pxmx;
using NCC.Extend.Entitys.lq_xh_pxmx;
using NCC.Extend.Entitys.lq_hytk_mx;
using NCC.Extend.Entitys.lq_kd_kdjlb;
using NCC.Extend.Entitys.lq_xh_hyhk;
using NCC.Extend.Entitys.lq_hytk_hytk;
|
96009bc9
hexiaodong
hxd
|
24
25
26
27
28
29
30
31
32
33
34
35
36
|
using Yitter.IdGenerator;
using NCC.Common.Helper;
using NCC.JsonSerialization;
using NCC.Common.Model.NPOI;
using NCC.Common.Configuration;
using NCC.DataEncryption;
using NCC.ClayObject;
namespace NCC.Extend.LqXmzl
{
/// <summary>
/// 项目资料服务
/// </summary>
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
37
|
[ApiDescriptionSettings(Tag = "绿纤品项资料服务", Name = "LqXmzl", Order = 200)]
|
96009bc9
hexiaodong
hxd
|
38
39
40
41
42
43
44
45
46
47
|
[Route("api/Extend/[controller]")]
public class LqXmzlService : ILqXmzlService, IDynamicApiController, ITransient
{
private readonly ISqlSugarRepository<LqXmzlEntity> _lqXmzlRepository;
private readonly SqlSugarScope _db;
private readonly IUserManager _userManager;
/// <summary>
/// 初始化一个<see cref="LqXmzlService"/>类型的新实例
/// </summary>
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
48
|
public LqXmzlService(ISqlSugarRepository<LqXmzlEntity> lqXmzlRepository, IUserManager userManager)
|
96009bc9
hexiaodong
hxd
|
49
|
{
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
50
|
_lqXmzlRepository = lqXmzlRepository;
|
96009bc9
hexiaodong
hxd
|
51
52
53
54
|
_db = _lqXmzlRepository.Context;
_userManager = userManager;
}
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
55
|
#region 获取品项资料
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
56
|
|
96009bc9
hexiaodong
hxd
|
57
58
59
60
61
62
63
64
65
66
67
68
|
/// <summary>
/// 获取项目资料
/// </summary>
/// <param name="id">参数</param>
/// <returns></returns>
[HttpGet("{id}")]
public async Task<dynamic> GetInfo(string id)
{
var entity = await _db.Queryable<LqXmzlEntity>().FirstAsync(p => p.Id == id);
var output = entity.Adapt<LqXmzlInfoOutput>();
return output;
}
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
69
|
#endregion
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
70
|
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
71
|
#region 获取品项资料列表
|
96009bc9
hexiaodong
hxd
|
72
|
/// <summary>
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
73
|
/// 获取品项资料列表
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
74
75
76
|
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
|
96009bc9
hexiaodong
hxd
|
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
[HttpGet("")]
public async Task<dynamic> GetList([FromQuery] LqXmzlListQueryInput input)
{
var sidx = input.sidx == null ? "id" : input.sidx;
var data = await _db.Queryable<LqXmzlEntity>()
.WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id))
.WhereIF(!string.IsNullOrEmpty(input.xmbh), p => p.Xmbh.Contains(input.xmbh))
.WhereIF(!string.IsNullOrEmpty(input.xmmc), p => p.Xmmc.Contains(input.xmmc))
.WhereIF(!string.IsNullOrEmpty(input.bzjg), p => p.Bzjg.Equals(input.bzjg))
.WhereIF(!string.IsNullOrEmpty(input.xmsc), p => p.Xmsc.Equals(input.xmsc))
.WhereIF(!string.IsNullOrEmpty(input.jcfwtc), p => p.Jcfwtc.Equals(input.jcfwtc))
.WhereIF(!string.IsNullOrEmpty(input.fl1), p => p.Fl1.Contains(input.fl1))
.WhereIF(!string.IsNullOrEmpty(input.fl2), p => p.Fl2.Contains(input.fl2))
.WhereIF(!string.IsNullOrEmpty(input.fl3), p => p.Fl3.Contains(input.fl3))
.WhereIF(!string.IsNullOrEmpty(input.fl4), p => p.Fl4.Contains(input.fl4))
|
96009bc9
hexiaodong
hxd
|
92
93
94
|
.WhereIF(!string.IsNullOrEmpty(input.fl), p => p.Fl.Contains(input.fl))
.WhereIF(!string.IsNullOrEmpty(input.qt1), p => p.Qt1.Contains(input.qt1))
.WhereIF(!string.IsNullOrEmpty(input.qt2), p => p.Qt2.Contains(input.qt2))
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
95
|
.WhereIF(!string.IsNullOrEmpty(input.sgf), p => p.Sgf.Equals(input.sgf))
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
96
97
98
|
.WhereIF(!string.IsNullOrEmpty(input.beautyType), p => p.BeautyType.Contains(input.beautyType))
.WhereIF(input.isEffective != 0, p => p.IsEffective.Equals(input.isEffective))
.WhereIF(!string.IsNullOrEmpty(input.sourceType), p => p.SourceType.Contains(input.sourceType))
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
99
|
.Select(it => new LqXmzlListOutput
|
96009bc9
hexiaodong
hxd
|
100
101
|
{
id = it.Id,
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
102
103
104
105
106
107
108
109
110
|
xmbh = it.Xmbh,
xmmc = it.Xmmc,
bzjg = it.Bzjg,
xmsc = it.Xmsc,
jcfwtc = it.Jcfwtc,
fl1 = it.Fl1,
fl2 = it.Fl2,
fl3 = it.Fl3,
fl4 = it.Fl4,
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
111
112
113
|
fl = it.Fl,
qt1 = it.Qt1,
qt2 = it.Qt2,
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
114
|
sgf = it.Sgf,
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
115
|
beautyType = it.BeautyType,
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
116
|
sourceType = it.SourceType,
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
117
|
isEffective = it.IsEffective,
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
118
119
|
}).MergeTable().OrderBy(sidx + " " + input.sort).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<LqXmzlListOutput>.SqlSugarPageResult(data);
|
96009bc9
hexiaodong
hxd
|
120
|
}
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
121
|
#endregion
|
96009bc9
hexiaodong
hxd
|
122
|
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
123
|
#region 新建品项资料
|
96009bc9
hexiaodong
hxd
|
124
|
/// <summary>
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
125
|
/// 新建品项资料
|
96009bc9
hexiaodong
hxd
|
126
127
128
129
130
131
132
133
134
135
136
137
|
/// </summary>
/// <param name="input">参数</param>
/// <returns></returns>
[HttpPost("")]
public async Task Create([FromBody] LqXmzlCrInput input)
{
var userInfo = await _userManager.GetUserInfo();
var entity = input.Adapt<LqXmzlEntity>();
entity.Id = YitIdHelper.NextId().ToString();
var isOk = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync();
if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1000);
}
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
138
|
#endregion
|
96009bc9
hexiaodong
hxd
|
139
|
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
140
|
#region 获取品项资料无分页列表
|
96009bc9
hexiaodong
hxd
|
141
|
/// <summary>
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
142
|
/// 获取品项资料无分页列表
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
143
144
145
|
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
|
96009bc9
hexiaodong
hxd
|
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
[NonAction]
public async Task<dynamic> GetNoPagingList([FromQuery] LqXmzlListQueryInput input)
{
var sidx = input.sidx == null ? "id" : input.sidx;
var data = await _db.Queryable<LqXmzlEntity>()
.WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id))
.WhereIF(!string.IsNullOrEmpty(input.xmbh), p => p.Xmbh.Contains(input.xmbh))
.WhereIF(!string.IsNullOrEmpty(input.xmmc), p => p.Xmmc.Contains(input.xmmc))
.WhereIF(!string.IsNullOrEmpty(input.bzjg), p => p.Bzjg.Equals(input.bzjg))
.WhereIF(!string.IsNullOrEmpty(input.xmsc), p => p.Xmsc.Equals(input.xmsc))
.WhereIF(!string.IsNullOrEmpty(input.jcfwtc), p => p.Jcfwtc.Equals(input.jcfwtc))
.WhereIF(!string.IsNullOrEmpty(input.fl1), p => p.Fl1.Contains(input.fl1))
.WhereIF(!string.IsNullOrEmpty(input.fl2), p => p.Fl2.Contains(input.fl2))
.WhereIF(!string.IsNullOrEmpty(input.fl3), p => p.Fl3.Contains(input.fl3))
.WhereIF(!string.IsNullOrEmpty(input.fl4), p => p.Fl4.Contains(input.fl4))
|
96009bc9
hexiaodong
hxd
|
161
162
163
|
.WhereIF(!string.IsNullOrEmpty(input.fl), p => p.Fl.Contains(input.fl))
.WhereIF(!string.IsNullOrEmpty(input.qt1), p => p.Qt1.Contains(input.qt1))
.WhereIF(!string.IsNullOrEmpty(input.qt2), p => p.Qt2.Contains(input.qt2))
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
164
165
|
.WhereIF(!string.IsNullOrEmpty(input.sgf), p => p.Sgf.Equals(input.sgf))
.Select(it => new LqXmzlListOutput
|
96009bc9
hexiaodong
hxd
|
166
167
|
{
id = it.Id,
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
168
169
170
171
172
173
174
175
176
|
xmbh = it.Xmbh,
xmmc = it.Xmmc,
bzjg = it.Bzjg,
xmsc = it.Xmsc,
jcfwtc = it.Jcfwtc,
fl1 = it.Fl1,
fl2 = it.Fl2,
fl3 = it.Fl3,
fl4 = it.Fl4,
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
177
178
179
|
fl = it.Fl,
qt1 = it.Qt1,
qt2 = it.Qt2,
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
180
181
182
|
sgf = it.Sgf,
}).MergeTable().OrderBy(sidx + " " + input.sort).ToListAsync();
return data;
|
96009bc9
hexiaodong
hxd
|
183
|
}
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
184
|
#endregion
|
96009bc9
hexiaodong
hxd
|
185
|
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
186
|
#region 导出品项资料
|
96009bc9
hexiaodong
hxd
|
187
|
/// <summary>
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
188
|
/// 导出品项资料
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
189
190
191
|
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
|
96009bc9
hexiaodong
hxd
|
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
[HttpGet("Actions/Export")]
public async Task<dynamic> Export([FromQuery] LqXmzlListQueryInput input)
{
var userInfo = await _userManager.GetUserInfo();
var exportData = new List<LqXmzlListOutput>();
if (input.dataType == 0)
{
var data = Clay.Object(await this.GetList(input));
exportData = data.Solidify<PageResult<LqXmzlListOutput>>().list;
}
else
{
exportData = await this.GetNoPagingList(input);
}
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
206
|
List<ParamsModel> paramList = "[{\"value\":\"主键\",\"field\":\"id\"},{\"value\":\"项目编号\",\"field\":\"xmbh\"},{\"value\":\"项目名称\",\"field\":\"xmmc\"},{\"value\":\"标准价格\",\"field\":\"bzjg\"},{\"value\":\"时长(分)\",\"field\":\"xmsc\"},{\"value\":\"基础服务提成\",\"field\":\"jcfwtc\"},{\"value\":\"分类1汇总表\",\"field\":\"fl1\"},{\"value\":\"分类2汇总表\",\"field\":\"fl2\"},{\"value\":\"分类3工资用\",\"field\":\"fl3\"},{\"value\":\"分类4品项用\",\"field\":\"fl4\"},{\"value\":\"统计类别\",\"field\":\"tjlb\"},{\"value\":\"折扣类别\",\"field\":\"zklb\"},{\"value\":\"分类\",\"field\":\"fl\"},{\"value\":\"其它1\",\"field\":\"qt1\"},{\"value\":\"其它2\",\"field\":\"qt2\"},{\"value\":\"溯源金额\",\"field\":\"syje\"},{\"value\":\"Cell金额\",\"field\":\"cellje\"},{\"value\":\"手工费\",\"field\":\"sgf\"},]".ToList<ParamsModel>();
|
96009bc9
hexiaodong
hxd
|
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
ExcelConfig excelconfig = new ExcelConfig();
excelconfig.FileName = "项目资料.xls";
excelconfig.HeadFont = "微软雅黑";
excelconfig.HeadPoint = 10;
excelconfig.IsAllSizeColumn = true;
excelconfig.ColumnModel = new List<ExcelColumnModel>();
List<string> selectKeyList = input.selectKey.Split(',').ToList();
foreach (var item in selectKeyList)
{
var isExist = paramList.Find(p => p.field == item);
if (isExist != null)
{
excelconfig.ColumnModel.Add(new ExcelColumnModel() { Column = isExist.field, ExcelColumn = isExist.value });
}
}
var addPath = FileVariable.TemporaryFilePath + excelconfig.FileName;
ExcelExportHelper<LqXmzlListOutput>.Export(exportData, excelconfig, addPath);
var fileName = _userManager.UserId + "|" + addPath + "|xls";
var output = new
{
name = excelconfig.FileName,
url = "/api/File/Download?encryption=" + DESCEncryption.Encrypt(fileName, "NCC")
};
return output;
}
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
232
|
#endregion
|
96009bc9
hexiaodong
hxd
|
233
|
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
234
|
#region 批量删除品项资料
|
96009bc9
hexiaodong
hxd
|
235
|
/// <summary>
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
236
|
/// 批量删除品项资料
|
96009bc9
hexiaodong
hxd
|
237
238
239
240
241
242
|
/// </summary>
/// <param name="ids">主键数组</param>
/// <returns></returns>
[HttpPost("batchRemove")]
public async Task BatchRemove([FromBody] List<string> ids)
{
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
243
|
throw NCCException.Oh("不允许删除项目资料");
|
96009bc9
hexiaodong
hxd
|
244
245
246
247
248
249
250
251
|
var entitys = await _db.Queryable<LqXmzlEntity>().In(it => it.Id, ids).ToListAsync();
if (entitys.Count > 0)
{
try
{
//开启事务
_db.BeginTran();
//批量删除项目资料
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
252
|
await _db.Deleteable<LqXmzlEntity>().In(d => d.Id, ids).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
253
254
255
256
257
258
259
260
261
262
263
|
//关闭事务
_db.CommitTran();
}
catch (Exception)
{
//回滚事务
_db.RollbackTran();
throw NCCException.Oh(ErrorCode.COM1002);
}
}
}
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
264
|
#endregion
|
96009bc9
hexiaodong
hxd
|
265
|
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
266
|
#region 更新品项资料
|
96009bc9
hexiaodong
hxd
|
267
|
/// <summary>
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
268
|
/// 更新品项资料
|
96009bc9
hexiaodong
hxd
|
269
270
271
272
273
274
275
276
277
278
279
|
/// </summary>
/// <param name="id">主键</param>
/// <param name="input">参数</param>
/// <returns></returns>
[HttpPut("{id}")]
public async Task Update(string id, [FromBody] LqXmzlUpInput input)
{
var entity = input.Adapt<LqXmzlEntity>();
var isOk = await _db.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1001);
}
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
280
|
#endregion
|
96009bc9
hexiaodong
hxd
|
281
|
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
282
|
#region 删除品项资料
|
96009bc9
hexiaodong
hxd
|
283
|
/// <summary>
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
284
|
/// 删除品项资料
|
96009bc9
hexiaodong
hxd
|
285
|
/// </summary>
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
286
|
/// <param name="id">主键</param>
|
96009bc9
hexiaodong
hxd
|
287
288
289
290
|
/// <returns></returns>
[HttpDelete("{id}")]
public async Task Delete(string id)
{
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
291
|
throw NCCException.Oh("不允许删除项目资料");
|
96009bc9
hexiaodong
hxd
|
292
|
}
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
293
|
#endregion
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
294
295
296
297
298
299
300
|
#region 获取字段去重数据
/// <summary>
/// 获取指定字段的去重数据
/// </summary>
/// <param name="fieldName">字段名称,支持:fl1、fl2、fl3、fl4、fl、qt1、beautyType、sourceType</param>
/// <returns>去重后的字段数据</returns>
|
63df7ccb
“wangming”
1
|
301
302
|
[HttpGet("GetDistinctFieldData")]
public async Task<dynamic> GetDistinctFieldData([FromQuery] string fieldName)
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
303
304
305
306
|
{
try
{
// 验证字段名称
|
63df7ccb
“wangming”
1
|
307
|
var validFields = new[] { "fl1", "fl2", "fl3", "fl4", "fl", "qt1", "qt2", "beautyType", "sourceType" };
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
|
if (!validFields.Contains(fieldName))
{
throw NCCException.Oh($"无效的字段名称: {fieldName}。支持的字段: {string.Join(", ", validFields)}");
}
List<string> distinctValues = new List<string>();
switch (fieldName)
{
case "fl1":
distinctValues = await _db.Queryable<LqXmzlEntity>()
.Where(p => !string.IsNullOrEmpty(p.Fl1))
.Select(p => p.Fl1)
.Distinct()
.ToListAsync();
break;
case "fl2":
distinctValues = await _db.Queryable<LqXmzlEntity>()
.Where(p => !string.IsNullOrEmpty(p.Fl2))
.Select(p => p.Fl2)
.Distinct()
.ToListAsync();
break;
case "fl3":
distinctValues = await _db.Queryable<LqXmzlEntity>()
.Where(p => !string.IsNullOrEmpty(p.Fl3))
.Select(p => p.Fl3)
.Distinct()
.ToListAsync();
break;
case "fl4":
distinctValues = await _db.Queryable<LqXmzlEntity>()
.Where(p => !string.IsNullOrEmpty(p.Fl4))
.Select(p => p.Fl4)
.Distinct()
.ToListAsync();
break;
case "fl":
distinctValues = await _db.Queryable<LqXmzlEntity>()
.Where(p => !string.IsNullOrEmpty(p.Fl))
.Select(p => p.Fl)
.Distinct()
.ToListAsync();
break;
case "qt1":
distinctValues = await _db.Queryable<LqXmzlEntity>()
.Where(p => !string.IsNullOrEmpty(p.Qt1))
.Select(p => p.Qt1)
.Distinct()
.ToListAsync();
break;
|
63df7ccb
“wangming”
1
|
359
360
361
362
363
364
365
|
case "qt2":
distinctValues = await _db.Queryable<LqXmzlEntity>()
.Where(p => !string.IsNullOrEmpty(p.Qt2))
.Select(p => p.Qt2)
.Distinct()
.ToListAsync();
break;
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
|
case "beautyType":
distinctValues = await _db.Queryable<LqXmzlEntity>()
.Where(p => !string.IsNullOrEmpty(p.BeautyType))
.Select(p => p.BeautyType)
.Distinct()
.ToListAsync();
break;
case "sourceType":
distinctValues = await _db.Queryable<LqXmzlEntity>()
.Where(p => !string.IsNullOrEmpty(p.SourceType))
.Select(p => p.SourceType)
.Distinct()
.ToListAsync();
break;
}
return new
{
fieldName = fieldName,
values = distinctValues.OrderBy(x => x).ToList()
};
}
catch (Exception ex)
{
throw NCCException.Oh($"获取字段去重数据失败:{ex.Message}");
}
}
#endregion
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
|
#region 品项维度统计
/// <summary>
/// 品项维度统计
/// </summary>
/// <remarks>
/// 按品项维度统计开卡、消耗、退卡等数据
/// 包括业绩、人数、占比、复购率等指标
///
/// 示例请求:
/// ```json
/// {
/// "startTime": "2024-01-01",
/// "endTime": "2024-12-31",
/// "storeId": "store001",
/// "category": "美容",
/// "itemId": "item001"
/// }
/// ```
///
/// 参数说明:
/// - startTime: 开始时间(可选)
/// - endTime: 结束时间(可选)
/// - storeId: 门店ID(可选)
/// - category: 品项分类(可选)
/// - itemId: 品项ID(可选,单个品项统计)
/// </remarks>
/// <param name="input">统计输入参数</param>
/// <returns>品项维度统计数据</returns>
/// <response code="200">统计成功</response>
/// <response code="400">参数错误</response>
/// <response code="500">服务器错误</response>
[HttpPost("GetItemStatistics")]
public async Task<dynamic> GetItemStatistics([FromBody] LqXmzlStatisticsInput input)
{
try
{
// 第一步:获取品项基础信息
var itemsQuery = _db.Queryable<LqXmzlEntity>()
.Where(x => x.IsEffective == 1);
if (!string.IsNullOrEmpty(input.ItemId))
{
itemsQuery = itemsQuery.Where(x => x.Id == input.ItemId);
}
if (!string.IsNullOrEmpty(input.Category))
{
itemsQuery = itemsQuery.Where(x => x.Fl1 == input.Category || x.Fl2 == input.Category || x.Fl == input.Category);
}
var items = await itemsQuery.ToListAsync();
if (!items.Any())
{
return new
{
success = true,
data = new List<LqXmzlStatisticsOutput>(),
message = "未找到符合条件的品项"
};
}
var itemIds = items.Select(x => x.Id).ToList();
// 第二步:开卡数据统计
var billingStats = await GetBillingStatistics(itemIds, input);
// 第三步:消耗数据统计
var consumeStats = await GetConsumeStatistics(itemIds, input);
// 第四步:退卡数据统计
var refundStats = await GetRefundStatistics(itemIds, input);
// 第五步:计算总数据用于占比计算
var totalBillingAmount = billingStats.Sum(x => x.BillingAmount);
var totalConsumeAmount = consumeStats.Sum(x => x.ConsumeAmount);
var totalBuyers = billingStats.Sum(x => x.TotalBuyers);
// 第六步:合并数据并计算占比
var result = new List<LqXmzlStatisticsOutput>();
foreach (var item in items)
{
var billingData = billingStats.FirstOrDefault(x => x.ItemId == item.Id);
var consumeData = consumeStats.FirstOrDefault(x => x.ItemId == item.Id);
var refundData = refundStats.FirstOrDefault(x => x.ItemId == item.Id);
var output = new LqXmzlStatisticsOutput
{
ItemId = item.Id,
ItemName = item.Xmmc,
ItemNumber = item.Xmbh,
BillingAmount = billingData?.BillingAmount ?? 0,
BillingAmountRatio = totalBillingAmount > 0 ? (billingData?.BillingAmount ?? 0) / totalBillingAmount : 0,
TotalBuyers = billingData?.TotalBuyers ?? 0,
ItemRatio = totalBuyers > 0 ? (billingData?.TotalBuyers ?? 0) / (decimal)totalBuyers : 0,
RepeatBuyers = billingData?.RepeatBuyers ?? 0,
RepeatBuyRate = (billingData?.TotalBuyers ?? 0) > 0 ? (billingData?.RepeatBuyers ?? 0) / (decimal)(billingData?.TotalBuyers ?? 1) : 0,
ConsumeAmount = consumeData?.ConsumeAmount ?? 0,
ConsumeAmountRatio = totalConsumeAmount > 0 ? (consumeData?.ConsumeAmount ?? 0) / totalConsumeAmount : 0,
ConsumePurchaseCount = consumeData?.ConsumePurchaseCount ?? 0,
ConsumeGiftCount = consumeData?.ConsumeGiftCount ?? 0,
ConsumeExperienceCount = consumeData?.ConsumeExperienceCount ?? 0,
RefundAmount = refundData?.RefundAmount ?? 0,
RefundCount = refundData?.RefundCount ?? 0
};
result.Add(output);
}
return new
{
success = true,
data = result,
message = "品项维度统计成功"
};
}
catch (Exception ex)
{
throw NCCException.Oh($"品项维度统计失败:{ex.Message}");
}
}
/// <summary>
/// 获取开卡统计数据
/// </summary>
private async Task<List<ItemStatisticsData>> GetBillingStatistics(List<string> itemIds, LqXmzlStatisticsInput input)
{
var query = _db.Queryable<LqKdPxmxEntity>()
.Where(x => itemIds.Contains(x.Px) && x.IsEffective == 1);
// 时间过滤
if (input.StartTime.HasValue)
{
query = query.Where(x => x.CreateTIme >= input.StartTime.Value);
}
if (input.EndTime.HasValue)
{
query = query.Where(x => x.CreateTIme <= input.EndTime.Value);
}
// 门店过滤(通过开单记录关联)
if (!string.IsNullOrEmpty(input.StoreId))
{
|
65e1ea9f
“wangming”
fix: 修复员工业绩统计和人次统计逻辑
|
539
540
541
542
|
// 使用子查询过滤门店 - 在SQL层面过滤,避免别名问题
query = query.Where(x => SqlFunc.Subqueryable<LqKdKdjlbEntity>()
.Where(kd => kd.Id == x.Glkdbh && kd.Djmd == input.StoreId && kd.IsEffective == 1)
.Any());
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
|
}
var result = await query
.GroupBy(x => x.Px)
.Select(x => new ItemStatisticsData
{
ItemId = x.Px,
BillingAmount = SqlFunc.AggregateSum(x.Pxjg * x.ProjectNumber),
TotalBuyers = SqlFunc.AggregateCount(x.MemberId),
RepeatBuyers = 0 // 复购人数需要单独计算
})
.ToListAsync();
// 单独计算复购人数
foreach (var item in result)
{
var memberCountQuery = _db.Queryable<LqKdPxmxEntity>()
.Where(x => x.Px == item.ItemId && x.IsEffective == 1);
if (input.StartTime.HasValue)
{
memberCountQuery = memberCountQuery.Where(x => x.CreateTIme >= input.StartTime.Value);
}
if (input.EndTime.HasValue)
{
memberCountQuery = memberCountQuery.Where(x => x.CreateTIme <= input.EndTime.Value);
}
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
570
|
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
571
572
|
if (!string.IsNullOrEmpty(input.StoreId))
{
|
65e1ea9f
“wangming”
fix: 修复员工业绩统计和人次统计逻辑
|
573
574
575
576
|
// 使用子查询过滤门店 - 在SQL层面过滤,避免别名问题
memberCountQuery = memberCountQuery.Where(x => SqlFunc.Subqueryable<LqKdKdjlbEntity>()
.Where(kd => kd.Id == x.Glkdbh && kd.Djmd == input.StoreId && kd.IsEffective == 1)
.Any());
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
|
}
var memberStats = await memberCountQuery
.GroupBy(x => x.MemberId)
.Having(x => SqlFunc.AggregateCount(x.MemberId) > 1)
.Select(x => SqlFunc.AggregateCount(x.MemberId))
.ToListAsync();
item.RepeatBuyers = memberStats.Count;
}
return result;
}
/// <summary>
/// 获取消耗统计数据
/// </summary>
private async Task<List<ItemConsumeStatisticsData>> GetConsumeStatistics(List<string> itemIds, LqXmzlStatisticsInput input)
{
var query = _db.Queryable<LqXhPxmxEntity>()
.Where(x => itemIds.Contains(x.Px));
// 时间过滤
if (input.StartTime.HasValue)
{
query = query.Where(x => x.CreateTIme >= input.StartTime.Value);
}
if (input.EndTime.HasValue)
{
query = query.Where(x => x.CreateTIme <= input.EndTime.Value);
}
// 门店过滤(通过耗卡记录关联)
if (!string.IsNullOrEmpty(input.StoreId))
{
|
65e1ea9f
“wangming”
fix: 修复员工业绩统计和人次统计逻辑
|
612
613
614
615
|
// 使用子查询过滤门店 - 在SQL层面过滤,避免别名问题
query = query.Where(x => SqlFunc.Subqueryable<LqXhHyhkEntity>()
.Where(xh => xh.Id == x.ConsumeInfoId && xh.Md == input.StoreId && xh.IsEffective == 1)
.Any());
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
|
}
var result = await query
.GroupBy(x => x.Px)
.Select(x => new ItemConsumeStatisticsData
{
ItemId = x.Px,
ConsumeAmount = SqlFunc.AggregateSum(x.Pxjg * x.ProjectNumber),
ConsumePurchaseCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.SourceType == "购买", x.ProjectNumber, 0)),
ConsumeGiftCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.SourceType == "赠送", x.ProjectNumber, 0)),
ConsumeExperienceCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.SourceType == "体验", x.ProjectNumber, 0))
})
.ToListAsync();
return result;
}
/// <summary>
/// 获取退卡统计数据
/// </summary>
private async Task<List<ItemRefundStatisticsData>> GetRefundStatistics(List<string> itemIds, LqXmzlStatisticsInput input)
{
var query = _db.Queryable<LqHytkMxEntity>()
.Where(x => itemIds.Contains(x.Px));
// 时间过滤
if (input.StartTime.HasValue)
{
query = query.Where(x => x.Tksj >= input.StartTime.Value);
}
if (input.EndTime.HasValue)
{
query = query.Where(x => x.Tksj <= input.EndTime.Value);
}
// 门店过滤(通过退卡记录关联)
if (!string.IsNullOrEmpty(input.StoreId))
{
|
65e1ea9f
“wangming”
fix: 修复员工业绩统计和人次统计逻辑
|
654
655
656
657
|
// 使用子查询过滤门店 - 在SQL层面过滤,避免别名问题
query = query.Where(x => SqlFunc.Subqueryable<LqHytkHytkEntity>()
.Where(hytk => hytk.Id == x.RefundInfoId && hytk.Md == input.StoreId && hytk.IsEffective == 1)
.Any());
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
|
}
var result = await query
.GroupBy(x => x.Px)
.Select(x => new ItemRefundStatisticsData
{
ItemId = x.Px,
RefundAmount = SqlFunc.AggregateSum(x.Tkje ?? 0),
RefundCount = SqlFunc.AggregateCount(x.Id)
})
.ToListAsync();
return result;
}
#endregion
}
/// <summary>
/// 品项统计数据(内部类)
/// </summary>
public class ItemStatisticsData
{
public string ItemId { get; set; }
public decimal BillingAmount { get; set; }
public int TotalBuyers { get; set; }
public int RepeatBuyers { get; set; }
}
/// <summary>
/// 品项消耗统计数据(内部类)
/// </summary>
public class ItemConsumeStatisticsData
{
public string ItemId { get; set; }
public decimal ConsumeAmount { get; set; }
public int ConsumePurchaseCount { get; set; }
public int ConsumeGiftCount { get; set; }
public int ConsumeExperienceCount { get; set; }
}
/// <summary>
/// 品项退卡统计数据(内部类)
/// </summary>
public class ItemRefundStatisticsData
{
public string ItemId { get; set; }
public decimal RefundAmount { get; set; }
public int RefundCount { get; set; }
|
96009bc9
hexiaodong
hxd
|
707
708
|
}
}
|