diff --git a/ARW.Model/Dto/Business/GoodsManager/Goodss/GoodsDto.cs b/ARW.Model/Dto/Business/GoodsManager/Goodss/GoodsDto.cs
new file mode 100644
index 0000000..e1960b1
--- /dev/null
+++ b/ARW.Model/Dto/Business/GoodsManager/Goodss/GoodsDto.cs
@@ -0,0 +1,133 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using ARW.Model.Models.Business.GoodsManager.Goodss;
+
+namespace ARW.Model.Dto.Business.GoodsManager.Goodss
+{
+ ///
+ /// 商品输入对象
+ ///
+ /// @author 黎文豪
+ /// @date 2023-06-19
+ ///
+ public class GoodsDto
+ {
+
+ public int GoodsId { get; set; }
+
+ public long GoodsGuid { get; set; }
+
+ [Required(ErrorMessage = "店铺guid不能为空")]
+ public long ShopGuid { get; set; }
+
+ [Required(ErrorMessage = "商品类目guid不能为空")]
+ public long GoodsCategoryGuid { get; set; }
+
+ [Required(ErrorMessage = "商品规格guid不能为空")]
+ public long GoodsSkuGuid { get; set; }
+
+ [Required(ErrorMessage = "配送模板guid不能为空")]
+ public long DeliveryGuid { get; set; }
+
+ [Required(ErrorMessage = "名称不能为空")]
+ public string GoodsName { get; set; }
+
+ [Required(ErrorMessage = "编码不能为空")]
+ public string GoodsCoding { get; set; }
+
+ public string GoodsMainImageVideo { get; set; }
+
+ public string GoodsVideoCover { get; set; }
+
+ public string GoodsSellingPoint { get; set; }
+
+ public int GoodsSpecType { get; set; }
+
+
+ [Required(ErrorMessage = "图片不能为空")]
+ public string GoodsPicture { get; set; }
+
+ [Required(ErrorMessage = "价格(最低)不能为空")]
+ public decimal GoodsPriceLowest { get; set; }
+
+ [Required(ErrorMessage = "价格(最高)不能为空")]
+ public decimal GoodsPriceHighest { get; set; }
+
+ [Required(ErrorMessage = "划线价格(最低)不能为空")]
+ public decimal GoodsDashedPriceLowest { get; set; }
+
+ [Required(ErrorMessage = "划线价格(最高)不能为空")]
+ public decimal GoodsDashedPriceHighest { get; set; }
+
+ [Required(ErrorMessage = "库存总量不能为空")]
+ public int GoodsTotalInventory { get; set; }
+
+ [Required(ErrorMessage = "初始销量不能为空")]
+ public int GoodsSalesInitial { get; set; }
+
+ [Required(ErrorMessage = "实际销量不能为空")]
+ public int GoodsSalesActual { get; set; }
+
+ [Required(ErrorMessage = "详情不能为空")]
+ public string GoodsDetails { get; set; }
+
+ [Required(ErrorMessage = "库存计算方式(1下单立减库存 2付款立减库存)不能为空")]
+ public int GoodsDeductStockType { get; set; }
+
+ [Required(ErrorMessage = "是否赠送积分(1开启 0关闭)不能为空")]
+ public int GoodsIsPointsGift { get; set; }
+
+ [Required(ErrorMessage = "是否允许使用积分抵扣(1允许 0不允许)不能为空")]
+ public int GoodsIsPointsDiscount { get; set; }
+
+ [Required(ErrorMessage = "积分抵扣设置(0默认抵扣 1单独设置抵扣)不能为空")]
+ public int GoodsIsAlonePointsDiscount { get; set; }
+
+ public string GoodsPointsDiscountConfig { get; set; }
+
+ [Required(ErrorMessage = "是否开启会员折扣(1开启 0关闭)不能为空")]
+ public int GoodsIsEnableGrade { get; set; }
+
+ [Required(ErrorMessage = "会员折扣设置(0默认等级折扣 1单独设置折扣)不能为空")]
+ public int GoodsIsAloneGrade { get; set; }
+
+ public string GoodsAloneGradeEquity { get; set; }
+
+ [Required(ErrorMessage = "上下架状态(1上架 2下架)不能为空")]
+ public int GoodsShelfStatus { get; set; }
+
+ [Required(ErrorMessage = "排序不能为空")]
+ public int GoodsSort { get; set; }
+
+
+
+
+
+ }
+
+
+ ///
+ /// 商品查询对象
+ ///
+ /// @author 黎文豪
+ /// @date 2023-06-19
+ ///
+ public class GoodsQueryDto : PagerInfo
+ {
+
+ public long? ShopGuid { get; set; }
+
+ public long? GoodsCategoryGuid { get; set; }
+
+ public string GoodsName { get; set; }
+
+ public string GoodsCoding { get; set; }
+
+ public string ids { get; set; }
+ }
+
+
+
+
+}
diff --git a/ARW.Model/Models/Business/GoodsManager/Goodss/Goods.cs b/ARW.Model/Models/Business/GoodsManager/Goodss/Goods.cs
new file mode 100644
index 0000000..d45600a
--- /dev/null
+++ b/ARW.Model/Models/Business/GoodsManager/Goodss/Goods.cs
@@ -0,0 +1,305 @@
+using System;
+using System.Collections.Generic;
+using SqlSugar;
+using OfficeOpenXml.Attributes;
+using Newtonsoft.Json;
+
+namespace ARW.Model.Models.Business.GoodsManager.Goodss
+{
+ ///
+ /// 商品,数据实体对象
+ ///
+ /// @author 黎文豪
+ /// @date 2023-06-19
+ ///
+ [SugarTable("tb_goods")]
+ public class Goods : BusinessBase
+ {
+
+ ///
+ /// 描述 :
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "GoodsId")]
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "goods_id")]
+ public int GoodsId { get; set; }
+
+
+ ///
+ /// 描述 :
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "GoodsGuid")]
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "goods_guid")]
+ public long GoodsGuid { get; set; }
+
+
+ ///
+ /// 描述 :店铺guid
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "店铺guid")]
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [SugarColumn(ColumnName = "shop_guid")]
+ public long ShopGuid { get; set; }
+
+
+ ///
+ /// 描述 :商品类目guid
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "商品类目guid")]
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [SugarColumn(ColumnName = "goods_category_guid")]
+ public long GoodsCategoryGuid { get; set; }
+
+
+ ///
+ /// 描述 :商品规格guid
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "商品规格guid")]
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [SugarColumn(ColumnName = "goods_sku_guid")]
+ public long GoodsSkuGuid { get; set; }
+
+
+ ///
+ /// 描述 :配送模板guid
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "配送模板guid")]
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [SugarColumn(ColumnName = "delivery_guid")]
+ public long DeliveryGuid { get; set; }
+
+
+ ///
+ /// 描述 :名称
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "名称")]
+ [SugarColumn(ColumnName = "goods_name")]
+ public string GoodsName { get; set; }
+
+
+ ///
+ /// 描述 :编码
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "编码")]
+ [SugarColumn(ColumnName = "goods_coding")]
+ public string GoodsCoding { get; set; }
+
+
+ ///
+ /// 描述 :主图视频
+ /// 空值 : true
+ ///
+ [EpplusTableColumn(Header = "主图视频")]
+ [SugarColumn(ColumnName = "goods_main_image_video")]
+ public string GoodsMainImageVideo { get; set; }
+
+
+ ///
+ /// 描述 :视频封面
+ /// 空值 : true
+ ///
+ [EpplusTableColumn(Header = "视频封面")]
+ [SugarColumn(ColumnName = "goods_video_cover")]
+ public string GoodsVideoCover { get; set; }
+
+
+ ///
+ /// 描述 :图片
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "图片")]
+ [SugarColumn(ColumnName = "goods_picture")]
+ public string GoodsPicture { get; set; }
+
+ ///
+ /// 描述 :卖点
+ /// 空值 : true
+ ///
+ [EpplusTableColumn(Header = "卖点")]
+ [SugarColumn(ColumnName = "goods_selling_point")]
+ public string GoodsSellingPoint { get; set; }
+
+ ///
+ /// 描述 :商品规格(1单规格 2多规格)
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "商品规格(1单规格 2多规格)")]
+ [SugarColumn(ColumnName = "goods_spec_type")]
+ public string GoodsSpecType { get; set; }
+
+
+ ///
+ /// 描述 :价格(最低)
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "价格(最低)")]
+ [SugarColumn(ColumnName = "goods_price_lowest")]
+ public decimal GoodsPriceLowest { get; set; }
+
+
+ ///
+ /// 描述 :价格(最高)
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "价格(最高)")]
+ [SugarColumn(ColumnName = "goods_price_highest")]
+ public decimal GoodsPriceHighest { get; set; }
+
+
+ ///
+ /// 描述 :划线价格(最低)
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "划线价格(最低)")]
+ [SugarColumn(ColumnName = "goods_dashed_price_lowest")]
+ public decimal GoodsDashedPriceLowest { get; set; }
+
+ ///
+ /// 描述 :划线价格(最高)
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "划线价格(最高)")]
+ [SugarColumn(ColumnName = "goods_dashed_price_highest")]
+ public decimal GoodsDashedPriceHighest { get; set; }
+
+
+ ///
+ /// 描述 :库存总量
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "库存总量")]
+ [SugarColumn(ColumnName = "goods_total_inventory")]
+ public int GoodsTotalInventory { get; set; }
+
+
+ ///
+ /// 描述 :初始销量
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "初始销量")]
+ [SugarColumn(ColumnName = "goods_sales_initial")]
+ public int GoodsSalesInitial { get; set; }
+
+
+ ///
+ /// 描述 :实际销量
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "实际销量")]
+ [SugarColumn(ColumnName = "goods_sales_actual")]
+ public int GoodsSalesActual { get; set; }
+
+
+ ///
+ /// 描述 :详情
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "详情")]
+ [SugarColumn(ColumnName = "goods_details")]
+ public string GoodsDetails { get; set; }
+
+
+ ///
+ /// 描述 :库存计算方式(1下单立减库存 2付款立减库存)
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "库存计算方式(1下单立减库存 2付款立减库存)")]
+ [SugarColumn(ColumnName = "goods_deduct_stock_type")]
+ public int GoodsDeductStockType { get; set; }
+
+
+ ///
+ /// 描述 :是否赠送积分(1开启 0关闭)
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "是否赠送积分(1开启 0关闭)")]
+ [SugarColumn(ColumnName = "goods_is_points_gift")]
+ public int GoodsIsPointsGift { get; set; }
+
+
+ ///
+ /// 描述 :是否允许使用积分抵扣(1允许 0不允许)
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "是否允许使用积分抵扣(1允许 0不允许)")]
+ [SugarColumn(ColumnName = "goods_is_points_discount")]
+ public int GoodsIsPointsDiscount { get; set; }
+
+
+ ///
+ /// 描述 :积分抵扣设置(0默认抵扣 1单独设置抵扣)
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "积分抵扣设置(0默认抵扣 1单独设置抵扣)")]
+ [SugarColumn(ColumnName = "goods_is_alone_points_discount")]
+ public int GoodsIsAlonePointsDiscount { get; set; }
+
+
+ ///
+ /// 描述 :单独设置积分抵扣的配置
+ /// 空值 : true
+ ///
+ [EpplusTableColumn(Header = "单独设置积分抵扣的配置")]
+ [SugarColumn(ColumnName = "goods_points_discount_config")]
+ public string GoodsPointsDiscountConfig { get; set; }
+
+
+ ///
+ /// 描述 :是否开启会员折扣(1开启 0关闭)
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "是否开启会员折扣(1开启 0关闭)")]
+ [SugarColumn(ColumnName = "goods_is_enable_grade")]
+ public int GoodsIsEnableGrade { get; set; }
+
+
+ ///
+ /// 描述 :会员折扣设置(0默认等级折扣 1单独设置折扣)
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "会员折扣设置(0默认等级折扣 1单独设置折扣)")]
+ [SugarColumn(ColumnName = "goods_is_alone_grade")]
+ public int GoodsIsAloneGrade { get; set; }
+
+
+ ///
+ /// 描述 :单独设置折扣的配置
+ /// 空值 : true
+ ///
+ [EpplusTableColumn(Header = "单独设置折扣的配置")]
+ [SugarColumn(ColumnName = "goods_alone_grade_equity")]
+ public string GoodsAloneGradeEquity { get; set; }
+
+
+ ///
+ /// 描述 :上下架状态(1上架 2下架)
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "上下架状态(1上架 2下架)")]
+ [SugarColumn(ColumnName = "goods_shelf_status")]
+ public int GoodsShelfStatus { get; set; }
+
+
+ ///
+ /// 描述 :排序
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "排序")]
+ [SugarColumn(ColumnName = "goods_sort")]
+ public int GoodsSort { get; set; }
+
+
+
+
+
+
+ }
+}
\ No newline at end of file
diff --git a/ARW.Model/Vo/Business/GoodsManager/Goodss/GoodsVo.cs b/ARW.Model/Vo/Business/GoodsManager/Goodss/GoodsVo.cs
new file mode 100644
index 0000000..d87a469
--- /dev/null
+++ b/ARW.Model/Vo/Business/GoodsManager/Goodss/GoodsVo.cs
@@ -0,0 +1,237 @@
+using Newtonsoft.Json;
+using OfficeOpenXml.Attributes;
+using SqlSugar;
+using System;
+
+namespace ARW.Model.Vo.Business.GoodsManager.Goodss
+{
+ ///
+ /// 商品展示对象
+ ///
+ /// @author 黎文豪
+ /// @date 2023-06-19
+ ///
+ public class GoodsVo
+ {
+
+
+ ///
+ /// 描述 :
+ ///
+ [EpplusIgnore]
+ public int GoodsId { get; set; }
+
+
+ ///
+ /// 描述 :
+ ///
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [EpplusIgnore]
+ public long GoodsGuid { get; set; }
+
+
+ ///
+ /// 描述 :店铺guid
+ ///
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [EpplusTableColumn(Header = "店铺guid")]
+ public long ShopGuid { get; set; }
+
+
+ ///
+ /// 描述 :商品类目guid
+ ///
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [EpplusTableColumn(Header = "商品类目guid")]
+ public long GoodsCategoryGuid { get; set; }
+
+
+ ///
+ /// 描述 :商品规格guid
+ ///
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [EpplusTableColumn(Header = "商品规格guid")]
+ public long GoodsSkuGuid { get; set; }
+
+
+ ///
+ /// 描述 :配送模板guid
+ ///
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [EpplusTableColumn(Header = "配送模板guid")]
+ public long DeliveryGuid { get; set; }
+
+
+ ///
+ /// 描述 :名称
+ ///
+ [EpplusTableColumn(Header = "名称")]
+ public string GoodsName { get; set; }
+
+
+ ///
+ /// 描述 :编码
+ ///
+ [EpplusTableColumn(Header = "编码")]
+ public string GoodsCoding { get; set; }
+
+
+ ///
+ /// 描述 :主图视频
+ ///
+ [EpplusIgnore]
+ public string GoodsMainImageVideo { get; set; }
+
+
+ ///
+ /// 描述 :视频封面
+ ///
+ [EpplusIgnore]
+ public string GoodsVideoCover { get; set; }
+
+ ///
+ /// 描述 :卖点
+ ///
+ [EpplusTableColumn(Header = "卖点")]
+ public string GoodsSellingPoint { get; set; }
+
+ ///
+ /// 描述 :商品规格(1单规格 2多规格)
+ /// 空值 : false
+ ///
+ [EpplusTableColumn(Header = "商品规格")]
+ public string GoodsSpecType { get; set; }
+
+ ///
+ /// 描述 :图片
+ ///
+ [EpplusTableColumn(Header = "图片")]
+ public string GoodsPicture { get; set; }
+
+
+ ///
+ /// 描述 :价格(最低)
+ ///
+ [EpplusTableColumn(Header = "价格(最低)")]
+ public decimal GoodsPriceLowest { get; set; }
+
+
+ ///
+ /// 描述 :价格(最高)
+ ///
+ [EpplusTableColumn(Header = "价格(最高)")]
+ public decimal GoodsPriceHighest { get; set; }
+
+
+ ///
+ /// 描述 :划线价格(最低)
+ ///
+ [EpplusTableColumn(Header = "划线价格(最低)")]
+ public decimal GoodsDashedPriceLowest { get; set; }
+
+ ///
+ /// 描述 :划线价格(最高)
+ ///
+ [EpplusTableColumn(Header = "划线价格(最高)")]
+ public decimal GoodsDashedPriceHighest { get; set; }
+
+
+ ///
+ /// 描述 :库存总量
+ ///
+ [EpplusTableColumn(Header = "库存总量")]
+ public int GoodsTotalInventory { get; set; }
+
+
+ ///
+ /// 描述 :初始销量
+ ///
+ [EpplusTableColumn(Header = "初始销量")]
+ public int GoodsSalesInitial { get; set; }
+
+
+ ///
+ /// 描述 :实际销量
+ ///
+ [EpplusTableColumn(Header = "实际销量")]
+ public int GoodsSalesActual { get; set; }
+
+
+ ///
+ /// 描述 :详情
+ ///
+ [EpplusTableColumn(Header = "详情")]
+ public string GoodsDetails { get; set; }
+
+
+ ///
+ /// 描述 :库存计算方式(1下单立减库存 2付款立减库存)
+ ///
+ [EpplusTableColumn(Header = "库存计算方式(1下单立减库存 2付款立减库存)")]
+ public int GoodsDeductStockType { get; set; }
+
+
+ ///
+ /// 描述 :是否赠送积分(1开启 0关闭)
+ ///
+ [EpplusTableColumn(Header = "是否赠送积分(1开启 0关闭)")]
+ public int GoodsIsPointsGift { get; set; }
+
+
+ ///
+ /// 描述 :是否允许使用积分抵扣(1允许 0不允许)
+ ///
+ [EpplusTableColumn(Header = "是否允许使用积分抵扣(1允许 0不允许)")]
+ public int GoodsIsPointsDiscount { get; set; }
+
+
+ ///
+ /// 描述 :积分抵扣设置(0默认抵扣 1单独设置抵扣)
+ ///
+ [EpplusTableColumn(Header = "积分抵扣设置(0默认抵扣 1单独设置抵扣)")]
+ public int GoodsIsAlonePointsDiscount { get; set; }
+
+
+ ///
+ /// 描述 :单独设置积分抵扣的配置
+ ///
+ [EpplusIgnore]
+ public string GoodsPointsDiscountConfig { get; set; }
+
+
+ ///
+ /// 描述 :是否开启会员折扣(1开启 0关闭)
+ ///
+ [EpplusTableColumn(Header = "是否开启会员折扣(1开启 0关闭)")]
+ public int GoodsIsEnableGrade { get; set; }
+
+
+ ///
+ /// 描述 :会员折扣设置(0默认等级折扣 1单独设置折扣)
+ ///
+ [EpplusTableColumn(Header = "会员折扣设置(0默认等级折扣 1单独设置折扣)")]
+ public int GoodsIsAloneGrade { get; set; }
+
+
+ ///
+ /// 描述 :单独设置折扣的配置
+ ///
+ [EpplusIgnore]
+ public string GoodsAloneGradeEquity { get; set; }
+
+
+ ///
+ /// 描述 :上下架状态(1上架 2下架)
+ ///
+ [EpplusTableColumn(Header = "上下架状态(1上架 2下架)")]
+ public int GoodsShelfStatus { get; set; }
+
+
+ ///
+ /// 描述 :排序
+ ///
+ [EpplusTableColumn(Header = "排序")]
+ public int GoodsSort { get; set; }
+
+ }
+}
diff --git a/ARW.Repository/Business/GoodsManager/Goodss/GoodsRepository.cs b/ARW.Repository/Business/GoodsManager/Goodss/GoodsRepository.cs
new file mode 100644
index 0000000..815cd77
--- /dev/null
+++ b/ARW.Repository/Business/GoodsManager/Goodss/GoodsRepository.cs
@@ -0,0 +1,20 @@
+using System;
+using Infrastructure.Attribute;
+using ARW.Repository.System;
+using ARW.Model.Models.Business.GoodsManager.Goodss;
+
+namespace ARW.Repository.Business.GoodsManager.Goodss
+{
+ ///
+ /// 商品仓储
+ ///
+ /// @author 黎文豪
+ /// @date 2023-06-19
+ ///
+ [AppService(ServiceLifetime = LifeTime.Transient)]
+ public class GoodsRepository : BaseRepository
+ {
+ #region 业务逻辑代码
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/ARW.Service/Business/BusinessService/GoodsManager/Goodss/GoodsService.cs b/ARW.Service/Business/BusinessService/GoodsManager/Goodss/GoodsService.cs
new file mode 100644
index 0000000..d3602d9
--- /dev/null
+++ b/ARW.Service/Business/BusinessService/GoodsManager/Goodss/GoodsService.cs
@@ -0,0 +1,200 @@
+using Infrastructure.Attribute;
+using Microsoft.AspNetCore.Http;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Infrastructure;
+using ARW.Model;
+using ARW.Repository;
+using ARW.Repository.Business.GoodsManager.Goodss;
+using ARW.Service.Business.IBusinessService.GoodsManager.Goodss;
+using ARW.Model.Dto.Business.GoodsManager.Goodss;
+using ARW.Model.Models.Business.GoodsManager.Goodss;
+using ARW.Model.Vo.Business.GoodsManager.Goodss;
+
+namespace ARW.Service.Business.BusinessService.GoodsManager.Goodss
+{
+ ///
+ /// 商品接口实现类
+ ///
+ /// @author 黎文豪
+ /// @date 2023-06-19
+ ///
+ [AppService(ServiceType = typeof(IGoodsService), ServiceLifetime = LifeTime.Transient)]
+ public class GoodsServiceImpl : BaseService, IGoodsService
+ {
+ private readonly GoodsRepository _GoodsRepository;
+
+ public GoodsServiceImpl(GoodsRepository GoodsRepository)
+ {
+ this._GoodsRepository = GoodsRepository;
+ }
+
+ #region 业务逻辑代码
+
+
+ ///
+ /// 查询商品分页列表
+ ///
+ public async Task> GetGoodsList(GoodsQueryDto parm)
+ {
+ //开始拼装查询条件d
+ var predicate = Expressionable.Create();
+
+ predicate = predicate.AndIF(parm.ShopGuid != null, s => s.ShopGuid == parm.ShopGuid);
+ predicate = predicate.AndIF(parm.GoodsCategoryGuid != null, s => s.GoodsCategoryGuid == parm.GoodsCategoryGuid);
+ predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.GoodsName), s => s.GoodsName.Contains(parm.GoodsName));
+ predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.GoodsCoding), s => s.GoodsCoding.Contains(parm.GoodsCoding));
+ var query = _GoodsRepository
+ .Queryable()
+ .Where(predicate.ToExpression())
+ .OrderBy(s => s.GoodsSort, OrderByType.Asc)
+ .Select(s => new GoodsVo
+ {
+ GoodsId = s.GoodsId,
+ GoodsGuid = s.GoodsGuid,
+ ShopGuid = s.ShopGuid,
+ GoodsCategoryGuid = s.GoodsCategoryGuid,
+ GoodsSkuGuid = s.GoodsSkuGuid,
+ DeliveryGuid = s.DeliveryGuid,
+ GoodsName = s.GoodsName,
+ GoodsCoding = s.GoodsCoding,
+ GoodsMainImageVideo = s.GoodsMainImageVideo,
+ GoodsVideoCover = s.GoodsVideoCover,
+ GoodsPicture = s.GoodsPicture,
+ GoodsSellingPoint = s.GoodsSellingPoint,
+ GoodsSpecType = s.GoodsSpecType,
+ GoodsPriceLowest = s.GoodsPriceLowest,
+ GoodsPriceHighest = s.GoodsPriceHighest,
+ GoodsDashedPriceLowest = s.GoodsDashedPriceLowest,
+ GoodsTotalInventory = s.GoodsTotalInventory,
+ GoodsSalesInitial = s.GoodsSalesInitial,
+ GoodsSalesActual = s.GoodsSalesActual,
+ GoodsDetails = s.GoodsDetails,
+ GoodsDeductStockType = s.GoodsDeductStockType,
+ GoodsIsPointsGift = s.GoodsIsPointsGift,
+ GoodsIsPointsDiscount = s.GoodsIsPointsDiscount,
+ GoodsIsAlonePointsDiscount = s.GoodsIsAlonePointsDiscount,
+ GoodsPointsDiscountConfig = s.GoodsPointsDiscountConfig,
+ GoodsIsEnableGrade = s.GoodsIsEnableGrade,
+ GoodsIsAloneGrade = s.GoodsIsAloneGrade,
+ GoodsAloneGradeEquity = s.GoodsAloneGradeEquity,
+ GoodsShelfStatus = s.GoodsShelfStatus,
+ GoodsSort = s.GoodsSort,
+ });
+
+
+ return await query.ToPageAsync(parm);
+ }
+
+ ///
+ /// 添加或修改商品
+ ///
+ public async Task AddOrUpdateGoods(Goods model)
+ {
+ if (model.GoodsId != 0)
+ {
+ var response = await _GoodsRepository.UpdateAsync(model);
+ return "修改成功!";
+ }
+ else
+ {
+
+ var response = await _GoodsRepository.InsertReturnSnowflakeIdAsync(model);
+ return "添加成功!";
+ }
+ }
+
+ #region Excel处理
+ ///
+ /// 数据导入处理
+ ///
+ public async Task HandleImportData(GoodsVo Goods)
+ {
+ return Goods;
+ }
+
+
+ ///
+ /// Excel导入
+ ///
+ public async Task ImportExcel(Goods Goods, int index, bool isUpdateSupport, string user)
+ {
+ try
+ {
+ // 空值判断
+ // if (Goods.GoodsId == null) throw new CustomException("商品不能为空");
+
+ if (isUpdateSupport)
+ {
+ // 判断唯一值
+ var model = await GetFirstAsync(s => s.GoodsId == Goods.GoodsId);
+
+ // 如果为空就新增数据
+ if (model == null)
+ {
+ // 开启事务
+ var res = await UseTranAsync(async () =>
+ {
+ var addRes = await AddOrUpdateGoods(Goods);
+ });
+ var addStr = $"第 {index} 行 => 商品:【{Goods.GoodsId}】新增成功!
";
+ return addStr;
+ }
+ else
+ {
+ // 如果有数据就进行修改
+ // 开启事务
+ await UseTranAsync(async () =>
+ {
+ Goods.GoodsId = model.GoodsId;
+ Goods.GoodsGuid = model.GoodsGuid;
+ Goods.Update_by = user;
+ Goods.Update_time = DateTime.Now;
+ var editRes = await AddOrUpdateGoods(Goods);
+ });
+ var editStr = $"第 {index} 行 => 商品:【{Goods.GoodsId}】更新成功!
";
+ return editStr;
+ }
+ }
+ else
+ {
+ // 开启事务
+ var res = await UseTranAsync(async () =>
+ {
+ var addRes = await AddOrUpdateGoods(Goods);
+ });
+ //Console.WriteLine(res.IsSuccess);
+ var addStr = $"第 {index} 行 => 商品:【{Goods.GoodsId}】新增成功!
";
+ return addStr;
+ }
+ }
+ catch (Exception ex)
+ {
+ var errorRes = $"第 {index} 行 => 商品:【{Goods.GoodsId}】导入失败!{ex.Message}
";
+ return errorRes;
+ throw;
+ }
+ }
+
+
+
+ ///
+ /// Excel数据导出处理
+ ///
+ public async Task> HandleExportData(List data)
+ {
+ return data;
+ }
+
+ #endregion
+
+
+
+ #endregion
+
+ }
+}
diff --git a/ARW.Service/Business/IBusinessService/GoodsManager/Goodss/IGoodsService.cs b/ARW.Service/Business/IBusinessService/GoodsManager/Goodss/IGoodsService.cs
new file mode 100644
index 0000000..cddcb51
--- /dev/null
+++ b/ARW.Service/Business/IBusinessService/GoodsManager/Goodss/IGoodsService.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ARW.Model;
+using ARW.Model.Dto.Business.GoodsManager.Goodss;
+using ARW.Model.Models.Business.GoodsManager.Goodss;
+using ARW.Model.Vo.Business.GoodsManager.Goodss;
+
+namespace ARW.Service.Business.IBusinessService.GoodsManager.Goodss
+{
+ ///
+ /// 商品接口类
+ ///
+ /// @author 黎文豪
+ /// @date 2023-06-19
+ ///
+ public interface IGoodsService : IBaseService
+ {
+ ///
+ /// 获取商品分页列表
+ ///
+ ///
+ ///
+ Task> GetGoodsList(GoodsQueryDto parm);
+
+
+ ///
+ /// 添加或修改商品
+ ///
+ ///
+ ///
+ Task AddOrUpdateGoods(Goods parm);
+
+
+ ///
+ /// 数据导入处理
+ ///
+ ///
+ ///
+ Task HandleImportData(GoodsVo GoodsVo);
+
+
+ ///
+ /// Excel导入
+ ///
+ ///
+ ///
+ Task ImportExcel(Goods Goods,int index,bool isUpdateSupport,string user);
+
+ ///
+ /// Excel导出
+ ///
+ Task> HandleExportData(List data);
+
+
+ }
+}
diff --git a/ARW.WebApi/Controllers/Business/GoodsManager/Goodss/GoodsController.cs b/ARW.WebApi/Controllers/Business/GoodsManager/Goodss/GoodsController.cs
new file mode 100644
index 0000000..06bd79f
--- /dev/null
+++ b/ARW.WebApi/Controllers/Business/GoodsManager/Goodss/GoodsController.cs
@@ -0,0 +1,180 @@
+using Infrastructure;
+using Infrastructure.Attribute;
+using Infrastructure.Enums;
+using Infrastructure.Model;
+using Mapster;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using ARW.Admin.WebApi.Extensions;
+using ARW.Admin.WebApi.Filters;
+using ARW.Common;
+using ARW.Model.Dto.Business.GoodsManager.Goodss;
+using ARW.Service.Business.IBusinessService.GoodsManager.Goodss;
+using ARW.Admin.WebApi.Controllers;
+using ARW.Model.Models.Business.GoodsManager.Goodss;
+using ARW.Model.Vo.Business.GoodsManager.Goodss;
+using Microsoft.AspNetCore.Authorization;
+using ARW.Admin.WebApi.Framework;
+
+
+namespace ARW.WebApi.Controllers.Business.GoodsManager.Goodss
+{
+ ///
+ /// 商品控制器
+ ///
+ /// @author 黎文豪
+ /// @date 2023-06-19
+ ///
+ [Verify]
+ [Route("business/[controller]")]
+ public class GoodsController : BaseController
+ {
+ private readonly IGoodsService _GoodsService;
+
+ ///
+ /// 依赖注入
+ ///
+ /// 商品服务
+ public GoodsController(IGoodsService GoodsService)
+ {
+ _GoodsService = GoodsService;
+ }
+
+
+ ///
+ /// 获取商品列表
+ ///
+ /// 查询参数
+ ///
+ [HttpGet("getGoodsList")]
+ [ActionPermissionFilter(Permission = "business:goods:list")]
+ public async Task GetGoodsList([FromQuery] GoodsQueryDto parm)
+ {
+ var res = await _GoodsService.GetGoodsList(parm);
+ return SUCCESS(res);
+ }
+
+ ///
+ /// 添加或修改商品
+ ///
+ ///
+ ///
+ [HttpPost("addOrUpdateGoods")]
+ [ActionPermissionFilter(Permission = "business:goods:addOrUpdate")]
+ [Log(Title = "添加或修改商品", BusinessType = BusinessType.ADDORUPDATE)]
+ public async Task AddOrUpdateGoods([FromBody] GoodsDto parm)
+ {
+ if (parm == null) { throw new CustomException("请求参数错误"); }
+
+ var modal = new Goods();
+ if (parm.GoodsId != 0) modal = parm.Adapt().ToUpdate(HttpContext);
+ else modal = parm.Adapt().ToCreate(HttpContext);
+
+ var res = await _GoodsService.AddOrUpdateGoods(modal);
+ return SUCCESS(res);
+ }
+
+ ///
+ /// 删除商品
+ ///
+ ///
+ [HttpDelete("{ids}")]
+ [ActionPermissionFilter(Permission = "business:goods:delete")]
+ [Log(Title = "商品删除", BusinessType = BusinessType.DELETE)]
+ public IActionResult Delete(string ids)
+ {
+ long[] idsArr = Tools.SpitLongArrary(ids);
+ if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
+ var response = _GoodsService.Delete(idsArr);
+ return SUCCESS("删除成功!");
+ }
+
+ ///
+ /// 导入商品
+ ///
+ /// 使用IFromFile必须使用name属性否则获取不到文件
+ /// 是否需要更新
+ ///
+ [HttpPost("importData")]
+ [Log(Title = "商品导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = false)]
+ [ActionPermissionFilter(Permission = "business:goods:import")]
+ public async Task ImportExcel([FromForm(Name = "file")] IFormFile formFile, bool updateSupport)
+ {
+ var isUpdateSupport = updateSupport;
+ IEnumerable parm = ExcelHelper.ImportData(formFile.OpenReadStream());
+
+ var i = 0;
+ var msgList = new List();
+ foreach (GoodsVo item in parm)
+ {
+ i++;
+ var Goods = await _GoodsService.HandleImportData(item);
+ var modal = Goods.Adapt().ToCreate(HttpContext);
+ var user = JwtUtil.GetLoginUser(App.HttpContext).UserName;
+ var msg = await _GoodsService.ImportExcel(modal, i, isUpdateSupport, user);
+ msgList.Add(msg);
+ }
+
+ return SUCCESS(msgList.ToArray());
+ }
+
+
+ ///
+ /// 商品导入模板下载
+ ///
+ ///
+ [HttpGet("importTemplate")]
+ [Log(Title = "商品模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = false, IsSaveResponseData = false)]
+ [AllowAnonymous]
+ public IActionResult ImportTemplateExcel()
+ {
+ List Goods = new List();
+ MemoryStream stream = new MemoryStream();
+
+ // 示例数据
+ var values = new List() { "111", "222", "333" };
+ string sFileName = DownloadImportTemplate(Goods, stream, "商品导入模板", values);
+
+ return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"{sFileName}");
+ }
+
+ ///
+ /// 导出商品
+ ///
+ ///
+ [Log(Title = "商品导出", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
+ [HttpGet("exportGoods")]
+ [ActionPermissionFilter(Permission = "business:goods:export")]
+ public async Task ExportExcel([FromQuery] GoodsQueryDto parm)
+ {
+ parm.PageSize = 10000;
+ var list = await _GoodsService.GetGoodsList(parm);
+ var data = list.Result;
+
+ // 选中数据
+ if (!string.IsNullOrEmpty(parm.ids))
+ {
+ int[] idsArr = Tools.SpitIntArrary(parm.ids);
+ var selectDataList = new List();
+ foreach (var item in idsArr)
+ {
+ var select_data = data.Where(s => s.GoodsId == item).First();
+ selectDataList.Add(select_data);
+ }
+ data = selectDataList;
+ }
+
+
+
+ // 导出数据处理
+ var handleData = await _GoodsService.HandleExportData(data);
+
+ string sFileName = ExportExcel(handleData, "Goods", "商品列表");
+ return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
+ }
+
+
+
+
+ }
+}
diff --git a/ARW.WebApi/Controllers/CommonController.cs b/ARW.WebApi/Controllers/CommonController.cs
index 925dbef..0fd8dfc 100644
--- a/ARW.WebApi/Controllers/CommonController.cs
+++ b/ARW.WebApi/Controllers/CommonController.cs
@@ -104,7 +104,7 @@ namespace ARW.Admin.WebApi.Controllers
//fileName = Path.GetFileNameWithoutExtension(formFile.FileName);
double fileSize = Math.Round(formFile.Length / 1024.0, 2);//文件大小KB
string[] NotAllowedFileExtensions = new string[] { ".bat", ".exe", ".jar", ".js" };
- int MaxContentLength = 15;
+ int MaxContentLength = 100;
if (NotAllowedFileExtensions.Contains(fileExt))
{
return ToResponse(ResultCode.CUSTOM_ERROR, "上传失败,未经允许上传类型");