费用记录,将返回的消息提示修改为多语言支持

usertest
嵇文龙 5 months ago
parent 9878a5f1c8
commit 800cb94f8f

@ -7,7 +7,11 @@ namespace DS.Module.Core;
/// </summary> /// </summary>
public static class MultiLanguageConst public static class MultiLanguageConst
{ {
/// <summary>
/// 未能获取指定的数据
/// </summary>
[Description("未能获取指定的数据")]
public const string ItemNotFound = "Item_NotFound";
/// <summary> /// <summary>
/// 查询成功 /// 查询成功
/// </summary> /// </summary>
@ -36,7 +40,7 @@ public static class MultiLanguageConst
public const string DataDelSuccess = "Data_Del_Success"; public const string DataDelSuccess = "Data_Del_Success";
/// <summary> /// <summary>
/// 删除成功 /// 操作失败
/// </summary> /// </summary>
[Description("操作失败")] [Description("操作失败")]
public const string Operation_Failed = "Operation_Failed"; public const string Operation_Failed = "Operation_Failed";
@ -507,11 +511,30 @@ public static class MultiLanguageConst
public const string FeeCodeExist = "Fee_Code_Exist"; public const string FeeCodeExist = "Fee_Code_Exist";
[Description("费用记录已存在")] [Description("费用记录已存在")]
public const string FeeRecordExist = "Fee_Record_Exist"; public const string FeeRecordExist = "Fee_Record_Exist";
[Description("费用记录不存在")]
public const string FeeRecordNotExist = "Fee_Record_NotExist";
[Description("没有找到费用记录")] [Description("没有找到费用记录")]
public const string FeeRecordNone = "Fee_Record_None"; public const string FeeRecordNone = "Fee_Record_None";
[Description("只能删除状态为‘录入’的费用")] [Description("只能删除状态为‘录入’或‘驳回提交’的费用")]
public const string FeeRecordDelete = "Fee_Record_Delete"; public const string FeeRecordDelete = "Fee_Record_Delete";
[Description("费用已锁定,禁止提交")]
public const string FeeLocked = "Fee_Record_Locked";
[Description("费用【{0}】状态不正确")]
public const string FeeRecordStatus = "Fee_Record_Status";
[Description("所选项包含正在审批中的费用,无法提交")]
public const string FeeRecordIsAuditing = "Fee_Record_IsAuditing";
[Description("当前审批费用包含已结算/部分结算的费用,无法提交")]
public const string FeeRecordIsSettled = "Fee_Record_IsSettled";
[Description("未能找到审批模板")]
public const string TemplateNotFound = "Template_NotFound";
[Description("以下项:{0} 未在审批状态中,无需撤销")]
public const string NoNeedWithdraw = "NoNeed_Withdraw";
[Description("未能获取业务信息")]
public const string BusinessNotFound = "Business_NotFound";
[Description("当前业务的费用状态为:{0},无法提交")]
public const string BusinessStatusError = "Business_Status_Error";
[Description("不支持的业务类型:{0}")]
public const string BusinessNotSupported = "Business_NotSupported";
#endregion #endregion
} }

@ -529,7 +529,7 @@ namespace DS.WMS.Core.Application.Method
protected override DataResult PreDelete(List<InvoiceApplication> applications) protected override DataResult PreDelete(List<InvoiceApplication> applications)
{ {
if (applications.Any(x => x.Status != InvoiceApplicationStatus.Pending && x.Status != InvoiceApplicationStatus.AuditRejected)) if (applications.Any(x => x.Status != InvoiceApplicationStatus.Pending && x.Status != InvoiceApplicationStatus.AuditRejected))
return DataResult.Failed("只能删除状态为‘未提交’或‘审核驳回’的申请单", MultiLanguageConst.FeeRecordDelete); return DataResult.Failed("只能删除状态为‘未提交’或‘审核驳回’的申请单");
return DataResult.Success; return DataResult.Success;
} }

@ -5,7 +5,6 @@ using DS.Module.Core.Extensions;
using DS.WMS.Core.Application.Dtos; using DS.WMS.Core.Application.Dtos;
using DS.WMS.Core.Application.Entity; using DS.WMS.Core.Application.Entity;
using DS.WMS.Core.Application.Interface; using DS.WMS.Core.Application.Interface;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Fee.Dtos; using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity; using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Info.Entity; using DS.WMS.Core.Info.Entity;
@ -123,6 +122,7 @@ namespace DS.WMS.Core.Application.Method
} }
var result = await queryList.ToQueryPageAsync(request.PageCondition); var result = await queryList.ToQueryPageAsync(request.PageCondition);
if (result.Data.Count > 0) if (result.Data.Count > 0)
{ {
//关联用户名称 //关联用户名称
@ -472,7 +472,7 @@ namespace DS.WMS.Core.Application.Method
protected override DataResult PreDelete(List<PaymentApplication> applications) protected override DataResult PreDelete(List<PaymentApplication> applications)
{ {
if (applications.Any(x => x.Status != PaymentApplicationStatus.Pending && x.Status != PaymentApplicationStatus.AuditRejected)) if (applications.Any(x => x.Status != PaymentApplicationStatus.Pending && x.Status != PaymentApplicationStatus.AuditRejected))
return DataResult.Failed("只能删除状态为‘未提交’或‘驳回’的申请单", MultiLanguageConst.FeeRecordDelete); return DataResult.Failed("只能删除状态为‘未提交’或‘驳回’的申请单");
return DataResult.Success; return DataResult.Success;
} }

@ -565,77 +565,4 @@ namespace DS.WMS.Core.Fee.Dtos
public DateTime CreateTime { get; set; } public DateTime CreateTime { get; set; }
} }
public class FeeAuditItemQuery : FeeAuditItem
{
/// <summary>
/// 业务类型
/// </summary>
public BusinessType BusinessType { get; set; }
/// <summary>
/// 委托编号
/// </summary>
public string CustomerNo { get; set; }
/// <summary>
/// 船名
/// </summary>
public string Vessel { get; set; }
/// <summary>
/// 航次
/// </summary>
public string Voyage { get; set; }
/// <summary>
/// 国外代理ID
/// </summary>
public long? AgencyId { get; set; }
/// <summary>
/// 结算对象
/// </summary>
public long? FeeCustomerId { get; set; }
/// <summary>
/// 运输类型
/// </summary>
public string ShipmentType { get; set; }
/// <summary>
/// 揽货人
/// </summary>
public long? SaleId { get; set; }
/// <summary>
/// 委托单位
/// </summary>
public long? CustomerId { get; set; }
/// <summary>
/// 业务日期
/// </summary>
public DateTime? BusinessDate { get; set; }
/// <summary>
/// 费用名称ID
/// </summary>
public long? FeeId { get; set; }
/// <summary>
/// 业务来源
/// </summary>
public long? SourceId { get; set; }
/// <summary>
/// 会计期间
/// </summary>
public string? AccountDate { get; set; }
/// <summary>
/// 操作员
/// </summary>
public long? OperatorId { get; set; }
}
} }

@ -0,0 +1,77 @@
using DS.WMS.Core.Op.Entity;
namespace DS.WMS.Core.Fee.Dtos
{
public class FeeAuditItemQuery : FeeAuditItem
{
/// <summary>
/// 业务类型
/// </summary>
public BusinessType BusinessType { get; set; }
/// <summary>
/// 委托编号
/// </summary>
public string CustomerNo { get; set; }
/// <summary>
/// 船名
/// </summary>
public string Vessel { get; set; }
/// <summary>
/// 航次
/// </summary>
public string Voyage { get; set; }
/// <summary>
/// 国外代理ID
/// </summary>
public long? AgencyId { get; set; }
/// <summary>
/// 结算对象
/// </summary>
public long? FeeCustomerId { get; set; }
/// <summary>
/// 运输类型
/// </summary>
public string ShipmentType { get; set; }
/// <summary>
/// 揽货人
/// </summary>
public long? SaleId { get; set; }
/// <summary>
/// 委托单位
/// </summary>
public long? CustomerId { get; set; }
/// <summary>
/// 业务日期
/// </summary>
public DateTime? BusinessDate { get; set; }
/// <summary>
/// 费用名称ID
/// </summary>
public long? FeeId { get; set; }
/// <summary>
/// 业务来源
/// </summary>
public long? SourceId { get; set; }
/// <summary>
/// 会计期间
/// </summary>
public string? AccountDate { get; set; }
/// <summary>
/// 操作员
/// </summary>
public long? OperatorId { get; set; }
}
}

@ -54,7 +54,8 @@ namespace DS.WMS.Core.Fee.Method
List<FlowInstance> flowList = null; List<FlowInstance> flowList = null;
if (string.Equals(request.OtherQueryCondition, Audit_Only)) if (string.Equals(request.OtherQueryCondition, Audit_Only))
{ {
flowList = await GetCurrentFlowsQuery(AuditTypes).ToListAsync(); flowList = await GetCurrentFlowsQuery(AuditTypes)
.Select(x=>new FlowInstance { BusinessId = x.BusinessId, BusinessType = x.BusinessType } ).ToListAsync();
//没有待审批的列表直接返回不再执行后续查询 //没有待审批的列表直接返回不再执行后续查询
if (flowList.Count == 0) if (flowList.Count == 0)
@ -190,7 +191,8 @@ namespace DS.WMS.Core.Fee.Method
List<FlowInstance> flowList = null; List<FlowInstance> flowList = null;
if (string.Equals(request.OtherQueryCondition, Audit_Only)) if (string.Equals(request.OtherQueryCondition, Audit_Only))
{ {
flowList = await GetCurrentFlowsQuery([AuditType.FeeBusiness.ToString()]).ToListAsync(); flowList = await GetCurrentFlowsQuery([AuditType.FeeBusiness.ToString()])
.Select(x => new FlowInstance { BusinessId = x.BusinessId, BusinessType = x.BusinessType }).ToListAsync();
//没有待审批的列表直接返回不再执行后续查询 //没有待审批的列表直接返回不再执行后续查询
if (flowList.Count == 0) if (flowList.Count == 0)
@ -206,6 +208,7 @@ namespace DS.WMS.Core.Fee.Method
} }
var result = await queryList.Select<FeeAuditBusiness>().ToQueryPageAsync(request.PageCondition); var result = await queryList.Select<FeeAuditBusiness>().ToQueryPageAsync(request.PageCondition);
if (result.Data.Count > 0) if (result.Data.Count > 0)
{ {
//关联用户名称 //关联用户名称
@ -317,7 +320,7 @@ namespace DS.WMS.Core.Fee.Method
} }
/// <summary> /// <summary>
/// 根据查询条件获取费用明细 /// 根据业务和查询条件获取费用明细
/// </summary> /// </summary>
/// <param name="id">业务ID</param> /// <param name="id">业务ID</param>
/// <param name="businessType">业务类型</param> /// <param name="businessType">业务类型</param>

@ -1,5 +1,4 @@
using System.Collections.Generic; using System.Text;
using System.Text;
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Extensions; using DS.Module.Core.Extensions;
using DS.WMS.Core.Fee.Dtos; using DS.WMS.Core.Fee.Dtos;
@ -90,7 +89,7 @@ namespace DS.WMS.Core.Fee.Method
} }
var data = await src.ToListAsync(); var data = await src.ToListAsync();
return new DataResult<List<FeeRecord>>(ResultCode.Success) { Data = data }; return DataResult<List<FeeRecord>>.Success(data);
} }
/// <summary> /// <summary>
@ -139,7 +138,7 @@ namespace DS.WMS.Core.Fee.Method
{ {
var first = items.Select(x => new { x.BusinessType, x.BusinessId }).FirstOrDefault(); var first = items.Select(x => new { x.BusinessType, x.BusinessId }).FirstOrDefault();
if (await IsFeeLockedAsync(first.BusinessId, first.BusinessType)) if (await IsFeeLockedAsync(first.BusinessId, first.BusinessType))
return DataResult.Failed("当前业务已费用锁定,禁止提交", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.FeeLocked);
DateTime dtNow = DateTime.Now; DateTime dtNow = DateTime.Now;
await TenantDb.Ado.BeginTranAsync(); await TenantDb.Ado.BeginTranAsync();
@ -162,7 +161,7 @@ namespace DS.WMS.Core.Fee.Method
{ {
if (fe.FeeStatus != FeeStatus.Entering && fe.FeeStatus != FeeStatus.RejectSubmission) if (fe.FeeStatus != FeeStatus.Entering && fe.FeeStatus != FeeStatus.RejectSubmission)
{ {
sb.Append($"费用【{fe.FeeName}】状态不正确,无法修改;"); sb.AppendFormat(MultiLanguageConst.FeeRecordStatus, fe.FeeName);
continue; continue;
} }
} }
@ -212,13 +211,13 @@ namespace DS.WMS.Core.Fee.Method
await TenantDb.Ado.CommitTranAsync(); await TenantDb.Ado.CommitTranAsync();
var list = createList.Union(updateList).Select(x => x.Adapt<FeeRecordRes>()); var list = createList.Union(updateList).Select(x => x.Adapt<FeeRecordRes>());
return DataResult.Successed("保存成功", list, MultiLanguageConst.DataUpdateSuccess); return DataResult.Success;
} }
catch (Exception ex) catch (Exception ex)
{ {
await TenantDb.Ado.RollbackTranAsync(); await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db); await ex.LogAsync(Db);
return DataResult.Failed("保存失败", MultiLanguageConst.DataUpdateFailed); return DataResult.Failed(MultiLanguageConst.Operation_Failed);
} }
finally finally
{ {
@ -239,7 +238,7 @@ namespace DS.WMS.Core.Fee.Method
x.FeeId == y.FeeId && x.FeeType == y.FeeType).Any( x.FeeId == y.FeeId && x.FeeType == y.FeeType).Any(
(x, y) => x.BusinessId == bid && x.BusinessType == businessType && tidArray.Contains(y.TemplateId)); (x, y) => x.BusinessId == bid && x.BusinessType == businessType && tidArray.Contains(y.TemplateId));
if (hasExists) if (hasExists)
return DataResult.Failed("费用记录已存在", MultiLanguageConst.FeeRecordExist); return DataResult.Failed(MultiLanguageConst.FeeRecordExist);
var details = await TenantDb.Queryable<FeeTemplateDetail>().Where(x => tidArray.Contains(x.TemplateId) && !x.Deleted).Select(x => new var details = await TenantDb.Queryable<FeeTemplateDetail>().Where(x => tidArray.Contains(x.TemplateId) && !x.Deleted).Select(x => new
{ {
@ -281,7 +280,7 @@ namespace DS.WMS.Core.Fee.Method
await WriteBackStatusAsync(bid, businessType); await WriteBackStatusAsync(bid, businessType);
return result > 0 ? DataResult.Successed("保存成功", records, MultiLanguageConst.DataCreateSuccess) : DataResult.Successed("操作失败!", MultiLanguageConst.Operation_Failed); return result > 0 ? DataResult.Success : DataResult.Successed(MultiLanguageConst.Operation_Failed);
} }
/// <summary> /// <summary>
@ -293,16 +292,16 @@ namespace DS.WMS.Core.Fee.Method
{ {
var model = await TenantDb.Queryable<FeeRecord>().Where(x => ids.Contains(x.Id)).Select(x => new { x.BusinessId, x.BusinessType }).FirstAsync(); var model = await TenantDb.Queryable<FeeRecord>().Where(x => ids.Contains(x.Id)).Select(x => new { x.BusinessId, x.BusinessType }).FirstAsync();
if (await IsFeeLockedAsync(model.BusinessId, model.BusinessType)) if (await IsFeeLockedAsync(model.BusinessId, model.BusinessType))
return DataResult.Failed("当前业务已费用锁定,禁止修改", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.FeeLocked);
if (await TenantDb.Queryable<FeeRecord>().AnyAsync(x => ids.Contains(x.Id) && (x.FeeStatus != FeeStatus.Entering && x.FeeStatus != FeeStatus.RejectSubmission))) if (await TenantDb.Queryable<FeeRecord>().AnyAsync(x => ids.Contains(x.Id) && (x.FeeStatus != FeeStatus.Entering && x.FeeStatus != FeeStatus.RejectSubmission)))
return DataResult.Failed("只能删除状态为‘录入’或‘驳回提交’的费用", MultiLanguageConst.FeeRecordDelete); return DataResult.Failed(MultiLanguageConst.FeeRecordDelete);
int result = await TenantDb.Deleteable<FeeRecord>(x => ids.Contains(x.Id)).ExecuteCommandAsync(); int result = await TenantDb.Deleteable<FeeRecord>(x => ids.Contains(x.Id)).ExecuteCommandAsync();
await WriteBackStatusAsync(model.BusinessId, model.BusinessType); await WriteBackStatusAsync(model.BusinessId, model.BusinessType);
return result > 0 ? DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess) : DataResult.Failed("删除失败!", MultiLanguageConst.Operation_Failed); return result > 0 ? DataResult.Success : DataResult.Failed(MultiLanguageConst.Operation_Failed);
} }
/// <summary> /// <summary>
@ -325,21 +324,21 @@ namespace DS.WMS.Core.Fee.Method
BusinessType = x.BusinessType BusinessType = x.BusinessType
}).ToListAsync(); }).ToListAsync();
if (fees.IsNullOrEmpty()) if (fees.IsNullOrEmpty())
return DataResult.Failed($"未能获取费用信息,提交失败", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.FeeRecordNotExist);
var bid = fees[0].BusinessId; var bid = fees[0].BusinessId;
var bType = fees[0].BusinessType; var bType = fees[0].BusinessType;
//业务状态检测 //业务状态检测
if (await IsFeeLockedAsync(bid, bType)) if (await IsFeeLockedAsync(bid, bType))
return DataResult.Failed("当前业务已费用锁定,禁止提交", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.FeeLocked);
if (fees.Any(x => x.FlowId.HasValue)) if (fees.Any(x => x.FlowId.HasValue))
return DataResult.Failed("当前费用包含正在审批中的费用,无法提交", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.FeeRecordIsAuditing);
if (fees.Any(x => x.FeeStatus == FeeStatus.PartialSettlement || x.FeeStatus == FeeStatus.SettlementCompleted)) if (fees.Any(x => x.FeeStatus == FeeStatus.PartialSettlement || x.FeeStatus == FeeStatus.SettlementCompleted))
return DataResult.Failed("当前审批费用包含已结算/部分结算的费用,无法提交", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.FeeRecordIsSettled);
DataResult result = DataResult.Failed(string.Empty, MultiLanguageConst.Operation_Failed); DataResult result = DataResult.Failed(MultiLanguageConst.Operation_Failed);
await TenantDb.Ado.BeginTranAsync(); await TenantDb.Ado.BeginTranAsync();
try try
{ {
@ -367,13 +366,13 @@ namespace DS.WMS.Core.Fee.Method
x.FlowId x.FlowId
}).ExecuteCommandAsync(); }).ExecuteCommandAsync();
await TenantDb.Ado.CommitTranAsync(); await TenantDb.Ado.CommitTranAsync();
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess); return DataResult.Success;
} }
catch (Exception ex) catch (Exception ex)
{ {
await TenantDb.Ado.RollbackTranAsync(); await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db); await ex.LogAsync(Db);
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.Operation_Failed);
} }
} }
@ -385,7 +384,7 @@ namespace DS.WMS.Core.Fee.Method
{ {
if (fe.FeeStatus != FeeStatus.Entering && fe.FeeStatus != FeeStatus.RejectSubmission) if (fe.FeeStatus != FeeStatus.Entering && fe.FeeStatus != FeeStatus.RejectSubmission)
{ {
sb.Append($"费用【{fe.FeeName}】状态不正确,无法提交审批;"); sb.AppendFormat(MultiLanguageConst.FeeRecordStatus, fe.FeeName);
continue; continue;
} }
} }
@ -394,7 +393,7 @@ namespace DS.WMS.Core.Fee.Method
var template = await FindTemplateAsync(AuditType.FeeAudit); var template = await FindTemplateAsync(AuditType.FeeAudit);
if (template == null) if (template == null)
return DataResult.Failed("未能找到审批模板", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.TemplateNotFound);
DateTime dtNow = DateTime.Now; DateTime dtNow = DateTime.Now;
foreach (var item in fees) foreach (var item in fees)
@ -429,7 +428,7 @@ namespace DS.WMS.Core.Fee.Method
{ {
if (fe.FeeStatus != FeeStatus.AuditPassed && fe.FeeStatus != FeeStatus.RejectApplication) if (fe.FeeStatus != FeeStatus.AuditPassed && fe.FeeStatus != FeeStatus.RejectApplication)
{ {
sb.Append($"费用【{fe.FeeName}】状态不正确,无法提交审批;"); sb.AppendFormat(MultiLanguageConst.FeeRecordStatus, fe.FeeName);
continue; continue;
} }
} }
@ -438,7 +437,7 @@ namespace DS.WMS.Core.Fee.Method
var template = await FindTemplateAsync(AuditType.FeeDelete); var template = await FindTemplateAsync(AuditType.FeeDelete);
if (template == null) if (template == null)
return DataResult.Failed("未能找到审批模板", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.TemplateNotFound);
DateTime dtNow = DateTime.Now; DateTime dtNow = DateTime.Now;
foreach (var item in fees) foreach (var item in fees)
@ -481,14 +480,14 @@ namespace DS.WMS.Core.Fee.Method
FeeStatus = x.FeeStatus FeeStatus = x.FeeStatus
}).ToListAsync(); }).ToListAsync();
if (fees.Count == 0) if (fees.Count == 0)
return DataResult.Failed("未能获取费用信息", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.FeeRecordNotExist);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
foreach (var fe in fees) foreach (var fe in fees)
{ {
if (fe.FeeStatus != FeeStatus.AuditPassed && fe.FeeStatus != FeeStatus.RejectApplication) if (fe.FeeStatus != FeeStatus.AuditPassed && fe.FeeStatus != FeeStatus.RejectApplication)
{ {
sb.Append($"费用【{fe.FeeName}】状态不正确,无法提交审批;"); sb.AppendFormat(MultiLanguageConst.FeeRecordStatus, fe.FeeName);
continue; continue;
} }
} }
@ -497,7 +496,7 @@ namespace DS.WMS.Core.Fee.Method
var template = await FindTemplateAsync(AuditType.FeeModify); var template = await FindTemplateAsync(AuditType.FeeModify);
if (template == null) if (template == null)
return DataResult.Failed("未能找到审批模板", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.TemplateNotFound);
DateTime dtNow = DateTime.Now; DateTime dtNow = DateTime.Now;
await TenantDb.Ado.BeginTranAsync(); await TenantDb.Ado.BeginTranAsync();
@ -530,13 +529,13 @@ namespace DS.WMS.Core.Fee.Method
await TenantDb.Updateable(fees).UpdateColumns(x => new { x.FeeStatus, x.FlowId }).ExecuteCommandAsync(); await TenantDb.Updateable(fees).UpdateColumns(x => new { x.FeeStatus, x.FlowId }).ExecuteCommandAsync();
await TenantDb.Ado.CommitTranAsync(); await TenantDb.Ado.CommitTranAsync();
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess); return DataResult.Success;
} }
catch (Exception ex) catch (Exception ex)
{ {
await TenantDb.Ado.RollbackTranAsync(); await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db); await ex.LogAsync(Db);
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.Operation_Failed);
} }
} }
@ -557,14 +556,14 @@ namespace DS.WMS.Core.Fee.Method
}).ToListAsync(); }).ToListAsync();
if (fees.Count == 0) if (fees.Count == 0)
return DataResult.Failed("未能找到费用记录", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.TemplateNotFound);
//未在审批状态中 //未在审批状态中
var fees2 = fees.FindAll(x => x.FlowId == null).ToList(); var fees2 = fees.FindAll(x => x.FlowId == null).ToList();
if (fees2.Count > 0) if (fees2.Count > 0)
{ {
string msg = string.Join("; ", fees2.Select(x => $"{x.FeeName}")); string msg = string.Join("; ", fees2.Select(x => $"{x.FeeName}"));
return DataResult.Failed($"以下费用项:{msg} 未在审批状态中,无需撤销", MultiLanguageConst.Operation_Failed); return DataResult.Failed(string.Format(MultiLanguageConst.NoNeedWithdraw, msg));
} }
var flows = fees.Select(x => new FlowInstance { Id = x.FlowId.Value, FlowStatus = (int)FlowStatusEnum.Draft, MakerList = string.Empty }).ToList(); var flows = fees.Select(x => new FlowInstance { Id = x.FlowId.Value, FlowStatus = (int)FlowStatusEnum.Draft, MakerList = string.Empty }).ToList();
@ -605,13 +604,13 @@ namespace DS.WMS.Core.Fee.Method
await TenantDb.Updateable(fees).UpdateColumns(x => new { x.Id, x.FeeStatus, x.SubmitBy, x.SubmitDate, x.FlowId }).ExecuteCommandAsync(); await TenantDb.Updateable(fees).UpdateColumns(x => new { x.Id, x.FeeStatus, x.SubmitBy, x.SubmitDate, x.FlowId }).ExecuteCommandAsync();
await TenantDb.Ado.CommitTranAsync(); await TenantDb.Ado.CommitTranAsync();
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess); return DataResult.Success;
} }
catch (Exception ex) catch (Exception ex)
{ {
await TenantDb.Ado.RollbackTranAsync(); await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db); await ex.LogAsync(Db);
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.Operation_Failed);
} }
} }
@ -628,23 +627,25 @@ namespace DS.WMS.Core.Fee.Method
x.BusinessType == BusinessType.OceanShippingExport).Select(x => new BusinessFeeStatus x.BusinessType == BusinessType.OceanShippingExport).Select(x => new BusinessFeeStatus
{ {
Id = x.Id, Id = x.Id,
BusinessId = x.BusinessId,
BusinessType = x.BusinessType,
IsFeeLocking = x.IsFeeLocking, IsFeeLocking = x.IsFeeLocking,
BillAuditStatus = x.BillAuditStatus, BillAuditStatus = x.BillAuditStatus,
FlowId = x.FlowId FlowId = x.FlowId
}).FirstAsync(); }).FirstAsync();
if (entity == null) if (entity == null)
return DataResult.Failed("未能找到业务信息", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.BusinessNotFound);
if (entity.IsFeeLocking.GetValueOrDefault()) if (entity.IsFeeLocking.GetValueOrDefault())
return DataResult.Failed("当前业务已费用锁定,禁止提交", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.FeeLocked);
if (entity.FlowId.HasValue) if (entity.FlowId.HasValue)
return DataResult.Failed($"当前业务正在审批中,无法提交", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.FeeRecordIsAuditing);
if (entity.BillAuditStatus == BillAuditStatus.AuditPassed) if (entity.BillAuditStatus == BillAuditStatus.AuditPassed)
return DataResult.Failed($"当前业务的费用状态为:{entity.BillAuditStatus.GetDescription()},无法提交", MultiLanguageConst.Operation_Failed); return DataResult.Failed(string.Format(MultiLanguageConst.BusinessStatusError, entity.BillAuditStatus.GetDescription()));
var template = await FindTemplateAsync(AuditType.FeeBusiness); var template = await FindTemplateAsync(AuditType.FeeBusiness);
if (template == null) if (template == null)
return DataResult.Failed("未能找到审批模板", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.TemplateNotFound);
var result = flowService.CreateFlowInstance(new CreateFlowInstanceReq var result = flowService.CreateFlowInstance(new CreateFlowInstanceReq
{ {
@ -670,12 +671,13 @@ namespace DS.WMS.Core.Fee.Method
}).ExecuteCommandAsync(); }).ExecuteCommandAsync();
//修改关联费用状态为提交审核 //修改关联费用状态为提交审核
await TenantDb.Updateable<FeeRecord>().Where(x => x.BusinessId == entity.BusinessId && x.BusinessType == entity.BusinessType)
.SetColumns(x => x.FeeStatus, FeeStatus.AuditSubmitted).ExecuteCommandAsync();
return DataResult.Success;
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
} }
return DataResult.Failed("创建工作流失败", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.Operation_Failed);
} }
/// <summary> /// <summary>
@ -688,7 +690,7 @@ namespace DS.WMS.Core.Fee.Method
{ {
var list = idArray.Select(x => new FeeRecord { Id = x, IsInvoice = enabled }).ToList(); var list = idArray.Select(x => new FeeRecord { Id = x, IsInvoice = enabled }).ToList();
int rows = await TenantDb.Updateable(list).UpdateColumns(x => new { x.IsInvoice }).ExecuteCommandAsync(); int rows = await TenantDb.Updateable(list).UpdateColumns(x => new { x.IsInvoice }).ExecuteCommandAsync();
return rows > 0 ? DataResult.Successed("设置成功!", MultiLanguageConst.DataUpdateSuccess) : DataResult.Failed("设置失败!", MultiLanguageConst.Operation_Failed); return rows > 0 ? DataResult.Success : DataResult.Failed(MultiLanguageConst.Operation_Failed);
} }
/// <summary> /// <summary>
@ -707,7 +709,7 @@ namespace DS.WMS.Core.Fee.Method
x.Name x.Name
}).FirstAsync(); }).FirstAsync();
if (model == null) if (model == null)
return DataResult.Failed("未能找到费用对象信息,设置失败!", MultiLanguageConst.Operation_Failed); return DataResult.Failed(MultiLanguageConst.ItemNotFound);
var list = idArray.Select(x => new FeeRecord var list = idArray.Select(x => new FeeRecord
{ {
@ -718,7 +720,7 @@ namespace DS.WMS.Core.Fee.Method
CustomerType = customerType CustomerType = customerType
}).ToList(); }).ToList();
int rows = await TenantDb.Updateable(list).UpdateColumns(x => new { x.CustomerId, x.CustomerCode, x.CustomerName, x.CustomerType }).ExecuteCommandAsync(); int rows = await TenantDb.Updateable(list).UpdateColumns(x => new { x.CustomerId, x.CustomerCode, x.CustomerName, x.CustomerType }).ExecuteCommandAsync();
return rows > 0 ? DataResult.Successed("设置成功!", MultiLanguageConst.DataUpdateSuccess) : DataResult.Failed("设置失败!", MultiLanguageConst.Operation_Failed); return rows > 0 ? DataResult.Success : DataResult.Failed(MultiLanguageConst.Operation_Failed);
} }
/// <summary> /// <summary>
@ -739,8 +741,8 @@ namespace DS.WMS.Core.Fee.Method
break; break;
default: default:
return DataResult<CostAccountingForm>.Failed( return DataResult<CostAccountingForm>.Failed(string.Format(
$"不支持业务类型为【{businessType.GetDescription()}】的费用打印", MultiLanguageConst.Operation_Failed); MultiLanguageConst.BusinessNotSupported, businessType.GetDescription()));
} }
if (form != null) if (form != null)
@ -748,17 +750,17 @@ namespace DS.WMS.Core.Fee.Method
long UserId = long.Parse(User.UserId); long UserId = long.Parse(User.UserId);
form.Creator = Db.Queryable<SysUser>().Where(x => x.Id == UserId).Select(x => x.NickName).First(); form.Creator = Db.Queryable<SysUser>().Where(x => x.Id == UserId).Select(x => x.NickName).First();
form.ReceivableRMB = form.Details.FindAll(x => x.Type == FeeType.Receivable && x.Currency == "CNY").Sum(x => x.Amount); form.ReceivableRMB = form.Details.FindAll(x => x.Type == FeeType.Receivable && x.Currency == RMB_CODE).Sum(x => x.Amount);
form.PayableRMB = form.Details.FindAll(x => x.Type == FeeType.Payable && x.Currency == "CNY").Sum(x => x.Amount); form.PayableRMB = form.Details.FindAll(x => x.Type == FeeType.Payable && x.Currency == RMB_CODE).Sum(x => x.Amount);
form.ReceivableUSD = form.Details.FindAll(x => x.Type == FeeType.Receivable && x.Currency == "USD").Sum(x => x.Amount); form.ReceivableUSD = form.Details.FindAll(x => x.Type == FeeType.Receivable && x.Currency == USD_CODE).Sum(x => x.Amount);
form.PayableUSD = form.Details.FindAll(x => x.Type == FeeType.Payable && x.Currency == "USD").Sum(x => x.Amount); form.PayableUSD = form.Details.FindAll(x => x.Type == FeeType.Payable && x.Currency == USD_CODE).Sum(x => x.Amount);
form.ReceivableOther = form.Details.FindAll(x => x.Type == FeeType.Receivable && (x.Currency != "CNY" && x.Currency != "USD")).Sum(x => x.Amount); form.ReceivableOther = form.Details.FindAll(x => x.Type == FeeType.Receivable && (x.Currency != RMB_CODE && x.Currency != USD_CODE)).Sum(x => x.Amount);
form.PayableOther = form.Details.FindAll(x => x.Type == FeeType.Payable && (x.Currency == "CNY" && x.Currency != "USD")).Sum(x => x.Amount); form.PayableOther = form.Details.FindAll(x => x.Type == FeeType.Payable && (x.Currency == RMB_CODE && x.Currency != USD_CODE)).Sum(x => x.Amount);
//获取美元汇率 //获取美元汇率
var fees = new List<FeeRecord> { var fees = new List<FeeRecord> {
new FeeRecord { Currency = "USD", FeeType = FeeType.Receivable }, new FeeRecord { Currency = USD_CODE, FeeType = FeeType.Receivable },
new FeeRecord { Currency = "USD", FeeType = FeeType.Payable } new FeeRecord { Currency = USD_CODE, FeeType = FeeType.Payable }
}; };
await FetchExchangeRateAsync(fees); await FetchExchangeRateAsync(fees);
form.ExchangeRate = fees[0].ExchangeRate.HasValue ? fees[0].ExchangeRate.Value : 1; form.ExchangeRate = fees[0].ExchangeRate.HasValue ? fees[0].ExchangeRate.Value : 1;

@ -1615,3 +1615,10 @@
2024-06-26 15:35:24.8370 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config 2024-06-26 15:35:24.8370 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config
2024-06-26 15:35:24.8453 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile 2024-06-26 15:35:24.8453 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-06-26 15:35:24.8453 Info Configuration initialized. 2024-06-26 15:35:24.8453 Info Configuration initialized.
2024-06-27 13:58:07.6301 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-06-27 13:58:07.6596 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-06-27 13:58:07.6624 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-06-27 13:58:07.6624 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-06-27 13:58:07.6624 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Source\Repos\DS8\ds-wms-service\DS.WMS.FeeApi\bin\Debug\net8.0\nlog.config
2024-06-27 13:58:07.6624 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-06-27 13:58:07.6624 Info Configuration initialized.

Loading…
Cancel
Save