自动费用模板修改

dev
嵇文龙 2 months ago
parent 0a70ff0734
commit a88e6ecef5

@ -65,6 +65,7 @@ namespace DS.WMS.Core.Fee.Entity
/// </summary>
[SugarColumn(ColumnDescription = "费用类型", IsNullable = false)]
public FeeType FeeType { get; set; }
/// <summary>
/// 费用类型文本
/// </summary>
@ -90,10 +91,16 @@ namespace DS.WMS.Core.Fee.Entity
public bool IsDisabled { get; set; }
/// <summary>
/// 费用类别
/// 费用类别ID
/// </summary>
[SugarColumn(ColumnDescription = "费用类别ID", IsNullable = true)]
public long? FeeCategoryId { get; set; }
/// <summary>
/// 费用类别名称
/// </summary>
[SugarColumn(ColumnDescription = "费用类别", IsNullable = true)]
public long? FeeCategory { get; set; }
[SugarColumn(ColumnDescription = "费用类别名称", IsNullable = true)]
public string? FeeCategoryName { get; set; }
/// <summary>
/// 优先级
@ -101,6 +108,48 @@ namespace DS.WMS.Core.Fee.Entity
[SugarColumn(ColumnDescription = "优先级", IsNullable = false)]
public int Priority { get; set; }
/// <summary>
/// 起运港代码
/// </summary>
[SugarColumn(ColumnDescription = "起运港代码", Length = 5, IsNullable = true)]
public string? POLCode { get; set; }
/// <summary>
/// 卸货港代码
/// </summary>
[SugarColumn(ColumnDescription = "卸货港代码", Length = 5, IsNullable = true)]
public string? PODCode { get; set; }
/// <summary>
/// 航线代码
/// </summary>
[SugarColumn(ColumnDescription = "航线代码", Length = 50, IsNullable = true)]
public long? LaneId { get; set; }
/// <summary>
/// 承运商代码
/// </summary>
[SugarColumn(ColumnDescription = "承运商代码", Length = 50, IsNullable = true)]
public long? CarrierId { get; set; }
/// <summary>
/// 付费方式代码
/// </summary>
[SugarColumn(ColumnDescription = "付费方式代码", Length = 50, IsNullable = true)]
public string? MBLFrtCode { get; set; }
/// <summary>
/// 业务来源ID
/// </summary>
[SugarColumn(ColumnDescription = "业务来源ID", IsNullable = true)]
public long? SourceId { get; set; }
/// <summary>
/// 订舱口ID
/// </summary>
[SugarColumn(ColumnDescription = "订舱口ID", IsNullable = true)]
public long? ForwarderId { get; set; }
/// <summary>
/// 模板明细
/// </summary>

@ -1,6 +1,4 @@
using DS.Module.Core;
using Masuit.Tools.Systems;
using SqlSugar;
using SqlSugar;
namespace DS.WMS.Core.Fee.Entity
{

@ -0,0 +1,61 @@
using DS.Module.Core;
using DS.WMS.Core.Op.Entity;
using SqlSugar;
namespace DS.WMS.Core.Fee.Entity
{
/// <summary>
/// 往来单位费用模板记录
/// </summary>
[SugarTable("fee_cust_template_record", "往来单位费用模板记录")]
public class FeeCustTemplateRecord
{
/// <summary>
/// ID
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
/// <summary>
/// 业务ID
/// </summary>
[SugarColumn(ColumnDescription = "业务ID")]
public long BusinessId { get; set; }
/// <summary>
/// 业务类型
/// </summary>
[SugarColumn(ColumnDescription = "业务类型")]
public BusinessType BusinessType { get; set; }
/// <summary>
/// 费用模板Id
/// </summary>
[SugarColumn(ColumnDescription = "费用模板Id")]
public long TemplateId { get; set; }
/// <summary>
/// 收付类型
/// </summary>
[SugarColumn(ColumnDescription = "收付类型")]
public FeeType FeeType { get; set; }
/// <summary>
/// 费用类别ID
/// </summary>
[SugarColumn(ColumnDescription = "费用类别ID", IsNullable = true)]
public long? FeeCategoryId { get; set; }
/// <summary>
/// 创建人
/// </summary>
[SugarColumn(ColumnDescription = "创建人")]
public long CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnDescription = "创建时间")]
public DateTime CreateTime { get; set; }
}
}

@ -145,7 +145,7 @@ namespace DS.WMS.Core.Fee.Entity
/// 备注
/// </summary>
[SugarColumn(ColumnDescription = "备注", Length = 1000, IsNullable = true)]
public string Remark { get; set; }
public string? Remark { get; set; }
/// <summary>
/// Desc:佣金比率
/// </summary>
@ -369,7 +369,7 @@ namespace DS.WMS.Core.Fee.Entity
/// 发票自助连接
/// </summary>
[SugarColumn(ColumnDescription = "发票自助连接", IsNullable = true, Length = 50)]
public string InvLinkId { get; set; }
public string? InvLinkId { get; set; }
/// <summary>
/// 提交日期
@ -392,6 +392,18 @@ namespace DS.WMS.Core.Fee.Entity
[SugarColumn(ColumnDescription = "排序", IsNullable = true)]
public int? OrderNo { get; set; }
/// <summary>
/// 录入方式
/// </summary>
[SugarColumn(ColumnDescription = "录入方式", IsNullable = true)]
public InputMethod? InputMethod { get; set; }
/// <summary>
/// 费用模板Id
/// </summary>
[SugarColumn(ColumnDescription = "费用模板Id")]
public long? TemplateId { get; set; }
/// <summary>
/// 通过含税单价数量 和税率
/// 计算不含税单价 不含税金额
@ -440,4 +452,22 @@ namespace DS.WMS.Core.Fee.Entity
Amount = Math.Round(TaxUnitPrice * Quantity, 2, MidpointRounding.AwayFromZero);
}
}
/// <summary>
/// 费用录入方式
/// </summary>
public enum InputMethod
{
/// <summary>
/// 手工录入
/// </summary>
[Description("手工录入")]
Manual,
/// <summary>
/// 模板自动生成
/// </summary>
[Description("模板自动生成")]
Automatic
}
}

@ -1,7 +1,6 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Op.Entity;
namespace DS.WMS.Core.Fee.Interface
{
@ -13,10 +12,9 @@ namespace DS.WMS.Core.Fee.Interface
/// <summary>
/// 根据业务ID与类型生成费用
/// </summary>
/// <param name="bsId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="etd">开船日</param>
/// <returns></returns>
Task GenerateFeesAsync(long bsId, BusinessType businessType = BusinessType.OceanShippingExport);
Task GenerateFeesAsync(DateTime etd);
/// <summary>
/// 列表

@ -35,9 +35,10 @@ public interface IFeeRecordService
/// 提交
/// </summary>
/// <param name="items">要提交的费用记录</param>
/// <param name="excludeZeroFee">是否排除总价为零的费用</param>
/// <param name="excludeZeroFee">是否排除总价为零的费用默认为false</param>
/// <param name="useTransaction">是否使用事务默认为true</param>
/// <returns></returns>
Task<DataResult> SaveAsync(IEnumerable<FeeRecord> items, bool excludeZeroFee = false);
Task<DataResult> SaveAsync(IEnumerable<FeeRecord> items, bool excludeZeroFee = false, bool useTransaction = true);
/// <summary>
/// 根据费用模板引入

@ -4,6 +4,7 @@ using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Op.Dtos;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Interface.TaskInteraction;
using Microsoft.Extensions.DependencyInjection;
@ -31,178 +32,186 @@ namespace DS.WMS.Core.Fee.Method
}
/// <summary>
/// 根据业务ID与类型生成费用
/// 根据开船日生成费用
/// </summary>
/// <param name="bsId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="etd">开船日</param>
/// <returns></returns>
public async Task GenerateFeesAsync(long bsId, BusinessType businessType = BusinessType.OceanShippingExport)
public async Task GenerateFeesAsync(DateTime etd)
{
var order = await TenantDb.Queryable<SeaExport>().Where(x => x.Id == bsId).Select(
x => new { x.CustomerId, x.CustomerName }).FirstAsync();
if (order == null)
DateTime dt = DateTime.Now;
var list = await TenantDb.Queryable<FeeCustTemplate>()
.Where(x => !x.IsDisabled && SqlFunc.Between(dt, x.StartTime, x.EndTime) && (x.IsShared || x.CustomerId != null))
.Select(x => new FeeCustTemplate
{
Id = x.Id,
CustomerId = x.CustomerId,
FeeType = x.FeeType,
FeeCategoryId = x.FeeCategoryId,
FeeCategoryName = x.FeeCategoryName,
Priority = x.Priority,
IsShared = x.IsShared,
POLCode = x.POLCode,
PODCode = x.PODCode,
LaneId = x.LaneId,
SourceId = x.SourceId,
CarrierId = x.CarrierId,
ForwarderId = x.ForwarderId,
MBLFrtCode = x.MBLFrtCode,
Condition = x.Condition
}).ToListAsync();
if (list.Count == 0)
return;
DateTime dt = DateTime.Now;
if (etd == default)
etd = DateTime.Now.Date;
var tids = list.Select(x => x.Id);
var orders = await TenantDb.Queryable<SeaExport>().Where(x => SqlFunc.DateIsSame(x.ETD, etd) &&
SqlFunc.Subqueryable<FeeCustTemplateRecord>().Where(y => y.BusinessId == x.Id && y.BusinessType == BusinessType.OceanShippingExport && tids.Contains(y.TemplateId)).NotAny())
.Select<SeaExportRes>().ToListAsync();
if (orders.Count == 0)
return;
List<FeeRecord> feeList = [];
await TenantDb.Ado.BeginTranAsync();
try
{
var list = await TenantDb.Queryable<FeeCustTemplate>()
.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.CustomerId,
x.FeeType,
x.Priority,
x.IsShared,
x.Condition
}).ToListAsync();
if (list.Count == 0)
return;
var conditionModels = list.Select(x => new
{
x.Id,
ConditionModel = JsonConvert.DeserializeObject<ConditionContent>(x.Condition)
}).ToList();
var data = await actionService.Value.GetBusinessDataAsync(bsId, businessType, conditionModels.Select(x => x.ConditionModel));
if (data == null)
return;
List<FeeRecord> feeList = [];
var custList = list.Where(x => x.CustomerId == order.CustomerId).OrderBy(x => x.Priority).ToList();
foreach (var item in custList) //遍历客户费用模板,查找匹配项
foreach (var order in orders)
{
var conditionModel = conditionModels.Find(x => x.Id == item.Id)?.ConditionModel;
if (actionService.Value.IsMatch(data, conditionModel))
var custList = list.Where(x => x.CustomerId == order.CustomerId).OrderBy(x => x.Priority);
foreach (var template in custList) //遍历客户费用模板,查找匹配项
{
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
var fees = await CreateFeesIfMatchAsync(order, template);
if (fees != null)
{
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;
feeList.AddRange(fees);
var record = new FeeCustTemplateRecord
{
BusinessId = order.CustomerId,
BusinessType = BusinessType.OceanShippingExport,
CreateBy = long.Parse(User.UserId),
CreateTime = dt,
FeeCategoryId = template.FeeCategoryId,
FeeType = template.FeeType,
TemplateId = template.Id
};
await TenantDb.Insertable(record).ExecuteCommandAsync();
}
}
}
if (feeList.Count == 0) //未找到客户模板,开始匹配共享模板
{
var sharedList = list.Where(x => x.IsShared).OrderBy(x => x.Priority).ToList();
foreach (var item in sharedList)
//未找到客户模板,开始匹配共享模板
if (feeList.Count == 0)
{
var conditionModel = conditionModels.Find(x => x.Id == item.Id)?.ConditionModel;
if (actionService.Value.IsMatch(data, conditionModel))
var sharedList = list.Where(x => x.IsShared).OrderBy(x => x.Priority).ToList();
foreach (var template in sharedList)
{
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
var fees = await CreateFeesIfMatchAsync(order, template);
if (fees != null)
{
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;
feeList.AddRange(fees);
var record = new FeeCustTemplateRecord
{
BusinessId = order.CustomerId,
BusinessType = BusinessType.OceanShippingExport,
CreateBy = long.Parse(User.UserId),
CreateTime = dt,
FeeCategoryId = template.FeeCategoryId,
FeeType = template.FeeType,
TemplateId = template.Id
};
await TenantDb.Insertable(record).ExecuteCommandAsync();
}
}
}
}
if (feeList.Count > 0)
{
var result = await feeService.Value.SaveAsync(feeList, true);
if (!result.Succeeded)
//写入当前业务的费用
if (feeList.Count > 0)
{
//记录失败日志
await new ApplicationException(result.Message).LogAsync(Db);
var result = await feeService.Value.SaveAsync(feeList, true, false);
if (!result.Succeeded)
{
//记录失败日志
await new ApplicationException(result.Message).LogAsync(Db);
}
feeList.Clear();
}
}
await TenantDb.Ado.CommitTranAsync();
}
catch (Exception ex)
{
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
}
}
private async Task<List<FeeRecord>?> CreateFeesIfMatchAsync(SeaExportRes order, FeeCustTemplate template)
{
if (!string.IsNullOrEmpty(template.POLCode) && template.POLCode != order.LoadPortCode)
return null;
if (!string.IsNullOrEmpty(template.PODCode) && template.PODCode != order.DischargePortCode)
return null;
if (!string.IsNullOrEmpty(template.MBLFrtCode) && template.MBLFrtCode != order.MBLFrtCode)
return null;
if (template.LaneId.HasValue && template.LaneId != order.LaneId)
return null;
if (template.CarrierId.HasValue && template.CarrierId != order.CarrierId)
return null;
if (template.SourceId.HasValue && template.SourceId != order.SourceId)
return null;
if (template.ForwarderId.HasValue && template.ForwarderId != order.ForwarderId)
return null;
if (!string.IsNullOrEmpty(template.Condition)) //设置了自定义匹配条件
{
var conditionModel = JsonConvert.DeserializeObject<ConditionContent>(template.Condition);
if (!actionService.Value.IsMatch(order, conditionModel))
return null;
}
if (await TenantDb.Queryable<FeeCustTemplateRecord>().AnyAsync(x => x.BusinessId == order.Id && x.BusinessType == BusinessType.OceanShippingExport &&
x.FeeType == template.FeeType && x.FeeCategoryId == template.FeeCategoryId))
return null;
return await TenantDb.Queryable<FeeCustTemplateDetail>().Where(y => y.TemplateId == template.Id)
.Select(x => new FeeRecord
{
BusinessId = order.Id,
BusinessType = BusinessType.OceanShippingExport,
FeeType = template.FeeType,
FeeId = x.FeeId,
FeeCode = x.FeeCode,
FeeName = x.FeeName,
CustomerId = x.CustomerId,
CustomerName = x.CustomerName,
CustomerType = x.CustomerType,
Unit = x.Unit,
UnitPrice = SqlFunc.IsNull(x.UnitPrice.Value, 0),
//Quantity = x.IsCtn ? 1 : 0,
Currency = x.Currency,
ExchangeRate = x.ExchangeRate,
TaxRate = SqlFunc.IsNull(x.TaxRate.Value, 0),
AccTaxRate = SqlFunc.IsNull(x.AccTaxRate.Value, 0),
Tax = SqlFunc.IsNull(x.Tax.Value, 0),
TaxUnitPrice = SqlFunc.IsNull(x.TaxUnitPrice.Value, 0),
IsInvoice = x.IsInvoice,
IsAdvancedPay = x.IsAdvancedPay,
Remark = template.FeeCategoryName,
TemplateId = x.TemplateId,
InputMethod = InputMethod.Automatic
}).ToListAsync();
}
/// <summary>
/// 列表
/// </summary>

@ -134,8 +134,9 @@ namespace DS.WMS.Core.Fee.Method
/// </summary>
/// <param name="items">要提交的费用记录</param>
/// <param name="excludeZeroFee">是否排除总价为零的费用</param>
/// <param name="useTransaction">是否使用事务</param>
/// <returns></returns>
public async Task<DataResult> SaveAsync(IEnumerable<FeeRecord> items, bool excludeZeroFee = false)
public async Task<DataResult> SaveAsync(IEnumerable<FeeRecord> items, bool excludeZeroFee = false, bool useTransaction = true)
{
ArgumentNullException.ThrowIfNull(items, nameof(items));
@ -232,7 +233,8 @@ namespace DS.WMS.Core.Fee.Method
items = items.Where(x => x.Amount != 0);
DateTime dtNow = DateTime.Now;
await TenantDb.Ado.BeginTranAsync();
if (useTransaction)
await TenantDb.Ado.BeginTranAsync();
try
{
List<FeeRecord>? fees = null;
@ -302,23 +304,23 @@ namespace DS.WMS.Core.Fee.Method
if (createList.Count > 0)
await TenantDb.Insertable(createList).ExecuteCommandAsync();
await TenantDb.Ado.CommitTranAsync();
if (useTransaction)
await TenantDb.Ado.CommitTranAsync();
var list = createList.Union(updateList).Select(x => x.Adapt<FeeRecordRes>());
var result = DataResult.Success;
result.Data = list.Select(x => x.Id);
await WriteBackStatusAsync(first.BusinessId, first.BusinessType);
return result;
}
catch (Exception ex)
{
await TenantDb.Ado.RollbackTranAsync();
if (useTransaction)
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
finally
{
await WriteBackStatusAsync(first.BusinessId, first.BusinessType);
}
}
/// <summary>

@ -11,9 +11,11 @@ using DS.WMS.Core.Invoice.Dtos;
using DS.WMS.Core.Invoice.Interface;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.Sys.Interface;
using LanguageExt.Pretty;
using Mapster;
using Masuit.Tools.Models;
using Microsoft.Extensions.DependencyInjection;
using Org.BouncyCastle.Asn1.Cmp;
using SqlSugar;
namespace DS.WMS.Core.Invoice.Method
@ -332,11 +334,24 @@ namespace DS.WMS.Core.Invoice.Method
detail.ExchangeRate = 1m;
if (detail.ExchangeRate.HasValue)
detail.ApplyAmount = detail.ApplyAmount * detail.ExchangeRate.Value;
detail.ApplyAmount *= detail.ExchangeRate.Value;
invoice.Details.Add(detail);
}
////执行开票金额分配
//foreach (var app in request.Applications)
//{
// var details2 = invoice.Details.Where(x => x.RefId == app.ApplicationId).OrderBy(x => x.ApplyAmount).ToList();
// if (app.AmountRMB.HasValue)
// {
// var result2 = AssignAmount(details2.FindAll(x => x.OriginalCurrency == FeeCurrency.RMB_CODE), app.AmountRMB.Value);
// if (!result2.Succeeded)
// return DataResult<TEntity>.Failed(result2.Message, result2.MultiCode);
// }
//}
}
else if (request.Invoice.Mode == InvoiceMode.Free) //自由开票
{
@ -418,22 +433,25 @@ namespace DS.WMS.Core.Invoice.Method
}
}
//补充销方信息
var org = await Db.Queryable<SysOrg>().Where(x => x.Id == User.OrgId).Select(x => new { x.OrgFullName, x.LicenseCode }).FirstAsync();
if (org != null)
{
invoice.OrgName = org.OrgFullName;
invoice.TaxID = org.LicenseCode;
}
var orgBank = await Db.Queryable<SysBank>().Where(x => x.LinkId == User.OrgId && x.Currency == invoice.Currency).OrderByDescending(x => x.IsDefault).Select(x => new
{
x.BankAccountNo,
x.BankName
}).FirstAsync();
if (orgBank != null)
if (invoice.Id == 0)
{
invoice.BankName = orgBank.BankName;
invoice.Account = orgBank.BankAccountNo;
//补充销方信息
var org = await Db.Queryable<SysOrg>().Where(x => x.Id == User.OrgId).Select(x => new { x.OrgFullName, x.LicenseCode }).FirstAsync();
if (org != null)
{
invoice.OrgName = org.OrgFullName;
invoice.TaxID = org.LicenseCode;
}
var orgBank = await Db.Queryable<SysBank>().Where(x => x.LinkId == User.OrgId && x.Currency == invoice.Currency).OrderByDescending(x => x.IsDefault).Select(x => new
{
x.BankAccountNo,
x.BankName
}).FirstAsync();
if (orgBank != null)
{
invoice.BankName = orgBank.BankName;
invoice.Account = orgBank.BankAccountNo;
}
}
//筛选出新增的费用明细
@ -539,6 +557,31 @@ namespace DS.WMS.Core.Invoice.Method
}
}
static DataResult AssignAmount(List<ApplicationDetail> details, decimal invoiceAmount)
{
if (details.Count == 0)
return DataResult.Success;
var totalRMB = details.Sum(x => x.ApplyAmount);
if (Math.Abs(invoiceAmount) > totalRMB)
return DataResult.Failed("申请开票金额不能大于剩余开票金额");
if (totalRMB != invoiceAmount) //非全额开票
{
var rest = totalRMB - invoiceAmount;
foreach (var detail in details)
{
if (rest == 0)
break;
detail.ApplyAmount = detail.ApplyAmount - rest;
rest = detail.ApplyAmount - rest;
}
}
return DataResult.Success;
}
/// <summary>
/// 生成发票明细
/// </summary>

@ -8,7 +8,6 @@ using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Op.Entity.TaskInteraction;
using DS.WMS.Core.Op.Interface.TaskInteraction;
using DS.WMS.Core.Op.Method.TaskInteraction.ActionSelector;
using DS.WMS.Core.Sys.Entity;
using DS.WMS.Core.TaskPlat.Entity;
using Fasterflect;
using LanguageExt.Pipes;

@ -845,34 +845,30 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
//根据审批结果更新任务状态
await SetTaskStatusAsync(req);
if (instance.FlowStatus == FlowStatusEnum.Approve)
{
//终审通过且任务类型为审单,则生成费用
if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT && instance.IsCompleted)
{
UriBuilder builder = new(configuration["FeeService:BaseUrl"])
{
Path = configuration["FeeService:GenerateFees"]
};
string url = builder.ToString();
if (string.IsNullOrEmpty(url))
{
await LogService.WriteLogAsync(req, "未在配置文件中配置费用服务URL无法根据费用模板生成费用");
continue;
}
string json = JsonConvert.SerializeObject(new BizItem
{
Id = req.BusinessId,
BusinessType = req.BusinessType.GetValueOrDefault()
});
Api.SendRequestAsync(HttpMethod.Post, url, json);
}
}
else if (instance.FlowStatus == FlowStatusEnum.Reject)
{
////终审通过且任务类型为审单,则生成费用
//if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT && instance.IsCompleted)
//{
// UriBuilder builder = new(configuration["FeeService:BaseUrl"])
// {
// Path = configuration["FeeService:GenerateFees"]
// };
// string url = builder.ToString();
// if (string.IsNullOrEmpty(url))
// {
// await LogService.WriteLogAsync(req, "未在配置文件中配置费用服务URL无法根据费用模板生成费用");
// continue;
// }
// string json = JsonConvert.SerializeObject(new BizItem
// {
// Id = req.BusinessId,
// BusinessType = req.BusinessType.GetValueOrDefault()
// });
// Api.SendRequestAsync(HttpMethod.Post, url, json);
//}
if (instance.FlowStatus == FlowStatusEnum.Reject)
result.Message = MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.TaskRejected));
}
if (IsOrderType(request.TaskType))
result.Data = new { instance.IsCompleted, instance.FlowStatus };

@ -1,7 +1,6 @@
using System.Net;
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Application.Dtos;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface;
using Microsoft.AspNetCore.Mvc;
@ -27,15 +26,15 @@ namespace DS.WMS.FeeApi.Controllers
/// <summary>
/// 生成订单费用
/// </summary>
/// <param name="biz"></param>
/// <param name="etd">开船日期</param>
/// <returns></returns>
[HttpPost, Route("GenerateFees")]
public async Task<IActionResult> GenerateFeesAsync([FromBody] BizItem biz)
public async Task<IActionResult> GenerateFeesAsync(DateTime? etd)
{
HttpStatusCode httpStatusCode;
try
{
await _invokeService.GenerateFeesAsync(biz.Id, biz.BusinessType);
await _invokeService.GenerateFeesAsync(etd ?? DateTime.Now.Date);
httpStatusCode = HttpStatusCode.NoContent;
}
catch

@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project>
<PropertyGroup>
<_PublishTargetUrl>D:\Publish\DS8\FeeApi</_PublishTargetUrl>
<History>True|2024-09-27T10:45:48.2812860Z||;True|2024-09-27T18:10:25.5697467+08:00||;True|2024-09-27T17:39:06.3169139+08:00||;True|2024-09-27T17:30:14.1043193+08:00||;True|2024-09-27T16:02:09.0703159+08:00||;True|2024-09-27T15:53:05.1789245+08:00||;True|2024-09-27T15:32:52.1934490+08:00||;True|2024-09-27T13:51:24.9197626+08:00||;True|2024-09-27T13:48:17.2817346+08:00||;True|2024-09-27T11:51:46.8193040+08:00||;True|2024-09-27T10:58:33.1059648+08:00||;True|2024-09-27T10:37:35.0336563+08:00||;False|2024-09-27T10:31:52.6302264+08:00||;True|2024-09-26T19:50:15.5513195+08:00||;True|2024-09-26T19:47:14.0781788+08:00||;True|2024-09-26T19:01:26.5428388+08:00||;True|2024-09-26T18:35:28.7455319+08:00||;True|2024-09-26T18:24:30.8084807+08:00||;True|2024-09-26T18:20:47.3005460+08:00||;True|2024-09-26T18:04:39.8012913+08:00||;True|2024-09-26T17:48:13.8526872+08:00||;True|2024-09-26T16:08:20.1746970+08:00||;True|2024-09-26T16:01:01.1501975+08:00||;False|2024-09-26T16:00:34.1516745+08:00||;True|2024-09-26T14:33:03.4007570+08:00||;True|2024-09-25T19:14:27.8906774+08:00||;True|2024-09-25T18:57:40.1435131+08:00||;True|2024-09-25T17:38:44.0915841+08:00||;True|2024-09-25T15:33:58.4630618+08:00||;True|2024-09-25T15:10:31.3022063+08:00||;False|2024-09-25T14:14:40.9640545+08:00||;True|2024-09-25T10:09:32.2558600+08:00||;True|2024-09-25T09:59:17.1525160+08:00||;False|2024-09-25T09:57:58.7265103+08:00||;False|2024-09-25T09:53:36.7732713+08:00||;False|2024-09-24T18:40:10.0166224+08:00||;True|2024-09-24T08:59:56.1995425+08:00||;True|2024-09-23T18:07:54.7222163+08:00||;True|2024-09-23T17:23:57.7568406+08:00||;True|2024-09-23T16:28:49.3169826+08:00||;True|2024-09-23T15:57:31.8052490+08:00||;True|2024-09-23T11:47:21.1445419+08:00||;True|2024-09-23T09:24:36.0732229+08:00||;True|2024-09-21T11:59:19.0549926+08:00||;True|2024-09-21T11:24:32.4451752+08:00||;True|2024-09-21T10:39:11.5297411+08:00||;True|2024-09-20T18:24:31.7827684+08:00||;True|2024-09-19T17:55:53.1666689+08:00||;True|2024-09-19T17:42:47.9061485+08:00||;True|2024-09-19T16:08:21.7225571+08:00||;False|2024-09-19T14:15:42.9318446+08:00||;True|2024-09-19T11:20:03.5567568+08:00||;True|2024-09-18T11:35:18.1509724+08:00||;True|2024-09-18T09:08:59.1152574+08:00||;True|2024-09-14T15:48:22.9374486+08:00||;True|2024-09-14T15:42:19.0503983+08:00||;True|2024-09-14T11:51:53.3339222+08:00||;True|2024-09-14T11:41:38.3542237+08:00||;True|2024-09-14T11:19:13.1037012+08:00||;True|2024-09-13T14:31:12.4598160+08:00||;True|2024-09-13T10:44:56.1241214+08:00||;False|2024-09-13T10:44:26.6088271+08:00||;False|2024-09-13T10:44:06.1615137+08:00||;False|2024-09-13T10:43:19.2432517+08:00||;False|2024-09-13T10:38:18.1663387+08:00||;True|2024-09-06T18:49:17.9435308+08:00||;True|2024-09-06T17:01:39.6646353+08:00||;True|2024-09-06T10:27:36.9990456+08:00||;True|2024-09-06T09:48:23.4236094+08:00||;True|2024-09-05T13:57:23.8452431+08:00||;True|2024-09-05T10:21:34.6675149+08:00||;True|2024-09-05T09:12:44.5610882+08:00||;True|2024-09-04T10:07:38.3707398+08:00||;True|2024-09-04T09:52:47.0574599+08:00||;True|2024-09-03T16:41:23.7516960+08:00||;True|2024-09-03T15:22:31.8718097+08:00||;True|2024-09-03T10:01:09.7656702+08:00||;False|2024-09-03T09:46:46.8956531+08:00||;True|2024-09-02T17:07:41.0268500+08:00||;True|2024-09-02T13:50:22.0203254+08:00||;True|2024-09-02T13:34:23.3441546+08:00||;True|2024-08-30T11:25:14.7431645+08:00||;True|2024-08-29T16:38:26.3491372+08:00||;True|2024-08-29T16:32:31.8580864+08:00||;False|2024-08-29T16:30:41.4763198+08:00||;True|2024-08-09T09:18:05.8484398+08:00||;True|2024-08-09T08:45:38.7858906+08:00||;True|2024-08-05T11:37:07.3133020+08:00||;True|2024-07-24T16:45:58.2272340+08:00||;True|2024-07-24T15:48:52.0128987+08:00||;True|2024-07-23T17:41:01.7494842+08:00||;True|2024-07-23T17:25:11.8773492+08:00||;True|2024-07-23T17:07:16.5460273+08:00||;True|2024-07-22T08:59:23.3235603+08:00||;True|2024-07-12T17:35:11.1225017+08:00||;True|2024-07-11T11:40:17.3581147+08:00||;True|2024-07-04T17:20:50.0175739+08:00||;True|2024-07-02T11:26:14.2092751+08:00||;True|2024-07-02T09:21:51.3513605+08:00||;True|2024-07-01T17:47:56.0407256+08:00||;</History>
<History>True|2024-09-27T11:01:59.6945760Z||;True|2024-09-27T18:45:48.2812860+08:00||;True|2024-09-27T18:10:25.5697467+08:00||;True|2024-09-27T17:39:06.3169139+08:00||;True|2024-09-27T17:30:14.1043193+08:00||;True|2024-09-27T16:02:09.0703159+08:00||;True|2024-09-27T15:53:05.1789245+08:00||;True|2024-09-27T15:32:52.1934490+08:00||;True|2024-09-27T13:51:24.9197626+08:00||;True|2024-09-27T13:48:17.2817346+08:00||;True|2024-09-27T11:51:46.8193040+08:00||;True|2024-09-27T10:58:33.1059648+08:00||;True|2024-09-27T10:37:35.0336563+08:00||;False|2024-09-27T10:31:52.6302264+08:00||;True|2024-09-26T19:50:15.5513195+08:00||;True|2024-09-26T19:47:14.0781788+08:00||;True|2024-09-26T19:01:26.5428388+08:00||;True|2024-09-26T18:35:28.7455319+08:00||;True|2024-09-26T18:24:30.8084807+08:00||;True|2024-09-26T18:20:47.3005460+08:00||;True|2024-09-26T18:04:39.8012913+08:00||;True|2024-09-26T17:48:13.8526872+08:00||;True|2024-09-26T16:08:20.1746970+08:00||;True|2024-09-26T16:01:01.1501975+08:00||;False|2024-09-26T16:00:34.1516745+08:00||;True|2024-09-26T14:33:03.4007570+08:00||;True|2024-09-25T19:14:27.8906774+08:00||;True|2024-09-25T18:57:40.1435131+08:00||;True|2024-09-25T17:38:44.0915841+08:00||;True|2024-09-25T15:33:58.4630618+08:00||;True|2024-09-25T15:10:31.3022063+08:00||;False|2024-09-25T14:14:40.9640545+08:00||;True|2024-09-25T10:09:32.2558600+08:00||;True|2024-09-25T09:59:17.1525160+08:00||;False|2024-09-25T09:57:58.7265103+08:00||;False|2024-09-25T09:53:36.7732713+08:00||;False|2024-09-24T18:40:10.0166224+08:00||;True|2024-09-24T08:59:56.1995425+08:00||;True|2024-09-23T18:07:54.7222163+08:00||;True|2024-09-23T17:23:57.7568406+08:00||;True|2024-09-23T16:28:49.3169826+08:00||;True|2024-09-23T15:57:31.8052490+08:00||;True|2024-09-23T11:47:21.1445419+08:00||;True|2024-09-23T09:24:36.0732229+08:00||;True|2024-09-21T11:59:19.0549926+08:00||;True|2024-09-21T11:24:32.4451752+08:00||;True|2024-09-21T10:39:11.5297411+08:00||;True|2024-09-20T18:24:31.7827684+08:00||;True|2024-09-19T17:55:53.1666689+08:00||;True|2024-09-19T17:42:47.9061485+08:00||;True|2024-09-19T16:08:21.7225571+08:00||;False|2024-09-19T14:15:42.9318446+08:00||;True|2024-09-19T11:20:03.5567568+08:00||;True|2024-09-18T11:35:18.1509724+08:00||;True|2024-09-18T09:08:59.1152574+08:00||;True|2024-09-14T15:48:22.9374486+08:00||;True|2024-09-14T15:42:19.0503983+08:00||;True|2024-09-14T11:51:53.3339222+08:00||;True|2024-09-14T11:41:38.3542237+08:00||;True|2024-09-14T11:19:13.1037012+08:00||;True|2024-09-13T14:31:12.4598160+08:00||;True|2024-09-13T10:44:56.1241214+08:00||;False|2024-09-13T10:44:26.6088271+08:00||;False|2024-09-13T10:44:06.1615137+08:00||;False|2024-09-13T10:43:19.2432517+08:00||;False|2024-09-13T10:38:18.1663387+08:00||;True|2024-09-06T18:49:17.9435308+08:00||;True|2024-09-06T17:01:39.6646353+08:00||;True|2024-09-06T10:27:36.9990456+08:00||;True|2024-09-06T09:48:23.4236094+08:00||;True|2024-09-05T13:57:23.8452431+08:00||;True|2024-09-05T10:21:34.6675149+08:00||;True|2024-09-05T09:12:44.5610882+08:00||;True|2024-09-04T10:07:38.3707398+08:00||;True|2024-09-04T09:52:47.0574599+08:00||;True|2024-09-03T16:41:23.7516960+08:00||;True|2024-09-03T15:22:31.8718097+08:00||;True|2024-09-03T10:01:09.7656702+08:00||;False|2024-09-03T09:46:46.8956531+08:00||;True|2024-09-02T17:07:41.0268500+08:00||;True|2024-09-02T13:50:22.0203254+08:00||;True|2024-09-02T13:34:23.3441546+08:00||;True|2024-08-30T11:25:14.7431645+08:00||;True|2024-08-29T16:38:26.3491372+08:00||;True|2024-08-29T16:32:31.8580864+08:00||;False|2024-08-29T16:30:41.4763198+08:00||;True|2024-08-09T09:18:05.8484398+08:00||;True|2024-08-09T08:45:38.7858906+08:00||;True|2024-08-05T11:37:07.3133020+08:00||;True|2024-07-24T16:45:58.2272340+08:00||;True|2024-07-24T15:48:52.0128987+08:00||;True|2024-07-23T17:41:01.7494842+08:00||;True|2024-07-23T17:25:11.8773492+08:00||;True|2024-07-23T17:07:16.5460273+08:00||;True|2024-07-22T08:59:23.3235603+08:00||;True|2024-07-12T17:35:11.1225017+08:00||;True|2024-07-11T11:40:17.3581147+08:00||;True|2024-07-04T17:20:50.0175739+08:00||;True|2024-07-02T11:26:14.2092751+08:00||;True|2024-07-02T09:21:51.3513605+08:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
Loading…
Cancel
Save