diff --git a/ARW.Model/Dto/Business/GoodsManager/Goodss/GoodsDto.cs b/ARW.Model/Dto/Business/GoodsManager/Goodss/GoodsDto.cs index 4eb867d..5ddea76 100644 --- a/ARW.Model/Dto/Business/GoodsManager/Goodss/GoodsDto.cs +++ b/ARW.Model/Dto/Business/GoodsManager/Goodss/GoodsDto.cs @@ -114,6 +114,18 @@ namespace ARW.Model.Dto.Business.GoodsManager.Goodss + } + + /// + /// + /// @author lwh + /// @date 2023-06-28 + /// 上下架对象 + /// + public class GoodsShelfDto + { + public int GoodsShelfStatus { get; set; } + public string ids { get; set; } } diff --git a/ARW.Service/Business/BusinessService/GoodsManager/Goodss/GoodsService.cs b/ARW.Service/Business/BusinessService/GoodsManager/Goodss/GoodsService.cs index b73f856..2fed5b7 100644 --- a/ARW.Service/Business/BusinessService/GoodsManager/Goodss/GoodsService.cs +++ b/ARW.Service/Business/BusinessService/GoodsManager/Goodss/GoodsService.cs @@ -33,6 +33,7 @@ using ARW.Repository.Business.ShopManager.Shops; using ARW.Repository.Business.LogisticsManage.Deliverys; using ARW.Repository.Business.GoodsManager.GoodsServicess; using Senparc.CO2NET.Extensions; +using ARW.Repository.Business.Custom.Customers; namespace ARW.Service.Business.BusinessService.GoodsManager.Goodss { @@ -228,6 +229,37 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.Goodss } + /// + /// 上下架商品 + /// + public async Task ShelfGoods(int id, int status) + { + try + { + var res = await _GoodsRepository.GetFirstAsync(s => s.GoodsId == id); + var shelfStatus = res.GoodsShelfStatus; + + if (shelfStatus == status) + { + var errorRes = $"商品:【{res.GoodsName}】已{(status == 1 ? "上" : "下")}架,请勿重复{(status == 1 ? "上" : "下")}架
"; + return errorRes; + } + + await UseTranAsync(async () => + { + await _GoodsRepository.UpdateAsync(f => new Goods { GoodsShelfStatus = status, Update_time = DateTime.Now }, s => s.GoodsId == id); + }); + + var addStr = $"商品:【{res.GoodsName}】{(status == 1 ? "上" : "下")}架成功!
"; + return addStr; + } + catch (Exception) + { + throw; + } + } + + #region Excel处理 /// @@ -242,8 +274,6 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.Goodss if (string.IsNullOrEmpty(Goods.GoodsPicture)) throw new CustomException("商品图片不能为空"); if (Goods.GoodsPriceLowest == 0) throw new CustomException("商品价格不能为空"); if (Goods.GoodsTotalInventory == 0) throw new CustomException("库存总量不能为空"); - if (string.IsNullOrEmpty(Goods.GoodsPicture)) throw new CustomException("商品图片不能为空"); - if (string.IsNullOrEmpty(Goods.GoodsPicture)) throw new CustomException("商品图片不能为空"); // 店铺 @@ -279,7 +309,7 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.Goodss // 配送模板 - var delivery = await _DeliveryRepository.GetFirstAsync(s => s.DeliveryName == "全国配送" && s.ShopGuid == Goods.ShopGuid); + var delivery = await _DeliveryRepository.GetFirstAsync(s => s.DeliveryName == "全国包邮" && s.ShopGuid == Goods.ShopGuid); Goods.DeliveryGuid = delivery.DeliveryGuid; @@ -299,14 +329,18 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.Goodss Goods.GoodsShelfStatus = 1; } + // 排序 + if (Goods.GoodsSort == 0) + { + Goods.GoodsSort = 100; + } + Goods.GoodsSpecType = 1; Goods.GoodsDeductStockType = 1; Goods.GoodsIsPointsGift = 0; Goods.GoodsIsPointsDiscount = 0; Goods.GoodsIsAlonePointsDiscount = 0; Goods.GoodsIsEnableGrade = 1; - Goods.GoodsSpecType = 0; - Goods.GoodsSort = 10; return Goods; } @@ -334,7 +368,7 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.Goodss GoodsVideoCover = goodsVo.GoodsVideoCover, GoodsPicture = goodsVo.GoodsPicture, GoodsSellingPoint = goodsVo.GoodsSellingPoint, - GoodsSpecType = goodsVo.GoodsSpecType, + GoodsSpecType = 1, GoodsPriceLowest = goodsVo.GoodsPriceLowest, GoodsPriceHighest = goodsVo.GoodsPriceHighest, GoodsDashedPriceLowest = goodsVo.GoodsDashedPriceLowest, @@ -763,8 +797,6 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.Goodss - - #endregion } diff --git a/ARW.Service/Business/IBusinessService/GoodsManager/Goodss/IGoodsService.cs b/ARW.Service/Business/IBusinessService/GoodsManager/Goodss/IGoodsService.cs index 50ad7a5..8e89668 100644 --- a/ARW.Service/Business/IBusinessService/GoodsManager/Goodss/IGoodsService.cs +++ b/ARW.Service/Business/IBusinessService/GoodsManager/Goodss/IGoodsService.cs @@ -56,5 +56,11 @@ namespace ARW.Service.Business.IBusinessService.GoodsManager.Goodss Task> HandleExportData(List data); + /// + /// 上下架商品 + /// + Task ShelfGoods(int id, int status); + + } } diff --git a/ARW.WebApi/Controllers/Business/GoodsManager/Goodss/GoodsController.cs b/ARW.WebApi/Controllers/Business/GoodsManager/Goodss/GoodsController.cs index c6c433c..a5c48a3 100644 --- a/ARW.WebApi/Controllers/Business/GoodsManager/Goodss/GoodsController.cs +++ b/ARW.WebApi/Controllers/Business/GoodsManager/Goodss/GoodsController.cs @@ -23,6 +23,7 @@ using ARW.Service.Business.IBusinessService.GoodsManager.GoodsSpecs.GoodsSpecRel using ARW.Service.Business.IBusinessService.GoodsManager.GoodsSpecs.Specs; using ARW.Service.Business.IBusinessService.GoodsManager.GoodsSpecs.SpecValues; using ARW.Service.Business.IBusinessService.ShopManager.Shops; +using ARW.Model.Dto.Business.ShopManager.Shops; namespace ARW.WebApi.Controllers.Business.GoodsManager.Goodss { @@ -269,6 +270,25 @@ namespace ARW.WebApi.Controllers.Business.GoodsManager.Goodss } + /// + /// 上下架商品 + /// + /// + [HttpPut("shelfGoods")] + public async Task ShelfGoods([FromBody] GoodsShelfDto param) + { + int[] idsArr = Tools.SpitIntArrary(param.ids); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"操作失败 Id 不能为空")); } + + var msgList = new List(); + foreach (var item in idsArr) + { + var msg = await _GoodsService.ShelfGoods(item, param.GoodsShelfStatus); + msgList.Add(msg); + } + + return SUCCESS(msgList.ToArray()); + } } diff --git a/ARW.WebApi/wwwroot/excel/商品导入模板模板 (4).xlsx b/ARW.WebApi/wwwroot/excel/商品导入模板模板 (4).xlsx new file mode 100644 index 0000000..edea3be Binary files /dev/null and b/ARW.WebApi/wwwroot/excel/商品导入模板模板 (4).xlsx differ