d98270e2
“wangming”
Enhance LqEventSe...
|
1
2
3
4
5
6
7
8
9
10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using NCC.ClayObject;
using NCC.Common.Configuration;
using NCC.Common.Core.Manager;
|
96009bc9
hexiaodong
hxd
|
11
12
13
|
using NCC.Common.Enum;
using NCC.Common.Extension;
using NCC.Common.Filter;
|
d98270e2
“wangming”
Enhance LqEventSe...
|
14
15
16
|
using NCC.Common.Helper;
using NCC.Common.Model.NPOI;
using NCC.DataEncryption;
|
96009bc9
hexiaodong
hxd
|
17
18
|
using NCC.Dependency;
using NCC.DynamicApiController;
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
19
|
using NCC.Extend.Entitys.Dto.LqXhHyhk;
|
d98270e2
“wangming”
Enhance LqEventSe...
|
20
21
22
|
using NCC.Extend.Entitys.Dto.LqXhJksyj;
using NCC.Extend.Entitys.Dto.LqXhKjbsyj;
using NCC.Extend.Entitys.Dto.LqXhPxmx;
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
23
|
using NCC.Extend.Entitys.Enum;
|
d98270e2
“wangming”
Enhance LqEventSe...
|
24
25
26
|
using NCC.Extend.Entitys.lq_kd_kdjlb;
using NCC.Extend.Entitys.lq_kd_pxmx;
using NCC.Extend.Entitys.lq_khxx;
|
efde7d04
“wangming”
更新多个文件,删除不再使用的CSS...
|
27
28
29
30
|
using NCC.Extend.Entitys.lq_xh_hyhk;
using NCC.Extend.Entitys.lq_xh_jksyj;
using NCC.Extend.Entitys.lq_xh_kjbsyj;
using NCC.Extend.Entitys.lq_xh_pxmx;
|
d98270e2
“wangming”
Enhance LqEventSe...
|
31
32
|
using NCC.Extend.Interfaces.LqXhHyhk;
using NCC.FriendlyException;
|
96009bc9
hexiaodong
hxd
|
33
|
using NCC.JsonSerialization;
|
d98270e2
“wangming”
Enhance LqEventSe...
|
34
35
|
using SqlSugar;
using Yitter.IdGenerator;
|
96009bc9
hexiaodong
hxd
|
36
37
38
39
|
namespace NCC.Extend.LqXhHyhk
{
/// <summary>
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
40
|
/// 耗卡记录表服务
|
96009bc9
hexiaodong
hxd
|
41
|
/// </summary>
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
42
|
[ApiDescriptionSettings(Tag = "绿纤耗卡记录表服务", Name = "LqXhHyhk", Order = 200, Groups = new[] { "Default" })]
|
96009bc9
hexiaodong
hxd
|
43
44
45
46
47
48
49
50
51
|
[Route("api/Extend/[controller]")]
public class LqXhHyhkService : ILqXhHyhkService, IDynamicApiController, ITransient
{
private readonly ISqlSugarRepository<LqXhHyhkEntity> _lqXhHyhkRepository;
private readonly ISqlSugarRepository<LqXhJksyjEntity> _lqXhJksyjRepository;
private readonly ISqlSugarRepository<LqXhKjbsyjEntity> _lqXhKjbsyjRepository;
private readonly ISqlSugarRepository<LqXhPxmxEntity> _lqXhPxmxRepository;
private readonly SqlSugarScope _db;
private readonly IUserManager _userManager;
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
52
|
private readonly ILogger<LqXhHyhkService> _logger;
|
96009bc9
hexiaodong
hxd
|
53
54
55
56
57
58
59
60
61
|
/// <summary>
/// 初始化一个<see cref="LqXhHyhkService"/>类型的新实例
/// </summary>
public LqXhHyhkService(
ISqlSugarRepository<LqXhHyhkEntity> lqXhHyhkRepository,
ISqlSugarRepository<LqXhJksyjEntity> lqXhJksyjRepository,
ISqlSugarRepository<LqXhKjbsyjEntity> lqXhKjbsyjRepository,
ISqlSugarRepository<LqXhPxmxEntity> lqXhPxmxRepository,
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
62
|
IUserManager userManager,
|
d98270e2
“wangming”
Enhance LqEventSe...
|
63
64
|
ILogger<LqXhHyhkService> logger
)
|
96009bc9
hexiaodong
hxd
|
65
|
{
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
66
|
_lqXhHyhkRepository = lqXhHyhkRepository;
|
96009bc9
hexiaodong
hxd
|
67
68
69
70
71
|
_db = _lqXhHyhkRepository.Context;
_lqXhJksyjRepository = lqXhJksyjRepository;
_lqXhKjbsyjRepository = lqXhKjbsyjRepository;
_lqXhPxmxRepository = lqXhPxmxRepository;
_userManager = userManager;
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
72
|
_logger = logger;
|
96009bc9
hexiaodong
hxd
|
73
74
|
}
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
75
|
#region 获取会员耗卡
|
96009bc9
hexiaodong
hxd
|
76
77
78
|
/// <summary>
/// 获取会员耗卡
/// </summary>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
79
80
81
|
/// <remarks>
/// 获取耗卡记录及其关联的品项明细、健康师业绩、科技部老师业绩信息
/// 按照耗卡的完整格式返回数据,不包含汇总信息
|
d98270e2
“wangming”
Enhance LqEventSe...
|
82
|
///
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
83
84
85
86
87
88
89
90
91
92
93
|
/// 返回数据结构:
/// - 主表信息:耗卡基础信息、门店信息、会员信息等
/// - 品项明细列表:每个品项包含完整的项目信息(项目次数、是否有效、来源类型等)
/// - 健康师业绩列表:按品项关联的健康师业绩信息
/// - 科技部老师业绩列表:按品项关联的科技部老师业绩信息
/// </remarks>
/// <param name="id">耗卡记录主键ID</param>
/// <returns>耗卡记录完整信息</returns>
/// <response code="200">查询成功</response>
/// <response code="404">耗卡记录不存在</response>
/// <response code="500">服务器内部错误</response>
|
96009bc9
hexiaodong
hxd
|
94
95
96
|
[HttpGet("{id}")]
public async Task<dynamic> GetInfo(string id)
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
97
98
99
100
101
102
103
104
105
106
107
108
|
try
{
// 1. 查询主表信息
var entity = await _db.Queryable<LqXhHyhkEntity>().FirstAsync(p => p.Id == id);
if (entity == null)
{
throw NCCException.Oh(ErrorCode.COM1005, "耗卡记录不存在");
}
var output = entity.Adapt<LqXhHyhkInfoOutput>();
// 2. 查询品项明细列表
|
b45d55f7
“wangming”
Refactor LqEventS...
|
109
|
var lqXhPxmxList = await _db.Queryable<LqXhPxmxEntity>().Where(w => w.ConsumeInfoId == entity.Id).ToListAsync();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
110
111
|
// 3. 查询健康师业绩列表
|
d98270e2
“wangming”
Enhance LqEventSe...
|
112
|
var lqXhJksyjList = await _db.Queryable<LqXhJksyjEntity>().Where(w => w.Glkdbh == entity.Id).ToListAsync();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
113
114
|
// 4. 查询科技部老师业绩列表
|
d98270e2
“wangming”
Enhance LqEventSe...
|
115
|
var lqXhKjbsyjList = await _db.Queryable<LqXhKjbsyjEntity>().Where(w => w.Glkdbh == entity.Id).ToListAsync();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
116
117
118
119
120
121
122
123
|
// 5. 构建品项明细输出,每个品项关联对应的业绩信息
var pxmxOutputList = new List<LqXhPxmxInfoOutput>();
foreach (var pxmx in lqXhPxmxList)
{
var pxmxOutput = new LqXhPxmxInfoOutput
{
id = pxmx.Id,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
124
125
|
consumeInfoId = pxmx.ConsumeInfoId,
billingItemId = pxmx.BillingItemId,
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
126
127
128
|
px = pxmx.Px,
pxmc = pxmx.Pxmc,
pxjg = pxmx.Pxjg,
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
129
130
131
|
memberId = pxmx.MemberId,
createTime = pxmx.CreateTIme,
projectNumber = pxmx.ProjectNumber,
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
132
|
sourceType = pxmx.SourceType,
|
d98270e2
“wangming”
Enhance LqEventSe...
|
133
|
totalPrice = pxmx.TotalPrice,
|
d7925aaa
“wangming”
星期五了,下班咯
|
134
|
isEffective = pxmx.IsEffective,
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
135
136
137
138
139
140
141
142
143
144
145
146
|
};
// 关联该品项的健康师业绩
var jksyjForPx = lqXhJksyjList.Where(j => j.Kdpxid == pxmx.Id).ToList();
pxmxOutput.lqXhJksyjList = jksyjForPx.Adapt<List<LqXhJksyjInfoOutput>>();
// 关联该品项的科技部老师业绩
var kjbsyjForPx = lqXhKjbsyjList.Where(k => k.Hkpxid == pxmx.Id).ToList();
pxmxOutput.lqXhKjbsyjList = kjbsyjForPx.Adapt<List<LqXhKjbsyjInfoOutput>>();
pxmxOutputList.Add(pxmxOutput);
}
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
147
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
148
149
|
// 6. 设置输出结果
output.lqXhPxmxList = pxmxOutputList;
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
150
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
151
152
153
|
// 7. 设置全局业绩列表(用于兼容性,但主要使用品项关联的业绩)
output.lqXhJksyjList = lqXhJksyjList.Adapt<List<LqXhJksyjInfoOutput>>();
output.lqXhKjbsyjList = lqXhKjbsyjList.Adapt<List<LqXhKjbsyjInfoOutput>>();
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
154
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
155
156
157
158
159
160
161
|
return output;
}
catch (Exception ex)
{
_logger.LogError(ex, "获取耗卡记录失败,ID:{Id}", id);
throw NCCException.Oh(ErrorCode.COM1000, "获取耗卡记录失败");
}
|
96009bc9
hexiaodong
hxd
|
162
|
}
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
163
|
#endregion
|
96009bc9
hexiaodong
hxd
|
164
|
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
165
|
#region 获取会员耗卡列表
|
96009bc9
hexiaodong
hxd
|
166
|
/// <summary>
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
167
168
169
170
|
/// 获取会员耗卡列表
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
|
96009bc9
hexiaodong
hxd
|
171
172
173
174
175
176
177
178
|
[HttpGet("")]
public async Task<dynamic> GetList([FromQuery] LqXhHyhkListQueryInput input)
{
var sidx = input.sidx == null ? "id" : input.sidx;
List<string> queryHksj = input.hksj != null ? input.hksj.Split(',').ToObeject<List<string>>() : null;
DateTime? startHksj = queryHksj != null ? Ext.GetDateTime(queryHksj.First()) : null;
DateTime? endHksj = queryHksj != null ? Ext.GetDateTime(queryHksj.Last()) : null;
var data = await _db.Queryable<LqXhHyhkEntity>()
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
179
|
.WhereIF(!string.IsNullOrEmpty(input.keyword), p => p.Hymc.Contains(input.keyword) || p.Hyzh.Contains(input.keyword) || p.MemberPhone.Contains(input.keyword))
|
96009bc9
hexiaodong
hxd
|
180
181
182
183
184
185
186
187
|
.WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id))
.WhereIF(!string.IsNullOrEmpty(input.md), p => p.Md.Equals(input.md))
.WhereIF(!string.IsNullOrEmpty(input.mdbh), p => p.Mdbh.Contains(input.mdbh))
.WhereIF(!string.IsNullOrEmpty(input.mdmc), p => p.Mdmc.Contains(input.mdmc))
.WhereIF(!string.IsNullOrEmpty(input.hy), p => p.Hy.Equals(input.hy))
.WhereIF(!string.IsNullOrEmpty(input.hyzh), p => p.Hyzh.Contains(input.hyzh))
.WhereIF(!string.IsNullOrEmpty(input.hymc), p => p.Hymc.Contains(input.hymc))
.WhereIF(!string.IsNullOrEmpty(input.gklx), p => p.Gklx.Equals(input.gklx))
|
96009bc9
hexiaodong
hxd
|
188
189
190
191
|
.WhereIF(!string.IsNullOrEmpty(input.sfykjb), p => p.Sfykjb.Equals(input.sfykjb))
.WhereIF(queryHksj != null, p => p.Hksj >= new DateTime(startHksj.ToDate().Year, startHksj.ToDate().Month, startHksj.ToDate().Day, 0, 0, 0))
.WhereIF(queryHksj != null, p => p.Hksj <= new DateTime(endHksj.ToDate().Year, endHksj.ToDate().Month, endHksj.ToDate().Day, 23, 59, 59))
.WhereIF(!string.IsNullOrEmpty(input.czry), p => p.Czry.Equals(input.czry))
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
192
|
.Select(it => new LqXhHyhkListOutput
|
96009bc9
hexiaodong
hxd
|
193
194
|
{
id = it.Id,
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
195
196
197
198
199
200
201
|
md = it.Md,
mdbh = it.Mdbh,
mdmc = it.Mdmc,
hy = it.Hy,
hyzh = it.Hyzh,
hymc = it.Hymc,
gklx = it.Gklx,
|
d7925aaa
“wangming”
星期五了,下班咯
|
202
203
|
xfje = SqlFunc.ToString(it.Xfje),
sgfy = SqlFunc.ToString(it.Sgfy),
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
204
205
206
|
sfykjb = it.Sfykjb,
hksj = it.Hksj,
czry = it.Czry,
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
207
|
memberPhone = it.MemberPhone,
|
d98270e2
“wangming”
Enhance LqEventSe...
|
208
209
210
211
|
})
.MergeTable()
.OrderBy(sidx + " " + input.sort)
.ToPagedListAsync(input.currentPage, input.pageSize);
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
212
|
return PageResult<LqXhHyhkListOutput>.SqlSugarPageResult(data);
|
96009bc9
hexiaodong
hxd
|
213
|
}
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
214
|
#endregion
|
96009bc9
hexiaodong
hxd
|
215
|
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
216
|
#region 新建会员耗卡
|
96009bc9
hexiaodong
hxd
|
217
218
219
|
/// <summary>
/// 新建会员耗卡
/// </summary>
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
220
221
|
/// <remarks>
/// 创建会员耗卡记录及其关联的品项明细、健康师业绩、科技部老师业绩信息
|
d98270e2
“wangming”
Enhance LqEventSe...
|
222
|
///
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
/// 示例请求:
/// ```json
/// {
/// "hyid": "会员ID",
/// "hkmd": "耗卡门店",
/// "hksj": "2025-01-11",
/// "lqXhPxmxList": [
/// {
/// "px": "品项编号",
/// "pxmc": "品项名称",
/// "pxjg": 100.00,
/// "projectNumber": 1,
/// "xfzs": "否",
/// "lqXhJksyjList": [
/// {
/// "jks": "健康师",
/// "jksxm": "健康师姓名",
/// "jksyj": "100"
/// }
/// ]
/// }
/// ]
/// }
/// ```
|
d98270e2
“wangming”
Enhance LqEventSe...
|
247
|
///
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
248
249
250
251
252
253
254
255
256
257
|
/// 参数说明:
/// - hyid: 会员ID
/// - hkmd: 耗卡门店
/// - lqXhPxmxList: 耗卡品项明细列表
/// </remarks>
/// <param name="input">会员耗卡创建参数</param>
/// <returns>无返回值</returns>
/// <response code="200">创建成功</response>
/// <response code="400">参数错误或数据验证失败</response>
/// <response code="500">服务器内部错误</response>
|
96009bc9
hexiaodong
hxd
|
258
259
260
261
262
263
|
[HttpPost("")]
public async Task Create([FromBody] LqXhHyhkCrInput input)
{
var userInfo = await _userManager.GetUserInfo();
var entity = input.Adapt<LqXhHyhkEntity>();
entity.Id = YitIdHelper.NextId().ToString();
|
96009bc9
hexiaodong
hxd
|
264
|
entity.Czry = _userManager.UserId;
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
265
|
entity.MemberPhone = _db.Queryable<LqKhxxEntity>().Where(w => w.Id == entity.Hy).First().Sjh;
|
d98270e2
“wangming”
Enhance LqEventSe...
|
266
|
entity.CreateTime = DateTime.Now;
|
96009bc9
hexiaodong
hxd
|
267
268
|
try
{
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
269
|
// 开启事务
|
96009bc9
hexiaodong
hxd
|
270
|
_db.BeginTran();
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
271
|
// 新增会员耗卡记录
|
96009bc9
hexiaodong
hxd
|
272
|
var newEntity = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteReturnEntityAsync();
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
273
274
275
276
277
278
|
// 收集所有需要插入的实体,然后批量插入
var allPxmxEntities = new List<LqXhPxmxEntity>();
var allJksyjEntities = new List<LqXhJksyjEntity>();
var allKjbsyjEntities = new List<LqXhKjbsyjEntity>();
// 处理品项明细列表
if (input.lqXhPxmxList != null && input.lqXhPxmxList.Any())
|
96009bc9
hexiaodong
hxd
|
279
|
{
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
280
|
foreach (var item in input.lqXhPxmxList)
|
96009bc9
hexiaodong
hxd
|
281
|
{
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
282
283
284
285
|
// 创建品项明细实体
var lqXhPxmxEntity = new LqXhPxmxEntity
{
Id = YitIdHelper.NextId().ToString(),
|
b45d55f7
“wangming”
Refactor LqEventS...
|
286
287
|
ConsumeInfoId = newEntity.Id,
BillingItemId = item.billingItemId,
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
288
289
|
CreateTIme = DateTime.Now,
MemberId = entity.Hy,
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
290
291
292
293
294
|
ProjectNumber = item.projectNumber ?? 1,
TotalPrice = (decimal)(item.pxjg * (item.projectNumber ?? 1)),
Px = item.px,
Pxmc = item.pxmc,
Pxjg = item.pxjg,
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
295
296
297
|
SourceType = item.sourceType,
};
allPxmxEntities.Add(lqXhPxmxEntity);
|
d98270e2
“wangming”
Enhance LqEventSe...
|
298
|
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
299
300
301
302
303
|
// 收集该品项关联的健康师业绩
if (item.lqXhJksyjList != null && item.lqXhJksyjList.Any())
{
foreach (var ijks_tem in item.lqXhJksyjList)
{
|
d98270e2
“wangming”
Enhance LqEventSe...
|
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
allJksyjEntities.Add(
new LqXhJksyjEntity
{
Id = YitIdHelper.NextId().ToString(),
Glkdbh = newEntity.Id,
Jks = ijks_tem.jks,
Jksxm = ijks_tem.jksxm,
Jkszh = ijks_tem.jkszh,
Jksyj = ijks_tem.jksyj,
Yjsj = DateTime.Now,
JsjId = ijks_tem.jsjId,
Kdpxid = lqXhPxmxEntity.Id,
LaborCost = ijks_tem.laborCost,
KdpxNumber = ijks_tem.kdpxNumber,
}
);
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
320
321
|
}
}
|
d98270e2
“wangming”
Enhance LqEventSe...
|
322
|
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
323
324
325
326
327
|
// 收集该品项关联的科技部老师业绩
if (item.lqXhKjbsyjList != null && item.lqXhKjbsyjList.Any())
{
foreach (var ikjbs_tem in item.lqXhKjbsyjList)
{
|
d98270e2
“wangming”
Enhance LqEventSe...
|
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
allKjbsyjEntities.Add(
new LqXhKjbsyjEntity
{
Id = YitIdHelper.NextId().ToString(),
Glkdbh = newEntity.Id,
Kjbls = ikjbs_tem.kjbls,
Kjblsxm = ikjbs_tem.kjblsxm,
Kjblszh = ikjbs_tem.kjblszh,
Kjblsyj = ikjbs_tem.kjblsyj,
Yjsj = DateTime.Now,
Hkpxid = lqXhPxmxEntity.Id,
LaborCost = ikjbs_tem.laborCost,
HdpxNumber = ikjbs_tem.hdpxNumber,
}
);
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
343
344
|
}
}
|
96009bc9
hexiaodong
hxd
|
345
|
}
|
96009bc9
hexiaodong
hxd
|
346
|
}
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
347
348
|
// 批量插入品项明细
if (allPxmxEntities.Any())
|
96009bc9
hexiaodong
hxd
|
349
|
{
|
dac8767e
“wangming”
111111111
|
350
|
await _db.Insertable(allPxmxEntities).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
351
|
}
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
352
353
|
// 批量插入健康师业绩
if (allJksyjEntities.Any())
|
96009bc9
hexiaodong
hxd
|
354
|
{
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
355
|
await _db.Insertable(allJksyjEntities).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
356
|
}
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
357
358
359
360
361
362
|
// 批量插入科技部老师业绩
if (allKjbsyjEntities.Any())
{
await _db.Insertable(allKjbsyjEntities).ExecuteCommandAsync();
}
// 提交事务
|
96009bc9
hexiaodong
hxd
|
363
364
|
_db.CommitTran();
}
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
365
|
catch (Exception ex)
|
96009bc9
hexiaodong
hxd
|
366
|
{
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
367
|
// 回滚事务
|
96009bc9
hexiaodong
hxd
|
368
|
_db.RollbackTran();
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
369
370
371
|
Console.WriteLine($"新建会员耗卡失败: {ex.Message}");
Console.WriteLine($"堆栈跟踪: {ex.StackTrace}");
throw NCCException.Oh(ErrorCode.COM1000, $"新建会员耗卡失败: {ex.Message}");
|
96009bc9
hexiaodong
hxd
|
372
373
|
}
}
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
374
|
#endregion
|
96009bc9
hexiaodong
hxd
|
375
|
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
376
|
#region 获取会员耗卡无分页列表
|
96009bc9
hexiaodong
hxd
|
377
|
/// <summary>
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
378
379
380
381
|
/// 获取会员耗卡无分页列表
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
|
96009bc9
hexiaodong
hxd
|
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
|
[NonAction]
public async Task<dynamic> GetNoPagingList([FromQuery] LqXhHyhkListQueryInput input)
{
var sidx = input.sidx == null ? "id" : input.sidx;
List<string> queryHksj = input.hksj != null ? input.hksj.Split(',').ToObeject<List<string>>() : null;
DateTime? startHksj = queryHksj != null ? Ext.GetDateTime(queryHksj.First()) : null;
DateTime? endHksj = queryHksj != null ? Ext.GetDateTime(queryHksj.Last()) : null;
var data = await _db.Queryable<LqXhHyhkEntity>()
.WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id))
.WhereIF(!string.IsNullOrEmpty(input.md), p => p.Md.Equals(input.md))
.WhereIF(!string.IsNullOrEmpty(input.mdbh), p => p.Mdbh.Contains(input.mdbh))
.WhereIF(!string.IsNullOrEmpty(input.mdmc), p => p.Mdmc.Contains(input.mdmc))
.WhereIF(!string.IsNullOrEmpty(input.hy), p => p.Hy.Equals(input.hy))
.WhereIF(!string.IsNullOrEmpty(input.hyzh), p => p.Hyzh.Contains(input.hyzh))
.WhereIF(!string.IsNullOrEmpty(input.hymc), p => p.Hymc.Contains(input.hymc))
.WhereIF(!string.IsNullOrEmpty(input.gklx), p => p.Gklx.Equals(input.gklx))
|
96009bc9
hexiaodong
hxd
|
398
399
400
401
|
.WhereIF(!string.IsNullOrEmpty(input.sfykjb), p => p.Sfykjb.Equals(input.sfykjb))
.WhereIF(queryHksj != null, p => p.Hksj >= new DateTime(startHksj.ToDate().Year, startHksj.ToDate().Month, startHksj.ToDate().Day, 0, 0, 0))
.WhereIF(queryHksj != null, p => p.Hksj <= new DateTime(endHksj.ToDate().Year, endHksj.ToDate().Month, endHksj.ToDate().Day, 23, 59, 59))
.WhereIF(!string.IsNullOrEmpty(input.czry), p => p.Czry.Equals(input.czry))
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
402
|
.Select(it => new LqXhHyhkListOutput
|
96009bc9
hexiaodong
hxd
|
403
404
|
{
id = it.Id,
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
405
406
407
408
409
410
411
|
md = it.Md,
mdbh = it.Mdbh,
mdmc = it.Mdmc,
hy = it.Hy,
hyzh = it.Hyzh,
hymc = it.Hymc,
gklx = it.Gklx,
|
d7925aaa
“wangming”
星期五了,下班咯
|
412
413
|
xfje = SqlFunc.ToString(it.Xfje),
sgfy = SqlFunc.ToString(it.Sgfy),
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
414
415
416
|
sfykjb = it.Sfykjb,
hksj = it.Hksj,
czry = it.Czry,
|
d98270e2
“wangming”
Enhance LqEventSe...
|
417
418
419
420
|
})
.MergeTable()
.OrderBy(sidx + " " + input.sort)
.ToListAsync();
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
421
|
return data;
|
96009bc9
hexiaodong
hxd
|
422
|
}
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
423
|
#endregion
|
96009bc9
hexiaodong
hxd
|
424
|
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
425
|
#region 导出会员耗卡
|
96009bc9
hexiaodong
hxd
|
426
|
/// <summary>
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
427
428
429
430
|
/// 导出会员耗卡
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
|
96009bc9
hexiaodong
hxd
|
431
432
433
434
435
436
437
438
439
440
441
442
443
444
|
[HttpGet("Actions/Export")]
public async Task<dynamic> Export([FromQuery] LqXhHyhkListQueryInput input)
{
var userInfo = await _userManager.GetUserInfo();
var exportData = new List<LqXhHyhkListOutput>();
if (input.dataType == 0)
{
var data = Clay.Object(await this.GetList(input));
exportData = data.Solidify<PageResult<LqXhHyhkListOutput>>().list;
}
else
{
exportData = await this.GetNoPagingList(input);
}
|
d98270e2
“wangming”
Enhance LqEventSe...
|
445
446
|
List<ParamsModel> paramList =
"[{\"value\":\"耗卡编号\",\"field\":\"id\"},{\"value\":\"门店\",\"field\":\"md\"},{\"value\":\"门店编号\",\"field\":\"mdbh\"},{\"value\":\"门店名称\",\"field\":\"mdmc\"},{\"value\":\"会员\",\"field\":\"hy\"},{\"value\":\"会员账号\",\"field\":\"hyzh\"},{\"value\":\"会员名称\",\"field\":\"hymc\"},{\"value\":\"顾客类型\",\"field\":\"gklx\"},{\"value\":\"消费金额\",\"field\":\"xfje\"},{\"value\":\"手工费用\",\"field\":\"sgfy\"},{\"value\":\"是否有科技部\",\"field\":\"sfykjb\"},{\"value\":\"耗卡时间\",\"field\":\"hksj\"},{\"value\":\"操作人员\",\"field\":\"czry\"},]".ToList<ParamsModel>();
|
96009bc9
hexiaodong
hxd
|
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
|
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<LqXhHyhkListOutput>.Export(exportData, excelconfig, addPath);
var fileName = _userManager.UserId + "|" + addPath + "|xls";
|
d98270e2
“wangming”
Enhance LqEventSe...
|
465
|
var output = new { name = excelconfig.FileName, url = "/api/File/Download?encryption=" + DESCEncryption.Encrypt(fileName, "NCC") };
|
96009bc9
hexiaodong
hxd
|
466
467
|
return output;
}
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
468
|
#endregion
|
96009bc9
hexiaodong
hxd
|
469
|
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
470
|
#region 批量删除会员耗卡
|
96009bc9
hexiaodong
hxd
|
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
|
/// <summary>
/// 批量删除会员耗卡
/// </summary>
/// <param name="ids">主键数组</param>
/// <returns></returns>
[HttpPost("batchRemove")]
public async Task BatchRemove([FromBody] List<string> ids)
{
var entitys = await _db.Queryable<LqXhHyhkEntity>().In(it => it.Id, ids).ToListAsync();
if (entitys.Count > 0)
{
try
{
//开启事务
_db.BeginTran();
//批量删除会员耗卡
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
487
|
await _db.Deleteable<LqXhHyhkEntity>().In(d => d.Id, ids).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
488
489
|
//清空子表数据
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
490
|
await _db.Deleteable<LqXhJksyjEntity>().In(u => u.Glkdbh, ids).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
491
492
|
//清空子表数据
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
493
|
await _db.Deleteable<LqXhKjbsyjEntity>().In(u => u.Glkdbh, ids).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
494
495
|
//清空子表数据
|
b45d55f7
“wangming”
Refactor LqEventS...
|
496
|
await _db.Deleteable<LqXhPxmxEntity>().In(u => u.ConsumeInfoId, ids).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
497
498
499
500
501
502
503
504
505
506
507
|
//关闭事务
_db.CommitTran();
}
catch (Exception)
{
//回滚事务
_db.RollbackTran();
throw NCCException.Oh(ErrorCode.COM1002);
}
}
}
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
508
|
#endregion
|
96009bc9
hexiaodong
hxd
|
509
|
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
510
|
#region 更新会员耗卡
|
96009bc9
hexiaodong
hxd
|
511
|
/// <summary>
|
d7925aaa
“wangming”
星期五了,下班咯
|
512
|
/// 更新会员耗卡,不会删除品项明细,只会更新或新增
|
96009bc9
hexiaodong
hxd
|
513
514
515
516
517
518
519
520
521
522
523
524
|
/// </summary>
/// <param name="id">主键</param>
/// <param name="input">参数</param>
/// <returns></returns>
[HttpPut("{id}")]
public async Task Update(string id, [FromBody] LqXhHyhkUpInput input)
{
var entity = input.Adapt<LqXhHyhkEntity>();
try
{
//开启事务
_db.BeginTran();
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
525
526
527
528
529
530
|
//查询记录
var LqXhHyhkInfo = await _db.Queryable<LqXhHyhkEntity>().Where(p => p.Id == id && p.IsEffective == StatusEnum.有效.GetHashCode()).FirstAsync();
if (LqXhHyhkInfo == null)
{
throw NCCException.Oh(ErrorCode.COM1005, "耗卡记录不存在或已作废");
}
|
d98270e2
“wangming”
Enhance LqEventSe...
|
531
|
entity.UpdateTime = DateTime.Now;
|
96009bc9
hexiaodong
hxd
|
532
533
534
535
536
|
//更新会员耗卡记录
await _db.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
//清空原有数据
await _db.Deleteable<LqXhJksyjEntity>().Where(u => u.Glkdbh == id).ExecuteCommandAsync();
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
537
|
await _db.Deleteable<LqXhKjbsyjEntity>().Where(u => u.Glkdbh == id).ExecuteCommandAsync();
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
538
|
await _db.Deleteable<LqXhPxmxEntity>().Where(u => u.ConsumeInfoId == id).ExecuteCommandAsync();
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
539
540
541
542
|
// 收集所有需要插入的实体,然后批量插入
var allPxmxEntities = new List<LqXhPxmxEntity>();
var allJksyjEntities = new List<LqXhJksyjEntity>();
var allKjbsyjEntities = new List<LqXhKjbsyjEntity>();
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
543
544
|
// 处理品项明细列表
if (input.lqXhPxmxList != null && input.lqXhPxmxList.Any())
|
96009bc9
hexiaodong
hxd
|
545
|
{
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
546
|
foreach (var item in input.lqXhPxmxList)
|
96009bc9
hexiaodong
hxd
|
547
|
{
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
548
549
|
// 创建品项明细实体
var lqXhPxmxEntity = new LqXhPxmxEntity
|
d7925aaa
“wangming”
星期五了,下班咯
|
550
|
{
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
551
552
553
554
555
556
557
558
559
560
561
562
|
Id = YitIdHelper.NextId().ToString(),
ConsumeInfoId = input.id,
BillingItemId = item.billingItemId,
CreateTIme = DateTime.Now,
MemberId = entity.Hy,
ProjectNumber = item.projectNumber ?? 1,
TotalPrice = (decimal)(item.pxjg * (item.projectNumber ?? 1)),
Px = item.px,
Pxmc = item.pxmc,
Pxjg = item.pxjg,
SourceType = item.sourceType,
};
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
563
|
allPxmxEntities.Add(lqXhPxmxEntity);
|
d98270e2
“wangming”
Enhance LqEventSe...
|
564
|
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
565
566
567
568
569
|
// 收集该品项关联的健康师业绩
if (item.lqXhJksyjList != null && item.lqXhJksyjList.Any())
{
foreach (var ijks_tem in item.lqXhJksyjList)
{
|
d98270e2
“wangming”
Enhance LqEventSe...
|
570
571
572
573
|
allJksyjEntities.Add(
new LqXhJksyjEntity
{
Id = YitIdHelper.NextId().ToString(),
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
574
|
Glkdbh = input.id,
|
d98270e2
“wangming”
Enhance LqEventSe...
|
575
576
577
578
579
580
581
582
583
584
585
|
Jks = ijks_tem.jks,
Jksxm = ijks_tem.jksxm,
Jkszh = ijks_tem.jkszh,
Jksyj = ijks_tem.jksyj,
Yjsj = DateTime.Now,
JsjId = ijks_tem.jsjId,
Kdpxid = lqXhPxmxEntity.Id,
LaborCost = ijks_tem.laborCost,
KdpxNumber = ijks_tem.kdpxNumber,
}
);
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
586
587
|
}
}
|
d98270e2
“wangming”
Enhance LqEventSe...
|
588
|
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
589
590
591
592
593
|
// 收集该品项关联的科技部老师业绩
if (item.lqXhKjbsyjList != null && item.lqXhKjbsyjList.Any())
{
foreach (var ikjbs_tem in item.lqXhKjbsyjList)
{
|
d98270e2
“wangming”
Enhance LqEventSe...
|
594
595
596
597
|
allKjbsyjEntities.Add(
new LqXhKjbsyjEntity
{
Id = YitIdHelper.NextId().ToString(),
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
598
|
Glkdbh = input.id,
|
d98270e2
“wangming”
Enhance LqEventSe...
|
599
600
601
602
603
604
605
606
607
608
|
Kjbls = ikjbs_tem.kjbls,
Kjblsxm = ikjbs_tem.kjblsxm,
Kjblszh = ikjbs_tem.kjblszh,
Kjblsyj = ikjbs_tem.kjblsyj,
Yjsj = DateTime.Now,
Hkpxid = lqXhPxmxEntity.Id,
LaborCost = ikjbs_tem.laborCost,
HdpxNumber = ikjbs_tem.hdpxNumber,
}
);
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
609
610
|
}
}
|
96009bc9
hexiaodong
hxd
|
611
|
}
|
96009bc9
hexiaodong
hxd
|
612
|
}
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
613
614
|
// 批量插入品项明细
if (allPxmxEntities.Any())
|
96009bc9
hexiaodong
hxd
|
615
|
{
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
616
|
await _db.Insertable(allPxmxEntities).ExecuteCommandAsync();
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
617
618
619
620
621
622
623
624
625
626
|
}
// 批量插入健康师业绩
if (allJksyjEntities.Any())
{
await _db.Insertable(allJksyjEntities).ExecuteCommandAsync();
}
// 批量插入科技部老师业绩
if (allKjbsyjEntities.Any())
{
await _db.Insertable(allKjbsyjEntities).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
627
|
}
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
628
|
// 提交事务
|
96009bc9
hexiaodong
hxd
|
629
630
631
632
633
634
635
636
637
|
_db.CommitTran();
}
catch (Exception)
{
//回滚事务
_db.RollbackTran();
throw NCCException.Oh(ErrorCode.COM1001);
}
}
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
638
|
#endregion
|
96009bc9
hexiaodong
hxd
|
639
|
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
640
|
#region 删除会员耗卡
|
96009bc9
hexiaodong
hxd
|
641
642
643
644
645
646
647
648
649
650
651
652
653
|
/// <summary>
/// 删除会员耗卡
/// </summary>
/// <returns></returns>
[HttpDelete("{id}")]
public async Task Delete(string id)
{
var entity = await _db.Queryable<LqXhHyhkEntity>().FirstAsync(p => p.Id == id);
_ = entity ?? throw NCCException.Oh(ErrorCode.COM1005);
try
{
//开启事务
_db.BeginTran();
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
654
|
|
96009bc9
hexiaodong
hxd
|
655
656
657
658
659
660
661
662
663
664
|
//删除会员耗卡记录
await _db.Deleteable<LqXhHyhkEntity>().Where(d => d.Id == id).ExecuteCommandAsync();
//清空子表数据
await _db.Deleteable<LqXhJksyjEntity>().Where(u => u.Glkdbh == id).ExecuteCommandAsync();
//清空子表数据
await _db.Deleteable<LqXhKjbsyjEntity>().Where(u => u.Glkdbh == id).ExecuteCommandAsync();
//清空子表数据
|
b45d55f7
“wangming”
Refactor LqEventS...
|
665
|
await _db.Deleteable<LqXhPxmxEntity>().Where(u => u.ConsumeInfoId == id).ExecuteCommandAsync();
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
666
|
|
96009bc9
hexiaodong
hxd
|
667
668
669
670
671
672
673
674
675
676
|
//关闭事务
_db.CommitTran();
}
catch (Exception)
{
//回滚事务
_db.RollbackTran();
throw NCCException.Oh(ErrorCode.COM1002);
}
}
|
35bb18d3
“wangming”
更新多个.DS_Store文件,删...
|
677
|
#endregion
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
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
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
|
#region 查询健康师消耗业绩列表
/// <summary>
/// 查询健康师业绩列表
/// </summary>
/// <param name="input">查询参数</param>
/// <returns>分页的健康师业绩列表</returns>
/// <remarks>
/// 查询健康师业绩记录,支持分页和时间筛选
///
/// 示例请求:
/// ```json
/// {
/// "glkdbh": "123456789",
/// "jksId": "健康师ID",
/// "startTime": "2025-01-01T00:00:00",
/// "endTime": "2025-01-31T23:59:59",
/// "currentPage": 1,
/// "pageSize": 10,
/// "sidx": "yjsj",
/// "sort": "desc"
/// }
/// ```
///
/// 参数说明:
/// - glkdbh: 开单记录ID(可选)
/// - jksId: 健康师ID(可选)
/// - startTime: 查询开始时间(可选)
/// - endTime: 查询结束时间(可选)
/// - currentPage: 当前页码
/// - pageSize: 每页大小
/// </remarks>
/// <response code="200">成功获取健康师业绩列表</response>
/// <response code="400">请求参数错误</response>
/// <response code="500">服务器内部错误</response>
[HttpGet("GetJksyjList")]
public async Task<dynamic> GetJksyjList([FromQuery] LqXhJksyjQueryInput input)
{
try
{
var sidx = string.IsNullOrEmpty(input.sidx) ? "yjsj" : input.sidx;
var sort = string.IsNullOrEmpty(input.sort) ? "desc" : input.sort;
var data = await _db.Queryable<LqXhJksyjEntity>()
.WhereIF(!string.IsNullOrEmpty(input.Glkdbh), w => w.Glkdbh == input.Glkdbh)
.WhereIF(!string.IsNullOrEmpty(input.JksId), w => w.Jks == input.JksId)
.WhereIF(input.StartTime.HasValue, w => w.Yjsj >= input.StartTime.Value)
.WhereIF(input.EndTime.HasValue, w => w.Yjsj <= input.EndTime.Value)
.Where(w => w.IsEffective == StatusEnum.有效.GetHashCode())
.Select(it => new LqXhJksyjInfoOutput
{
id = it.Id,
glkdbh = it.Glkdbh,
jks = it.Jks,
jksxm = it.Jksxm,
jkszh = it.Jkszh,
jksyj = it.Jksyj.ToString(),
yjsj = it.Yjsj,
jsjId = it.JsjId,
kdpxid = it.Kdpxid,
laborCost = it.LaborCost,
kdpxNumber = it.KdpxNumber,
storeName = SqlFunc.Subqueryable<LqXhHyhkEntity>().Where(w => w.Id == it.Glkdbh).Select(w => w.Mdmc),
memberId = SqlFunc.Subqueryable<LqXhHyhkEntity>().Where(w => w.Id == it.Glkdbh).Select(w => w.Hy),
memberName = SqlFunc.Subqueryable<LqXhHyhkEntity>().Where(w => w.Id == it.Glkdbh).Select(w => w.Hymc),
})
.MergeTable()
.OrderBy(sidx + " " + sort)
.ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<LqXhJksyjInfoOutput>.SqlSugarPageResult(data);
}
catch (Exception ex)
{
throw NCCException.Oh($"获取健康师业绩列表失败: {ex.Message}");
}
}
#endregion
#region 耗卡记录作废
/// <summary>
/// 耗卡记录作废
/// </summary>
/// <param name="id">耗卡记录ID</param>
/// <returns></returns>
[HttpPut("CancelCardUsageRecord/{id}")]
public async Task<dynamic> CancelCardUsageRecord(string id)
{
try
{
//开启事务
_db.BeginTran();
//查询消耗记录表信息
var LqhyhkInfo = await _db.Queryable<LqXhHyhkEntity>().Where(p => p.Id == id && p.IsEffective == StatusEnum.有效.GetHashCode()).FirstAsync();
if (LqhyhkInfo == null)
{
throw NCCException.Oh(ErrorCode.COM1005, "耗卡记录不存在或已作废");
}
//更新耗卡记录状态
LqhyhkInfo.IsEffective = StatusEnum.无效.GetHashCode();
await _db.Updateable(LqhyhkInfo).ExecuteCommandAsync();
//更新品项明细表状态
await _db.Updateable<LqXhPxmxEntity>().SetColumns(it => new LqXhPxmxEntity { IsEffective = StatusEnum.无效.GetHashCode() }).Where(w => w.ConsumeInfoId == id).ExecuteCommandAsync();
//更新健康师业绩表状态
await _db.Updateable<LqXhJksyjEntity>().SetColumns(it => new LqXhJksyjEntity { IsEffective = StatusEnum.无效.GetHashCode() }).Where(w => w.Glkdbh == id).ExecuteCommandAsync();
//更新科技部老师业绩表状态
await _db.Updateable<LqXhKjbsyjEntity>().SetColumns(it => new LqXhKjbsyjEntity { IsEffective = StatusEnum.无效.GetHashCode() }).Where(w => w.Glkdbh == id).ExecuteCommandAsync();
//关闭事务
_db.CommitTran();
return LqhyhkInfo;
}
catch (Exception)
{
//回滚事务
_db.RollbackTran();
throw NCCException.Oh(ErrorCode.COM1001);
}
}
#endregion
#region 获取某个会员的耗卡记录
/// <summary>
/// 获取某个会员的耗卡记录(分页)
/// </summary>
/// <param name="input">查询参数</param>
/// <returns></returns>
[HttpGet("GetMemberCardUsageRecord")]
public async Task<dynamic> GetMemberCardUsageRecord([FromQuery] LqXhHyhkMemberCardUsageQueryInput input)
{
try
{
// 参数验证
if (string.IsNullOrEmpty(input.MemberId))
{
throw NCCException.Oh("会员ID不能为空");
}
// 分页查询会员耗卡记录
var data = await _db.Queryable<LqXhHyhkEntity>()
.Where(p => p.Hy == input.MemberId && p.IsEffective == StatusEnum.有效.GetHashCode())
.WhereIF(!string.IsNullOrEmpty(input.StoreId), p => p.Md == input.StoreId)
.WhereIF(input.StartTime.HasValue, p => p.Hksj >= input.StartTime.Value)
.WhereIF(input.EndTime.HasValue, p => p.Hksj <= input.EndTime.Value)
.Select(it => new LqXhHyhkMemberCardUsageOutput
{
Id = it.Id,
MemberId = it.Hy,
MemberName = it.Hymc,
StoreId = it.Md,
StoreName = it.Mdmc,
UsageDate = it.Hksj,
TotalAmount = it.Xfje,
Remarks = it.SignatureFile,
CreateTime = it.CreateTime
})
.MergeTable()
.OrderBy((input.sidx == null ? "UsageDate" : input.sidx) + " " + (input.sort ?? "desc"))
.ToPagedListAsync(input.currentPage, input.pageSize);
// 获取当前页耗卡记录ID,直接查询对应的品项明细
if (data.list.Any())
{
var recordIds = data.list.Select(r => r.Id).ToList();
// 批量查询当前页记录的所有品项明细
var itemDetails = await _db.Queryable<LqXhPxmxEntity>().Where(w => recordIds.Contains(w.ConsumeInfoId) && w.IsEffective == StatusEnum.有效.GetHashCode()).ToListAsync();
// 按耗卡记录ID分组明细
var detailsGrouped = itemDetails.GroupBy(d => d.ConsumeInfoId).ToDictionary(g => g.Key, g => g.ToList());
// 为每个记录添加品项明细
foreach (var record in data.list)
{
if (detailsGrouped.ContainsKey(record.Id))
{
record.ItemDetails = detailsGrouped[record.Id].Select(detail => new LqXhHyhkMemberCardUsageItemDetail
{
Id = detail.Id,
ItemId = detail.Px,
ItemName = detail.Pxmc,
UnitPrice = detail.Pxjg,
ProjectNumber = detail.ProjectNumber,
TotalPrice = detail.TotalPrice,
SourceType = detail.SourceType,
CreateTime = detail.CreateTIme
}).ToList();
}
}
}
return PageResult<LqXhHyhkMemberCardUsageOutput>.SqlSugarPageResult(data);
}
catch (Exception ex)
{
throw NCCException.Oh($"获取会员耗卡记录失败: {ex.Message}");
}
}
#endregion
|
96009bc9
hexiaodong
hxd
|
871
872
|
}
}
|