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;
|
14cbcfd9
“wangming”
feat: 添加人次记录表和品项分类字段
|
30
|
using NCC.Extend.Entitys.lq_xmzl;
|
d64f9fbd
“wangming”
feat: 添加退卡明细查询和导出功能
|
31
32
|
using NCC.Extend.Entitys.lq_khxx;
using NCC.Extend.Entitys.lq_mdxx;
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
33
34
|
using NCC.Extend.Interfaces.LqHytkHytk;
using NCC.FriendlyException;
|
96009bc9
hexiaodong
hxd
|
35
|
using NCC.JsonSerialization;
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
36
37
|
using SqlSugar;
using Yitter.IdGenerator;
|
96009bc9
hexiaodong
hxd
|
38
39
40
41
|
namespace NCC.Extend.LqHytkHytk
{
/// <summary>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
42
|
/// 退卡_信息表服务
|
96009bc9
hexiaodong
hxd
|
43
|
/// </summary>
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
44
|
[ApiDescriptionSettings(Tag = "绿纤退卡信息表服务", Name = "LqHytkHytk", Order = 200)]
|
96009bc9
hexiaodong
hxd
|
45
46
47
48
49
|
[Route("api/Extend/[controller]")]
public class LqHytkHytkService : ILqHytkHytkService, IDynamicApiController, ITransient
{
private readonly ISqlSugarRepository<LqHytkHytkEntity> _lqHytkHytkRepository;
private readonly ISqlSugarRepository<LqHytkMxEntity> _lqHytkMxRepository;
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
50
51
|
private readonly ISqlSugarRepository<LqHytkJksyjEntity> _lqHytkJksyjRepository;
private readonly ISqlSugarRepository<LqHytkKjbsyjEntity> _lqHytkKjbsyjRepository;
|
96009bc9
hexiaodong
hxd
|
52
53
54
55
56
57
58
59
60
|
private readonly SqlSugarScope _db;
private readonly IUserManager _userManager;
/// <summary>
/// 初始化一个<see cref="LqHytkHytkService"/>类型的新实例
/// </summary>
public LqHytkHytkService(
ISqlSugarRepository<LqHytkHytkEntity> lqHytkHytkRepository,
ISqlSugarRepository<LqHytkMxEntity> lqHytkMxRepository,
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
61
62
|
ISqlSugarRepository<LqHytkJksyjEntity> lqHytkJksyjRepository,
ISqlSugarRepository<LqHytkKjbsyjEntity> lqHytkKjbsyjRepository,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
63
64
|
IUserManager userManager
)
|
96009bc9
hexiaodong
hxd
|
65
|
{
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
66
|
_lqHytkHytkRepository = lqHytkHytkRepository;
|
96009bc9
hexiaodong
hxd
|
67
|
_lqHytkMxRepository = lqHytkMxRepository;
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
68
69
70
|
_lqHytkJksyjRepository = lqHytkJksyjRepository;
_lqHytkKjbsyjRepository = lqHytkKjbsyjRepository;
_db = _lqHytkHytkRepository.Context;
|
96009bc9
hexiaodong
hxd
|
71
72
73
|
_userManager = userManager;
}
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
74
|
#region 获取退卡信息列表
|
96009bc9
hexiaodong
hxd
|
75
|
/// <summary>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
76
|
/// 获取退卡信息列表
|
96009bc9
hexiaodong
hxd
|
77
|
/// </summary>
|
a78c0ae8
“wangming”
feat: 退卡服务添加健康师和科...
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/// <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”
更新退卡相关功能,重构退卡信息表及...
|
102
|
/// <param name="input">查询参数</param>
|
a78c0ae8
“wangming”
feat: 退卡服务添加健康师和科...
|
103
104
105
106
|
/// <returns>分页的退卡记录列表,包含退卡基本信息、品项明细、健康师业绩、科技部老师业绩</returns>
/// <response code="200">成功返回退卡列表</response>
/// <response code="400">参数错误</response>
/// <response code="500">服务器内部错误</response>
|
96009bc9
hexiaodong
hxd
|
107
108
109
110
|
[HttpGet("")]
public async Task<dynamic> GetList([FromQuery] LqHytkHytkListQueryInput input)
{
var sidx = input.sidx == null ? "id" : input.sidx;
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
111
|
List<string> queryTksj = input.tksj != null ? input.tksj.Split(',').ToObeject<List<string>>() : null;
|
96009bc9
hexiaodong
hxd
|
112
113
|
DateTime? startTksj = queryTksj != null ? Ext.GetDateTime(queryTksj.First()) : null;
DateTime? endTksj = queryTksj != null ? Ext.GetDateTime(queryTksj.Last()) : null;
|
a78c0ae8
“wangming”
feat: 退卡服务添加健康师和科...
|
114
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
|
// 根据是否传入健康师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
|
156
157
|
.WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id))
.WhereIF(!string.IsNullOrEmpty(input.md), p => p.Md.Equals(input.md))
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
158
|
.WhereIF(!string.IsNullOrEmpty(input.mdbh), p => p.Mdbh.Contains(input.mdbh))
|
96009bc9
hexiaodong
hxd
|
159
160
|
.WhereIF(!string.IsNullOrEmpty(input.mdmc), p => p.Mdmc.Contains(input.mdmc))
.WhereIF(!string.IsNullOrEmpty(input.hy), p => p.Hy.Equals(input.hy))
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
161
|
.WhereIF(!string.IsNullOrEmpty(input.hymc), p => p.Hymc.Contains(input.hymc))
|
96009bc9
hexiaodong
hxd
|
162
|
.WhereIF(!string.IsNullOrEmpty(input.hyzh), p => p.Hyzh.Contains(input.hyzh))
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
163
164
165
|
.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
|
166
|
.WhereIF(!string.IsNullOrEmpty(input.bz), p => p.Bz.Contains(input.bz))
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
167
168
|
.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...
|
169
|
.WhereIF(!string.IsNullOrEmpty(input.fileUrl), p => p.FileUrl.Contains(input.fileUrl))
|
fee50345
“wangming”
feat: 实现KPI数据穿透功能
|
170
171
|
.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”
更新退卡相关功能,重构退卡信息表及...
|
172
|
.WhereIF(!string.IsNullOrEmpty(input.czry), p => p.Czry.Equals(input.czry))
|
e745bcc2
“wangming”
修复转卡方法中的空引用异常和Fir...
|
173
|
.WhereIF(input.isEffective != 0, p => p.IsEffective == input.isEffective)
|
5e0c6e5a
“wangming”
feat: 完善会员画像功能,优化...
|
174
|
.WhereIF(input.isEffective == 0, p => p.IsEffective == StatusEnum.有效.GetHashCode()) // 如果未指定,默认只返回有效的
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
175
|
.Select(it => new LqHytkHytkListOutput
|
96009bc9
hexiaodong
hxd
|
176
177
|
{
id = it.Id,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
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”
优化开单记录作废功能:添加详细错误...
|
193
|
isEffective = it.IsEffective,
|
fb9d5c60
“wangming”
feat: 更新LqHytkHyt...
|
194
|
cancelRemark = it.CancelRemark,
|
63df7ccb
“wangming”
1
|
195
|
actualRefundAmount = it.ActualRefundAmount
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
196
197
198
199
|
})
.MergeTable()
.OrderBy(sidx + " " + input.sort)
.ToPagedListAsync(input.currentPage, input.pageSize);
|
a78c0ae8
“wangming”
feat: 退卡服务添加健康师和科...
|
200
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
|
// 获取当前页的退卡记录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文件,优...
|
298
|
return PageResult<LqHytkHytkListOutput>.SqlSugarPageResult(data);
|
96009bc9
hexiaodong
hxd
|
299
|
}
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
300
|
#endregion
|
96009bc9
hexiaodong
hxd
|
301
|
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
302
|
#region 创建退卡信息及其关联的品项明细、健康师业绩、科技部老师业绩信息
|
96009bc9
hexiaodong
hxd
|
303
|
/// <summary>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
304
|
/// 创建退卡信息及其关联的品项明细、健康师业绩、科技部老师业绩信息
|
96009bc9
hexiaodong
hxd
|
305
|
/// </summary>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
306
|
/// <remarks>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
307
308
309
310
311
312
313
314
315
316
|
/// 参数说明:
/// - 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
|
317
318
319
320
321
322
|
[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”
更新退卡相关功能,重构退卡信息表及...
|
323
324
|
entity.F_CreateTime = DateTime.Now;
entity.F_CreateUser = userInfo.userId;
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
325
|
entity.IsEffective = StatusEnum.有效.GetHashCode();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
326
|
entity.Czry = userInfo.userId;
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
327
|
|
96009bc9
hexiaodong
hxd
|
328
329
|
try
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
330
|
// 开启事务
|
96009bc9
hexiaodong
hxd
|
331
|
_db.BeginTran();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
332
|
// 新增退卡主表记录
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
333
|
var newEntity = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteReturnEntityAsync();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
334
335
336
337
|
// 收集所有需要插入的实体,然后批量插入
var allMxEntities = new List<LqHytkMxEntity>();
var allJksyjEntities = new List<LqHytkJksyjEntity>();
var allKjbsyjEntities = new List<LqHytkKjbsyjEntity>();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
338
339
|
// 处理品项明细列表
if (input.lqHytkMxList != null && input.lqHytkMxList.Any())
|
96009bc9
hexiaodong
hxd
|
340
|
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
341
|
foreach (var item in input.lqHytkMxList)
|
96009bc9
hexiaodong
hxd
|
342
|
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
343
344
345
346
|
// 创建品项明细实体
var lqHytkMxEntity = new LqHytkMxEntity
{
Id = YitIdHelper.NextId().ToString(),
|
b45d55f7
“wangming”
Refactor LqEventS...
|
347
348
|
RefundInfoId = newEntity.Id,
BillingItemId = item.billingItemId,
|
bc35ccd1
“wangming”
feat: 添加退卡业务相关功能
|
349
|
MemberId = newEntity.Hy,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
350
351
|
CreateTime = DateTime.Now,
CreateUser = userInfo.userId,
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
352
353
354
355
|
Px = item.px,
Pxmc = item.pxmc,
Pxjg = item.pxjg,
Tkje = item.tkje,
|
96e0ccc7
“wangming”
优化GetBillingRecor...
|
356
|
Tksj = input.tksj,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
357
|
ProjectNumber = item.F_ProjectNumber ?? 1,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
358
359
|
SourceType = item.F_SourceType,
TotalPrice = item.F_TotalPrice ?? (item.pxjg * (item.F_ProjectNumber ?? 1)),
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
360
|
IsEffective = StatusEnum.有效.GetHashCode(),
|
14cbcfd9
“wangming”
feat: 添加人次记录表和品项分类字段
|
361
|
ItemCategory = await _db.Queryable<LqXmzlEntity>().Where(x => x.Id == item.px).Select(x => x.Qt2).FirstAsync(),
|
3f8b942f
“wangming”
feat: 添加业绩类型字段并修复...
|
362
|
PerformanceType = await _db.Queryable<LqXmzlEntity>().Where(x => x.Id == item.px).Select(x => x.Fl3).FirstAsync() ?? "",
|
ac25ff12
“wangming”
feat: 添加大项目部老师工资计...
|
363
|
BeautyType = await _db.Queryable<LqXmzlEntity>().Where(x => x.Id == item.px).Select(x => x.BeautyType).FirstAsync(),
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
364
365
|
};
allMxEntities.Add(lqHytkMxEntity);
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
366
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
367
368
369
370
371
|
// 收集该品项关联的健康师业绩
if (item.lqHytkJksyjList != null && item.lqHytkJksyjList.Any())
{
foreach (var ijks_tem in item.lqHytkJksyjList)
{
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
372
373
374
375
376
377
378
379
|
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...
|
380
|
Tksj = input.tksj,
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
381
382
383
384
385
386
|
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”
优化开单记录作废功能:添加详细错误...
|
387
388
|
CardReturn = lqHytkMxEntity.Id,
IsEffective = StatusEnum.有效.GetHashCode(),
|
8514f465
“wangming”
feat: 优化业务逻辑和功能完善
|
389
390
|
ItemCategory = lqHytkMxEntity.ItemCategory,
ItemId = lqHytkMxEntity.Px,
|
7e362a14
“wangming”
feat: 为业绩表添加门店ID和...
|
391
|
StoreId = newEntity.Md,
|
3f8b942f
“wangming”
feat: 添加业绩类型字段并修复...
|
392
|
ItemName = lqHytkMxEntity.Pxmc,
|
ac25ff12
“wangming”
feat: 添加大项目部老师工资计...
|
393
394
|
PerformanceType = lqHytkMxEntity.PerformanceType,
BeautyType = lqHytkMxEntity.BeautyType,
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
395
|
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
396
|
);
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
397
398
|
}
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
399
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
400
401
402
403
404
|
// 收集该品项关联的科技部老师业绩
if (item.lqHytkKjbsyjList != null && item.lqHytkKjbsyjList.Any())
{
foreach (var ikjbs_tem in item.lqHytkKjbsyjList)
{
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
405
406
407
408
409
410
411
412
413
|
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...
|
414
|
Tksj = input.tksj,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
415
416
417
418
419
|
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...
|
420
|
CardReturn = lqHytkMxEntity.Id,
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
421
|
IsEffective = StatusEnum.有效.GetHashCode(),
|
8514f465
“wangming”
feat: 优化业务逻辑和功能完善
|
422
423
|
ItemCategory = lqHytkMxEntity.ItemCategory,
ItemId = lqHytkMxEntity.Px,
|
7e362a14
“wangming”
feat: 为业绩表添加门店ID和...
|
424
|
StoreId = newEntity.Md,
|
3f8b942f
“wangming”
feat: 添加业绩类型字段并修复...
|
425
|
ItemName = lqHytkMxEntity.Pxmc,
|
ac25ff12
“wangming”
feat: 添加大项目部老师工资计...
|
426
427
|
PerformanceType = lqHytkMxEntity.PerformanceType,
BeautyType = lqHytkMxEntity.BeautyType,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
428
429
|
}
);
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
430
431
|
}
}
|
96009bc9
hexiaodong
hxd
|
432
|
}
|
96009bc9
hexiaodong
hxd
|
433
|
}
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
434
435
|
// 批量插入品项明细
if (allMxEntities.Any())
|
96009bc9
hexiaodong
hxd
|
436
|
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
437
|
await _db.Insertable(allMxEntities).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
438
|
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
439
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
440
441
|
// 批量插入健康师业绩
if (allJksyjEntities.Any())
|
96009bc9
hexiaodong
hxd
|
442
|
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
443
|
await _db.Insertable(allJksyjEntities).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
444
|
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
445
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
446
447
|
// 批量插入科技部老师业绩
if (allKjbsyjEntities.Any())
|
96009bc9
hexiaodong
hxd
|
448
|
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
449
|
await _db.Insertable(allKjbsyjEntities).ExecuteCommandAsync();
|
96009bc9
hexiaodong
hxd
|
450
|
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
451
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
452
453
454
455
456
457
458
|
// 关闭事务
_db.CommitTran();
}
catch (Exception ex)
{
_db.RollbackTran();
throw NCCException.Oh(ErrorCode.COM1005, ex.Message);
|
96009bc9
hexiaodong
hxd
|
459
460
|
}
}
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
461
|
#endregion
|
96009bc9
hexiaodong
hxd
|
462
|
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
463
|
#region 更新退卡信息及其关联的品项明细、健康师业绩、科技部老师业绩信息
|
96009bc9
hexiaodong
hxd
|
464
|
/// <summary>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
465
|
/// 更新退卡信息及其关联的品项明细、健康师业绩、科技部老师业绩信息
|
96009bc9
hexiaodong
hxd
|
466
|
/// </summary>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
467
468
469
470
471
472
473
474
475
476
|
/// <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
|
477
478
479
|
[HttpPut("{id}")]
public async Task Update(string id, [FromBody] LqHytkHytkUpInput input)
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
480
|
var userInfo = await _userManager.GetUserInfo();
|
96009bc9
hexiaodong
hxd
|
481
|
var entity = input.Adapt<LqHytkHytkEntity>();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
482
483
484
|
entity.Id = id;
entity.F_ModifyTime = DateTime.Now;
entity.F_ModifyUser = userInfo.userId;
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
485
|
|
96009bc9
hexiaodong
hxd
|
486
487
|
try
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
488
|
// 开启事务
|
96009bc9
hexiaodong
hxd
|
489
|
_db.BeginTran();
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
490
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
491
492
|
// 更新退卡主表记录
await _db.Updateable(entity).IgnoreColumns(true).ExecuteCommandAsync();
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
493
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
494
|
// 删除原有的关联数据
|
b45d55f7
“wangming”
Refactor LqEventS...
|
495
|
await _db.Deleteable<LqHytkMxEntity>().Where(x => x.RefundInfoId == id).ExecuteCommandAsync();
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
496
497
|
await _db.Deleteable<LqHytkJksyjEntity>().Where(x => x.Gltkbh == id).ExecuteCommandAsync();
await _db.Deleteable<LqHytkKjbsyjEntity>().Where(x => x.Gltkbh == id).ExecuteCommandAsync();
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
498
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
499
500
501
502
|
// 收集所有需要插入的实体,然后批量插入
var allMxEntities = new List<LqHytkMxEntity>();
var allJksyjEntities = new List<LqHytkJksyjEntity>();
var allKjbsyjEntities = new List<LqHytkKjbsyjEntity>();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
503
504
|
// 处理品项明细列表
if (input.lqHytkMxList != null && input.lqHytkMxList.Any())
|
96009bc9
hexiaodong
hxd
|
505
|
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
506
|
foreach (var item in input.lqHytkMxList)
|
96009bc9
hexiaodong
hxd
|
507
|
{
|
bc35ccd1
“wangming”
feat: 添加退卡业务相关功能
|
508
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
509
510
511
512
|
// 创建品项明细实体
var lqHytkMxEntity = new LqHytkMxEntity
{
Id = YitIdHelper.NextId().ToString(),
|
b45d55f7
“wangming”
Refactor LqEventS...
|
513
514
|
RefundInfoId = id,
BillingItemId = item.billingItemId,
|
bc35ccd1
“wangming”
feat: 添加退卡业务相关功能
|
515
|
MemberId = entity.Hy,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
516
517
|
CreateTime = DateTime.Now,
CreateUser = userInfo.userId,
|
dac8767e
“wangming”
111111111
|
518
|
Tksj = input.tksj,
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
519
520
521
522
|
Px = item.px,
Pxmc = item.pxmc,
Pxjg = item.pxjg,
Tkje = item.tkje,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
523
|
ProjectNumber = item.F_ProjectNumber ?? 1,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
524
525
|
SourceType = item.F_SourceType,
TotalPrice = item.F_TotalPrice ?? (item.pxjg * (item.F_ProjectNumber ?? 1)),
|
14cbcfd9
“wangming”
feat: 添加人次记录表和品项分类字段
|
526
|
ItemCategory = await _db.Queryable<LqXmzlEntity>().Where(x => x.Id == item.px).Select(x => x.Qt2).FirstAsync(),
|
3f8b942f
“wangming”
feat: 添加业绩类型字段并修复...
|
527
|
PerformanceType = await _db.Queryable<LqXmzlEntity>().Where(x => x.Id == item.px).Select(x => x.Fl3).FirstAsync() ?? "",
|
ac25ff12
“wangming”
feat: 添加大项目部老师工资计...
|
528
|
BeautyType = await _db.Queryable<LqXmzlEntity>().Where(x => x.Id == item.px).Select(x => x.BeautyType).FirstAsync(),
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
529
530
|
};
allMxEntities.Add(lqHytkMxEntity);
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
531
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
532
533
534
535
536
|
// 收集该品项关联的健康师业绩
if (item.lqHytkJksyjList != null && item.lqHytkJksyjList.Any())
{
foreach (var ijks_tem in item.lqHytkJksyjList)
{
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
537
538
539
540
541
542
543
544
545
|
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...
|
546
|
Tksj = input.tksj,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
547
548
549
550
551
552
|
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: 优化业务逻辑和功能完善
|
553
554
|
ItemCategory = lqHytkMxEntity.ItemCategory,
ItemId = lqHytkMxEntity.Px,
|
7e362a14
“wangming”
feat: 为业绩表添加门店ID和...
|
555
|
StoreId = entity.Md,
|
3f8b942f
“wangming”
feat: 添加业绩类型字段并修复...
|
556
|
ItemName = lqHytkMxEntity.Pxmc,
|
ac25ff12
“wangming”
feat: 添加大项目部老师工资计...
|
557
558
|
PerformanceType = lqHytkMxEntity.PerformanceType,
BeautyType = lqHytkMxEntity.BeautyType,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
559
560
|
}
);
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
561
562
|
}
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
563
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
564
565
566
567
568
|
// 收集该品项关联的科技部老师业绩
if (item.lqHytkKjbsyjList != null && item.lqHytkKjbsyjList.Any())
{
foreach (var ikjbs_tem in item.lqHytkKjbsyjList)
{
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
569
570
571
572
573
574
575
576
577
|
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...
|
578
|
Tksj = input.tksj,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
579
580
581
582
583
|
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: 优化业务逻辑和功能完善
|
584
585
|
ItemCategory = lqHytkMxEntity.ItemCategory,
ItemId = lqHytkMxEntity.Px,
|
7e362a14
“wangming”
feat: 为业绩表添加门店ID和...
|
586
|
StoreId = entity.Md,
|
3f8b942f
“wangming”
feat: 添加业绩类型字段并修复...
|
587
|
ItemName = lqHytkMxEntity.Pxmc,
|
ac25ff12
“wangming”
feat: 添加大项目部老师工资计...
|
588
589
|
PerformanceType = lqHytkMxEntity.PerformanceType,
BeautyType = lqHytkMxEntity.BeautyType,
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
590
591
|
}
);
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
592
593
|
}
}
|
96009bc9
hexiaodong
hxd
|
594
|
}
|
96009bc9
hexiaodong
hxd
|
595
|
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
596
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
597
598
599
600
601
|
// 批量插入品项明细
if (allMxEntities.Any())
{
await _db.Insertable(allMxEntities).ExecuteCommandAsync();
}
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
602
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
603
604
605
606
607
|
// 批量插入健康师业绩
if (allJksyjEntities.Any())
{
await _db.Insertable(allJksyjEntities).ExecuteCommandAsync();
}
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
608
609
610
611
612
|
// 批量插入科技部老师业绩
if (allKjbsyjEntities.Any())
{
await _db.Insertable(allKjbsyjEntities).ExecuteCommandAsync();
}
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
613
|
// 关闭事务
|
96009bc9
hexiaodong
hxd
|
614
615
|
_db.CommitTran();
}
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
616
|
catch (Exception ex)
|
96009bc9
hexiaodong
hxd
|
617
|
{
|
96009bc9
hexiaodong
hxd
|
618
|
_db.RollbackTran();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
619
|
throw NCCException.Oh(ErrorCode.COM1005, ex.Message);
|
96009bc9
hexiaodong
hxd
|
620
621
|
}
}
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
622
|
#endregion
|
96009bc9
hexiaodong
hxd
|
623
|
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
624
|
#region 作废退卡信息
|
96009bc9
hexiaodong
hxd
|
625
|
/// <summary>
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
626
|
/// 作废退卡信息
|
96009bc9
hexiaodong
hxd
|
627
|
/// </summary>
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
628
|
/// <param name="id">主键</param>
|
96009bc9
hexiaodong
hxd
|
629
|
/// <returns></returns>
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
630
|
[HttpPut("VoidRefundCardInfo/{id}")]
|
fb9d5c60
“wangming”
feat: 更新LqHytkHyt...
|
631
|
public async Task<dynamic> VoidRefundCardInfo(string id, [FromQuery] string remarks = null)
|
96009bc9
hexiaodong
hxd
|
632
|
{
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
633
|
try
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
634
|
{
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
635
636
637
638
639
640
641
642
|
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”
优化开单记录作废功能:添加详细错误...
|
643
|
entity.IsEffective = StatusEnum.无效.GetHashCode();
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
644
|
entity.F_ModifyTime = DateTime.Now;
|
fb9d5c60
“wangming”
feat: 更新LqHytkHyt...
|
645
|
entity.CancelRemark = remarks;
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
646
647
|
await _db.Updateable(entity).ExecuteCommandAsync();
// 更新明细表
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
648
|
await _db.Updateable<LqHytkMxEntity>().SetColumns(it => new LqHytkMxEntity { IsEffective = StatusEnum.无效.GetHashCode() }).Where(w => w.RefundInfoId == id).ExecuteCommandAsync();
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
649
|
// 更新健康师业绩表
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
650
|
await _db.Updateable<LqHytkJksyjEntity>().SetColumns(it => new LqHytkJksyjEntity { IsEffective = StatusEnum.无效.GetHashCode() }).Where(w => w.Gltkbh == id).ExecuteCommandAsync();
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
651
|
// 更新科技部业绩表
|
3e508db5
“wangming”
优化开单记录作废功能:添加详细错误...
|
652
|
await _db.Updateable<LqHytkKjbsyjEntity>().SetColumns(it => new LqHytkKjbsyjEntity { IsEffective = StatusEnum.无效.GetHashCode() }).Where(w => w.Gltkbh == id).ExecuteCommandAsync();
|
2164125c
“wangming”
feat: 删除LqXhmxb相关...
|
653
654
655
656
657
658
659
660
|
// 提交事务
_db.CommitTran();
return entity;
}
catch (Exception ex)
{
_db.RollbackTran();
throw NCCException.Oh($"删除退卡信息失败: {ex.Message}");
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
661
662
|
}
}
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
663
|
#endregion
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
664
|
|
dac8767e
“wangming”
111111111
|
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
|
#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: 新增门店类别枚举和耗卡...
|
699
|
await _db.Deleteable<LqHytkMxEntity>().Where(x => x.RefundInfoId == id).ExecuteCommandAsync();
|
dac8767e
“wangming”
111111111
|
700
701
|
// 2. 删除退卡健康师业绩记录
|
ce74473f
“wangming”
feat: 新增门店类别枚举和耗卡...
|
702
|
await _db.Deleteable<LqHytkJksyjEntity>().Where(x => x.Gltkbh == id).ExecuteCommandAsync();
|
dac8767e
“wangming”
111111111
|
703
704
|
// 3. 删除退卡科技部老师业绩记录
|
ce74473f
“wangming”
feat: 新增门店类别枚举和耗卡...
|
705
|
await _db.Deleteable<LqHytkKjbsyjEntity>().Where(x => x.Gltkbh == id).ExecuteCommandAsync();
|
dac8767e
“wangming”
111111111
|
706
707
|
// 4. 删除退卡主表记录
|
ce74473f
“wangming”
feat: 新增门店类别枚举和耗卡...
|
708
|
await _db.Deleteable<LqHytkHytkEntity>().Where(x => x.Id == id).ExecuteCommandAsync();
|
dac8767e
“wangming”
111111111
|
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
|
// 提交事务
_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...
|
730
|
#region 获取退卡信息详情
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
731
732
733
734
735
736
|
/// <summary>
/// 获取退卡信息详情
/// </summary>
/// <remarks>
/// 获取退卡记录及其关联的品项明细、健康师业绩、科技部老师业绩信息
/// 按照退卡的完整格式返回数据,不包含汇总信息
|
00486d53
“wangming”
更新多个.DS_Store文件,优...
|
737
|
///
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
738
739
740
741
742
743
744
745
746
747
748
749
750
751
|
/// 返回数据结构:
/// - 主表信息:退卡基础信息、门店信息、会员信息、退卡金额等
/// - 品项明细列表:每个品项包含完整的项目信息(项目次数、是否有效、来源类型等)
/// - 健康师业绩列表:按品项关联的健康师业绩信息
/// - 科技部老师业绩列表:按品项关联的科技部老师业绩信息
/// </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
|
752
753
|
try
{
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
754
|
// 1. 查询主表信息
|
fb9d5c60
“wangming”
feat: 更新LqHytkHyt...
|
755
|
var entity = await _db.Queryable<LqHytkHytkEntity>().Where(p => p.Id == id).FirstAsync();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
756
757
|
if (entity == null)
{
|
fb9d5c60
“wangming”
feat: 更新LqHytkHyt...
|
758
|
throw NCCException.Oh("退卡记录不存在");
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
759
|
}
|
96009bc9
hexiaodong
hxd
|
760
|
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
761
762
763
|
var output = entity.Adapt<LqHytkHytkInfoOutput>();
// 2. 查询品项明细列表
|
b45d55f7
“wangming”
Refactor LqEventS...
|
764
|
var lqHytkMxList = await _db.Queryable<LqHytkMxEntity>().Where(w => w.RefundInfoId == entity.Id).ToListAsync();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
765
766
|
// 3. 查询健康师业绩列表
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
767
|
var lqHytkJksyjList = await _db.Queryable<LqHytkJksyjEntity>().Where(w => w.Gltkbh == entity.Id).ToListAsync();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
768
769
|
// 4. 查询科技部老师业绩列表
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
770
|
var lqHytkKjbsyjList = await _db.Queryable<LqHytkKjbsyjEntity>().Where(w => w.Gltkbh == entity.Id).ToListAsync();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
771
772
773
774
775
776
777
778
|
// 5. 构建品项明细输出,每个品项关联对应的业绩信息
var mxOutputList = new List<LqHytkMxInfoOutput>();
foreach (var mx in lqHytkMxList)
{
var mxOutput = new LqHytkMxInfoOutput
{
id = mx.Id,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
779
780
|
refundInfoId = mx.RefundInfoId,
billingItemId = mx.BillingItemId,
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
781
782
783
784
|
px = mx.Px,
pxmc = mx.Pxmc,
pxjg = mx.Pxjg,
tkje = mx.Tkje,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
785
|
projectNumber = mx.ProjectNumber,
|
b45d55f7
“wangming”
Refactor LqEventS...
|
786
787
|
sourceType = mx.SourceType,
totalPrice = mx.TotalPrice,
|
fb9d5c60
“wangming”
feat: 更新LqHytkHyt...
|
788
|
isEffective = mx.IsEffective,
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
789
790
791
|
};
// 关联该品项的健康师业绩
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
792
|
var jksyjForMx = lqHytkJksyjList.Where(j => j.CardReturn == mx.Id).ToList();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
793
794
795
|
mxOutput.lqHytkJksyjList = jksyjForMx.Adapt<List<LqHytkJksyjInfoOutput>>();
// 关联该品项的科技部老师业绩
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
796
|
var kjbsyjForMx = lqHytkKjbsyjList.Where(k => k.CardReturn == mx.Id).ToList();
|
2b23ca5e
“wangming”
更新退卡相关功能,重构退卡信息表及...
|
797
798
799
800
801
802
803
804
805
806
807
808
809
|
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
|
810
|
}
|
fb9d5c60
“wangming”
feat: 更新LqHytkHyt...
|
811
|
catch (Exception ex)
|
96009bc9
hexiaodong
hxd
|
812
|
{
|
fb9d5c60
“wangming”
feat: 更新LqHytkHyt...
|
813
|
throw NCCException.Oh($"获取退卡记录详情失败: {ex.Message}");
|
96009bc9
hexiaodong
hxd
|
814
815
|
}
}
|
0ef47194
“wangming”
Refactor LqHytkHy...
|
816
|
#endregion
|
d64f9fbd
“wangming”
feat: 添加退卡明细查询和导出功能
|
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
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
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
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
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
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
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
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
|
#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 ?? "");
}
// 5. 组装数据
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;
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,
itemCategory = mx.ItemCategory
});
}
// 6. 排序
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();
}
// 7. 分页
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 ?? "");
}
// 5. 组装数据
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;
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,
itemCategory = mx.ItemCategory
});
}
// 6. 排序
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
|
1257
1258
|
}
}
|