optimize
jianghaiqing 10 months ago
parent 6a0ebced0f
commit aa6dedf079

@ -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
{
/// <summary>
/// ID
/// </summary>
public long Id { get; set; }
/// <summary>
/// 币别代码
/// </summary>
[Description("币别代码")]
public string CodeName { get; set; }
/// <summary>
/// 币别名称
/// </summary>
[Description("币别名称")]
public string Name { get; set; }
/// <summary>
/// 描述
/// </summary>
[Description("描述")]
public string Description { get; set; }
/// <summary>
/// 默认对人民币汇率;录入费用时如果汇率设置里没有设置汇率,提此处汇率
/// </summary>
[Description("默认对人民币汇率;录入费用时如果汇率设置里没有设置汇率,提此处汇率")]
public decimal DefaultRate { get; set; }
/// <summary>
/// 财务软件对应代码
/// </summary>
[Description("财务软件对应代码")]
public string FinanceSoftCode { get; set; }
}
/// <summary>
/// 查询
/// </summary>
public class FeeCurrencyPageInput: PageInputBase
{
/// <summary>
/// 币别代码
/// </summary>
[Description("币别代码")]
public string CodeName { get; set; }
/// <summary>
/// 币别名称
/// </summary>
[Description("币别名称")]
public string Name { get; set; }
}
/// <summary>
/// 台账列表
/// </summary>
public class FeeCurrencyPageOutput: FeeCurrencyDto
{
}
/// <summary>
/// 保存
/// </summary>
public class FeeCurrencySaveDto: FeeCurrencyDto
{
}
}

@ -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
{
/// <summary>
/// ID
/// </summary>
public long Id { get; set; }
/// <summary>
/// 币别代码
/// </summary>
[Description("币别代码")]
public string Currency { get; set; }
/// <summary>
/// 应收汇率
/// </summary>
[Description("应收汇率")]
public decimal DrValue { get; set; }
/// <summary>
/// 开始日期
/// </summary>
[Description("开始日期")]
public DateTime StartTime { get; set; }
/// <summary>
/// 结束日期
/// </summary>
[Description("结束日期")]
public DateTime EndTime { get; set; }
/// <summary>
/// 应付汇率
/// </summary>
[Description("应付汇率")]
public decimal CrValue { get; set; }
/// <summary>
/// 本位币
/// </summary>
[Description("本位币")]
public string LocalCurr { get; set; }
/// <summary>
/// 备注
/// </summary>
[Description("备注")]
public string Remark { get; set; }
}
/// <summary>
/// 查询
/// </summary>
public class FeeCurrencyExchangePageInput: PageInputBase
{
/// <summary>
/// 币别代码
/// </summary>
[Description("币别代码")]
public string Currency { get; set; }
/// <summary>
/// 开始日期起始
/// </summary>
[Description("开始日期")]
public DateTime? StartTimeBegin { get; set; }
/// <summary>
/// 开始日期截止
/// </summary>
[Description("开始日期")]
public DateTime? StartTimeEnd { get; set; }
/// <summary>
/// 结束日期起始
/// </summary>
[Description("结束日期")]
public DateTime? EndTimeBegin { get; set; }
/// <summary>
/// 结束日期截止
/// </summary>
[Description("结束日期")]
public DateTime? EndTimeEnd { get; set; }
}
/// <summary>
/// 台账列表
/// </summary>
public class FeeCurrencyExchangePageOutput: FeeCurrencyExchangeDto
{
}
/// <summary>
/// 保存
/// </summary>
public class FeeCurrencyExchangeSaveDto: FeeCurrencyExchangeDto
{
}
}

@ -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
{
/// <summary>
/// 汇率
/// </summary>
[ApiDescriptionSettings("Application", Name = "FeeCurrencyExchange", Order = 1)]
public class FeeCurrencyExchangeService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<FeeCurrencyExchange> _repCode;
private readonly ILogger<FeeCurrencyExchangeService> _logger;
private readonly ISysCacheService _cache;
private readonly IEventPublisher _publisher;
public FeeCurrencyExchangeService(SqlSugarRepository<FeeCurrencyExchange> repCode,
ILogger<FeeCurrencyExchangeService> logger,
ISysCacheService cache,
IEventPublisher publisher)
{
_repCode = repCode;
_logger = logger;
_cache = cache;
_publisher = publisher;
}
/// <summary>
/// 费用代码查询
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/FeeCurrencyExchange/Page")]
public async Task<dynamic> 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<SqlSugarPagedList<FeeCurrencyExchangePageOutput>>();
return result.XnPagedResult();
}
/// <summary>
/// 保存
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/FeeCurrencyExchange/Save")]
public async Task<FeeCurrencyExchangeSaveDto> 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<FeeCurrencyExchange>();
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<FeeCurrencyExchangeSaveDto>();
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("/FeeCurrencyExchange/Detail")]
public async Task<FeeCurrencyExchangeSaveDto> Detail(long id)
{
var entity = await _repCode.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == id);
return entity.Adapt<FeeCurrencyExchangeSaveDto>();
}
/// <summary>
/// 删除
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
[HttpPost("/FeeCurrencyExchange/Delete")]
public async Task Delete(List<long> 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();
}
}
}

@ -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
{
/// <summary>
/// 费用币别
/// </summary>
[ApiDescriptionSettings("Application", Name = "FeeCurrency", Order = 1)]
public class FeeCurrencyService : IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<FeeCurrency> _repCode;
private readonly ILogger<FeeCurrencyService> _logger;
private readonly ISysCacheService _cache;
private readonly IEventPublisher _publisher;
public FeeCurrencyService(SqlSugarRepository<FeeCurrency> repCode,
ILogger<FeeCurrencyService> logger,
ISysCacheService cache,
IEventPublisher publisher)
{
_repCode = repCode;
_logger = logger;
_cache = cache;
_publisher = publisher;
}
/// <summary>
/// 费用代码查询
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/FeeCurrency/Page")]
public async Task<dynamic> 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<SqlSugarPagedList<FeeCurrencyPageOutput>>();
return result.XnPagedResult();
}
/// <summary>
/// 保存
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/FeeCurrency/Save")]
public async Task<FeeCurrencySaveDto> Save(FeeCurrencySaveDto input)
{
if (input == null)
{
throw Oops.Bah("请传入正常数据!");
}
FeeCurrency entity = null;
if (input.Id == 0)
{
entity = input.Adapt<FeeCurrency>();
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<FeeCurrencySaveDto>();
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("/FeeCurrency/Detail")]
public async Task<FeeCurrencySaveDto> Detail(long id)
{
var entity = await _repCode.AsQueryable().Filter(null, true).FirstAsync(x => x.Id == id);
return entity.Adapt<FeeCurrencySaveDto>();
}
/// <summary>
/// 删除
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
[HttpPost("/FeeCurrency/Delete")]
public async Task Delete(List<long> 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();
}
}
}
Loading…
Cancel
Save