cjy 3 weeks ago
commit 5189da36bc

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

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

@ -727,7 +727,6 @@ namespace DS.WMS.Core.Fee.Method
if (await taskService.HasAuthorizedAsync())
{
result = await taskService.AuditAsync(request);
if (!result.Succeeded)
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();
return result;
}
@ -807,25 +784,7 @@ namespace DS.WMS.Core.Fee.Method
public async Task<DataResult> UpdateStatusAsync(FlowCallback callback)
{
var auditType = callback.AuditType;
FeeRecord? fee = null;
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(
FeeRecord? fee = await TenantDb.Queryable<FeeRecord>().Where(x => x.Id == callback.BusinessId).Select(
x => new FeeRecord
{
Id = x.Id,
@ -833,12 +792,10 @@ namespace DS.WMS.Core.Fee.Method
BusinessId = x.BusinessId,
BusinessType = x.BusinessType
}).FirstAsync();
if (fee == null)
return DataResult.Failed(MultiLanguageConst.EmptyData);
fee.Reason = callback.RejectReason;
}
if (fee == null)
return DataResult.Failed(MultiLanguageConst.EmptyData);
fee.Reason = callback.RejectReason;
long userId = long.Parse(User.UserId);
DateTime dtNow = DateTime.Now;
await TenantDb.Ado.BeginTranAsync();
@ -940,78 +897,8 @@ namespace DS.WMS.Core.Fee.Method
break;
}
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 feeService.WriteBackStatusAsync(fee.BusinessId, fee.BusinessType);
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;
}
catch (Exception ex)

@ -895,12 +895,14 @@ namespace DS.WMS.Core.Fee.Method
if (taskType == TaskBaseTypeEnum.BILL_RECV_AUDIT)
{
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)
{
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
{

@ -1,4 +1,7 @@
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.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)
{
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.Interface;
using DS.WMS.Core.TaskPlat.Dtos;
using Mapster;
using Masuit.Tools;
using Masuit.Tools.Systems;
@ -52,13 +53,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
bool updateFlag = false;
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))
{
updateFlag = true;
}
else
{
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskExists));
}
long userId = long.Parse(User.UserId);
DateTime dtNow = DateTime.Now;
@ -129,57 +124,54 @@ namespace DS.WMS.Core.TaskInteraction.Method
await LogService.WriteLogAsync(task);
}
//审核任务需创建工作流
if (AuditTaskTypes.Contains(request.TaskType))
result = await CreateAndStartWorkflow(task, false);
if (!result.Succeeded)
return result;
if (updateFlag)
{
result = await CreateAndStartWorkflow(task, false);
result = await SetTaskStatusAsync(new TaskUpdateRequest
{
BusinessId = request.BusinessId,
BusinessType = request.BusinessType,
TaskTypeName = request.TaskTypeName,
TaskStatus = TaskStatusEnum.Create
}, false);
if (!result.Succeeded)
return result;
}
else //费用审核需拆分任务
{
var instance = result.Data as FlowInstance;
var ids = FlowInstanceService.GetMarkers(instance).Select(long.Parse).ToArray();
var recvUserList = await FillInUserInfoAsync(ids);
if (updateFlag)
{
result = await SetTaskStatusAsync(new TaskUpdateRequest
var fee = await TenantDb.Queryable<FeeRecord>().Where(x => x.Id == request.BusinessId)
.Select(x => new
{
BusinessId = request.BusinessId,
BusinessType = request.BusinessType,
TaskTypeName = request.TaskTypeName,
TaskStatus = TaskStatusEnum.Create
}, false);
x.Id,
x.BusinessId,
x.BusinessType
}).FirstAsync();
foreach (var item in recvUserList)
{
var copiedInfo = info.DeepClone();
copiedInfo.Head.BSNO = fee.BusinessId; //替换为费用关联的订单ID
copiedInfo.Main.RecvUserInfoList.Clear();
copiedInfo.Main.RecvUserInfoList.Add(item);
copiedInfo.Main.ExtData = new { fee.BusinessType, FeeId = fee.Id };
result = await ManagerService.InitTaskJob(copiedInfo);
if (!result.Succeeded)
return result;
}
else //费用审核需拆分任务
{
var instance = result.Data as FlowInstance;
var ids = FlowInstanceService.GetMarkers(instance).Select(long.Parse).ToArray();
var recvUserList = await FillInUserInfoAsync(ids);
var fee = await TenantDb.Queryable<FeeRecord>().Where(x => x.Id == request.BusinessId)
.Select(x => new
{
x.Id,
x.BusinessId,
x.BusinessType
}).FirstAsync();
foreach (var item in recvUserList)
{
var copiedInfo = info.DeepClone();
copiedInfo.Head.BSNO = fee.BusinessId; //替换为费用关联的订单ID
copiedInfo.Main.RecvUserInfoList.Clear();
copiedInfo.Main.RecvUserInfoList.Add(item);
copiedInfo.Main.ExtData = new { fee.BusinessType, FeeId = fee.Id };
result = await ManagerService.InitTaskJob(copiedInfo);
if (!result.Succeeded)
{
await Db.Deleteable(instance).ExecuteCommandAsync();
return result;
}
await Db.Deleteable(instance).ExecuteCommandAsync();
return result;
}
}
}
if (useTransaction)
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>()
.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)
{
ArgumentNullException.ThrowIfNull(callback, nameof(callback));
if (callback.AuditType == null || callback.BusinessType == null)
if (callback.AuditType == null)
return;
string remark = "终审完成,审批结果为:" + callback.FlowStatus.GetDescription();
@ -1070,7 +1070,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
RecvUserIdList = [task.CreateBy] //通知任务发起人
};
//创建驳回任务以进行通知
await CreateTaskAsync(request);
await CreateTaskAsync(request, false);
//更新任务描述为驳回原因
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.Fee.Dtos;
using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.TaskInteraction.Dtos;
using DS.WMS.Core.TaskInteraction.Interface;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.FeeApi.Controllers
@ -152,7 +154,7 @@ namespace DS.WMS.FeeApi.Controllers
}
/// <summary>
/// 变更费用审批状态(用于工作流框架的回调)
/// 变更费用审核状态
/// </summary>
/// <param name="callback">回调信息</param>
/// <returns></returns>
@ -164,5 +166,28 @@ namespace DS.WMS.FeeApi.Controllers
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.Method.ReportProviders;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.TaskInteraction.Dtos;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.FeeApi.Controllers
@ -226,29 +227,29 @@ namespace DS.WMS.FeeApi.Controllers
/// <summary>
/// 发起整票审核
/// </summary>
/// <param name="model">业务ID和类型</param>
/// <param name="request">业务ID和类型</param>
/// <returns></returns>
[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)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
if (!ModelState.IsValid)
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>
/// <param name="model">业务ID和类型</param>
/// <param name="request">业务ID和类型</param>
/// <returns></returns>
[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)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
if (!ModelState.IsValid)
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>

Loading…
Cancel
Save