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.LogisticsManage.DeliveryRules; using ARW.Service.Business.IBusinessService.LogisticsManage.DeliveryRules; using ARW.Model.Dto.Business.LogisticsManage.DeliveryRules; using ARW.Model.Models.Business.LogisticsManage.DeliveryRules; using ARW.Model.Vo.Business.LogisticsManage.DeliveryRules; namespace ARW.Service.Business.BusinessService.LogisticsManage.DeliveryRules { /// /// 配送模板区域及运费接口实现类 /// /// @author 黎文豪 /// @date 2023-06-16 /// [AppService(ServiceType = typeof(IDeliveryRuleService), ServiceLifetime = LifeTime.Transient)] public class DeliveryRuleServiceImpl : BaseService, IDeliveryRuleService { private readonly DeliveryRuleRepository _DeliveryRuleRepository; public DeliveryRuleServiceImpl(DeliveryRuleRepository DeliveryRuleRepository) { this._DeliveryRuleRepository = DeliveryRuleRepository; } #region 业务逻辑代码 /// /// 查询配送模板区域及运费分页列表 /// public async Task> GetDeliveryRuleList(DeliveryRuleQueryDto parm) { //开始拼装查询条件d var predicate = Expressionable.Create(); predicate = predicate.AndIF(parm.DeliveryGuid != null, s => s.DeliveryGuid == parm.DeliveryGuid); var query = _DeliveryRuleRepository .Queryable() .Where(predicate.ToExpression()) .OrderBy(s => s.Create_time, OrderByType.Desc) .Select(s => new DeliveryRuleVo { DeliveryRuleId = s.DeliveryRuleId, DeliveryRuleGuid = s.DeliveryRuleGuid, DeliveryGuid = s.DeliveryGuid, DeliveryRuleRegion = s.DeliveryRuleRegion, DeliveryRuleRegionText = s.DeliveryRuleRegionText, DeliveryRuleFirst = s.DeliveryRuleFirst, DeliveryRuleFirstFee = s.DeliveryRuleFirstFee, DeliveryRuleAdditional = s.DeliveryRuleAdditional, DeliveryRuleAdditionalFee = s.DeliveryRuleAdditionalFee, }); return await query.ToPageAsync(parm); } /// /// 添加或修改配送模板区域及运费 /// public async Task AddOrUpdateDeliveryRule(DeliveryRule model) { if (model.DeliveryRuleId != 0) { var response = await _DeliveryRuleRepository.UpdateAsync(model); return "修改成功!"; } else { var response = await _DeliveryRuleRepository.InsertReturnSnowflakeIdAsync(model); return "添加成功!"; } } #region Excel处理 #endregion #endregion } }