|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using System.Text;
|
|
|
|
|
using AngleSharp.Dom;
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
@ -311,7 +312,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 发起审批工作流
|
|
|
|
|
/// 发起审批/申请删除工作流
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="auditType">审批类型</param>
|
|
|
|
|
/// <param name="idArray">费用记录ID</param>
|
|
|
|
@ -340,7 +341,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
if (fees.Any(x => x.FeeStatus == FeeStatus.PartialSettlement || x.FeeStatus == FeeStatus.SettlementCompleted))
|
|
|
|
|
return DataResult.Failed($"当前审批费用包含已结算/部分结算的费用,无法提交", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
|
|
|
|
|
DataResult result = null;
|
|
|
|
|
DataResult result = DataResult.Failed(string.Empty, MultiLanguageConst.Operation_Failed);
|
|
|
|
|
tenantDb.Ado.BeginTran();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
@ -348,10 +349,6 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
{
|
|
|
|
|
result = ApplyAudit(tenantDb, fees);
|
|
|
|
|
}
|
|
|
|
|
else if (auditType == FeeAuditType.ApplyModification)
|
|
|
|
|
{
|
|
|
|
|
ApplyModify(tenantDb, fees);
|
|
|
|
|
}
|
|
|
|
|
else if (auditType == FeeAuditType.ApplyDeletion)
|
|
|
|
|
{
|
|
|
|
|
result = ApplyDelete(tenantDb, fees);
|
|
|
|
@ -421,8 +418,8 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//审核通过->申请修改
|
|
|
|
|
DataResult ApplyModify(SqlSugarScopeProvider tenantDb, List<FeeRecord> fees)
|
|
|
|
|
//审核通过->申请删除
|
|
|
|
|
DataResult ApplyDelete(SqlSugarScopeProvider tenantDb, List<FeeRecord> fees)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
foreach (var fe in fees)
|
|
|
|
@ -436,11 +433,10 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
if (sb.Length > 0)
|
|
|
|
|
return DataResult.Failed(sb.ToString(), MultiLanguageConst.Operation_Failed);
|
|
|
|
|
|
|
|
|
|
var template = FindTemplate(FeeAuditType.ApplyModification.ToString());
|
|
|
|
|
var template = FindTemplate(FeeAuditType.ApplyDeletion.ToString());
|
|
|
|
|
if (template == null)
|
|
|
|
|
return DataResult.Failed("未能找到审批模板", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
|
|
|
|
|
List<FeeModification> list = new List<FeeModification>(fees.Count);
|
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
|
foreach (var item in fees)
|
|
|
|
|
{
|
|
|
|
@ -450,27 +446,33 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
var instance = result.Data as FlowInstance;
|
|
|
|
|
flowService.StartFlowInstance(instance.Id.ToString());
|
|
|
|
|
|
|
|
|
|
//变更状态为申请修改
|
|
|
|
|
item.FeeStatus = FeeStatus.ApplyModification;
|
|
|
|
|
//变更状态为申请删除
|
|
|
|
|
item.FeeStatus = FeeStatus.ApplyDeletion;
|
|
|
|
|
item.SubmitBy = long.Parse(user.UserId);
|
|
|
|
|
item.SubmitDate = dtNow;
|
|
|
|
|
item.FlowId = instance.Id;
|
|
|
|
|
|
|
|
|
|
FeeModification modification = item.Adapt<FeeModification>();
|
|
|
|
|
modification.Id = 0;
|
|
|
|
|
modification.FeeRecordId = item.Id;
|
|
|
|
|
list.Add(modification);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tenantDb.Insertable(list).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//审核通过->申请删除
|
|
|
|
|
DataResult ApplyDelete(SqlSugarScopeProvider tenantDb, List<FeeRecord> fees)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 发起费用修改申请
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="items">费用修改信息</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult SubmitForModification(IEnumerable<FeeModification> items)
|
|
|
|
|
{
|
|
|
|
|
var idList = items.Select(x => x.FeeRecordId).Distinct().ToList();
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
var fees = tenantDb.Queryable<FeeRecord>().Select(x => new FeeRecord
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
FeeName = x.FeeName,
|
|
|
|
|
FeeStatus = x.FeeStatus
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
foreach (var fe in fees)
|
|
|
|
|
{
|
|
|
|
@ -483,28 +485,42 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
if (sb.Length > 0)
|
|
|
|
|
return DataResult.Failed(sb.ToString(), MultiLanguageConst.Operation_Failed);
|
|
|
|
|
|
|
|
|
|
var template = FindTemplate(FeeAuditType.ApplyDeletion.ToString());
|
|
|
|
|
var template = FindTemplate(FeeAuditType.ApplyModification.ToString());
|
|
|
|
|
if (template == null)
|
|
|
|
|
return DataResult.Failed("未能找到审批模板", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
|
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
|
foreach (var item in fees)
|
|
|
|
|
tenantDb.Ado.BeginTran();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var result = flowService.CreateFlowInstance(new CreateFlowInstanceReq { BusinessId = item.Id, TemplateId = template.Id });
|
|
|
|
|
if (result.Succeeded)
|
|
|
|
|
foreach (var fee in fees)
|
|
|
|
|
{
|
|
|
|
|
var instance = result.Data as FlowInstance;
|
|
|
|
|
flowService.StartFlowInstance(instance.Id.ToString());
|
|
|
|
|
|
|
|
|
|
//变更状态为申请删除
|
|
|
|
|
item.FeeStatus = FeeStatus.ApplyDeletion;
|
|
|
|
|
item.SubmitBy = long.Parse(user.UserId);
|
|
|
|
|
item.SubmitDate = dtNow;
|
|
|
|
|
item.FlowId = instance.Id;
|
|
|
|
|
var result = flowService.CreateFlowInstance(new CreateFlowInstanceReq { BusinessId = fee.Id, TemplateId = template.Id });
|
|
|
|
|
if (result.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
var instance = result.Data as FlowInstance;
|
|
|
|
|
flowService.StartFlowInstance(instance.Id.ToString());
|
|
|
|
|
|
|
|
|
|
//变更状态为申请修改
|
|
|
|
|
fee.FeeStatus = FeeStatus.ApplyModification;
|
|
|
|
|
fee.SubmitBy = long.Parse(user.UserId);
|
|
|
|
|
fee.SubmitDate = dtNow;
|
|
|
|
|
fee.FlowId = instance.Id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
tenantDb.Insertable<FeeModification>(items).ExecuteCommand();
|
|
|
|
|
tenantDb.Updateable<FeeRecord>(fees).UpdateColumns(x => new { x.FeeStatus, x.FlowId }).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
tenantDb.Ado.CommitTran();
|
|
|
|
|
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
|
//todo:记录错误日志
|
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -515,15 +531,12 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
public DataResult UpdateAuditStatus(FlowCallback callback)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
var fee = tenantDb.Queryable<FeeRecord>().Where(x => x.Id == callback.BusinessId).Select(x => new { x.Id, x.FeeStatus }).First();
|
|
|
|
|
var fee = tenantDb.Queryable<FeeRecord>().Where(x => x.Id == callback.BusinessId).Select(
|
|
|
|
|
x => new FeeRecord { Id = x.Id, FeeStatus = x.FeeStatus }).First();
|
|
|
|
|
if (fee == null)
|
|
|
|
|
return DataResult.Failed("未能找到费用记录,更新状态失败", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
|
|
|
|
|
var entity = new FeeRecord
|
|
|
|
|
{
|
|
|
|
|
Id = fee.Id,
|
|
|
|
|
Reason = callback.RejectReason
|
|
|
|
|
};
|
|
|
|
|
fee.Reason = callback.RejectReason;
|
|
|
|
|
var auditType = callback.AuditType.ToEnum<FeeAuditType>();
|
|
|
|
|
tenantDb.Ado.BeginTran();
|
|
|
|
|
try
|
|
|
|
@ -531,62 +544,80 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
switch (auditType)
|
|
|
|
|
{
|
|
|
|
|
case FeeAuditType.ApplyAudit:
|
|
|
|
|
entity.AuditBy = long.Parse(user.UserId);
|
|
|
|
|
entity.AuditDate = DateTime.Now;
|
|
|
|
|
fee.AuditBy = long.Parse(user.UserId);
|
|
|
|
|
fee.AuditDate = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Approve)
|
|
|
|
|
{
|
|
|
|
|
entity.FeeStatus = FeeStatus.AuditPassed;
|
|
|
|
|
entity.Reason = string.Empty;
|
|
|
|
|
fee.FeeStatus = FeeStatus.AuditPassed;
|
|
|
|
|
fee.Reason = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
else if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
|
entity.FeeStatus = FeeStatus.RejectSubmission;
|
|
|
|
|
fee.FeeStatus = FeeStatus.RejectSubmission;
|
|
|
|
|
|
|
|
|
|
tenantDb.Updateable(entity).UpdateColumns(x => new
|
|
|
|
|
tenantDb.Updateable(fee).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.Id,
|
|
|
|
|
x.FeeStatus,
|
|
|
|
|
x.AuditBy,
|
|
|
|
|
x.AuditDate,
|
|
|
|
|
x.Reason,
|
|
|
|
|
x.FlowId
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FeeAuditType.ApplyModification:
|
|
|
|
|
//申请修改审核成功需要回填费用信息
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Approve)
|
|
|
|
|
{
|
|
|
|
|
entity.FeeStatus = FeeStatus.AuditPassed;
|
|
|
|
|
entity.Reason = string.Empty;
|
|
|
|
|
fee.FeeStatus = FeeStatus.AuditPassed;
|
|
|
|
|
fee.Reason = string.Empty;
|
|
|
|
|
|
|
|
|
|
var fm = tenantDb.Queryable<FeeModification>().Where(x => x.FeeRecordId == fee.Id).OrderByDescending(x => x.CreateTime).First();
|
|
|
|
|
if (fm == null)
|
|
|
|
|
return DataResult.Failed("未找到费用修改信息,更新失败", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
|
|
|
|
|
var entity = fm.Adapt<FeeRecord>();
|
|
|
|
|
entity.FeeStatus = FeeStatus.AuditPassed;
|
|
|
|
|
entity.Reason = callback.RejectReason;
|
|
|
|
|
fee = entity;
|
|
|
|
|
|
|
|
|
|
fm.Deleted = true;
|
|
|
|
|
fm.DeleteTime = DateTime.Now;
|
|
|
|
|
fm.DeleteBy = long.Parse(user.UserId);
|
|
|
|
|
tenantDb.Updateable(fm).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.Id,
|
|
|
|
|
x.DeleteBy,
|
|
|
|
|
x.Deleted,
|
|
|
|
|
x.DeleteTime
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
else if (callback.FlowStatus == FlowStatusEnum.Reject)
|
|
|
|
|
entity.FeeStatus = FeeStatus.RejectApplication;
|
|
|
|
|
fee.FeeStatus = FeeStatus.RejectApplication;
|
|
|
|
|
|
|
|
|
|
tenantDb.Updateable(entity).UpdateColumns(x => new
|
|
|
|
|
tenantDb.Updateable(fee).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.Id,
|
|
|
|
|
x.FeeStatus,
|
|
|
|
|
x.AuditBy,
|
|
|
|
|
x.AuditDate,
|
|
|
|
|
x.Reason,
|
|
|
|
|
x.FlowId
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
break;
|
|
|
|
|
case FeeAuditType.ApplyDeletion:
|
|
|
|
|
if (callback.FlowStatus == FlowStatusEnum.Approve)
|
|
|
|
|
{
|
|
|
|
|
tenantDb.Deleteable(entity).ExecuteCommand();
|
|
|
|
|
tenantDb.Deleteable(fee).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
entity.FeeStatus = FeeStatus.RejectApplication;
|
|
|
|
|
fee.FeeStatus = FeeStatus.RejectApplication;
|
|
|
|
|
|
|
|
|
|
tenantDb.Updateable(entity).UpdateColumns(x => new
|
|
|
|
|
tenantDb.Updateable(fee).UpdateColumns(x => new
|
|
|
|
|
{
|
|
|
|
|
x.Id,
|
|
|
|
|
x.FeeStatus,
|
|
|
|
|
x.AuditBy,
|
|
|
|
|
x.AuditDate,
|
|
|
|
|
x.Reason,
|
|
|
|
|
x.FlowId
|
|
|
|
|
}).ExecuteCommand();
|
|
|
|
|
}
|
|
|
|
@ -613,6 +644,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
tenantDb.Ado.RollbackTran();
|
|
|
|
|
//todo:记录错误日志
|
|
|
|
|
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -644,12 +676,12 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
return DataResult.Failed($"以下费用项:{msg} 未在审批状态中,无需撤销", MultiLanguageConst.Operation_Failed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var flows = fees.Select(x => new FlowInstance { Id = x.FlowId.Value });
|
|
|
|
|
var flows = fees.Select(x => new FlowInstance { Id = x.FlowId.Value, FlowStatus = (int)FlowStatusEnum.Draft, MakerList = string.Empty });
|
|
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
tenantDb.Ado.BeginTran();
|
|
|
|
|
tenantDb.Deleteable<FlowInstance>(flows).ExecuteCommand();
|
|
|
|
|
tenantDb.Updateable<FlowInstance>(flows).UpdateColumns(x => new { x.FlowStatus, x.MakerList }).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
foreach (var item in fees)
|
|
|
|
|
{
|
|
|
|
@ -685,6 +717,16 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 整单审核
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bid">业务ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
//public DataResult AuditBusiness(int type, long bid)
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查找模板
|
|
|
|
|
/// </summary>
|
|
|
|
|