LqMdxxService.cs
24.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
using NCC.Common.Core.Manager;
using NCC.Common.Enum;
using NCC.Common.Extension;
using NCC.Common.Filter;
using NCC.Dependency;
using NCC.DynamicApiController;
using NCC.FriendlyException;
using NCC.Extend.Interfaces.BusinessOperationLog;
using NCC.Extend.Interfaces.LqMdxx;
using NCC.Extend.Interfaces.StoreProfileVersion;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using NCC.Extend.Entitys.lq_mdxx;
using NCC.Extend.Entitys.Dto.LqMdxx;
using Yitter.IdGenerator;
using NCC.Common.Helper;
using NCC.JsonSerialization;
using NCC.Common.Model.NPOI;
using NCC.Common.Configuration;
using NCC.DataEncryption;
using NCC.ClayObject;
using NCC.Extend.Entitys.Enum;
using NCC.Code;
using NCC.Extend.Entitys.Dto.Common;
using Newtonsoft.Json;
namespace NCC.Extend.LqMdxx
{
/// <summary>
/// 门店信息服务
/// </summary>
[ApiDescriptionSettings(Tag = "绿纤门店信息服务", Name = "LqMdxx", Order = 200)]
[Route("api/Extend/[controller]")]
public class LqMdxxService : ILqMdxxService, IDynamicApiController, ITransient
{
private readonly ISqlSugarRepository<LqMdxxEntity> _lqMdxxRepository;
private readonly SqlSugarScope _db;
private readonly IUserManager _userManager;
private readonly IStoreProfileVersionAppender _storeProfileVersionAppender;
private readonly IBusinessOperationLogService _businessOperationLogService;
private const int InvalidStatus = (int)StatusEnum.无效;
/// <summary>
/// 初始化一个<see cref="LqMdxxService"/>类型的新实例
/// </summary>
public LqMdxxService(
ISqlSugarRepository<LqMdxxEntity> lqMdxxRepository,
IUserManager userManager,
IStoreProfileVersionAppender storeProfileVersionAppender,
IBusinessOperationLogService businessOperationLogService)
{
_lqMdxxRepository = lqMdxxRepository;
_db = _lqMdxxRepository.Context;
_userManager = userManager;
_storeProfileVersionAppender = storeProfileVersionAppender;
_businessOperationLogService = businessOperationLogService;
}
#region 门店信息
/// <summary>
/// 获取门店信息
/// </summary>
/// <param name="id">参数</param>
/// <returns></returns>
[HttpGet("{id}")]
public async Task<dynamic> GetInfo(string id)
{
var entity = await _db.Queryable<LqMdxxEntity>().FirstAsync(p => p.Id == id);
var output = entity.Adapt<LqMdxxInfoOutput>();
return output;
}
#endregion
#region 门店信息列表
/// <summary>
/// 获取门店信息列表
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
[HttpGet("")]
public async Task<dynamic> GetList([FromQuery] LqMdxxListQueryInput input)
{
var sidx = input.sidx == null ? "id" : input.sidx;
List<string> queryKysj = input.kysj != null ? input.kysj.Split(',').ToObeject<List<string>>() : null;
DateTime? startKysj = queryKysj != null ? Ext.GetDateTime(queryKysj.First()) : null;
DateTime? endKysj = queryKysj != null ? Ext.GetDateTime(queryKysj.Last()) : null;
var data = await _db.Queryable<LqMdxxEntity>()
.Where(p => p.Status == null || p.Status != InvalidStatus)
.WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id))
.WhereIF(!string.IsNullOrEmpty(input.mdbm), p => p.Mdbm.Contains(input.mdbm))
.WhereIF(!string.IsNullOrEmpty(input.djmdbh), p => p.Djmdbh.Contains(input.djmdbh))
.WhereIF(!string.IsNullOrEmpty(input.djmd), p => p.Djmd.Contains(input.djmd))
.WhereIF(!string.IsNullOrEmpty(input.dm), p => p.Dm.Contains(input.dm) || p.Djmd.Contains(input.dm))
.WhereIF(!string.IsNullOrEmpty(input.cs), p => p.Cs.Contains(input.cs))
.WhereIF(!string.IsNullOrEmpty(input.dz), p => p.Dz.Contains(input.dz))
.WhereIF(!string.IsNullOrEmpty(input.xm), p => p.Xm.Contains(input.xm))
.WhereIF(!string.IsNullOrEmpty(input.dhhm), p => p.Dhhm.Contains(input.dhhm))
.WhereIF(!string.IsNullOrEmpty(input.zj), p => p.Zj.Contains(input.zj))
.WhereIF(queryKysj != null, p => p.Kysj >= new DateTime(startKysj.ToDate().Year, startKysj.ToDate().Month, startKysj.ToDate().Day, 0, 0, 0))
.WhereIF(queryKysj != null, p => p.Kysj <= new DateTime(endKysj.ToDate().Year, endKysj.ToDate().Month, endKysj.ToDate().Day, 23, 59, 59))
.WhereIF(!string.IsNullOrEmpty(input.zxzt), p => p.Zxzt.Equals(input.zxzt))
.WhereIF(!string.IsNullOrEmpty(input.gsmc), p => p.Gsmc.Contains(input.gsmc))
.WhereIF(!string.IsNullOrEmpty(input.fr), p => p.Fr.Contains(input.fr))
.WhereIF(!string.IsNullOrEmpty(input.ywsb), p => p.Ywsb.Equals(input.ywsb))
.Select(it => new LqMdxxListOutput
{
id = it.Id,
mdbm = it.Mdbm,
djmdbh = it.Djmdbh,
djmd = it.Djmd,
dm = it.Dm,
cs = it.Cs,
dz = it.Dz,
xm = it.Xm,
dhhm = it.Dhhm,
zj = it.Zj,
kysj = it.Kysj,
zxzt = it.Zxzt,
gsmc = it.Gsmc,
fr = it.Fr,
ywsb = it.Ywsb,
jyb = it.Jyb,
kjb = it.Kjb,
dxmb = it.Dxmb,
syb = it.Syb,
xsyj = it.Xsyj,
xhyj = it.Xhyj,
xms = it.Xms,
rt1 = it.Rt1,
rt2 = it.Rt2,
rc = it.Rc,
storeCategory = it.StoreCategory,
storeType = it.StoreType,
zzrs = it.Zzrs,
storeImages = it.StoreImages,
storeDescription = it.StoreDescription,
storeTags = it.StoreTags,
businessHours = it.BusinessHours,
trafficTips = it.TrafficTips,
}).MergeTable().OrderBy(sidx + " " + input.sort).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult<LqMdxxListOutput>.SqlSugarPageResult(data);
}
#endregion
#region 新建门店信息
/// <summary>
/// 新建门店信息
/// </summary>
/// <param name="input">参数</param>
/// <returns></returns>
[HttpPost("")]
public async Task Create([FromBody] LqMdxxCrInput input)
{
var userInfo = await _userManager.GetUserInfo();
var entity = input.Adapt<LqMdxxEntity>();
entity.Id = YitIdHelper.NextId().ToString();
var isOk = await _db.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync();
if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1000);
await TryWriteBusinessLogAsync(
"门店信息",
"新增门店",
"lq_mdxx",
entity.Id,
$"新增门店:{GetStoreDisplayName(entity)}(ID:{entity.Id})",
JsonConvert.SerializeObject(new { after = new { entity.Id, entity.Mdbm, entity.Dm, entity.Cs } }));
}
#endregion
#region 获取门店信息无分页列表
/// <summary>
/// 获取门店信息无分页列表
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
[NonAction]
public async Task<dynamic> GetNoPagingList([FromQuery] LqMdxxListQueryInput input)
{
var sidx = input.sidx == null ? "id" : input.sidx;
List<string> queryKysj = input.kysj != null ? input.kysj.Split(',').ToObeject<List<string>>() : null;
DateTime? startKysj = queryKysj != null ? Ext.GetDateTime(queryKysj.First()) : null;
DateTime? endKysj = queryKysj != null ? Ext.GetDateTime(queryKysj.Last()) : null;
var data = await _db.Queryable<LqMdxxEntity>()
.Where(p => p.Status == null || p.Status != InvalidStatus)
.WhereIF(!string.IsNullOrEmpty(input.id), p => p.Id.Contains(input.id))
.WhereIF(!string.IsNullOrEmpty(input.mdbm), p => p.Mdbm.Contains(input.mdbm))
.WhereIF(!string.IsNullOrEmpty(input.djmdbh), p => p.Djmdbh.Contains(input.djmdbh))
.WhereIF(!string.IsNullOrEmpty(input.djmd), p => p.Djmd.Contains(input.djmd))
.WhereIF(!string.IsNullOrEmpty(input.dm), p => p.Dm.Contains(input.dm) || p.Djmd.Contains(input.dm))
.WhereIF(!string.IsNullOrEmpty(input.cs), p => p.Cs.Contains(input.cs))
.WhereIF(!string.IsNullOrEmpty(input.dz), p => p.Dz.Contains(input.dz))
.WhereIF(!string.IsNullOrEmpty(input.xm), p => p.Xm.Contains(input.xm))
.WhereIF(!string.IsNullOrEmpty(input.dhhm), p => p.Dhhm.Contains(input.dhhm))
.WhereIF(!string.IsNullOrEmpty(input.zj), p => p.Zj.Contains(input.zj))
.WhereIF(queryKysj != null, p => p.Kysj >= new DateTime(startKysj.ToDate().Year, startKysj.ToDate().Month, startKysj.ToDate().Day, 0, 0, 0))
.WhereIF(queryKysj != null, p => p.Kysj <= new DateTime(endKysj.ToDate().Year, endKysj.ToDate().Month, endKysj.ToDate().Day, 23, 59, 59))
.WhereIF(!string.IsNullOrEmpty(input.zxzt), p => p.Zxzt.Equals(input.zxzt))
.WhereIF(!string.IsNullOrEmpty(input.gsmc), p => p.Gsmc.Contains(input.gsmc))
.WhereIF(!string.IsNullOrEmpty(input.fr), p => p.Fr.Contains(input.fr))
.WhereIF(!string.IsNullOrEmpty(input.ywsb), p => p.Ywsb.Equals(input.ywsb))
.Select(it => new LqMdxxListOutput
{
id = it.Id,
mdbm = it.Mdbm,
djmdbh = it.Djmdbh,
djmd = it.Djmd,
dm = it.Dm,
cs = it.Cs,
dz = it.Dz,
xm = it.Xm,
dhhm = it.Dhhm,
zj = it.Zj,
kysj = it.Kysj,
zxzt = it.Zxzt,
gsmc = it.Gsmc,
fr = it.Fr,
ywsb = it.Ywsb,
jyb = it.Jyb,
kjb = it.Kjb,
dxmb = it.Dxmb,
syb = it.Syb,
gsqssj = it.Gsqssj,
gszzsj = it.Gszzsj,
status = it.Status,
xsyj = it.Xsyj,
xhyj = it.Xhyj,
xms = it.Xms,
rt1 = it.Rt1,
rt2 = it.Rt2,
rc = it.Rc,
storeCategory = it.StoreCategory,
storeType = it.StoreType,
zzrs = it.Zzrs,
storeImages = it.StoreImages,
storeDescription = it.StoreDescription,
storeTags = it.StoreTags,
businessHours = it.BusinessHours,
trafficTips = it.TrafficTips,
}).MergeTable().OrderBy(sidx + " " + input.sort).ToListAsync();
return data;
}
#endregion
#region 导出门店信息
/// <summary>
/// 导出门店信息
/// </summary>
/// <param name="input">请求参数</param>
/// <returns></returns>
[HttpGet("Actions/Export")]
public async Task<dynamic> Export([FromQuery] LqMdxxListQueryInput input)
{
var userInfo = await _userManager.GetUserInfo();
var exportData = new List<LqMdxxListOutput>();
if (input.dataType == 0)
{
var data = Clay.Object(await this.GetList(input));
exportData = data.Solidify<PageResult<LqMdxxListOutput>>().list;
}
else
{
exportData = await this.GetNoPagingList(input);
}
List<ParamsModel> paramList = "[{\"value\":\"主键\",\"field\":\"id\"},{\"value\":\"门店编码\",\"field\":\"mdbm\"},{\"value\":\"单据门店编号\",\"field\":\"djmdbh\"},{\"value\":\"单据门店\",\"field\":\"djmd\"},{\"value\":\"店名\",\"field\":\"dm\"},{\"value\":\"城市\",\"field\":\"cs\"},{\"value\":\"地址\",\"field\":\"dz\"},{\"value\":\"姓名\",\"field\":\"xm\"},{\"value\":\"电话号码\",\"field\":\"dhhm\"},{\"value\":\"座机\",\"field\":\"zj\"},{\"value\":\"开业时间\",\"field\":\"kysj\"},{\"value\":\"最新状态\",\"field\":\"zxzt\"},{\"value\":\"工商名称\",\"field\":\"gsmc\"},{\"value\":\"法人\",\"field\":\"fr\"},{\"value\":\"有无社保\",\"field\":\"ywsb\"},{\"value\":\"在职人数\",\"field\":\"zzrs\"},{\"value\":\"门店介绍\",\"field\":\"storeDescription\"},{\"value\":\"门店标签\",\"field\":\"storeTags\"},{\"value\":\"营业时间设置\",\"field\":\"businessHours\"},{\"value\":\"交通提示\",\"field\":\"trafficTips\"}]".ToList<ParamsModel>();
ExcelConfig excelconfig = new ExcelConfig();
excelconfig.FileName = "门店信息.xls";
excelconfig.HeadFont = "微软雅黑";
excelconfig.HeadPoint = 10;
excelconfig.IsAllSizeColumn = true;
excelconfig.ColumnModel = new List<ExcelColumnModel>();
List<string> selectKeyList = input.selectKey.Split(',').ToList();
foreach (var item in selectKeyList)
{
var isExist = paramList.Find(p => p.field == item);
if (isExist != null)
{
excelconfig.ColumnModel.Add(new ExcelColumnModel() { Column = isExist.field, ExcelColumn = isExist.value });
}
}
var addPath = FileVariable.TemporaryFilePath + excelconfig.FileName;
ExcelExportHelper<LqMdxxListOutput>.Export(exportData, excelconfig, addPath);
await TryWriteBusinessLogAsync(
"门店信息",
"导出门店信息",
"lq_mdxx",
null,
$"导出门店信息,共 {exportData.Count} 条",
JsonConvert.SerializeObject(new
{
filters = new { input.mdbm, input.dm, input.cs, input.zxzt, input.dataType },
rowCount = exportData.Count,
fileName = excelconfig.FileName
}));
var fileName = _userManager.UserId + "|" + addPath + "|xls";
var output = new
{
name = excelconfig.FileName,
url = "/api/File/Download?encryption=" + DESCEncryption.Encrypt(fileName, "NCC")
};
return output;
}
#endregion
#region 批量删除门店信息
/// <summary>
/// 批量标记删除门店信息(软删除,将 status 置为无效)
/// </summary>
/// <param name="ids">主键数组</param>
/// <returns></returns>
[HttpPost("batchRemove")]
public async Task BatchRemove([FromBody] List<string> ids)
{
var entitys = await _db.Queryable<LqMdxxEntity>()
.In(it => it.Id, ids)
.Where(p => p.Status == null || p.Status != InvalidStatus)
.ToListAsync();
if (entitys.Count == 0) return;
var deleteSnapshots = entitys
.Select(entity => new { Entity = entity, BeforeStatus = entity.Status })
.ToList();
try
{
_db.BeginTran();
foreach (var snapshot in deleteSnapshots)
{
snapshot.Entity.Status = InvalidStatus;
}
var isOk = await _db.Updateable(entitys).UpdateColumns(it => new { it.Status }).ExecuteCommandAsync();
if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1001);
foreach (var snapshot in deleteSnapshots)
{
await _storeProfileVersionAppender.AfterStorePersistedAsync(snapshot.Entity.Id, "STORE_STATUS_UPDATE");
}
_db.CommitTran();
}
catch (Exception)
{
_db.RollbackTran();
throw NCCException.Oh(ErrorCode.COM1002);
}
// 事务提交成功后再写业务日志,避免回滚后仍留下日志
foreach (var snapshot in deleteSnapshots)
{
try
{
await _businessOperationLogService.WriteAsync(
"门店信息",
"批量删除",
"lq_mdxx",
snapshot.Entity.Id,
$"批量删除门店:{GetStoreDisplayName(snapshot.Entity)}(ID:{snapshot.Entity.Id})",
BuildStoreDeleteDetailJson(snapshot.Entity, snapshot.BeforeStatus));
}
catch (Exception)
{
// 写日志失败不拖垮主业务
}
}
}
#endregion
#region 更新门店信息
/// <summary>
/// 更新门店信息
/// </summary>
/// <param name="id">主键</param>
/// <param name="input">参数</param>
/// <returns></returns>
[HttpPut("{id}")]
public async Task Update(string id, [FromBody] LqMdxxUpInput input)
{
var before = await _db.Queryable<LqMdxxEntity>().FirstAsync(p => p.Id == id);
_ = before ?? throw NCCException.Oh(ErrorCode.COM1005);
var entity = input.Adapt<LqMdxxEntity>();
entity.Id = id; // 设置主键ID
var isOk = await _db.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1001);
await _storeProfileVersionAppender.AfterStorePersistedAsync(id, "STORE_UPDATE");
await TryWriteBusinessLogAsync(
"门店信息",
"修改门店",
"lq_mdxx",
id,
$"修改门店:{GetStoreDisplayName(before)}(ID:{id})",
JsonConvert.SerializeObject(new
{
before = new { before.Id, before.Mdbm, before.Dm, before.Cs, before.Zxzt },
after = new { entity.Mdbm, entity.Dm, entity.Cs, entity.Zxzt }
}));
}
#endregion
#region 更新门店目标字段
/// <summary>
/// 更新门店目标字段
/// </summary>
/// <param name="id">主键</param>
/// <param name="input">目标字段参数</param>
/// <returns></returns>
[HttpPut("{id}/targets")]
public async Task UpdateTargets(string id, [FromBody] LqMdxxTargetUpdateInput input)
{
var before = await _db.Queryable<LqMdxxEntity>().FirstAsync(p => p.Id == id);
_ = before ?? throw NCCException.Oh(ErrorCode.COM1005);
var isOk = await _db.Updateable<LqMdxxEntity>()
.SetColumns(it => new LqMdxxEntity
{
Xsyj = input.xsyj,
Xhyj = input.xhyj,
Xms = input.xms,
Rt1 = input.rt1,
Rt2 = input.rt2,
Rc = input.rc
})
.Where(x => x.Id == id)
.ExecuteCommandAsync();
if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1001);
await _storeProfileVersionAppender.AfterStorePersistedAsync(id, "STORE_TARGETS_UPDATE");
await TryWriteBusinessLogAsync(
"门店信息",
"修改门店目标",
"lq_mdxx",
id,
$"修改门店目标字段(ID:{id})",
JsonConvert.SerializeObject(new
{
before = new { before.Xsyj, before.Xhyj, before.Xms, before.Rt1, before.Rt2, before.Rc },
after = new { input.xsyj, input.xhyj, input.xms, input.rt1, input.rt2, input.rc }
}));
}
#endregion
#region 删除门店信息
/// <summary>
/// 标记删除门店信息(软删除,将 status 置为无效)
/// </summary>
/// <returns></returns>
[HttpDelete("{id}")]
public async Task Delete(string id)
{
var entity = await _db.Queryable<LqMdxxEntity>().FirstAsync(p => p.Id == id);
_ = entity ?? throw NCCException.Oh(ErrorCode.COM1005);
if (entity.Status == InvalidStatus) throw NCCException.Oh("该门店已标记删除");
var beforeStatus = entity.Status;
entity.Status = InvalidStatus;
var isOk = await _db.Updateable(entity).UpdateColumns(it => new { it.Status }).ExecuteCommandAsync();
if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1001);
await _storeProfileVersionAppender.AfterStorePersistedAsync(id, "STORE_STATUS_UPDATE");
try
{
await _businessOperationLogService.WriteAsync(
"门店信息",
"删除",
"lq_mdxx",
id,
$"删除门店:{GetStoreDisplayName(entity)}(ID:{id})",
BuildStoreDeleteDetailJson(entity, beforeStatus));
}
catch (Exception)
{
// 写日志失败不拖垮主业务
}
}
#endregion
#region 获取门店下拉选择数据
/// <summary>
/// 获取门店下拉选择数据
/// </summary>
/// <returns></returns>
[HttpGet("Selector")]
public async Task<dynamic> GetSelector()
{
var list = await _db.Queryable<LqMdxxEntity>()
.Where(it => it.Zxzt == "开店")
.Where(p => p.Status == null || p.Status != InvalidStatus)
.Select(it => new { id = it.Id, fullName = it.Dm, enCode = it.Mdbm })
.ToListAsync();
return new { list = list };
}
#endregion
#region 获取门店类别下拉选择数据
/// <summary>
/// 获取门店类别下拉选择数据
/// </summary>
/// <returns></returns>
[HttpGet("Selector/StoreCategory")]
public List<EnumOutput> GetStoreCategorySelector()
{
return Enum.GetValues<StoreCategoryEnum>().Select(e => new EnumOutput
{
Value = (int)e,
Name = e.ToString(),
Description = e.GetDescription(),
}).ToList();
}
#endregion
#region 获取门店类型下拉选择数据
/// <summary>
/// 获取门店类型下拉选择数据
/// </summary>
/// <returns></returns>
[HttpGet("Selector/StoreType")]
public List<EnumOutput> GetStoreTypeSelector()
{
//从Enum中获取门店类型
var storeTypeEnum = Enum.GetValues<StoreTypeEnum>()
.Select(e => new EnumOutput
{
Value = (int)e,
Name = e.ToString(),
Description = e.GetDescription(),
})
.ToList();
return storeTypeEnum;
}
#endregion
private static string GetStoreDisplayName(LqMdxxEntity entity)
{
return entity.Dm ?? entity.Djmd ?? entity.Mdbm ?? entity.Id;
}
private static string BuildStoreDeleteDetailJson(LqMdxxEntity entity, int? beforeStatus)
{
return new
{
before = new
{
entity.Id,
entity.Mdbm,
entity.Dm,
entity.Djmd,
entity.Cs,
status = beforeStatus
},
after = new { status = InvalidStatus }
}.Serialize();
}
private async Task TryWriteBusinessLogAsync(string moduleCode, string actionCode, string bizType, string bizId, string summary, string detailJson = null)
{
try
{
await _businessOperationLogService.WriteAsync(moduleCode, actionCode, bizType, bizId, summary, detailJson);
}
catch (Exception)
{
// 写日志失败不拖垮主业务
}
}
}
}