|
|
|
@ -1,9 +1,14 @@
|
|
|
|
|
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.Interface;
|
|
|
|
|
using Masuit.Tools.Systems;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
{
|
|
|
|
@ -12,12 +17,16 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class FeeBillTaskService : TaskService, IFeeBillTaskService
|
|
|
|
|
{
|
|
|
|
|
readonly IFeeRecordService feeService;
|
|
|
|
|
readonly ILogger<FeeBillTaskService> logger;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="provider"></param>
|
|
|
|
|
public FeeBillTaskService(IServiceProvider provider) : base(provider)
|
|
|
|
|
{
|
|
|
|
|
feeService = provider.GetRequiredService<IFeeRecordService>();
|
|
|
|
|
logger = provider.GetRequiredService<ILogger<FeeBillTaskService>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -43,13 +52,17 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var biz = await TenantDb.Queryable<BusinessFeeStatus>().Where(x => x.BusinessId == callback.BusinessId && x.BusinessType == callback.BusinessType)
|
|
|
|
|
.Select(x => new BusinessFeeStatus
|
|
|
|
|
.InnerJoin<SeaExport>((x, s) => x.BusinessId == s.Id)
|
|
|
|
|
.Select((x, s) => new BusinessFeeStatus
|
|
|
|
|
{
|
|
|
|
|
CustomerNo = s.CustomerNo,
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
BusinessId = x.BusinessId,
|
|
|
|
|
BusinessType = x.BusinessType,
|
|
|
|
|
BillAuditStatus = x.BillAuditStatus,
|
|
|
|
|
BillFeeStatusTime = x.BillFeeStatusTime
|
|
|
|
|
BillFeeStatusTime = x.BillFeeStatusTime,
|
|
|
|
|
ProfitMargin = SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == x.BusinessId && f.BusinessType == x.BusinessType && f.FeeType == FeeType.Receivable).Sum(f => f.Amount)
|
|
|
|
|
- SqlFunc.Subqueryable<FeeRecord>().Where(f => f.BusinessId == x.BusinessId && f.BusinessType == x.BusinessType && f.FeeType == FeeType.Payable).Sum(f => f.Amount)
|
|
|
|
|
}).FirstAsync();
|
|
|
|
|
if (biz == null)
|
|
|
|
|
return;
|
|
|
|
@ -64,6 +77,9 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Approve)
|
|
|
|
|
{
|
|
|
|
|
biz.BillAuditStatus = BillAuditStatus.RecvPassed;
|
|
|
|
|
//生成应付确认任务
|
|
|
|
|
await feeService.SubmitBillAuditAsync(callback.BusinessId, callback.BusinessType.GetValueOrDefault(),
|
|
|
|
|
TaskBaseTypeEnum.BILL_PAY_AUDIT, false);
|
|
|
|
|
}
|
|
|
|
|
else if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
|
{
|
|
|
|
@ -127,6 +143,37 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
await ex.LogAsync(Db);
|
|
|
|
|
throw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (biz.ProfitMargin > 0)
|
|
|
|
|
{
|
|
|
|
|
biz.IsFeeLocking = true;
|
|
|
|
|
biz.FeeLockingTime = dtNow;
|
|
|
|
|
biz.FeeLockingUserId = userId;
|
|
|
|
|
biz.FeeLockingUserName = User.UserName;
|
|
|
|
|
|
|
|
|
|
await TenantDb.Updateable(biz).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.IsFeeLocking,
|
|
|
|
|
x.FeeLockingTime,
|
|
|
|
|
x.FeeLockingUserId,
|
|
|
|
|
x.FeeLockingUserName
|
|
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
else //如果为非正利润则生成锁单任务
|
|
|
|
|
{
|
|
|
|
|
var result = await CreateTaskAsync(new TaskCreationRequest
|
|
|
|
|
{
|
|
|
|
|
BusinessId = biz.BusinessId,
|
|
|
|
|
BusinessType = biz.BusinessType,
|
|
|
|
|
TaskTypeName = TaskBaseTypeEnum.BILL_LOCK_AUDIT.ToString(),
|
|
|
|
|
TaskTitle = $"【{TaskBaseTypeEnum.BILL_LOCK_AUDIT.GetDescription()}】{biz.CustomerNo}",
|
|
|
|
|
});
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
logger.LogError($"生成【{TaskBaseTypeEnum.BILL_LOCK_AUDIT.GetDescription()}】任务失败:" + result.Message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|