|
|
|
@ -38,50 +38,25 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task GenerateFeesAsync(long bsId, BusinessType businessType = BusinessType.OceanShippingExport)
|
|
|
|
|
{
|
|
|
|
|
//switch (businessType)
|
|
|
|
|
//{
|
|
|
|
|
// case BusinessType.OceanShippingExport:
|
|
|
|
|
// break;
|
|
|
|
|
// case BusinessType.OceanShippingImport:
|
|
|
|
|
// break;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
var order = await TenantDb.Queryable<SeaExport>().Where(x => x.Id == bsId).Select(
|
|
|
|
|
x => new { x.CustomerId }).FirstAsync();
|
|
|
|
|
x => new { x.CustomerId, x.CustomerName }).FirstAsync();
|
|
|
|
|
if (order == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
DateTime dt = DateTime.Now;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var list = await TenantDb.Queryable<FeeCustTemplate>()
|
|
|
|
|
.Where(x => x.BusinessType == businessType && !SqlFunc.IsNullOrEmpty(x.Condition) &&
|
|
|
|
|
(x.IsShared || x.CustomerId == order.CustomerId))
|
|
|
|
|
.Where(x => !x.IsDisabled && x.BusinessType == businessType && SqlFunc.Between(dt, x.StartTime, x.EndTime) &&
|
|
|
|
|
!SqlFunc.IsNullOrEmpty(x.Condition) && (x.IsShared || x.CustomerId == order.CustomerId))
|
|
|
|
|
.Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.Id,
|
|
|
|
|
x.Condition,
|
|
|
|
|
Details = SqlFunc.Subqueryable<FeeCustTemplateDetail>().Where(y =>
|
|
|
|
|
y.TemplateId == x.Id && y.CustomerId == order.CustomerId).ToList(y => new
|
|
|
|
|
{
|
|
|
|
|
y.CustomerId,
|
|
|
|
|
y.CustomerName,
|
|
|
|
|
y.CustomerType,
|
|
|
|
|
y.FeeId,
|
|
|
|
|
y.FeeCode,
|
|
|
|
|
y.FeeName,
|
|
|
|
|
y.FeeType,
|
|
|
|
|
y.Unit,
|
|
|
|
|
y.IsCtn,
|
|
|
|
|
y.Currency,
|
|
|
|
|
y.UnitPrice,
|
|
|
|
|
y.ExchangeRate,
|
|
|
|
|
y.TaxRate,
|
|
|
|
|
y.AccTaxRate,
|
|
|
|
|
y.Tax,
|
|
|
|
|
y.TaxUnitPrice,
|
|
|
|
|
y.IsInvoice,
|
|
|
|
|
y.IsAdvancedPay
|
|
|
|
|
})
|
|
|
|
|
x.CustomerId,
|
|
|
|
|
x.FeeType,
|
|
|
|
|
x.Priority,
|
|
|
|
|
x.IsShared,
|
|
|
|
|
x.Condition
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
if (list.Count == 0)
|
|
|
|
@ -97,16 +72,38 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
List<FeeRecord> feeList = [];
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
var custList = list.Where(x => x.CustomerId == order.CustomerId).OrderBy(x => x.Priority).ToList();
|
|
|
|
|
foreach (var item in custList) //遍历客户费用模板,查找匹配项
|
|
|
|
|
{
|
|
|
|
|
var conditionModel = conditionModels.Find(x => x.Id == item.Id)?.ConditionModel;
|
|
|
|
|
if (actionService.Value.IsMatch(data, conditionModel))
|
|
|
|
|
{
|
|
|
|
|
var fees = item.Details.Select(x => new FeeRecord
|
|
|
|
|
var details = await TenantDb.Queryable<FeeCustTemplateDetail>().Where(y => y.TemplateId == item.Id)
|
|
|
|
|
.Select(y => new
|
|
|
|
|
{
|
|
|
|
|
y.CustomerId,
|
|
|
|
|
y.CustomerName,
|
|
|
|
|
y.CustomerType,
|
|
|
|
|
y.FeeId,
|
|
|
|
|
y.FeeCode,
|
|
|
|
|
y.FeeName,
|
|
|
|
|
y.Unit,
|
|
|
|
|
y.IsCtn,
|
|
|
|
|
y.Currency,
|
|
|
|
|
y.UnitPrice,
|
|
|
|
|
y.ExchangeRate,
|
|
|
|
|
y.TaxRate,
|
|
|
|
|
y.AccTaxRate,
|
|
|
|
|
y.Tax,
|
|
|
|
|
y.TaxUnitPrice,
|
|
|
|
|
y.IsInvoice,
|
|
|
|
|
y.IsAdvancedPay
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
var fees = details.Select(x => new FeeRecord
|
|
|
|
|
{
|
|
|
|
|
BusinessId = bsId,
|
|
|
|
|
BusinessType = businessType,
|
|
|
|
|
FeeType = x.FeeType,
|
|
|
|
|
FeeType = item.FeeType,
|
|
|
|
|
FeeId = x.FeeId,
|
|
|
|
|
FeeCode = x.FeeCode,
|
|
|
|
|
FeeName = x.FeeName,
|
|
|
|
@ -126,8 +123,67 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
IsInvoice = x.IsInvoice,
|
|
|
|
|
IsAdvancedPay = x.IsAdvancedPay,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
feeList.AddRange(fees);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (feeList.Count == 0) //未找到客户模板,开始匹配共享模板
|
|
|
|
|
{
|
|
|
|
|
var sharedList = list.Where(x => x.IsShared).OrderBy(x => x.Priority).ToList();
|
|
|
|
|
foreach (var item in sharedList)
|
|
|
|
|
{
|
|
|
|
|
var conditionModel = conditionModels.Find(x => x.Id == item.Id)?.ConditionModel;
|
|
|
|
|
if (actionService.Value.IsMatch(data, conditionModel))
|
|
|
|
|
{
|
|
|
|
|
var details = await TenantDb.Queryable<FeeCustTemplateDetail>().Where(y => y.TemplateId == item.Id)
|
|
|
|
|
.Select(y => new
|
|
|
|
|
{
|
|
|
|
|
y.CustomerId,
|
|
|
|
|
y.CustomerName,
|
|
|
|
|
y.CustomerType,
|
|
|
|
|
y.FeeId,
|
|
|
|
|
y.FeeCode,
|
|
|
|
|
y.FeeName,
|
|
|
|
|
y.Unit,
|
|
|
|
|
y.IsCtn,
|
|
|
|
|
y.Currency,
|
|
|
|
|
y.UnitPrice,
|
|
|
|
|
y.ExchangeRate,
|
|
|
|
|
y.TaxRate,
|
|
|
|
|
y.AccTaxRate,
|
|
|
|
|
y.Tax,
|
|
|
|
|
y.TaxUnitPrice,
|
|
|
|
|
y.IsInvoice,
|
|
|
|
|
y.IsAdvancedPay
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
var fees = details.Select(x => new FeeRecord
|
|
|
|
|
{
|
|
|
|
|
BusinessId = bsId,
|
|
|
|
|
BusinessType = businessType,
|
|
|
|
|
FeeType = item.FeeType,
|
|
|
|
|
FeeId = x.FeeId,
|
|
|
|
|
FeeCode = x.FeeCode,
|
|
|
|
|
FeeName = x.FeeName,
|
|
|
|
|
CustomerId = x.CustomerId,
|
|
|
|
|
CustomerName = x.CustomerName,
|
|
|
|
|
CustomerType = x.CustomerType?.ToString(),
|
|
|
|
|
Unit = x.Unit,
|
|
|
|
|
UnitPrice = x.UnitPrice.GetValueOrDefault(),
|
|
|
|
|
Quantity = x.IsCtn ? 1 : 0,
|
|
|
|
|
Note = x.IsCtn.ToString().ToLowerInvariant(), //临时存储
|
|
|
|
|
Currency = x.Currency,
|
|
|
|
|
ExchangeRate = x.ExchangeRate,
|
|
|
|
|
TaxRate = x.TaxRate.GetValueOrDefault(),
|
|
|
|
|
AccTaxRate = x.AccTaxRate.GetValueOrDefault(),
|
|
|
|
|
Tax = x.Tax.GetValueOrDefault(),
|
|
|
|
|
TaxUnitPrice = x.TaxUnitPrice.GetValueOrDefault(),
|
|
|
|
|
IsInvoice = x.IsInvoice,
|
|
|
|
|
IsAdvancedPay = x.IsAdvancedPay,
|
|
|
|
|
});
|
|
|
|
|
feeList.AddRange(fees);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -155,19 +211,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
public async Task<DataResult<List<FeeCustTemplate>>> GetListAsync(PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
var whereList = request.GetConditionalModels(Db);
|
|
|
|
|
return await TenantDb.Queryable<FeeCustTemplate>().Select(x => new FeeCustTemplate
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
BusinessType = x.BusinessType,
|
|
|
|
|
CustomerId = x.CustomerId,
|
|
|
|
|
CustomerName = x.CustomerName,
|
|
|
|
|
CustomerType = x.CustomerType,
|
|
|
|
|
Name = x.Name,
|
|
|
|
|
IsShared = x.IsShared,
|
|
|
|
|
Note = x.Note,
|
|
|
|
|
CreateBy = x.CreateBy,
|
|
|
|
|
CreateTime = x.CreateTime
|
|
|
|
|
}).Where(whereList).ToQueryPageAsync(request.PageCondition);
|
|
|
|
|
return await TenantDb.Queryable<FeeCustTemplate>().Where(whereList).ToQueryPageAsync(request.PageCondition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|