|
|
|
@ -1,10 +1,11 @@
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
|
|
using DS.WMS.Core.Fee.Interface;
|
|
|
|
|
using DS.WMS.Core.Flow.Dtos;
|
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Dtos;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Entity;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Interface;
|
|
|
|
|
using LanguageExt.Common;
|
|
|
|
|
using Masuit.Tools.Systems;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
@ -17,7 +18,6 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class FeeBillTaskService : TaskService, IFeeBillTaskService
|
|
|
|
|
{
|
|
|
|
|
readonly IFeeRecordService feeService;
|
|
|
|
|
readonly ILogger<FeeBillTaskService> logger;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化
|
|
|
|
@ -25,7 +25,6 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
/// <param name="provider"></param>
|
|
|
|
|
public FeeBillTaskService(IServiceProvider provider) : base(provider)
|
|
|
|
|
{
|
|
|
|
|
feeService = provider.GetRequiredService<IFeeRecordService>();
|
|
|
|
|
logger = provider.GetRequiredService<ILogger<FeeBillTaskService>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -67,19 +66,27 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
if (biz == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
DataResult result;
|
|
|
|
|
long userId = long.Parse(User.UserId);
|
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await UpdateTaskStatus(callback, biz);
|
|
|
|
|
|
|
|
|
|
if (auditType == TaskBaseTypeEnum.BILL_RECV_AUDIT)
|
|
|
|
|
{
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Approve)
|
|
|
|
|
{
|
|
|
|
|
biz.BillAuditStatus = BillAuditStatus.RecvPassed;
|
|
|
|
|
biz.BillAuditStatus = BillAuditStatus.PaySubmitted;
|
|
|
|
|
//生成应付确认任务
|
|
|
|
|
await feeService.SubmitBillAuditAsync(callback.BusinessId, callback.BusinessType.GetValueOrDefault(),
|
|
|
|
|
TaskBaseTypeEnum.BILL_PAY_AUDIT, false);
|
|
|
|
|
result = await CreateTaskAsync(new TaskCreationRequest
|
|
|
|
|
{
|
|
|
|
|
BusinessId = callback.BusinessId,
|
|
|
|
|
BusinessType = callback.BusinessType.GetValueOrDefault(),
|
|
|
|
|
TaskTypeName = TaskBaseTypeEnum.BILL_PAY_AUDIT.ToString(),
|
|
|
|
|
TaskTitle = $"【{TaskBaseTypeEnum.BILL_PAY_AUDIT.GetDescription()}】【{callback.BusinessType.GetDescription()}】{biz.CustomerNo}"
|
|
|
|
|
}, false);
|
|
|
|
|
}
|
|
|
|
|
else if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
|
{
|
|
|
|
@ -134,7 +141,6 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
.ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await base.UpdateBusinessAsync(callback);
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
@ -144,7 +150,8 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (auditType == TaskBaseTypeEnum.BILL_PAY_AUDIT && callback.FlowStatus == FlowStatusEnum.Approve)
|
|
|
|
|
{
|
|
|
|
|
if (biz.ProfitMargin > 0)
|
|
|
|
|
{
|
|
|
|
|
biz.IsFeeLocking = true;
|
|
|
|
@ -162,7 +169,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
}
|
|
|
|
|
else //如果为非正利润则生成锁单任务
|
|
|
|
|
{
|
|
|
|
|
var result = await CreateTaskAsync(new TaskCreationRequest
|
|
|
|
|
result = await CreateTaskAsync(new TaskCreationRequest
|
|
|
|
|
{
|
|
|
|
|
BusinessId = biz.BusinessId,
|
|
|
|
|
BusinessType = biz.BusinessType,
|
|
|
|
@ -176,4 +183,57 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//更新当前任务状态
|
|
|
|
|
private async Task UpdateTaskStatus(FlowCallback callback, BusinessFeeStatus business)
|
|
|
|
|
{
|
|
|
|
|
DataResult result = await SetTaskStatusAsync(new TaskUpdateRequest
|
|
|
|
|
{
|
|
|
|
|
BusinessId = callback.BusinessId,
|
|
|
|
|
BusinessType = callback.BusinessType,
|
|
|
|
|
TaskTypeName = callback.AuditType.ToString()!,
|
|
|
|
|
TaskStatus = TaskStatusEnum.Complete
|
|
|
|
|
}, false);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
logger.LogError($"设置【{callback.AuditType.GetDescription()}】任务状态失败:" + result.Message);
|
|
|
|
|
|
|
|
|
|
string remark = "终审完成,审批结果为:" + callback.FlowStatus.GetDescription();
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
|
{
|
|
|
|
|
var task = await GetQuery(callback.BusinessId, callback.BusinessType, callback.AuditType.Value).FirstAsync();
|
|
|
|
|
var request = new TaskCreationRequest
|
|
|
|
|
{
|
|
|
|
|
BusinessId = callback.BusinessId,
|
|
|
|
|
BusinessType = callback.BusinessType,
|
|
|
|
|
TaskTypeName = GetRejectedType(callback.AuditType.Value).ToString()!,
|
|
|
|
|
TaskTitle = $"【{TaskBaseTypeEnum.BILL_PAY_AUDIT.GetDescription()}】【{callback.BusinessType.GetDescription()}】{business.CustomerNo}",
|
|
|
|
|
RecvUserIdList = [task.CreateBy] //通知任务发起人
|
|
|
|
|
};
|
|
|
|
|
//创建驳回任务以进行通知
|
|
|
|
|
await CreateTaskAsync(request, false);
|
|
|
|
|
|
|
|
|
|
//更新任务描述为驳回原因
|
|
|
|
|
await SetTaskBaseDescription(callback.BusinessId, request.TaskType, callback.RejectReason!);
|
|
|
|
|
|
|
|
|
|
remark += ";驳回原因:" + callback.RejectReason;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long userId = long.Parse(User.UserId);
|
|
|
|
|
var users = await FillInUserInfoAsync(userId);
|
|
|
|
|
//记录日志
|
|
|
|
|
await LogService.WriteLogAsync(new BusinessTaskLog
|
|
|
|
|
{
|
|
|
|
|
ActionType = ActionType.Audit,
|
|
|
|
|
AuditStatus = callback.FlowStatus,
|
|
|
|
|
BusinessId = callback.BusinessId,
|
|
|
|
|
BusinessType = callback.BusinessType,
|
|
|
|
|
CreateBy = userId,
|
|
|
|
|
CreateTime = DateTime.Now,
|
|
|
|
|
TaskStatus = callback.FlowStatus == FlowStatusEnum.Approve ? TaskStatusEnum.Complete : TaskStatusEnum.Pending,
|
|
|
|
|
TaskType = callback.AuditType.GetValueOrDefault(),
|
|
|
|
|
RecvUsers = users.Count > 0 ? users[0].RecvUserName : null,
|
|
|
|
|
Remark = remark
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|