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

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

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

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

@ -12,6 +12,24 @@ namespace DS.WMS.Core.Fee.Entity
[SugarTable("fee_cust_template", "往来单位费用模板")]
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>

@ -40,21 +40,6 @@ namespace DS.WMS.Core.Fee.Entity
[SugarColumn(ColumnDescription = "费用名称", Length = 100, IsNullable = true)]
public string? FeeName { get; set; }
/// <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>
[SugarColumn(ColumnDescription = "收付类型(收、付)", IsNullable = false, DefaultValue = "1")]
@ -72,19 +57,14 @@ namespace DS.WMS.Core.Fee.Entity
/// <summary>
/// 币别
/// </summary>
[SugarColumn(ColumnDescription = "币别", Length = 100, IsNullable = true)]
public string? Currency { get; set; }
[SugarColumn(ColumnDescription = "币别", Length = 100, IsNullable = false)]
public string Currency { get; set; } = string.Empty;
/// <summary>
/// 单价
/// </summary>
[SugarColumn(ColumnDescription = "单价", IsNullable = true, Length = 18, DecimalDigits = 4, DefaultValue = "0")]
public decimal? UnitPrice { get; set; }
/// <summary>
/// 排序
/// </summary>
[SugarColumn(ColumnDescription = "排序")]
public int OrderNo { get; set; } = 100;
/// <summary>
/// 汇率
/// </summary>
[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 (TenantDb.Queryable<FeeCustTemplateDetail>().Where(x =>
x.FeeId == req.FeeId && x.CustomerId == req.CustomerId && x.FeeType == req.FeeType).Any())
if (TenantDb.Queryable<FeeCustTemplateDetail>().Where(x => x.FeeId == req.FeeId && x.FeeType == req.FeeType).Any())
return DataResult.Failed("往来单位固定费用已存在!", MultiLanguageConst.FeeCustTemplateDetailExist);
var data = req.Adapt<FeeCustTemplateDetail>();

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

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

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

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

@ -625,6 +625,12 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
MakerList = x.MakerList,
}).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 };
return result;
}
@ -710,13 +716,6 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
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

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