|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using AngleSharp.Dom;
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
using DS.WMS.Core.Application.Dtos;
|
|
|
|
|
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.Interface;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Masuit.Tools.Systems;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using static iText.StyledXmlParser.Jsoup.Select.Evaluator;
|
|
|
|
|
|
|
|
|
|
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];
|
|
|
|
|
|
|
|
|
|
//一键审核支持的类型
|
|
|
|
|
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 IFeeRecordService feeService;
|
|
|
|
|
readonly IFeeTaskService taskService;
|
|
|
|
|
readonly Lazy<IFeeBillTaskService> billService;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化
|
|
|
|
@ -44,6 +48,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
flowService = serviceProvider.GetRequiredService<IClientFlowInstanceService>();
|
|
|
|
|
feeService = serviceProvider.GetRequiredService<IFeeRecordService>();
|
|
|
|
|
taskService = serviceProvider.GetRequiredService<IFeeTaskService>();
|
|
|
|
|
billService = new Lazy<IFeeBillTaskService>(serviceProvider.GetRequiredService<IFeeBillTaskService>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -68,8 +73,8 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
if (flows.Count == 0)
|
|
|
|
|
return DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
|
|
|
|
|
ids1 = flows.Where(x => x.AuditType != TaskBaseTypeEnum.FEE_BUSINESS_AUDIT).Select(x => x.BusinessId).ToArray();
|
|
|
|
|
ids2 = 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.BILL_RECV_AUDIT).Select(x => x.BusinessId).ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var queryList = CreateQuery(ids1, ids2);
|
|
|
|
@ -205,7 +210,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
long[]? ids = null;
|
|
|
|
|
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)
|
|
|
|
@ -372,8 +377,8 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
if (flows.Count == 0)
|
|
|
|
|
return DataResult<PendingAuditFee>.Success(pendingAudit, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
|
|
|
|
|
ids1 = flows.Where(x => x.AuditType != TaskBaseTypeEnum.FEE_BUSINESS_AUDIT).Select(x => x.BusinessId).ToArray();
|
|
|
|
|
ids2 = 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.BILL_RECV_AUDIT).Select(x => x.BusinessId).ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
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;
|
|
|
|
|
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)
|
|
|
|
|
.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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TaskBaseTypeEnum BIZ_TASK_TYPE = TaskBaseTypeEnum.FEE_BUSINESS_AUDIT;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 整票审核
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request">审批请求</param>
|
|
|
|
|
/// <param name="request">审核请求</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> AuditBusinessAsync(BizAuditRequest request)
|
|
|
|
|
public async Task<DataResult> AuditBillAsync(TaskAuditRequest request)
|
|
|
|
|
{
|
|
|
|
|
DataResult result;
|
|
|
|
|
bool hasAuthorized = await taskService.HasAuthorizedAsync();
|
|
|
|
|
var gpList = request.Items.GroupBy(x => x.BusinessType).ToList();
|
|
|
|
|
foreach (var gp in gpList)
|
|
|
|
|
DataResult result = DataResult.Success;
|
|
|
|
|
var entity = await TenantDb.Queryable<BusinessFeeStatus>().Where(x => request.Ids.Contains(x.BusinessId) && x.BusinessType == request.BusinessType)
|
|
|
|
|
.Select(x => new BusinessFeeStatus
|
|
|
|
|
{
|
|
|
|
|
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,
|
|
|
|
|
x.BillAuditStatus,
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
BillAuditStatus = x.BillAuditStatus,
|
|
|
|
|
BillFeeStatusTime = x.BillFeeStatusTime
|
|
|
|
|
}).FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (bizList.Count == 0)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData));
|
|
|
|
|
if (entity == null)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData));
|
|
|
|
|
|
|
|
|
|
if (bizList.Any(x => x.BillAuditStatus != BillAuditStatus.RecvSubmitted && x.BillAuditStatus != BillAuditStatus.PaySubmitted))
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.BusinessAuditStatusError));
|
|
|
|
|
if (request.TaskType == TaskBaseTypeEnum.BILL_RECV_AUDIT)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
if (await taskService.HasAuthorizedAsync())
|
|
|
|
|
{
|
|
|
|
|
result = await taskService.AuditAsync(new TaskAuditRequest
|
|
|
|
|
{
|
|
|
|
|
Ids = ids,
|
|
|
|
|
Remark = request.Remark,
|
|
|
|
|
Result = request.Result,
|
|
|
|
|
TaskTypeName = BIZ_TASK_TYPE.ToString()
|
|
|
|
|
});
|
|
|
|
|
result = await taskService.AuditAsync(request);
|
|
|
|
|
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FlowNotFound));
|
|
|
|
|
|
|
|
|
|
if (flows.Any(x => !x.MakerList.Contains(User.UserId)))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
foreach (var flow in flows)
|
|
|
|
|
{
|
|
|
|
|
result = await flowService.AuditAsync(new FlowAuditInfo
|
|
|
|
@ -745,9 +751,38 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
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>
|
|
|
|
@ -775,7 +810,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
var auditType = callback.AuditType;
|
|
|
|
|
FeeRecord? fee = 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)
|
|
|
|
|
.Select(x => new BusinessFeeStatus
|
|
|
|
@ -904,32 +939,32 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
//case TaskBaseTypeEnum.FEE_BUSINESS_AUDIT:
|
|
|
|
|
// FeeStatus status = FeeStatus.RejectSubmission;
|
|
|
|
|
// if (callback.FlowStatus == FlowStatusEnum.Approve)
|
|
|
|
|
// {
|
|
|
|
|
// biz.BillAuditStatus = BillAuditStatus.AuditPassed;
|
|
|
|
|
// status = FeeStatus.AuditPassed;
|
|
|
|
|
// }
|
|
|
|
|
// else if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
|
// {
|
|
|
|
|
// biz.BillAuditStatus = BillAuditStatus.Rejected;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// await TenantDb.Updateable(biz).UpdateColumns(x => new
|
|
|
|
|
// {
|
|
|
|
|
// x.BillAuditStatus
|
|
|
|
|
// }).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
// await TenantDb.Updateable<FeeRecord>()
|
|
|
|
|
// .SetColumns(x => x.FeeStatus == status)
|
|
|
|
|
// .SetColumns(x => x.AuditBy == UserId)
|
|
|
|
|
// .SetColumns(x => x.AuditOperator == User.UserName)
|
|
|
|
|
// .SetColumns(x => x.AuditDate == dtNow)
|
|
|
|
|
// .Where(x => x.BusinessId == biz.BusinessId && x.BusinessType == biz.BusinessType &&
|
|
|
|
|
// x.FeeStatus != FeeStatus.PartialSettlement && x.FeeStatus != FeeStatus.SettlementCompleted).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
//case TaskBaseTypeEnum.FEE_BUSINESS_AUDIT:
|
|
|
|
|
// FeeStatus status = FeeStatus.RejectSubmission;
|
|
|
|
|
// if (callback.FlowStatus == FlowStatusEnum.Approve)
|
|
|
|
|
// {
|
|
|
|
|
// biz.BillAuditStatus = BillAuditStatus.AuditPassed;
|
|
|
|
|
// status = FeeStatus.AuditPassed;
|
|
|
|
|
// }
|
|
|
|
|
// else if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
|
// {
|
|
|
|
|
// biz.BillAuditStatus = BillAuditStatus.Rejected;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// await TenantDb.Updateable(biz).UpdateColumns(x => new
|
|
|
|
|
// {
|
|
|
|
|
// x.BillAuditStatus
|
|
|
|
|
// }).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
// await TenantDb.Updateable<FeeRecord>()
|
|
|
|
|
// .SetColumns(x => x.FeeStatus == status)
|
|
|
|
|
// .SetColumns(x => x.AuditBy == UserId)
|
|
|
|
|
// .SetColumns(x => x.AuditOperator == User.UserName)
|
|
|
|
|
// .SetColumns(x => x.AuditDate == dtNow)
|
|
|
|
|
// .Where(x => x.BusinessId == biz.BusinessId && x.BusinessType == biz.BusinessType &&
|
|
|
|
|
// x.FeeStatus != FeeStatus.PartialSettlement && x.FeeStatus != FeeStatus.SettlementCompleted).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////驳回申请则逻辑删除关联工作流
|
|
|
|
@ -946,11 +981,11 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
|
|
|
|
|
if (auditType != TaskBaseTypeEnum.FEE_BUSINESS_AUDIT)
|
|
|
|
|
if (auditType != TaskBaseTypeEnum.BILL_RECV_AUDIT)
|
|
|
|
|
{
|
|
|
|
|
await feeService.WriteBackStatusAsync(
|
|
|
|
|
auditType == TaskBaseTypeEnum.FEE_BUSINESS_AUDIT ? biz.BusinessId : fee.BusinessId,
|
|
|
|
|
auditType == TaskBaseTypeEnum.FEE_BUSINESS_AUDIT ? biz.BusinessType : fee.BusinessType);
|
|
|
|
|
auditType == TaskBaseTypeEnum.BILL_RECV_AUDIT ? biz.BusinessId : fee.BusinessId,
|
|
|
|
|
auditType == TaskBaseTypeEnum.BILL_RECV_AUDIT ? biz.BusinessType : fee.BusinessType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|