优化与bug修复

usertest
嵇文龙 6 months ago
parent dc1b5ef44e
commit e60a6966f1

@ -1,7 +1,7 @@
using SqlSugar;
using System.ComponentModel;
using System.ComponentModel;
using DS.Module.Core.Data;
using Newtonsoft.Json;
using SqlSugar;
namespace DS.Module.Core.Extensions;
@ -42,12 +42,29 @@ public static partial class Extensions
{
page.NotNull(nameof(page));
var result = source.WhereAsync(page.PageIndex, page.PageSize, page.SortConditions);
var result = source.Where(page.PageIndex, page.PageSize, page.SortConditions);
var list = result.data;
var total = result.totalNumber;
return DataResult<List<TEntity>>.PageList(total, list, MultiLanguageConst.DataQuerySuccess);
}
/// <summary>
/// 将查询转换为分页结果
/// </summary>
/// <typeparam name="TEntity"></typeparam>
/// <param name="source">数据源</param>
/// <param name="page">分页设置</param>
/// <returns></returns>
public static async Task<DataResult<List<TEntity>>> ToQueryPageAsync<TEntity>(this ISugarQueryable<TEntity> source,
PageCondition page)
{
page.NotNull(nameof(page));
var result = await source.WhereAsync(page.PageIndex, page.PageSize, page.SortConditions);
var list = result.Item1;
var total = result.Item2;
return DataResult<List<TEntity>>.PageList(total, list, MultiLanguageConst.DataQuerySuccess);
}
/// <summary>
///
/// </summary>
@ -57,7 +74,7 @@ public static partial class Extensions
/// <param name="orderConditions"></param>
/// <typeparam name="TEntity"></typeparam>
/// <returns></returns>
private static (List<TEntity> data, int totalNumber) WhereAsync<TEntity>(this ISugarQueryable<TEntity> source,
private static (List<TEntity> data, int totalNumber) Where<TEntity>(this ISugarQueryable<TEntity> source,
int pageIndex,
int pageSize, SortCondition[] orderConditions)
{
@ -82,6 +99,28 @@ public static partial class Extensions
? source.ToPageList(pageIndex, pageSize, ref total)
: Enumerable.Empty<TEntity>().ToList(), total);
}
private static async Task<Tuple<List<TEntity>, int>> WhereAsync<TEntity>(this ISugarQueryable<TEntity> source,
int pageIndex, int pageSize, SortCondition[] orderConditions)
{
ISugarQueryable<TEntity> orderSource;
if (orderConditions == null || orderConditions.Length == 0)
{
orderSource = source.OrderBy("Id");
}
else
{
orderSource = source.OrderBy(orderConditions);
}
source = orderSource;
var total = new RefAsync<int>();
var list = await source.ToPageListAsync(pageIndex, pageSize, total);
return new Tuple<List<TEntity>, int>(list, total.Value);
}
/// <summary>
/// 转换SqlSugar条件查询表达式
/// </summary>
@ -100,7 +139,8 @@ public static partial class Extensions
(WhereType.And,
new ConditionalModel
{
FieldName = item.Field, ConditionalType = GetConditionalType(item.Operator),
FieldName = item.Field,
ConditionalType = GetConditionalType(item.Operator),
FieldValue = item.Value
})
);
@ -109,9 +149,9 @@ public static partial class Extensions
if (conditionList.Count > 0)
{
conditionalCollections.Add(new ConditionalCollections
{
ConditionalList = conditionList
}
{
ConditionalList = conditionList
}
)
;
}
@ -127,7 +167,8 @@ public static partial class Extensions
(WhereType.And,
new ConditionalModel
{
FieldName = item1.Field, ConditionalType = GetConditionalType(item1.Operator),
FieldName = item1.Field,
ConditionalType = GetConditionalType(item1.Operator),
FieldValue = item1.Value
})
);
@ -141,7 +182,8 @@ public static partial class Extensions
(WhereType.Or,
new ConditionalModel
{
FieldName = item1.Field, ConditionalType =GetConditionalType(item1.Operator),
FieldName = item1.Field,
ConditionalType = GetConditionalType(item1.Operator),
FieldValue = item1.Value
})
);
@ -152,9 +194,9 @@ public static partial class Extensions
if (groupList.Count > 0)
{
conditionalCollections.Add(new ConditionalCollections
{
ConditionalList = groupList
}
{
ConditionalList = groupList
}
)
;
}
@ -168,7 +210,8 @@ public static partial class Extensions
(WhereType.Or,
new ConditionalModel
{
FieldName = item.Field, ConditionalType = GetConditionalType(item.Operator),
FieldName = item.Field,
ConditionalType = GetConditionalType(item.Operator),
FieldValue = item.Value
})
);
@ -177,9 +220,9 @@ public static partial class Extensions
if (conditionList.Count > 0)
{
conditionalCollections.Add(new ConditionalCollections
{
ConditionalList = conditionList
}
{
ConditionalList = conditionList
}
)
;
}
@ -195,7 +238,8 @@ public static partial class Extensions
(WhereType.And,
new ConditionalModel
{
FieldName = item1.Field, ConditionalType = GetConditionalType(item1.Operator),
FieldName = item1.Field,
ConditionalType = GetConditionalType(item1.Operator),
FieldValue = item1.Value
})
);
@ -209,7 +253,8 @@ public static partial class Extensions
(WhereType.Or,
new ConditionalModel
{
FieldName = item1.Field, ConditionalType = GetConditionalType(item1.Operator),
FieldName = item1.Field,
ConditionalType = GetConditionalType(item1.Operator),
FieldValue = item1.Value
})
);
@ -220,9 +265,9 @@ public static partial class Extensions
if (groupList.Count > 0)
{
conditionalCollections.Add(new ConditionalCollections
{
ConditionalList = groupList
}
{
ConditionalList = groupList
}
)
;
}
@ -230,12 +275,12 @@ public static partial class Extensions
return conditionalCollections;
}
/// <summary>
/// 转换SqlSugar 条件操作符
/// </summary>
/// <param name="conditionalType"></param>
/// <returns></returns>
/// <summary>
/// 转换SqlSugar 条件操作符
/// </summary>
/// <param name="conditionalType"></param>
/// <returns></returns>
private static ConditionalType GetConditionalType(string conditionalType)
{
switch (conditionalType)

@ -6,7 +6,15 @@ namespace DS.WMS.Core
{
public static class LogExtensions
{
public static void Log(this Exception ex, ISqlSugarClient db)
const long CONFIG_ID = 1288018625843826680;
/// <summary>
/// 将异常信息记录到数据库
/// </summary>
/// <param name="ex"></param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task LogAsync(this Exception ex, ISqlSugarClient db)
{
string className = string.Empty;
var stacktrace = new StackTrace();
@ -24,7 +32,7 @@ namespace DS.WMS.Core
};
var scope = (SqlSugarScope)db;
scope.GetConnection(1288018625843826680).Insertable(exLog).ExecuteCommand();
await scope.GetConnection(CONFIG_ID).Insertable(exLog).ExecuteCommandAsync();
}
}
}

@ -2,7 +2,10 @@
namespace DS.WMS.Core.Fee.Dtos
{
public class FeeAuditRequest
/// <summary>
/// 审批请求
/// </summary>
public class AuditRequest
{
/// <summary>
/// 审核结果1=通过2=驳回
@ -12,28 +15,24 @@ namespace DS.WMS.Core.Fee.Dtos
/// <summary>
/// 审批备注
/// </summary>
public string Remark { get; set; }
public string? Remark { get; set; }
}
public class FeeAuditRequest : AuditRequest
{
/// <summary>
/// 审批的费用ID
/// </summary>
public long[] Ids { get; set; }
/// <summary>
/// 业务类型
/// </summary>
public BusinessType BusinessType { get; set; }
}
public class FeeBizAuditRequest
public class FeeBizAuditRequest: AuditRequest
{
/// <summary>
/// 审核结果1=通过2=驳回
/// </summary>
public int Result { get; set; }
/// <summary>
/// 审批备注
/// </summary>
public string Remark { get; set; }
public List<BizAudit> Items { get; set; }
}

@ -15,14 +15,14 @@ namespace DS.WMS.Core.Fee.Interface
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<FeeAuditBusiness>> GetList(PageRequest request);
Task<DataResult<List<FeeAuditBusiness>>> GetListAsync(PageRequest request);
/// <summary>
/// 获取整票审核列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<FeeAuditBusiness>> GetBizList(PageRequest request);
Task<DataResult<List<FeeAuditBusiness>>> GetBizListAsync(PageRequest request);
/// <summary>
/// 批量审批
@ -31,7 +31,7 @@ namespace DS.WMS.Core.Fee.Interface
/// <param name="remark">备注</param>
/// <param name="idArray">待审批的费用ID</param>
/// <returns></returns>
DataResult Audit(int yesOrNo, string remark, params long[] idArray);
Task<DataResult> AuditAsync(int yesOrNo, string remark, params long[] idArray);
/// <summary>
/// 本票审核(一键审核当前登录用户的所有待审核项)
@ -39,26 +39,26 @@ namespace DS.WMS.Core.Fee.Interface
/// <param name="yesOrNo">审批结果1=通过2=驳回</param>
/// <param name="remark">备注</param>
/// <returns></returns>
DataResult Audit(int yesOrNo, string remark);
Task<DataResult> AuditAsync(int yesOrNo, string remark);
/// <summary>
/// 整单费用状态审核
/// </summary>
/// <param name="request"></param>
DataResult AuditBusiness(FeeBizAuditRequest request);
Task<DataResult> AuditBusinessAsync(FeeBizAuditRequest request);
/// <summary>
/// 设置业务费用锁定状态
/// </summary>
/// <param name="items">业务信息</param>
/// <returns></returns>
DataResult SetFeeLocking(IEnumerable<BusinessFeeStatus> items);
Task<DataResult> SetFeeLockingAsync(IEnumerable<BusinessFeeStatus> items);
/// <summary>
/// 根据审批结果更新审批状态
/// </summary>
///<param name="callback">回调信息</param>
/// <returns></returns>
DataResult UpdateAuditStatus(FlowCallback callback);
Task<DataResult> UpdateStatusAsync(FlowCallback callback);
}
}

@ -1,8 +1,8 @@
using DS.Module.Core;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Op.Entity;
using SqlSugar;
namespace DS.WMS.Core.Fee.Interface;
@ -13,21 +13,21 @@ public interface IFeeRecordService
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<FeeRecordRes>> GetListByPage(PageRequest request);
Task<DataResult<List<FeeRecordRes>>> GetListByPageAsync(PageRequest request);
/// <summary>
/// 列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
DataResult<List<FeeRecord>> GetList(string query);
Task<DataResult<List<FeeRecord>>> GetListAsync(string query);
/// <summary>
/// 提交
/// </summary>
/// <param name="items">要提交的费用记录</param>
/// <returns></returns>
DataResult InsertOrUpdate(IEnumerable<FeeRecord> items);
Task<DataResult> SaveAsync(IEnumerable<FeeRecord> items);
/// <summary>
/// 根据费用模板引入
@ -36,14 +36,14 @@ public interface IFeeRecordService
/// <param name="type">业务类型</param>
/// <param name="tidArray">模板ID</param>
/// <returns></returns>
DataResult CreateByTemplate(long bid, BusinessType type, params long[] tidArray);
Task<DataResult> CreateByTemplateAsync(long bid, BusinessType type, params long[] tidArray);
/// <summary>
/// 删除
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
DataResult Delete(params long[] ids);
Task<DataResult> DeleteAsync(params long[] ids);
/// <summary>
/// 发起审批工作流
@ -52,21 +52,21 @@ public interface IFeeRecordService
/// <param name="remark">备注</param>
/// <param name="idArray">费用记录ID</param>
/// <returns></returns>
DataResult SubmitForApproval(FeeAuditType auditType, string remark, params long[] idArray);
Task<DataResult> SubmitForApprovalAsync(FeeAuditType auditType, string remark, params long[] idArray);
/// <summary>
/// 发起费用修改申请
/// </summary>
/// <param name="items">费用修改信息</param>
/// <returns></returns>
DataResult SubmitForModification(IEnumerable<FeeModification> items);
Task<DataResult> SubmitForModificationAsync(IEnumerable<FeeModification> items);
/// <summary>
/// 撤销审批
/// </summary>
/// <param name="ids">费用记录ID</param>
/// <returns></returns>
DataResult Withdraw(params long[] ids);
Task<DataResult> WithdrawAsync(params long[] ids);
/// <summary>
/// 发起整单审核
@ -74,7 +74,16 @@ public interface IFeeRecordService
/// <param name="bid">业务ID</param>
/// <param name="type">业务类型</param>
/// <returns></returns>
DataResult SubmitBusinessAudit(long bid, BusinessType type);
Task<DataResult> SubmitBusinessAuditAsync(long bid, BusinessType type);
/// <summary>
/// 回写业务表费用状态
/// </summary>
/// <param name="tenantDb"></param>
/// <param name="businessId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <returns></returns>
Task WriteBackStatusAsync(SqlSugarScopeProvider tenantDb, long businessId, BusinessType businessType);
/// <summary>
/// 获取费用核算单打印信息
@ -82,7 +91,7 @@ public interface IFeeRecordService
/// <param name="businessType">业务类型</param>
/// <param name="idArray">费用记录ID</param>
/// <returns></returns>
DataResult<CostAccountingForm> GetPrintInfo(BusinessType businessType, params long[] idArray);
Task<DataResult<CostAccountingForm>> GetPrintInfoAsync(BusinessType businessType, params long[] idArray);
/// <summary>
/// 设置发票启用状态
@ -90,5 +99,5 @@ public interface IFeeRecordService
/// <param name="enabled">是否启用</param>
/// <param name="idArray">费用记录ID</param>
/// <returns></returns>
DataResult SetInvoiceEnabled(bool enabled, params long[] idArray);
Task<DataResult> SetInvoiceEnabledAsync(bool enabled, params long[] idArray);
}

@ -42,14 +42,16 @@ namespace DS.WMS.Core.Fee.Method
readonly IUser user;
readonly ISaasDbService saasService;
readonly IClientFlowInstanceService flowService;
readonly IFeeRecordService feeService;
public FeeAuditService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
flowService = _serviceProvider.GetRequiredService<IClientFlowInstanceService>();
db = serviceProvider.GetRequiredService<ISqlSugarClient>();
user = serviceProvider.GetRequiredService<IUser>();
saasService = serviceProvider.GetRequiredService<ISaasDbService>();
flowService = serviceProvider.GetRequiredService<IClientFlowInstanceService>();
feeService = serviceProvider.GetRequiredService<IFeeRecordService>();
}
/// <summary>
@ -57,11 +59,11 @@ namespace DS.WMS.Core.Fee.Method
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DataResult<List<FeeAuditBusiness>> GetList(PageRequest request)
public async Task<DataResult<List<FeeAuditBusiness>>> GetListAsync(PageRequest request)
{
var flowList = db.Queryable<FlowInstance>().Where(x => x.FlowStatus == RunningStatus
var flowList = await db.Queryable<FlowInstance>().Where(x => x.FlowStatus == RunningStatus
&& SqlFunc.SplitIn(x.MakerList, user.UserId) && AuditTypes.Contains(x.AuditType))
.Select(x => new FlowInstance { BusinessId = x.BusinessId, BusinessType = x.BusinessType }).ToList();
.Select(x => new FlowInstance { BusinessId = x.BusinessId, BusinessType = x.BusinessType }).ToListAsync();
//没有待审批的列表直接返回不再执行后续查询
if (flowList.Count == 0)
DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
@ -77,14 +79,14 @@ namespace DS.WMS.Core.Fee.Method
queryList = queryList.Where(whereList);
}
var result = queryList.ToQueryPage(request.PageCondition);
var result = await queryList.ToQueryPageAsync(request.PageCondition);
if (result.Data.Count > 0)
{
//关联用户名称
var userIds = result.Data.Where(x => x.OperatorId.HasValue).Select(x => x.OperatorId.Value)
.Union(result.Data.Select(x => x.CreateBy))
.Distinct();
var users = db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToList();
var users = await db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
foreach (var item in result.Data)
{
item.CreateByName = users.Find(x => x.Id == item.CreateBy)?.UserName;
@ -104,12 +106,12 @@ namespace DS.WMS.Core.Fee.Method
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DataResult<List<FeeAuditBusiness>> GetBizList(PageRequest request)
public async Task<DataResult<List<FeeAuditBusiness>>> GetBizListAsync(PageRequest request)
{
string auditType = FeeAuditType.Business.ToString();
var flowList = db.Queryable<FlowInstance>().Where(x => x.FlowStatus == RunningStatus
var flowList = await db.Queryable<FlowInstance>().Where(x => x.FlowStatus == RunningStatus
&& SqlFunc.SplitIn(x.MakerList, user.UserId) && x.AuditType == auditType)
.Select(x => new FlowInstance { BusinessId = x.BusinessId, BusinessType = x.BusinessType }).ToList();
.Select(x => new FlowInstance { BusinessId = x.BusinessId, BusinessType = x.BusinessType }).ToListAsync();
//没有待审批的列表直接返回不再执行后续查询
if (flowList.Count == 0)
DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
@ -123,14 +125,14 @@ namespace DS.WMS.Core.Fee.Method
queryList = queryList.Where(whereList);
}
var result = queryList.ToQueryPage(request.PageCondition);
var result = await queryList.ToQueryPageAsync(request.PageCondition);
if (result.Data.Count > 0)
{
//关联用户名称
var userIds = result.Data.Where(x => x.OperatorId.HasValue).Select(x => x.OperatorId.Value)
.Union(result.Data.Select(x => x.CreateBy))
.Distinct();
var users = db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToList();
var users = await db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
foreach (var item in result.Data)
{
item.CreateByName = users.Find(x => x.Id == item.CreateBy)?.UserName;
@ -145,7 +147,7 @@ namespace DS.WMS.Core.Fee.Method
return result;
}
//创建各项业务数据的查询并集
//创建各项费用数据的查询并集
internal static ISugarQueryable<FeeAuditBusiness> CreateQuery(SqlSugarScopeProvider tenantDb, IEnumerable<FlowInstance> additions)
{
//海运出口
@ -153,7 +155,7 @@ namespace DS.WMS.Core.Fee.Method
var query1 = tenantDb.Queryable<SeaExport, BusinessFeeStatus, FeeRecord, CodeSource, CodeSourceDetail>((s, b, f, cs, csd) => new JoinQueryInfos(
JoinType.Left, s.Id == b.BusinessId && b.BusinessType == BusinessType.OceanShippingExport,
JoinType.Inner, s.Id == f.BusinessId && f.BusinessType == BusinessType.OceanShippingExport && AuditStatusArray.Contains(f.FeeStatus),
JoinType.Left,s.SourceId == cs.Id,
JoinType.Left, s.SourceId == cs.Id,
JoinType.Left, s.SourceDetailId == csd.Id
))
.WhereIF(ids1 != null && ids1.Length > 0, (s, b, f) => ids1.Contains(f.Id))
@ -311,7 +313,7 @@ namespace DS.WMS.Core.Fee.Method
});
//海运进口
return tenantDb.UnionAll(new List<ISugarQueryable<FeeAuditBusiness>> { query1 });
}
@ -323,16 +325,16 @@ namespace DS.WMS.Core.Fee.Method
/// <param name="remark">备注</param>
/// <param name="idArray">待审批的费用ID</param>
/// <returns></returns>
public DataResult Audit(int yesOrNo, string remark, params long[] idArray)
public async Task<DataResult> AuditAsync(int yesOrNo, string remark, params long[] idArray)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var fees = tenantDb.Queryable<FeeRecord>().Where(x => idArray.Contains(x.Id)).Select(x => new
var fees = await tenantDb.Queryable<FeeRecord>().Where(x => idArray.Contains(x.Id)).Select(x => new
{
x.Id,
x.FeeName,
x.FeeStatus,
x.FlowId
}).ToList();
}).ToListAsync();
if (fees.Count == 0)
return DataResult.Failed("未能获取费用信息");
@ -344,7 +346,7 @@ namespace DS.WMS.Core.Fee.Method
return DataResult.Failed("提交数据中包含不在待审批状态的费用");
var flowIds = fees.Select(x => x.FlowId.GetValueOrDefault());
var flows = db.Queryable<FlowInstance>().Where(x => flowIds.Contains(x.Id)).ToList();
var flows = await db.Queryable<FlowInstance>().Where(x => flowIds.Contains(x.Id)).ToListAsync();
if (flows.Count == 0)
return DataResult.Failed("未能获取审批工作流");
@ -385,16 +387,16 @@ namespace DS.WMS.Core.Fee.Method
/// <param name="yesOrNo">审批结果1=通过2=驳回</param>
/// <param name="remark">备注</param>
/// <returns></returns>
public DataResult Audit(int yesOrNo, string remark)
public async Task<DataResult> AuditAsync(int yesOrNo, string remark)
{
var recordIds = db.Queryable<FlowInstance>().Where(x => x.FlowStatus == RunningStatus &&
var recordIds = await db.Queryable<FlowInstance>().Where(x => x.FlowStatus == RunningStatus &&
SqlFunc.SplitIn(x.MakerList, user.UserId) && AuditTypes.Contains(x.AuditType))
.Select(x => x.BusinessId).ToArray();
.Select(x => x.BusinessId).ToArrayAsync();
//没有待审批的列表直接返回不再执行后续查询
if (recordIds.Length == 0)
return DataResult.Failed("当前暂无待审批的费用");
return Audit(yesOrNo, remark, recordIds);
return await AuditAsync(yesOrNo, remark, recordIds);
}
/// <summary>
@ -402,20 +404,20 @@ namespace DS.WMS.Core.Fee.Method
/// </summary>
/// <param name="request">审批请求</param>
/// <returns></returns>
public DataResult AuditBusiness(FeeBizAuditRequest request)
public async Task<DataResult> AuditBusinessAsync(FeeBizAuditRequest request)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var gpList = request.Items.GroupBy(x => x.BusinessType).ToList();
foreach (var gp in gpList)
{
var bIdArr = gp.Select(x => x.Id).ToArray();
var bizList = tenantDb.Queryable<BusinessFeeStatus>().Where(x => bIdArr.Contains(x.BusinessId) && x.BusinessType == gp.Key)
var bizList = await tenantDb.Queryable<BusinessFeeStatus>().Where(x => bIdArr.Contains(x.BusinessId) && x.BusinessType == gp.Key)
.Select(x => new
{
x.Id,
x.BillAuditStatus,
x.FlowId
}).ToList();
}).ToListAsync();
if (bizList.Count == 0)
return DataResult.Failed("未能获取业务信息");
@ -428,13 +430,13 @@ namespace DS.WMS.Core.Fee.Method
var fIdArr = bizList.Select(x => x.FlowId).ToArray();
string auditType = FeeAuditType.Business.ToString();
var flows = db.Queryable<FlowInstance>().Where(x => fIdArr.Contains(x.Id) && x.AuditType == auditType).ToList();
var flows = await db.Queryable<FlowInstance>().Where(x => fIdArr.Contains(x.Id) && x.AuditType == auditType).ToListAsync();
if (flows.Count == 0)
return DataResult.Failed("未能获取审批工作流");
if (flows.Any(x => !x.MakerList.Contains(user.UserId)))
return DataResult.Failed("所选项包含不属于当前用户权限范围内的审批,禁止提交");
continue;
foreach (var flow in flows)
{
@ -461,13 +463,13 @@ namespace DS.WMS.Core.Fee.Method
/// </summary>
/// <param name="items">业务信息</param>
/// <returns></returns>
public DataResult SetFeeLocking(IEnumerable<BusinessFeeStatus> items)
public async Task<DataResult> SetFeeLockingAsync(IEnumerable<BusinessFeeStatus> items)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
int rows = tenantDb.Updateable<BusinessFeeStatus>(items)
int rows = await tenantDb.Updateable<BusinessFeeStatus>(items)
.WhereColumns(x => new { x.BusinessId, x.BusinessType })
.UpdateColumns(x => new { x.IsFeeLocking })
.ExecuteCommand();
.ExecuteCommandAsync();
return rows > 0 ? DataResult.Success : DataResult.Failed("更新失败");
}
@ -477,7 +479,7 @@ namespace DS.WMS.Core.Fee.Method
/// </summary>
/// <param name="callback">回调信息</param>
/// <returns></returns>
public DataResult UpdateAuditStatus(FlowCallback callback)
public async Task<DataResult> UpdateStatusAsync(FlowCallback callback)
{
var auditType = callback.AuditType.ToEnum<FeeAuditType>();
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
@ -485,20 +487,20 @@ namespace DS.WMS.Core.Fee.Method
BusinessFeeStatus biz = null;
if (auditType == FeeAuditType.Business)
{
biz = tenantDb.Queryable<BusinessFeeStatus>().Where(x => x.Id == callback.BusinessId && x.BusinessType == callback.BusinessType)
biz = await tenantDb.Queryable<BusinessFeeStatus>().Where(x => x.Id == callback.BusinessId && x.BusinessType == callback.BusinessType)
.Select(x => new BusinessFeeStatus
{
Id = x.Id,
BusinessId = x.BusinessId,
BillAuditStatus = x.BillAuditStatus
}).First();
}).FirstAsync();
if (biz == null)
return DataResult.Failed("未能找到业务信息,更新状态失败", MultiLanguageConst.Operation_Failed);
}
else
{
fee = tenantDb.Queryable<FeeRecord>().Where(x => x.Id == callback.BusinessId && x.BusinessType == callback.BusinessType).Select(
x => new FeeRecord { Id = x.Id, FeeStatus = x.FeeStatus }).First();
fee = await tenantDb.Queryable<FeeRecord>().Where(x => x.Id == callback.BusinessId && x.BusinessType == callback.BusinessType).Select(
x => new FeeRecord { Id = x.Id, FeeStatus = x.FeeStatus }).FirstAsync();
if (fee == null)
return DataResult.Failed("未能找到费用记录,更新状态失败", MultiLanguageConst.Operation_Failed);
@ -507,7 +509,7 @@ namespace DS.WMS.Core.Fee.Method
long userId = long.Parse(user.UserId);
DateTime dtNow = DateTime.Now;
tenantDb.Ado.BeginTran();
await tenantDb.Ado.BeginTranAsync();
try
{
switch (auditType)
@ -525,7 +527,7 @@ namespace DS.WMS.Core.Fee.Method
else if (callback.FlowStatus == FlowStatusEnum.Reject)
fee.FeeStatus = FeeStatus.RejectSubmission;
tenantDb.Updateable(fee).UpdateColumns(x => new
await tenantDb.Updateable(fee).UpdateColumns(x => new
{
x.FeeStatus,
x.AuditBy,
@ -533,14 +535,14 @@ namespace DS.WMS.Core.Fee.Method
x.AuditDate,
x.Reason,
x.FlowId
}).ExecuteCommand();
}).ExecuteCommandAsync();
break;
case FeeAuditType.ApplyModification:
//申请修改审核成功需要回填费用信息
if (callback.FlowStatus == FlowStatusEnum.Approve)
{
var fm = tenantDb.Queryable<FeeModification>().Where(x => x.FeeRecordId == fee.Id).OrderByDescending(x => x.CreateTime).First();
var fm = await tenantDb.Queryable<FeeModification>().Where(x => x.FeeRecordId == fee.Id).OrderByDescending(x => x.CreateTime).FirstAsync();
if (fm == null)
return DataResult.Failed("未找到费用修改信息,更新失败", MultiLanguageConst.Operation_Failed);
@ -551,29 +553,29 @@ namespace DS.WMS.Core.Fee.Method
entity.UpdateBy = userId;
entity.UpdateTime = dtNow;
//全表更新
tenantDb.Updateable(entity).IgnoreColumns(
x => new { x.AuditBy, x.AuditDate, x.AuditOperator, x.SubmitBy, x.SubmitDate }).ExecuteCommand();
await tenantDb.Updateable(entity).IgnoreColumns(
x => new { x.AuditBy, x.AuditDate, x.AuditOperator, x.SubmitBy, x.SubmitDate }).ExecuteCommandAsync();
//逻辑删除暂存数据
fm.Deleted = true;
fm.DeleteTime = dtNow;
fm.DeleteBy = userId;
tenantDb.Updateable(fm).UpdateColumns(x => new
await tenantDb.Updateable(fm).UpdateColumns(x => new
{
x.DeleteBy,
x.Deleted,
x.DeleteTime
}).ExecuteCommand();
}).ExecuteCommandAsync();
}
else if (callback.FlowStatus == FlowStatusEnum.Reject)
{
fee.FeeStatus = FeeStatus.RejectApplication;
tenantDb.Updateable(fee).UpdateColumns(x => new
await tenantDb.Updateable(fee).UpdateColumns(x => new
{
x.FeeStatus,
x.Reason,
x.FlowId
}).ExecuteCommand();
}).ExecuteCommandAsync();
}
break;
@ -585,27 +587,27 @@ namespace DS.WMS.Core.Fee.Method
fee.DeleteBy = userId;
fee.DeleteTime = dtNow;
tenantDb.Updateable(fee).UpdateColumns(x => new
await tenantDb.Updateable(fee).UpdateColumns(x => new
{
x.DeleteBy,
x.Deleted,
x.DeleteTime,
x.Reason,
x.FlowId
}).ExecuteCommand();
}).ExecuteCommandAsync();
//tenantDb.Deleteable(fee).ExecuteCommand();
//tenantDb.Deleteable(fee).ExecuteCommandAsync();
}
else
{
fee.FeeStatus = FeeStatus.RejectApplication;
tenantDb.Updateable(fee).UpdateColumns(x => new
await tenantDb.Updateable(fee).UpdateColumns(x => new
{
x.FeeStatus,
x.Reason,
x.FlowId
}).ExecuteCommand();
}).ExecuteCommandAsync();
}
break;
@ -621,21 +623,20 @@ namespace DS.WMS.Core.Fee.Method
biz.BillAuditStatus = BillAuditStatus.Rejected;
}
tenantDb.Updateable(biz).UpdateColumns(x => new
await tenantDb.Updateable(biz).UpdateColumns(x => new
{
x.BillAuditStatus,
x.FlowId
}).ExecuteCommand();
}).ExecuteCommandAsync();
tenantDb.Updateable<FeeRecord>()
await tenantDb.Updateable<FeeRecord>()
.SetColumns(x => x.FeeStatus == status)
.SetColumns(x => x.FlowId == null)
.SetColumns(x => x.AuditBy == userId)
.SetColumns(x => x.AuditOperator == user.UserName)
.SetColumns(x => x.AuditDate == dtNow)
.Where(x => x.BusinessId == biz.BusinessId && x.BusinessType == callback.BusinessType &&
(x.FeeStatus == FeeStatus.Entering || x.FeeStatus == FeeStatus.RejectSubmission)).ExecuteCommand();
(x.FeeStatus == FeeStatus.Entering || x.FeeStatus == FeeStatus.RejectSubmission)).ExecuteCommandAsync();
break;
default:
@ -645,27 +646,27 @@ namespace DS.WMS.Core.Fee.Method
//驳回申请则逻辑删除关联工作流
if (callback.FlowStatus == FlowStatusEnum.Reject)
{
db.Updateable(new FlowInstance
await db.Updateable(new FlowInstance
{
Id = callback.InstanceId,
Deleted = true,
DeleteBy = 0,
DeleteTime = DateTime.Now
}).UpdateColumns(x => new { x.Deleted, x.DeleteBy, x.DeleteTime }).ExecuteCommand();
}).UpdateColumns(x => new { x.Deleted, x.DeleteBy, x.DeleteTime }).ExecuteCommandAsync();
}
tenantDb.Ado.CommitTran();
await tenantDb.Ado.CommitTranAsync();
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
}
catch (Exception ex)
{
tenantDb.Ado.RollbackTran();
ex.Log(db);
await tenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(db);
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
}
finally
{
FeeRecordService.WriteBackStatus(tenantDb, callback.BusinessId, callback.BusinessType);
await feeService.WriteBackStatusAsync(tenantDb, callback.BusinessId, callback.BusinessType);
}
}

@ -49,23 +49,23 @@ namespace DS.WMS.Core.Fee.Method
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DataResult<List<FeeRecordRes>> GetListByPage(PageRequest request)
public async Task<DataResult<List<FeeRecordRes>>> GetListByPageAsync(PageRequest request)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
long userId = long.Parse(user.UserId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<FeeRecord>()
var data = await tenantDb.Queryable<FeeRecord>()
.Where(x => x.IsOpen || (!x.IsOpen && x.CreateBy == userId))
.Where(whereList)
.Select<FeeRecordRes>()
.ToQueryPage(request.PageCondition);
.ToQueryPageAsync(request.PageCondition);
//关联用户名称
var userIds = data.Data.Where(x => x.UpdateBy.HasValue).Select(x => x.UpdateBy.Value)
//.Union(data.Data.Where(x => x.SubmitBy.HasValue).Select(x => x.SubmitBy.Value))
.Union(data.Data.Select(x => x.CreateBy)).Distinct();
var users = db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToList();
var users = await db.Queryable<SysUser>().Where(x => userIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
foreach (var item in data.Data)
{
item.CreateByName = users.Find(x => x.Id == item.CreateBy)?.UserName;
@ -89,7 +89,7 @@ namespace DS.WMS.Core.Fee.Method
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public DataResult<List<FeeRecord>> GetList(string query)
public async Task<DataResult<List<FeeRecord>>> GetListAsync(string query)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
long userId = long.Parse(user.UserId);
@ -101,7 +101,7 @@ namespace DS.WMS.Core.Fee.Method
src = src.Where(whereList);
}
var data = src.ToList();
var data = await src.ToListAsync();
return new DataResult<List<FeeRecord>>(ResultCode.Success) { Data = data };
}
@ -112,7 +112,7 @@ namespace DS.WMS.Core.Fee.Method
/// <param name="businessType">业务类型</param>
/// <param name="type">锁定范围</param>
/// <returns></returns>
bool IsFeeLocked(long bid, BusinessType businessType, FeeType type = FeeType.All)
internal async Task<bool> IsFeeLockedAsync(long bid, BusinessType businessType, FeeType type = FeeType.All)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
bool? isFeeLocking = null;
@ -123,8 +123,8 @@ namespace DS.WMS.Core.Fee.Method
case FeeType.Payable:
break;
case FeeType.All:
isFeeLocking = tenantDb.Queryable<BusinessFeeStatus>().Where(
x => x.BusinessId == bid && x.BusinessType == businessType).Select(x => x.IsFeeLocking).First();
isFeeLocking = await tenantDb.Queryable<BusinessFeeStatus>().Where(
x => x.BusinessId == bid && x.BusinessType == businessType).Select(x => x.IsFeeLocking).FirstAsync();
break;
}
return isFeeLocking.GetValueOrDefault();
@ -135,29 +135,29 @@ namespace DS.WMS.Core.Fee.Method
/// </summary>
/// <param name="items">要提交的费用记录</param>
/// <returns></returns>
public DataResult InsertOrUpdate(IEnumerable<FeeRecord> items)
public async Task<DataResult> SaveAsync(IEnumerable<FeeRecord> items)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var first = items.Select(x => new { x.BusinessType, x.BusinessId }).FirstOrDefault();
if (IsFeeLocked(first.BusinessId, first.BusinessType))
if (await IsFeeLockedAsync(first.BusinessId, first.BusinessType))
return DataResult.Failed("当前业务已费用锁定,禁止提交", MultiLanguageConst.Operation_Failed);
try
{
tenantDb.Ado.BeginTran();
await tenantDb.Ado.BeginTranAsync();
DateTime dtNow = DateTime.Now;
var feeIds = items.Where(x => x.Id > 0).Select(x => x.Id).ToArray();
//包含修改的项,需要检测费用状态再修改
if (feeIds.Length > 0)
{
var fees = tenantDb.Queryable<FeeRecord>().Where(x => feeIds.Contains(x.Id)).Select(x => new FeeRecord
var fees = await tenantDb.Queryable<FeeRecord>().Where(x => feeIds.Contains(x.Id)).Select(x => new FeeRecord
{
Id = x.Id,
FeeName = x.FeeName,
FeeStatus = x.FeeStatus
}).ToList();
}).ToListAsync();
StringBuilder sb = new StringBuilder();
foreach (var fe in fees)
@ -173,7 +173,7 @@ namespace DS.WMS.Core.Fee.Method
}
//若计价货币单位不等于默认货币则尝试获取最新汇率
FetchExchangeRate(tenantDb, items);
await FetchExchangeRateAsync(tenantDb, items);
List<FeeRecord> list = new List<FeeRecord>(items.Count());
foreach (var item in items)
@ -184,41 +184,42 @@ namespace DS.WMS.Core.Fee.Method
{
item.BusinessId = first.BusinessId;
item.BusinessType = first.BusinessType;
tenantDb.Insertable(item).ExecuteCommand();
await tenantDb.Insertable(item).ExecuteCommandAsync();
}
else
{
tenantDb.Updateable(item).IgnoreColumns(x => new
await tenantDb.Updateable(item).IgnoreColumns(x => new
{
x.FeeStatus,
x.CreateBy,
x.CreateTime,
x.BusinessId,
x.BusinessType,
x.DeleteBy,
x.Deleted,
x.DeleteTime,
x.SubmitDate,
x.SubmitBy
}).ExecuteCommand();
}).ExecuteCommandAsync();
}
list.Add(item);
}
tenantDb.Ado.CommitTran();
await tenantDb.Ado.CommitTranAsync();
var list2 = list.Select(x => x.Adapt<FeeRecordRes>()).ToList();
return DataResult.Successed("保存成功", list2, MultiLanguageConst.DataUpdateSuccess);
}
catch (Exception ex)
{
tenantDb.Ado.RollbackTran();
ex.Log(db);
await tenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(db);
return DataResult.Failed("保存失败", MultiLanguageConst.DataUpdateFailed);
}
finally
{
WriteBackStatus(tenantDb, first.BusinessId, first.BusinessType);
await WriteBackStatusAsync(tenantDb, first.BusinessId, first.BusinessType);
}
}
@ -229,17 +230,17 @@ namespace DS.WMS.Core.Fee.Method
/// <param name="businessType">业务类型</param>
/// <param name="tidArray">模板ID</param>
/// <returns></returns>
public DataResult CreateByTemplate(long bid, BusinessType businessType, params long[] tidArray)
public async Task<DataResult> CreateByTemplateAsync(long bid, BusinessType businessType, params long[] tidArray)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
bool hasExists = tenantDb.Queryable<FeeRecord>().LeftJoin<FeeTemplateDetail>((x, y) =>
x.FeeId == y.FeeId && x.FeeType == y.FeeType).Any((x, y) =>
x.BusinessId == bid && x.BusinessType == businessType && tidArray.Contains(y.TemplateId) && !y.Deleted);
x.FeeId == y.FeeId && x.FeeType == y.FeeType).Any(
(x, y) => x.BusinessId == bid && x.BusinessType == businessType && tidArray.Contains(y.TemplateId));
if (hasExists)
return DataResult.Failed("费用记录已存在", MultiLanguageConst.FeeRecordExist);
var details = 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
{
x.FeeType,
x.FeeId,
@ -261,7 +262,7 @@ namespace DS.WMS.Core.Fee.Method
x.IsInvoice,
x.SaleOrgId,
x.Note
}).ToList();
}).ToListAsync();
List<FeeRecord> records = new List<FeeRecord>(details.Count);
foreach (var item in details)
@ -274,11 +275,10 @@ namespace DS.WMS.Core.Fee.Method
}
//若计价货币单位不等于默认货币则尝试获取最新汇率
FetchExchangeRate(tenantDb, records);
int result = tenantDb.Insertable(records).ExecuteCommand();
await FetchExchangeRateAsync(tenantDb, records);
int result = await tenantDb.Insertable(records).ExecuteCommandAsync();
WriteBackStatus(tenantDb, bid, businessType);
await WriteBackStatusAsync(tenantDb, bid, businessType);
return result > 0 ? DataResult.Successed("保存成功", records, MultiLanguageConst.DataCreateSuccess) : DataResult.Successed("操作失败!", MultiLanguageConst.Operation_Failed);
}
@ -288,20 +288,20 @@ namespace DS.WMS.Core.Fee.Method
/// </summary>
/// <param name="ids">费用记录ID</param>
/// <returns></returns>
public DataResult Delete(params long[] ids)
public async Task<DataResult> DeleteAsync(params long[] ids)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var model = tenantDb.Queryable<FeeRecord>().Where(x => ids.Contains(x.Id)).Select(x => new { x.BusinessId, x.BusinessType }).First();
if (IsFeeLocked(model.BusinessId, model.BusinessType))
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))
return DataResult.Failed("当前业务已费用锁定,禁止修改", MultiLanguageConst.Operation_Failed);
if (tenantDb.Queryable<FeeRecord>().Any(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);
int result = tenantDb.Deleteable<FeeRecord>(x => ids.Contains(x.Id)).ExecuteCommand();
int result = await tenantDb.Deleteable<FeeRecord>(x => ids.Contains(x.Id)).ExecuteCommandAsync();
WriteBackStatus(tenantDb, model.BusinessId, model.BusinessType);
await WriteBackStatusAsync(tenantDb, model.BusinessId, model.BusinessType);
return result > 0 ? DataResult.Successed("删除成功!", MultiLanguageConst.DataDelSuccess) : DataResult.Failed("删除失败!", MultiLanguageConst.Operation_Failed);
}
@ -313,10 +313,10 @@ namespace DS.WMS.Core.Fee.Method
/// <param name="remark">备注</param>
/// <param name="idArray">费用记录ID</param>
/// <returns></returns>
public DataResult SubmitForApproval(FeeAuditType auditType, string remark, params long[] idArray)
public async Task<DataResult> SubmitForApprovalAsync(FeeAuditType auditType, string remark, params long[] idArray)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var fees = tenantDb.Queryable<FeeRecord>().Where(x => idArray.Contains(x.Id)).Select(
var fees = await tenantDb.Queryable<FeeRecord>().Where(x => idArray.Contains(x.Id)).Select(
x => new FeeRecord
{
Id = x.Id,
@ -324,14 +324,14 @@ namespace DS.WMS.Core.Fee.Method
FeeStatus = x.FeeStatus,
FlowId = x.FlowId,
BusinessId = x.BusinessId
}).ToList();
}).ToListAsync();
if (fees.IsNullOrEmpty())
return DataResult.Failed($"未能获取费用信息,提交失败", MultiLanguageConst.Operation_Failed);
var bid = fees[0].BusinessId;
var bType = fees[0].BusinessType;
//业务状态检测
if (IsFeeLocked(bid, bType))
if (await IsFeeLockedAsync(bid, bType))
return DataResult.Failed("当前业务已费用锁定,禁止提交", MultiLanguageConst.Operation_Failed);
if (fees.Any(x => x.FlowId.HasValue))
@ -341,7 +341,7 @@ namespace DS.WMS.Core.Fee.Method
return DataResult.Failed($"当前审批费用包含已结算/部分结算的费用,无法提交", MultiLanguageConst.Operation_Failed);
DataResult result = DataResult.Failed(string.Empty, MultiLanguageConst.Operation_Failed);
tenantDb.Ado.BeginTran();
await tenantDb.Ado.BeginTranAsync();
try
{
if (auditType == FeeAuditType.ApplyAudit)
@ -355,25 +355,25 @@ namespace DS.WMS.Core.Fee.Method
if (!result.Succeeded)
{
tenantDb.Ado.RollbackTran();
await tenantDb.Ado.RollbackTranAsync();
return result;
}
tenantDb.Updateable(fees).UpdateColumns(x => new
await tenantDb.Updateable(fees).UpdateColumns(x => new
{
x.Id,
x.FeeStatus,
x.SubmitBy,
x.SubmitDate,
x.FlowId
}).ExecuteCommand();
tenantDb.Ado.CommitTran();
}).ExecuteCommandAsync();
await tenantDb.Ado.CommitTranAsync();
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
}
catch (Exception ex)
{
tenantDb.Ado.RollbackTran();
ex.Log(db);
await tenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(db);
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
}
}
@ -472,16 +472,16 @@ namespace DS.WMS.Core.Fee.Method
/// </summary>
/// <param name="items">费用修改信息</param>
/// <returns></returns>
public DataResult SubmitForModification(IEnumerable<FeeModification> items)
public async Task<DataResult> SubmitForModificationAsync(IEnumerable<FeeModification> items)
{
var idList = items.Select(x => x.FeeRecordId).Distinct().ToList();
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var fees = tenantDb.Queryable<FeeRecord>().Where(x => idList.Contains(x.Id)).Select(x => new FeeRecord
var fees = await tenantDb.Queryable<FeeRecord>().Where(x => idList.Contains(x.Id)).Select(x => new FeeRecord
{
Id = x.Id,
FeeName = x.FeeName,
FeeStatus = x.FeeStatus
}).ToList();
}).ToListAsync();
if (fees.Count == 0)
return DataResult.Failed("未能获取费用信息", MultiLanguageConst.Operation_Failed);
@ -502,7 +502,7 @@ namespace DS.WMS.Core.Fee.Method
return DataResult.Failed("未能找到审批模板", MultiLanguageConst.Operation_Failed);
DateTime dtNow = DateTime.Now;
tenantDb.Ado.BeginTran();
await tenantDb.Ado.BeginTranAsync();
try
{
foreach (var fee in fees)
@ -528,16 +528,16 @@ namespace DS.WMS.Core.Fee.Method
}
var list = items.ToList();
tenantDb.Insertable(list).ExecuteCommand();
tenantDb.Updateable(fees).UpdateColumns(x => new { x.FeeStatus, x.FlowId }).ExecuteCommand();
await tenantDb.Insertable(list).ExecuteCommandAsync();
await tenantDb.Updateable(fees).UpdateColumns(x => new { x.FeeStatus, x.FlowId }).ExecuteCommandAsync();
tenantDb.Ado.CommitTran();
await tenantDb.Ado.CommitTranAsync();
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
}
catch (Exception ex)
{
tenantDb.Ado.RollbackTran();
ex.Log(db);
await tenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(db);
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
}
}
@ -547,17 +547,17 @@ namespace DS.WMS.Core.Fee.Method
/// </summary>
/// <param name="idArray">费用记录ID</param>
/// <returns></returns>
public DataResult Withdraw(params long[] idArray)
public async Task<DataResult> WithdrawAsync(params long[] idArray)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var fees = tenantDb.Queryable<FeeRecord>().Where(x => idArray.Contains(x.Id)).Select(
var fees = await tenantDb.Queryable<FeeRecord>().Where(x => idArray.Contains(x.Id)).Select(
x => new FeeRecord
{
Id = x.Id,
FeeName = x.FeeName,
FeeStatus = x.FeeStatus,
FlowId = x.FlowId
}).ToList();
}).ToListAsync();
if (fees.IsNullOrEmpty())
return DataResult.Failed("未能找到费用记录", MultiLanguageConst.Operation_Failed);
@ -574,8 +574,8 @@ namespace DS.WMS.Core.Fee.Method
DateTime dtNow = DateTime.Now;
try
{
tenantDb.Ado.BeginTran();
db.Updateable(flows).UpdateColumns(x => new { x.FlowStatus, x.MakerList }).ExecuteCommand();
await tenantDb.Ado.BeginTranAsync();
await db.Updateable(flows).UpdateColumns(x => new { x.FlowStatus, x.MakerList }).ExecuteCommandAsync();
foreach (var item in fees)
{
@ -588,11 +588,11 @@ namespace DS.WMS.Core.Fee.Method
item.FeeStatus = FeeStatus.AuditPassed;
//删除暂存数据
var entity = tenantDb.Queryable<FeeModification>().OrderByDescending(
x => x.CreateTime).Select(x => new { x.Id, x.FeeRecordId }).First(x => x.FeeRecordId == item.Id);
var entity = await tenantDb.Queryable<FeeModification>().OrderByDescending(
x => x.CreateTime).Select(x => new { x.Id, x.FeeRecordId }).FirstAsync(x => x.FeeRecordId == item.Id);
if (entity != null)
{
tenantDb.Deleteable<FeeModification>().Where(x => x.Id == entity.Id).ExecuteCommand();
await tenantDb.Deleteable<FeeModification>().Where(x => x.Id == entity.Id).ExecuteCommandAsync();
}
break;
case FeeStatus.ApplyDeletion:
@ -605,15 +605,15 @@ namespace DS.WMS.Core.Fee.Method
item.FlowId = null;
}
tenantDb.Updateable(fees).UpdateColumns(x => new { x.Id, x.FeeStatus, x.SubmitBy, x.SubmitDate, x.FlowId }).ExecuteCommand();
await tenantDb.Updateable(fees).UpdateColumns(x => new { x.Id, x.FeeStatus, x.SubmitBy, x.SubmitDate, x.FlowId }).ExecuteCommandAsync();
tenantDb.Ado.CommitTran();
await tenantDb.Ado.CommitTranAsync();
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
}
catch (Exception ex)
{
tenantDb.Ado.RollbackTran();
ex.Log(db);
await tenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(db);
return DataResult.Failed("提交失败!", MultiLanguageConst.Operation_Failed);
}
@ -625,17 +625,17 @@ namespace DS.WMS.Core.Fee.Method
/// <param name="bid">业务ID</param>
/// <param name="type">业务类型</param>
/// <returns></returns>
public DataResult SubmitBusinessAudit(long bid, BusinessType type)
public async Task<DataResult> SubmitBusinessAuditAsync(long bid, BusinessType type)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var entity = tenantDb.Queryable<BusinessFeeStatus>().Where(x => x.BusinessId == bid &&
var entity = await 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();
}).FirstAsync();
if (entity == null)
return DataResult.Failed("未能找到业务信息", MultiLanguageConst.Operation_Failed);
@ -666,14 +666,16 @@ namespace DS.WMS.Core.Fee.Method
entity.BillFeeStatusTime = DateTime.Now;
entity.FlowId = instance.Id;
tenantDb.Updateable(entity).UpdateColumns(x => new
await tenantDb.Updateable(entity).UpdateColumns(x => new
{
x.BillAuditStatus,
x.BillFeeStatusTime,
x.FlowId
}).ExecuteCommand();
}).ExecuteCommandAsync();
//修改关联费用状态为提交审核
tenantDb.Ado.CommitTran();
return DataResult.Successed("提交成功!", MultiLanguageConst.DataUpdateSuccess);
}
@ -686,11 +688,11 @@ namespace DS.WMS.Core.Fee.Method
/// <param name="enabled">是否启用</param>
/// <param name="idArray">费用记录ID</param>
/// <returns></returns>
public DataResult SetInvoiceEnabled(bool enabled, params long[] idArray)
public async Task<DataResult> SetInvoiceEnabledAsync(bool enabled, params long[] idArray)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = idArray.Select(x => new FeeRecord { Id = x, IsInvoice = enabled }).ToList();
int rows = tenantDb.Updateable(list).UpdateColumns(x => new { x.IsInvoice }).ExecuteCommand();
int rows = await tenantDb.Updateable(list).UpdateColumns(x => new { x.IsInvoice }).ExecuteCommandAsync();
return rows > 0 ? DataResult.Successed("设置成功!", MultiLanguageConst.DataUpdateSuccess) : DataResult.Failed("设置失败!", MultiLanguageConst.Operation_Failed);
}
@ -701,15 +703,15 @@ namespace DS.WMS.Core.Fee.Method
/// <param name="customerType">客户类别</param>
/// <param name="idArray">费用记录ID</param>
/// <returns></returns>
public DataResult SetCustomer(long customerId, string customerType, params long[] idArray)
public async Task<DataResult> SetCustomerAsync(long customerId, string customerType, params long[] idArray)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var model = tenantDb.Queryable<InfoClient>().Where(x => x.Id == customerId).Select(x => new
var model = await tenantDb.Queryable<InfoClient>().Where(x => x.Id == customerId).Select(x => new
{
Id = customerId,
x.CodeName,
x.Name
}).First();
}).FirstAsync();
if (model == null)
return DataResult.Failed("未能找到费用对象信息,设置失败!", MultiLanguageConst.Operation_Failed);
@ -721,7 +723,7 @@ namespace DS.WMS.Core.Fee.Method
CustomerName = model.Name,
CustomerType = customerType
}).ToList();
int rows = tenantDb.Updateable(list).UpdateColumns(x => new { x.CustomerId, x.CustomerCode, x.CustomerName, x.CustomerType }).ExecuteCommand();
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);
}
@ -731,16 +733,14 @@ namespace DS.WMS.Core.Fee.Method
/// <param name="businessType">业务类型</param>
/// <param name="idArray">费用记录ID</param>
/// <returns></returns>
public DataResult<CostAccountingForm> GetPrintInfo(BusinessType businessType, params long[] idArray)
public async Task<DataResult<CostAccountingForm>> GetPrintInfoAsync(BusinessType businessType, params long[] idArray)
{
CostAccountingForm form = null;
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
switch (businessType)
{
//case BusinessType.ChangeOrder:
// break;
case BusinessType.OceanShippingExport:
form = GetOceanShippingExportForm(tenantDb, idArray);
form = await GetOceanShippingExportAsync(tenantDb, idArray);
break;
case BusinessType.OceanShippingImport:
@ -767,7 +767,7 @@ namespace DS.WMS.Core.Fee.Method
new FeeRecord { Currency = "USD", FeeType = FeeType.Receivable },
new FeeRecord { Currency = "USD", FeeType = FeeType.Payable }
};
FetchExchangeRate(tenantDb, fees);
await FetchExchangeRateAsync(tenantDb, fees);
form.ExchangeRate = fees[0].ExchangeRate.HasValue ? fees[0].ExchangeRate.Value : 1;
form.TotalReceivable = Math.Round(form.ReceivableUSD * form.ExchangeRate, 4, MidpointRounding.ToEven) + form.ReceivableRMB + form.ReceivableOther;
form.TotalPayable = Math.Round(form.PayableUSD * form.ExchangeRate, 4, MidpointRounding.ToEven) + form.PayableRMB + form.PayableOther;
@ -776,11 +776,11 @@ namespace DS.WMS.Core.Fee.Method
return DataResult<CostAccountingForm>.Success(form);
}
CostAccountingForm GetOceanShippingExportForm(SqlSugarScopeProvider tenantDb, params long[] idArray)
//获取海运出口打印数据
async Task<CostAccountingForm> GetOceanShippingExportAsync(SqlSugarScopeProvider tenantDb, params long[] idArray)
{
CostAccountingForm form = null;
var list = tenantDb.Queryable<FeeRecord>().InnerJoin<SeaExport>((x, y) => x.BusinessId == y.Id)
var list = await tenantDb.Queryable<FeeRecord>().InnerJoin<SeaExport>((x, y) => x.BusinessId == y.Id)
.Where((x, y) => idArray.Contains(x.Id)
//&& x.FeeStatus == FeeStatus.SettlementCompleted
).Select((x, y) => new
@ -802,7 +802,7 @@ namespace DS.WMS.Core.Fee.Method
y.DischargePort,
y.CntrTotal, //Volume
y.IssueType //放单方式
}).ToList();
}).ToListAsync();
if (list.Count == 0)
return form;
@ -835,21 +835,23 @@ namespace DS.WMS.Core.Fee.Method
return form;
}
//回写业务主表的费用状态
internal static void WriteBackStatus(SqlSugarScopeProvider tenantDb, long businessId, BusinessType businessType)
/// <summary>
/// 回写业务表费用状态
/// </summary>
/// <param name="tenantDb"></param>
/// <param name="businessId">业务ID</param>
/// <param name="businessType">业务类型</param>
/// <returns></returns>
public async Task WriteBackStatusAsync(SqlSugarScopeProvider tenantDb, long businessId, BusinessType businessType)
{
var fees = tenantDb.Queryable<FeeRecord>().Where(x => x.BusinessId == businessId && x.BusinessType == businessType)
var fees = await tenantDb.Queryable<FeeRecord>().Where(x => x.BusinessId == businessId && x.BusinessType == businessType)
.Select(x => new FeeRecord
{
//BusinessId = businessId,
//BusinessType = businessType,
FeeType = x.FeeType,
FeeStatus = x.FeeStatus
}).ToList();
}).ToListAsync();
if (fees.IsNullOrEmpty())
{
return;
}
var arFeeStatus = DetermineStatus(fees.FindAll(x => x.FeeType == FeeType.Receivable));
var apFeeStatus = DetermineStatus(fees.FindAll(x => x.FeeType == FeeType.Payable));
@ -866,8 +868,14 @@ namespace DS.WMS.Core.Fee.Method
upt = upt.SetColumns(x => x.APFeeStatus == apFeeStatus);
}
upt.Where(x => x.BusinessType == businessType && x.BusinessId == businessId)
.ExecuteCommand();
try
{
await upt.Where(x => x.BusinessType == businessType && x.BusinessId == businessId).ExecuteCommandAsync();
}
catch (Exception ex)
{
await ex.LogAsync(db);
}
}
}
@ -879,6 +887,7 @@ namespace DS.WMS.Core.Fee.Method
{
billFeeStatus = BillFeeStatus.NotEntered;
}
//全状态
else if (fees.All(x => x.FeeStatus == FeeStatus.Entering))
{
billFeeStatus = BillFeeStatus.Entering;
@ -903,6 +912,7 @@ namespace DS.WMS.Core.Fee.Method
{
billFeeStatus = BillFeeStatus.SettlementCompleted;
}
//部分状态
else if (fees.Any(x => x.FeeStatus == FeeStatus.Entering))
{
billFeeStatus = BillFeeStatus.PartialEntering;
@ -933,13 +943,13 @@ namespace DS.WMS.Core.Fee.Method
}
//获取汇率
void FetchExchangeRate(SqlSugarScopeProvider tenantDb, IEnumerable<FeeRecord> items)
async Task FetchExchangeRateAsync(SqlSugarScopeProvider tenantDb, IEnumerable<FeeRecord> items)
{
var exRecords = items.Where(x => !x.ExchangeRate.HasValue && x.Currency != DefaultCurrency).ToList();
if (exRecords.Count > 0)
{
var codes = exRecords.Select(x => x.Currency).Distinct().ToList();
var currencies = tenantDb.Queryable<FeeCurrency>().Where(x => codes.Contains(x.CodeName)).Includes(x => x.Exchanges).ToList();
var currencies = await tenantDb.Queryable<FeeCurrency>().Where(x => codes.Contains(x.CodeName)).Includes(x => x.Exchanges).ToListAsync();
DateTime dtNow = DateTime.Now;
foreach (var item in exRecords)
{

@ -10,6 +10,9 @@ using Microsoft.Extensions.DependencyInjection;
namespace DS.WMS.Core.Flow.Method;
/// <summary>
/// 租户端工作流实例管理
/// </summary>
public class ClientFlowInstanceService : FlowInstanceService, IClientFlowInstanceService
{
readonly ISaasDbService saasService;

@ -441,7 +441,7 @@ public class FlowInstanceService : IFlowInstanceService
var response = await http.PostAsync(uri, jsonRequest);
if (!response.IsSuccessStatusCode)
{
new HttpRequestException("回调请求失败", null, response.StatusCode).Log(db);
new HttpRequestException("回调请求失败", null, response.StatusCode).LogAsync(db);
}
//更新回调执行标识
@ -450,7 +450,7 @@ public class FlowInstanceService : IFlowInstanceService
}
catch (Exception ex)
{
ex.Log(db);
ex.LogAsync(db);
}
finally
{

@ -2,7 +2,6 @@
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Flow.Interface;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.FeeApi.Controllers
@ -13,14 +12,10 @@ namespace DS.WMS.FeeApi.Controllers
public class FeeAuditController : ApiController
{
readonly IFeeAuditService _auditService;
readonly IFeeRecordService _feeService;
readonly IClientFlowInstanceService _flowService;
public FeeAuditController(IFeeAuditService auditService, IFeeRecordService feeService, IClientFlowInstanceService flowService)
public FeeAuditController(IFeeAuditService auditService)
{
_auditService = auditService;
_feeService = feeService;
_flowService = flowService;
}
/// <summary>
@ -29,9 +24,9 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("GetList")]
public DataResult<List<FeeAuditBusiness>> List([FromBody] PageRequest request)
public async Task<DataResult<List<FeeAuditBusiness>>> ListAsync([FromBody] PageRequest request)
{
return _auditService.GetList(request);
return await _auditService.GetListAsync(request);
}
/// <summary>
@ -40,9 +35,9 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("GetBizList")]
public DataResult<List<FeeAuditBusiness>> BizList([FromBody] PageRequest request)
public async Task<DataResult<List<FeeAuditBusiness>>> BizListAsync([FromBody] PageRequest request)
{
return _auditService.GetBizList(request);
return await _auditService.GetBizListAsync(request);
}
/// <summary>
@ -51,12 +46,12 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("Audit")]
public DataResult Audit(FeeAuditRequest request)
public async Task<DataResult> AuditAsync(FeeAuditRequest request)
{
if (request == null || request.Ids.Length == 0 || (request.Result != 1 && request.Result != 2))
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return _auditService.Audit(request.Result, request.Remark, request.Ids);
return await _auditService.AuditAsync(request.Result, request.Remark, request.Ids);
}
/// <summary>
@ -66,12 +61,12 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="remark">审批备注</param>
/// <returns></returns>
[HttpPost, Route("OneClickAudit")]
public DataResult OneClickAudit(int status, string remark)
public async Task<DataResult> OneClickAuditAsync(int status, string remark)
{
if (status != 1 && status != 2)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return _auditService.Audit(status, remark);
return await _auditService.AuditAsync(status, remark);
}
/// <summary>
@ -80,12 +75,12 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("AuditBusiness")]
public DataResult AuditBusiness(FeeBizAuditRequest request)
public async Task<DataResult> AuditBusinessAsync(FeeBizAuditRequest request)
{
if (request == null || (request.Result != 1 && request.Result != 2) || request.Items == null || !request.Items.Any())
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return _auditService.AuditBusiness(request);
return await _auditService.AuditBusinessAsync(request);
}
/// <summary>
@ -94,12 +89,12 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="callback">回调信息</param>
/// <returns></returns>
[HttpPost, Route("ChangeStatus")]
public DataResult ChangeStatus([FromBody] FlowCallback callback)
public async Task<DataResult> ChangeStatusAsync([FromBody] FlowCallback callback)
{
if (callback == null)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return _auditService.UpdateAuditStatus(callback);
return await _auditService.UpdateStatusAsync(callback);
}
}
}

@ -4,7 +4,6 @@ using DS.Module.Core.Extensions;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Fee.Entity;
using DS.WMS.Core.Fee.Interface;
using DS.WMS.Core.Flow.Interface;
using DS.WMS.Core.Op.Entity;
using Mapster;
using Microsoft.AspNetCore.Mvc;
@ -17,17 +16,15 @@ namespace DS.WMS.FeeApi.Controllers
public class FeeRecordController : ApiController
{
readonly IFeeRecordService _feeService;
readonly IClientFlowInstanceService _flowService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="feeService"></param>
/// <param name="flowService"></param>
public FeeRecordController(IFeeRecordService feeService, IClientFlowInstanceService flowService)
public FeeRecordController(IFeeRecordService feeService)
{
_feeService = feeService;
_flowService = flowService;
}
/// <summary>
@ -37,10 +34,9 @@ namespace DS.WMS.FeeApi.Controllers
/// <returns></returns>
[HttpPost]
[Route("GetList")]
public DataResult<List<FeeRecordRes>> GetList([FromBody] PageRequest request)
public async Task<DataResult<List<FeeRecordRes>>> GetListAsync([FromBody] PageRequest request)
{
var res = _feeService.GetListByPage(request);
return res;
return await _feeService.GetListByPageAsync(request);
}
/// <summary>
@ -49,12 +45,12 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="request">查询条件</param>
/// <returns></returns>
[HttpPost, Route("FeeStatistics")]
public DataResult<FeeStatistics> FeeStatistics([FromBody] FeeStatisticsRequest request)
public async Task<DataResult<FeeStatistics>> StatisticsAsync([FromBody] FeeStatisticsRequest request)
{
if (request == null)
return DataResult<FeeStatistics>.Failed("参数无效", MultiLanguageConst.IllegalRequest);
var res = _feeService.GetList(request.QueryCondition);
var res = await _feeService.GetListAsync(request.QueryCondition);
if (!res.Succeeded)
return DataResult<FeeStatistics>.Error(res.Message);
@ -68,7 +64,7 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="recordSubmit">费用提交参数</param>
/// <returns></returns>
[HttpPost, Route("Submit")]
public DataResult Submit([FromBody] FeeRecordSubmit recordSubmit)
public async Task<DataResult> SubmitAsync([FromBody] FeeRecordSubmit recordSubmit)
{
if (recordSubmit == null || recordSubmit.Items.IsNullOrEmpty())
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
@ -82,7 +78,7 @@ namespace DS.WMS.FeeApi.Controllers
item.BusinessId = recordSubmit.BusinessId;
item.BusinessType = recordSubmit.BusinessType;
}
return _feeService.InsertOrUpdate(list);
return await _feeService.SaveAsync(list);
}
/// <summary>
@ -91,13 +87,12 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="request">请求参数</param>
/// <returns></returns>
[HttpPost, Route("CreateByTemplate")]
public DataResult CreateByTemplate([FromBody] FeeRecordByTemplate request)
public async Task<DataResult> CreateByTemplateAsync([FromBody] FeeRecordByTemplate request)
{
if (request == null || request.TemplateIdList.Length == 0)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
var res = _feeService.CreateByTemplate(request.BusinessId, request.BusinessType, request.TemplateIdList);
return res;
return await _feeService.CreateByTemplateAsync(request.BusinessId, request.BusinessType, request.TemplateIdList);
}
/// <summary>
@ -106,13 +101,12 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="model">费用记录ID</param>
/// <returns></returns>
[HttpPost, Route("Delete")]
public DataResult Delete([FromBody] IdModel model)
public async Task<DataResult> DeleteAsync([FromBody] IdModel model)
{
if (model == null || model.Ids.Length == 0)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
var res = _feeService.Delete(model.Ids);
return res;
return await _feeService.DeleteAsync(model.Ids);
}
/// <summary>
@ -121,12 +115,12 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="model">费用记录ID</param>
/// <returns></returns>
[HttpPost, Route("ApplyAudit")]
public DataResult ApplyAudit([FromBody] IdModel model)
public async Task<DataResult> ApplyAuditAsync([FromBody] IdModel model)
{
if (model == null || model.Ids.Length == 0)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return _feeService.SubmitForApproval(FeeAuditType.ApplyAudit, model.Remark, model.Ids);
return await _feeService.SubmitForApprovalAsync(FeeAuditType.ApplyAudit, model.Remark, model.Ids);
}
/// <summary>
@ -135,12 +129,12 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="model">费用记录ID</param>
/// <returns></returns>
[HttpPost, Route("ApplyDeletion")]
public DataResult ApplyDeletion([FromBody] IdModel model)
public async Task<DataResult> ApplyDeletionAsync([FromBody] IdModel model)
{
if (model == null || model.Ids.Length == 0)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return _feeService.SubmitForApproval(FeeAuditType.ApplyDeletion, model.Remark, model.Ids);
return await _feeService.SubmitForApprovalAsync(FeeAuditType.ApplyDeletion, model.Remark, model.Ids);
}
/// <summary>
@ -149,12 +143,12 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="items">费用修改信息</param>
/// <returns></returns>
[HttpPost, Route("ApplyModification")]
public DataResult ApplyModification([FromBody] IEnumerable<FeeModification> items)
public async Task<DataResult> ApplyModificationAsync([FromBody] IEnumerable<FeeModification> items)
{
if (items.IsNullOrEmpty())
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return _feeService.SubmitForModification(items);
return await _feeService.SubmitForModificationAsync(items);
}
/// <summary>
@ -163,12 +157,12 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="model">费用记录ID</param>
/// <returns></returns>
[HttpPost, Route("Withdraw")]
public DataResult Withdraw([FromBody] IdModel model)
public async Task<DataResult> WithdrawAsync([FromBody] IdModel model)
{
if (model == null || model.Ids.Length == 0)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return _feeService.Withdraw(model.Ids);
return await _feeService.WithdrawAsync(model.Ids);
}
/// <summary>
@ -177,12 +171,12 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="model">业务ID和类型</param>
/// <returns></returns>
[HttpPost, Route("ApplyBusinessAudit")]
public DataResult ApplyBusinessAudit(IdModel model)
public async Task<DataResult> ApplyBusinessAuditAsync(IdModel model)
{
if (model == null || !long.TryParse(model.Id, out long bid))
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return _feeService.SubmitBusinessAudit(bid, (BusinessType)model.BusinessType);
return await _feeService.SubmitBusinessAuditAsync(bid, (BusinessType)model.BusinessType);
}
/// <summary>
@ -191,12 +185,12 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="model">费用记录ID</param>
/// <returns></returns>
[HttpPost, Route("GetPrintInfo")]
public DataResult<CostAccountingForm> GetPrintInfo(IdModel model)
public async Task<DataResult<CostAccountingForm>> GetPrintInfoAsync(IdModel model)
{
if (model == null || model.Ids.Length == 0)
return DataResult<CostAccountingForm>.Failed("参数无效", MultiLanguageConst.IllegalRequest);
return _feeService.GetPrintInfo((BusinessType)model.BusinessType, model.Ids);
return await _feeService.GetPrintInfoAsync((BusinessType)model.BusinessType, model.Ids);
}
/// <summary>
@ -205,13 +199,13 @@ namespace DS.WMS.FeeApi.Controllers
/// <param name="model">费用记录ID</param>
/// <returns></returns>
[HttpPost, Route("SetInvoiceEnabled")]
public DataResult SetInvoiceEnabled(IdModel model)
public async Task<DataResult> SetInvoiceEnabledAsync(IdModel model)
{
if (model == null || model.Ids.Length == 0)
return DataResult.Failed("参数无效", MultiLanguageConst.IllegalRequest);
bool enabled = Convert.ToBoolean(model.Value);
return _feeService.SetInvoiceEnabled(enabled, model.Ids);
return await _feeService.SetInvoiceEnabledAsync(enabled, model.Ids);
}
}
}

@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project>
<PropertyGroup>
<_PublishTargetUrl>D:\Publish\DS8\FeeApi</_PublishTargetUrl>
<History>True|2024-06-04T06:23:21.3742450Z||;True|2024-05-31T17:01:42.4717460+08:00||;True|2024-05-31T13:56:03.0734064+08:00||;True|2024-05-31T08:45:52.3549394+08:00||;True|2024-05-30T17:16:32.8907958+08:00||;True|2024-05-30T16:18:06.9957657+08:00||;True|2024-05-29T15:44:18.4051203+08:00||;True|2024-05-29T15:11:03.1518632+08:00||;True|2024-05-29T14:52:26.0823495+08:00||;True|2024-05-29T11:17:20.2245101+08:00||;True|2024-05-29T08:36:28.9569161+08:00||;True|2024-05-28T08:44:31.4427261+08:00||;False|2024-05-28T08:44:02.5254826+08:00||;True|2024-05-27T15:16:32.9413631+08:00||;True|2024-05-27T15:03:42.9803879+08:00||;True|2024-05-27T08:49:54.3933663+08:00||;True|2024-05-27T08:46:13.5862236+08:00||;True|2024-05-23T17:19:32.8154451+08:00||;True|2024-05-23T17:19:01.4587615+08:00||;True|2024-05-22T16:52:42.2166228+08:00||;True|2024-05-22T15:19:49.1773202+08:00||;True|2024-05-22T15:13:31.9485525+08:00||;True|2024-05-22T13:29:02.1355808+08:00||;True|2024-05-22T09:48:40.8753914+08:00||;True|2024-05-22T09:25:06.2068137+08:00||;True|2024-05-22T09:18:53.0759815+08:00||;True|2024-05-21T17:13:36.4091775+08:00||;True|2024-05-21T14:41:18.8486299+08:00||;True|2024-05-21T11:04:27.3649637+08:00||;</History>
<History>True|2024-06-06T02:57:27.8273617Z||;True|2024-06-04T14:23:21.3742450+08:00||;True|2024-05-31T17:01:42.4717460+08:00||;True|2024-05-31T13:56:03.0734064+08:00||;True|2024-05-31T08:45:52.3549394+08:00||;True|2024-05-30T17:16:32.8907958+08:00||;True|2024-05-30T16:18:06.9957657+08:00||;True|2024-05-29T15:44:18.4051203+08:00||;True|2024-05-29T15:11:03.1518632+08:00||;True|2024-05-29T14:52:26.0823495+08:00||;True|2024-05-29T11:17:20.2245101+08:00||;True|2024-05-29T08:36:28.9569161+08:00||;True|2024-05-28T08:44:31.4427261+08:00||;False|2024-05-28T08:44:02.5254826+08:00||;True|2024-05-27T15:16:32.9413631+08:00||;True|2024-05-27T15:03:42.9803879+08:00||;True|2024-05-27T08:49:54.3933663+08:00||;True|2024-05-27T08:46:13.5862236+08:00||;True|2024-05-23T17:19:32.8154451+08:00||;True|2024-05-23T17:19:01.4587615+08:00||;True|2024-05-22T16:52:42.2166228+08:00||;True|2024-05-22T15:19:49.1773202+08:00||;True|2024-05-22T15:13:31.9485525+08:00||;True|2024-05-22T13:29:02.1355808+08:00||;True|2024-05-22T09:48:40.8753914+08:00||;True|2024-05-22T09:25:06.2068137+08:00||;True|2024-05-22T09:18:53.0759815+08:00||;True|2024-05-21T17:13:36.4091775+08:00||;True|2024-05-21T14:41:18.8486299+08:00||;True|2024-05-21T11:04:27.3649637+08:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
Loading…
Cancel
Save