diff --git a/Myshipping.Application/Service/Fee/Dto/FeeCurrencyDto.cs b/Myshipping.Application/Service/Fee/Dto/FeeCurrencyDto.cs new file mode 100644 index 00000000..16495aab --- /dev/null +++ b/Myshipping.Application/Service/Fee/Dto/FeeCurrencyDto.cs @@ -0,0 +1,86 @@ +using Myshipping.Core; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application.Service.Fee.Dto +{ + public class FeeCurrencyDto + { + /// + /// ID + /// + public long Id { get; set; } + + /// + /// 币别代码 + /// + [Description("币别代码")] + public string CodeName { get; set; } + + /// + /// 币别名称 + /// + [Description("币别名称")] + public string Name { get; set; } + + /// + /// 描述 + /// + [Description("描述")] + public string Description { get; set; } + + /// + /// 默认对人民币汇率;录入费用时如果汇率设置里没有设置汇率,提此处汇率 + /// + [Description("默认对人民币汇率;录入费用时如果汇率设置里没有设置汇率,提此处汇率")] + public decimal DefaultRate { get; set; } + + /// + /// 财务软件对应代码 + /// + [Description("财务软件对应代码")] + public string FinanceSoftCode { get; set; } + + } + + /// + /// 查询 + /// + public class FeeCurrencyPageInput: PageInputBase + { + + /// + /// 币别代码 + /// + [Description("币别代码")] + public string CodeName { get; set; } + + /// + /// 币别名称 + /// + [Description("币别名称")] + public string Name { get; set; } + + } + + /// + /// 台账列表 + /// + public class FeeCurrencyPageOutput: FeeCurrencyDto + { + + } + + /// + /// 保存 + /// + public class FeeCurrencySaveDto: FeeCurrencyDto + { + + } +} diff --git a/Myshipping.Application/Service/Fee/Dto/FeeCurrencyExchangeDto.cs b/Myshipping.Application/Service/Fee/Dto/FeeCurrencyExchangeDto.cs new file mode 100644 index 00000000..bd025970 --- /dev/null +++ b/Myshipping.Application/Service/Fee/Dto/FeeCurrencyExchangeDto.cs @@ -0,0 +1,115 @@ +using Myshipping.Core; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Myshipping.Application.Service.Fee.Dto +{ + public class FeeCurrencyExchangeDto + { + /// + /// ID + /// + public long Id { get; set; } + + /// + /// 币别代码 + /// + [Description("币别代码")] + public string Currency { get; set; } + + /// + /// 应收汇率 + /// + [Description("应收汇率")] + public decimal DrValue { get; set; } + + /// + /// 开始日期 + /// + [Description("开始日期")] + public DateTime StartTime { get; set; } + + /// + /// 结束日期 + /// + [Description("结束日期")] + public DateTime EndTime { get; set; } + + /// + /// 应付汇率 + /// + [Description("应付汇率")] + public decimal CrValue { get; set; } + + /// + /// 本位币 + /// + [Description("本位币")] + public string LocalCurr { get; set; } + + /// + /// 备注 + /// + [Description("备注")] + public string Remark { get; set; } + + } + + /// + /// 查询 + /// + public class FeeCurrencyExchangePageInput: PageInputBase + { + /// + /// 币别代码 + /// + [Description("币别代码")] + public string Currency { get; set; } + + + /// + /// 开始日期起始 + /// + [Description("开始日期")] + public DateTime? StartTimeBegin { get; set; } + + /// + /// 开始日期截止 + /// + [Description("开始日期")] + public DateTime? StartTimeEnd { get; set; } + + /// + /// 结束日期起始 + /// + [Description("结束日期")] + public DateTime? EndTimeBegin { get; set; } + + /// + /// 结束日期截止 + /// + [Description("结束日期")] + public DateTime? EndTimeEnd { get; set; } + } + + /// + /// 台账列表 + /// + public class FeeCurrencyExchangePageOutput: FeeCurrencyExchangeDto + { + + } + + /// + /// 保存 + /// + public class FeeCurrencyExchangeSaveDto: FeeCurrencyExchangeDto + { + + } +} diff --git a/Myshipping.Application/Service/Fee/FeeCurrencyExchangeService.cs b/Myshipping.Application/Service/Fee/FeeCurrencyExchangeService.cs new file mode 100644 index 00000000..4f3f494b --- /dev/null +++ b/Myshipping.Application/Service/Fee/FeeCurrencyExchangeService.cs @@ -0,0 +1,164 @@ +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 +{ + /// + /// 汇率 + /// + [ApiDescriptionSettings("Application", Name = "FeeCurrencyExchange", Order = 1)] + public class FeeCurrencyExchangeService : IDynamicApiController, ITransient + { + private readonly SqlSugarRepository _repCode; + + private readonly ILogger _logger; + private readonly ISysCacheService _cache; + + private readonly IEventPublisher _publisher; + + public FeeCurrencyExchangeService(SqlSugarRepository repCode, + ILogger logger, + ISysCacheService cache, + IEventPublisher publisher) + { + _repCode = repCode; + + _logger = logger; + _cache = cache; + + _publisher = publisher; + } + + /// + /// 费用代码查询 + /// + /// + /// + [HttpPost("/FeeCurrencyExchange/Page")] + public async Task Page(FeeCurrencyExchangePageInput input) + { + var entities = await _repCode.AsQueryable() + .WhereIF(!string.IsNullOrEmpty(input.Currency), u => u.Currency.Contains(input.Currency)) + .WhereIF(input.StartTimeBegin.HasValue, u => u.StartTime > input.StartTimeBegin.Value) + .WhereIF(input.StartTimeEnd.HasValue, u => u.StartTime < input.StartTimeEnd.Value.AddDays(1)) + .WhereIF(input.EndTimeBegin.HasValue, u => u.EndTime > input.EndTimeBegin.Value) + .WhereIF(input.EndTimeEnd.HasValue, u => u.EndTime < input.EndTimeEnd.Value.AddDays(1)) + .ToPagedListAsync(input.PageNo, input.PageSize); + + var result = entities.Adapt>(); + + return result.XnPagedResult(); + } + + /// + /// 保存 + /// + /// + /// + [HttpPost("/FeeCurrencyExchange/Save")] + public async Task Save(FeeCurrencyExchangeSaveDto input) + { + if (input == null) + { + throw Oops.Bah("请传入正常数据!"); + } + + var minDate = DateTime.Today.AddYears(-1); + if (input.StartTime < minDate || input.EndTime < minDate) + { + throw Oops.Bah("开始日期或结束日期有误!"); + } + + FeeCurrencyExchange entity = null; + if (input.Id == 0) + { + //判断时间范围重复 + var cc = await _repCode.AsQueryable().Where(x => (input.StartTime >= x.StartTime && input.StartTime <= x.EndTime) + || (input.EndTime >= x.StartTime && input.EndTime <= x.EndTime)) + .CountAsync(); + if (cc > 0) + { + throw Oops.Bah("日期范围存在交叉的数据!"); + } + + entity = input.Adapt(); + entity.Id = YitIdHelper.NextId(); + await _repCode.InsertAsync(entity); + + } + else + { + //判断时间范围重复 + var cc = await _repCode.AsQueryable().Where(x => x.Id != input.Id && + ( + (input.StartTime >= x.StartTime && input.StartTime <= x.EndTime) + || (input.EndTime >= x.StartTime && input.EndTime <= x.EndTime) + )) + .CountAsync(); + if (cc > 0) + { + throw Oops.Bah("日期范围存在交叉的数据!"); + } + + entity = await _repCode.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == input.Id); + entity = input.Adapt(entity); + await _repCode.UpdateAsync(entity); + } + + return entity.Adapt(); + } + + /// + /// 获取详情 + /// + /// + /// + [HttpGet("/FeeCurrencyExchange/Detail")] + public async Task Detail(long id) + { + var entity = await _repCode.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == id); + + return entity.Adapt(); + } + + + /// + /// 删除 + /// + /// + /// + [HttpPost("/FeeCurrencyExchange/Delete")] + public async Task Delete(List ids) + { + var list = await _repCode.AsQueryable().Filter(null, true).Where(x => ids.Contains(x.Id)).ToListAsync(); + list.ForEach(x => x.IsDeleted = true); + await _repCode.AsUpdateable(list).ExecuteCommandAsync(); + } + } +} diff --git a/Myshipping.Application/Service/Fee/FeeCurrencyService.cs b/Myshipping.Application/Service/Fee/FeeCurrencyService.cs new file mode 100644 index 00000000..9b136407 --- /dev/null +++ b/Myshipping.Application/Service/Fee/FeeCurrencyService.cs @@ -0,0 +1,134 @@ +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 +{ + /// + /// 费用币别 + /// + [ApiDescriptionSettings("Application", Name = "FeeCurrency", Order = 1)] + public class FeeCurrencyService : IDynamicApiController, ITransient + { + private readonly SqlSugarRepository _repCode; + + private readonly ILogger _logger; + private readonly ISysCacheService _cache; + + private readonly IEventPublisher _publisher; + + public FeeCurrencyService(SqlSugarRepository repCode, + ILogger logger, + ISysCacheService cache, + IEventPublisher publisher) + { + _repCode = repCode; + + _logger = logger; + _cache = cache; + + _publisher = publisher; + } + + /// + /// 费用代码查询 + /// + /// + /// + [HttpPost("/FeeCurrency/Page")] + public async Task Page(FeeCurrencyPageInput input) + { + var entities = await _repCode.AsQueryable() + .WhereIF(!string.IsNullOrEmpty(input.CodeName), u => u.CodeName.Contains(input.CodeName)) + .WhereIF(!string.IsNullOrEmpty(input.Name), u => u.Name.Contains(input.Name)) + .ToPagedListAsync(input.PageNo, input.PageSize); + + var result = entities.Adapt>(); + + return result.XnPagedResult(); + } + + /// + /// 保存 + /// + /// + /// + [HttpPost("/FeeCurrency/Save")] + public async Task Save(FeeCurrencySaveDto input) + { + if (input == null) + { + throw Oops.Bah("请传入正常数据!"); + } + + FeeCurrency entity = null; + if (input.Id == 0) + { + entity = input.Adapt(); + entity.Id = YitIdHelper.NextId(); + await _repCode.InsertAsync(entity); + + } + else + { + entity = await _repCode.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == input.Id); + entity = input.Adapt(entity); + await _repCode.UpdateAsync(entity); + } + + return entity.Adapt(); + } + + /// + /// 获取详情 + /// + /// + /// + [HttpGet("/FeeCurrency/Detail")] + public async Task Detail(long id) + { + var entity = await _repCode.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == id); + + return entity.Adapt(); + } + + + /// + /// 删除 + /// + /// + /// + [HttpPost("/FeeCurrency/Delete")] + public async Task Delete(List ids) + { + var list = await _repCode.AsQueryable().Filter(null, true).Where(x => ids.Contains(x.Id)).ToListAsync(); + list.ForEach(x => x.IsDeleted = true); + await _repCode.AsUpdateable(list).ExecuteCommandAsync(); + } + } +}