diff --git a/ds-wms-service/DS.Module.Core/Enums/FeeStatus.cs b/ds-wms-service/DS.Module.Core/Enums/FeeStatus.cs
index b8c9b397..b0694487 100644
--- a/ds-wms-service/DS.Module.Core/Enums/FeeStatus.cs
+++ b/ds-wms-service/DS.Module.Core/Enums/FeeStatus.cs
@@ -69,27 +69,51 @@ namespace DS.Module.Core
}
///
- /// 整单审核状态
+ /// 业务费用状态
///
- public enum BillAuditStatus
+ public enum BillFeeStatus
{
///
- /// 待审核
+ /// 未录入
///
- [Description("待审核")]
- PendingAudit = 0,
+ [Description("未录入")]
+ NotEntered = 0,
+
+ ///
+ /// 录入状态
+ ///
+ [Description("录入状态")]
+ Entering = 1,
+
+ ///
+ /// 部分录入
+ ///
+ [Description("部分录入")]
+ PartialEntering = 2,
///
/// 审核通过
///
[Description("审核通过")]
- AuditPassed = 1,
+ AuditPassed = 3,
///
/// 驳回提交
///
[Description("驳回提交")]
- Rejected = 2
+ RejectSubmission = 4,
+
+ ///
+ /// 部分结算
+ ///
+ [Description("部分结算")]
+ PartialSettlement = 5,
+
+ ///
+ /// 结算完毕
+ ///
+ [Description("结算完毕")]
+ SettlementCompleted = 6
}
///
diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs
index c4a6a72a..46e82bff 100644
--- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs
+++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeRecordService.cs
@@ -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 records)
{
var exRecords = records.Where(x => !x.ExchangeRate.HasValue && x.Currency != DefaultCurrency).ToList();
@@ -551,14 +553,27 @@ namespace DS.WMS.Core.Fee.Method
///
public DataResult UpdateAuditStatus(FlowCallback callback)
{
+ var auditType = callback.AuditType.ToEnum();
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
- var fee = tenantDb.Queryable().Where(x => x.Id == callback.BusinessId).Select(
+ FeeRecord fee = null;
+ BusinessFeeStatus businessFee = null;
+ if (auditType == FeeAuditType.Business)
+ {
+ businessFee = tenantDb.Queryable().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().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();
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().
+ 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
///
/// 整单审核
///
+ /// 业务类型
/// 业务ID
///
- //public DataResult AuditBusiness(int type, long bid)
- //{
+ public DataResult AuditBusiness(BusinessType type, long bid)
+ {
+ var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
+ var entity = tenantDb.Queryable().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 fees)
{
diff --git a/ds-wms-service/DS.WMS.Core/Op/Entity/BusinessFeeStatus.cs b/ds-wms-service/DS.WMS.Core/Op/Entity/BusinessFeeStatus.cs
index 25e4b766..065eabf9 100644
--- a/ds-wms-service/DS.WMS.Core/Op/Entity/BusinessFeeStatus.cs
+++ b/ds-wms-service/DS.WMS.Core/Op/Entity/BusinessFeeStatus.cs
@@ -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
///
[SqlSugar.SugarTable("op_business_fee_status", "业务相关费用状态表")]
public class BusinessFeeStatus : BaseModel
- {
+ {
///
/// 业务Id
///
@@ -21,19 +22,19 @@ namespace DS.WMS.Core.Op.Entity
/// 业务类型 1.海运出口
///
[SqlSugar.SugarColumn(ColumnDescription = "业务类型 1.海运出口", IsNullable = false, DefaultValue = "1")]
- public int BusinessType { get; set; } = 1;
+ public BusinessType BusinessType { get; set; } = BusinessType.OceanShippingExport;
///
/// 应收费用状态
///
- [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;
///
/// 应付费用状态
///
[SqlSugar.SugarColumn(ColumnDescription = "应付费用状态", IsNullable = false, DefaultValue = "0")]
- public int APFeeStatus { get; set; } = 0;
+ public BillFeeStatus APFeeStatus { get; set; } = BillFeeStatus.NotEntered;
///
/// 应收开票状态
@@ -76,6 +77,10 @@ namespace DS.WMS.Core.Op.Entity
///
[SqlSugar.SugarColumn(ColumnDescription = "整单费用状态时间", IsNullable = true)]
public DateTime BillFeeStatusTime { get; set; }
+
+ [SugarColumn(ColumnDescription = "当前审批工作流ID", IsNullable = true)]
+ public long? FlowId { get; set; }
+
///
/// 业务初始化费用状态
///
@@ -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,
};
}
}
+
+ ///
+ /// 业务类型
+ ///
+ public enum BusinessType
+ {
+ ///
+ /// 海运出口
+ ///
+ OceanShippingExport = 1,
+
+ ///
+ /// 海运进口
+ ///
+ OceanShippingImport = 2
+ }
+
+ ///
+ /// 整单审核状态
+ ///
+ public enum BillAuditStatus
+ {
+ ///
+ /// 待提交
+ ///
+ [Description("待提交")]
+ Pending = 0,
+
+ ///
+ /// 提交审核
+ ///
+ [Description("提交审核")]
+ AuditSubmitted = 1,
+
+ ///
+ /// 审核通过
+ ///
+ [Description("审核通过")]
+ AuditPassed = 2,
+
+ ///
+ /// 驳回提交
+ ///
+ [Description("驳回提交")]
+ Rejected = 3
+ }
}