|
|
|
@ -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)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|