Kaynağa Gözat

产品分类查询,商品查询,库存同步方法(暂未完成)

zhangkun 5 yıl önce
ebeveyn
işleme
2a8044ef21

+ 30 - 0
代码/System.Common/IRepositories/IRepository.cs

@@ -40,6 +40,21 @@ namespace System.Common
40 40
         /// </summary>
41 41
         Task<int> Add(T obj);
42 42
         /// <summary>
43
+        /// 添加排除某列
44
+        /// </summary>
45
+        /// <param name="obj"></param>
46
+        /// <returns></returns>
47
+        Task<int> AddIgnore(T obj, Expression<Func<T, object>> IgnoreColumns);
48
+
49
+
50
+        /// <summary>
51
+        /// 强势插入,插入自增值 
52
+        /// </summary>
53
+        /// <param name="obj"></param>
54
+        /// <param name="isStrong">是否强势</param>
55
+        /// <returns></returns>
56
+        Task<int> AddStrong(T obj, bool isStrong = false);
57
+        /// <summary>
43 58
         /// 批量添加
44 59
         /// </summary>
45 60
         /// <param name="objlist"></param>
@@ -59,5 +74,20 @@ namespace System.Common
59 74
         /// <param name="id"></param>
60 75
         /// <returns></returns>
61 76
         Task<bool> Update(T obj);
77
+
78
+        /// <summary>
79
+        /// 批量更新
80
+        /// </summary>
81
+        /// <param name="obj"></param>
82
+        /// <returns></returns>
83
+        Task<bool> UpdateList(List<T> obj);
84
+
85
+        /// <summary>
86
+        /// 批量指定字段更新
87
+        /// </summary>
88
+        /// <param name="objColumns">model => new { model.Name }</param>
89
+        /// <returns></returns>
90
+        Task<bool> UpdateListToColumns(List<T> obj, Expression<Func<T, object>> objColumns);
91
+
62 92
     }
63 93
 }

+ 46 - 0
代码/System.Common/Repositories/BaseRepository.cs

@@ -106,6 +106,30 @@ namespace System.Common
106 106
             return await Db.Insertable<T>(obj).ExecuteReturnIdentityAsync();
107 107
             //return CurrentDb.InsertReturnIdentity(obj);
108 108
         }
109
+
110
+
111
+        /// <summary>
112
+        /// 添加排除某列
113
+        /// </summary>
114
+        /// <param name="obj"></param>
115
+        /// <returns></returns>
116
+        public async Task<int> AddIgnore(T obj, Expression<Func<T, object>> IgnoreColumns)
117
+        {
118
+            return await Db.Insertable<T>(obj).IgnoreColumns(IgnoreColumns).ExecuteReturnIdentityAsync();
119
+            //return CurrentDb.InsertReturnIdentity(obj);
120
+        }
121
+
122
+        /// <summary>
123
+        /// 强势插入,插入自增值 
124
+        /// </summary>
125
+        /// <param name="obj"></param>
126
+        /// <param name="isStrong">是否强势</param>
127
+        /// <returns></returns>
128
+        public async Task<int> AddStrong(T obj,bool isStrong=false)
129
+        {
130
+            return await Db.Insertable<T>(obj).IgnoreColumns(true, isStrong).ExecuteReturnIdentityAsync();
131
+            //return CurrentDb.InsertReturnIdentity(obj);
132
+        }
109 133
         /// <summary>
110 134
         /// 批量添加
111 135
         /// </summary>
@@ -136,5 +160,27 @@ namespace System.Common
136 160
             return await Db.Updateable<T>(obj).ExecuteCommandHasChangeAsync();
137 161
             //return CurrentDb.Update(obj);
138 162
         }
163
+        /// <summary>
164
+        /// 批量整条更新
165
+        /// </summary>
166
+        /// <param name="obj"></param>
167
+        /// <returns></returns>
168
+        public async Task<bool> UpdateList(List<T> obj)
169
+        {
170
+            return await Db.Updateable<T>(obj).ExecuteCommandHasChangeAsync();
171
+            //return CurrentDb.Update(obj);
172
+        }
173
+
174
+        /// <summary>
175
+        /// 批量指定字段更新  方法有待考究
176
+        /// </summary>
177
+        /// <param name="objColumns">model => new { model.Name }</param>
178
+        /// <returns></returns>
179
+        [Obsolete]
180
+        public async Task<bool> UpdateListToColumns(List<T> obj, Expression<Func<T, object>> objColumns)
181
+        {
182
+            return await Db.Updateable<T>(obj).UpdateColumns(objColumns).ExecuteCommandHasChangeAsync();
183
+            //return CurrentDb.Update(obj);
184
+        }
139 185
     }
140 186
 }

+ 23 - 0
代码/System.Model/T_Bus_Product.cs

@@ -39,7 +39,11 @@ namespace System.Model
39 39
 		private string _f_username;
40 40
 		private DateTime? _f_addtime =DateTime.Now;
41 41
 		private DateTime? _f_updatetime=DateTime.Now;
42
+		private DateTime? _f_laststockupdate ;
42 43
 		private int _f_sort=10000;
44
+		private int _f_stock = 0;
45
+
46
+
43 47
 		/// <summary>
44 48
 		/// 产品编号ID
45 49
 		/// </summary>
@@ -280,6 +284,25 @@ namespace System.Model
280 284
 			set { _f_sort = value; }
281 285
 			get { return _f_sort; }
282 286
 		}
287
+
288
+		/// <summary>
289
+		/// 上次库存更新时间
290
+		/// </summary>
291
+		public DateTime? F_LastStockUpdate
292
+		{
293
+			set { _f_laststockupdate = value; }
294
+			get { return _f_laststockupdate; }
295
+		}
296
+
297
+		/// <summary>
298
+		/// 产品库存
299
+		/// </summary>
300
+		public int F_Stock
301
+		{
302
+			set { _f_stock = value; }
303
+			get { return _f_stock; }
304
+		}
305
+
283 306
 		#endregion Model
284 307
 
285 308
 	}

+ 285 - 24
代码/TVShoppingCallCenter_ZLJ/Controllers/Product/ProductController.cs

@@ -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
 }

+ 21 - 0
代码/TVShoppingCallCenter_ZLJ/Models/Dtos/ProductDto.cs

@@ -39,6 +39,9 @@ namespace TVShoppingCallCenter_ZLJ.Models.Dtos
39 39
 		private DateTime? _f_addtime;
40 40
 		private DateTime? _f_updatetime;
41 41
 		private int _f_sort;
42
+		private DateTime? _f_laststockupdate;
43
+		private int _f_stock = 0;
44
+
42 45
 		/// <summary>
43 46
 		/// 产品编号ID
44 47
 		/// </summary>
@@ -279,6 +282,24 @@ namespace TVShoppingCallCenter_ZLJ.Models.Dtos
279 282
 			set { _f_sort = value; }
280 283
 			get { return _f_sort; }
281 284
 		}
285
+
286
+		/// <summary>
287
+		/// 上次库存更新时间
288
+		/// </summary>
289
+		public DateTime? F_LastStockUpdate
290
+		{
291
+			set { _f_laststockupdate = value; }
292
+			get { return _f_laststockupdate; }
293
+		}
294
+
295
+		/// <summary>
296
+		/// 产品库存
297
+		/// </summary>
298
+		public int F_Stock
299
+		{
300
+			set { _f_stock = value; }
301
+			get { return _f_stock; }
302
+		}
282 303
 		#endregion Model
283 304
 
284 305
 	}

+ 96 - 0
代码/TVShoppingCallCenter_ZLJ/Models/Inputs/ProductClassInput.cs

@@ -0,0 +1,96 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace TVShoppingCallCenter_ZLJ.Models.Inputs
7
+{
8
+    public class ProductClassInput
9
+	{
10
+
11
+		#region Model
12
+		private int _f_classid;
13
+		private int? _f_parentid=0;
14
+		private string _f_classname="";
15
+		private string _f_classshortname="";
16
+		private DateTime? _f_addtime=DateTime.Now;
17
+		private string _f_username="";
18
+		private DateTime? _f_updatetime=DateTime.Now;
19
+		private int? _f_userid;
20
+		private int? _f_sort=10000;
21
+		/// <summary>
22
+		/// 产品分类编号
23
+		/// </summary>
24
+		public int F_ClassId
25
+		{
26
+			set { _f_classid = value; }
27
+			get { return _f_classid; }
28
+		}
29
+		/// <summary>
30
+		/// 上级分类 0顶级
31
+		/// </summary>
32
+		public int? F_parentId
33
+		{
34
+			set { _f_parentid = value; }
35
+			get { return _f_parentid; }
36
+		}
37
+		/// <summary>
38
+		/// 产品分类名称
39
+		/// </summary>
40
+		public string F_ClassName
41
+		{
42
+			set { _f_classname = value; }
43
+			get { return _f_classname; }
44
+		}
45
+		/// <summary>
46
+		/// 产品分类简称/代码
47
+		/// </summary>
48
+		public string F_ClassShortName
49
+		{
50
+			set { _f_classshortname = value; }
51
+			get { return _f_classshortname; }
52
+		}
53
+		/// <summary>
54
+		/// 添加时间
55
+		/// </summary>
56
+		public DateTime? F_Addtime
57
+		{
58
+			set { _f_addtime = value; }
59
+			get { return _f_addtime; }
60
+		}
61
+		/// <summary>
62
+		/// 操作员
63
+		/// </summary>
64
+		public string F_UserName
65
+		{
66
+			set { _f_username = value; }
67
+			get { return _f_username; }
68
+		}
69
+		/// <summary>
70
+		/// 最后更新时间
71
+		/// </summary>
72
+		public DateTime? F_UpdateTime
73
+		{
74
+			set { _f_updatetime = value; }
75
+			get { return _f_updatetime; }
76
+		}
77
+		/// <summary>
78
+		/// 操作员id
79
+		/// </summary>
80
+		public int? F_UserId
81
+		{
82
+			set { _f_userid = value; }
83
+			get { return _f_userid; }
84
+		}
85
+		/// <summary>
86
+		/// 排序
87
+		/// </summary>
88
+		public int? F_Sort
89
+		{
90
+			set { _f_sort = value; }
91
+			get { return _f_sort; }
92
+		}
93
+		#endregion Model
94
+
95
+	}
96
+}

+ 306 - 0
代码/TVShoppingCallCenter_ZLJ/Models/Inputs/ProductInput.cs

@@ -0,0 +1,306 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace TVShoppingCallCenter_ZLJ.Models.Inputs
7
+{
8
+    public class ProductInput
9
+	{
10
+
11
+		#region Model
12
+		private int _f_productid;
13
+		private string _f_productnumber;
14
+		private string _f_productname;
15
+		private string _f_productshortname;
16
+		private string _f_classname;
17
+		private int _f_classid;
18
+		private string _f_pinyinshort;
19
+		private DateTime? _f_onsalebegin;
20
+		private DateTime? _f_onsaleend;
21
+		private bool _f_issale;
22
+		private string _f_factory;
23
+		private string _f_address;
24
+		private string _f_supplier;
25
+		private int? _f_integral;
26
+		private decimal? _f_marketprice;
27
+		private decimal? _f_memberprice;
28
+		private decimal? _f_specialprice;
29
+		private int? _f_isdelete;
30
+		private string _f_des;
31
+		private string _f_attribute;
32
+		private decimal? _f_weight;
33
+		private string _f_tag;
34
+		private string _f_picture;
35
+		private string _f_video;
36
+		private string _f_content;
37
+		private int? _f_userid;
38
+		private string _f_username;
39
+		private DateTime? _f_addtime;
40
+		private DateTime? _f_updatetime;
41
+		private int _f_sort;
42
+		private DateTime? _f_laststockupdate;
43
+		private int _f_stock = 0;
44
+
45
+		/// <summary>
46
+		/// 产品编号ID
47
+		/// </summary>
48
+		public int F_ProductId
49
+		{
50
+			set { _f_productid = value; }
51
+			get { return _f_productid; }
52
+		}
53
+		/// <summary>
54
+		/// 产品条形码
55
+		/// </summary>
56
+		public string F_ProductNumber
57
+		{
58
+			set { _f_productnumber = value; }
59
+			get { return _f_productnumber; }
60
+		}
61
+		/// <summary>
62
+		/// 产品名称
63
+		/// </summary>
64
+		public string F_ProductName
65
+		{
66
+			set { _f_productname = value; }
67
+			get { return _f_productname; }
68
+		}
69
+		/// <summary>
70
+		/// 产品简称/编码
71
+		/// </summary>
72
+		public string F_ProductShortName
73
+		{
74
+			set { _f_productshortname = value; }
75
+			get { return _f_productshortname; }
76
+		}
77
+		/// <summary>
78
+		/// 分类名称
79
+		/// </summary>
80
+		public string F_ClassName
81
+		{
82
+			set { _f_classname = value; }
83
+			get { return _f_classname; }
84
+		}
85
+		/// <summary>
86
+		/// 分类id
87
+		/// </summary>
88
+		public int F_ClassId
89
+		{
90
+			set { _f_classid = value; }
91
+			get { return _f_classid; }
92
+		}
93
+		/// <summary>
94
+		/// 拼音简码
95
+		/// </summary>
96
+		public string F_PinyinShort
97
+		{
98
+			set { _f_pinyinshort = value; }
99
+			get { return _f_pinyinshort; }
100
+		}
101
+		/// <summary>
102
+		/// 上架时间
103
+		/// </summary>
104
+		public DateTime? F_OnSaleBegin
105
+		{
106
+			set { _f_onsalebegin = value; }
107
+			get { return _f_onsalebegin; }
108
+		}
109
+		/// <summary>
110
+		/// 下架时间
111
+		/// </summary>
112
+		public DateTime? F_OnSaleEnd
113
+		{
114
+			set { _f_onsaleend = value; }
115
+			get { return _f_onsaleend; }
116
+		}
117
+		/// <summary>
118
+		/// 是否正在上架(可暂不启用)
119
+		/// </summary>
120
+		public bool F_IsSale
121
+		{
122
+			set { _f_issale = value; }
123
+			get { return _f_issale; }
124
+		}
125
+		/// <summary>
126
+		/// 生产厂家
127
+		/// </summary>
128
+		public string F_Factory
129
+		{
130
+			set { _f_factory = value; }
131
+			get { return _f_factory; }
132
+		}
133
+		/// <summary>
134
+		/// 产品产地
135
+		/// </summary>
136
+		public string F_Address
137
+		{
138
+			set { _f_address = value; }
139
+			get { return _f_address; }
140
+		}
141
+		/// <summary>
142
+		/// 供货商
143
+		/// </summary>
144
+		public string F_Supplier
145
+		{
146
+			set { _f_supplier = value; }
147
+			get { return _f_supplier; }
148
+		}
149
+		/// <summary>
150
+		/// 兑换积分
151
+		/// </summary>
152
+		public int? F_Integral
153
+		{
154
+			set { _f_integral = value; }
155
+			get { return _f_integral; }
156
+		}
157
+		/// <summary>
158
+		/// 市场价
159
+		/// </summary>
160
+		public decimal? F_MarketPrice
161
+		{
162
+			set { _f_marketprice = value; }
163
+			get { return _f_marketprice; }
164
+		}
165
+		/// <summary>
166
+		/// 会员价
167
+		/// </summary>
168
+		public decimal? F_MemberPrice
169
+		{
170
+			set { _f_memberprice = value; }
171
+			get { return _f_memberprice; }
172
+		}
173
+		/// <summary>
174
+		/// 特价/优惠价
175
+		/// </summary>
176
+		public decimal? F_SpecialPrice
177
+		{
178
+			set { _f_specialprice = value; }
179
+			get { return _f_specialprice; }
180
+		}
181
+		/// <summary>
182
+		/// 0整除 1已删除(隐藏)
183
+		/// </summary>
184
+		public int? F_IsDelete
185
+		{
186
+			set { _f_isdelete = value; }
187
+			get { return _f_isdelete; }
188
+		}
189
+		/// <summary>
190
+		/// 产品描述
191
+		/// </summary>
192
+		public string F_Des
193
+		{
194
+			set { _f_des = value; }
195
+			get { return _f_des; }
196
+		}
197
+		/// <summary>
198
+		/// 商品属性(体积)规格(暂不启用)
199
+		/// </summary>
200
+		public string F_Attribute
201
+		{
202
+			set { _f_attribute = value; }
203
+			get { return _f_attribute; }
204
+		}
205
+		/// <summary>
206
+		/// 产品重量
207
+		/// </summary>
208
+		public decimal? F_Weight
209
+		{
210
+			set { _f_weight = value; }
211
+			get { return _f_weight; }
212
+		}
213
+		/// <summary>
214
+		/// 产品标签
215
+		/// </summary>
216
+		public string F_Tag
217
+		{
218
+			set { _f_tag = value; }
219
+			get { return _f_tag; }
220
+		}
221
+		/// <summary>
222
+		/// 产品图片(暂不启用)
223
+		/// </summary>
224
+		public string F_Picture
225
+		{
226
+			set { _f_picture = value; }
227
+			get { return _f_picture; }
228
+		}
229
+		/// <summary>
230
+		/// 产品视频(暂不启用)
231
+		/// </summary>
232
+		public string F_Video
233
+		{
234
+			set { _f_video = value; }
235
+			get { return _f_video; }
236
+		}
237
+		/// <summary>
238
+		/// 产品图文介绍(暂不启用)
239
+		/// </summary>
240
+		public string F_Content
241
+		{
242
+			set { _f_content = value; }
243
+			get { return _f_content; }
244
+		}
245
+		/// <summary>
246
+		/// 操作人Id
247
+		/// </summary>
248
+		public int? F_UserId
249
+		{
250
+			set { _f_userid = value; }
251
+			get { return _f_userid; }
252
+		}
253
+		/// <summary>
254
+		/// 操作人姓名
255
+		/// </summary>
256
+		public string F_UserName
257
+		{
258
+			set { _f_username = value; }
259
+			get { return _f_username; }
260
+		}
261
+		/// <summary>
262
+		/// 添加时间
263
+		/// </summary>
264
+		public DateTime? F_AddTime
265
+		{
266
+			set { _f_addtime = value; }
267
+			get { return _f_addtime; }
268
+		}
269
+		/// <summary>
270
+		/// 上次操作时间
271
+		/// </summary>
272
+		public DateTime? F_UpdateTime
273
+		{
274
+			set { _f_updatetime = value; }
275
+			get { return _f_updatetime; }
276
+		}
277
+		/// <summary>
278
+		/// 排序
279
+		/// </summary>
280
+		public int F_Sort
281
+		{
282
+			set { _f_sort = value; }
283
+			get { return _f_sort; }
284
+		}
285
+
286
+		/// <summary>
287
+		/// 上次库存更新时间
288
+		/// </summary>
289
+		public DateTime? F_LastStockUpdate
290
+		{
291
+			set { _f_laststockupdate = value; }
292
+			get { return _f_laststockupdate; }
293
+		}
294
+
295
+		/// <summary>
296
+		/// 产品库存
297
+		/// </summary>
298
+		public int F_Stock
299
+		{
300
+			set { _f_stock = value; }
301
+			get { return _f_stock; }
302
+		}
303
+		#endregion Model
304
+
305
+	}
306
+}