按票统计

usertest
嵇文龙 5 months ago
parent c64e8a993d
commit d7951e7095

@ -1,5 +1,4 @@
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Runtime.Serialization;
using DS.Module.Core;
using DS.Module.Core.Enums;
using DS.WMS.Core.Op.Entity;
@ -500,4 +499,236 @@ namespace DS.WMS.Core.Fee.Dtos
}
}
}
/// <summary>
/// 按票统计
/// </summary>
public class BizFeeStat
{
/// <summary>
/// 应收款总计
/// </summary>
public decimal ReceivableTotal { get; set; }
/// <summary>
/// 应付款总计
/// </summary>
public decimal PayableTotal { get; set; }
/// <summary>
/// 利润总计
/// </summary>
public decimal ProfitTotal { get { return ReceivableTotal - PayableTotal; } }
/// <summary>
/// 利润率
/// </summary>
public string ProfitMargin
{
get
{
if (PayableTotal == 0)
return string.Empty;
//利润率=利润÷成本×100%
return string.Concat(Math.Round(ReceivableTotal / PayableTotal * 100, 2, MidpointRounding.AwayFromZero), "%");
}
}
/// <summary>
/// 人民币应收款
/// </summary>
public decimal ReceivableCNY { get; set; }
/// <summary>
/// 人民币应付款
/// </summary>
public decimal PayableCNY { get; set; }
/// <summary>
/// 人民币利润
/// </summary>
public decimal ProfitCNY { get { return ReceivableCNY - PayableCNY; } }
/// <summary>
/// 美元应收款
/// </summary>
public decimal ReceivableUSD { get; set; }
/// <summary>
/// 美元应付款
/// </summary>
public decimal PayableUSD { get; set; }
/// <summary>
/// 美元利润
/// </summary>
public decimal ProfitUSD { get { return ReceivableUSD - PayableUSD; } }
/// <summary>
/// 其他币种应收款
/// </summary>
public decimal ReceivableOther { get; set; }
/// <summary>
/// 其他币种应付款
/// </summary>
public decimal PayableOther { get; set; }
/// <summary>
/// 其他币种利润
/// </summary>
public decimal ProfitOther { get { return ReceivableOther - PayableOther; } }
/// <summary>
/// 退舱
/// </summary>
public string? CancelCabin { get; set; }
/// <summary>
/// 签单方式
/// </summary>
public string? IssueType { get; set; }
/// <summary>
/// 报关日期
/// </summary>
public DateTime? CustomsDate { get; set; }
/// <summary>
/// 预抵日期
/// </summary>
public DateTime? ETA { get; set; }
/// <summary>
/// 装货港
/// </summary>
public string? LoadPort { get; set; }
// <summary>
/// 卸货港
/// </summary>
public string? DischargePort { get; set; }
/// <summary>
/// 目的地
/// </summary>
public string? Destination { get; set; }
/// <summary>
/// 场站
/// </summary>
public string? Yard { get; set; }
/// <summary>
/// 业务来源明细
/// </summary>
public string? SourceDetailName { get; set; }
/// <summary>
/// 箱TEU
/// </summary>
public int TEU { get; set; }
/// <summary>
/// 品名
/// </summary>
public string? GoodsName { get; set; }
/// <summary>
/// 国外代理
/// </summary>
public string? Agent { get; set; }
/// <summary>
/// 操作员代码
/// </summary>
public long? OperatorId { get; set; }
/// <summary>
/// 主提单号
/// </summary>
public string? MBLNO { get; set; }
/// <summary>
/// 分提单号
/// </summary>
public string? HBLNO { get; set; }
/// <summary>
/// 委托编号
/// </summary>
public string? CustomerNo { get; set; }
/// <summary>
/// 费用对象ID
/// </summary>
public long? CustomerId { get; set; }
/// <summary>
/// 委托单位名称
/// </summary>
public string? CustomerName { get; set; }
/// <summary>
/// 业务锁定
/// </summary>
public bool? IsBusinessLocking { get; set; }
/// <summary>
/// 费用锁定
/// </summary>
public bool? IsFeeLocking { get; set; }
/// <summary>
/// 开船日期
/// </summary>
public DateTime? ETD { get; set; }
/// <summary>
/// 业务来源
/// </summary>
public string? SourceName { get; set; }
/// <summary>
/// 集装箱
/// </summary>
public string? CntrTotal { get; set; }
/// <summary>
/// 会计期间
/// </summary>
public string? AccountDate { get; set; }
/// <summary>
/// 操作
/// </summary>
public string? Operator { get; set; }
/// <summary>
/// 船名
/// </summary>
public string? Vessel { get; set; }
/// <summary>
/// 航次
/// </summary>
public string? Voyage { get; set; }
/// <summary>
/// 船公司
/// </summary>
public string? Carrier { get; set; }
/// <summary>
/// 订舱代理
/// </summary>
public string? Forwarder { get; set; }
/// <summary>
/// 订舱编号
/// </summary>
public string? BookingNo { get; set; }
}
}

@ -26,6 +26,14 @@ namespace DS.WMS.Core.Fee.Interface
/// <returns></returns>
Task<DataResult<FeeBiz>> GetFeeBizAsync(long id, BusinessType businessType, long customerId);
/// <summary>
/// 获取按票统计
/// </summary>
/// <param name="id">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <returns></returns>
Task<DataResult<BizFeeStat>> GetStatAsync(long id, BusinessType businessType);
/// <summary>
/// 一键审核当前登录用户的所有待审核项
/// </summary>

@ -1,5 +1,6 @@
using DS.Module.Core;
using DS.Module.Core.Enums;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface;
@ -7,6 +8,7 @@ using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Flow.Entity;
using DS.WMS.Core.Flow.Interface;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Entity;
using Microsoft.Extensions.DependencyInjection;
namespace DS.WMS.Core.Fee.Method
@ -149,6 +151,89 @@ namespace DS.WMS.Core.Fee.Method
return DataResult<FeeBiz>.Success(model);
}
/// <summary>
/// 获取按票统计
/// </summary>
/// <param name="id">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <returns></returns>
public async Task<DataResult<BizFeeStat>> GetStatAsync(long id, BusinessType businessType)
{
BizFeeStat? stat = null;
switch (businessType)
{
case BusinessType.OceanShippingExport:
stat = await TenantDb.Queryable<BusinessFeeStatus>()
.InnerJoin<SeaExport>((b, s) => b.BusinessId == s.Id)
.LeftJoin<CodeSource>((b, s, cs) => s.SourceId == cs.Id)
.LeftJoin<CodeSourceDetail>((b, s, cs, csd) => s.SourceDetailId == csd.Id)
.Select((b, s, cs, csd) => new BizFeeStat
{
IsBusinessLocking = b.IsBusinessLocking,
IsFeeLocking = b.IsFeeLocking,
HBLNO = s.HBLNO,
MBLNO = s.MBLNO,
CustomerNo = s.CustomerNo,
CustomerName = s.CustomerName,
ETD = s.ETD,
ETA = s.ETA,
CntrTotal = s.CntrTotal,
AccountDate = s.AccountDate,
OperatorId = s.OperatorId,
Vessel = s.Vessel,
Voyage = s.Voyno,
Carrier = s.Carrier,
Forwarder = s.Forwarder,
BookingNo = s.BookingNo,
CustomsDate = s.CustomDate,
LoadPort = s.LoadPort,
DischargePort = s.DischargePort,
Destination = s.Destination,
Yard = s.Yard,
Agent = s.Agent,
TEU = s.TEU,
GoodsName = s.GoodsName,
IssueType = s.IssueType,
SourceName = cs.SourceName,
SourceDetailName = csd.DetailName
}).FirstAsync();
break;
case BusinessType.OceanShippingImport:
break;
}
if (stat == null)
return DataResult<BizFeeStat>.Success(stat);
var fees = await TenantDb.Queryable<FeeRecord>().Where(f =>
f.BusinessId == id && f.BusinessType == businessType && f.FeeStatus == FeeStatus.AuditPassed)
.Select(x => new
{
x.FeeType,
x.Currency,
x.Amount
}).ToListAsync();
stat.ReceivableTotal = fees.FindAll(x => x.FeeType == FeeType.Receivable).Sum(x => x.Amount).GetValueOrDefault();
stat.ReceivableCNY = fees.FindAll(x => x.FeeType == FeeType.Receivable && x.Currency == RMB_CODE).Sum(x => x.Amount).GetValueOrDefault();
stat.ReceivableUSD = fees.FindAll(x => x.FeeType == FeeType.Receivable && x.Currency == USD_CODE).Sum(x => x.Amount).GetValueOrDefault();
stat.ReceivableOther = fees.FindAll(x => x.FeeType == FeeType.Receivable && (x.Currency != USD_CODE && x.Currency != RMB_CODE)).Sum(x => x.Amount).GetValueOrDefault();
stat.PayableTotal = fees.FindAll(x => x.FeeType == FeeType.Payable).Sum(x => x.Amount).GetValueOrDefault();
stat.PayableCNY = fees.FindAll(x => x.FeeType == FeeType.Payable && x.Currency == RMB_CODE).Sum(x => x.Amount).GetValueOrDefault();
stat.PayableUSD = fees.FindAll(x => x.FeeType == FeeType.Payable && x.Currency == USD_CODE).Sum(x => x.Amount).GetValueOrDefault();
stat.PayableOther = fees.FindAll(x => x.FeeType == FeeType.Payable && (x.Currency != USD_CODE && x.Currency != RMB_CODE)).Sum(x => x.Amount).GetValueOrDefault();
long?[] usersId = [stat.OperatorId];
if (Array.Exists(usersId, x => x.HasValue))
{
var users = await Db.Queryable<SysUser>().Where(x => usersId.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
stat.Operator = users.Find(x => x.Id == stat.OperatorId)?.UserName;
}
return DataResult<BizFeeStat>.Success(stat);
}
/// <summary>
/// 一键审核当前登录用户的所有待审核项
/// </summary>

@ -16,9 +16,19 @@ namespace DS.WMS.Core.Fee.Method
public abstract class FeeServiceBase
{
/// <summary>
/// //默认本币
/// 默认本币
/// </summary>
protected const string DefaultCurrency = "CNY";
public const string DefaultCurrency = "CNY";
/// <summary>
/// 人民币代码
/// </summary>
public const string RMB_CODE = "CNY";
/// <summary>
/// 美元代码
/// </summary>
public const string USD_CODE = "USD";
/// <summary>
/// 工作流运行状态值

@ -1,4 +1,5 @@
using DS.Module.Core;
using Castle.Core.Resource;
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Interface;
@ -43,11 +44,23 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="customerId">结算对象ID</param>
/// <returns></returns>
[HttpGet, Route("GetFeeBiz")]
public async Task<DataResult<FeeBiz>> GetFeeBizAsync(long id, BusinessType businessType, long customerId)
public async Task<DataResult<FeeBiz>> GetFeeBizAsync([FromQuery] long id, [FromQuery] BusinessType businessType, [FromQuery] long customerId)
{
return await _auditService.GetFeeBizAsync(id, businessType, customerId);
}
/// <summary>
/// 获取按票统计
/// </summary>
/// <param name="id">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <returns></returns>
[HttpGet, Route("GetStat")]
public async Task<DataResult<BizFeeStat>> GetStatAsync([FromQuery] long id, [FromQuery] BusinessType businessType)
{
return await _auditService.GetStatAsync(id, businessType);
}
/// <summary>
/// 按申请单审核
/// </summary>

@ -1349,3 +1349,17 @@
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.
2024-06-18 14:44:02.2634 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-06-18 14:44:02.3405 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-06-18 14:44:02.3526 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-06-18 14:44:02.3776 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-18 14:44:02.3942 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-18 14:44:02.4029 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-06-18 14:44:02.4127 Info Configuration initialized.
2024-06-18 14:50:39.0690 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-06-18 14:50:39.2056 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-06-18 14:50:39.2214 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-06-18 14:50:39.2800 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-18 14:50:39.2948 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-18 14:50:39.2948 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-06-18 14:50:39.3179 Info Configuration initialized.

@ -6,7 +6,7 @@
<Project>
<PropertyGroup>
<_PublishTargetUrl>D:\Code\PublishCopy\ds8-mainapi</_PublishTargetUrl>
<History>True|2024-06-18T00:55:07.3014083Z||;True|2024-06-18T08:40:51.6182342+08:00||;True|2024-06-13T19:48:34.0429148+08:00||;True|2024-06-13T19:09:39.6804400+08:00||;True|2024-06-13T15:41:56.9502735+08:00||;True|2024-06-13T15:23:59.4555910+08:00||;True|2024-06-13T15:12:55.6093356+08:00||;True|2024-06-11T17:08:01.8930314+08:00||;True|2024-06-07T15:23:11.1389680+08:00||;True|2024-06-07T10:23:59.6079620+08:00||;True|2024-06-06T17:42:56.1843783+08:00||;True|2024-06-04T14:20:46.7742295+08:00||;True|2024-05-31T17:57:35.6858600+08:00||;True|2024-05-31T15:25:20.8503086+08:00||;True|2024-05-30T17:22:52.2563382+08:00||;True|2024-05-30T17:05:35.7504154+08:00||;True|2024-05-29T17:17:39.6966826+08:00||;</History>
<History>True|2024-06-18T02:09:37.3872162Z||;True|2024-06-18T10:00:43.4402179+08:00||;True|2024-06-18T08:55:07.3014083+08:00||;True|2024-06-18T08:40:51.6182342+08:00||;True|2024-06-13T19:48:34.0429148+08:00||;True|2024-06-13T19:09:39.6804400+08:00||;True|2024-06-13T15:41:56.9502735+08:00||;True|2024-06-13T15:23:59.4555910+08:00||;True|2024-06-13T15:12:55.6093356+08:00||;True|2024-06-11T17:08:01.8930314+08:00||;True|2024-06-07T15:23:11.1389680+08:00||;True|2024-06-07T10:23:59.6079620+08:00||;True|2024-06-06T17:42:56.1843783+08:00||;True|2024-06-04T14:20:46.7742295+08:00||;True|2024-05-31T17:57:35.6858600+08:00||;True|2024-05-31T15:25:20.8503086+08:00||;True|2024-05-30T17:22:52.2563382+08:00||;True|2024-05-30T17:05:35.7504154+08:00||;True|2024-05-29T17:17:39.6966826+08:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
Loading…
Cancel
Save