|
|
@@ -55,24 +55,25 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
55
|
55
|
#region 验证 参数
|
|
56
|
56
|
|
|
57
|
57
|
|
|
58
|
|
- if (string.IsNullOrEmpty(input.F_ClassName))
|
|
|
58
|
+ if (string.IsNullOrEmpty(input.ClassName))
|
|
59
|
59
|
return Error("请输入分类名称");
|
|
60
|
|
- if (string.IsNullOrEmpty(input.F_ClassShortName))
|
|
|
60
|
+ if (string.IsNullOrEmpty(input.ClassShortName))
|
|
61
|
61
|
return Error("请输入分类简写");
|
|
62
|
62
|
|
|
63
|
63
|
#endregion
|
|
64
|
|
- Expression<Func<T_Bus_ProductClass, bool>> eq = a => a.F_ClassName == input.F_ClassName;
|
|
65
|
|
- if (await _productClassRepository.GetCount(eq.Or(b => b.F_ClassShortName == input.F_ClassShortName)) > 0)
|
|
|
64
|
+ Expression<Func<T_Bus_ProductClass, bool>> eq = a => a.F_ClassName == input.ClassName;
|
|
|
65
|
+ if (await _productClassRepository.GetCount(eq.Or(b => b.F_ClassShortName == input.ClassShortName)) > 0)
|
|
66
|
66
|
{
|
|
67
|
67
|
return Error("分类/简写名称重复");
|
|
68
|
68
|
}
|
|
69
|
69
|
T_Bus_ProductClass T_Bus_ProductClassModel = new T_Bus_ProductClass();
|
|
70
|
|
- if (input.F_ClassId != 0)
|
|
71
|
|
- T_Bus_ProductClassModel.F_ClassId = input.F_ClassId;
|
|
|
70
|
+ if (input.ClassId != 0)
|
|
|
71
|
+ T_Bus_ProductClassModel.F_ClassId = input.ClassId;
|
|
72
|
72
|
|
|
73
|
|
- T_Bus_ProductClassModel.F_ClassShortName = input.F_ClassShortName;
|
|
74
|
|
- T_Bus_ProductClassModel.F_parentId = input.F_parentId;
|
|
75
|
|
- T_Bus_ProductClassModel.F_ClassName = input.F_ClassName;
|
|
|
73
|
+ T_Bus_ProductClassModel.F_ClassShortName = input.ClassShortName;
|
|
|
74
|
+ T_Bus_ProductClassModel.F_ParentId = input.ParentId;
|
|
|
75
|
+ T_Bus_ProductClassModel.F_Sort = 10000;
|
|
|
76
|
+ T_Bus_ProductClassModel.F_ClassName = input.ClassName;
|
|
76
|
77
|
T_Bus_ProductClassModel.F_UserName = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Name).Value;
|
|
77
|
78
|
T_Bus_ProductClassModel.F_UserId = int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.PrimarySid).Value, 0);
|
|
78
|
79
|
|
|
|
@@ -100,18 +101,18 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
100
|
101
|
#region 验证 参数
|
|
101
|
102
|
|
|
102
|
103
|
|
|
103
|
|
- if (string.IsNullOrEmpty(input.F_ClassName))
|
|
|
104
|
+ if (string.IsNullOrEmpty(input.ClassName))
|
|
104
|
105
|
return Error("请输入分类名称");
|
|
105
|
|
- if (string.IsNullOrEmpty(input.F_ClassShortName))
|
|
|
106
|
+ if (string.IsNullOrEmpty(input.ClassShortName))
|
|
106
|
107
|
return Error("请输入分类简写");
|
|
107
|
|
- if (input.F_ClassId <= 0)
|
|
|
108
|
+ if (input.ClassId <= 0)
|
|
108
|
109
|
return Error("缺少参数");
|
|
109
|
110
|
#endregion
|
|
110
|
|
- T_Bus_ProductClass T_Bus_ProductClassModel = await _productClassRepository.GetSingle(a => a.F_ClassId == input.F_ClassId);
|
|
|
111
|
+ T_Bus_ProductClass T_Bus_ProductClassModel = await _productClassRepository.GetSingle(a => a.F_ClassId == input.ClassId);
|
|
|
112
|
+
|
|
|
113
|
+ T_Bus_ProductClassModel.F_ClassName = input.ClassName;
|
|
|
114
|
+ T_Bus_ProductClassModel.F_ClassShortName = input.ClassShortName;
|
|
111
|
115
|
|
|
112
|
|
- T_Bus_ProductClassModel.F_ClassName = input.F_ClassName;
|
|
113
|
|
- T_Bus_ProductClassModel.F_ClassShortName = input.F_ClassShortName;
|
|
114
|
|
- T_Bus_ProductClassModel.F_parentId = input.F_parentId;
|
|
115
|
116
|
|
|
116
|
117
|
T_Bus_ProductClassModel.F_UserName = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Name).Value;
|
|
117
|
118
|
T_Bus_ProductClassModel.F_UserId = int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.PrimarySid).Value, 0);
|
|
|
@@ -119,11 +120,11 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
119
|
120
|
|
|
120
|
121
|
if (await _productClassRepository.Update(T_Bus_ProductClassModel))
|
|
121
|
122
|
{
|
|
122
|
|
- return Success("新增商品分类成功");
|
|
|
123
|
+ return Success("保存商品分类成功");
|
|
123
|
124
|
}
|
|
124
|
125
|
else
|
|
125
|
126
|
{
|
|
126
|
|
- return Error("新增分类失败,请重试!");
|
|
|
127
|
+ return Error("保存分类失败,请重试!");
|
|
127
|
128
|
}
|
|
128
|
129
|
}
|
|
129
|
130
|
|
|
|
@@ -162,33 +163,28 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
162
|
163
|
public async Task<IActionResult> ProductClassList(ProductClassInput input)
|
|
163
|
164
|
{
|
|
164
|
165
|
|
|
165
|
|
- #region 验证 参数
|
|
166
|
|
-
|
|
167
|
|
- if (input.F_ClassId <= 0)
|
|
168
|
|
- return Error("缺少参数");
|
|
169
|
|
- #endregion
|
|
170
|
166
|
|
|
171
|
167
|
|
|
172
|
168
|
#region 拼接条件
|
|
173
|
169
|
|
|
174
|
170
|
Expression<Func<T_Bus_ProductClass, bool>> eq = a => a.F_ClassId > 0;
|
|
175
|
171
|
|
|
176
|
|
- if (input.F_ClassId > 0)
|
|
177
|
|
- eq = eq.And(a => a.F_ClassId == input.F_ClassId);
|
|
178
|
|
- if (!string.IsNullOrEmpty(input.F_ClassName))
|
|
|
172
|
+ if (input.ClassId > 0)
|
|
|
173
|
+ eq = eq.And(a => a.F_ClassId == input.ClassId);
|
|
|
174
|
+ if (!string.IsNullOrEmpty(input.ClassName))
|
|
179
|
175
|
{
|
|
180
|
|
- eq = eq.And(a => a.F_ClassName.Contains(input.F_ClassName));
|
|
181
|
|
- // eq.Or(a => a.F_ClassShortName.Contains(input.F_ClassName));
|
|
|
176
|
+ eq = eq.And(a => a.F_ClassName.Contains(input.ClassName));
|
|
182
|
177
|
}
|
|
183
|
|
- if (input.F_parentId > 0)
|
|
|
178
|
+ if (!string.IsNullOrEmpty(input.ClassShortName))
|
|
184
|
179
|
{
|
|
185
|
|
- eq = eq.And(a => a.F_parentId == input.F_parentId);
|
|
|
180
|
+ eq = eq.And(a => a.F_ClassShortName.Contains(input.ClassShortName));
|
|
186
|
181
|
}
|
|
187
|
|
- if (input.F_parentId == -1)
|
|
|
182
|
+ if (input.ParentId >= 0)
|
|
188
|
183
|
{
|
|
189
|
|
- eq = eq.And(a => a.F_parentId == 0);
|
|
|
184
|
+ eq = eq.And(a => a.F_ParentId == input.ParentId);
|
|
190
|
185
|
}
|
|
191
|
186
|
|
|
|
187
|
+
|
|
192
|
188
|
#endregion
|
|
193
|
189
|
|
|
194
|
190
|
|
|
|
@@ -436,7 +432,10 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
436
|
432
|
{
|
|
437
|
433
|
|
|
438
|
434
|
#region 拼接条件
|
|
439
|
|
-
|
|
|
435
|
+ if (input.Limit <= 0)
|
|
|
436
|
+ {
|
|
|
437
|
+ input.Limit = 100000;
|
|
|
438
|
+ }
|
|
440
|
439
|
Expression<Func<T_Bus_Product, bool>> eq = a => a.F_IsDelete == 1;
|
|
441
|
440
|
|
|
442
|
441
|
if (input.ClassId > 0)
|
|
|
@@ -486,7 +485,7 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
486
|
485
|
#endregion
|
|
487
|
486
|
|
|
488
|
487
|
RefAsync<int> count = 0;
|
|
489
|
|
- var list = await _productRepository.GetListByPage(eq, new MyPageModel() { PageIndex = 1, PageSize = 20, PageCount = count });
|
|
|
488
|
+ var list = await _productRepository.GetListByPage(eq, new MyPageModel() { PageIndex = 1, PageSize = input.Limit, PageCount = count });
|
|
490
|
489
|
|
|
491
|
490
|
return Success("成功", list);
|
|
492
|
491
|
|
|
|
@@ -558,14 +557,8 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
558
|
557
|
#endregion
|
|
559
|
558
|
int recordCount =0;
|
|
560
|
559
|
var list = await _productRepository.GetListByPage(conModels, new MyPageModel() { 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());
|
|
|
560
|
+
|
|
|
561
|
+ return Success("成功", list);
|
|
569
|
562
|
}
|
|
570
|
563
|
|
|
571
|
564
|
|
|
|
@@ -591,8 +584,8 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
591
|
584
|
foreach (ProductInput m in input)
|
|
592
|
585
|
{
|
|
593
|
586
|
// return Success(m.F_ProductId.ToString() + ":" + m.F_Stock.ToString());
|
|
594
|
|
- if (!string.IsNullOrEmpty(m.ProductName))
|
|
595
|
|
- return Error("参数缺失产品名称");
|
|
|
587
|
+ //if (!string.IsNullOrEmpty(m.ProductName))
|
|
|
588
|
+ // return Error("参数缺失产品名称");
|
|
596
|
589
|
if (m.ProductId <= 0)
|
|
597
|
590
|
return Error("参数缺失产品id");
|
|
598
|
591
|
if (m.Stock < 0)
|
|
|
@@ -606,7 +599,7 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
606
|
599
|
}
|
|
607
|
600
|
|
|
608
|
601
|
#endregion
|
|
609
|
|
- //此字段更新单独字段优先
|
|
|
602
|
+ //此字段更新单独字段
|
|
610
|
603
|
if (await _productRepository.UpdateListToColumns(listmodel, it => new { it.F_Stock }))
|
|
611
|
604
|
return Success("更新库存成功");
|
|
612
|
605
|
else
|