|
|
@@ -1,4 +1,9 @@
|
|
1
|
|
-using System;
|
|
|
1
|
+//————————————
|
|
|
2
|
+//des:产品管理类
|
|
|
3
|
+//author:zhangkun
|
|
|
4
|
+//addtime:2020-06-10
|
|
|
5
|
+//————————————
|
|
|
6
|
+using System;
|
|
2
|
7
|
using System.Collections.Generic;
|
|
3
|
8
|
using System.Common;
|
|
4
|
9
|
using System.IRepositories;
|
|
|
@@ -21,7 +26,6 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
21
|
26
|
|
|
22
|
27
|
private readonly IBus_ProductRepository _productRepository;
|
|
23
|
28
|
private readonly IBus_ProductClassRepository _productClassRepository;
|
|
24
|
|
-
|
|
25
|
29
|
public ProductController(IBus_ProductRepository productRepository, IBus_ProductClassRepository productClassRepository)
|
|
26
|
30
|
{
|
|
27
|
31
|
_productRepository = productRepository;
|
|
|
@@ -209,31 +213,31 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
209
|
213
|
|
|
210
|
214
|
#region 验证 参数
|
|
211
|
215
|
|
|
212
|
|
- if (input.F_ClassId == 0)
|
|
|
216
|
+ if (input.ClassId == 0)
|
|
213
|
217
|
return Error("请选择分类名称");
|
|
214
|
|
- if (string.IsNullOrEmpty(input.F_ProductName))
|
|
|
218
|
+ if (string.IsNullOrEmpty(input.ProductName))
|
|
215
|
219
|
return Error("请输入产品名称");
|
|
216
|
|
- if (string.IsNullOrEmpty(input.F_ProductShortName))
|
|
|
220
|
+ if (string.IsNullOrEmpty(input.ProductShortName))
|
|
217
|
221
|
return Error("请输入产品简写");
|
|
218
|
|
- if (string.IsNullOrEmpty(input.F_ProductNumber))
|
|
|
222
|
+ if (string.IsNullOrEmpty(input.ProductNumber))
|
|
219
|
223
|
return Error("请输入产品条形码");
|
|
220
|
|
- if (string.IsNullOrEmpty(input.F_ClassName))
|
|
|
224
|
+ if (string.IsNullOrEmpty(input.ClassName))
|
|
221
|
225
|
return Error("请选择分类名称");
|
|
222
|
|
- if (input.F_MarketPrice <= 0)
|
|
|
226
|
+ if (input.MarketPrice <= 0)
|
|
223
|
227
|
return Error("请输入正确市场价");
|
|
224
|
|
- if (input.F_MemberPrice <= 0)
|
|
|
228
|
+ if (input.MemberPrice <= 0)
|
|
225
|
229
|
return Error("请输入正确会员价");
|
|
226
|
|
- if (input.F_SpecialPrice <= 0)
|
|
|
230
|
+ if (input.SpecialPrice <= 0)
|
|
227
|
231
|
return Error("请输入正确特惠价");
|
|
228
|
|
- if (input.F_ProductId <= 0)
|
|
|
232
|
+ if (input.ProductId <= 0)
|
|
229
|
233
|
return Error("请输入正确产品编码");
|
|
230
|
|
- if (string.IsNullOrEmpty(input.F_PinyinShort))
|
|
|
234
|
+ if (string.IsNullOrEmpty(input.PinyinShort))
|
|
231
|
235
|
return Error("请输入正确拼音简码");
|
|
232
|
236
|
#endregion
|
|
233
|
|
- Expression<Func<T_Bus_Product, bool>> eq = a => a.F_ProductName == input.F_ProductName;
|
|
234
|
|
- eq = eq.Or(b => b.F_PinyinShort == input.F_PinyinShort);
|
|
235
|
|
- eq = eq.Or(b => b.F_ProductId == input.F_ProductId);
|
|
236
|
|
- eq = eq.Or(b => b.F_ProductShortName == input.F_ProductShortName);
|
|
|
237
|
+ Expression<Func<T_Bus_Product, bool>> eq = a => a.F_ProductName == input.ProductName;
|
|
|
238
|
+ eq = eq.Or(b => b.F_PinyinShort == input.PinyinShort);
|
|
|
239
|
+ eq = eq.Or(b => b.F_ProductId == input.ProductId);
|
|
|
240
|
+ eq = eq.Or(b => b.F_ProductShortName == input.ProductShortName);
|
|
237
|
241
|
if (await _productRepository.GetCount(eq) > 0)
|
|
238
|
242
|
{
|
|
239
|
243
|
return Error("名称/条形码/简称 有重复");
|
|
|
@@ -242,32 +246,33 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
242
|
246
|
T_Bus_Product T_Bus_ProductModel = new T_Bus_Product();
|
|
243
|
247
|
|
|
244
|
248
|
|
|
245
|
|
- T_Bus_ProductModel.F_ProductId = input.F_ProductId;
|
|
246
|
|
- T_Bus_ProductModel.F_ProductName = input.F_ProductName;
|
|
247
|
|
- T_Bus_ProductModel.F_ProductShortName = input.F_ProductShortName;
|
|
248
|
|
- T_Bus_ProductModel.F_ProductNumber = input.F_ProductNumber;
|
|
249
|
|
- T_Bus_ProductModel.F_PinyinShort = input.F_PinyinShort;
|
|
|
249
|
+ T_Bus_ProductModel.F_ProductId = input.ProductId;
|
|
|
250
|
+ T_Bus_ProductModel.F_ProductName = input.ProductName;
|
|
|
251
|
+ T_Bus_ProductModel.F_ProductShortName = input.ProductShortName;
|
|
|
252
|
+ T_Bus_ProductModel.F_ProductNumber = input.ProductNumber;
|
|
|
253
|
+ T_Bus_ProductModel.F_PinyinShort = input.PinyinShort;
|
|
250
|
254
|
|
|
251
|
|
- T_Bus_ProductModel.F_ClassId = input.F_ClassId;
|
|
252
|
|
- T_Bus_ProductModel.F_ClassName = input.F_ClassName;
|
|
|
255
|
+ T_Bus_ProductModel.F_ClassId = input.ClassId;
|
|
|
256
|
+ T_Bus_ProductModel.F_ClassName = input.ClassName;
|
|
253
|
257
|
|
|
254
|
258
|
|
|
255
|
|
- T_Bus_ProductModel.F_MarketPrice = input.F_MarketPrice;
|
|
256
|
|
- T_Bus_ProductModel.F_MemberPrice = input.F_MemberPrice;
|
|
257
|
|
- T_Bus_ProductModel.F_SpecialPrice = input.F_SpecialPrice;
|
|
258
|
|
- T_Bus_ProductModel.F_Integral = input.F_Integral;
|
|
|
259
|
+ T_Bus_ProductModel.F_MarketPrice = input.MarketPrice;
|
|
|
260
|
+ T_Bus_ProductModel.F_MemberPrice = input.MemberPrice;
|
|
|
261
|
+ T_Bus_ProductModel.F_SpecialPrice = input.SpecialPrice;
|
|
|
262
|
+ T_Bus_ProductModel.F_Integral = input.Integral;
|
|
259
|
263
|
|
|
260
|
|
- T_Bus_ProductModel.F_Address = input.F_Address;
|
|
261
|
|
- T_Bus_ProductModel.F_Des = input.F_Des;
|
|
262
|
|
- T_Bus_ProductModel.F_Factory = input.F_Factory;
|
|
263
|
|
- T_Bus_ProductModel.F_Supplier = input.F_Supplier;
|
|
|
264
|
+ T_Bus_ProductModel.F_Address = input.Address;
|
|
|
265
|
+ T_Bus_ProductModel.F_Des = input.Des;
|
|
|
266
|
+ T_Bus_ProductModel.F_Factory = input.Factory;
|
|
|
267
|
+ T_Bus_ProductModel.F_Supplier = input.Supplier;
|
|
|
268
|
+ T_Bus_ProductModel.F_IsDelete = 1;
|
|
264
|
269
|
|
|
265
|
|
- T_Bus_ProductModel.F_IsSale = input.F_IsSale = input.F_OnSaleBegin < DateTime.Now;
|
|
266
|
|
- T_Bus_ProductModel.F_Weight = input.F_Weight;
|
|
267
|
|
- if (input.F_OnSaleBegin != null)
|
|
268
|
|
- { T_Bus_ProductModel.F_OnSaleBegin = input.F_OnSaleBegin.GetValueOrDefault().ToString("yyyy-MM-dd 00:00:01").ObjToDate(); }
|
|
269
|
|
- if (input.F_OnSaleEnd != null)
|
|
270
|
|
- { T_Bus_ProductModel.F_OnSaleEnd = input.F_OnSaleEnd.GetValueOrDefault().ToString("yyyy-MM-dd 23:59:59").ObjToDate(); }
|
|
|
270
|
+ T_Bus_ProductModel.F_IsSale = input.IsSale = input.OnSaleBegin < DateTime.Now;
|
|
|
271
|
+ T_Bus_ProductModel.F_Weight = input.Weight;
|
|
|
272
|
+ if (input.OnSaleBegin != null)
|
|
|
273
|
+ { T_Bus_ProductModel.F_OnSaleBegin = input.OnSaleBegin.GetValueOrDefault().ToString("yyyy-MM-dd 00:00:01").ObjToDate(); }
|
|
|
274
|
+ if (input.OnSaleEnd != null)
|
|
|
275
|
+ { T_Bus_ProductModel.F_OnSaleEnd = input.OnSaleEnd.GetValueOrDefault().ToString("yyyy-MM-dd 23:59:59").ObjToDate(); }
|
|
271
|
276
|
|
|
272
|
277
|
|
|
273
|
278
|
|
|
|
@@ -296,56 +301,56 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
296
|
301
|
|
|
297
|
302
|
#region 验证 参数
|
|
298
|
303
|
|
|
299
|
|
- if (input.F_ClassId == 0)
|
|
|
304
|
+ if (input.ClassId == 0)
|
|
300
|
305
|
return Error("请选择分类名称");
|
|
301
|
|
- if (string.IsNullOrEmpty(input.F_ProductName))
|
|
|
306
|
+ if (string.IsNullOrEmpty(input.ProductName))
|
|
302
|
307
|
return Error("请输入产品名称");
|
|
303
|
|
- if (string.IsNullOrEmpty(input.F_ProductShortName))
|
|
|
308
|
+ if (string.IsNullOrEmpty(input.ProductShortName))
|
|
304
|
309
|
return Error("请输入产品简写");
|
|
305
|
|
- if (string.IsNullOrEmpty(input.F_ProductNumber))
|
|
|
310
|
+ if (string.IsNullOrEmpty(input.ProductNumber))
|
|
306
|
311
|
return Error("请输入产品条形码");
|
|
307
|
|
- if (string.IsNullOrEmpty(input.F_ClassName))
|
|
|
312
|
+ if (string.IsNullOrEmpty(input.ClassName))
|
|
308
|
313
|
return Error("请选择分类名称");
|
|
309
|
|
- if (input.F_MarketPrice <= 0)
|
|
|
314
|
+ if (input.MarketPrice <= 0)
|
|
310
|
315
|
return Error("请输入正确市场价");
|
|
311
|
|
- if (input.F_MemberPrice <= 0)
|
|
|
316
|
+ if (input.MemberPrice <= 0)
|
|
312
|
317
|
return Error("请输入正确会员价");
|
|
313
|
|
- if (input.F_SpecialPrice <= 0)
|
|
|
318
|
+ if (input.SpecialPrice <= 0)
|
|
314
|
319
|
return Error("请输入正确特惠价");
|
|
315
|
|
- if (input.F_ProductId <= 0)
|
|
|
320
|
+ if (input.ProductId <= 0)
|
|
316
|
321
|
return Error("产品ID不能修改");
|
|
317
|
|
- if (string.IsNullOrEmpty(input.F_PinyinShort))
|
|
|
322
|
+ if (string.IsNullOrEmpty(input.PinyinShort))
|
|
318
|
323
|
return Error("请输入正确拼音简码");
|
|
319
|
324
|
#endregion
|
|
320
|
325
|
|
|
321
|
|
- T_Bus_Product T_Bus_ProductModel = await _productRepository.GetSingle(a => a.F_ProductId == input.F_ProductId);
|
|
|
326
|
+ T_Bus_Product T_Bus_ProductModel = await _productRepository.GetSingle(a => a.F_ProductId == input.ProductId);
|
|
322
|
327
|
|
|
323
|
328
|
if (T_Bus_ProductModel == null)
|
|
324
|
329
|
return Error("如需新添加,请点击新增按钮,此记录不存在");
|
|
325
|
330
|
|
|
326
|
|
- T_Bus_ProductModel.F_ProductName = input.F_ProductName;
|
|
327
|
|
- T_Bus_ProductModel.F_ProductShortName = input.F_ProductShortName;
|
|
328
|
|
- T_Bus_ProductModel.F_ProductNumber = input.F_ProductNumber;
|
|
329
|
|
- T_Bus_ProductModel.F_PinyinShort = input.F_PinyinShort;
|
|
|
331
|
+ T_Bus_ProductModel.F_ProductName = input.ProductName;
|
|
|
332
|
+ T_Bus_ProductModel.F_ProductShortName = input.ProductShortName;
|
|
|
333
|
+ T_Bus_ProductModel.F_ProductNumber = input.ProductNumber;
|
|
|
334
|
+ T_Bus_ProductModel.F_PinyinShort = input.PinyinShort;
|
|
330
|
335
|
|
|
331
|
|
- T_Bus_ProductModel.F_ClassId = input.F_ClassId;
|
|
332
|
|
- T_Bus_ProductModel.F_ClassName = input.F_ClassName;
|
|
|
336
|
+ T_Bus_ProductModel.F_ClassId = input.ClassId;
|
|
|
337
|
+ T_Bus_ProductModel.F_ClassName = input.ClassName;
|
|
333
|
338
|
|
|
334
|
339
|
|
|
335
|
|
- T_Bus_ProductModel.F_MarketPrice = input.F_MarketPrice;
|
|
336
|
|
- T_Bus_ProductModel.F_MemberPrice = input.F_MemberPrice;
|
|
337
|
|
- T_Bus_ProductModel.F_SpecialPrice = input.F_SpecialPrice;
|
|
338
|
|
- T_Bus_ProductModel.F_Integral = input.F_Integral;
|
|
|
340
|
+ T_Bus_ProductModel.F_MarketPrice = input.MarketPrice;
|
|
|
341
|
+ T_Bus_ProductModel.F_MemberPrice = input.MemberPrice;
|
|
|
342
|
+ T_Bus_ProductModel.F_SpecialPrice = input.SpecialPrice;
|
|
|
343
|
+ T_Bus_ProductModel.F_Integral = input.Integral;
|
|
339
|
344
|
|
|
340
|
|
- T_Bus_ProductModel.F_Address = input.F_Address;
|
|
341
|
|
- T_Bus_ProductModel.F_Des = input.F_Des;
|
|
342
|
|
- T_Bus_ProductModel.F_Factory = input.F_Factory;
|
|
343
|
|
- T_Bus_ProductModel.F_Supplier = input.F_Supplier;
|
|
|
345
|
+ T_Bus_ProductModel.F_Address = input.Address;
|
|
|
346
|
+ T_Bus_ProductModel.F_Des = input.Des;
|
|
|
347
|
+ T_Bus_ProductModel.F_Factory = input.Factory;
|
|
|
348
|
+ T_Bus_ProductModel.F_Supplier = input.Supplier;
|
|
344
|
349
|
|
|
345
|
|
- T_Bus_ProductModel.F_IsSale = input.F_IsSale = input.F_OnSaleBegin < DateTime.Now;//此状态暂不启用 以时间判断
|
|
346
|
|
- T_Bus_ProductModel.F_Weight = input.F_Weight;
|
|
347
|
|
- T_Bus_ProductModel.F_OnSaleBegin = input.F_OnSaleBegin ?? input.F_OnSaleBegin.GetValueOrDefault().ToString("yyyy-MM-dd 00:00:01").ObjToDate();
|
|
348
|
|
- T_Bus_ProductModel.F_OnSaleEnd = input.F_OnSaleEnd ?? input.F_OnSaleEnd.GetValueOrDefault().ToString("yyyy-MM-dd 23:59:59").ObjToDate();
|
|
|
350
|
+ T_Bus_ProductModel.F_IsSale = input.IsSale = input.OnSaleBegin < DateTime.Now;//此状态暂不启用 以时间判断
|
|
|
351
|
+ T_Bus_ProductModel.F_Weight = input.Weight;
|
|
|
352
|
+ T_Bus_ProductModel.F_OnSaleBegin = input.OnSaleBegin ?? input.OnSaleBegin.GetValueOrDefault().ToString("yyyy-MM-dd 00:00:01").ObjToDate();
|
|
|
353
|
+ T_Bus_ProductModel.F_OnSaleEnd = input.OnSaleEnd ?? input.OnSaleEnd.GetValueOrDefault().ToString("yyyy-MM-dd 23:59:59").ObjToDate();
|
|
349
|
354
|
|
|
350
|
355
|
|
|
351
|
356
|
|
|
|
@@ -430,63 +435,138 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
430
|
435
|
public async Task<IActionResult> ProductList(ProductInput input)
|
|
431
|
436
|
{
|
|
432
|
437
|
|
|
433
|
|
-
|
|
434
|
438
|
#region 拼接条件
|
|
435
|
439
|
|
|
436
|
|
- Expression<Func<T_Bus_Product, bool>> eq = a => a.F_IsDelete == 0;
|
|
|
440
|
+ Expression<Func<T_Bus_Product, bool>> eq = a => a.F_IsDelete == 1;
|
|
437
|
441
|
|
|
438
|
|
- if (input.F_ClassId > 0)
|
|
439
|
|
- eq = eq.And(a => a.F_ProductId == input.F_ProductId);
|
|
440
|
|
- if (!string.IsNullOrEmpty(input.F_ClassName))
|
|
|
442
|
+ if (input.ClassId > 0)
|
|
|
443
|
+ eq = eq.And(a => a.F_ProductId == input.ProductId);
|
|
|
444
|
+ if (!string.IsNullOrEmpty(input.ClassName))
|
|
441
|
445
|
{
|
|
442
|
|
- eq = eq.And(a => a.F_ClassName.Contains(input.F_ClassName));
|
|
|
446
|
+ eq = eq.And(a => a.F_ClassName.Contains(input.ClassName));
|
|
443
|
447
|
// eq.Or(a => a.F_ClassShortName.Contains(input.F_ClassName));
|
|
444
|
448
|
}
|
|
445
|
449
|
//产品名/标题
|
|
446
|
|
- if (!string.IsNullOrEmpty(input.F_ProductName))
|
|
|
450
|
+ if (!string.IsNullOrEmpty(input.ProductName))
|
|
447
|
451
|
{
|
|
448
|
|
- eq = eq.And(a => a.F_ProductName.Contains(input.F_ProductName));
|
|
|
452
|
+ eq = eq.And(a => a.F_ProductName.Contains(input.ProductName));
|
|
449
|
453
|
}
|
|
450
|
454
|
//指定分类
|
|
451
|
|
- if (input.F_ClassId > 0)
|
|
|
455
|
+ if (input.ClassId > 0)
|
|
452
|
456
|
{
|
|
453
|
|
- eq = eq.And(a => a.F_ClassId == input.F_ClassId);
|
|
|
457
|
+ eq = eq.And(a => a.F_ClassId == input.ClassId);
|
|
454
|
458
|
}
|
|
455
|
459
|
//分类名称
|
|
456
|
|
- if (!string.IsNullOrEmpty(input.F_ClassName))
|
|
|
460
|
+ if (!string.IsNullOrEmpty(input.ClassName))
|
|
457
|
461
|
{
|
|
458
|
|
- eq = eq.And(a => a.F_ClassName.Contains(input.F_ClassName));
|
|
|
462
|
+ eq = eq.And(a => a.F_ClassName.Contains(input.ClassName));
|
|
459
|
463
|
}
|
|
460
|
464
|
//拼音简码
|
|
461
|
|
- if (!string.IsNullOrEmpty(input.F_PinyinShort))
|
|
|
465
|
+ if (!string.IsNullOrEmpty(input.PinyinShort))
|
|
462
|
466
|
{
|
|
463
|
|
- eq = eq.And(a => a.F_PinyinShort == input.F_PinyinShort);
|
|
|
467
|
+ eq = eq.And(a => a.F_PinyinShort == input.PinyinShort);
|
|
464
|
468
|
}
|
|
465
|
469
|
|
|
466
|
470
|
//条形码
|
|
467
|
|
- if (!string.IsNullOrEmpty(input.F_ProductNumber))
|
|
|
471
|
+ if (!string.IsNullOrEmpty(input.ProductNumber))
|
|
468
|
472
|
{
|
|
469
|
|
- eq = eq.And(a => a.F_ProductNumber == input.F_ProductNumber);
|
|
|
473
|
+ eq = eq.And(a => a.F_ProductNumber == input.ProductNumber);
|
|
470
|
474
|
}
|
|
471
|
475
|
//简称/编码/副标题
|
|
472
|
|
- if (!string.IsNullOrEmpty(input.F_ProductShortName))
|
|
|
476
|
+ if (!string.IsNullOrEmpty(input.ProductShortName))
|
|
473
|
477
|
{
|
|
474
|
|
- eq = eq.And(a => a.F_ProductShortName == input.F_ProductShortName);
|
|
|
478
|
+ eq = eq.And(a => a.F_ProductShortName == input.ProductShortName);
|
|
475
|
479
|
}
|
|
476
|
480
|
//标签
|
|
477
|
|
- if (!string.IsNullOrEmpty(input.F_Tag))
|
|
|
481
|
+ if (!string.IsNullOrEmpty(input.Tag))
|
|
478
|
482
|
{
|
|
479
|
|
- eq.And(a => a.F_Tag.Contains(input.F_Tag));
|
|
|
483
|
+ eq.And(a => a.F_Tag.Contains(input.Tag));
|
|
480
|
484
|
}
|
|
481
|
485
|
|
|
482
|
486
|
#endregion
|
|
483
|
487
|
|
|
484
|
|
-
|
|
485
|
|
- List<T_Bus_Product> list = await _productRepository.GetListALL(eq);
|
|
|
488
|
+ int count = 0;
|
|
|
489
|
+ var list = await _productRepository.GetListByPage(eq,new PageModel{PageCount= count, PageSize=5,PageIndex=1 });
|
|
486
|
490
|
|
|
487
|
491
|
return Success("成功", list);
|
|
488
|
492
|
|
|
489
|
493
|
}
|
|
|
494
|
+ /// <summary>
|
|
|
495
|
+ /// 分页获取产品列表
|
|
|
496
|
+ /// </summary>
|
|
|
497
|
+ /// <param name="input">筛选字段</param>
|
|
|
498
|
+ /// <param name="pagesize"></param>
|
|
|
499
|
+ /// <param name="pageindex"></param>
|
|
|
500
|
+ /// <returns></returns>
|
|
|
501
|
+ [HttpPost("getlistbypage")]
|
|
|
502
|
+ public async Task<IActionResult> GetListByPage([FromBody]ProductInput input, int pagesize, int pageindex)
|
|
|
503
|
+ {
|
|
|
504
|
+ List<IConditionalModel> conModels = new List<IConditionalModel>();
|
|
|
505
|
+ #region 条件筛选
|
|
|
506
|
+
|
|
|
507
|
+
|
|
|
508
|
+ conModels.Add(new ConditionalModel() { FieldName = "F_IsDelete", ConditionalType = ConditionalType.Equal, FieldValue = ((int)EnumDelState.Enabled).ToString() });
|
|
|
509
|
+
|
|
|
510
|
+ if (input.ProductId > 0)
|
|
|
511
|
+ {
|
|
|
512
|
+ conModels.Add(new ConditionalModel() { FieldName = "F_ProductId", ConditionalType = ConditionalType.Equal, FieldValue = input.ProductId.ToString() });
|
|
|
513
|
+ }
|
|
|
514
|
+ //指定分类
|
|
|
515
|
+ if (input.ClassId > 0)
|
|
|
516
|
+ {
|
|
|
517
|
+ conModels.Add(new ConditionalModel() { FieldName = "F_ClassId", ConditionalType = ConditionalType.Equal, FieldValue = input.ClassId.ToString() });
|
|
|
518
|
+ }
|
|
|
519
|
+
|
|
|
520
|
+ if (!string.IsNullOrEmpty(input.ClassName))
|
|
|
521
|
+ {
|
|
|
522
|
+ conModels.Add(new ConditionalModel() { FieldName = "F_ClassName", ConditionalType = ConditionalType.Like, FieldValue = input.ClassName });
|
|
|
523
|
+
|
|
|
524
|
+ }
|
|
|
525
|
+ //产品名/标题
|
|
|
526
|
+ if (!string.IsNullOrEmpty(input.ProductName))
|
|
|
527
|
+ {
|
|
|
528
|
+ conModels.Add(new ConditionalModel() { FieldName = "F_ProductName", ConditionalType = ConditionalType.Like, FieldValue = input.ProductName });
|
|
|
529
|
+ }
|
|
|
530
|
+ //分类名称
|
|
|
531
|
+ if (!string.IsNullOrEmpty(input.ClassName))
|
|
|
532
|
+ {
|
|
|
533
|
+ conModels.Add(new ConditionalModel() { FieldName = "F_ClassName", ConditionalType = ConditionalType.Like, FieldValue = input.ClassName });
|
|
|
534
|
+ }
|
|
|
535
|
+ //拼音简码
|
|
|
536
|
+ if (!string.IsNullOrEmpty(input.PinyinShort))
|
|
|
537
|
+ {
|
|
|
538
|
+ conModels.Add(new ConditionalModel() { FieldName = "F_PinyinShort", ConditionalType = ConditionalType.Equal, FieldValue = input.PinyinShort });
|
|
|
539
|
+ }
|
|
|
540
|
+
|
|
|
541
|
+ //条形码
|
|
|
542
|
+ if (!string.IsNullOrEmpty(input.ProductNumber))
|
|
|
543
|
+ {
|
|
|
544
|
+ conModels.Add(new ConditionalModel() { FieldName = "F_ProductNumber", ConditionalType = ConditionalType.Equal, FieldValue = input.ProductNumber });
|
|
|
545
|
+ }
|
|
|
546
|
+ //简称/编码/副标题
|
|
|
547
|
+ if (!string.IsNullOrEmpty(input.ProductShortName))
|
|
|
548
|
+ {
|
|
|
549
|
+ conModels.Add(new ConditionalModel() { FieldName = "F_ProductShortName", ConditionalType = ConditionalType.Like, FieldValue = input.ProductShortName });
|
|
|
550
|
+ }
|
|
|
551
|
+ //标签
|
|
|
552
|
+ if (!string.IsNullOrEmpty(input.Tag))
|
|
|
553
|
+ {
|
|
|
554
|
+ conModels.Add(new ConditionalModel() { FieldName = "F_Tag", ConditionalType = ConditionalType.Equal, FieldValue = input.Tag });
|
|
|
555
|
+ }
|
|
|
556
|
+
|
|
|
557
|
+
|
|
|
558
|
+ #endregion
|
|
|
559
|
+ int recordCount =0;
|
|
|
560
|
+ var list = await _productRepository.GetListByPage(conModels, new PageModel() { PageIndex = pageindex, PageSize = pagesize, PageCount = recordCount });
|
|
|
561
|
+ var obj = new
|
|
|
562
|
+ {
|
|
|
563
|
+ state = "success",
|
|
|
564
|
+ message = "成功",
|
|
|
565
|
+ rows = list,
|
|
|
566
|
+ total= recordCount
|
|
|
567
|
+ };
|
|
|
568
|
+ return Content(obj.ToJson());
|
|
|
569
|
+ }
|
|
490
|
570
|
|
|
491
|
571
|
|
|
492
|
572
|
#endregion
|
|
|
@@ -497,13 +577,13 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
497
|
577
|
/// 更新库存(对方库存变化 入库 出库 时做更新) 订单发货时,对面库存 出库要对应订单,以便跟踪
|
|
498
|
578
|
/// </summary>
|
|
499
|
579
|
/// <param name="input">目前暂定Id唯一标识更新如果不方便可以以F_ProductName,如果那边更好操作,顺序上这边先有产品的话可以以id操作,或者以条形码操作</param>
|
|
|
580
|
+ /// 基类BaseController继承的不是[ApiController],也没有加[ApiController]头标 所以用到json序列化传值 和测试工具raw传值必须加[FromBody]
|
|
500
|
581
|
/// <returns></returns>
|
|
501
|
582
|
[HttpPost("updatestock")]
|
|
502
|
|
- public async Task<IActionResult> UpdateStock(List<ProductInput> input)
|
|
|
583
|
+ public async Task<IActionResult> UpdateStock([FromBody]List<ProductInput> input)
|
|
503
|
584
|
{
|
|
504
|
585
|
|
|
505
|
586
|
#region 验证 参数
|
|
506
|
|
- //List<ProductInput> m = input;
|
|
507
|
587
|
if (input.Count <= 0)
|
|
508
|
588
|
return Error("参数缺失,没有数据");
|
|
509
|
589
|
List<T_Bus_Product> listmodel = new List<T_Bus_Product>();
|
|
|
@@ -511,15 +591,18 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
511
|
591
|
foreach (ProductInput m in input)
|
|
512
|
592
|
{
|
|
513
|
593
|
// return Success(m.F_ProductId.ToString() + ":" + m.F_Stock.ToString());
|
|
514
|
|
- if (!string.IsNullOrEmpty(m.F_ProductName))
|
|
|
594
|
+ if (!string.IsNullOrEmpty(m.ProductName))
|
|
515
|
595
|
return Error("参数缺失产品名称");
|
|
516
|
|
- if (m.F_ProductId <= 0)
|
|
|
596
|
+ if (m.ProductId <= 0)
|
|
517
|
597
|
return Error("参数缺失产品id");
|
|
518
|
|
- if (m.F_Stock < 0)
|
|
|
598
|
+ if (m.Stock < 0)
|
|
519
|
599
|
return Error("参数缺失库存");
|
|
520
|
|
- T_Bus_Product model = await _productRepository.GetSingle(a => a.F_ProductId == m.F_ProductId);
|
|
521
|
|
- model.F_Stock = m.F_Stock;
|
|
522
|
|
- listmodel.Add(model);
|
|
|
600
|
+ T_Bus_Product model = await _productRepository.GetSingle(a => a.F_ProductId == m.ProductId);
|
|
|
601
|
+ if (model != null)
|
|
|
602
|
+ {
|
|
|
603
|
+ model.F_Stock = m.Stock;
|
|
|
604
|
+ listmodel.Add(model);
|
|
|
605
|
+ }
|
|
523
|
606
|
}
|
|
524
|
607
|
|
|
525
|
608
|
#endregion
|