|
|
|
@ -0,0 +1,154 @@
|
|
|
|
|
using Furion;
|
|
|
|
|
using Furion.DependencyInjection;
|
|
|
|
|
using Furion.DynamicApiController;
|
|
|
|
|
using Furion.EventBus;
|
|
|
|
|
using Furion.FriendlyException;
|
|
|
|
|
using Furion.LinqBuilder;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Myshipping.Application.ConfigOption;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Myshipping.Application.Event;
|
|
|
|
|
using Myshipping.Application.Service.BookingOrder.Dto;
|
|
|
|
|
using Myshipping.Application.Service.BookingSlot.Dto;
|
|
|
|
|
using Myshipping.Application.Service.Fee.Dto;
|
|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using Myshipping.Core.Service;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Yitter.IdGenerator;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 费用模板
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ApiDescriptionSettings("Application", Name = "FeeTemplate", Order = 1)]
|
|
|
|
|
public class FeeTemplateService : IDynamicApiController, ITransient
|
|
|
|
|
{
|
|
|
|
|
private readonly SqlSugarRepository<FeeTemplate> _repTemplate;
|
|
|
|
|
private readonly SqlSugarRepository<FeeTemplateDetail> _repTemplateDetail;
|
|
|
|
|
|
|
|
|
|
private readonly ILogger<FeeTemplateService> _logger;
|
|
|
|
|
private readonly ISysCacheService _cache;
|
|
|
|
|
|
|
|
|
|
private readonly IEventPublisher _publisher;
|
|
|
|
|
|
|
|
|
|
public FeeTemplateService(SqlSugarRepository<FeeTemplate> repTemplate,
|
|
|
|
|
SqlSugarRepository<FeeTemplateDetail> repTemplateDetail,
|
|
|
|
|
ILogger<FeeTemplateService> logger,
|
|
|
|
|
ISysCacheService cache,
|
|
|
|
|
IEventPublisher publisher)
|
|
|
|
|
{
|
|
|
|
|
_repTemplate = repTemplate;
|
|
|
|
|
_repTemplateDetail = repTemplateDetail;
|
|
|
|
|
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_cache = cache;
|
|
|
|
|
|
|
|
|
|
_publisher = publisher;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 费用模板查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/FeeTemplate/Page")]
|
|
|
|
|
public async Task<dynamic> Page(FeeTemplatePageInput input)
|
|
|
|
|
{
|
|
|
|
|
var entities = await _repTemplate.AsQueryable()
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.OpType), u => u.OpType == input.OpType)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.FeeType), u => u.OpType == input.FeeType)
|
|
|
|
|
.WhereIF(!string.IsNullOrEmpty(input.Name), u => u.Name.Contains(input.Name))
|
|
|
|
|
.ToPagedListAsync(input.PageNo, input.PageSize);
|
|
|
|
|
|
|
|
|
|
var result = entities.Adapt<SqlSugarPagedList<FeeTemplatePageOutput>>();
|
|
|
|
|
|
|
|
|
|
return result.XnPagedResult();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/FeeTemplate/Save")]
|
|
|
|
|
public async Task<FeeTemplateSaveDto> Save(FeeTemplateSaveDto input)
|
|
|
|
|
{
|
|
|
|
|
if (input == null)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Bah("请传入正常数据!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FeeTemplate entity = null;
|
|
|
|
|
if (input.Id == 0)
|
|
|
|
|
{
|
|
|
|
|
entity = input.Adapt<FeeTemplate>();
|
|
|
|
|
entity.Id = YitIdHelper.NextId();
|
|
|
|
|
await _repTemplate.InsertAsync(entity);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
entity = await _repTemplate.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == input.Id);
|
|
|
|
|
entity = input.Adapt(entity);
|
|
|
|
|
await _repTemplate.UpdateAsync(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _repTemplateDetail.DeleteAsync(x => x.TemplateID == entity.Id);
|
|
|
|
|
foreach (var det in input.Detail)
|
|
|
|
|
{
|
|
|
|
|
var detail = det.Adapt<FeeTemplateDetail>();
|
|
|
|
|
detail.Id = YitIdHelper.NextId();
|
|
|
|
|
detail.TemplateID = entity.Id;
|
|
|
|
|
await _repTemplateDetail.InsertAsync(detail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var rtn = entity.Adapt<FeeTemplateSaveDto>();
|
|
|
|
|
rtn.Detail = input.Detail;
|
|
|
|
|
|
|
|
|
|
return rtn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet("/FeeTemplate/Detail")]
|
|
|
|
|
public async Task<FeeTemplateSaveDto> Detail(long id)
|
|
|
|
|
{
|
|
|
|
|
var entity = await _repTemplate.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == id);
|
|
|
|
|
var detailList = await _repTemplateDetail.AsQueryable().Where(x => x.TemplateID == id).ToListAsync();
|
|
|
|
|
var rtn = entity.Adapt<FeeTemplateSaveDto>();
|
|
|
|
|
rtn.Detail = detailList.Adapt<List<FeeTemplateDetailDto>>();
|
|
|
|
|
return rtn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ids"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost("/FeeTemplate/Delete")]
|
|
|
|
|
public async Task Delete(List<long> ids)
|
|
|
|
|
{
|
|
|
|
|
var list = await _repTemplate.AsQueryable().Filter(null, true).Where(x => ids.Contains(x.Id)).ToListAsync();
|
|
|
|
|
list.ForEach(x => x.IsDeleted = true);
|
|
|
|
|
await _repTemplate.AsUpdateable(list).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|