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.GoodsSpecs.GoodsSkus; using ARW.Service.Business.IBusinessService.GoodsManager.GoodsSpecs.GoodsSkus; using ARW.Model.Dto.Business.GoodsManager.GoodsSpecs.GoodsSkus; using ARW.Model.Models.Business.GoodsManager.GoodsSpecs.GoodsSkus; using ARW.Model.Vo.Business.GoodsManager.GoodsSpecs.GoodsSkus; namespace ARW.Service.Business.BusinessService.GoodsManager.GoodsSpecs.GoodsSkus { /// /// 商品规格接口实现类 /// /// @author 黎文豪 /// @date 2023-06-19 /// [AppService(ServiceType = typeof(IGoodsSkuService), ServiceLifetime = LifeTime.Transient)] public class GoodsSkuServiceImpl : BaseService, IGoodsSkuService { private readonly GoodsSkuRepository _GoodsSkuRepository; public GoodsSkuServiceImpl(GoodsSkuRepository GoodsSkuRepository) { this._GoodsSkuRepository = GoodsSkuRepository; } #region 业务逻辑代码 /// /// 查询商品规格分页列表 /// public async Task> GetGoodsSkuList(GoodsSkuQueryDto parm) { //开始拼装查询条件d var predicate = Expressionable.Create(); var query = _GoodsSkuRepository .Queryable() .Where(predicate.ToExpression()) .OrderBy(s => s.Create_time,OrderByType.Asc) .Select(s => new GoodsSkuVo { GoodsSkuId = s.GoodsSkuId, GoodsGuid = s.GoodsGuid, SpecValueId = s.SpecValueId, GoodsSkuImg = s.GoodsSkuImg, GoodsSkuSkuCode = s.GoodsSkuSkuCode, GoodsSkuPrice = s.GoodsSkuPrice, GoodsSkuLinePrice = s.GoodsSkuLinePrice, GoodsSkuStockNum = s.GoodsSkuStockNum, GoodsSkuWeight = s.GoodsSkuWeight, GoodsSkuProps = s.GoodsSkuProps, }); return await query.ToPageAsync(parm); } /// /// 添加或修改商品规格 /// public async Task AddOrUpdateGoodsSku(GoodsSku model) { if (model.GoodsSkuId != 0) { var response = await _GoodsSkuRepository.UpdateAsync(model); return "修改成功!"; } else { var response = await _GoodsSkuRepository.InsertReturnSnowflakeIdAsync(model); return "添加成功!"; } } #region Excel处理 #endregion #endregion } }