业务相关费用状态表增加枚举

usertest
嵇文龙 6 months ago
parent 091cfba529
commit f2527e5d9e

@ -69,27 +69,51 @@ namespace DS.Module.Core
}
/// <summary>
/// 整单审核状态
/// 业务费用状态
/// </summary>
public enum BillAuditStatus
public enum BillFeeStatus
{
/// <summary>
/// 待审核
/// 未录入
/// </summary>
[Description("待审核")]
PendingAudit = 0,
[Description("未录入")]
NotEntered = 0,
/// <summary>
/// 录入状态
/// </summary>
[Description("录入状态")]
Entering = 1,
/// <summary>
/// 部分录入
/// </summary>
[Description("部分录入")]
PartialEntering = 2,
/// <summary>
/// 审核通过
/// </summary>
[Description("审核通过")]
AuditPassed = 1,
AuditPassed = 3,
/// <summary>
/// 驳回提交
/// </summary>
[Description("驳回提交")]
Rejected = 2
RejectSubmission = 4,
/// <summary>
/// 部分结算
/// </summary>
[Description("部分结算")]
PartialSettlement = 5,
/// <summary>
/// 结算完毕
/// </summary>
[Description("结算完毕")]
SettlementCompleted = 6
}
/// <summary>

@ -14,6 +14,7 @@ using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.Sys.Entity;
using LanguageExt;
using Mapster;
using Masuit.Tools.Systems;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
@ -213,6 +214,7 @@ namespace DS.WMS.Core.Fee.Method
}
//获取汇率
void FetchExchangeRate(SqlSugarScopeProvider tenantDb, IEnumerable<FeeRecord> records)
{
var exRecords = records.Where(x => !x.ExchangeRate.HasValue && x.Currency != DefaultCurrency).ToList();
@ -551,14 +553,27 @@ namespace DS.WMS.Core.Fee.Method
/// <returns></returns>
public DataResult UpdateAuditStatus(FlowCallback callback)
{
var auditType = callback.AuditType.ToEnum<FeeAuditType>();
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var fee = tenantDb.Queryable<FeeRecord>().Where(x => x.Id == callback.BusinessId).Select(
FeeRecord fee = null;
BusinessFeeStatus businessFee = null;
if (auditType == FeeAuditType.Business)
{
businessFee = tenantDb.Queryable<BusinessFeeStatus>().Where(x => x.Id == callback.BusinessId).Select(
x => new BusinessFeeStatus { Id = x.Id, BusinessId = x.BusinessId, BillAuditStatus = x.BillAuditStatus }).First();
if (businessFee == null)
return DataResult.Failed("未能找到业务信息,更新状态失败", MultiLanguageConst.Operation_Failed);
}
else
{
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);
if (fee == null)
return DataResult.Failed("未能找到费用记录,更新状态失败", MultiLanguageConst.Operation_Failed);
fee.Reason = callback.RejectReason;
}
fee.Reason = callback.RejectReason;
var auditType = callback.AuditType.ToEnum<FeeAuditType>();
tenantDb.Ado.BeginTran();
try
{
@ -642,6 +657,31 @@ namespace DS.WMS.Core.Fee.Method
x.FlowId
}).ExecuteCommand();
}
break;
case FeeAuditType.Business:
FeeStatus status = FeeStatus.RejectSubmission;
if (callback.FlowStatus == FlowStatusEnum.Approve)
{
businessFee.BillAuditStatus = BillAuditStatus.AuditPassed;
status = FeeStatus.AuditPassed;
}
else if (callback.FlowStatus == FlowStatusEnum.Reject)
{
businessFee.BillAuditStatus = BillAuditStatus.Rejected;
}
tenantDb.Updateable(businessFee).UpdateColumns(x => new
{
x.BillAuditStatus,
x.FlowId
}).ExecuteCommand();
tenantDb.Updateable<FeeRecord>().
SetColumns(x => x.FeeStatus == status).
SetColumns(x=>x.FlowId == null).
Where(x => x.BusinessId == businessFee.BusinessId &&
(x.FeeStatus == FeeStatus.Entering || x.FeeStatus == FeeStatus.RejectSubmission)).ExecuteCommand();
break;
default:
return DataResult.Failed("费用未处于审批状态,更新状态失败", MultiLanguageConst.Operation_Failed);
@ -741,14 +781,61 @@ namespace DS.WMS.Core.Fee.Method
/// <summary>
/// 整单审核
/// </summary>
/// <param name="type">业务类型</param>
/// <param name="bid">业务ID</param>
/// <returns></returns>
//public DataResult AuditBusiness(int type, long bid)
//{
public DataResult AuditBusiness(BusinessType type, long bid)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var entity = tenantDb.Queryable<BusinessFeeStatus>().Where(x => x.BusinessId == bid &&
x.BusinessType == BusinessType.OceanShippingExport).Select(x => new BusinessFeeStatus
{
Id = x.Id,
IsFeeLocking = x.IsFeeLocking,
BillAuditStatus = x.BillAuditStatus,
FlowId = x.FlowId
}).First();
if (entity == null)
return DataResult.Failed("未能找到业务信息", MultiLanguageConst.Operation_Failed);
if (entity.IsFeeLocking.GetValueOrDefault())
return DataResult.Failed("当前业务已费用锁定,禁止提交", MultiLanguageConst.Operation_Failed);
if (entity.FlowId.HasValue)
return DataResult.Failed($"当前业务正在审批中,无法提交", MultiLanguageConst.Operation_Failed);
if (entity.BillAuditStatus == BillAuditStatus.AuditPassed)
return DataResult.Failed($"当前业务的费用状态为:{entity.BillAuditStatus.GetDescription()},无法提交", MultiLanguageConst.Operation_Failed);
var template = FindTemplate(FeeAuditType.Business.ToString());
if (template == null)
return DataResult.Failed("未能找到审批模板", MultiLanguageConst.Operation_Failed);
var result = flowService.CreateFlowInstance(new CreateFlowInstanceReq { BusinessId = entity.Id, TemplateId = template.Id });
if (result.Succeeded)
{
var instance = result.Data as FlowInstance;
flowService.StartFlowInstance(instance.Id.ToString());
//变更状态为提交审核
entity.BillAuditStatus = BillAuditStatus.AuditSubmitted;
entity.BillFeeStatusTime = DateTime.Now;
entity.FlowId = instance.Id;
//}
tenantDb.Updateable(entity).UpdateColumns(x => new
{
x.BillAuditStatus,
x.BillFeeStatusTime,
x.FlowId
}).ExecuteCommand();
tenantDb.Ado.CommitTran();
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
}
return DataResult.Failed("创建工作流失败", MultiLanguageConst.Operation_Failed);
}
//回写业务主表的费用状态
void WriteBackStatus(SqlSugarScopeProvider tenantDb, List<FeeRecord> fees)
{

@ -1,4 +1,5 @@
using DS.Module.Core;
using System.ComponentModel;
using DS.Module.Core;
using DS.Module.Core.Data;
using SqlSugar;
@ -9,7 +10,7 @@ namespace DS.WMS.Core.Op.Entity
/// </summary>
[SqlSugar.SugarTable("op_business_fee_status", "业务相关费用状态表")]
public class BusinessFeeStatus : BaseModel<long>
{
{
/// <summary>
/// 业务Id
/// </summary>
@ -21,19 +22,19 @@ namespace DS.WMS.Core.Op.Entity
/// 业务类型 1.海运出口
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "业务类型 1.海运出口", IsNullable = false, DefaultValue = "1")]
public int BusinessType { get; set; } = 1;
public BusinessType BusinessType { get; set; } = BusinessType.OceanShippingExport;
/// <summary>
/// 应收费用状态
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "应收费用状态", IsNullable = false, DefaultValue ="0")]
public int ARFeeStatus { get; set; } = 0;
[SqlSugar.SugarColumn(ColumnDescription = "应收费用状态", IsNullable = false, DefaultValue = "0")]
public BillFeeStatus ARFeeStatus { get; set; } = BillFeeStatus.NotEntered;
/// <summary>
/// 应付费用状态
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "应付费用状态", IsNullable = false, DefaultValue = "0")]
public int APFeeStatus { get; set; } = 0;
public BillFeeStatus APFeeStatus { get; set; } = BillFeeStatus.NotEntered;
/// <summary>
/// 应收开票状态
@ -76,6 +77,10 @@ namespace DS.WMS.Core.Op.Entity
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "整单费用状态时间", IsNullable = true)]
public DateTime BillFeeStatusTime { get; set; }
[SugarColumn(ColumnDescription = "当前审批工作流ID", IsNullable = true)]
public long? FlowId { get; set; }
/// <summary>
/// 业务初始化费用状态
/// </summary>
@ -90,12 +95,58 @@ namespace DS.WMS.Core.Op.Entity
APFeeStatus = 0,
ARInvoiceStatus = 0,
APInvoiceStatus = 0,
ARCheckStatus = 0,
IsBusinessLocking = false,
ARCheckStatus = 0,
IsBusinessLocking = false,
IsFeeLocking = false,
BillAuditStatus = BillAuditStatus.PendingAudit,
BillAuditStatus = BillAuditStatus.Pending,
//BillFeeStatusTime = null,
};
}
}
/// <summary>
/// 业务类型
/// </summary>
public enum BusinessType
{
/// <summary>
/// 海运出口
/// </summary>
OceanShippingExport = 1,
/// <summary>
/// 海运进口
/// </summary>
OceanShippingImport = 2
}
/// <summary>
/// 整单审核状态
/// </summary>
public enum BillAuditStatus
{
/// <summary>
/// 待提交
/// </summary>
[Description("待提交")]
Pending = 0,
/// <summary>
/// 提交审核
/// </summary>
[Description("提交审核")]
AuditSubmitted = 1,
/// <summary>
/// 审核通过
/// </summary>
[Description("审核通过")]
AuditPassed = 2,
/// <summary>
/// 驳回提交
/// </summary>
[Description("驳回提交")]
Rejected = 3
}
}

Loading…
Cancel
Save