00486d53
“wangming”
更新多个.DS_Store文件,优...
|
1
2
|
using System;
using System.Collections.Generic;
|
d64f9fbd
“wangming”
feat: 添加退卡明细查询和导出功能
|
3
|
using System.IO;
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
4
|
using System.Linq;
|
d64f9fbd
“wangming”
feat: 添加退卡明细查询和导出功能
|
5
|
using System.Reflection;
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
6
7
8
9
10
|
using System.Threading.Tasks;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using NCC.ClayObject;
using NCC.Common.Configuration;
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
11
|
using NCC.Common.Core.Manager;
|
96009bc9
hexiaodong
hxd
|
12
13
14
|
using NCC.Common.Enum;
using NCC.Common.Extension;
using NCC.Common.Filter;
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
15
16
17
|
using NCC.Common.Helper;
using NCC.Common.Model.NPOI;
using NCC.DataEncryption;
|
96009bc9
hexiaodong
hxd
|
18
19
|
using NCC.Dependency;
using NCC.DynamicApiController;
|
96009bc9
hexiaodong
hxd
|
20
|
using NCC.Extend.Entitys.Dto.LqHytkHytk;
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
21
22
|
using NCC.Extend.Entitys.Dto.LqHytkJksyj;
using NCC.Extend.Entitys.Dto.LqHytkKjbsyj;
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
23
|
using NCC.Extend.Entitys.Dto.LqHytkMx;
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
24
|
using NCC.Extend.Entitys.Enum;
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
25
26
27
28
|
using NCC.Extend.Entitys.lq_hytk_hytk;
using NCC.Extend.Entitys.lq_hytk_jksyj;
using NCC.Extend.Entitys.lq_hytk_kjbsyj;
using NCC.Extend.Entitys.lq_hytk_mx;
|
bc35ccd1
“wangming”
feat: 添加退卡业务相关功能
|
29
|
using NCC.Extend.Entitys.lq_kd_pxmx;
|
77631543
“wangming”
优化门店驾驶舱页面布局并添加退款明...
|
30
|
using NCC.Extend.Entitys.lq_kd_jksyj;
|
14cbcfd9
“wangming”
feat: 添加人次记录表和品项分类字段
|
31
|
using NCC.Extend.Entitys.lq_xmzl;
|
d64f9fbd
“wangming”
feat: 添加退卡明细查询和导出功能
|
32
33
|
using NCC.Extend.Entitys.lq_khxx;
using NCC.Extend.Entitys.lq_mdxx;
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
34
35
|
using NCC.Extend.Interfaces.LqHytkHytk;
using NCC.FriendlyException;
|
96009bc9
hexiaodong
hxd
|
36
|
using NCC.JsonSerialization;
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
37
38
|
using SqlSugar;
using Yitter.IdGenerator;
|
96009bc9
hexiaodong
hxd
|
39
40
41
42
|
namespace NCC.Extend.LqHytkHytk
{
/// <summary>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
43
|
/// 退卡_信息表服务
|
96009bc9
hexiaodong
hxd
|
44
|
/// </summary>
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
45
|
[ApiDescriptionSettings(Tag = "绿纤退卡信息表服务", Name = "LqHytkHytk", Order = 200)]
|
96009bc9
hexiaodong
hxd
|
46
47
48
49
50
|
[Route("api/Extend/[controller]")]
public class LqHytkHytkService : ILqHytkHytkService, IDynamicApiController, ITransient
{
private readonly ISqlSugarRepository<LqHytkHytkEntity> _lqHytkHytkRepository;
private readonly ISqlSugarRepository<LqHytkMxEntity> _lqHytkMxRepository;
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
51
52
|
private readonly ISqlSugarRepository<LqHytkJksyjEntity> _lqHytkJksyjRepository;
private readonly ISqlSugarRepository<LqHytkKjbsyjEntity> _lqHytkKjbsyjRepository;
|
96009bc9
hexiaodong
hxd
|
53
54
55
56
57
58
59
60
61
|
private readonly SqlSugarScope _db;
private readonly IUserManager _userManager;
/// <summary>
/// 初始化一个<see cref="LqHytkHytkService"/>类型的新实例
/// </summary>
public LqHytkHytkService(
ISqlSugarRepository<LqHytkHytkEntity> lqHytkHytkRepository,
ISqlSugarRepository<LqHytkMxEntity> lqHytkMxRepository,
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
62
63
|
ISqlSugarRepository<LqHytkJksyjEntity> lqHytkJksyjRepository,
ISqlSugarRepository<LqHytkKjbsyjEntity> lqHytkKjbsyjRepository,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
64
65
|
IUserManager userManager
)
|
96009bc9
hexiaodong
hxd
|
66
|
{
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
67
|
_lqHytkHytkRepository = lqHytkHytkRepository;
|
96009bc9
hexiaodong
hxd
|
68
|
_lqHytkMxRepository = lqHytkMxRepository;
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
69
70
71
|
_lqHytkJksyjRepository = lqHytkJksyjRepository;
_lqHytkKjbsyjRepository = lqHytkKjbsyjRepository;
_db = _lqHytkHytkRepository.Context;
|
96009bc9
hexiaodong
hxd
|
72
73
74
|
_userManager = userManager;
}
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
75
|
#region 获取退卡信息列表
|
96009bc9
hexiaodong
hxd
|
76
|
/// <summary>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
77
|
/// 获取退卡信息列表
|
96009bc9
hexiaodong
hxd
|
78
|
/// </summary>
|
a78c0ae8
“wangming”
feat: 退卡服务添加健康师和科...
|
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/// <remarks>
/// 获取退卡记录列表,支持根据健康师ID或科技部老师ID筛选,返回品项明细、健康师业绩和科技部老师业绩
///
/// 示例请求:
/// ```json
/// GET /api/Extend/LqHytkHytk?jksId=健康师ID&kjblsId=科技部老师ID&currentPage=1&pageSize=10
/// ```
///
/// 参数说明:
/// - jksId: 健康师ID(可选,传入后只返回该健康师参与的退卡记录)
/// - kjblsId: 科技部老师ID(可选,传入后只返回该老师参与的退卡记录)
/// - id: 退卡编号(可选)
/// - md: 门店ID(可选)
/// - hy: 会员ID(可选)
/// - tksj: 退卡时间(可选,格式:yyyy-MM-dd,yyyy-MM-dd)
/// - currentPage: 当前页码(必填)
/// - pageSize: 每页数量(必填)
///
/// 返回数据说明:
/// - 退卡基本信息:id、门店信息、会员信息、退卡金额、退卡时间等
/// - lqHytkMxList: 退卡品项明细列表,每个明细包含品项信息、退款金额、项目次数等
/// - lqHytkJksyjList: 健康师业绩列表,每个业绩包含健康师信息、业绩金额、手工费、退卡品项次数等
/// - lqHytkKjbsyjList: 科技部老师业绩列表,每个业绩包含科技部老师信息、业绩金额、手工费、退卡品项次数等
/// </remarks>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
103
|
/// <param name="input">查询参数</param>
|
a78c0ae8
“wangming”
feat: 退卡服务添加健康师和科...
|
104
105
106
107
|
/// <returns>分页的退卡记录列表,包含退卡基本信息、品项明细、健康师业绩、科技部老师业绩</returns>
/// <response code="200">成功返回退卡列表</response>
/// <response code="400">参数错误</response>
/// <response code="500">服务器内部错误</response>
|
96009bc9
hexiaodong
hxd
|
108
109
110
111
|
[HttpGet("")]
public async Task<dynamic> GetList([FromQuery] LqHytkHytkListQueryInput input)
{
var sidx = input.sidx == null ? "id" : input.sidx;
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
112
|
List<string> queryTksj = input.tksj != null ? input.tksj.Split(',').ToObeject<List<string>>() : null;
|
96009bc9
hexiaodong
hxd
|
113
114
|
DateTime? startTksj = queryTksj != null ? Ext.GetDateTime(queryTksj.First()) : null;
DateTime? endTksj = queryTksj != null ? Ext.GetDateTime(queryTksj.Last()) : null;
|
a78c0ae8
“wangming”
feat: 退卡服务添加健康师和科...
|
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
// 根据是否传入健康师ID或科技部老师ID,动态构建查询
ISugarQueryable<LqHytkHytkEntity> baseQuery = null;
if (!string.IsNullOrEmpty(input.jksId) && !string.IsNullOrEmpty(input.kjblsId))
{
// 同时传入健康师ID和科技部老师ID,需要同时关联两个业绩表(不过滤有效性)
baseQuery = _db.Queryable<LqHytkJksyjEntity, LqHytkKjbsyjEntity, LqHytkHytkEntity>(
(jksyj, kjbsyj, hytk) => jksyj.Gltkbh == hytk.Id && kjbsyj.Gltkbh == hytk.Id)
.Where((jksyj, kjbsyj, hytk) => jksyj.Jkszh == input.jksId)
.Where((jksyj, kjbsyj, hytk) => kjbsyj.Kjblszh == input.kjblsId)
.Select((jksyj, kjbsyj, hytk) => hytk)
.Distinct()
.MergeTable();
}
else if (!string.IsNullOrEmpty(input.jksId))
{
// 只传入健康师ID,关联健康师业绩表(不过滤有效性)
baseQuery = _db.Queryable<LqHytkJksyjEntity, LqHytkHytkEntity>(
(jksyj, hytk) => jksyj.Gltkbh == hytk.Id)
.Where((jksyj, hytk) => jksyj.Jkszh == input.jksId)
.Select((jksyj, hytk) => hytk)
.Distinct()
.MergeTable();
}
else if (!string.IsNullOrEmpty(input.kjblsId))
{
// 只传入科技部老师ID,关联科技部老师业绩表(不过滤有效性)
baseQuery = _db.Queryable<LqHytkKjbsyjEntity, LqHytkHytkEntity>(
(kjbsyj, hytk) => kjbsyj.Gltkbh == hytk.Id)
.Where((kjbsyj, hytk) => kjbsyj.Kjblszh == input.kjblsId)
.Select((kjbsyj, hytk) => hytk)
.Distinct()
.MergeTable();
}
else
{
// 没有传入健康师ID或科技部老师ID,使用原来的查询逻辑
baseQuery = _db.Queryable<LqHytkHytkEntity>();
}
var data = await baseQuery
|
96009bc9
hexiaodong
hxd
|
157
158
|
.WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id))
.WhereIF(!string.IsNullOrEmpty(input.md), p => p.Md.Equals(input.md))
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
159
|
.WhereIF(!string.IsNullOrEmpty(input.mdbh), p => p.Mdbh.Contains(input.mdbh))
|
96009bc9
hexiaodong
hxd
|
160
161
|
.WhereIF(!string.IsNullOrEmpty(input.mdmc), p => p.Mdmc.Contains(input.mdmc))
.WhereIF(!string.IsNullOrEmpty(input.hy), p => p.Hy.Equals(input.hy))
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
162
|
.WhereIF(!string.IsNullOrEmpty(input.hymc), p => p.Hymc.Contains(input.hymc))
|
96009bc9
hexiaodong
hxd
|
163
|
.WhereIF(!string.IsNullOrEmpty(input.hyzh), p => p.Hyzh.Contains(input.hyzh))
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
164
165
166
|
.WhereIF(!string.IsNullOrEmpty(input.gklx), p => p.Gklx.Contains(input.gklx))
.WhereIF(input.tkje.HasValue, p => p.Tkje == input.tkje)
.WhereIF(input.sgfy.HasValue, p => p.Sgfy == input.sgfy)
|
96009bc9
hexiaodong
hxd
|
167
|
.WhereIF(!string.IsNullOrEmpty(input.bz), p => p.Bz.Contains(input.bz))
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
168
169
|
.WhereIF(!string.IsNullOrEmpty(input.tkzt), p => p.Tkzt.Contains(input.tkzt))
.WhereIF(!string.IsNullOrEmpty(input.tkyy), p => p.Tkyy.Contains(input.tkyy))
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
170
|
.WhereIF(!string.IsNullOrEmpty(input.fileUrl), p => p.FileUrl.Contains(input.fileUrl))
|
fee50345
“wangming”
feat: 实现KPI数据穿透功能
|
171
172
|
.WhereIF(startTksj.HasValue, p => p.Tksj >= new DateTime(startTksj.Value.Year, startTksj.Value.Month, startTksj.Value.Day, 0, 0, 0))
.WhereIF(endTksj.HasValue, p => p.Tksj <= new DateTime(endTksj.Value.Year, endTksj.Value.Month, endTksj.Value.Day, 23, 59, 59))
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
173
|
.WhereIF(!string.IsNullOrEmpty(input.czry), p => p.Czry.Equals(input.czry))
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
174
|
.WhereIF(input.isEffective != 0, p => p.IsEffective == input.isEffective)
|
5e0c6e5a
“wangming”
feat: 完善会员画像功能,优化...
|
175
|
.WhereIF(input.isEffective == 0, p => p.IsEffective == StatusEnum.有效.GetHashCode()) // 如果未指定,默认只返回有效的
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
176
|
.Select(it => new LqHytkHytkListOutput
|
96009bc9
hexiaodong
hxd
|
177
178
|
{
id = it.Id,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
md = it.Md,
mdbh = it.Mdbh,
mdmc = it.Mdmc,
hy = it.Hy,
hymc = it.Hymc,
hyzh = it.Hyzh,
gklx = it.Gklx,
tkje = it.Tkje,
sgfy = it.Sgfy,
bz = it.Bz,
tkzt = it.Tkzt,
tkyy = it.Tkyy,
tksj = it.Tksj,
czry = it.Czry,
fileUrl = it.FileUrl,
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
194
|
isEffective = it.IsEffective,
|
fb9d5c60
“wangming”
feat: 更新LqHytkHyt...
|
195
|
cancelRemark = it.CancelRemark,
|
63df7ccb
“wangming”
1
|
196
|
actualRefundAmount = it.ActualRefundAmount
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
197
198
199
200
|
})
.MergeTable()
.OrderBy(sidx + " " + input.sort)
.ToPagedListAsync(input.currentPage, input.pageSize);
|
a78c0ae8
“wangming”
feat: 退卡服务添加健康师和科...
|
201
202
203
204
205
206
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
// 获取当前页的退卡记录ID列表
var refundIds = data.list.Select(x => x.id).ToList();
// 批量查询品项明细(不过滤有效性,返回所有记录)
var itemDetails = new List<LqHytkMxInfoOutput>();
if (refundIds.Any())
{
itemDetails = await _db.Queryable<LqHytkMxEntity>()
.Where(x => refundIds.Contains(x.RefundInfoId))
.Select(x => new LqHytkMxInfoOutput
{
id = x.Id,
refundInfoId = x.RefundInfoId,
billingItemId = x.BillingItemId,
px = x.Px,
pxmc = x.Pxmc,
pxjg = x.Pxjg,
tkje = x.Tkje,
projectNumber = x.ProjectNumber,
isEffective = x.IsEffective,
sourceType = x.SourceType,
totalPrice = x.TotalPrice
})
.ToListAsync();
}
// 批量查询健康师业绩(性能优化:一次性查询所有退卡的健康师业绩,不过滤有效性)
var jksyjList = new List<LqHytkJksyjInfoOutput>();
if (refundIds.Any())
{
jksyjList = await _db.Queryable<LqHytkJksyjEntity>()
.Where(x => refundIds.Contains(x.Gltkbh))
.Select(x => new LqHytkJksyjInfoOutput
{
id = x.Id,
gltkbh = x.Gltkbh,
jks = x.Jks,
jksxm = x.Jksxm,
jkszh = x.Jkszh,
jksyj = x.Jksyj,
tksj = x.Tksj,
F_jsjid = x.F_jsjid,
F_tkpxid = x.F_tkpxid,
F_LaborCost = x.F_LaborCost,
F_tkpxNumber = x.F_tkpxNumber
})
.ToListAsync();
}
// 批量查询科技部老师业绩(性能优化:一次性查询所有退卡的科技部老师业绩,不过滤有效性)
var kjbsyjList = new List<LqHytkKjbsyjInfoOutput>();
if (refundIds.Any())
{
kjbsyjList = await _db.Queryable<LqHytkKjbsyjEntity>()
.Where(x => refundIds.Contains(x.Gltkbh))
.Select(x => new LqHytkKjbsyjInfoOutput
{
id = x.Id,
gltkbh = x.Gltkbh,
kjbls = x.Kjbls,
kjblsxm = x.Kjblsxm,
kjblszh = x.Kjblszh,
kjblsyj = x.Kjblsyj,
tksj = x.Tksj,
F_tkpxid = x.F_tkpxid,
F_LaborCost = x.F_LaborCost,
F_tkpxNumber = x.F_tkpxNumber
})
.ToListAsync();
}
// 按退卡ID分组品项明细
var itemDetailsGrouped = itemDetails.GroupBy(x => x.refundInfoId)
.ToDictionary(g => g.Key, g => g.ToList());
// 按退卡ID分组健康师业绩
var jksyjGrouped = jksyjList.GroupBy(x => x.gltkbh)
.ToDictionary(g => g.Key, g => g.ToList());
// 按退卡ID分组科技部老师业绩
var kjbsyjGrouped = kjbsyjList.GroupBy(x => x.gltkbh)
.ToDictionary(g => g.Key, g => g.ToList());
// 为每个退卡记录分配品项明细、健康师业绩和科技部老师业绩
foreach (var item in data.list)
{
item.lqHytkMxList = itemDetailsGrouped.ContainsKey(item.id)
? itemDetailsGrouped[item.id]
: new List<LqHytkMxInfoOutput>();
item.lqHytkJksyjList = jksyjGrouped.ContainsKey(item.id)
? jksyjGrouped[item.id]
: new List<LqHytkJksyjInfoOutput>();
item.lqHytkKjbsyjList = kjbsyjGrouped.ContainsKey(item.id)
? kjbsyjGrouped[item.id]
: new List<LqHytkKjbsyjInfoOutput>();
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
299
|
return PageResult<LqHytkHytkListOutput>.SqlSugarPageResult(data);
|
96009bc9
hexiaodong
hxd
|
300
|
}
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
301
|
#endregion
|
96009bc9
hexiaodong
hxd
|
302
|
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
303
|
#region 创建退卡信息及其关联的品项明细、健康师业绩、科技部老师业绩信息
|
96009bc9
hexiaodong
hxd
|
304
|
/// <summary>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
305
|
/// 创建退卡信息及其关联的品项明细、健康师业绩、科技部老师业绩信息
|
96009bc9
hexiaodong
hxd
|
306
|
/// </summary>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
307
|
/// <remarks>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
308
309
310
311
312
313
314
315
316
317
|
/// 参数说明:
/// - md: 门店ID
/// - hy: 会员ID
/// - lqHytkMxList: 退卡品项明细列表
/// </remarks>
/// <param name="input">退卡创建参数</param>
/// <returns>无返回值</returns>
/// <response code="200">创建成功</response>
/// <response code="400">参数错误或数据验证失败</response>
/// <response code="500">服务器内部错误</response>
|
96009bc9
hexiaodong
hxd
|
318
319
320
321
322
323
|
[HttpPost("")]
public async Task Create([FromBody] LqHytkHytkCrInput input)
{
var userInfo = await _userManager.GetUserInfo();
var entity = input.Adapt<LqHytkHytkEntity>();
entity.Id = YitIdHelper.NextId().ToString();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
324
325
|
entity.F_CreateTime = DateTime.Now;
entity.F_CreateUser = userInfo.userId;
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
326
|
entity.IsEffective = StatusEnum.有效.GetHashCode();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
327
|
entity.Czry = userInfo.userId;
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
328
|
|
96009bc9
hexiaodong
hxd
|
329
330
|
try
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
331
|
// 开启事务
|
96009bc9
hexiaodong
hxd
|
332
|
_db.BeginTran();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
333
|
// 新增退卡主表记录
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
334
|
var newEntity = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteReturnEntityAsync();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
335
336
337
338
|
// 收集所有需要插入的实体,然后批量插入
var allMxEntities = new List<LqHytkMxEntity>();
var allJksyjEntities = new List<LqHytkJksyjEntity>();
var allKjbsyjEntities = new List<LqHytkKjbsyjEntity>();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
339
340
|
// 处理品项明细列表
if (input.lqHytkMxList != null && input.lqHytkMxList.Any())
|
96009bc9
hexiaodong
hxd
|
341
|
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
342
|
foreach (var item in input.lqHytkMxList)
|
96009bc9
hexiaodong
hxd
|
343
|
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
344
345
346
347
|
// 创建品项明细实体
var lqHytkMxEntity = new LqHytkMxEntity
{
Id = YitIdHelper.NextId().ToString(),
|
b45d55f7
“wangming”
Refactor LqEventS...
|
348
349
|
RefundInfoId = newEntity.Id,
BillingItemId = item.billingItemId,
|
bc35ccd1
“wangming”
feat: 添加退卡业务相关功能
|
350
|
MemberId = newEntity.Hy,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
351
352
|
CreateTime = DateTime.Now,
CreateUser = userInfo.userId,
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
353
354
355
356
|
Px = item.px,
Pxmc = item.pxmc,
Pxjg = item.pxjg,
Tkje = item.tkje,
|
96e0ccc7
“wangming”
优化GetBillingRecor...
|
357
|
Tksj = input.tksj,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
358
|
ProjectNumber = item.F_ProjectNumber ?? 1,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
359
360
|
SourceType = item.F_SourceType,
TotalPrice = item.F_TotalPrice ?? (item.pxjg * (item.F_ProjectNumber ?? 1)),
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
361
|
IsEffective = StatusEnum.有效.GetHashCode(),
|
14cbcfd9
“wangming”
feat: 添加人次记录表和品项分类字段
|
362
|
ItemCategory = await _db.Queryable<LqXmzlEntity>().Where(x => x.Id == item.px).Select(x => x.Qt2).FirstAsync(),
|
3f8b942f
“wangming”
feat: 添加业绩类型字段并修复...
|
363
|
PerformanceType = await _db.Queryable<LqXmzlEntity>().Where(x => x.Id == item.px).Select(x => x.Fl3).FirstAsync() ?? "",
|
ac25ff12
“wangming”
feat: 添加大项目部老师工资计...
|
364
|
BeautyType = await _db.Queryable<LqXmzlEntity>().Where(x => x.Id == item.px).Select(x => x.BeautyType).FirstAsync(),
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
365
366
|
};
allMxEntities.Add(lqHytkMxEntity);
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
367
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
368
369
370
371
372
|
// 收集该品项关联的健康师业绩
if (item.lqHytkJksyjList != null && item.lqHytkJksyjList.Any())
{
foreach (var ijks_tem in item.lqHytkJksyjList)
{
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
373
374
375
376
377
378
379
380
|
allJksyjEntities.Add(new LqHytkJksyjEntity
{
Id = YitIdHelper.NextId().ToString(),
Gltkbh = newEntity.Id,
Jks = ijks_tem.jks,
Jksxm = ijks_tem.jksxm,
Jkszh = ijks_tem.jkszh,
Jksyj = ijks_tem.jksyj,
|
96e0ccc7
“wangming”
优化GetBillingRecor...
|
381
|
Tksj = input.tksj,
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
382
383
384
385
386
387
|
F_jsjid = ijks_tem.F_jsjid,
F_tkpxid = ijks_tem.F_tkpxid,
F_LaborCost = ijks_tem.F_LaborCost,
F_tkpxNumber = ijks_tem.F_tkpxNumber,
F_CreateTime = DateTime.Now,
F_CreateUser = userInfo.userId,
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
388
389
|
CardReturn = lqHytkMxEntity.Id,
IsEffective = StatusEnum.有效.GetHashCode(),
|
8514f465
“wangming”
feat: 优化业务逻辑和功能完善
|
390
391
|
ItemCategory = lqHytkMxEntity.ItemCategory,
ItemId = lqHytkMxEntity.Px,
|
7e362a14
“wangming”
feat: 为业绩表添加门店ID和...
|
392
|
StoreId = newEntity.Md,
|
3f8b942f
“wangming”
feat: 添加业绩类型字段并修复...
|
393
|
ItemName = lqHytkMxEntity.Pxmc,
|
ac25ff12
“wangming”
feat: 添加大项目部老师工资计...
|
394
395
|
PerformanceType = lqHytkMxEntity.PerformanceType,
BeautyType = lqHytkMxEntity.BeautyType,
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
396
|
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
397
|
);
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
398
399
|
}
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
400
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
401
402
403
404
405
|
// 收集该品项关联的科技部老师业绩
if (item.lqHytkKjbsyjList != null && item.lqHytkKjbsyjList.Any())
{
foreach (var ikjbs_tem in item.lqHytkKjbsyjList)
{
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
406
407
408
409
410
411
412
413
414
|
allKjbsyjEntities.Add(
new LqHytkKjbsyjEntity
{
Id = YitIdHelper.NextId().ToString(),
Gltkbh = newEntity.Id,
Kjbls = ikjbs_tem.kjbls,
Kjblsxm = ikjbs_tem.kjblsxm,
Kjblszh = ikjbs_tem.kjblszh,
Kjblsyj = ikjbs_tem.kjblsyj,
|
96e0ccc7
“wangming”
优化GetBillingRecor...
|
415
|
Tksj = input.tksj,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
416
417
418
419
420
|
F_tkpxid = ikjbs_tem.F_tkpxid,
F_LaborCost = ikjbs_tem.F_LaborCost,
F_tkpxNumber = ikjbs_tem.F_tkpxNumber,
F_CreateTime = DateTime.Now,
F_CreateUser = userInfo.userId,
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
421
|
CardReturn = lqHytkMxEntity.Id,
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
422
|
IsEffective = StatusEnum.有效.GetHashCode(),
|
8514f465
“wangming”
feat: 优化业务逻辑和功能完善
|
423
424
|
ItemCategory = lqHytkMxEntity.ItemCategory,
ItemId = lqHytkMxEntity.Px,
|
7e362a14
“wangming”
feat: 为业绩表添加门店ID和...
|
425
|
StoreId = newEntity.Md,
|
3f8b942f
“wangming”
feat: 添加业绩类型字段并修复...
|
426
|
ItemName = lqHytkMxEntity.Pxmc,
|
ac25ff12
“wangming”
feat: 添加大项目部老师工资计...
|
427
428
|
PerformanceType = lqHytkMxEntity.PerformanceType,
BeautyType = lqHytkMxEntity.BeautyType,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
429
430
|
}
);
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
431
432
|
}
}
|
96009bc9
hexiaodong
hxd
|
433
|
}
|
96009bc9
hexiaodong
hxd
|
434
|
}
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
435
436
|
// 批量插入品项明细
if (allMxEntities.Any())
|
96009bc9
hexiaodong
hxd
|
437
|
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
438
|
await _db.Insertable(allMxEntities).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
439
|
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
440
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
441
442
|
// 批量插入健康师业绩
if (allJksyjEntities.Any())
|
96009bc9
hexiaodong
hxd
|
443
|
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
444
|
await _db.Insertable(allJksyjEntities).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
445
|
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
446
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
447
448
|
// 批量插入科技部老师业绩
if (allKjbsyjEntities.Any())
|
96009bc9
hexiaodong
hxd
|
449
|
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
450
|
await _db.Insertable(allKjbsyjEntities).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
451
|
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
452
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
453
454
455
456
457
458
459
|
// 关闭事务
_db.CommitTran();
}
catch (Exception ex)
{
_db.RollbackTran();
throw NCCException.Oh(ErrorCode.COM1005, ex.Message);
|
96009bc9
hexiaodong
hxd
|
460
461
|
}
}
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
462
|
#endregion
|
96009bc9
hexiaodong
hxd
|
463
|
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
464
|
#region 更新退卡信息及其关联的品项明细、健康师业绩、科技部老师业绩信息
|
96009bc9
hexiaodong
hxd
|
465
|
/// <summary>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
466
|
/// 更新退卡信息及其关联的品项明细、健康师业绩、科技部老师业绩信息
|
96009bc9
hexiaodong
hxd
|
467
|
/// </summary>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
468
469
470
471
472
473
474
475
476
477
|
/// <remarks>
/// 更新退卡记录及其关联的品项明细、健康师业绩、科技部老师业绩信息
/// 先删除原有的关联数据,再插入新的数据
/// </remarks>
/// <param name="id">退卡ID</param>
/// <param name="input">退卡更新参数</param>
/// <returns>无返回值</returns>
/// <response code="200">更新成功</response>
/// <response code="400">参数错误或数据验证失败</response>
/// <response code="500">服务器内部错误</response>
|
96009bc9
hexiaodong
hxd
|
478
479
480
|
[HttpPut("{id}")]
public async Task Update(string id, [FromBody] LqHytkHytkUpInput input)
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
481
|
var userInfo = await _userManager.GetUserInfo();
|
96009bc9
hexiaodong
hxd
|
482
|
var entity = input.Adapt<LqHytkHytkEntity>();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
483
484
485
|
entity.Id = id;
entity.F_ModifyTime = DateTime.Now;
entity.F_ModifyUser = userInfo.userId;
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
486
|
|
96009bc9
hexiaodong
hxd
|
487
488
|
try
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
489
|
// 开启事务
|
96009bc9
hexiaodong
hxd
|
490
|
_db.BeginTran();
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
491
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
492
493
|
// 更新退卡主表记录
await _db.Updateable(entity).IgnoreColumns(true).ExecuteCommandAsync();
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
494
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
495
|
// 删除原有的关联数据
|
b45d55f7
“wangming”
Refactor LqEventS...
|
496
|
await _db.Deleteable<LqHytkMxEntity>().Where(x => x.RefundInfoId == id).ExecuteCommandAsync();
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
497
498
|
await _db.Deleteable<LqHytkJksyjEntity>().Where(x => x.Gltkbh == id).ExecuteCommandAsync();
await _db.Deleteable<LqHytkKjbsyjEntity>().Where(x => x.Gltkbh == id).ExecuteCommandAsync();
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
499
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
500
501
502
503
|
// 收集所有需要插入的实体,然后批量插入
var allMxEntities = new List<LqHytkMxEntity>();
var allJksyjEntities = new List<LqHytkJksyjEntity>();
var allKjbsyjEntities = new List<LqHytkKjbsyjEntity>();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
504
505
|
// 处理品项明细列表
if (input.lqHytkMxList != null && input.lqHytkMxList.Any())
|
96009bc9
hexiaodong
hxd
|
506
|
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
507
|
foreach (var item in input.lqHytkMxList)
|
96009bc9
hexiaodong
hxd
|
508
|
{
|
bc35ccd1
“wangming”
feat: 添加退卡业务相关功能
|
509
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
510
511
512
513
|
// 创建品项明细实体
var lqHytkMxEntity = new LqHytkMxEntity
{
Id = YitIdHelper.NextId().ToString(),
|
b45d55f7
“wangming”
Refactor LqEventS...
|
514
515
|
RefundInfoId = id,
BillingItemId = item.billingItemId,
|
bc35ccd1
“wangming”
feat: 添加退卡业务相关功能
|
516
|
MemberId = entity.Hy,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
517
518
|
CreateTime = DateTime.Now,
CreateUser = userInfo.userId,
|
dac8767e
“wangming”
111111111
|
519
|
Tksj = input.tksj,
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
520
521
522
523
|
Px = item.px,
Pxmc = item.pxmc,
Pxjg = item.pxjg,
Tkje = item.tkje,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
524
|
ProjectNumber = item.F_ProjectNumber ?? 1,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
525
526
|
SourceType = item.F_SourceType,
TotalPrice = item.F_TotalPrice ?? (item.pxjg * (item.F_ProjectNumber ?? 1)),
|
14cbcfd9
“wangming”
feat: 添加人次记录表和品项分类字段
|
527
|
ItemCategory = await _db.Queryable<LqXmzlEntity>().Where(x => x.Id == item.px).Select(x => x.Qt2).FirstAsync(),
|
3f8b942f
“wangming”
feat: 添加业绩类型字段并修复...
|
528
|
PerformanceType = await _db.Queryable<LqXmzlEntity>().Where(x => x.Id == item.px).Select(x => x.Fl3).FirstAsync() ?? "",
|
ac25ff12
“wangming”
feat: 添加大项目部老师工资计...
|
529
|
BeautyType = await _db.Queryable<LqXmzlEntity>().Where(x => x.Id == item.px).Select(x => x.BeautyType).FirstAsync(),
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
530
531
|
};
allMxEntities.Add(lqHytkMxEntity);
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
532
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
533
534
535
536
537
|
// 收集该品项关联的健康师业绩
if (item.lqHytkJksyjList != null && item.lqHytkJksyjList.Any())
{
foreach (var ijks_tem in item.lqHytkJksyjList)
{
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
538
539
540
541
542
543
544
545
546
|
allJksyjEntities.Add(
new LqHytkJksyjEntity
{
Id = YitIdHelper.NextId().ToString(),
Gltkbh = id,
Jks = ijks_tem.jks,
Jksxm = ijks_tem.jksxm,
Jkszh = ijks_tem.jkszh,
Jksyj = ijks_tem.jksyj,
|
96e0ccc7
“wangming”
优化GetBillingRecor...
|
547
|
Tksj = input.tksj,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
548
549
550
551
552
553
|
F_jsjid = ijks_tem.F_jsjid,
F_tkpxid = ijks_tem.F_tkpxid,
F_LaborCost = ijks_tem.F_LaborCost,
F_tkpxNumber = ijks_tem.F_tkpxNumber,
F_CreateTime = DateTime.Now,
F_CreateUser = userInfo.userId,
|
8514f465
“wangming”
feat: 优化业务逻辑和功能完善
|
554
555
|
ItemCategory = lqHytkMxEntity.ItemCategory,
ItemId = lqHytkMxEntity.Px,
|
7e362a14
“wangming”
feat: 为业绩表添加门店ID和...
|
556
|
StoreId = entity.Md,
|
3f8b942f
“wangming”
feat: 添加业绩类型字段并修复...
|
557
|
ItemName = lqHytkMxEntity.Pxmc,
|
ac25ff12
“wangming”
feat: 添加大项目部老师工资计...
|
558
559
|
PerformanceType = lqHytkMxEntity.PerformanceType,
BeautyType = lqHytkMxEntity.BeautyType,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
560
561
|
}
);
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
562
563
|
}
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
564
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
565
566
567
568
569
|
// 收集该品项关联的科技部老师业绩
if (item.lqHytkKjbsyjList != null && item.lqHytkKjbsyjList.Any())
{
foreach (var ikjbs_tem in item.lqHytkKjbsyjList)
{
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
570
571
572
573
574
575
576
577
578
|
allKjbsyjEntities.Add(
new LqHytkKjbsyjEntity
{
Id = YitIdHelper.NextId().ToString(),
Gltkbh = id,
Kjbls = ikjbs_tem.kjbls,
Kjblsxm = ikjbs_tem.kjblsxm,
Kjblszh = ikjbs_tem.kjblszh,
Kjblsyj = ikjbs_tem.kjblsyj,
|
96e0ccc7
“wangming”
优化GetBillingRecor...
|
579
|
Tksj = input.tksj,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
580
581
582
583
584
|
F_tkpxid = ikjbs_tem.F_tkpxid,
F_LaborCost = ikjbs_tem.F_LaborCost,
F_tkpxNumber = ikjbs_tem.F_tkpxNumber,
F_CreateTime = DateTime.Now,
F_CreateUser = userInfo.userId,
|
8514f465
“wangming”
feat: 优化业务逻辑和功能完善
|
585
586
|
ItemCategory = lqHytkMxEntity.ItemCategory,
ItemId = lqHytkMxEntity.Px,
|
7e362a14
“wangming”
feat: 为业绩表添加门店ID和...
|
587
|
StoreId = entity.Md,
|
3f8b942f
“wangming”
feat: 添加业绩类型字段并修复...
|
588
|
ItemName = lqHytkMxEntity.Pxmc,
|
ac25ff12
“wangming”
feat: 添加大项目部老师工资计...
|
589
590
|
PerformanceType = lqHytkMxEntity.PerformanceType,
BeautyType = lqHytkMxEntity.BeautyType,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
591
592
|
}
);
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
593
594
|
}
}
|
96009bc9
hexiaodong
hxd
|
595
|
}
|
96009bc9
hexiaodong
hxd
|
596
|
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
597
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
598
599
600
601
602
|
// 批量插入品项明细
if (allMxEntities.Any())
{
await _db.Insertable(allMxEntities).ExecuteCommandAsync();
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
603
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
604
605
606
607
608
|
// 批量插入健康师业绩
if (allJksyjEntities.Any())
{
await _db.Insertable(allJksyjEntities).ExecuteCommandAsync();
}
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
609
610
611
612
613
|
// 批量插入科技部老师业绩
if (allKjbsyjEntities.Any())
{
await _db.Insertable(allKjbsyjEntities).ExecuteCommandAsync();
}
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
614
|
// 关闭事务
|
96009bc9
hexiaodong
hxd
|
615
616
|
_db.CommitTran();
}
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
617
|
catch (Exception ex)
|
96009bc9
hexiaodong
hxd
|
618
|
{
|
96009bc9
hexiaodong
hxd
|
619
|
_db.RollbackTran();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
620
|
throw NCCException.Oh(ErrorCode.COM1005, ex.Message);
|
96009bc9
hexiaodong
hxd
|
621
622
|
}
}
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
623
|
#endregion
|
96009bc9
hexiaodong
hxd
|
624
|
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
625
|
#region 作废退卡信息
|
96009bc9
hexiaodong
hxd
|
626
|
/// <summary>
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
627
|
/// 作废退卡信息
|
96009bc9
hexiaodong
hxd
|
628
|
/// </summary>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
629
|
/// <param name="id">主键</param>
|
96009bc9
hexiaodong
hxd
|
630
|
/// <returns></returns>
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
631
|
[HttpPut("VoidRefundCardInfo/{id}")]
|
fb9d5c60
“wangming”
feat: 更新LqHytkHyt...
|
632
|
public async Task<dynamic> VoidRefundCardInfo(string id, [FromQuery] string remarks = null)
|
96009bc9
hexiaodong
hxd
|
633
|
{
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
634
|
try
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
635
|
{
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
636
637
638
639
640
641
642
643
|
var entity = await _db.Queryable<LqHytkHytkEntity>().FirstAsync(p => p.Id == id && p.IsEffective == StatusEnum.有效.GetHashCode());
if (entity == null)
{
throw NCCException.Oh("退卡信息不存在或已被作废");
}
// 开启事务
_db.BeginTran();
// 更新主表
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
644
|
entity.IsEffective = StatusEnum.无效.GetHashCode();
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
645
|
entity.F_ModifyTime = DateTime.Now;
|
fb9d5c60
“wangming”
feat: 更新LqHytkHyt...
|
646
|
entity.CancelRemark = remarks;
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
647
648
|
await _db.Updateable(entity).ExecuteCommandAsync();
// 更新明细表
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
649
|
await _db.Updateable<LqHytkMxEntity>().SetColumns(it => new LqHytkMxEntity { IsEffective = StatusEnum.无效.GetHashCode() }).Where(w => w.RefundInfoId == id).ExecuteCommandAsync();
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
650
|
// 更新健康师业绩表
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
651
|
await _db.Updateable<LqHytkJksyjEntity>().SetColumns(it => new LqHytkJksyjEntity { IsEffective = StatusEnum.无效.GetHashCode() }).Where(w => w.Gltkbh == id).ExecuteCommandAsync();
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
652
|
// 更新科技部业绩表
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
653
|
await _db.Updateable<LqHytkKjbsyjEntity>().SetColumns(it => new LqHytkKjbsyjEntity { IsEffective = StatusEnum.无效.GetHashCode() }).Where(w => w.Gltkbh == id).ExecuteCommandAsync();
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
654
655
656
657
658
659
660
661
|
// 提交事务
_db.CommitTran();
return entity;
}
catch (Exception ex)
{
_db.RollbackTran();
throw NCCException.Oh($"删除退卡信息失败: {ex.Message}");
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
662
663
|
}
}
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
664
|
#endregion
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
665
|
|
dac8767e
“wangming”
111111111
|
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
|
#region 物理删除退卡信息
/// <summary>
/// 物理删除退卡信息
/// </summary>
/// <remarks>
/// 彻底删除退卡记录及其所有关联数据,包括:
/// - 退卡主表记录
/// - 退卡品项明细记录
/// - 退卡健康师业绩记录
/// - 退卡科技部老师业绩记录
///
/// 注意:此操作不可逆,请谨慎使用
/// </remarks>
/// <param name="id">退卡记录主键ID</param>
/// <returns>删除结果</returns>
/// <response code="200">删除成功</response>
/// <response code="404">退卡记录不存在</response>
/// <response code="500">服务器内部错误</response>
[HttpDelete("physical/{id}")]
public async Task<dynamic> PhysicalDelete(string id)
{
try
{
// 检查退卡记录是否存在
var entity = await _db.Queryable<LqHytkHytkEntity>().FirstAsync(p => p.Id == id);
if (entity == null)
{
throw NCCException.Oh("退卡记录不存在");
}
// 开启事务
_db.BeginTran();
// 1. 删除退卡品项明细记录
|
ce74473f
“wangming”
feat: 新增门店类别枚举和耗卡...
|
700
|
await _db.Deleteable<LqHytkMxEntity>().Where(x => x.RefundInfoId == id).ExecuteCommandAsync();
|
dac8767e
“wangming”
111111111
|
701
702
|
// 2. 删除退卡健康师业绩记录
|
ce74473f
“wangming”
feat: 新增门店类别枚举和耗卡...
|
703
|
await _db.Deleteable<LqHytkJksyjEntity>().Where(x => x.Gltkbh == id).ExecuteCommandAsync();
|
dac8767e
“wangming”
111111111
|
704
705
|
// 3. 删除退卡科技部老师业绩记录
|
ce74473f
“wangming”
feat: 新增门店类别枚举和耗卡...
|
706
|
await _db.Deleteable<LqHytkKjbsyjEntity>().Where(x => x.Gltkbh == id).ExecuteCommandAsync();
|
dac8767e
“wangming”
111111111
|
707
708
|
// 4. 删除退卡主表记录
|
ce74473f
“wangming”
feat: 新增门店类别枚举和耗卡...
|
709
|
await _db.Deleteable<LqHytkHytkEntity>().Where(x => x.Id == id).ExecuteCommandAsync();
|
dac8767e
“wangming”
111111111
|
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
|
// 提交事务
_db.CommitTran();
return new
{
success = true,
message = "退卡记录已彻底删除",
deletedId = id,
deletedTime = DateTime.Now
};
}
catch (Exception ex)
{
// 回滚事务
_db.RollbackTran();
throw NCCException.Oh($"物理删除退卡记录失败: {ex.Message}");
}
}
#endregion
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
731
|
#region 获取退卡信息详情
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
732
733
734
735
736
737
|
/// <summary>
/// 获取退卡信息详情
/// </summary>
/// <remarks>
/// 获取退卡记录及其关联的品项明细、健康师业绩、科技部老师业绩信息
/// 按照退卡的完整格式返回数据,不包含汇总信息
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
738
|
///
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
739
740
741
742
743
744
745
746
747
748
749
750
751
752
|
/// 返回数据结构:
/// - 主表信息:退卡基础信息、门店信息、会员信息、退卡金额等
/// - 品项明细列表:每个品项包含完整的项目信息(项目次数、是否有效、来源类型等)
/// - 健康师业绩列表:按品项关联的健康师业绩信息
/// - 科技部老师业绩列表:按品项关联的科技部老师业绩信息
/// </remarks>
/// <param name="id">退卡记录主键ID</param>
/// <returns>退卡记录完整信息</returns>
/// <response code="200">查询成功</response>
/// <response code="404">退卡记录不存在</response>
/// <response code="500">服务器内部错误</response>
[HttpGet("{id}")]
public async Task<dynamic> GetInfo(string id)
{
|
96009bc9
hexiaodong
hxd
|
753
754
|
try
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
755
|
// 1. 查询主表信息
|
fb9d5c60
“wangming”
feat: 更新LqHytkHyt...
|
756
|
var entity = await _db.Queryable<LqHytkHytkEntity>().Where(p => p.Id == id).FirstAsync();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
757
758
|
if (entity == null)
{
|
fb9d5c60
“wangming”
feat: 更新LqHytkHyt...
|
759
|
throw NCCException.Oh("退卡记录不存在");
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
760
|
}
|
96009bc9
hexiaodong
hxd
|
761
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
762
763
764
|
var output = entity.Adapt<LqHytkHytkInfoOutput>();
// 2. 查询品项明细列表
|
b45d55f7
“wangming”
Refactor LqEventS...
|
765
|
var lqHytkMxList = await _db.Queryable<LqHytkMxEntity>().Where(w => w.RefundInfoId == entity.Id).ToListAsync();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
766
767
|
// 3. 查询健康师业绩列表
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
768
|
var lqHytkJksyjList = await _db.Queryable<LqHytkJksyjEntity>().Where(w => w.Gltkbh == entity.Id).ToListAsync();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
769
770
|
// 4. 查询科技部老师业绩列表
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
771
|
var lqHytkKjbsyjList = await _db.Queryable<LqHytkKjbsyjEntity>().Where(w => w.Gltkbh == entity.Id).ToListAsync();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
772
773
774
775
776
777
778
779
|
// 5. 构建品项明细输出,每个品项关联对应的业绩信息
var mxOutputList = new List<LqHytkMxInfoOutput>();
foreach (var mx in lqHytkMxList)
{
var mxOutput = new LqHytkMxInfoOutput
{
id = mx.Id,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
780
781
|
refundInfoId = mx.RefundInfoId,
billingItemId = mx.BillingItemId,
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
782
783
784
785
|
px = mx.Px,
pxmc = mx.Pxmc,
pxjg = mx.Pxjg,
tkje = mx.Tkje,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
786
|
projectNumber = mx.ProjectNumber,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
787
788
|
sourceType = mx.SourceType,
totalPrice = mx.TotalPrice,
|
fb9d5c60
“wangming”
feat: 更新LqHytkHyt...
|
789
|
isEffective = mx.IsEffective,
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
790
791
792
|
};
// 关联该品项的健康师业绩
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
793
|
var jksyjForMx = lqHytkJksyjList.Where(j => j.CardReturn == mx.Id).ToList();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
794
795
796
|
mxOutput.lqHytkJksyjList = jksyjForMx.Adapt<List<LqHytkJksyjInfoOutput>>();
// 关联该品项的科技部老师业绩
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
797
|
var kjbsyjForMx = lqHytkKjbsyjList.Where(k => k.CardReturn == mx.Id).ToList();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
798
799
800
801
802
803
804
805
806
807
808
809
810
|
mxOutput.lqHytkKjbsyjList = kjbsyjForMx.Adapt<List<LqHytkKjbsyjInfoOutput>>();
mxOutputList.Add(mxOutput);
}
// 6. 设置输出结果
output.lqHytkMxList = mxOutputList;
// 7. 设置全局业绩列表(用于兼容性,但主要使用品项关联的业绩)
output.lqHytkJksyjList = lqHytkJksyjList.Adapt<List<LqHytkJksyjInfoOutput>>();
output.lqHytkKjbsyjList = lqHytkKjbsyjList.Adapt<List<LqHytkKjbsyjInfoOutput>>();
return output;
|
96009bc9
hexiaodong
hxd
|
811
|
}
|
fb9d5c60
“wangming”
feat: 更新LqHytkHyt...
|
812
|
catch (Exception ex)
|
96009bc9
hexiaodong
hxd
|
813
|
{
|
fb9d5c60
“wangming”
feat: 更新LqHytkHyt...
|
814
|
throw NCCException.Oh($"获取退卡记录详情失败: {ex.Message}");
|
96009bc9
hexiaodong
hxd
|
815
816
|
}
}
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
817
|
#endregion
|
d64f9fbd
“wangming”
feat: 添加退卡明细查询和导出功能
|
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
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
|
#region 退卡明细查询
/// <summary>
/// 获取退卡明细列表
/// </summary>
/// <remarks>
/// 获取退卡明细列表,支持多门店、会员、时间范围、品项、业绩类型、科美类型、来源类型、品项分类等筛选
///
/// 示例请求:
/// ```json
/// GET /api/Extend/LqHytkHytk/refund-detail-list?storeIds=门店ID1,门店ID2&memberId=会员ID&startTime=2025-01-01&endTime=2025-12-31&currentPage=1&pageSize=20
/// ```
///
/// 参数说明:
/// - storeIds: 门店ID列表(可选,多门店筛选)
/// - memberId: 会员ID(可选)
/// - startTime: 开始时间(可选,时间范围筛选)
/// - endTime: 结束时间(可选,时间范围筛选)
/// - itemId: 品项ID(可选)
/// - performanceType: 业绩类型(可选)
/// - beautyType: 科美类型(可选)
/// - sourceType: 来源类型(可选)
/// - itemCategory: 品项分类(可选)
/// - currentPage: 当前页码(必填)
/// - pageSize: 每页数量(必填)
/// </remarks>
/// <param name="input">查询参数</param>
/// <returns>分页的退卡明细列表</returns>
/// <response code="200">成功返回退卡明细列表</response>
/// <response code="400">参数错误</response>
/// <response code="500">服务器内部错误</response>
[HttpPost("refund-detail-list")]
public async Task<dynamic> GetRefundDetailList([FromBody] RefundDetailListQueryInput input)
{
try
{
if (input == null)
{
throw NCCException.Oh("参数不能为空");
}
// 1. 先查询退卡明细表
var mxQuery = _db.Queryable<LqHytkMxEntity>()
.Where(mx => mx.IsEffective == StatusEnum.有效.GetHashCode())
.WhereIF(!string.IsNullOrEmpty(input.itemId), mx => mx.Px == input.itemId)
.WhereIF(!string.IsNullOrEmpty(input.performanceType), mx => mx.PerformanceType == input.performanceType)
.WhereIF(!string.IsNullOrEmpty(input.beautyType), mx => mx.BeautyType == input.beautyType)
.WhereIF(!string.IsNullOrEmpty(input.sourceType), mx => mx.SourceType == input.sourceType)
.WhereIF(!string.IsNullOrEmpty(input.itemCategory), mx => mx.ItemCategory == input.itemCategory)
.WhereIF(input.startTime.HasValue, mx => mx.Tksj.HasValue && mx.Tksj >= input.startTime.Value)
.WhereIF(input.endTime.HasValue, mx => mx.Tksj.HasValue && mx.Tksj <= input.endTime.Value);
var mxList = await mxQuery.ToListAsync();
if (!mxList.Any())
{
return PageResult<RefundDetailListOutput>.SqlSugarPageResult(new SqlSugarPagedList<RefundDetailListOutput>());
}
// 2. 批量查询退卡信息表
var refundInfoIds = mxList.Select(x => x.RefundInfoId).Where(x => !string.IsNullOrEmpty(x)).Distinct().ToList();
var refundInfoList = new List<LqHytkHytkEntity>();
if (refundInfoIds.Any())
{
refundInfoList = await _db.Queryable<LqHytkHytkEntity>()
.Where(x => refundInfoIds.Contains(x.Id))
.WhereIF(input.storeIds != null && input.storeIds.Any(), x => input.storeIds.Contains(x.Md))
.WhereIF(!string.IsNullOrEmpty(input.memberId), x => x.Hy == input.memberId)
.WhereIF(input.startTime.HasValue && !mxList.Any(m => m.Tksj.HasValue), x => x.Tksj.HasValue && x.Tksj >= input.startTime.Value)
.WhereIF(input.endTime.HasValue && !mxList.Any(m => m.Tksj.HasValue), x => x.Tksj.HasValue && x.Tksj <= input.endTime.Value)
.ToListAsync();
}
var refundInfoDict = refundInfoList.ToDictionary(x => x.Id, x => x);
// 3. 批量查询门店信息
var storeIds = refundInfoList.Select(x => x.Md).Where(x => !string.IsNullOrEmpty(x)).Distinct().ToList();
var storeDict = new Dictionary<string, string>();
if (storeIds.Any())
{
var stores = await _db.Queryable<LqMdxxEntity>()
.Where(x => storeIds.Contains(x.Id))
.Select(x => new { x.Id, x.Dm })
.ToListAsync();
storeDict = stores.ToDictionary(x => x.Id, x => x.Dm ?? "");
}
// 4. 批量查询会员信息
var memberIds = mxList.Select(x => x.MemberId).Where(x => !string.IsNullOrEmpty(x))
.Concat(refundInfoList.Select(x => x.Hy).Where(x => !string.IsNullOrEmpty(x)))
.Distinct().ToList();
var memberDict = new Dictionary<string, string>();
if (memberIds.Any())
{
var members = await _db.Queryable<LqKhxxEntity>()
.Where(x => memberIds.Contains(x.Id))
.Select(x => new { x.Id, x.Sjh })
.ToListAsync();
memberDict = members.ToDictionary(x => x.Id, x => x.Sjh ?? "");
}
|
77631543
“wangming”
优化门店驾驶舱页面布局并添加退款明...
|
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
|
// 5. 批量查询健康师业绩信息
var billingItemIds = mxList.Select(x => x.BillingItemId).Where(x => !string.IsNullOrEmpty(x)).Distinct().ToList();
var healthCoachDict = new Dictionary<string, (string Id, string Name, decimal Performance)>();
if (billingItemIds.Any())
{
// 通过开单品项明细ID查询开单品项明细,获取开单编号和品项明细ID
var pxmxList = await _db.Queryable<LqKdPxmxEntity>()
.Where(x => billingItemIds.Contains(x.Id))
.Select(x => new { x.Id, x.Glkdbh })
.ToListAsync();
if (pxmxList.Any())
{
var glkdbhList = pxmxList.Select(x => x.Glkdbh).Where(x => !string.IsNullOrEmpty(x)).Distinct().ToList();
var pxmxIdList = pxmxList.Select(x => x.Id).Distinct().ToList();
// 通过开单编号和品项明细ID查询健康师业绩
var jksyjList = await _db.Queryable<LqKdJksyjEntity>()
.Where(x => glkdbhList.Contains(x.Glkdbh) && pxmxIdList.Contains(x.Kdpxid) && x.IsEffective == 1)
.Select(x => new { x.Glkdbh, x.Kdpxid, x.Jkszh, x.Jksxm, x.Jksyj })
.ToListAsync();
// 建立开单品项明细ID到健康师信息的映射
foreach (var jksyj in jksyjList)
{
// 找到对应的开单品项明细ID
var pxmxId = pxmxList.FirstOrDefault(x => x.Glkdbh == jksyj.Glkdbh && x.Id == jksyj.Kdpxid)?.Id;
if (!string.IsNullOrEmpty(pxmxId))
{
var jksyjValue = decimal.TryParse(jksyj.Jksyj, out var perf) ? perf : 0;
healthCoachDict[pxmxId] = (jksyj.Jkszh ?? "", jksyj.Jksxm ?? "", jksyjValue);
}
}
}
}
// 6. 组装数据
|
d64f9fbd
“wangming”
feat: 添加退卡明细查询和导出功能
|
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
|
var resultList = new List<RefundDetailListOutput>();
foreach (var mx in mxList)
{
var refundInfo = refundInfoDict.ContainsKey(mx.RefundInfoId) ? refundInfoDict[mx.RefundInfoId] : null;
// 应用筛选条件
if (input.storeIds != null && input.storeIds.Any())
{
if (refundInfo == null || !input.storeIds.Contains(refundInfo.Md))
continue;
}
if (!string.IsNullOrEmpty(input.memberId))
{
if (mx.MemberId != input.memberId && (refundInfo == null || refundInfo.Hy != input.memberId))
continue;
}
var memberId = mx.MemberId ?? (refundInfo?.Hy);
var refundTime = mx.Tksj ?? refundInfo?.Tksj;
|
77631543
“wangming”
优化门店驾驶舱页面布局并添加退款明...
|
976
977
978
979
980
|
// 获取健康师信息
var healthCoachInfo = !string.IsNullOrEmpty(mx.BillingItemId) && healthCoachDict.ContainsKey(mx.BillingItemId)
? healthCoachDict[mx.BillingItemId]
: (Id: "", Name: "", Performance: 0m);
|
d64f9fbd
“wangming”
feat: 添加退卡明细查询和导出功能
|
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
|
resultList.Add(new RefundDetailListOutput
{
storeId = refundInfo?.Md,
storeName = refundInfo != null && storeDict.ContainsKey(refundInfo.Md) ? storeDict[refundInfo.Md] : "",
memberId = memberId,
memberName = refundInfo?.Hymc,
memberPhone = !string.IsNullOrEmpty(memberId) && memberDict.ContainsKey(memberId) ? memberDict[memberId] : "",
refundTime = refundTime,
itemId = mx.Px,
itemName = mx.Pxmc,
refundQuantity = mx.ProjectNumber,
unitPrice = mx.Pxjg ?? 0,
totalPrice = mx.Tkje ?? mx.TotalPrice ?? 0,
performanceType = mx.PerformanceType,
beautyType = mx.BeautyType,
sourceType = mx.SourceType,
|
77631543
“wangming”
优化门店驾驶舱页面布局并添加退款明...
|
997
998
999
1000
|
itemCategory = mx.ItemCategory,
healthCoachId = healthCoachInfo.Id,
healthCoachName = healthCoachInfo.Name,
healthCoachPerformance = healthCoachInfo.Performance
|
d64f9fbd
“wangming”
feat: 添加退卡明细查询和导出功能
|
1001
1002
1003
|
});
}
|
77631543
“wangming”
优化门店驾驶舱页面布局并添加退款明...
|
1004
|
// 7. 排序
|
d64f9fbd
“wangming”
feat: 添加退卡明细查询和导出功能
|
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
|
var sidx = string.IsNullOrEmpty(input.sidx) ? "refundTime" : input.sidx;
var sort = string.IsNullOrEmpty(input.sort) ? "desc" : input.sort;
if (sort.ToLower() == "desc")
{
resultList = resultList.OrderByDescending(x => GetPropertyValue(x, sidx)).ToList();
}
else
{
resultList = resultList.OrderBy(x => GetPropertyValue(x, sidx)).ToList();
}
|
77631543
“wangming”
优化门店驾驶舱页面布局并添加退款明...
|
1017
|
// 8. 分页
|
d64f9fbd
“wangming”
feat: 添加退卡明细查询和导出功能
|
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
|
var total = resultList.Count;
var skip = (input.currentPage - 1) * input.pageSize;
var pagedList = resultList.Skip(skip).Take(input.pageSize).ToList();
var pageList = new SqlSugarPagedList<RefundDetailListOutput>
{
list = pagedList,
pagination = new PagedModel
{
PageIndex = input.currentPage,
PageSize = input.pageSize,
Total = total
}
};
return PageResult<RefundDetailListOutput>.SqlSugarPageResult(pageList);
}
catch (Exception ex)
{
throw NCCException.Oh($"获取退卡明细列表失败: {ex.Message}");
}
}
private object GetPropertyValue(RefundDetailListOutput obj, string propertyName)
{
var prop = typeof(RefundDetailListOutput).GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
return prop?.GetValue(obj) ?? "";
}
/// <summary>
/// 获取退卡明细列表(无分页,用于导出)
/// </summary>
/// <param name="input">查询参数</param>
/// <returns>退卡明细列表</returns>
[NonAction]
public async Task<List<RefundDetailListOutput>> GetRefundDetailListNoPaging(RefundDetailListQueryInput input)
{
try
{
// 1. 先查询退卡明细表
var mxQuery = _db.Queryable<LqHytkMxEntity>()
.Where(mx => mx.IsEffective == StatusEnum.有效.GetHashCode())
.WhereIF(!string.IsNullOrEmpty(input.itemId), mx => mx.Px == input.itemId)
.WhereIF(!string.IsNullOrEmpty(input.performanceType), mx => mx.PerformanceType == input.performanceType)
.WhereIF(!string.IsNullOrEmpty(input.beautyType), mx => mx.BeautyType == input.beautyType)
.WhereIF(!string.IsNullOrEmpty(input.sourceType), mx => mx.SourceType == input.sourceType)
.WhereIF(!string.IsNullOrEmpty(input.itemCategory), mx => mx.ItemCategory == input.itemCategory)
.WhereIF(input.startTime.HasValue, mx => mx.Tksj.HasValue && mx.Tksj >= input.startTime.Value)
.WhereIF(input.endTime.HasValue, mx => mx.Tksj.HasValue && mx.Tksj <= input.endTime.Value);
var mxList = await mxQuery.ToListAsync();
if (!mxList.Any())
{
return new List<RefundDetailListOutput>();
}
// 2. 批量查询退卡信息表
var refundInfoIds = mxList.Select(x => x.RefundInfoId).Where(x => !string.IsNullOrEmpty(x)).Distinct().ToList();
var refundInfoList = new List<LqHytkHytkEntity>();
if (refundInfoIds.Any())
{
refundInfoList = await _db.Queryable<LqHytkHytkEntity>()
.Where(x => refundInfoIds.Contains(x.Id))
.WhereIF(input.storeIds != null && input.storeIds.Any(), x => input.storeIds.Contains(x.Md))
.WhereIF(!string.IsNullOrEmpty(input.memberId), x => x.Hy == input.memberId)
.WhereIF(input.startTime.HasValue && !mxList.Any(m => m.Tksj.HasValue), x => x.Tksj.HasValue && x.Tksj >= input.startTime.Value)
.WhereIF(input.endTime.HasValue && !mxList.Any(m => m.Tksj.HasValue), x => x.Tksj.HasValue && x.Tksj <= input.endTime.Value)
.ToListAsync();
}
var refundInfoDict = refundInfoList.ToDictionary(x => x.Id, x => x);
// 3. 批量查询门店信息
var storeIds = refundInfoList.Select(x => x.Md).Where(x => !string.IsNullOrEmpty(x)).Distinct().ToList();
var storeDict = new Dictionary<string, string>();
if (storeIds.Any())
{
var stores = await _db.Queryable<LqMdxxEntity>()
.Where(x => storeIds.Contains(x.Id))
.Select(x => new { x.Id, x.Dm })
.ToListAsync();
storeDict = stores.ToDictionary(x => x.Id, x => x.Dm ?? "");
}
// 4. 批量查询会员信息
var memberIds = mxList.Select(x => x.MemberId).Where(x => !string.IsNullOrEmpty(x))
.Concat(refundInfoList.Select(x => x.Hy).Where(x => !string.IsNullOrEmpty(x)))
.Distinct().ToList();
var memberDict = new Dictionary<string, string>();
if (memberIds.Any())
{
var members = await _db.Queryable<LqKhxxEntity>()
.Where(x => memberIds.Contains(x.Id))
.Select(x => new { x.Id, x.Sjh })
.ToListAsync();
memberDict = members.ToDictionary(x => x.Id, x => x.Sjh ?? "");
}
|
77631543
“wangming”
优化门店驾驶舱页面布局并添加退款明...
|
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
|
// 5. 批量查询健康师业绩信息
var billingItemIds = mxList.Select(x => x.BillingItemId).Where(x => !string.IsNullOrEmpty(x)).Distinct().ToList();
var healthCoachDict = new Dictionary<string, (string Id, string Name, decimal Performance)>();
if (billingItemIds.Any())
{
// 通过开单品项明细ID查询开单品项明细,获取开单编号和品项明细ID
var pxmxList = await _db.Queryable<LqKdPxmxEntity>()
.Where(x => billingItemIds.Contains(x.Id))
.Select(x => new { x.Id, x.Glkdbh })
.ToListAsync();
if (pxmxList.Any())
{
var glkdbhList = pxmxList.Select(x => x.Glkdbh).Where(x => !string.IsNullOrEmpty(x)).Distinct().ToList();
var pxmxIdList = pxmxList.Select(x => x.Id).Distinct().ToList();
// 通过开单编号和品项明细ID查询健康师业绩
var jksyjList = await _db.Queryable<LqKdJksyjEntity>()
.Where(x => glkdbhList.Contains(x.Glkdbh) && pxmxIdList.Contains(x.Kdpxid) && x.IsEffective == 1)
.Select(x => new { x.Glkdbh, x.Kdpxid, x.Jkszh, x.Jksxm, x.Jksyj })
.ToListAsync();
// 建立开单品项明细ID到健康师信息的映射
foreach (var jksyj in jksyjList)
{
// 找到对应的开单品项明细ID
var pxmxId = pxmxList.FirstOrDefault(x => x.Glkdbh == jksyj.Glkdbh && x.Id == jksyj.Kdpxid)?.Id;
if (!string.IsNullOrEmpty(pxmxId))
{
var jksyjValue = decimal.TryParse(jksyj.Jksyj, out var perf) ? perf : 0;
healthCoachDict[pxmxId] = (jksyj.Jkszh ?? "", jksyj.Jksxm ?? "", jksyjValue);
}
}
}
}
// 6. 组装数据
|
d64f9fbd
“wangming”
feat: 添加退卡明细查询和导出功能
|
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
|
var resultList = new List<RefundDetailListOutput>();
foreach (var mx in mxList)
{
var refundInfo = refundInfoDict.ContainsKey(mx.RefundInfoId) ? refundInfoDict[mx.RefundInfoId] : null;
// 应用筛选条件
if (input.storeIds != null && input.storeIds.Any())
{
if (refundInfo == null || !input.storeIds.Contains(refundInfo.Md))
continue;
}
if (!string.IsNullOrEmpty(input.memberId))
{
if (mx.MemberId != input.memberId && (refundInfo == null || refundInfo.Hy != input.memberId))
continue;
}
var memberId = mx.MemberId ?? (refundInfo?.Hy);
var refundTime = mx.Tksj ?? refundInfo?.Tksj;
|
77631543
“wangming”
优化门店驾驶舱页面布局并添加退款明...
|
1174
1175
1176
1177
1178
|
// 获取健康师信息
var healthCoachInfo = !string.IsNullOrEmpty(mx.BillingItemId) && healthCoachDict.ContainsKey(mx.BillingItemId)
? healthCoachDict[mx.BillingItemId]
: (Id: "", Name: "", Performance: 0m);
|
d64f9fbd
“wangming”
feat: 添加退卡明细查询和导出功能
|
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
|
resultList.Add(new RefundDetailListOutput
{
storeId = refundInfo?.Md,
storeName = refundInfo != null && storeDict.ContainsKey(refundInfo.Md) ? storeDict[refundInfo.Md] : "",
memberId = memberId,
memberName = refundInfo?.Hymc,
memberPhone = !string.IsNullOrEmpty(memberId) && memberDict.ContainsKey(memberId) ? memberDict[memberId] : "",
refundTime = refundTime,
itemId = mx.Px,
itemName = mx.Pxmc,
refundQuantity = mx.ProjectNumber,
unitPrice = mx.Pxjg ?? 0,
totalPrice = mx.Tkje ?? mx.TotalPrice ?? 0,
performanceType = mx.PerformanceType,
beautyType = mx.BeautyType,
sourceType = mx.SourceType,
|
77631543
“wangming”
优化门店驾驶舱页面布局并添加退款明...
|
1195
1196
1197
1198
|
itemCategory = mx.ItemCategory,
healthCoachId = healthCoachInfo.Id,
healthCoachName = healthCoachInfo.Name,
healthCoachPerformance = healthCoachInfo.Performance
|
d64f9fbd
“wangming”
feat: 添加退卡明细查询和导出功能
|
1199
1200
1201
|
});
}
|
77631543
“wangming”
优化门店驾驶舱页面布局并添加退款明...
|
1202
|
// 7. 排序
|
d64f9fbd
“wangming”
feat: 添加退卡明细查询和导出功能
|
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
|
var sidx = string.IsNullOrEmpty(input.sidx) ? "refundTime" : input.sidx;
var sort = string.IsNullOrEmpty(input.sort) ? "desc" : input.sort;
if (sort.ToLower() == "desc")
{
resultList = resultList.OrderByDescending(x => GetPropertyValue(x, sidx)).ToList();
}
else
{
resultList = resultList.OrderBy(x => GetPropertyValue(x, sidx)).ToList();
}
return resultList;
}
catch (Exception ex)
{
throw NCCException.Oh($"获取退卡明细列表失败: {ex.Message}");
}
}
#endregion
#region 退卡明细导出
/// <summary>
/// 导出退卡明细
/// </summary>
/// <remarks>
/// 导出退卡明细到Excel,支持多门店、会员、时间范围、品项、业绩类型、科美类型、来源类型、品项分类等筛选
///
/// 示例请求:
/// ```json
/// POST /api/Extend/LqHytkHytk/refund-detail-export
/// {
/// "storeIds": ["门店ID1", "门店ID2"],
/// "memberId": "会员ID",
/// "startTime": "2025-01-01T00:00:00",
/// "endTime": "2025-12-31T23:59:59",
/// "itemId": "品项ID",
/// "performanceType": "业绩类型",
/// "beautyType": "科美类型",
/// "sourceType": "来源类型",
/// "itemCategory": "品项分类"
/// }
/// ```
/// </remarks>
/// <param name="input">查询参数</param>
/// <returns>Excel文件下载信息</returns>
/// <response code="200">成功返回Excel文件下载链接</response>
/// <response code="400">参数错误</response>
/// <response code="500">服务器内部错误</response>
[HttpPost("refund-detail-export")]
public async Task<dynamic> ExportRefundDetail([FromBody] RefundDetailListQueryInput input)
{
try
{
var userInfo = await _userManager.GetUserInfo();
var exportData = await GetRefundDetailListNoPaging(input);
if (exportData == null || !exportData.Any())
{
return new { name = "退卡明细.xls", url = "", message = "没有找到符合条件的数据" };
}
// 定义导出字段
List<ParamsModel> paramList =
"[{\"value\":\"门店\",\"field\":\"storeName\"},{\"value\":\"会员ID\",\"field\":\"memberId\"},{\"value\":\"会员名称\",\"field\":\"memberName\"},{\"value\":\"会员电话\",\"field\":\"memberPhone\"},{\"value\":\"退卡时间\",\"field\":\"refundTime\"},{\"value\":\"退卡品项ID\",\"field\":\"itemId\"},{\"value\":\"退卡品项名称\",\"field\":\"itemName\"},{\"value\":\"退卡数量\",\"field\":\"refundQuantity\"},{\"value\":\"单价\",\"field\":\"unitPrice\"},{\"value\":\"总价\",\"field\":\"totalPrice\"},{\"value\":\"业绩类型\",\"field\":\"performanceType\"},{\"value\":\"科美类型\",\"field\":\"beautyType\"},{\"value\":\"来源类型\",\"field\":\"sourceType\"},{\"value\":\"品项分类\",\"field\":\"itemCategory\"},]".ToList<ParamsModel>();
ExcelConfig excelconfig = new ExcelConfig();
excelconfig.FileName = "退卡明细_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
excelconfig.HeadFont = "微软雅黑";
excelconfig.HeadPoint = 10;
excelconfig.IsAllSizeColumn = true;
excelconfig.ColumnModel = new List<ExcelColumnModel>();
// 添加所有字段到导出列
foreach (var param in paramList)
{
excelconfig.ColumnModel.Add(new ExcelColumnModel() { Column = param.field, ExcelColumn = param.value });
}
// 查找项目根目录
var baseDir = AppContext.BaseDirectory;
var projectRoot = baseDir;
var dir = new DirectoryInfo(baseDir);
// 优先查找包含 .git 目录的目录(真正的项目根目录)
while (dir != null && dir.Parent != null)
{
try
{
if (dir.GetDirectories(".git").Any())
{
projectRoot = dir.FullName;
break;
}
}
catch
{
// 忽略访问错误,继续向上查找
}
dir = dir.Parent;
}
// 如果没找到 .git 目录,再查找包含 .sln 文件的目录
if (projectRoot == baseDir)
{
dir = new DirectoryInfo(baseDir);
while (dir != null && dir.Parent != null)
{
try
{
if (dir.GetFiles("*.sln").Any())
{
projectRoot = dir.FullName;
break;
}
}
catch
{
// 忽略访问错误,继续向上查找
}
dir = dir.Parent;
}
}
// 在项目根目录下创建 ExportFiles 文件夹
var exportFilesPath = Path.Combine(projectRoot, "ExportFiles");
if (!Directory.Exists(exportFilesPath))
{
Directory.CreateDirectory(exportFilesPath);
}
var addPath = Path.Combine(exportFilesPath, excelconfig.FileName);
ExcelExportHelper<RefundDetailListOutput>.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;
}
catch (Exception ex)
{
throw NCCException.Oh($"导出退卡明细失败: {ex.Message}");
}
}
#endregion
|
96009bc9
hexiaodong
hxd
|
1346
1347
|
}
}
|