|
@@ -7,11 +7,14 @@ using System.Threading.Tasks;
|
|
|
using XYY.Core.Standard.Data.Infrastructure;
|
|
|
using Dapper;
|
|
|
using SMP.Model.Enums;
|
|
|
+using SMP.Model.Report;
|
|
|
|
|
|
namespace SMP.Data.Finance
|
|
|
{
|
|
|
public interface IFinance_Logistics_LadingBillRepository : IBaseRepository<Finance_Logistics_LadingBill>
|
|
|
{
|
|
|
+ [NonTrans]
|
|
|
+ Task<IEnumerable<int>> GetPublics(int month);
|
|
|
[NonTrans]
|
|
|
Task<IEnumerable<Finance_Logistics_LadingBill>> GetPortLadingBillsByNumbers(List<string> LadingBillNumbers);
|
|
|
Task<Finance_Logistics_LadingBill> GetLadingBill(string LadingBillNumber);
|
|
@@ -30,6 +33,7 @@ namespace SMP.Data.Finance
|
|
|
Task ClearIncidentals(int LadingBillId, AmountType amountType = AmountType.应付);
|
|
|
|
|
|
Task<IEnumerable<Finance_Logistics_LadingBill>> QueryByLadingBillNumbers(IEnumerable<string> ladingBillNumbers);
|
|
|
+ Task<IEnumerable<LadingBillCost>> GetLadingBillCost(int month, int publicId);
|
|
|
#endregion
|
|
|
#region 订单成本(作废)
|
|
|
//Task CreateCostTable(string BillTypeCode);
|
|
@@ -57,18 +61,18 @@ where rowNum=1 ");
|
|
|
}
|
|
|
public async Task<Finance_Logistics_LadingBill> GetLadingBill(string LadingBillNumber)
|
|
|
{
|
|
|
- var result =await QueryAsync(x=>x.LadingBillNumber==LadingBillNumber);
|
|
|
+ var result = await QueryAsync(x => x.LadingBillNumber == LadingBillNumber);
|
|
|
return result.FirstOrDefault();
|
|
|
}
|
|
|
#region 帐单费项
|
|
|
public async Task<IEnumerable<Finance_Incidental>> GetIncidentals(int LadingBillId, AmountType amountType = AmountType.应付)
|
|
|
{
|
|
|
string amtTypeCondition = null;
|
|
|
- if(amountType==AmountType.应付)
|
|
|
+ if (amountType == AmountType.应付)
|
|
|
{
|
|
|
amtTypeCondition = " and (AmountType is null or AmountType=0) ";
|
|
|
}
|
|
|
- else
|
|
|
+ else
|
|
|
{
|
|
|
var amtType = (int)amountType;
|
|
|
amtTypeCondition = $" and AmountType={amtType} ";
|
|
@@ -76,7 +80,7 @@ where rowNum=1 ");
|
|
|
string sql = $"select * from Finance_Incidental(nolock) where LadingBillId={LadingBillId} {amtTypeCondition} and IsDeleted=0 ";
|
|
|
return await _unitOfWork.QueryBySqlAsync<Finance_Incidental>(sql);
|
|
|
}
|
|
|
- public async Task ClearIncidentals(int LadingBillId,AmountType amountType=AmountType.应付)
|
|
|
+ public async Task ClearIncidentals(int LadingBillId, AmountType amountType = AmountType.应付)
|
|
|
{
|
|
|
string amtTypeCondition = null;
|
|
|
if (amountType == AmountType.应付)
|
|
@@ -99,6 +103,49 @@ where rowNum=1 ");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ public async Task<IEnumerable<int>> GetPublics(int month)
|
|
|
+ {
|
|
|
+ DateTime start = new DateTime(DateTime.Now.Year, month, 1);
|
|
|
+ DateTime end = start.AddMonths(1);
|
|
|
+ string sql = @"
|
|
|
+ select PublicChannelId ,count(0)
|
|
|
+ from Logistisc_Order(nolock) where ReceiveTime between @start and @end
|
|
|
+ group by PublicChannelId";
|
|
|
+
|
|
|
+ var result = await _unitOfWork.Connection.QueryAsync<int>(sql, new { start, end }, _unitOfWork.Transaction);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ [NonTrans]
|
|
|
+ public async Task<IEnumerable<LadingBillCost>> GetLadingBillCost(int month,int publicId)
|
|
|
+ {
|
|
|
+ DateTime start = new DateTime(DateTime.Now.Year, month, 1);
|
|
|
+ DateTime end = start.AddMonths(1);
|
|
|
+ string sql = @" with t1 as(
|
|
|
+ select b.LadingBillNumber,f.Name,sum(c.SettlementAmount)SettlementAmount,CONVERT(nvarchar(7),ReceiveTime,120 ) as [Month] from
|
|
|
+ (select LadingBillNumber
|
|
|
+ from Logistisc_Order(nolock) where PublicChannelId = @publicId and ReceiveTime between @start and @end
|
|
|
+ group by LadingBillNumber)as a
|
|
|
+ join Logistisc_Order(nolock)b on PublicChannelId =@publicId and a.LadingBillNumber=b.LadingBillNumber
|
|
|
+ join Compute_ExpenseAmount(nolock)c on c.Number = b.SystemNo and c.CostType=1
|
|
|
+ join Compute_ExpenseAmountBatchOperation(nolock) d on d.BatchNo = c.BatchNo
|
|
|
+ join Compute_ExpenseItem(nolock)e on c.ExpenseItemId=e.Id
|
|
|
+ join Compute_ExpenseItemCategory(nolock)f on f.Id=e.CategoryId
|
|
|
+ group by b.LadingBillNumber,f.Name,CONVERT(nvarchar(7),ReceiveTime,120 ))
|
|
|
+
|
|
|
+ select * from (
|
|
|
+ select 提单=LadingBillNumber,类目=Name,费用=SettlementAmount,月份=[MONTH] from t1
|
|
|
+ )a
|
|
|
+ pivot
|
|
|
+ (
|
|
|
+ sum(a.费用) for a.类目 in(空运成本,尾程派送费,海外清关,出口报关,全程派送费用,中转成本)
|
|
|
+ )p
|
|
|
+ order by 提单,月份
|
|
|
+ ";
|
|
|
+ var result = await _unitOfWork.Connection.QueryAsync<LadingBillCost>(sql, new { start, end, publicId }, _unitOfWork.Transaction, null);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
#region 订单成本(作废)
|
|
|
//public async Task CreateCostTable(string tableName)
|