You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
5.5 KiB
C#

using DS.Module.Core;
1 month ago
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.TaskInteraction.Dtos;
using DS.WMS.Core.TaskInteraction.Interface;
namespace DS.WMS.Core.TaskInteraction.Method
{
/// <summary>
/// 费用整票审核任务
/// </summary>
public class FeeBillTaskService : TaskService, IFeeBillTaskService
{
/// <summary>
/// 初始化
/// </summary>
/// <param name="provider"></param>
public FeeBillTaskService(IServiceProvider provider) : base(provider)
{
}
1 month ago
/// <summary>
/// 批量创建
/// </summary>
/// <param name="request"></param>
/// <param name="useTransaction"></param>
/// <returns></returns>
public override Task<DataResult> CreateMultipleTaskAsync(TaskCreationRequest request, bool useTransaction = true)
{
return Task.FromResult(DataResult.Failed("不支持批量提交整票审核任务"));
}
1 month ago
/// <summary>
/// 回调更新
/// </summary>
/// <param name="callback"></param>
/// <returns></returns>
public override async Task UpdateBusinessAsync(FlowCallback callback)
{
var auditType = callback.AuditType;
if (auditType != TaskBaseTypeEnum.BILL_RECV_AUDIT && auditType != TaskBaseTypeEnum.BILL_PAY_AUDIT)
return;
var biz = await TenantDb.Queryable<BusinessFeeStatus>().Where(x => x.BusinessId == callback.BusinessId && x.BusinessType == callback.BusinessType)
1 month ago
.Select(x => new BusinessFeeStatus
{
Id = x.Id,
BusinessId = x.BusinessId,
BusinessType = x.BusinessType,
1 month ago
BillAuditStatus = x.BillAuditStatus,
BillFeeStatusTime = x.BillFeeStatusTime
1 month ago
}).FirstAsync();
if (biz == null)
return;
long userId = long.Parse(User.UserId);
DateTime dtNow = DateTime.Now;
await TenantDb.Ado.BeginTranAsync();
try
{
if (auditType == TaskBaseTypeEnum.BILL_RECV_AUDIT)
{
if (callback.FlowStatus == FlowStatusEnum.Approve)
{
biz.BillAuditStatus = BillAuditStatus.RecvPassed;
}
else if (callback.FlowStatus == FlowStatusEnum.Reject)
{
biz.BillAuditStatus = BillAuditStatus.RecvRejected;
await TenantDb.Updateable<FeeRecord>()
.SetColumns(x => x.FeeStatus == FeeStatus.RejectSubmission)
.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.AuditSubmitted)
.ExecuteCommandAsync();
1 month ago
}
biz.BillFeeStatusTime = dtNow;
await TenantDb.Updateable(biz).UpdateColumns(x => new
{
x.BillAuditStatus,
x.BillFeeStatusTime
1 month ago
}).ExecuteCommandAsync();
}
else if (auditType == TaskBaseTypeEnum.BILL_PAY_AUDIT)
{
FeeStatus status = FeeStatus.RejectSubmission;
if (callback.FlowStatus == FlowStatusEnum.Approve)
{
biz.BillAuditStatus = BillAuditStatus.PayPassed;
biz.ARFeeStatus = biz.APFeeStatus = BillFeeStatus.AuditPassed;
1 month ago
status = FeeStatus.AuditPassed;
}
else if (callback.FlowStatus == FlowStatusEnum.Reject)
{
biz.BillAuditStatus = BillAuditStatus.PayRejected;
biz.ARFeeStatus = biz.APFeeStatus = BillFeeStatus.RejectSubmission;
status = FeeStatus.RejectSubmission;
1 month ago
}
biz.BillFeeStatusTime = dtNow;
await TenantDb.Updateable(biz).UpdateColumns(x => new
{
x.BillAuditStatus,
x.BillFeeStatusTime,
x.ARFeeStatus,
1 month ago
x.APFeeStatus
}).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.AuditSubmitted)
1 month ago
.ExecuteCommandAsync();
}
await base.UpdateBusinessAsync(callback);
await TenantDb.Ado.CommitTranAsync();
}
catch (Exception ex)
{
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
throw;
}
}
}
}