key1_beacon_api/ARW.Service/Business/BusinessService/LogisticsManage/DeliveryRules/DeliveryRuleService.cs

98 lines
3.2 KiB
C#

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
{
/// <summary>
/// 配送模板区域及运费接口实现类
///
/// @author 黎文豪
/// @date 2023-06-16
/// </summary>
[AppService(ServiceType = typeof(IDeliveryRuleService), ServiceLifetime = LifeTime.Transient)]
public class DeliveryRuleServiceImpl : BaseService<DeliveryRule>, IDeliveryRuleService
{
private readonly DeliveryRuleRepository _DeliveryRuleRepository;
public DeliveryRuleServiceImpl(DeliveryRuleRepository DeliveryRuleRepository)
{
this._DeliveryRuleRepository = DeliveryRuleRepository;
}
#region
/// <summary>
/// 查询配送模板区域及运费分页列表
/// </summary>
public async Task<PagedInfo<DeliveryRuleVo>> GetDeliveryRuleList(DeliveryRuleQueryDto parm)
{
//开始拼装查询条件d
var predicate = Expressionable.Create<DeliveryRule>();
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);
}
/// <summary>
/// 添加或修改配送模板区域及运费
/// </summary>
public async Task<string> 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
}
}