|
|
@ -1,4 +1,5 @@
|
|
|
|
using DS.Module.Core;
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
using DS.Module.Core.Enums;
|
|
|
|
using DS.Module.Core.Enums;
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
@ -9,6 +10,8 @@ using DS.WMS.Core.Flow.Entity;
|
|
|
|
using DS.WMS.Core.Flow.Interface;
|
|
|
|
using DS.WMS.Core.Flow.Interface;
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
|
|
|
|
using DS.WMS.Core.Sys.Interface;
|
|
|
|
|
|
|
|
using LanguageExt.Common;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using SqlSugar;
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
|
@ -20,6 +23,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
public class FeeApplicationService : FeeServiceBase, IFeeApplicationService
|
|
|
|
public class FeeApplicationService : FeeServiceBase, IFeeApplicationService
|
|
|
|
{
|
|
|
|
{
|
|
|
|
readonly IClientFlowInstanceService flowService;
|
|
|
|
readonly IClientFlowInstanceService flowService;
|
|
|
|
|
|
|
|
readonly ICommonService commonService;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 初始化
|
|
|
|
/// 初始化
|
|
|
@ -28,6 +32,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
public FeeApplicationService(IServiceProvider serviceProvider) : base(serviceProvider)
|
|
|
|
public FeeApplicationService(IServiceProvider serviceProvider) : base(serviceProvider)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
flowService = serviceProvider.GetRequiredService<IClientFlowInstanceService>();
|
|
|
|
flowService = serviceProvider.GetRequiredService<IClientFlowInstanceService>();
|
|
|
|
|
|
|
|
commonService = serviceProvider.GetRequiredService<ICommonService>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -125,6 +130,46 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
return TenantDb.UnionAll(new List<ISugarQueryable<FeeApplicationBiz>> { query1 });
|
|
|
|
return TenantDb.UnionAll(new List<ISugarQueryable<FeeApplicationBiz>> { query1 });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 根据业务编号及类型获取关联费用记录
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="id">业务ID</param>
|
|
|
|
|
|
|
|
/// <param name="businessType">业务类型</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public async Task<DataResult<List<FeeRecordDto>>> GetFeesAsync(long id, BusinessType businessType)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var list = await TenantDb.Queryable<FeeRecord>()
|
|
|
|
|
|
|
|
.Where(f => f.BusinessId == id && f.BusinessType == businessType && f.FeeStatus == FeeStatus.AuditPassed)
|
|
|
|
|
|
|
|
.Select(f => new FeeRecordDto
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Id = f.Id,
|
|
|
|
|
|
|
|
FeeName = f.FeeName,
|
|
|
|
|
|
|
|
FeeType = f.FeeType,
|
|
|
|
|
|
|
|
Amount = f.Amount,
|
|
|
|
|
|
|
|
Currency = f.Currency,
|
|
|
|
|
|
|
|
OriginalRate = f.ExchangeRate,
|
|
|
|
|
|
|
|
RestAmount = f.Amount - f.SettlementAmount - f.OrderAmount + f.OrderSettlementAmount,
|
|
|
|
|
|
|
|
InvoiceAmount = f.InvoiceAmount,
|
|
|
|
|
|
|
|
Remark = f.Remark,
|
|
|
|
|
|
|
|
CreateBy = f.CreateBy
|
|
|
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
list.RemoveAll(f => f.RestAmount == 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//关联用户名称
|
|
|
|
|
|
|
|
var userIds = list.Select(x => x.CreateBy).Distinct();
|
|
|
|
|
|
|
|
var users = await Db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
|
|
|
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
item.CreateByName = users.Find(x => x.Id == item.CreateBy)?.UserName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return DataResult<List<FeeRecordDto>>.Success(list);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 获取分页列表
|
|
|
|
/// 获取分页列表
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -149,25 +194,171 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 提交保存申请单
|
|
|
|
/// 获取申请单详情
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="id">申请单ID</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public async Task<DataResult<FeeApplicationDto>> GetAsync(long id)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var dto = await TenantDb.Queryable<FeeApplication>().Where(x => x.Id == id).Select<FeeApplicationDto>().FirstAsync();
|
|
|
|
|
|
|
|
if (dto != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dto.Details = await TenantDb.Queryable<FeeApplicationDetail>()
|
|
|
|
|
|
|
|
.LeftJoin<FeeRecord>((d, f) => d.RecordId == f.Id)
|
|
|
|
|
|
|
|
.LeftJoin<BusinessFeeStatus>((d, f, b) => f.BusinessId == b.BusinessId && f.BusinessType == b.BusinessType)
|
|
|
|
|
|
|
|
.Where(d => d.ApplicationId == id)
|
|
|
|
|
|
|
|
.Select((d, f, b) => new FeeApplicationDetailDto
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
AccTaxRate = f.AccTaxRate,
|
|
|
|
|
|
|
|
Amount = d.Amount,
|
|
|
|
|
|
|
|
FeeName = d.FeeName,
|
|
|
|
|
|
|
|
FeeType = f.FeeType,
|
|
|
|
|
|
|
|
FeeObject = f.CustomerName,
|
|
|
|
|
|
|
|
OriginalCurrency = d.OriginalCurrency,
|
|
|
|
|
|
|
|
OriginalRate = f.ExchangeRate,
|
|
|
|
|
|
|
|
ExchangeRate = d.ExchangeRate,
|
|
|
|
|
|
|
|
OriginalAmount = d.OriginalAmount,
|
|
|
|
|
|
|
|
BusinessId = b.BusinessId,
|
|
|
|
|
|
|
|
BusinessType = b.BusinessType,
|
|
|
|
|
|
|
|
IsBusinessLocking = b.IsBusinessLocking,
|
|
|
|
|
|
|
|
IsFeeLocking = b.IsFeeLocking
|
|
|
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var gList = dto.Details.GroupBy(x => x.BusinessType).ToList();
|
|
|
|
|
|
|
|
foreach (var g in gList)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (g.Key)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case BusinessType.OceanShippingExport:
|
|
|
|
|
|
|
|
var ids = g.Select(x => x.BusinessId).ToList();
|
|
|
|
|
|
|
|
var list1 = await TenantDb.Queryable<SeaExport>().Where(x => ids.Contains(x.Id)).Select(x => new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
x.Id,
|
|
|
|
|
|
|
|
x.MBLNO,
|
|
|
|
|
|
|
|
x.CustomerNo,
|
|
|
|
|
|
|
|
x.CustomerName,
|
|
|
|
|
|
|
|
x.ETD,
|
|
|
|
|
|
|
|
x.CntrTotal,
|
|
|
|
|
|
|
|
x.AccountDate,
|
|
|
|
|
|
|
|
x.OperatorCode,
|
|
|
|
|
|
|
|
x.Vessel,
|
|
|
|
|
|
|
|
x.Voyno,
|
|
|
|
|
|
|
|
x.Carrier,
|
|
|
|
|
|
|
|
x.Forwarder
|
|
|
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
foreach (var item in g)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var biz = list1.Find(x => x.Id == item.BusinessId);
|
|
|
|
|
|
|
|
if (biz != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
item.MBLNO = biz.MBLNO;
|
|
|
|
|
|
|
|
item.CustomerName = biz.CustomerName;
|
|
|
|
|
|
|
|
item.CustomerNo = biz.CustomerNo;
|
|
|
|
|
|
|
|
item.ETD = biz.ETD;
|
|
|
|
|
|
|
|
item.CntrTotal = biz.CntrTotal;
|
|
|
|
|
|
|
|
item.AccountDate = biz.AccountDate;
|
|
|
|
|
|
|
|
item.Operator = biz.OperatorCode;
|
|
|
|
|
|
|
|
item.Vessel = biz.Vessel;
|
|
|
|
|
|
|
|
item.Voyage = biz.Voyno;
|
|
|
|
|
|
|
|
item.Carrier = biz.Carrier;
|
|
|
|
|
|
|
|
item.Forwarder = biz.Forwarder;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case BusinessType.OceanShippingImport:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return DataResult<FeeApplicationDto>.Success(dto);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 提交保存费用申请单
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="application">申请单</param>
|
|
|
|
/// <param name="application">申请单</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task<DataResult> SaveAsync(FeeApplication application)
|
|
|
|
public async Task<DataResult> SaveAsync(FeeApplication application)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
application.Details ??= [];
|
|
|
|
if (application.Id > 0)
|
|
|
|
if (application.Id > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//修改需检查申请单状态
|
|
|
|
//修改需检查申请单状态
|
|
|
|
if (await TenantDb.Queryable<FeeApplication>().AnyAsync(x =>
|
|
|
|
var model = await TenantDb.Queryable<FeeApplication>().Where(x => x.Id == application.Id).Select(
|
|
|
|
x.Id == application.Id && (x.Status == ApplicationStatus.AuditSubmittd || x.Status == ApplicationStatus.AuditPassed)))
|
|
|
|
x => new { x.Status, x.Currency }).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (model.Status == ApplicationStatus.AuditSubmittd || model.Status == ApplicationStatus.AuditPassed)
|
|
|
|
return DataResult.Failed("只能修改状态为:未提交/审核驳回的申请单");
|
|
|
|
return DataResult.Failed("只能修改状态为:未提交/审核驳回的申请单");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (application.Details.Count > 0 && !string.Equals(model.Currency, application.Currency, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
|
|
return DataResult.Failed("提交币别需与原申请单币别一致");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<FeeRecord>? fees = null;
|
|
|
|
|
|
|
|
if (application.Details.Count > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (application.Details.GroupBy(x => x.CustomerName).Select(x => x.Key).Count() > 1)
|
|
|
|
|
|
|
|
return DataResult.Failed("申请单的结算对象有且只能有一个");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!application.Currency.IsNullOrEmpty() && application.Details.Any(x => x.Currency != application.Currency))
|
|
|
|
|
|
|
|
return DataResult.Failed($"申请单的所有明细币别必须为 {application.Currency}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//仅处理新增的明细
|
|
|
|
|
|
|
|
var ids = application.Details.FindAll(x => x.Id == 0).Select(x => x.RecordId).ToList();
|
|
|
|
|
|
|
|
fees = await TenantDb.Queryable<FeeRecord>().Where(x => ids.Contains(x.Id)).Select(x => new FeeRecord
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
|
|
|
Amount = x.Amount,
|
|
|
|
|
|
|
|
OrderAmount = x.OrderAmount,
|
|
|
|
|
|
|
|
OrderSettlementAmount = x.OrderSettlementAmount,
|
|
|
|
|
|
|
|
SettlementAmount = x.SettlementAmount
|
|
|
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new();
|
|
|
|
|
|
|
|
foreach (var detail in application.Details)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var fee = fees.Find(x => x.Id == detail.RecordId);
|
|
|
|
|
|
|
|
if (fee == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sb.Append($"未能关联明细【{detail.FeeName}】的费用信息;");
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//未申请金额=总金额-结算金额-申请金额+申请金额已结算
|
|
|
|
|
|
|
|
var restAmount = fee.Amount.GetValueOrDefault() - fee.SettlementAmount.GetValueOrDefault() - fee.OrderAmount.GetValueOrDefault() + fee.OrderSettlementAmount;
|
|
|
|
|
|
|
|
if (detail.OriginalAmount > 0 && detail.OriginalAmount > restAmount)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sb.Append($"申请单明细【{detail.FeeName}】的申请金额不能超出原费用的金额;");
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (detail.OriginalAmount < 0 && detail.OriginalAmount < restAmount)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sb.Append($"申请单明细【{detail.FeeName}】的申请金额不能超出原费用的金额;");
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//更新费用记录的已申请金额
|
|
|
|
|
|
|
|
fee.OrderAmount += detail.OriginalAmount;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
detail.Category = FeeCategory.PaidApplication;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sb.Length > 0)
|
|
|
|
|
|
|
|
return DataResult.Failed(sb.ToString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (application.Currency.IsNullOrEmpty())
|
|
|
|
|
|
|
|
application.ExchangeRate = 1m;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
application.AmountRMB = application.Details.Where(x => x.Currency == "CNY").Sum(x => x.Amount);
|
|
|
|
|
|
|
|
application.AmountUSD = application.Details.Where(x => x.Currency == "USD").Sum(x => x.Amount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//关联用户名称
|
|
|
|
//关联用户名称
|
|
|
|
var userIds = new long?[] { application.SettlerId, application.PaymentApplicantId };
|
|
|
|
//var userIds = new long?[] { application.SettlerId, application.PaymentApplicantId };
|
|
|
|
var users = await Db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
|
|
|
|
//var users = await Db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
|
|
|
|
application.SettlerName = application.SettlerId.HasValue ? users.Find(x => x.Id == application.SettlerId.Value)?.UserName : string.Empty;
|
|
|
|
//application.SettlerName = application.SettlerId.HasValue ? users.Find(x => x.Id == application.SettlerId.Value)?.UserName : string.Empty;
|
|
|
|
application.PaymentApplicantName = application.PaymentApplicantId.HasValue ? users.Find(x => x.Id == application.PaymentApplicantId.Value)?.UserName : string.Empty;
|
|
|
|
//application.PaymentApplicantName = application.PaymentApplicantId.HasValue ? users.Find(x => x.Id == application.PaymentApplicantId.Value)?.UserName : string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
try
|
|
|
|
try
|
|
|
@ -175,14 +366,36 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
//关联导航属性插入
|
|
|
|
//关联导航属性插入
|
|
|
|
if (application.Id == 0)
|
|
|
|
if (application.Id == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
//创建时需要生成申请单编号
|
|
|
|
|
|
|
|
var sequence = commonService.GetSequenceNext<FeeApplication>();
|
|
|
|
|
|
|
|
if (!sequence.Succeeded)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return DataResult.Failed(sequence.Message, MultiLanguageConst.SequenceSetNotExist);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
application.ApplicationNO = sequence.Data;
|
|
|
|
|
|
|
|
|
|
|
|
await TenantDb.InsertNav(application).Include(x => x.Details).ExecuteCommandAsync();
|
|
|
|
await TenantDb.InsertNav(application).Include(x => x.Details).ExecuteCommandAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//关联导航属性更新
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await TenantDb.UpdateNav(application).Include(x => x.Details).ExecuteCommandAsync();
|
|
|
|
var createList = application.Details.FindAll(x => x.Id == 0);
|
|
|
|
|
|
|
|
if (createList.Count > 0)
|
|
|
|
|
|
|
|
await TenantDb.Insertable(createList).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await TenantDb.Updateable(application).IgnoreColumns(x => new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
x.ApplicationNO,
|
|
|
|
|
|
|
|
x.CreateBy,
|
|
|
|
|
|
|
|
x.CreateTime,
|
|
|
|
|
|
|
|
x.Deleted,
|
|
|
|
|
|
|
|
x.DeleteBy,
|
|
|
|
|
|
|
|
x.DeleteTime
|
|
|
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fees != null)
|
|
|
|
|
|
|
|
await TenantDb.Updateable(fees).UpdateColumns(x => new { x.OrderAmount }).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
return DataResult.Success;
|
|
|
|
return DataResult.Success;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -194,6 +407,44 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 删除申请单明细
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="ids">申请单明细ID</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public async Task<DataResult> DeleteDetailAsync(params long[] ids)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var details = await TenantDb.Queryable<FeeApplicationDetail>().Where(x => ids.Contains(x.Id)).Select(
|
|
|
|
|
|
|
|
x => new FeeApplicationDetail
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
|
|
|
RecordId = x.RecordId,
|
|
|
|
|
|
|
|
OriginalAmount = x.OriginalAmount
|
|
|
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//还原费用表的已申请金额
|
|
|
|
|
|
|
|
var fees = details.Select(x => new FeeRecord { Id = x.RecordId, OrderAmount = x.OriginalAmount }).ToList();
|
|
|
|
|
|
|
|
TenantDb.Updateable(fees)
|
|
|
|
|
|
|
|
.PublicSetColumns(it => it.OrderAmount, "-")
|
|
|
|
|
|
|
|
.UpdateColumns(x => new { x.OrderAmount })
|
|
|
|
|
|
|
|
.ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await TenantDb.Deleteable(details).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
|
|
|
await ex.LogAsync(Db);
|
|
|
|
|
|
|
|
return DataResult.Failed("删除失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 删除申请单
|
|
|
|
/// 删除申请单
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -204,8 +455,35 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
if (await TenantDb.Queryable<FeeApplication>().AnyAsync(x => ids.Contains(x.Id) && (x.Status != ApplicationStatus.Pending && x.Status != ApplicationStatus.AuditRejected)))
|
|
|
|
if (await TenantDb.Queryable<FeeApplication>().AnyAsync(x => ids.Contains(x.Id) && (x.Status != ApplicationStatus.Pending && x.Status != ApplicationStatus.AuditRejected)))
|
|
|
|
return DataResult.Failed("只能删除状态为‘待审核’或‘驳回’的申请单", MultiLanguageConst.FeeRecordDelete);
|
|
|
|
return DataResult.Failed("只能删除状态为‘待审核’或‘驳回’的申请单", MultiLanguageConst.FeeRecordDelete);
|
|
|
|
|
|
|
|
|
|
|
|
bool result = await TenantDb.DeleteNav<FeeApplication>(x => ids.Contains(x.Id)).Include(x => x.Details).ExecuteCommandAsync();
|
|
|
|
var details = await TenantDb.Queryable<FeeApplicationDetail>().Where(x => ids.Contains(x.ApplicationId)).Select(
|
|
|
|
return result ? DataResult.Successed("删除成功!") : DataResult.Failed("删除失败!");
|
|
|
|
x => new FeeApplicationDetail
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
|
|
|
RecordId = x.RecordId,
|
|
|
|
|
|
|
|
OriginalAmount = x.OriginalAmount
|
|
|
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//还原费用表的已申请金额
|
|
|
|
|
|
|
|
var fees = details.Select(x => new FeeRecord { Id = x.RecordId, OrderAmount = x.OriginalAmount }).ToList();
|
|
|
|
|
|
|
|
TenantDb.Updateable(fees)
|
|
|
|
|
|
|
|
.PublicSetColumns(it => it.OrderAmount, "-")
|
|
|
|
|
|
|
|
.UpdateColumns(x => new { x.OrderAmount })
|
|
|
|
|
|
|
|
.ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await TenantDb.DeleteNav<FeeApplication>(x => ids.Contains(x.Id)).Include(x => x.Details).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
|
|
|
await ex.LogAsync(Db);
|
|
|
|
|
|
|
|
return DataResult.Failed("删除失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -306,7 +584,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await Db.Updateable(flows).UpdateColumns(x => new { x.FlowStatus, x.MakerList }).ExecuteCommandAsync();
|
|
|
|
await Db.Updateable(flows).UpdateColumns(x => new { x.FlowStatus, x.MakerList }).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var item in list)
|
|
|
|
foreach (var item in list)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
item.Status = ApplicationStatus.Pending;
|
|
|
|
item.Status = ApplicationStatus.Pending;
|
|
|
|
item.FlowId = null;
|
|
|
|
item.FlowId = null;
|
|
|
|