获取业务费用统计

usertest
嵇文龙 5 months ago
parent 6ca2e89b86
commit 8158a88dcf

@ -186,7 +186,7 @@ namespace DS.WMS.Core.Fee.Dtos
/// <summary>
/// 审核状态(仅查询用)
/// </summary>
public AuditStatusForQuery? AuditStatus { get; set; }
}
@ -216,13 +216,11 @@ namespace DS.WMS.Core.Fee.Dtos
/// <summary>
/// 业务类型
/// </summary>
[IgnoreDataMember]
public long BusinessId { get; set; }
/// <summary>
/// 业务类型
/// </summary>
[IgnoreDataMember]
public BusinessType BusinessType { get; set; }
/// <summary>
@ -241,7 +239,12 @@ namespace DS.WMS.Core.Fee.Dtos
public string? CustomerNo { get; set; }
/// <summary>
/// 委托单位
/// 费用对象ID
/// </summary>
public long? CustomerId { get; set; }
/// <summary>
/// 委托单位名称
/// </summary>
public string? CustomerName { get; set; }
@ -397,6 +400,8 @@ namespace DS.WMS.Core.Fee.Dtos
/// <param name="details">申请单明细</param>
public FeeApplicationSummary(List<FeeApplicationDetailDto> details)
{
ArgumentNullException.ThrowIfNull(details);
Details = details;
SummaryItems = details.GroupBy(x => new { x.FeeType, x.OriginalCurrency }).Select(x => new SummaryItem
{
@ -408,6 +413,22 @@ namespace DS.WMS.Core.Fee.Dtos
}
}
/// <summary>
/// 按业务统计费用
/// </summary>
public class FeeBiz
{
/// <summary>
/// 当前结算对象的全局应收总额
/// </summary>
public decimal ReceivableTotal { get; set; }
/// <summary>
/// 费用合计
/// </summary>
public List<TotalItem> TotalItems { get; set; }
}
/// <summary>
/// 申请单费用汇总
/// </summary>
@ -437,8 +458,46 @@ namespace DS.WMS.Core.Fee.Dtos
/// <summary>
/// 申请单费用合计项
/// </summary>
public class TotalItem
public class TotalItem
{
/// <summary>
/// 币别
/// </summary>
public string Currency { get; set; }
/// <summary>
/// 应收款
/// </summary>
public decimal ReceivableAmount { get; set; }
/// <summary>
/// 未收
/// </summary>
public decimal RestAmount { get; set; }
/// <summary>
/// 应付款
/// </summary>
public decimal PayableAmount { get; set; }
/// <summary>
/// 利润
/// </summary>
public decimal Profit { get { return ReceivableAmount - PayableAmount; } }
/// <summary>
/// 利润率
/// </summary>
public string ProfitMargin
{
get
{
if (PayableAmount == 0)
return string.Empty;
//利润率=利润÷成本×100%
return string.Concat((ReceivableAmount / PayableAmount) * 100, "%");
}
}
}
}

@ -1,6 +1,7 @@
using DS.Module.Core;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Op.Entity;
namespace DS.WMS.Core.Fee.Interface
{
@ -16,6 +17,15 @@ namespace DS.WMS.Core.Fee.Interface
/// <returns></returns>
Task<DataResult<FeeApplicationSummary>> GetDetailsAsync(long id);
/// <summary>
/// 获取业务费用统计
/// </summary>
/// <param name="id">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="customerId">结算对象ID</param>
/// <returns></returns>
Task<DataResult<FeeBiz>> GetFeeBizAsync(long id, BusinessType businessType, long customerId);
/// <summary>
/// 一键审核当前登录用户的所有待审核项
/// </summary>

@ -43,6 +43,7 @@ namespace DS.WMS.Core.Fee.Method
{
AccTaxRate = f.AccTaxRate,
Amount = d.Amount,
CustomerId = f.CustomerId,
FeeName = d.FeeName,
FeeType = f.FeeType,
FeeObject = f.CustomerName,
@ -108,7 +109,42 @@ namespace DS.WMS.Core.Fee.Method
}
}
return DataResult<FeeApplicationSummary>.Success(new FeeApplicationSummary(details));
var model = new FeeApplicationSummary(details);
var customerId = details.GroupBy(x => x.CustomerId).Select(x => x.Key).FirstOrDefault();
return DataResult<FeeApplicationSummary>.Success(model);
}
/// <summary>
/// 获取业务费用统计
/// </summary>
/// <param name="id">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="customerId">结算对象ID</param>
/// <returns></returns>
public async Task<DataResult<FeeBiz>> GetFeeBizAsync(long id, BusinessType businessType, long customerId)
{
FeeBiz model = new FeeBiz();
model.ReceivableTotal = (await TenantDb.Queryable<FeeRecord>().Where(x => x.CustomerId == customerId
&& x.FeeType == FeeType.Receivable && x.FeeStatus == FeeStatus.AuditPassed).SumAsync(x => x.Amount)).GetValueOrDefault();
var fees = await TenantDb.Queryable<FeeRecord>().Where(x =>
x.BusinessId == id && x.BusinessType == businessType && x.FeeStatus == FeeStatus.AuditPassed)
.Select(x => new
{
x.Currency,
x.FeeType,
x.Amount,
}).ToListAsync();
model.TotalItems = fees.GroupBy(x => x.Currency).Select(x => new TotalItem
{
Currency = x.Key,
PayableAmount = x.Where(y => y.FeeType == FeeType.Payable && y.Currency == x.Key).Sum(y => y.Amount).GetValueOrDefault(),
ReceivableAmount = x.Where(y => y.FeeType == FeeType.Receivable && y.Currency == x.Key).Sum(y => y.Amount).GetValueOrDefault(),
RestAmount = 0 //未收
}).ToList();
return DataResult<FeeBiz>.Success(model);
}
/// <summary>
@ -229,9 +265,14 @@ namespace DS.WMS.Core.Fee.Method
Id = x.Id,
Status = x.Status
}).FirstAsync();
if (app == null)
{
await new ApplicationException($"未能获取ID={callback.BusinessId}的申请单,回调更新失败").LogAsync(Db);
return DataResult.Failed("无法获取申请单信息,回调更新失败");
}
var auditType = callback.AuditType.ToEnum<AuditType>();
long UserId = long.Parse(User.UserId);
long userId = long.Parse(User.UserId);
DateTime dtNow = DateTime.Now;
await TenantDb.Ado.BeginTranAsync();
try
@ -239,7 +280,7 @@ namespace DS.WMS.Core.Fee.Method
switch (auditType)
{
case AuditType.PaidApplication:
app.AuditerId = UserId;
app.AuditerId = userId;
app.AuditerName = User.UserName;
app.AuditTime = dtNow;
app.Reason = callback.RejectReason;

@ -69,5 +69,5 @@ public interface IClientFlowInstanceService
/// <returns></returns>
DataResult<List<FlowInstanceHistoryRes>> GetFlowInstanceHistoryList(string id);
DataResult<FlowInstanceRes> GetFlowInstance(long businessId, BusinessType businessType, string type);
DataResult<FlowInstanceRes> GetFlowInstance(long businessId, BusinessType? businessType, string type);
}

@ -78,10 +78,13 @@ public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanc
/// <param name="businessType">业务类型</param>
/// <param name="type">模板类型</param>
/// <returns></returns>
public DataResult<FlowInstanceRes> GetFlowInstance(long businessId, BusinessType businessType, string type)
public DataResult<FlowInstanceRes> GetFlowInstance(long businessId, BusinessType? businessType, string type)
{
var entity = db.Queryable<FlowInstance>().Where(x => x.BusinessId == businessId && x.BusinessType == businessType && x.AuditType == type)
.OrderByDescending(x => x.CreateTime).First();
var query = db.Queryable<FlowInstance>().Where(x => x.BusinessId == businessId && x.BusinessType == businessType && x.AuditType == type);
if (businessType.HasValue)
query = query.Where(x => x.BusinessType == businessType.Value);
var entity = query.OrderByDescending(x => x.CreateTime).Take(1).First();
var result = entity == null ? null : entity.Adapt<FlowInstanceRes>();
return DataResult<FlowInstanceRes>.Success(result);
}

@ -3,6 +3,7 @@ using DS.Module.Core.Data;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Op.Entity;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.FeeApi.Controllers
@ -29,11 +30,24 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="id">申请单ID</param>
/// <returns></returns>
[HttpGet, Route("GetDetails")]
public async Task<DataResult<FeeApplicationSummary>> GetDetailsAsync([FromQuery] long id)
public async Task<DataResult<FeeApplicationSummary>> GetDetailsAsync([FromQuery] long id)
{
return await _auditService.GetDetailsAsync(id);
}
/// <summary>
/// 获取业务费用统计
/// </summary>
/// <param name="id">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="customerId">结算对象ID</param>
/// <returns></returns>
[HttpGet, Route("GetFeeBiz")]
public async Task<DataResult<FeeBiz>> GetFeeBizAsync(long id, BusinessType businessType, long customerId)
{
return await _auditService.GetFeeBizAsync(id, businessType, customerId);
}
/// <summary>
/// 按申请单审核
/// </summary>
@ -68,7 +82,8 @@ namespace DS.WMS.FeeApi.Controllers
/// </summary>
/// <param name="model">申请单ID</param>
/// <returns></returns>
public async Task<DataResult> SetUnPrinted(IdModel model)
[HttpPost, Route("SetUnPrinted")]
public async Task<DataResult> SetUnPrinted(IdModel model)
{
if (model.Ids == null || model.Ids.Length == 0)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);

@ -1314,3 +1314,38 @@
2024-06-17 09:17:55.3526 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config
2024-06-17 09:17:55.3734 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-06-17 09:17:55.3869 Info Configuration initialized.
2024-06-17 11:45:46.9677 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-06-17 11:45:47.0041 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-06-17 11:45:47.0041 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-06-17 11:45:47.0204 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-06-17 11:45:47.0204 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config
2024-06-17 11:45:47.0204 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-06-17 11:45:47.0356 Info Configuration initialized.
2024-06-17 11:46:28.1701 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-06-17 11:46:28.2017 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-06-17 11:46:28.2082 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-06-17 11:46:28.2222 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-06-17 11:46:28.2222 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config
2024-06-17 11:46:28.2222 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-06-17 11:46:28.2222 Info Configuration initialized.
2024-06-17 14:02:24.6961 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-06-17 14:02:24.7542 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-06-17 14:02:24.7542 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-06-17 14:02:24.7798 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-06-17 14:02:24.7798 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config
2024-06-17 14:02:24.7798 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-06-17 14:02:24.8038 Info Configuration initialized.
2024-06-17 15:29:00.7025 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-06-17 15:29:00.7530 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-06-17 15:29:00.7719 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-06-17 15:29:00.7897 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-06-17 15:29:00.7897 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config
2024-06-17 15:29:00.8052 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-06-17 15:29:00.8052 Info Configuration initialized.
2024-06-17 17:07:13.8040 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-06-17 17:07:13.8384 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-06-17 17:07:13.8492 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-06-17 17:07:13.9152 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-06-17 17:07:13.9261 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config
2024-06-17 17:07:13.9261 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-06-17 17:07:13.9464 Info Configuration initialized.

@ -118,11 +118,11 @@ public class ClientFlowInstanceController : ApiController
/// 获取流程运行实例的内容
/// </summary>
/// <param name="businessId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <param name="businessType">业务类型(可空)</param>
/// <param name="type">流程类型</param>
/// <returns></returns>
[HttpGet, Route("GetFlowContent")]
public DataResult<string> GetFlowContent([FromQuery] long businessId, [FromQuery] BusinessType businessType, [FromQuery] AuditType type)
public DataResult<string> GetFlowContent([FromQuery] long businessId, [FromQuery] BusinessType? businessType, [FromQuery] AuditType type)
{
var res = _invokeService.GetFlowInstance(businessId, businessType, type.ToString());
string? content = res.Data?.Content;

Loading…
Cancel
Save