根据业务ID与类型生成费用

usertest
嵇文龙 3 months ago
parent 282f876afc
commit 2c17f3bd38

@ -21,11 +21,6 @@
/// 数据源名称 /// 数据源名称
/// </summary> /// </summary>
public string? SourceName { get; set; } public string? SourceName { get; set; }
/// <summary>
/// 附加数据项
/// </summary>
public object? ExtraData { get; set; }
} }
public class ConditionDetail public class ConditionDetail

@ -36,7 +36,7 @@ public class FeeCustTemplateDetailReq
/// <summary> /// <summary>
/// 收付类型(收、付) /// 收付类型(收、付)
/// </summary> /// </summary>
public int FeeType { get; set; } public FeeType FeeType { get; set; }
/// <summary> /// <summary>
/// 客户Id /// 客户Id
/// </summary> /// </summary>

@ -12,6 +12,24 @@ namespace DS.WMS.Core.Fee.Entity
[SugarTable("fee_cust_template", "往来单位费用模板")] [SugarTable("fee_cust_template", "往来单位费用模板")]
public class FeeCustTemplate : SharedOrgModel<long> public class FeeCustTemplate : SharedOrgModel<long>
{ {
/// <summary>
/// 结算对象Id
/// </summary>
[SugarColumn(ColumnDescription = "结算对象Id")]
public long CustomerId { get; set; }
/// <summary>
/// 结算对象
/// </summary>
[SugarColumn(ColumnDescription = "结算对象", Length = 100, IsNullable = true)]
public string? CustomerName { get; set; }
/// <summary>
/// 结算对象类型
/// </summary>
[SugarColumn(ColumnDescription = "结算对象类型", IsNullable = true)]
public CustomerTypeEnum? CustomerType { get; set; }
/// <summary> /// <summary>
/// 业务类型 /// 业务类型
/// </summary> /// </summary>

@ -40,21 +40,6 @@ namespace DS.WMS.Core.Fee.Entity
[SugarColumn(ColumnDescription = "费用名称", Length = 100, IsNullable = true)] [SugarColumn(ColumnDescription = "费用名称", Length = 100, IsNullable = true)]
public string? FeeName { get; set; } public string? FeeName { get; set; }
/// <summary> /// <summary>
/// 结算对象Id
/// </summary>
[SugarColumn(ColumnDescription = "结算对象Id")]
public long CustomerId { get; set; }
/// <summary>
/// 结算对象
/// </summary>
[SugarColumn(ColumnDescription = "结算对象", Length = 100, IsNullable = true)]
public string? CustomerName { get; set; }
/// <summary>
/// 客户类型
/// </summary>
[SugarColumn(ColumnDescription = "客户类型", IsNullable = true)]
public CustomerTypeEnum? CustomerType { get; set; }
/// <summary>
/// 收付类型(收、付) /// 收付类型(收、付)
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "收付类型(收、付)", IsNullable = false, DefaultValue = "1")] [SugarColumn(ColumnDescription = "收付类型(收、付)", IsNullable = false, DefaultValue = "1")]
@ -72,19 +57,14 @@ namespace DS.WMS.Core.Fee.Entity
/// <summary> /// <summary>
/// 币别 /// 币别
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "币别", Length = 100, IsNullable = true)] [SugarColumn(ColumnDescription = "币别", Length = 100, IsNullable = false)]
public string? Currency { get; set; } public string Currency { get; set; } = string.Empty;
/// <summary> /// <summary>
/// 单价 /// 单价
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "单价", IsNullable = true, Length = 18, DecimalDigits = 4, DefaultValue = "0")] [SugarColumn(ColumnDescription = "单价", IsNullable = true, Length = 18, DecimalDigits = 4, DefaultValue = "0")]
public decimal? UnitPrice { get; set; } public decimal? UnitPrice { get; set; }
/// <summary> /// <summary>
/// 排序
/// </summary>
[SugarColumn(ColumnDescription = "排序")]
public int OrderNo { get; set; } = 100;
/// <summary>
/// 汇率 /// 汇率
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "汇率", IsNullable = true, Length = 18, DecimalDigits = 4, DefaultValue = "0")] [SugarColumn(ColumnDescription = "汇率", IsNullable = true, Length = 18, DecimalDigits = 4, DefaultValue = "0")]

@ -44,8 +44,7 @@ namespace DS.WMS.Core.Fee.Method
{ {
if (req.Id == 0) if (req.Id == 0)
{ {
if (TenantDb.Queryable<FeeCustTemplateDetail>().Where(x => if (TenantDb.Queryable<FeeCustTemplateDetail>().Where(x => x.FeeId == req.FeeId && x.FeeType == req.FeeType).Any())
x.FeeId == req.FeeId && x.CustomerId == req.CustomerId && x.FeeType == req.FeeType).Any())
return DataResult.Failed("往来单位固定费用已存在!", MultiLanguageConst.FeeCustTemplateDetailExist); return DataResult.Failed("往来单位固定费用已存在!", MultiLanguageConst.FeeCustTemplateDetailExist);
var data = req.Adapt<FeeCustTemplateDetail>(); var data = req.Adapt<FeeCustTemplateDetail>();

@ -15,7 +15,7 @@ namespace DS.WMS.Core.Fee.Method
/// <summary> /// <summary>
/// 往来单位费用模板 /// 往来单位费用模板
/// </summary> /// </summary>
public class FeeCustTemplateService : FeeServiceBase public class FeeCustTemplateService : FeeServiceBase, IFeeCustTemplateService
{ {
Lazy<IActionManagerService> actionService; Lazy<IActionManagerService> actionService;
Lazy<IFeeRecordService> feeService; Lazy<IFeeRecordService> feeService;
@ -38,91 +38,100 @@ namespace DS.WMS.Core.Fee.Method
/// <returns></returns> /// <returns></returns>
public async Task GenerateFeesAsync(long bsId, BusinessType businessType = BusinessType.OceanShippingExport) public async Task GenerateFeesAsync(long bsId, BusinessType businessType = BusinessType.OceanShippingExport)
{ {
var list = await TenantDb.Queryable<FeeCustTemplate>().Where(x => x.BusinessType == businessType && var model = await actionService.Value.GetBusinessDataAsync(bsId, businessType, nameof(SeaExport.CustomerId));
!SqlFunc.IsNullOrEmpty(x.Condition)).Select(x => new long custId = model.CustomerId;
{ try
x.Id, {
x.FeeType, var list = await TenantDb.Queryable<FeeCustTemplate>()
x.Condition, .Where(x => x.BusinessType == businessType && x.CustomerId == custId && !SqlFunc.IsNullOrEmpty(x.Condition))
Details = x.Details.Select(y => new .Select(x => new
{ {
y.FeeId, x.Id,
y.FeeCode, x.CustomerId,
y.FeeName, x.CustomerName,
y.FeeType, x.CustomerType,
y.CustomerId, x.Condition,
y.CustomerName, Details = SqlFunc.Subqueryable<FeeCustTemplateDetail>().Where(y => y.TemplateId == x.Id).ToList(y => new
y.CustomerType, {
y.Unit, y.FeeId,
y.IsCtn, y.FeeCode,
y.Currency, y.FeeName,
y.UnitPrice, y.FeeType,
y.ExchangeRate, y.Unit,
y.TaxRate, y.IsCtn,
y.AccTaxRate, y.Currency,
y.Tax, y.UnitPrice,
y.TaxUnitPrice, y.ExchangeRate,
y.IsInvoice, y.TaxRate,
y.IsAdvancedPay y.AccTaxRate,
}) y.Tax,
}).ToListAsync(); y.TaxUnitPrice,
y.IsInvoice,
y.IsAdvancedPay
})
}).ToListAsync();
if (list.Count == 0) if (list.Count == 0)
return; return;
var conditionModels = list.Select(x => new var conditionModels = list.Select(x => new
{ {
x.Id, x.Id,
ConditionModel = JsonConvert.DeserializeObject<ConditionContent>(x.Condition) ConditionModel = JsonConvert.DeserializeObject<ConditionContent>(x.Condition)
}).ToList(); }).ToList();
var data = actionService.Value.GetBusinessDataAsync(bsId, businessType, conditionModels.Select(x => x.ConditionModel)); var data = await actionService.Value.GetBusinessDataAsync(bsId, businessType, conditionModels.Select(x => x.ConditionModel));
if (data == null) if (data == null)
return; return;
List<FeeRecord> feeList = []; List<FeeRecord> feeList = [];
foreach (var item in list) foreach (var item in list)
{
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 conditionModel = conditionModels.Find(x => x.Id == item.Id)?.ConditionModel;
if (actionService.Value.IsMatch(data, conditionModel))
{ {
BusinessId = bsId, var fees = item.Details.Select(x => new FeeRecord
BusinessType = businessType, {
FeeType = x.FeeType, BusinessId = bsId,
FeeId = x.FeeId, BusinessType = businessType,
FeeCode = x.FeeCode, FeeType = x.FeeType,
FeeName = x.FeeName, FeeId = x.FeeId,
CustomerId = x.CustomerId, FeeCode = x.FeeCode,
CustomerName = x.CustomerName, FeeName = x.FeeName,
CustomerType = x.CustomerType?.ToString(), CustomerId = item.CustomerId,
Unit = x.Unit, CustomerName = item.CustomerName,
UnitPrice = x.UnitPrice.GetValueOrDefault(), CustomerType = item.CustomerType?.ToString(),
Currency = x.Currency, Unit = x.Unit,
//IsCtn = x.IsCtn, UnitPrice = x.UnitPrice.GetValueOrDefault(),
ExchangeRate = x.ExchangeRate, Currency = x.Currency,
TaxRate = x.TaxRate.GetValueOrDefault(), //IsCtn = x.IsCtn,
AccTaxRate = x.AccTaxRate.GetValueOrDefault(), ExchangeRate = x.ExchangeRate,
Tax = x.Tax.GetValueOrDefault(), TaxRate = x.TaxRate.GetValueOrDefault(),
TaxUnitPrice = x.TaxUnitPrice.GetValueOrDefault(), AccTaxRate = x.AccTaxRate.GetValueOrDefault(),
IsInvoice = x.IsInvoice, Tax = x.Tax.GetValueOrDefault(),
IsAdvancedPay = x.IsAdvancedPay, TaxUnitPrice = x.TaxUnitPrice.GetValueOrDefault(),
Amount = x.UnitPrice.GetValueOrDefault() IsInvoice = x.IsInvoice,
}); IsAdvancedPay = x.IsAdvancedPay,
Amount = x.UnitPrice.GetValueOrDefault()
});
feeList.AddRange(fees); feeList.AddRange(fees);
}
} }
}
if (feeList.Count > 0) if (feeList.Count > 0)
{
var result = await feeService.Value.SaveAsync(feeList);
if (!result.Succeeded)
{ {
//记录失败日志 var result = await feeService.Value.SaveAsync(feeList);
await new ApplicationException(result.Message).LogAsync(Db); if (!result.Succeeded)
{
//记录失败日志
await new ApplicationException(result.Message).LogAsync(Db);
}
} }
} }
catch (Exception ex)
{
await ex.LogAsync(Db);
}
} }
/// <summary> /// <summary>
@ -172,6 +181,7 @@ namespace DS.WMS.Core.Fee.Method
foreach (var item in model.Details) foreach (var item in model.Details)
{ {
item.TemplateId = model.Id; item.TemplateId = model.Id;
item.FeeType = model.FeeType;
item.CreateBy = userId; item.CreateBy = userId;
item.CreateTime = dt; item.CreateTime = dt;
} }

@ -193,26 +193,28 @@ namespace DS.WMS.Core.Fee.Method
//若计价货币单位不等于本位币则尝试获取最新汇率 //若计价货币单位不等于本位币则尝试获取最新汇率
await FetchExchangeRateAsync(items); await FetchExchangeRateAsync(items);
var createList = items.Where(x => x.Id == 0).ToList();
await TenantDb.Insertable(createList).ExecuteCommandAsync();
var updateList = items.Where(x => x.Id > 0).ToList(); var updateList = items.Where(x => x.Id > 0).ToList();
await TenantDb.Updateable(updateList).IgnoreColumns(x => new if (updateList.Count > 0)
{ await TenantDb.Updateable(updateList).IgnoreColumns(x => new
x.FeeStatus, {
x.BusinessId, x.FeeStatus,
x.BusinessType, x.BusinessId,
x.CreateBy, x.BusinessType,
x.CreateTime, x.CreateBy,
x.DeleteBy, x.CreateTime,
x.Deleted, x.DeleteBy,
x.DeleteTime, x.Deleted,
x.SubmitDate, x.DeleteTime,
x.SubmitBy, x.SubmitDate,
x.AuditBy, x.SubmitBy,
x.AuditOperator, x.AuditBy,
x.AuditDate x.AuditOperator,
}).ExecuteCommandAsync(); x.AuditDate
}).ExecuteCommandAsync();
var createList = items.Where(x => x.Id == 0).ToList();
if (createList.Count > 0)
await TenantDb.Insertable(createList).ExecuteCommandAsync();
await TenantDb.Ado.CommitTranAsync(); await TenantDb.Ado.CommitTranAsync();

@ -71,7 +71,7 @@ public class FlowInstance : BaseTenantModel<long>
/// <summary> /// <summary>
/// 执行人 /// 执行人
/// </summary> /// </summary>
[Description("执行人")] [SugarColumn(ColumnDescription = "执行人", ColumnDataType = "longtext", IsNullable = true)]
public string MakerList { get; set; } public string MakerList { get; set; }
/// <summary> /// <summary>

@ -13,7 +13,6 @@ using Fasterflect;
using Masuit.Tools; using Masuit.Tools;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using SqlSugar; using SqlSugar;
using static AnyDiff.DifferenceLines;
namespace DS.WMS.Core.Op.Method.TaskInteraction namespace DS.WMS.Core.Op.Method.TaskInteraction
{ {
@ -45,6 +44,9 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
ArgumentNullException.ThrowIfNull(condition, nameof(condition)); ArgumentNullException.ThrowIfNull(condition, nameof(condition));
TaskFlowDataContext dataContext = new((TaskFlowDataNameConst.Business, source)); TaskFlowDataContext dataContext = new((TaskFlowDataNameConst.Business, source));
if (condition.SourceName.IsNullOrEmpty())
condition.SourceName = TaskFlowDataNameConst.Business;
return ConditionHelper.IsPass(condition, dataContext); return ConditionHelper.IsPass(condition, dataContext);
} }

@ -625,6 +625,12 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
MakerList = x.MakerList, MakerList = x.MakerList,
}).FirstAsync(); }).FirstAsync();
//终审通过且任务类型为审单,则生成费用
if (request.TaskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT && flow.FlowStatus == FlowStatusEnum.Approve && flow.IsCompleted)
{
FeeTemplateService.Value.GenerateFeesAsync(request.Ids[0], request.BusinessType.GetValueOrDefault());
}
result.Data = new { flow.IsCompleted, flow.FlowStatus }; result.Data = new { flow.IsCompleted, flow.FlowStatus };
return result; return result;
} }
@ -710,13 +716,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
remark += ";驳回理由:" + callback.RejectReason; remark += ";驳回理由:" + callback.RejectReason;
} }
else if (callback.FlowStatus == FlowStatusEnum.Approve)
{
if (taskType == TaskBaseTypeEnum.WAIT_ORDER_AUDIT)
{
FeeTemplateService.Value.GenerateFeesAsync(callback.BusinessId, callback.BusinessType.GetValueOrDefault());
}
}
//记录日志 //记录日志
await LogService.WriteLogAsync(new BusinessTaskLog await LogService.WriteLogAsync(new BusinessTaskLog

@ -1,23 +1,23 @@
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Data; using DS.Module.Core.Data;
using DS.WMS.Core.Fee.Dtos; using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface; using DS.WMS.Core.Fee.Interface;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.FeeApi.Controllers namespace DS.WMS.FeeApi.Controllers
{ {
/// <summary> /// <summary>
/// 往来单位固定费用-服务 /// 往来单位费用模板API
/// </summary> /// </summary>
public class FeeCustTemplateDetailController : ApiController public class FeeCustTemplateController : ApiController
{ {
private readonly IFeeCustTemplateDetailService _invokeService; readonly IFeeCustTemplateService _invokeService;
/// <summary> /// <summary>
/// 构造函数 /// 构造函数
/// </summary> /// </summary>
/// <param name="invokeService"></param> /// <param name="invokeService"></param>
public FeeCustTemplateDetailController(IFeeCustTemplateDetailService invokeService) public FeeCustTemplateController(IFeeCustTemplateService invokeService)
{ {
_invokeService = invokeService; _invokeService = invokeService;
} }
@ -27,12 +27,10 @@ namespace DS.WMS.FeeApi.Controllers
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost, Route("GetList")]
[Route("GetFeeCustTemplateDetailList")] public async Task<DataResult<List<FeeCustTemplate>>> GetListAsync([FromBody] PageRequest request)
public DataResult<List<FeeCustTemplateDetailRes>> GetFeeCustTemplateDetailList([FromBody] PageRequest request)
{ {
var res = _invokeService.GetListByPage(request); return await _invokeService.GetListAsync(request);
return res;
} }
/// <summary> /// <summary>
@ -40,12 +38,13 @@ namespace DS.WMS.FeeApi.Controllers
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost, Route("Edit")]
[Route("EditFeeCustTemplateDetail")] public async Task<DataResult> EditAsync([FromBody] FeeCustTemplate model)
public DataResult EditFeeCustTemplateDetail([FromBody] FeeCustTemplateDetailReq model)
{ {
var res = _invokeService.EditAsync(model); if (model == null)
return res; return DataResult.FailedWithDesc(MultiLanguageConst.IllegalRequest);
return await _invokeService.EditAsync(model);
} }
/// <summary> /// <summary>
@ -53,12 +52,10 @@ namespace DS.WMS.FeeApi.Controllers
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet, Route("Edit")]
[Route("GetFeeCustTemplateDetailInfo")] public async Task<DataResult<FeeCustTemplate>> GetAsync([FromQuery] long id)
public DataResult<FeeCustTemplateDetailRes> GetFeeCustTemplateDetailInfo([FromQuery] string id)
{ {
var res = _invokeService.GetFeeCustTemplateDetailInfo(id); return await _invokeService.GetAsync(id);
return res;
} }
/// <summary> /// <summary>
Loading…
Cancel
Save