|
|
@@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Authorization;
|
|
11
|
11
|
using Microsoft.AspNetCore.Http;
|
|
12
|
12
|
using Microsoft.AspNetCore.Mvc;
|
|
13
|
13
|
using SqlSugar;
|
|
14
|
|
-using TVShoppingCallCenter_ZLJ.Models.Dtos;
|
|
|
14
|
+using TVShoppingCallCenter_ZLJ.Models.Inputs;
|
|
15
|
15
|
|
|
16
|
16
|
namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
17
|
17
|
{
|
|
|
@@ -45,7 +45,7 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
45
|
45
|
/// <param name="input"></param>
|
|
46
|
46
|
/// <returns></returns>
|
|
47
|
47
|
[HttpPost("addproductclass")]
|
|
48
|
|
- public async Task<IActionResult> AddProductClass(ProductClassDto input)
|
|
|
48
|
+ public async Task<IActionResult> AddProductClass(ProductClassInput input)
|
|
49
|
49
|
{
|
|
50
|
50
|
|
|
51
|
51
|
#region 验证 参数
|
|
|
@@ -57,6 +57,11 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
57
|
57
|
return Error("请输入分类简写");
|
|
58
|
58
|
|
|
59
|
59
|
#endregion
|
|
|
60
|
+ Expression<Func<T_Bus_ProductClass, bool>> eq = a => a.F_ClassName == input.F_ClassName;
|
|
|
61
|
+ if (await _productClassRepository.GetCount(eq.Or(b => b.F_ClassShortName == input.F_ClassShortName)) > 0)
|
|
|
62
|
+ {
|
|
|
63
|
+ return Error("分类/简写名称重复");
|
|
|
64
|
+ }
|
|
60
|
65
|
T_Bus_ProductClass T_Bus_ProductClassModel = new T_Bus_ProductClass();
|
|
61
|
66
|
if (input.F_ClassId != 0)
|
|
62
|
67
|
T_Bus_ProductClassModel.F_ClassId = input.F_ClassId;
|
|
|
@@ -85,7 +90,7 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
85
|
90
|
/// <param name="input"></param>
|
|
86
|
91
|
/// <returns></returns>
|
|
87
|
92
|
[HttpPost("updateproductclass")]
|
|
88
|
|
- public async Task<IActionResult> UpdateProductClass(ProductClassDto input)
|
|
|
93
|
+ public async Task<IActionResult> UpdateProductClass(ProductClassInput input)
|
|
89
|
94
|
{
|
|
90
|
95
|
|
|
91
|
96
|
#region 验证 参数
|
|
|
@@ -121,21 +126,20 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
121
|
126
|
/// <summary>
|
|
122
|
127
|
/// 删除商品分类
|
|
123
|
128
|
/// </summary>
|
|
124
|
|
- /// <param name="input"></param>
|
|
|
129
|
+ /// <param name="ids">格式 ,1,2,3,4,</param>
|
|
125
|
130
|
/// <returns></returns>
|
|
126
|
131
|
[HttpPost("deleteproductclass")]
|
|
127
|
|
- public async Task<IActionResult> DeleteProductClass(ProductClassDto input)
|
|
|
132
|
+ public async Task<IActionResult> DeleteProductClass(string ids)
|
|
128
|
133
|
{
|
|
129
|
134
|
|
|
130
|
|
- #region 验证 参数
|
|
131
|
135
|
|
|
132
|
|
- if (input.F_ClassId <= 0)
|
|
133
|
|
- return Error("缺少参数");
|
|
134
|
|
- #endregion
|
|
135
|
|
-
|
|
136
|
|
- //删除的时候 分类下有商品怎么处理 暂未处理 后续根据需求处理
|
|
|
136
|
+ if (string.IsNullOrEmpty(ids))
|
|
|
137
|
+ return Error("请输入删除id");
|
|
|
138
|
+ if (ids.Replace(",", "") == "")
|
|
|
139
|
+ return Error("请输入删除id");
|
|
137
|
140
|
|
|
138
|
|
- if (await _productClassRepository.Delete(a => a.F_ClassId == input.F_ClassId))
|
|
|
141
|
+ //删除的时候 分类下有商品怎么处理 暂未处理 后续根据需求处理 可以指定规则,分类下没有产品才可以删除
|
|
|
142
|
+ if (await _productClassRepository.Delete(a => ids.Contains("," + a.F_ClassId.ToString() + ",")))
|
|
139
|
143
|
{
|
|
140
|
144
|
return Success("删除商品分类成功");
|
|
141
|
145
|
}
|
|
|
@@ -151,7 +155,7 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
151
|
155
|
/// <param name="input"></param>
|
|
152
|
156
|
/// <returns></returns>
|
|
153
|
157
|
[HttpPost("getproductclass")]
|
|
154
|
|
- public async Task<IActionResult> ProductClassList(ProductClassDto input)
|
|
|
158
|
+ public async Task<IActionResult> ProductClassList(ProductClassInput input)
|
|
155
|
159
|
{
|
|
156
|
160
|
|
|
157
|
161
|
#region 验证 参数
|
|
|
@@ -166,24 +170,24 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
166
|
170
|
Expression<Func<T_Bus_ProductClass, bool>> eq = a => a.F_ClassId > 0;
|
|
167
|
171
|
|
|
168
|
172
|
if (input.F_ClassId > 0)
|
|
169
|
|
- eq.And(a => a.F_ClassId == input.F_ClassId);
|
|
|
173
|
+ eq = eq.And(a => a.F_ClassId == input.F_ClassId);
|
|
170
|
174
|
if (!string.IsNullOrEmpty(input.F_ClassName))
|
|
171
|
175
|
{
|
|
172
|
|
- eq.And(a => a.F_ClassName.Contains(input.F_ClassName));
|
|
|
176
|
+ eq = eq.And(a => a.F_ClassName.Contains(input.F_ClassName));
|
|
173
|
177
|
// eq.Or(a => a.F_ClassShortName.Contains(input.F_ClassName));
|
|
174
|
178
|
}
|
|
175
|
179
|
if (input.F_parentId > 0)
|
|
176
|
180
|
{
|
|
177
|
|
- eq.And(a => a.F_parentId == input.F_parentId);
|
|
|
181
|
+ eq = eq.And(a => a.F_parentId == input.F_parentId);
|
|
178
|
182
|
}
|
|
179
|
183
|
if (input.F_parentId == -1)
|
|
180
|
184
|
{
|
|
181
|
|
- eq.And(a => a.F_parentId == 0);
|
|
|
185
|
+ eq = eq.And(a => a.F_parentId == 0);
|
|
182
|
186
|
}
|
|
183
|
187
|
|
|
184
|
188
|
#endregion
|
|
185
|
189
|
|
|
186
|
|
- //删除的时候 分类下有商品怎么处理 暂未处理 后续根据需求处理 需要事务
|
|
|
190
|
+
|
|
187
|
191
|
List<T_Bus_ProductClass> list = await _productClassRepository.GetListALL(eq);
|
|
188
|
192
|
|
|
189
|
193
|
return Success("成功", list);
|
|
|
@@ -192,13 +196,15 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
192
|
196
|
|
|
193
|
197
|
|
|
194
|
198
|
#endregion
|
|
|
199
|
+
|
|
|
200
|
+ #region 产品操作
|
|
195
|
201
|
/// <summary>
|
|
196
|
|
- /// 新增商品
|
|
|
202
|
+ /// 新增商品 库存只通过两种方式变动 1 (我们下订单后,对方库存发别的地儿)对方库存变动回调我们,我们更新相关产品库存 2 我们定时去拿库存统一更新
|
|
197
|
203
|
/// </summary>
|
|
198
|
204
|
/// <param name="input"></param>
|
|
199
|
205
|
/// <returns></returns>
|
|
200
|
206
|
[HttpPost("addproduct")]
|
|
201
|
|
- public async Task<IActionResult> AddProduct(ProductDto input)
|
|
|
207
|
+ public async Task<IActionResult> AddProduct(ProductInput input)
|
|
202
|
208
|
{
|
|
203
|
209
|
|
|
204
|
210
|
#region 验证 参数
|
|
|
@@ -219,15 +225,24 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
219
|
225
|
return Error("请输入正确会员价");
|
|
220
|
226
|
if (input.F_SpecialPrice <= 0)
|
|
221
|
227
|
return Error("请输入正确特惠价");
|
|
|
228
|
+ if (input.F_ProductId <= 0)
|
|
|
229
|
+ return Error("请输入正确产品编码");
|
|
222
|
230
|
if (string.IsNullOrEmpty(input.F_PinyinShort))
|
|
223
|
231
|
return Error("请输入正确拼音简码");
|
|
224
|
232
|
#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
|
+ if (await _productRepository.GetCount(eq) > 0)
|
|
|
238
|
+ {
|
|
|
239
|
+ return Error("名称/条形码/简称 有重复");
|
|
|
240
|
+ }
|
|
225
|
241
|
|
|
226
|
242
|
T_Bus_Product T_Bus_ProductModel = new T_Bus_Product();
|
|
227
|
243
|
|
|
228
|
244
|
|
|
229
|
|
- if (input.F_ProductId > 0)
|
|
230
|
|
- T_Bus_ProductModel.F_ProductId = input.F_ProductId;
|
|
|
245
|
+ T_Bus_ProductModel.F_ProductId = input.F_ProductId;
|
|
231
|
246
|
T_Bus_ProductModel.F_ProductName = input.F_ProductName;
|
|
232
|
247
|
T_Bus_ProductModel.F_ProductShortName = input.F_ProductShortName;
|
|
233
|
248
|
T_Bus_ProductModel.F_ProductNumber = input.F_ProductNumber;
|
|
|
@@ -249,6 +264,86 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
249
|
264
|
|
|
250
|
265
|
T_Bus_ProductModel.F_IsSale = input.F_IsSale = input.F_OnSaleBegin < DateTime.Now;
|
|
251
|
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(); }
|
|
|
271
|
+
|
|
|
272
|
+
|
|
|
273
|
+
|
|
|
274
|
+ T_Bus_ProductModel.F_UserName = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Name).Value;
|
|
|
275
|
+ T_Bus_ProductModel.F_UserId = int.Parse(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.PrimarySid).Value, 0);
|
|
|
276
|
+
|
|
|
277
|
+
|
|
|
278
|
+ if (await _productRepository.AddStrong(T_Bus_ProductModel, true) == 0)
|
|
|
279
|
+ {
|
|
|
280
|
+ return Success("新增商品成功");
|
|
|
281
|
+ }
|
|
|
282
|
+ else
|
|
|
283
|
+ {
|
|
|
284
|
+ return Error("新增商品失败,请重试!");
|
|
|
285
|
+ }
|
|
|
286
|
+ }
|
|
|
287
|
+
|
|
|
288
|
+ /// <summary>
|
|
|
289
|
+ /// 修改商品 库存只通过两种方式变动 1 (我们下订单后,对方库存发别的地儿)对方库存变动回调我们,我们更新相关产品库存 2 我们定时去拿库存统一更新
|
|
|
290
|
+ /// </summary>
|
|
|
291
|
+ /// <param name="input"></param>
|
|
|
292
|
+ /// <returns></returns>
|
|
|
293
|
+ [HttpPost("updateproduct")]
|
|
|
294
|
+ public async Task<IActionResult> UpdateProduct(ProductInput input)
|
|
|
295
|
+ {
|
|
|
296
|
+
|
|
|
297
|
+ #region 验证 参数
|
|
|
298
|
+
|
|
|
299
|
+ if (input.F_ClassId == 0)
|
|
|
300
|
+ return Error("请选择分类名称");
|
|
|
301
|
+ if (string.IsNullOrEmpty(input.F_ProductName))
|
|
|
302
|
+ return Error("请输入产品名称");
|
|
|
303
|
+ if (string.IsNullOrEmpty(input.F_ProductShortName))
|
|
|
304
|
+ return Error("请输入产品简写");
|
|
|
305
|
+ if (string.IsNullOrEmpty(input.F_ProductNumber))
|
|
|
306
|
+ return Error("请输入产品条形码");
|
|
|
307
|
+ if (string.IsNullOrEmpty(input.F_ClassName))
|
|
|
308
|
+ return Error("请选择分类名称");
|
|
|
309
|
+ if (input.F_MarketPrice <= 0)
|
|
|
310
|
+ return Error("请输入正确市场价");
|
|
|
311
|
+ if (input.F_MemberPrice <= 0)
|
|
|
312
|
+ return Error("请输入正确会员价");
|
|
|
313
|
+ if (input.F_SpecialPrice <= 0)
|
|
|
314
|
+ return Error("请输入正确特惠价");
|
|
|
315
|
+ if (input.F_ProductId <= 0)
|
|
|
316
|
+ return Error("产品ID不能修改");
|
|
|
317
|
+ if (string.IsNullOrEmpty(input.F_PinyinShort))
|
|
|
318
|
+ return Error("请输入正确拼音简码");
|
|
|
319
|
+ #endregion
|
|
|
320
|
+
|
|
|
321
|
+ T_Bus_Product T_Bus_ProductModel = await _productRepository.GetSingle(a => a.F_ProductId == input.F_ProductId);
|
|
|
322
|
+
|
|
|
323
|
+ if (T_Bus_ProductModel == null)
|
|
|
324
|
+ return Error("如需新添加,请点击新增按钮,此记录不存在");
|
|
|
325
|
+
|
|
|
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;
|
|
|
330
|
+
|
|
|
331
|
+ T_Bus_ProductModel.F_ClassId = input.F_ClassId;
|
|
|
332
|
+ T_Bus_ProductModel.F_ClassName = input.F_ClassName;
|
|
|
333
|
+
|
|
|
334
|
+
|
|
|
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;
|
|
|
339
|
+
|
|
|
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;
|
|
|
344
|
+
|
|
|
345
|
+ T_Bus_ProductModel.F_IsSale = input.F_IsSale = input.F_OnSaleBegin < DateTime.Now;//此状态暂不启用 以时间判断
|
|
|
346
|
+ T_Bus_ProductModel.F_Weight = input.F_Weight;
|
|
252
|
347
|
T_Bus_ProductModel.F_OnSaleBegin = input.F_OnSaleBegin ?? input.F_OnSaleBegin.GetValueOrDefault().ToString("yyyy-MM-dd 00:00:01").ObjToDate();
|
|
253
|
348
|
T_Bus_ProductModel.F_OnSaleEnd = input.F_OnSaleEnd ?? input.F_OnSaleEnd.GetValueOrDefault().ToString("yyyy-MM-dd 23:59:59").ObjToDate();
|
|
254
|
349
|
|
|
|
@@ -260,16 +355,182 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
|
|
260
|
355
|
|
|
261
|
356
|
if (await _productRepository.Update(T_Bus_ProductModel))
|
|
262
|
357
|
{
|
|
263
|
|
- return Success("新增商品成功");
|
|
|
358
|
+ return Success("保存商品成功");
|
|
264
|
359
|
}
|
|
265
|
360
|
else
|
|
266
|
361
|
{
|
|
267
|
|
- return Error("新增商品失败,请重试!");
|
|
|
362
|
+ return Error("保存商品失败,请重试!");
|
|
|
363
|
+ }
|
|
|
364
|
+ }
|
|
|
365
|
+
|
|
|
366
|
+ /// <summary>
|
|
|
367
|
+ /// 删除商品 硬删除
|
|
|
368
|
+ /// </summary>
|
|
|
369
|
+ /// <param name="ids">格式 ,1,2,3,</param>
|
|
|
370
|
+ /// <returns></returns>
|
|
|
371
|
+ [HttpPost("deleteproductbyids")]
|
|
|
372
|
+ public async Task<IActionResult> DeleteProductByIds(string ids)
|
|
|
373
|
+ {
|
|
|
374
|
+
|
|
|
375
|
+ #region 验证 参数
|
|
|
376
|
+
|
|
|
377
|
+ if (string.IsNullOrEmpty(ids))
|
|
|
378
|
+ return Error("请输入删除id");
|
|
|
379
|
+ if (ids.Replace(",", "") == "")
|
|
|
380
|
+ return Error("请输入删除id");
|
|
|
381
|
+ #endregion
|
|
|
382
|
+
|
|
|
383
|
+ if (await _productRepository.Delete(a => ids.Contains("," + a.F_ProductId.ToString() + ",")))
|
|
|
384
|
+ {
|
|
|
385
|
+ return Success("删除商品成功");
|
|
|
386
|
+ }
|
|
|
387
|
+ else
|
|
|
388
|
+ {
|
|
|
389
|
+ return Error("删除商品失败,请重试!");
|
|
268
|
390
|
}
|
|
269
|
391
|
}
|
|
|
392
|
+ /// <summary>
|
|
|
393
|
+ /// 删除商品 软删除
|
|
|
394
|
+ /// </summary>
|
|
|
395
|
+ /// <param name="ids">格式 ,1,2,3,</param>
|
|
|
396
|
+ /// <returns></returns>
|
|
|
397
|
+ [HttpPost("delproductbyids")]
|
|
|
398
|
+ public async Task<IActionResult> DelProduct(string ids)
|
|
|
399
|
+ {
|
|
270
|
400
|
|
|
|
401
|
+ #region 验证 参数
|
|
271
|
402
|
|
|
|
403
|
+ if (string.IsNullOrEmpty(ids))
|
|
|
404
|
+ return Error("请输入删除id");
|
|
|
405
|
+ if (ids.Replace(",", "") == "")
|
|
|
406
|
+ return Error("请输入删除id");
|
|
|
407
|
+ #endregion
|
|
|
408
|
+ List<T_Bus_Product> listmodel = await _productRepository.GetListALL(a => ids.Contains("," + a.F_ProductId.ToString() + ","));
|
|
272
|
409
|
|
|
273
|
410
|
|
|
|
411
|
+ //此处如果不是批量删除,最好事务
|
|
|
412
|
+ for (int i = 0; i < listmodel.Count; i++)
|
|
|
413
|
+ {
|
|
|
414
|
+ listmodel[i].F_IsDelete = 1;
|
|
|
415
|
+ }
|
|
|
416
|
+
|
|
|
417
|
+ if (await _productRepository.UpdateList(listmodel))
|
|
|
418
|
+ return Success("删除商品成功");
|
|
|
419
|
+ else
|
|
|
420
|
+ return Success("删除商品失败");
|
|
|
421
|
+ }
|
|
|
422
|
+
|
|
|
423
|
+
|
|
|
424
|
+ /// <summary>
|
|
|
425
|
+ /// 查询商品
|
|
|
426
|
+ /// </summary>
|
|
|
427
|
+ /// <param name="input"></param>
|
|
|
428
|
+ /// <returns></returns>
|
|
|
429
|
+ [HttpPost("getproduct")]
|
|
|
430
|
+ public async Task<IActionResult> ProductList(ProductInput input)
|
|
|
431
|
+ {
|
|
|
432
|
+
|
|
|
433
|
+
|
|
|
434
|
+ #region 拼接条件
|
|
|
435
|
+
|
|
|
436
|
+ Expression<Func<T_Bus_Product, bool>> eq = a => a.F_IsDelete == 0;
|
|
|
437
|
+
|
|
|
438
|
+ if (input.F_ClassId > 0)
|
|
|
439
|
+ eq = eq.And(a => a.F_ProductId == input.F_ProductId);
|
|
|
440
|
+ if (!string.IsNullOrEmpty(input.F_ClassName))
|
|
|
441
|
+ {
|
|
|
442
|
+ eq = eq.And(a => a.F_ClassName.Contains(input.F_ClassName));
|
|
|
443
|
+ // eq.Or(a => a.F_ClassShortName.Contains(input.F_ClassName));
|
|
|
444
|
+ }
|
|
|
445
|
+ //产品名/标题
|
|
|
446
|
+ if (!string.IsNullOrEmpty(input.F_ProductName))
|
|
|
447
|
+ {
|
|
|
448
|
+ eq = eq.And(a => a.F_ProductName.Contains(input.F_ProductName));
|
|
|
449
|
+ }
|
|
|
450
|
+ //指定分类
|
|
|
451
|
+ if (input.F_ClassId > 0)
|
|
|
452
|
+ {
|
|
|
453
|
+ eq = eq.And(a => a.F_ClassId == input.F_ClassId);
|
|
|
454
|
+ }
|
|
|
455
|
+ //分类名称
|
|
|
456
|
+ if (!string.IsNullOrEmpty(input.F_ClassName))
|
|
|
457
|
+ {
|
|
|
458
|
+ eq = eq.And(a => a.F_ClassName.Contains(input.F_ClassName));
|
|
|
459
|
+ }
|
|
|
460
|
+ //拼音简码
|
|
|
461
|
+ if (!string.IsNullOrEmpty(input.F_PinyinShort))
|
|
|
462
|
+ {
|
|
|
463
|
+ eq = eq.And(a => a.F_PinyinShort == input.F_PinyinShort);
|
|
|
464
|
+ }
|
|
|
465
|
+
|
|
|
466
|
+ //条形码
|
|
|
467
|
+ if (!string.IsNullOrEmpty(input.F_ProductNumber))
|
|
|
468
|
+ {
|
|
|
469
|
+ eq = eq.And(a => a.F_ProductNumber == input.F_ProductNumber);
|
|
|
470
|
+ }
|
|
|
471
|
+ //简称/编码/副标题
|
|
|
472
|
+ if (!string.IsNullOrEmpty(input.F_ProductShortName))
|
|
|
473
|
+ {
|
|
|
474
|
+ eq = eq.And(a => a.F_ProductShortName == input.F_ProductShortName);
|
|
|
475
|
+ }
|
|
|
476
|
+ //标签
|
|
|
477
|
+ if (!string.IsNullOrEmpty(input.F_Tag))
|
|
|
478
|
+ {
|
|
|
479
|
+ eq.And(a => a.F_Tag.Contains(input.F_Tag));
|
|
|
480
|
+ }
|
|
|
481
|
+
|
|
|
482
|
+ #endregion
|
|
|
483
|
+
|
|
|
484
|
+
|
|
|
485
|
+ List<T_Bus_Product> list = await _productRepository.GetListALL(eq);
|
|
|
486
|
+
|
|
|
487
|
+ return Success("成功", list);
|
|
|
488
|
+
|
|
|
489
|
+ }
|
|
|
490
|
+
|
|
|
491
|
+
|
|
|
492
|
+ #endregion
|
|
|
493
|
+
|
|
|
494
|
+ #region 库存对接
|
|
|
495
|
+
|
|
|
496
|
+ /// <summary>
|
|
|
497
|
+ /// 更新库存(对方库存变化 入库 出库 时做更新) 订单发货时,对面库存 出库要对应订单,以便跟踪
|
|
|
498
|
+ /// </summary>
|
|
|
499
|
+ /// <param name="input">目前暂定Id唯一标识更新如果不方便可以以F_ProductName,如果那边更好操作,顺序上这边先有产品的话可以以id操作,或者以条形码操作</param>
|
|
|
500
|
+ /// <returns></returns>
|
|
|
501
|
+ [HttpPost("updatestock")]
|
|
|
502
|
+ public async Task<IActionResult> UpdateStock(List<ProductInput> input)
|
|
|
503
|
+ {
|
|
|
504
|
+
|
|
|
505
|
+ #region 验证 参数
|
|
|
506
|
+ //List<ProductInput> m = input;
|
|
|
507
|
+ if (input.Count <= 0)
|
|
|
508
|
+ return Error("参数缺失,没有数据");
|
|
|
509
|
+ List<T_Bus_Product> listmodel = new List<T_Bus_Product>();
|
|
|
510
|
+
|
|
|
511
|
+ foreach (ProductInput m in input)
|
|
|
512
|
+ {
|
|
|
513
|
+ // return Success(m.F_ProductId.ToString() + ":" + m.F_Stock.ToString());
|
|
|
514
|
+ if (!string.IsNullOrEmpty(m.F_ProductName))
|
|
|
515
|
+ return Error("参数缺失产品名称");
|
|
|
516
|
+ if (m.F_ProductId <= 0)
|
|
|
517
|
+ return Error("参数缺失产品id");
|
|
|
518
|
+ if (m.F_Stock < 0)
|
|
|
519
|
+ 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);
|
|
|
523
|
+ }
|
|
|
524
|
+
|
|
|
525
|
+ #endregion
|
|
|
526
|
+ //此字段更新单独字段优先
|
|
|
527
|
+ if (await _productRepository.UpdateListToColumns(listmodel, it => new { it.F_Stock }))
|
|
|
528
|
+ return Success("更新库存成功");
|
|
|
529
|
+ else
|
|
|
530
|
+ return Success("更新库存失败");
|
|
|
531
|
+ }
|
|
|
532
|
+
|
|
|
533
|
+
|
|
|
534
|
+ #endregion
|
|
274
|
535
|
}
|
|
275
|
536
|
}
|