|
|
@ -1,4 +1,5 @@
|
|
|
|
using DS.Module.Core;
|
|
|
|
using AngleSharp.Dom;
|
|
|
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
using DS.WMS.Core.Application.Dtos;
|
|
|
|
using DS.WMS.Core.Application.Dtos;
|
|
|
|
using DS.WMS.Core.Code.Entity;
|
|
|
|
using DS.WMS.Core.Code.Entity;
|
|
|
@ -13,8 +14,10 @@ using DS.WMS.Core.Sys.Entity;
|
|
|
|
using DS.WMS.Core.TaskInteraction.Dtos;
|
|
|
|
using DS.WMS.Core.TaskInteraction.Dtos;
|
|
|
|
using DS.WMS.Core.TaskInteraction.Interface;
|
|
|
|
using DS.WMS.Core.TaskInteraction.Interface;
|
|
|
|
using Mapster;
|
|
|
|
using Mapster;
|
|
|
|
|
|
|
|
using Masuit.Tools.Systems;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using SqlSugar;
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
using static iText.StyledXmlParser.Jsoup.Select.Evaluator;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Fee.Method
|
|
|
|
namespace DS.WMS.Core.Fee.Method
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -29,11 +32,12 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
public static readonly FeeStatus[] AuditStatusArray = [FeeStatus.AuditSubmitted, FeeStatus.ApplyDeletion, FeeStatus.ApplyModification];
|
|
|
|
public static readonly FeeStatus[] AuditStatusArray = [FeeStatus.AuditSubmitted, FeeStatus.ApplyDeletion, FeeStatus.ApplyModification];
|
|
|
|
|
|
|
|
|
|
|
|
//一键审核支持的类型
|
|
|
|
//一键审核支持的类型
|
|
|
|
static readonly TaskBaseTypeEnum[] AuditTypes = [TaskBaseTypeEnum.FEE_AUDIT, TaskBaseTypeEnum.FEE_MODIFY_AUDIT, TaskBaseTypeEnum.FEE_DELETE_AUDIT, TaskBaseTypeEnum.FEE_BUSINESS_AUDIT];
|
|
|
|
static readonly TaskBaseTypeEnum[] AuditTypes = [TaskBaseTypeEnum.FEE_AUDIT, TaskBaseTypeEnum.FEE_MODIFY_AUDIT, TaskBaseTypeEnum.FEE_DELETE_AUDIT, TaskBaseTypeEnum.BILL_RECV_AUDIT];
|
|
|
|
|
|
|
|
|
|
|
|
readonly IClientFlowInstanceService flowService;
|
|
|
|
readonly IClientFlowInstanceService flowService;
|
|
|
|
readonly IFeeRecordService feeService;
|
|
|
|
readonly IFeeRecordService feeService;
|
|
|
|
readonly IFeeTaskService taskService;
|
|
|
|
readonly IFeeTaskService taskService;
|
|
|
|
|
|
|
|
readonly Lazy<IFeeBillTaskService> billService;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 初始化
|
|
|
|
/// 初始化
|
|
|
@ -44,6 +48,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
flowService = serviceProvider.GetRequiredService<IClientFlowInstanceService>();
|
|
|
|
flowService = serviceProvider.GetRequiredService<IClientFlowInstanceService>();
|
|
|
|
feeService = serviceProvider.GetRequiredService<IFeeRecordService>();
|
|
|
|
feeService = serviceProvider.GetRequiredService<IFeeRecordService>();
|
|
|
|
taskService = serviceProvider.GetRequiredService<IFeeTaskService>();
|
|
|
|
taskService = serviceProvider.GetRequiredService<IFeeTaskService>();
|
|
|
|
|
|
|
|
billService = new Lazy<IFeeBillTaskService>(serviceProvider.GetRequiredService<IFeeBillTaskService>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -68,8 +73,8 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
if (flows.Count == 0)
|
|
|
|
if (flows.Count == 0)
|
|
|
|
return DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
return DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
|
|
|
|
|
|
|
ids1 = flows.Where(x => x.AuditType != TaskBaseTypeEnum.FEE_BUSINESS_AUDIT).Select(x => x.BusinessId).ToArray();
|
|
|
|
ids1 = flows.Where(x => x.AuditType != TaskBaseTypeEnum.BILL_RECV_AUDIT).Select(x => x.BusinessId).ToArray();
|
|
|
|
ids2 = flows.Where(x => x.AuditType == TaskBaseTypeEnum.FEE_BUSINESS_AUDIT).Select(x => x.BusinessId).ToArray();
|
|
|
|
ids2 = flows.Where(x => x.AuditType == TaskBaseTypeEnum.BILL_RECV_AUDIT).Select(x => x.BusinessId).ToArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var queryList = CreateQuery(ids1, ids2);
|
|
|
|
var queryList = CreateQuery(ids1, ids2);
|
|
|
@ -205,7 +210,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
long[]? ids = null;
|
|
|
|
long[]? ids = null;
|
|
|
|
if (request.OtherQueryCondition)
|
|
|
|
if (request.OtherQueryCondition)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ids = await GetCurrentFlowsQuery(TaskBaseTypeEnum.FEE_BUSINESS_AUDIT).Select(x => x.BusinessId).Distinct().ToArrayAsync();
|
|
|
|
ids = await GetCurrentFlowsQuery(TaskBaseTypeEnum.BILL_RECV_AUDIT).Select(x => x.BusinessId).Distinct().ToArrayAsync();
|
|
|
|
|
|
|
|
|
|
|
|
//没有待审批的列表直接返回不再执行后续查询
|
|
|
|
//没有待审批的列表直接返回不再执行后续查询
|
|
|
|
if (ids.Length == 0)
|
|
|
|
if (ids.Length == 0)
|
|
|
@ -372,8 +377,8 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
if (flows.Count == 0)
|
|
|
|
if (flows.Count == 0)
|
|
|
|
return DataResult<PendingAuditFee>.Success(pendingAudit, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
return DataResult<PendingAuditFee>.Success(pendingAudit, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
|
|
|
|
|
|
|
ids1 = flows.Where(x => x.AuditType != TaskBaseTypeEnum.FEE_BUSINESS_AUDIT).Select(x => x.BusinessId).ToArray();
|
|
|
|
ids1 = flows.Where(x => x.AuditType != TaskBaseTypeEnum.BILL_RECV_AUDIT).Select(x => x.BusinessId).ToArray();
|
|
|
|
ids2 = flows.Where(x => x.AuditType == TaskBaseTypeEnum.FEE_BUSINESS_AUDIT).Select(x => x.BusinessId).ToArray();
|
|
|
|
ids2 = flows.Where(x => x.AuditType == TaskBaseTypeEnum.BILL_RECV_AUDIT).Select(x => x.BusinessId).ToArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var fees = await TenantDb.Queryable<FeeRecord>().Where(f => f.BusinessId == request.Id && f.BusinessType == request.BusinessType)
|
|
|
|
var fees = await TenantDb.Queryable<FeeRecord>().Where(f => f.BusinessId == request.Id && f.BusinessType == request.BusinessType)
|
|
|
@ -385,7 +390,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
}).ToListAsync();
|
|
|
|
}).ToListAsync();
|
|
|
|
pendingAudit.IsPositiveProfit = fees.Where(x => x.FeeType == FeeType.Receivable).Sum(x => x.Amount * (x.ExchangeRate ?? 1))
|
|
|
|
pendingAudit.IsPositiveProfit = fees.Where(x => x.FeeType == FeeType.Receivable).Sum(x => x.Amount * (x.ExchangeRate ?? 1))
|
|
|
|
- fees.Where(x => x.FeeType == FeeType.Payable).Sum(x => x.Amount * (x.ExchangeRate ?? 1)) > 0;
|
|
|
|
- fees.Where(x => x.FeeType == FeeType.Payable).Sum(x => x.Amount * (x.ExchangeRate ?? 1)) > 0;
|
|
|
|
pendingAudit.IsBusinessAudit = await flowService.Exists(TaskBaseTypeEnum.FEE_BUSINESS_AUDIT, request.BusinessType, null, request.Id);
|
|
|
|
pendingAudit.IsBusinessAudit = await flowService.Exists(TaskBaseTypeEnum.BILL_RECV_AUDIT, request.BusinessType, null, request.Id);
|
|
|
|
|
|
|
|
|
|
|
|
var query1 = TenantDb.Queryable<FeeRecord>().Where(f => f.BusinessId == request.Id && f.BusinessType == request.BusinessType)
|
|
|
|
var query1 = TenantDb.Queryable<FeeRecord>().Where(f => f.BusinessId == request.Id && f.BusinessType == request.BusinessType)
|
|
|
|
.InnerJoin<SeaExport>((f, s) => f.BusinessId == s.Id)
|
|
|
|
.InnerJoin<SeaExport>((f, s) => f.BusinessId == s.Id)
|
|
|
@ -683,55 +688,56 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
return await AuditAsync(request.Result, request.Remark, recordIds);
|
|
|
|
return await AuditAsync(request.Result, request.Remark, recordIds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const TaskBaseTypeEnum BIZ_TASK_TYPE = TaskBaseTypeEnum.FEE_BUSINESS_AUDIT;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 整票审核
|
|
|
|
/// 整票审核
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="request">审批请求</param>
|
|
|
|
/// <param name="request">审核请求</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task<DataResult> AuditBusinessAsync(BizAuditRequest request)
|
|
|
|
public async Task<DataResult> AuditBillAsync(TaskAuditRequest request)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DataResult result;
|
|
|
|
DataResult result = DataResult.Success;
|
|
|
|
bool hasAuthorized = await taskService.HasAuthorizedAsync();
|
|
|
|
var entity = await TenantDb.Queryable<BusinessFeeStatus>().Where(x => request.Ids.Contains(x.BusinessId) && x.BusinessType == request.BusinessType)
|
|
|
|
var gpList = request.Items.GroupBy(x => x.BusinessType).ToList();
|
|
|
|
.Select(x => new BusinessFeeStatus
|
|
|
|
foreach (var gp in gpList)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var ids = gp.Select(x => x.Id).ToArray();
|
|
|
|
|
|
|
|
var bizList = await TenantDb.Queryable<BusinessFeeStatus>().Where(x => ids.Contains(x.BusinessId) && x.BusinessType == gp.Key)
|
|
|
|
|
|
|
|
.Select(x => new
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
x.Id,
|
|
|
|
Id = x.Id,
|
|
|
|
x.BillAuditStatus,
|
|
|
|
BillAuditStatus = x.BillAuditStatus,
|
|
|
|
}).ToListAsync();
|
|
|
|
BillFeeStatusTime = x.BillFeeStatusTime
|
|
|
|
|
|
|
|
}).FirstAsync();
|
|
|
|
|
|
|
|
|
|
|
|
if (bizList.Count == 0)
|
|
|
|
if (entity == null)
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData));
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData));
|
|
|
|
|
|
|
|
|
|
|
|
if (bizList.Any(x => x.BillAuditStatus != BillAuditStatus.RecvSubmitted && x.BillAuditStatus != BillAuditStatus.PaySubmitted))
|
|
|
|
if (request.TaskType == TaskBaseTypeEnum.BILL_RECV_AUDIT)
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.BusinessAuditStatusError));
|
|
|
|
{
|
|
|
|
|
|
|
|
if (entity.BillAuditStatus != BillAuditStatus.RecvSubmitted)
|
|
|
|
|
|
|
|
return DataResult.Failed(string.Format(MultiLanguageConst.BusinessStatusError, entity.BillAuditStatus.GetDescription()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (request.TaskType == TaskBaseTypeEnum.BILL_PAY_AUDIT)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (entity.BillAuditStatus != BillAuditStatus.PaySubmitted)
|
|
|
|
|
|
|
|
return DataResult.Failed(string.Format(MultiLanguageConst.BusinessStatusError, entity.BillAuditStatus.GetDescription()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskNotSupported));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (hasAuthorized)
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = await taskService.AuditAsync(new TaskAuditRequest
|
|
|
|
if (await taskService.HasAuthorizedAsync())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Ids = ids,
|
|
|
|
result = await taskService.AuditAsync(request);
|
|
|
|
Remark = request.Remark,
|
|
|
|
|
|
|
|
Result = request.Result,
|
|
|
|
|
|
|
|
TaskTypeName = BIZ_TASK_TYPE.ToString()
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
if (!result.Succeeded)
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var flows = await flowService.GetInstanceByBSIdAsync(BIZ_TASK_TYPE, gp.Key, ids);
|
|
|
|
var flows = await flowService.GetInstanceByBSIdAsync(request.TaskType, request.BusinessType, request.Ids);
|
|
|
|
if (flows.Count == 0)
|
|
|
|
if (flows.Count == 0)
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FlowNotFound));
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FlowNotFound));
|
|
|
|
|
|
|
|
|
|
|
|
if (flows.Any(x => !x.MakerList.Contains(User.UserId)))
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var flow in flows)
|
|
|
|
foreach (var flow in flows)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = await flowService.AuditAsync(new FlowAuditInfo
|
|
|
|
result = await flowService.AuditAsync(new FlowAuditInfo
|
|
|
@ -745,9 +751,38 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
long userId = long.Parse(User.UserId);
|
|
|
|
|
|
|
|
entity.BillFeeStatusTime = DateTime.Now;
|
|
|
|
|
|
|
|
//变更状态为提交审核
|
|
|
|
|
|
|
|
if (request.TaskType == TaskBaseTypeEnum.BILL_RECV_AUDIT)
|
|
|
|
|
|
|
|
entity.BillAuditStatus = BillAuditStatus.RecvPassed;
|
|
|
|
|
|
|
|
else if (request.TaskType == TaskBaseTypeEnum.BILL_PAY_AUDIT)
|
|
|
|
|
|
|
|
entity.BillAuditStatus = BillAuditStatus.PayPassed;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await TenantDb.Updateable(entity).UpdateColumns(x => new
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
x.BillAuditStatus,
|
|
|
|
|
|
|
|
x.BillFeeStatusTime
|
|
|
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//修改关联费用状态为审核完成
|
|
|
|
|
|
|
|
await TenantDb.Updateable<FeeRecord>().Where(x => x.BusinessId == entity.BusinessId && x.BusinessType == entity.BusinessType && x.FeeStatus == FeeStatus.AuditSubmitted)
|
|
|
|
|
|
|
|
.SetColumns(x => x.FeeStatus == FeeStatus.AuditPassed)
|
|
|
|
|
|
|
|
.SetColumns(x => x.AuditBy == userId)
|
|
|
|
|
|
|
|
.SetColumns(x => x.AuditOperator == User.UserName)
|
|
|
|
|
|
|
|
.SetColumns(x => x.AuditDate == entity.BillFeeStatusTime)
|
|
|
|
|
|
|
|
.ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
|
|
|
await ex.LogAsync(Db);
|
|
|
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -775,7 +810,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
var auditType = callback.AuditType;
|
|
|
|
var auditType = callback.AuditType;
|
|
|
|
FeeRecord? fee = null;
|
|
|
|
FeeRecord? fee = null;
|
|
|
|
BusinessFeeStatus? biz = null;
|
|
|
|
BusinessFeeStatus? biz = null;
|
|
|
|
if (auditType == TaskBaseTypeEnum.FEE_BUSINESS_AUDIT)
|
|
|
|
if (auditType == TaskBaseTypeEnum.BILL_RECV_AUDIT)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
biz = await TenantDb.Queryable<BusinessFeeStatus>().Where(x => x.Id == callback.BusinessId && x.BusinessType == callback.BusinessType)
|
|
|
|
biz = await TenantDb.Queryable<BusinessFeeStatus>().Where(x => x.Id == callback.BusinessId && x.BusinessType == callback.BusinessType)
|
|
|
|
.Select(x => new BusinessFeeStatus
|
|
|
|
.Select(x => new BusinessFeeStatus
|
|
|
@ -946,11 +981,11 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
|
|
|
|
|
|
|
if (auditType != TaskBaseTypeEnum.FEE_BUSINESS_AUDIT)
|
|
|
|
if (auditType != TaskBaseTypeEnum.BILL_RECV_AUDIT)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await feeService.WriteBackStatusAsync(
|
|
|
|
await feeService.WriteBackStatusAsync(
|
|
|
|
auditType == TaskBaseTypeEnum.FEE_BUSINESS_AUDIT ? biz.BusinessId : fee.BusinessId,
|
|
|
|
auditType == TaskBaseTypeEnum.BILL_RECV_AUDIT ? biz.BusinessId : fee.BusinessId,
|
|
|
|
auditType == TaskBaseTypeEnum.FEE_BUSINESS_AUDIT ? biz.BusinessType : fee.BusinessType);
|
|
|
|
auditType == TaskBaseTypeEnum.BILL_RECV_AUDIT ? biz.BusinessType : fee.BusinessType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
return DataResult.Success;
|
|
|
|