cjy 4 weeks ago
commit 5189da36bc

@ -629,11 +629,12 @@ public static class MultiLanguageConst
public const string AuditUnauthorization = "Audit_Unauthorized"; public const string AuditUnauthorization = "Audit_Unauthorized";
[Description("当前暂无待审批的项")] [Description("当前暂无待审批的项")]
public const string NoAuditItems = "No_Audit_Items"; public const string NoAuditItems = "No_Audit_Items";
[Description("所选项正在进行审批")] [Description("所选项正在进行审批")]
public const string ItemsAreAuditing = "Items_Are_Auditing"; public const string ItemsAreAuditing = "Items_Are_Auditing";
[Description("没有找到费用名称")] [Description("没有找到费用名称")]
public const string NoFeeName = "NoFeeName"; public const string NoFeeName = "NoFeeName";
[Description("无法执行操作,当前订单的整票费用审核状态为:{0}")]
public const string BillFeeStatusError = "BillRecvStatusError";
#endregion #endregion
#region 申请相关 #region 申请相关

@ -166,7 +166,7 @@ namespace DS.Module.Core
/// <summary> /// <summary>
/// 待提交 /// 待提交
/// </summary> /// </summary>
[Description("待提交")] [Description("应收待提交")]
Pending = 0, Pending = 0,
/// <summary> /// <summary>

@ -727,7 +727,6 @@ namespace DS.WMS.Core.Fee.Method
if (await taskService.HasAuthorizedAsync()) if (await taskService.HasAuthorizedAsync())
{ {
result = await taskService.AuditAsync(request); result = await taskService.AuditAsync(request);
if (!result.Succeeded) if (!result.Succeeded)
return result; return result;
} }
@ -751,28 +750,6 @@ namespace DS.WMS.Core.Fee.Method
} }
} }
//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(); await TenantDb.Ado.CommitTranAsync();
return result; return result;
} }
@ -807,25 +784,7 @@ namespace DS.WMS.Core.Fee.Method
public async Task<DataResult> UpdateStatusAsync(FlowCallback callback) public async Task<DataResult> UpdateStatusAsync(FlowCallback callback)
{ {
var auditType = callback.AuditType; var auditType = callback.AuditType;
FeeRecord? fee = null; FeeRecord? fee = await TenantDb.Queryable<FeeRecord>().Where(x => x.Id == callback.BusinessId).Select(
BusinessFeeStatus? biz = null;
if (auditType == TaskBaseTypeEnum.BILL_RECV_AUDIT || auditType == TaskBaseTypeEnum.BILL_PAY_AUDIT)
{
biz = await TenantDb.Queryable<BusinessFeeStatus>().Where(x => x.Id == callback.BusinessId && x.BusinessType == callback.BusinessType)
.Select(x => new BusinessFeeStatus
{
Id = x.Id,
BillAuditStatus = x.BillAuditStatus,
BillFeeStatusTime = x.BillFeeStatusTime,
ARFeeStatus = x.ARFeeStatus,
APFeeStatus = x.APFeeStatus
}).FirstAsync();
if (biz == null)
return DataResult.Failed(MultiLanguageConst.EmptyData);
}
else
{
fee = await TenantDb.Queryable<FeeRecord>().Where(x => x.Id == callback.BusinessId).Select(
x => new FeeRecord x => new FeeRecord
{ {
Id = x.Id, Id = x.Id,
@ -837,8 +796,6 @@ namespace DS.WMS.Core.Fee.Method
return DataResult.Failed(MultiLanguageConst.EmptyData); return DataResult.Failed(MultiLanguageConst.EmptyData);
fee.Reason = callback.RejectReason; fee.Reason = callback.RejectReason;
}
long userId = long.Parse(User.UserId); long userId = long.Parse(User.UserId);
DateTime dtNow = DateTime.Now; DateTime dtNow = DateTime.Now;
await TenantDb.Ado.BeginTranAsync(); await TenantDb.Ado.BeginTranAsync();
@ -940,78 +897,8 @@ namespace DS.WMS.Core.Fee.Method
break; break;
} }
if (auditType == TaskBaseTypeEnum.BILL_RECV_AUDIT) await feeService.WriteBackStatusAsync(fee.BusinessId, fee.BusinessType);
{
FeeStatus status = FeeStatus.RejectSubmission;
if (callback.FlowStatus == FlowStatusEnum.Approve)
{
biz.BillAuditStatus = BillAuditStatus.RecvPassed;
biz.ARFeeStatus = BillFeeStatus.AuditPassed;
status = FeeStatus.AuditPassed;
}
else if (callback.FlowStatus == FlowStatusEnum.Reject)
{
biz.BillAuditStatus = BillAuditStatus.RecvRejected;
biz.ARFeeStatus = BillFeeStatus.RejectSubmission;
}
biz.BillFeeStatusTime = dtNow;
await TenantDb.Updateable(biz).UpdateColumns(x => new
{
x.BillAuditStatus,
x.BillFeeStatusTime,
x.ARFeeStatus
}).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)
.ExecuteCommandAsync();
}
else if (auditType == TaskBaseTypeEnum.BILL_PAY_AUDIT)
{
FeeStatus status = FeeStatus.RejectSubmission;
if (callback.FlowStatus == FlowStatusEnum.Approve)
{
biz.BillAuditStatus = BillAuditStatus.PayPassed;
biz.APFeeStatus = BillFeeStatus.AuditPassed;
status = FeeStatus.AuditPassed;
}
else if (callback.FlowStatus == FlowStatusEnum.Reject)
{
biz.BillAuditStatus = BillAuditStatus.PayRejected;
biz.APFeeStatus = BillFeeStatus.RejectSubmission;
}
biz.BillFeeStatusTime = dtNow;
await TenantDb.Updateable(biz).UpdateColumns(x => new
{
x.BillAuditStatus,
x.BillFeeStatusTime,
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)
.ExecuteCommandAsync();
}
await TenantDb.Ado.CommitTranAsync(); await TenantDb.Ado.CommitTranAsync();
if (auditType != TaskBaseTypeEnum.BILL_RECV_AUDIT && auditType != TaskBaseTypeEnum.BILL_PAY_AUDIT)
{
await feeService.WriteBackStatusAsync(
biz != null ? biz.BusinessId : fee.BusinessId,
biz != null ? biz.BusinessType : fee.BusinessType);
}
return DataResult.Success; return DataResult.Success;
} }
catch (Exception ex) catch (Exception ex)

@ -895,12 +895,14 @@ namespace DS.WMS.Core.Fee.Method
if (taskType == TaskBaseTypeEnum.BILL_RECV_AUDIT) if (taskType == TaskBaseTypeEnum.BILL_RECV_AUDIT)
{ {
if (entity.BillAuditStatus != BillAuditStatus.Pending && entity.BillAuditStatus != BillAuditStatus.RecvRejected) if (entity.BillAuditStatus != BillAuditStatus.Pending && entity.BillAuditStatus != BillAuditStatus.RecvRejected)
return DataResult.Failed(string.Format(MultiLanguageConst.BusinessStatusError, entity.BillAuditStatus.GetDescription())); return DataResult.Failed(string.Format(
MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BillFeeStatusError)), entity.BillAuditStatus.GetDescription()));
} }
else if (taskType == TaskBaseTypeEnum.BILL_PAY_AUDIT) else if (taskType == TaskBaseTypeEnum.BILL_PAY_AUDIT)
{ {
if (entity.BillAuditStatus != BillAuditStatus.RecvPassed && entity.BillAuditStatus != BillAuditStatus.PayRejected) if (entity.BillAuditStatus != BillAuditStatus.RecvPassed && entity.BillAuditStatus != BillAuditStatus.PayRejected)
return DataResult.Failed(string.Format(MultiLanguageConst.BusinessStatusError, entity.BillAuditStatus.GetDescription())); return DataResult.Failed(string.Format(
MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BillFeeStatusError)), entity.BillAuditStatus.GetDescription()));
} }
else else
{ {

@ -1,4 +1,7 @@
using DS.Module.Core; using DS.Module.Core;
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.Dtos;
using DS.WMS.Core.TaskInteraction.Interface; using DS.WMS.Core.TaskInteraction.Interface;
@ -17,9 +20,117 @@ namespace DS.WMS.Core.TaskInteraction.Method
{ {
} }
/// <summary>
/// 批量创建
/// </summary>
/// <param name="request"></param>
/// <param name="useTransaction"></param>
/// <returns></returns>
public override Task<DataResult> CreateMultipleTaskAsync(TaskCreationRequest request, bool useTransaction = true) public override Task<DataResult> CreateMultipleTaskAsync(TaskCreationRequest request, bool useTransaction = true)
{ {
return Task.FromResult(DataResult.Failed("不支持批量提交整票审核任务")); return Task.FromResult(DataResult.Failed("不支持批量提交整票审核任务"));
} }
/// <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.Id == callback.BusinessId && x.BusinessType == callback.BusinessType)
.Select(x => new BusinessFeeStatus
{
Id = x.Id,
BillAuditStatus = x.BillAuditStatus,
BillFeeStatusTime = x.BillFeeStatusTime,
ARFeeStatus = x.ARFeeStatus,
APFeeStatus = x.APFeeStatus
}).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)
{
FeeStatus status = FeeStatus.RejectSubmission;
if (callback.FlowStatus == FlowStatusEnum.Approve)
{
biz.BillAuditStatus = BillAuditStatus.RecvPassed;
biz.ARFeeStatus = BillFeeStatus.AuditPassed;
status = FeeStatus.AuditPassed;
}
else if (callback.FlowStatus == FlowStatusEnum.Reject)
{
biz.BillAuditStatus = BillAuditStatus.RecvRejected;
biz.ARFeeStatus = BillFeeStatus.RejectSubmission;
}
biz.BillFeeStatusTime = dtNow;
await TenantDb.Updateable(biz).UpdateColumns(x => new
{
x.BillAuditStatus,
x.BillFeeStatusTime,
x.ARFeeStatus
}).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)
.ExecuteCommandAsync();
}
else if (auditType == TaskBaseTypeEnum.BILL_PAY_AUDIT)
{
FeeStatus status = FeeStatus.RejectSubmission;
if (callback.FlowStatus == FlowStatusEnum.Approve)
{
biz.BillAuditStatus = BillAuditStatus.PayPassed;
biz.APFeeStatus = BillFeeStatus.AuditPassed;
status = FeeStatus.AuditPassed;
}
else if (callback.FlowStatus == FlowStatusEnum.Reject)
{
biz.BillAuditStatus = BillAuditStatus.PayRejected;
biz.APFeeStatus = BillFeeStatus.RejectSubmission;
}
biz.BillFeeStatusTime = dtNow;
await TenantDb.Updateable(biz).UpdateColumns(x => new
{
x.BillAuditStatus,
x.BillFeeStatusTime,
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)
.ExecuteCommandAsync();
}
await base.UpdateBusinessAsync(callback);
await TenantDb.Ado.CommitTranAsync();
}
catch (Exception ex)
{
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
throw;
}
}
} }
} }

@ -8,6 +8,7 @@ using DS.WMS.Core.TaskInteraction.Dtos;
using DS.WMS.Core.TaskInteraction.Entity; using DS.WMS.Core.TaskInteraction.Entity;
using DS.WMS.Core.TaskInteraction.Interface; using DS.WMS.Core.TaskInteraction.Interface;
using DS.WMS.Core.TaskPlat.Dtos; using DS.WMS.Core.TaskPlat.Dtos;
using Mapster;
using Masuit.Tools; using Masuit.Tools;
using Masuit.Tools.Systems; using Masuit.Tools.Systems;
@ -52,13 +53,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
bool updateFlag = false; bool updateFlag = false;
var task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).FirstAsync(); var task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).FirstAsync();
if (task != null && AuditTaskTypes.Contains(request.TaskType) && (task.TaskStatus == TaskStatusEnum.Pending || task.TaskStatus == TaskStatusEnum.Cancel)) if (task != null && AuditTaskTypes.Contains(request.TaskType) && (task.TaskStatus == TaskStatusEnum.Pending || task.TaskStatus == TaskStatusEnum.Cancel))
{
updateFlag = true; updateFlag = true;
}
else
{
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskExists));
}
long userId = long.Parse(User.UserId); long userId = long.Parse(User.UserId);
DateTime dtNow = DateTime.Now; DateTime dtNow = DateTime.Now;
@ -129,9 +124,6 @@ namespace DS.WMS.Core.TaskInteraction.Method
await LogService.WriteLogAsync(task); await LogService.WriteLogAsync(task);
} }
//审核任务需创建工作流
if (AuditTaskTypes.Contains(request.TaskType))
{
result = await CreateAndStartWorkflow(task, false); result = await CreateAndStartWorkflow(task, false);
if (!result.Succeeded) if (!result.Succeeded)
return result; return result;
@ -178,7 +170,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
} }
} }
} }
}
if (useTransaction) if (useTransaction)
await TenantDb.Ado.CommitTranAsync(); await TenantDb.Ado.CommitTranAsync();
@ -450,7 +442,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
} }
//获取指定业务的所有关联费用类任务 //获取指定业务的所有关联费用类任务
internal async Task<List<BusinessTask>> GetFeeTasks(BusinessType bsType, long[] bsIds, params long[] excludeFeeIds) async Task<List<BusinessTask>> GetFeeTasks(BusinessType bsType, long[] bsIds, params long[] excludeFeeIds)
{ {
return await TenantDb.Queryable<BusinessTask>() return await TenantDb.Queryable<BusinessTask>()
.InnerJoin<FeeRecord>((t, f) => t.BusinessId == f.Id) .InnerJoin<FeeRecord>((t, f) => t.BusinessId == f.Id)

@ -1055,7 +1055,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
public virtual async Task UpdateBusinessAsync(FlowCallback callback) public virtual async Task UpdateBusinessAsync(FlowCallback callback)
{ {
ArgumentNullException.ThrowIfNull(callback, nameof(callback)); ArgumentNullException.ThrowIfNull(callback, nameof(callback));
if (callback.AuditType == null || callback.BusinessType == null) if (callback.AuditType == null)
return; return;
string remark = "终审完成,审批结果为:" + callback.FlowStatus.GetDescription(); string remark = "终审完成,审批结果为:" + callback.FlowStatus.GetDescription();
@ -1070,7 +1070,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
RecvUserIdList = [task.CreateBy] //通知任务发起人 RecvUserIdList = [task.CreateBy] //通知任务发起人
}; };
//创建驳回任务以进行通知 //创建驳回任务以进行通知
await CreateTaskAsync(request); await CreateTaskAsync(request, false);
//更新任务描述为驳回原因 //更新任务描述为驳回原因
await SetTaskBaseDescription(callback.BusinessId, request.TaskType, callback.RejectReason!); await SetTaskBaseDescription(callback.BusinessId, request.TaskType, callback.RejectReason!);

@ -1,9 +1,11 @@
using DS.Module.Core; using System.Net;
using DS.Module.Core;
using DS.WMS.Core.Application.Dtos; using DS.WMS.Core.Application.Dtos;
using DS.WMS.Core.Fee.Dtos; using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Interface; using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Flow.Dtos; using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.TaskInteraction.Dtos; using DS.WMS.Core.TaskInteraction.Dtos;
using DS.WMS.Core.TaskInteraction.Interface;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.FeeApi.Controllers namespace DS.WMS.FeeApi.Controllers
@ -152,7 +154,7 @@ namespace DS.WMS.FeeApi.Controllers
} }
/// <summary> /// <summary>
/// 变更费用审批状态(用于工作流框架的回调) /// 变更费用审核状态
/// </summary> /// </summary>
/// <param name="callback">回调信息</param> /// <param name="callback">回调信息</param>
/// <returns></returns> /// <returns></returns>
@ -164,5 +166,28 @@ namespace DS.WMS.FeeApi.Controllers
return await _auditService.UpdateStatusAsync(callback); return await _auditService.UpdateStatusAsync(callback);
} }
/// <summary>
/// 整票审核回调
/// </summary>
/// <param name="service"></param>
/// <param name="callback">回调信息</param>
/// <returns></returns>
[HttpPost, Route("BillCallback")]
public async Task<IActionResult> BillCallbackAsync([FromServices] IFeeBillTaskService service, [FromBody] FlowCallback callback)
{
if (callback == null)
return BadRequest("参数无效");
try
{
await service.UpdateBusinessAsync(callback);
return Ok();
}
catch (Exception ex)
{
return StatusCode((int)HttpStatusCode.InternalServerError, ex.Message);
}
}
} }
} }

@ -5,6 +5,7 @@ using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface; using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Fee.Method.ReportProviders; using DS.WMS.Core.Fee.Method.ReportProviders;
using DS.WMS.Core.Op.Entity; using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.TaskInteraction.Dtos;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.FeeApi.Controllers namespace DS.WMS.FeeApi.Controllers
@ -226,29 +227,29 @@ namespace DS.WMS.FeeApi.Controllers
/// <summary> /// <summary>
/// 发起整票审核 /// 发起整票审核
/// </summary> /// </summary>
/// <param name="model">业务ID和类型</param> /// <param name="request">业务ID和类型</param>
/// <returns></returns> /// <returns></returns>
[HttpPost, Route("ApplyBusinessAudit")] [HttpPost, Route("ApplyBusinessAudit")]
public async Task<DataResult> ApplyBillAuditAsync([FromBody] IdModel<TaskBaseTypeEnum> model) public async Task<DataResult> ApplyBillAuditAsync([FromBody] TaskRequest request)
{ {
if (!long.TryParse(model.Id, out long bid) || model.BusinessType == null) if (!ModelState.IsValid)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest); return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
return await _feeService.SubmitBillAuditAsync(bid, (BusinessType)model.BusinessType.Value, model.Value); return await _feeService.SubmitBillAuditAsync(request.BusinessId, request.BusinessType.GetValueOrDefault(), request.TaskType);
} }
/// <summary> /// <summary>
/// 撤销整票审核 /// 撤销整票审核
/// </summary> /// </summary>
/// <param name="model">业务ID和类型</param> /// <param name="request">业务ID和类型</param>
/// <returns></returns> /// <returns></returns>
[HttpPost, Route("WithdrawBusiness")] [HttpPost, Route("WithdrawBusiness")]
public async Task<DataResult> WithdrawBillAsync([FromBody] IdModel<TaskBaseTypeEnum> model) public async Task<DataResult> WithdrawBillAsync([FromBody] TaskRequest request)
{ {
if (!long.TryParse(model.Id, out long bid) || model.BusinessType == null) if (!ModelState.IsValid)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest); return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
return await _feeService.WithdrawBillAsync(bid, (BusinessType)model.BusinessType.Value, model.Value); return await _feeService.WithdrawBillAsync(request.BusinessId, request.BusinessType.GetValueOrDefault(), request.TaskType);
} }
/// <summary> /// <summary>

Loading…
Cancel
Save