|
|
|
@ -29,7 +29,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
public static readonly FeeStatus[] AuditStatusArray = [FeeStatus.AuditSubmitted, FeeStatus.ApplyDeletion, FeeStatus.ApplyModification];
|
|
|
|
|
|
|
|
|
|
//一键审核支持的类型
|
|
|
|
|
static readonly TaskBaseTypeEnum[] AuditTypes = [TaskBaseTypeEnum.FEE_AUDIT, TaskBaseTypeEnum.FEE_MODIFY_AUDIT, TaskBaseTypeEnum.FEE_DELETE_AUDIT];
|
|
|
|
|
static readonly TaskBaseTypeEnum[] AuditTypes = [TaskBaseTypeEnum.FEE_AUDIT, TaskBaseTypeEnum.FEE_MODIFY_AUDIT, TaskBaseTypeEnum.FEE_DELETE_AUDIT, TaskBaseTypeEnum.FEE_BUSINESS_AUDIT];
|
|
|
|
|
|
|
|
|
|
readonly IClientFlowInstanceService flowService;
|
|
|
|
|
readonly IFeeRecordService feeService;
|
|
|
|
@ -53,17 +53,26 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<FeeAuditBusiness>>> GetListAsync(PageRequest<bool> request)
|
|
|
|
|
{
|
|
|
|
|
long[]? ids = null;
|
|
|
|
|
long[]? ids1 = null;
|
|
|
|
|
long[]? ids2 = null;
|
|
|
|
|
if (request.OtherQueryCondition)
|
|
|
|
|
{
|
|
|
|
|
ids = await GetCurrentFlowsQuery(AuditTypes).Select(x => x.BusinessId).Distinct().ToArrayAsync();
|
|
|
|
|
var flows = await GetCurrentFlowsQuery(AuditTypes).Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.BusinessId,
|
|
|
|
|
x.BusinessType,
|
|
|
|
|
x.AuditType
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
//没有待审批的列表直接返回不再执行后续查询
|
|
|
|
|
if (ids.Length == 0)
|
|
|
|
|
if (flows.Count == 0)
|
|
|
|
|
return DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
|
|
|
|
|
ids1 = flows.Where(x => x.AuditType != TaskBaseTypeEnum.FEE_BUSINESS_AUDIT).Select(x => x.BusinessId).ToArray();
|
|
|
|
|
ids2 = flows.Where(x => x.AuditType == TaskBaseTypeEnum.FEE_BUSINESS_AUDIT).Select(x => x.BusinessId).ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var queryList = CreateQuery(ids);
|
|
|
|
|
var queryList = CreateQuery(ids1, ids2);
|
|
|
|
|
|
|
|
|
|
if (!request.QueryCondition.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
@ -93,8 +102,13 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建各项费用数据的查询并集
|
|
|
|
|
internal ISugarQueryable<FeeAuditBusiness> CreateQuery(params long[]? feeIds)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 创建各项费用数据的查询并集
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ids1">费用ID</param>
|
|
|
|
|
/// <param name="ids2">业务ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
internal ISugarQueryable<FeeAuditBusiness> CreateQuery(long[]? ids1, long[]? ids2)
|
|
|
|
|
{
|
|
|
|
|
//海运出口
|
|
|
|
|
var query1 = TenantDb.Queryable<SeaExport, BusinessFeeStatus, FeeRecord, CodeSource, CodeSourceDetail>((s, b, f, cs, csd) => new JoinQueryInfos(
|
|
|
|
@ -103,7 +117,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
JoinType.Left, s.SourceId == cs.Id,
|
|
|
|
|
JoinType.Left, s.SourceDetailId == csd.Id
|
|
|
|
|
))
|
|
|
|
|
.WhereIF(feeIds != null && feeIds.Length > 0, (s, b, f) => feeIds.Contains(f.Id))
|
|
|
|
|
.WhereIF(ids1 != null && ids1.Length > 0 || ids2 != null && ids2.Length > 0, (s, b, f) => ids1.Contains(f.Id) || ids2.Contains(s.Id))
|
|
|
|
|
.GroupBy(s => s.Id)
|
|
|
|
|
.Select((s, b, f, cs, csd) => new FeeAuditBusiness
|
|
|
|
|
{
|
|
|
|
@ -330,7 +344,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
BusinessType = request.BusinessType,
|
|
|
|
|
Carrier = x.Carrier,
|
|
|
|
|
CustomerNo = x.CustomerNo,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CustomerName = x.CustomerName,
|
|
|
|
|
DischargePort = x.DischargePort,
|
|
|
|
|
ETA = x.ETA,
|
|
|
|
@ -343,14 +357,23 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
|
|
|
|
|
if (pendingAudit != null)
|
|
|
|
|
{
|
|
|
|
|
long[] ids = [];
|
|
|
|
|
long[] ids1 = [];
|
|
|
|
|
long[] ids2 = [];
|
|
|
|
|
if (request.AuditOnly)
|
|
|
|
|
{
|
|
|
|
|
ids = await GetCurrentFlowsQuery(AuditTypes).Select(x => x.BusinessId).Distinct().ToArrayAsync();
|
|
|
|
|
var flows = await GetCurrentFlowsQuery(AuditTypes).Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.BusinessId,
|
|
|
|
|
x.BusinessType,
|
|
|
|
|
x.AuditType
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
//没有待审批的列表直接返回不再执行后续查询
|
|
|
|
|
if (ids.Length == 0)
|
|
|
|
|
if (flows.Count == 0)
|
|
|
|
|
return DataResult<PendingAuditFee>.Success(pendingAudit, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
|
|
|
|
|
ids1 = flows.Where(x => x.AuditType != TaskBaseTypeEnum.FEE_BUSINESS_AUDIT).Select(x => x.BusinessId).ToArray();
|
|
|
|
|
ids2 = flows.Where(x => x.AuditType == TaskBaseTypeEnum.FEE_BUSINESS_AUDIT).Select(x => x.BusinessId).ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var fees = await TenantDb.Queryable<FeeRecord>().Where(f => f.BusinessId == request.Id && f.BusinessType == request.BusinessType)
|
|
|
|
@ -362,11 +385,12 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
pendingAudit.IsPositiveProfit = fees.Where(x => x.FeeType == FeeType.Receivable).Sum(x => x.Amount * (x.ExchangeRate ?? 1))
|
|
|
|
|
- fees.Where(x => x.FeeType == FeeType.Payable).Sum(x => x.Amount * (x.ExchangeRate ?? 1)) > 0;
|
|
|
|
|
pendingAudit.IsBusinessAudit = await flowService.Exists(TaskBaseTypeEnum.FEE_BUSINESS_AUDIT, request.BusinessType, null, request.Id);
|
|
|
|
|
|
|
|
|
|
var query1 = TenantDb.Queryable<FeeRecord>().Where(f => f.BusinessId == request.Id && f.BusinessType == request.BusinessType)
|
|
|
|
|
.InnerJoin<SeaExport>((f, s) => f.BusinessId == s.Id)
|
|
|
|
|
.LeftJoin<InfoClient>((f, s, i) => f.CustomerId == i.Id)
|
|
|
|
|
.WhereIF(ids.Length > 0, (f, s, i) => ids.Contains(f.Id) && AuditStatusArray.Contains(f.FeeStatus))
|
|
|
|
|
.WhereIF(ids1.Length > 0, (f, s, i) => (ids1.Contains(f.Id) || ids2.Contains(f.BusinessId)) && AuditStatusArray.Contains(f.FeeStatus))
|
|
|
|
|
.Select((f, s, i) => new FeeAuditItemQuery
|
|
|
|
|
{
|
|
|
|
|
Id = f.Id,
|
|
|
|
@ -521,6 +545,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// <param name="remark">备注</param>
|
|
|
|
|
/// <param name="idArray">待审批的费用ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <remarks>核心审核方法</remarks>
|
|
|
|
|
public async Task<DataResult> AuditAsync(int yesOrNo, string? remark, params long[] idArray)
|
|
|
|
|
{
|
|
|
|
|
var fees = await TenantDb.Queryable<FeeRecord>().Where(x => idArray.Contains(x.Id)).Select(x => new
|
|
|
|
@ -631,11 +656,11 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
public async Task<DataResult> AuditAsync(BizAuditRequest request)
|
|
|
|
|
{
|
|
|
|
|
var ids = await GetCurrentFlowsQuery(TaskBaseTypeEnum.FEE_AUDIT).Select(x => x.BusinessId).ToArrayAsync();
|
|
|
|
|
var query = CreateQuery(ids);
|
|
|
|
|
var query = CreateQuery(ids, []);
|
|
|
|
|
|
|
|
|
|
if (!request.QueryCondition.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
var whereList = Db.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
query = query.Where(whereList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|