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
|
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;
|
1cf1bd86
“wangming”
feat: 添加项目资料表手工费字...
|
31
|
using NCC.Extend.Entitys.Enum;
|
96009bc9
hexiaodong
hxd
|
32
33
34
35
36
37
|
namespace NCC.Extend.LqXmzl
{
/// <summary>
/// 项目资料服务
/// </summary>
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
38
|
[ApiDescriptionSettings(Tag = "绿纤品项资料服务", Name = "LqXmzl", Order = 200)]
|
96009bc9
hexiaodong
hxd
|
39
40
41
42
43
44
45
46
47
48
|
[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”
更新门店目标设定相关功能,新增字段...
|
49
|
public LqXmzlService(ISqlSugarRepository<LqXmzlEntity> lqXmzlRepository, IUserManager userManager)
|
96009bc9
hexiaodong
hxd
|
50
|
{
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
51
|
_lqXmzlRepository = lqXmzlRepository;
|
96009bc9
hexiaodong
hxd
|
52
53
54
55
|
_db = _lqXmzlRepository.Context;
_userManager = userManager;
}
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
56
|
#region 获取品项资料
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
57
|
|
96009bc9
hexiaodong
hxd
|
58
59
60
61
62
63
64
65
66
67
68
69
|
/// <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”
更新门店目标设定相关功能,新增字段...
|
70
|
#endregion
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
71
|
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
72
|
#region 获取品项资料列表
|
96009bc9
hexiaodong
hxd
|
73
|
/// <summary>
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
74
|
/// 获取品项资料列表
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
75
76
77
|
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
|
96009bc9
hexiaodong
hxd
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
[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
|
93
94
95
|
.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”
更新门店目标设定相关功能,新增字段...
|
96
|
.WhereIF(!string.IsNullOrEmpty(input.sgf), p => p.Sgf.Equals(input.sgf))
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
97
98
99
|
.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”
更新门店目标设定相关功能,新增字段...
|
100
|
.Select(it => new LqXmzlListOutput
|
96009bc9
hexiaodong
hxd
|
101
102
|
{
id = it.Id,
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
103
104
105
106
107
108
109
110
111
|
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”
更新门店目标设定相关功能,新增字段...
|
112
113
114
|
fl = it.Fl,
qt1 = it.Qt1,
qt2 = it.Qt2,
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
115
|
sgf = it.Sgf,
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
116
|
beautyType = it.BeautyType,
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
117
|
sourceType = it.SourceType,
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
118
|
isEffective = it.IsEffective,
|
1cf1bd86
“wangming”
feat: 添加项目资料表手工费字...
|
119
120
121
122
|
medicalBeautyLaborCost = it.MedicalBeautyLaborCost,
techBeautyLaborCost = it.TechBeautyLaborCost,
lifeBeautyLaborCost = it.LifeBeautyLaborCost,
healthCoachLaborCost = it.HealthCoachLaborCost,
|
3ab6f199
“wangming”
feat: 创建门店目标表和总经理...
|
123
|
isAllowAccompanied = it.IsAllowAccompanied,
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
124
125
|
}).MergeTable().OrderBy(sidx + " " + input.sort).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<LqXmzlListOutput>.SqlSugarPageResult(data);
|
96009bc9
hexiaodong
hxd
|
126
|
}
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
127
|
#endregion
|
96009bc9
hexiaodong
hxd
|
128
|
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
129
|
#region 新建品项资料
|
96009bc9
hexiaodong
hxd
|
130
|
/// <summary>
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
131
|
/// 新建品项资料
|
96009bc9
hexiaodong
hxd
|
132
133
134
135
136
137
138
139
140
141
142
143
|
/// </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”
更新门店目标设定相关功能,新增字段...
|
144
|
#endregion
|
96009bc9
hexiaodong
hxd
|
145
|
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
146
|
#region 获取品项资料无分页列表
|
96009bc9
hexiaodong
hxd
|
147
|
/// <summary>
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
148
|
/// 获取品项资料无分页列表
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
149
150
151
|
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
|
96009bc9
hexiaodong
hxd
|
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
[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
|
167
168
169
|
.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”
更新门店目标设定相关功能,新增字段...
|
170
171
|
.WhereIF(!string.IsNullOrEmpty(input.sgf), p => p.Sgf.Equals(input.sgf))
.Select(it => new LqXmzlListOutput
|
96009bc9
hexiaodong
hxd
|
172
173
|
{
id = it.Id,
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
174
175
176
177
178
179
180
181
182
|
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”
更新门店目标设定相关功能,新增字段...
|
183
184
185
|
fl = it.Fl,
qt1 = it.Qt1,
qt2 = it.Qt2,
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
186
187
188
|
sgf = it.Sgf,
}).MergeTable().OrderBy(sidx + " " + input.sort).ToListAsync();
return data;
|
96009bc9
hexiaodong
hxd
|
189
|
}
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
190
|
#endregion
|
96009bc9
hexiaodong
hxd
|
191
|
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
192
|
#region 导出品项资料
|
96009bc9
hexiaodong
hxd
|
193
|
/// <summary>
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
194
|
/// 导出品项资料
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
195
196
197
|
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
|
96009bc9
hexiaodong
hxd
|
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
[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”
更新门店目标设定相关功能,新增字段...
|
212
|
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
|
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
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”
更新门店目标设定相关功能,新增字段...
|
238
|
#endregion
|
96009bc9
hexiaodong
hxd
|
239
|
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
240
|
#region 批量删除品项资料
|
96009bc9
hexiaodong
hxd
|
241
|
/// <summary>
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
242
|
/// 批量删除品项资料
|
96009bc9
hexiaodong
hxd
|
243
244
245
246
247
248
|
/// </summary>
/// <param name="ids">主键数组</param>
/// <returns></returns>
[HttpPost("batchRemove")]
public async Task BatchRemove([FromBody] List<string> ids)
{
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
249
|
throw NCCException.Oh("不允许删除项目资料");
|
96009bc9
hexiaodong
hxd
|
250
251
252
253
254
255
256
257
|
var entitys = await _db.Queryable<LqXmzlEntity>().In(it => it.Id, ids).ToListAsync();
if (entitys.Count > 0)
{
try
{
//开启事务
_db.BeginTran();
//批量删除项目资料
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
258
|
await _db.Deleteable<LqXmzlEntity>().In(d => d.Id, ids).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
259
260
261
262
263
264
265
266
267
268
269
|
//关闭事务
_db.CommitTran();
}
catch (Exception)
{
//回滚事务
_db.RollbackTran();
throw NCCException.Oh(ErrorCode.COM1002);
}
}
}
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
270
|
#endregion
|
96009bc9
hexiaodong
hxd
|
271
|
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
272
|
#region 更新品项资料
|
96009bc9
hexiaodong
hxd
|
273
|
/// <summary>
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
274
|
/// 更新品项资料
|
96009bc9
hexiaodong
hxd
|
275
276
277
278
279
280
281
282
283
284
285
|
/// </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”
更新门店目标设定相关功能,新增字段...
|
286
|
#endregion
|
96009bc9
hexiaodong
hxd
|
287
|
|
1cf1bd86
“wangming”
feat: 添加项目资料表手工费字...
|
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
#region 设置品项作废
/// <summary>
/// 设置品项作废
/// </summary>
/// <param name="id">主键</param>
/// <returns></returns>
[HttpPut("SetInvalid/{id}")]
public async Task SetInvalid(string id)
{
var entity = await _db.Queryable<LqXmzlEntity>().FirstAsync(p => p.Id == id);
if (entity == null) throw NCCException.Oh("品项不存在");
entity.IsEffective = StatusEnum.无效.GetHashCode();
var isOk = await _db.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1001);
}
#endregion
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
305
|
#region 删除品项资料
|
96009bc9
hexiaodong
hxd
|
306
|
/// <summary>
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
307
|
/// 删除品项资料
|
96009bc9
hexiaodong
hxd
|
308
|
/// </summary>
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
309
|
/// <param name="id">主键</param>
|
96009bc9
hexiaodong
hxd
|
310
311
312
313
|
/// <returns></returns>
[HttpDelete("{id}")]
public async Task Delete(string id)
{
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
314
|
throw NCCException.Oh("不允许删除项目资料");
|
96009bc9
hexiaodong
hxd
|
315
|
}
|
2ce7c3cb
“wangming”
更新门店目标设定相关功能,新增字段...
|
316
|
#endregion
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
317
318
319
320
321
322
323
|
#region 获取字段去重数据
/// <summary>
/// 获取指定字段的去重数据
/// </summary>
/// <param name="fieldName">字段名称,支持:fl1、fl2、fl3、fl4、fl、qt1、beautyType、sourceType</param>
/// <returns>去重后的字段数据</returns>
|
63df7ccb
“wangming”
1
|
324
325
|
[HttpGet("GetDistinctFieldData")]
public async Task<dynamic> GetDistinctFieldData([FromQuery] string fieldName)
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
326
327
328
329
|
{
try
{
// 验证字段名称
|
63df7ccb
“wangming”
1
|
330
|
var validFields = new[] { "fl1", "fl2", "fl3", "fl4", "fl", "qt1", "qt2", "beautyType", "sourceType" };
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
|
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
|
382
383
384
385
386
387
388
|
case "qt2":
distinctValues = await _db.Queryable<LqXmzlEntity>()
.Where(p => !string.IsNullOrEmpty(p.Qt2))
.Select(p => p.Qt2)
.Distinct()
.ToListAsync();
break;
|
f987b6a6
“wangming”
feat: 完善开单记录汇总查询功能
|
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
|
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...
|
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
|
#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
};
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
|
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: 修复员工业绩统计和人次统计逻辑
|
561
562
563
564
|
// 使用子查询过滤门店 - 在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...
|
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
|
}
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: 完善开单记录汇总查询功能
|
592
|
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
593
594
|
if (!string.IsNullOrEmpty(input.StoreId))
{
|
65e1ea9f
“wangming”
fix: 修复员工业绩统计和人次统计逻辑
|
595
596
597
598
|
// 使用子查询过滤门店 - 在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...
|
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
|
}
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: 修复员工业绩统计和人次统计逻辑
|
634
635
636
637
|
// 使用子查询过滤门店 - 在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...
|
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
|
}
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: 修复员工业绩统计和人次统计逻辑
|
676
677
678
679
|
// 使用子查询过滤门店 - 在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...
|
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
|
}
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
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
695
|
}
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
|
/// <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; }
|
fc259a33
“wangming”
feat: 添加消耗功能加班相关字...
|
714
715
716
|
public decimal ConsumePurchaseCount { get; set; }
public decimal ConsumeGiftCount { get; set; }
public decimal ConsumeExperienceCount { get; set; }
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
717
718
719
720
721
722
723
724
725
726
|
}
/// <summary>
/// 品项退卡统计数据(内部类)
/// </summary>
public class ItemRefundStatisticsData
{
public string ItemId { get; set; }
public decimal RefundAmount { get; set; }
public int RefundCount { get; set; }
|
96009bc9
hexiaodong
hxd
|
727
728
|
}
}
|