|
|
@ -6,6 +6,7 @@ using DS.Module.UserModule;
|
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
|
using DS.WMS.Core.Fee.Interface;
|
|
|
|
using DS.WMS.Core.Fee.Interface;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
using Mapster;
|
|
|
|
using Mapster;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using SqlSugar;
|
|
|
|
using SqlSugar;
|
|
|
@ -14,7 +15,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class FeeRecordService : IFeeRecordService
|
|
|
|
public class FeeRecordService : IFeeRecordService
|
|
|
|
{
|
|
|
|
{
|
|
|
|
readonly string DefaultCurrency = "RMB";
|
|
|
|
readonly string DefaultCurrency = "CNY";
|
|
|
|
|
|
|
|
|
|
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
|
private readonly ISqlSugarClient db;
|
|
|
|
private readonly ISqlSugarClient db;
|
|
|
@ -42,10 +43,43 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
var data = tenantDb.Queryable<FeeRecord>()
|
|
|
|
var data = tenantDb.Queryable<FeeRecord>()
|
|
|
|
.Where(whereList)
|
|
|
|
.Where(whereList)
|
|
|
|
.Select<FeeRecordRes>().ToQueryPage(request.PageCondition);
|
|
|
|
.Select<FeeRecordRes>()
|
|
|
|
|
|
|
|
.ToQueryPage(request.PageCondition);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//关联用户名称
|
|
|
|
|
|
|
|
var userIds = data.Data.Where(x => x.UpdateBy.HasValue).Select(x => x.UpdateBy.Value).Distinct().ToList();
|
|
|
|
|
|
|
|
var users = db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToList();
|
|
|
|
|
|
|
|
foreach (var item in data.Data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (item.UpdateBy.HasValue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
item.UpdateByName = users.Find(x => x.Id == item.UpdateBy.Value)?.UserName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 列表
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="query"></param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public DataResult<List<FeeRecord>> GetList(string query)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
var src = tenantDb.Queryable<FeeRecord>();
|
|
|
|
|
|
|
|
if (!query.IsNullOrEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//序列化查询条件
|
|
|
|
|
|
|
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(query);
|
|
|
|
|
|
|
|
src = src.Where(whereList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var data = src.ToList();
|
|
|
|
|
|
|
|
return new DataResult<List<FeeRecord>>(ResultCode.Success) { Data = data };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 提交
|
|
|
|
/// 提交
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -58,10 +92,12 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Ado.BeginTran();
|
|
|
|
tenantDb.Ado.BeginTran();
|
|
|
|
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
foreach (var item in items)
|
|
|
|
foreach (var item in items)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
item.BusinessId = bid;
|
|
|
|
item.BusinessId = bid;
|
|
|
|
item.FeeStatus = FeeStatusEnum.Entering;
|
|
|
|
item.FeeStatus = FeeStatusEnum.Entering;
|
|
|
|
|
|
|
|
item.SubmitDate = dtNow;
|
|
|
|
|
|
|
|
|
|
|
|
if (item.Id == 0)
|
|
|
|
if (item.Id == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -69,7 +105,16 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tenantDb.Updateable(item).ExecuteCommand();
|
|
|
|
tenantDb.Updateable(item).IgnoreColumns(x => new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
x.FeeStatus,
|
|
|
|
|
|
|
|
x.CreateBy,
|
|
|
|
|
|
|
|
x.CreateTime,
|
|
|
|
|
|
|
|
x.BusinessId,
|
|
|
|
|
|
|
|
x.DeleteBy,
|
|
|
|
|
|
|
|
x.Deleted,
|
|
|
|
|
|
|
|
x.DeleteTime
|
|
|
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tenantDb.Ado.CommitTran();
|
|
|
|
tenantDb.Ado.CommitTran();
|
|
|
@ -137,13 +182,13 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//若计价货币单位不等于默认货币则尝试获取最新汇率
|
|
|
|
//若计价货币单位不等于默认货币则尝试获取最新汇率
|
|
|
|
var exDetails = records.FindAll(x => !x.ExchangeRate.HasValue && x.Currency != DefaultCurrency);
|
|
|
|
var exRecords = records.FindAll(x => !x.ExchangeRate.HasValue && x.Currency != DefaultCurrency);
|
|
|
|
if (exDetails.Count > 0)
|
|
|
|
if (exRecords.Count > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var codes = exDetails.Select(x => x.Currency).Distinct().ToList();
|
|
|
|
var codes = exRecords.Select(x => x.Currency).Distinct().ToList();
|
|
|
|
var currencies = tenantDb.Queryable<FeeCurrency>().Where(x => codes.Contains(x.CodeName)).Includes(x => x.Exchanges).ToList();
|
|
|
|
var currencies = tenantDb.Queryable<FeeCurrency>().Where(x => codes.Contains(x.CodeName)).Includes(x => x.Exchanges).ToList();
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
foreach (var item in exDetails)
|
|
|
|
foreach (var item in exRecords)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var currency = currencies.Find(x => x.CodeName == item.Currency);
|
|
|
|
var currency = currencies.Find(x => x.CodeName == item.Currency);
|
|
|
|
if (currency != null)
|
|
|
|
if (currency != null)
|
|
|
@ -156,18 +201,28 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
x.StartDate >= dtNow && x.EndDate <= dtNow).OrderByDescending(x => x.UpdateTime).FirstOrDefault();
|
|
|
|
x.StartDate >= dtNow && x.EndDate <= dtNow).OrderByDescending(x => x.UpdateTime).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
if (exchange != null)
|
|
|
|
if (exchange != null)
|
|
|
|
{
|
|
|
|
|
|
|
|
item.ExchangeRate = item.FeeType == 1 ? exchange.DRValue : exchange.CRValue;
|
|
|
|
item.ExchangeRate = item.FeeType == 1 ? exchange.DRValue : exchange.CRValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int result = tenantDb.Insertable(records).ExecuteCommand();
|
|
|
|
int result = tenantDb.Insertable(records).ExecuteCommand();
|
|
|
|
return result > 0 ? DataResult.Successed("保存成功", records, MultiLanguageConst.DataCreateSuccess) : DataResult.Successed("操作失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
return result > 0 ? DataResult.Successed("保存成功", records, MultiLanguageConst.DataCreateSuccess) : DataResult.Successed("操作失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 根据费用明细转换为模板明细
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="idArray">费用明细ID</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public DataResult<List<FeeTemplateDetailRes>> ReadAsTemplate(params long[] idArray)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
var list = tenantDb.Queryable<FeeRecord>().Where(x => idArray.Contains(x.Id)).Select<FeeTemplateDetailRes>().ToList();
|
|
|
|
|
|
|
|
return new DataResult<List<FeeTemplateDetailRes>>(ResultCode.Success) { Data = list };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 删除(录入状态)
|
|
|
|
/// 删除(录入状态)
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|