zhangkun 5 anos atrás
pai
commit
81270340df

+ 33 - 32
代码/TVShoppingCallCenter_ZLJ/Controllers/Product/ProductController.cs

1
 /* =============================================
1
 /* =============================================
2
 -- Author:		<Author,,zhangkun>
2
 -- Author:		<Author,,zhangkun>
3
 -- Create date: <Create Date,,20200609>
3
 -- Create date: <Create Date,,20200609>
4
+-- Description:	<Description,,商品 库存 商品类别相关操作)>
4
 -- ============================================*/
5
 -- ============================================*/
5
 using System;
6
 using System;
6
 using System.Collections.Generic;
7
 using System.Collections.Generic;
52
                 Message = "访问信息"
52
                 Message = "访问信息"
53
             });
53
             });
54
         }
54
         }
55
-        #region 品分类
55
+        #region 品分类
56
 
56
 
57
         /// <summary>
57
         /// <summary>
58
         /// 新增商品分类
58
         /// 新增商品分类
158
             if (ids.Replace(",", "") == "")
158
             if (ids.Replace(",", "") == "")
159
                 return Error("请输入删除id");
159
                 return Error("请输入删除id");
160
 
160
 
161
-            //删除的时候  分类下有商品怎么处理  暂未处理  后续根据需求处理  可以指定规则,分类下没有品才可以删除
161
+            //删除的时候  分类下有商品怎么处理  暂未处理  后续根据需求处理  可以指定规则,分类下没有品才可以删除
162
             if (await _productClassRepository.Delete(a => ids.Contains("," + a.F_ClassId.ToString() + ",")))
162
             if (await _productClassRepository.Delete(a => ids.Contains("," + a.F_ClassId.ToString() + ",")))
163
             {
163
             {
164
                 return Success("删除商品分类成功");
164
                 return Success("删除商品分类成功");
211
                 treeModel.code = item.F_ClassShortName;
211
                 treeModel.code = item.F_ClassShortName;
212
                 treeList.Add(treeModel);
212
                 treeList.Add(treeModel);
213
             }
213
             }
214
-            return Success("获取品分类树成功", treeList.TreeRecursion(0));
214
+            return Success("获取品分类树成功", treeList.TreeRecursion(0));
215
         }
215
         }
216
 
216
 
217
 
217
 
218
         #endregion
218
         #endregion
219
 
219
 
220
-        #region 品操作
220
+        #region 品操作
221
 
221
 
222
         /// <summary>
222
         /// <summary>
223
         /// 导入商品
223
         /// 导入商品
265
                         }
265
                         }
266
                         if (Products[i].ProductShortName == Products[j].ProductShortName)
266
                         if (Products[i].ProductShortName == Products[j].ProductShortName)
267
                         {
267
                         {
268
-                            return Error(Products[i].ProductId + "标题 有重复:" + Products[j].ProductId);
268
+                            return Error(Products[i].ProductId + "商品副标题 有重复:" + Products[j].ProductId);
269
                         }
269
                         }
270
                     }
270
                     }
271
 
271
 
279
 
279
 
280
                     if (await _productRepository.GetCount(eq) > 0)
280
                     if (await _productRepository.GetCount(eq) > 0)
281
                     {
281
                     {
282
-                        return Error("品名称有重复:" + input.ProductId);
282
+                        return Error("品名称有重复:" + input.ProductId);
283
                     }
283
                     }
284
                     eq = b => b.F_ProductId == input.ProductId;
284
                     eq = b => b.F_ProductId == input.ProductId;
285
                     if (await _productRepository.GetCount(eq) > 0)
285
                     if (await _productRepository.GetCount(eq) > 0)
286
                     {
286
                     {
287
-                        return Error("品ID有重复:" + input.ProductId);
287
+                        return Error("品ID有重复:" + input.ProductId);
288
                     }
288
                     }
289
                     eq = b => b.F_ProductShortName == input.ProductShortName;
289
                     eq = b => b.F_ProductShortName == input.ProductShortName;
290
                     if (await _productRepository.GetCount(eq) > 0)
290
                     if (await _productRepository.GetCount(eq) > 0)
291
                     {
291
                     {
292
-                        return Error("标题有重复:" + input.ProductId);
292
+                        return Error("商品副标题有重复:" + input.ProductId);
293
                     }
293
                     }
294
                     input.IsDelete = 0;
294
                     input.IsDelete = 0;
295
                     if(!string.IsNullOrEmpty(input.ProductId))
295
                     if(!string.IsNullOrEmpty(input.ProductId))
310
 
310
 
311
 
311
 
312
         /// <summary>
312
         /// <summary>
313
-        /// 新增商品 库存只通过两种方式变动 1 (我们下订单后,对方库存发别的地儿)对方库存变动回调我们,我们更新相关品库存  2  我们定时去拿库存统一更新
313
+        /// 新增商品 库存只通过两种方式变动 1 (我们下订单后,对方库存发别的地儿)对方库存变动回调我们,我们更新相关品库存  2  我们定时去拿库存统一更新
314
         /// </summary>
314
         /// </summary>
315
         /// <param name="input"></param>
315
         /// <param name="input"></param>
316
         /// <returns></returns>
316
         /// <returns></returns>
323
             if (input.ClassId == 0)
323
             if (input.ClassId == 0)
324
                 return Error("请选择分类名称");
324
                 return Error("请选择分类名称");
325
             if (string.IsNullOrEmpty(input.ProductName))
325
             if (string.IsNullOrEmpty(input.ProductName))
326
-                return Error("请输入品名称");
326
+                return Error("请输入品名称");
327
             if (string.IsNullOrEmpty(input.ProductShortName))
327
             if (string.IsNullOrEmpty(input.ProductShortName))
328
-                return Error("请输入品简写");
328
+                return Error("请输入品简写");
329
             if (string.IsNullOrEmpty(input.ProductNumber))
329
             if (string.IsNullOrEmpty(input.ProductNumber))
330
-                return Error("请输入品款号");
330
+                return Error("请输入品款号");
331
             if (string.IsNullOrEmpty(input.ClassName))
331
             if (string.IsNullOrEmpty(input.ClassName))
332
                 return Error("请选择分类名称");
332
                 return Error("请选择分类名称");
333
             if (input.MarketPrice <= 0)
333
             if (input.MarketPrice <= 0)
337
             if (input.SpecialPrice <= 0)
337
             if (input.SpecialPrice <= 0)
338
                 return Error("请输入正确特惠价");
338
                 return Error("请输入正确特惠价");
339
             if (string.IsNullOrEmpty(input.ProductId))
339
             if (string.IsNullOrEmpty(input.ProductId))
340
-                return Error("请输入正确品编码");
340
+                return Error("请输入正确品编码");
341
 
341
 
342
             #endregion
342
             #endregion
343
 
343
 
344
             if (await _productRepository.GetCount(a => a.F_ProductName == input.ProductName) > 0)
344
             if (await _productRepository.GetCount(a => a.F_ProductName == input.ProductName) > 0)
345
             {
345
             {
346
-                return Error("品名称 有重复");
346
+                return Error("品名称 有重复");
347
             }
347
             }
348
             if (await _productRepository.GetCount(b => b.F_ProductId == input.ProductId) > 0)
348
             if (await _productRepository.GetCount(b => b.F_ProductId == input.ProductId) > 0)
349
             {
349
             {
350
-                return Error("品ID 有重复");
350
+                return Error("品ID 有重复");
351
             }
351
             }
352
             if (await _productRepository.GetCount(b => b.F_ProductShortName == input.ProductShortName) > 0)
352
             if (await _productRepository.GetCount(b => b.F_ProductShortName == input.ProductShortName) > 0)
353
             {
353
             {
354
-                return Error("品副标题 有重复");
354
+                return Error("品副标题 有重复");
355
             }
355
             }
356
             if (!string.IsNullOrEmpty(input.Tag))
356
             if (!string.IsNullOrEmpty(input.Tag))
357
             {
357
             {
430
         }
430
         }
431
 
431
 
432
         /// <summary>
432
         /// <summary>
433
-        /// 修改商品 库存只通过两种方式变动 1 (我们下订单后,对方库存发别的地儿)对方库存变动回调我们,我们更新相关品库存  2  我们定时去拿库存统一更新
433
+        /// 修改商品 库存只通过两种方式变动 1 (我们下订单后,对方库存发别的地儿)对方库存变动回调我们,我们更新相关品库存  2  我们定时去拿库存统一更新
434
         /// </summary>
434
         /// </summary>
435
         /// <param name="input"></param>
435
         /// <param name="input"></param>
436
         /// <returns></returns>
436
         /// <returns></returns>
443
             if (input.ClassId == 0)
443
             if (input.ClassId == 0)
444
                 return Error("请选择分类名称");
444
                 return Error("请选择分类名称");
445
             if (string.IsNullOrEmpty(input.ProductName))
445
             if (string.IsNullOrEmpty(input.ProductName))
446
-                return Error("请输入品名称");
446
+                return Error("请输入品名称");
447
             if (string.IsNullOrEmpty(input.ProductShortName))
447
             if (string.IsNullOrEmpty(input.ProductShortName))
448
-                return Error("请输入品简写");
448
+                return Error("请输入品简写");
449
             if (string.IsNullOrEmpty(input.ProductNumber))
449
             if (string.IsNullOrEmpty(input.ProductNumber))
450
-                return Error("请输入品条形码");
450
+                return Error("请输入品条形码");
451
             if (string.IsNullOrEmpty(input.ClassName))
451
             if (string.IsNullOrEmpty(input.ClassName))
452
                 return Error("请选择分类名称");
452
                 return Error("请选择分类名称");
453
             if (input.MarketPrice <= 0)
453
             if (input.MarketPrice <= 0)
457
             if (input.SpecialPrice <= 0)
457
             if (input.SpecialPrice <= 0)
458
                 return Error("请输入正确特惠价");
458
                 return Error("请输入正确特惠价");
459
             if (string.IsNullOrEmpty(input.ProductId))
459
             if (string.IsNullOrEmpty(input.ProductId))
460
-                return Error("品ID不能为空");
460
+                return Error("品ID不能为空");
461
             if (string.IsNullOrEmpty(input.PinyinShort))
461
             if (string.IsNullOrEmpty(input.PinyinShort))
462
                 return Error("请输入正确拼音简码");
462
                 return Error("请输入正确拼音简码");
463
             #endregion
463
             #endregion
478
                 List<T_Bus_Product> T_Bus_ProductModelSearch = await _productRepository.GetListALL(eq);
478
                 List<T_Bus_Product> T_Bus_ProductModelSearch = await _productRepository.GetListALL(eq);
479
                 if (T_Bus_ProductModelSearch.Count > 1)
479
                 if (T_Bus_ProductModelSearch.Count > 1)
480
                 {
480
                 {
481
-                    if (n == 1) { return Error("品名称 有重复"); }
482
-                    else if (n == 2) { return Error("品ID 有重复"); }
483
-                    else if (n == 3) { return Error("副标题/标题 有重复"); }
481
+                    if (n == 1) { return Error("品名称 有重复"); }
482
+                    else if (n == 2) { return Error("品ID 有重复"); }
483
+                    else if (n == 3) { return Error("副标题/商品副标题 有重复"); }
484
                 }
484
                 }
485
                 if (T_Bus_ProductModelSearch.Count == 1 && T_Bus_ProductModelSearch[0].F_ProductId != input.ProductId)
485
                 if (T_Bus_ProductModelSearch.Count == 1 && T_Bus_ProductModelSearch[0].F_ProductId != input.ProductId)
486
                 {
486
                 {
487
-                    if (n == 1) { return Error("品名称 有重复"); }
488
-                    else if (n == 2) { return Error("品ID 有重复"); }
489
-                    else if (n == 3) { return Error("副标题/标题 有重复"); }
487
+                    if (n == 1) { return Error("品名称 有重复"); }
488
+                    else if (n == 2) { return Error("品ID 有重复"); }
489
+                    else if (n == 3) { return Error("副标题/商品副标题 有重复"); }
490
                 }
490
                 }
491
                 n++;
491
                 n++;
492
             }
492
             }
609
                 eq = eq.And(a => a.F_ClassName.Contains(input.ClassName));
609
                 eq = eq.And(a => a.F_ClassName.Contains(input.ClassName));
610
                 // eq.Or(a => a.F_ClassShortName.Contains(input.F_ClassName));
610
                 // eq.Or(a => a.F_ClassShortName.Contains(input.F_ClassName));
611
             }
611
             }
612
-            //品名/标题
612
+            //品名/标题
613
             if (!string.IsNullOrEmpty(input.ProductName))
613
             if (!string.IsNullOrEmpty(input.ProductName))
614
             {
614
             {
615
                 eq = eq.And(a => a.F_ProductName.Contains(input.ProductName));
615
                 eq = eq.And(a => a.F_ProductName.Contains(input.ProductName));
699
 
699
 
700
         }
700
         }
701
         /// <summary>
701
         /// <summary>
702
-        /// 分页获取品列表
702
+        /// 分页获取品列表
703
         /// </summary>
703
         /// </summary>
704
         /// <param name="input">筛选字段</param>
704
         /// <param name="input">筛选字段</param>
705
         /// <returns></returns>
705
         /// <returns></returns>
727
                 conModels.Add(new ConditionalModel() { FieldName = "F_ClassId", ConditionalType = ConditionalType.Equal, FieldValue = input.ClassId.ToString() });
727
                 conModels.Add(new ConditionalModel() { FieldName = "F_ClassId", ConditionalType = ConditionalType.Equal, FieldValue = input.ClassId.ToString() });
728
             }
728
             }
729
 
729
 
730
-            //品名/标题
730
+            //品名/标题
731
             if (!string.IsNullOrEmpty(input.ProductName))
731
             if (!string.IsNullOrEmpty(input.ProductName))
732
             {
732
             {
733
                 conModels.Add(new ConditionalModel() { FieldName = "F_ProductName", ConditionalType = ConditionalType.Like, FieldValue = input.ProductName });
733
                 conModels.Add(new ConditionalModel() { FieldName = "F_ProductName", ConditionalType = ConditionalType.Like, FieldValue = input.ProductName });
821
         /// <summary>
821
         /// <summary>
822
         /// 更新库存(对方库存变化  入库 出库 时做更新)  订单发货时,对面库存 出库要对应订单,以便跟踪
822
         /// 更新库存(对方库存变化  入库 出库 时做更新)  订单发货时,对面库存 出库要对应订单,以便跟踪
823
         /// </summary>
823
         /// </summary>
824
-        /// <param name="input">目前暂定Id唯一标识更新如果不方便可以以F_ProductName,如果那边更好操作,顺序上这边先有品的话可以以id操作,或者以条形码操作</param>
824
+        /// <param name="input">目前暂定Id唯一标识更新如果不方便可以以F_ProductName,如果那边更好操作,顺序上这边先有品的话可以以id操作,或者以条形码操作</param>
825
         /// 基类BaseController继承的不是[ApiController],也没有加[ApiController]头标  所以用到json序列化传值 和测试工具raw传值必须加[FromBody]
825
         /// 基类BaseController继承的不是[ApiController],也没有加[ApiController]头标  所以用到json序列化传值 和测试工具raw传值必须加[FromBody]
826
         /// <returns></returns>
826
         /// <returns></returns>
827
         [HttpPost("updatestock")]
827
         [HttpPost("updatestock")]
836
             foreach (ProductInput m in input)
836
             foreach (ProductInput m in input)
837
             {
837
             {
838
                 if (string.IsNullOrEmpty(m.ProductId))
838
                 if (string.IsNullOrEmpty(m.ProductId))
839
-                    return Error("参数缺失品id");
839
+                    return Error("参数缺失品id");
840
 
840
 
841
                 T_Bus_Product model = await _productRepository.GetSingle(a => a.F_ProductId == m.ProductId);
841
                 T_Bus_Product model = await _productRepository.GetSingle(a => a.F_ProductId == m.ProductId);
842
 
842