|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using Castle.Core.Resource;
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
using DS.WMS.Core.Code.Entity;
|
|
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
|
@ -7,10 +8,13 @@ using DS.WMS.Core.Fee.Interface;
|
|
|
|
|
using DS.WMS.Core.Flow.Dtos;
|
|
|
|
|
using DS.WMS.Core.Flow.Entity;
|
|
|
|
|
using DS.WMS.Core.Flow.Interface;
|
|
|
|
|
using DS.WMS.Core.Info.Entity;
|
|
|
|
|
using DS.WMS.Core.Op.Entity;
|
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
using NPOI.Util;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Fee.Method
|
|
|
|
@ -20,6 +24,8 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class FeeAuditService : FeeServiceBase, IFeeAuditService
|
|
|
|
|
{
|
|
|
|
|
const string Audit_Only = "AuditOnly=1";
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 待审核的状态值
|
|
|
|
|
/// </summary>
|
|
|
|
@ -55,61 +61,17 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<FeeAuditBusiness>>> GetListAsync(PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
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 }).ToListAsync();
|
|
|
|
|
//没有待审批的列表直接返回不再执行后续查询
|
|
|
|
|
if (flowList.Count == 0)
|
|
|
|
|
DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
|
|
|
|
|
var queryList = CreateQuery(flowList);
|
|
|
|
|
//queryList = queryList.Where(x => SqlFunc.Subqueryable<FlowInstance>().Where(
|
|
|
|
|
// y => y.BusinessId == x.Id && y.BusinessType == x.BusinessType && SqlFunc.SplitIn(y.MakerList, User.UserId)).Any());
|
|
|
|
|
|
|
|
|
|
if (!request.QueryCondition.IsNullOrEmpty())
|
|
|
|
|
List<FlowInstance> flowList = null;
|
|
|
|
|
if (string.Equals(request.OtherQueryCondition, Audit_Only))
|
|
|
|
|
{
|
|
|
|
|
var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
queryList = queryList.Where(whereList);
|
|
|
|
|
}
|
|
|
|
|
flowList = await GetCurrentFlowsQuery(AuditTypes).ToListAsync();
|
|
|
|
|
|
|
|
|
|
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 = 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;
|
|
|
|
|
|
|
|
|
|
if (item.OperatorId.HasValue)
|
|
|
|
|
{
|
|
|
|
|
item.Operator = Users.Find(x => x.Id == item.OperatorId.Value)?.UserName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//没有待审批的列表直接返回不再执行后续查询
|
|
|
|
|
if (flowList.Count == 0)
|
|
|
|
|
DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取整票审核列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<FeeAuditBusiness>>> GetBizListAsync(PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
string auditType = AuditType.FeeBusiness.ToString();
|
|
|
|
|
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 }).ToListAsync();
|
|
|
|
|
//没有待审批的列表直接返回不再执行后续查询
|
|
|
|
|
if (flowList.Count == 0)
|
|
|
|
|
DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
|
|
|
|
|
var queryList = CreateBizQuery(flowList);
|
|
|
|
|
var queryList = CreateQuery(flowList);
|
|
|
|
|
|
|
|
|
|
if (!request.QueryCondition.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
@ -117,14 +79,14 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
queryList = queryList.Where(whereList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = await queryList.ToQueryPageAsync(request.PageCondition);
|
|
|
|
|
var result = await queryList.Select<FeeAuditBusiness>().ToQueryPageAsync(request.PageCondition);
|
|
|
|
|
if (result.Data.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//关联用户名称
|
|
|
|
|
var UserIds = result.Data.Where(x => x.OperatorId.HasValue).Select(x => x.OperatorId.Value)
|
|
|
|
|
var userIds = result.Data.Where(x => x.OperatorId.HasValue).Select(x => x.OperatorId.Value)
|
|
|
|
|
.Union(result.Data.Select(x => x.CreateBy))
|
|
|
|
|
.Distinct();
|
|
|
|
|
var Users = await Db.Queryable<SysUser>().Where(x => UserIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToListAsync();
|
|
|
|
|
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;
|
|
|
|
@ -140,7 +102,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建各项费用数据的查询并集
|
|
|
|
|
internal ISugarQueryable<FeeAuditBusiness> CreateQuery(IEnumerable<FlowInstance> additions)
|
|
|
|
|
internal ISugarQueryable<FeeAuditBusinessQuery> CreateQuery(IEnumerable<FlowInstance>? additions)
|
|
|
|
|
{
|
|
|
|
|
//海运出口
|
|
|
|
|
var ids1 = additions?.Where(x => x.BusinessType == BusinessType.OceanShippingExport).Select(x => x.BusinessId).ToArray();
|
|
|
|
@ -152,7 +114,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
))
|
|
|
|
|
.WhereIF(ids1 != null && ids1.Length > 0, (s, b, f) => ids1.Contains(f.Id))
|
|
|
|
|
.GroupBy(s => s.Id)
|
|
|
|
|
.Select((s, b, f, cs, csd) => new FeeAuditBusiness
|
|
|
|
|
.Select((s, b, f, cs, csd) => new FeeAuditBusinessQuery
|
|
|
|
|
{
|
|
|
|
|
Id = s.Id,
|
|
|
|
|
AccountDate = s.AccountDate,
|
|
|
|
@ -181,6 +143,9 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
Doc = s.Doc,
|
|
|
|
|
ETD = s.ETD,
|
|
|
|
|
Forwarder = s.Forwarder,
|
|
|
|
|
FeeId = f.FeeId,
|
|
|
|
|
FeeCustomerId = f.CustomerId,
|
|
|
|
|
FeeCustomerName = f.CustomerName,
|
|
|
|
|
GoodsName = s.GoodsName,
|
|
|
|
|
HBLNO = s.HBLNO,
|
|
|
|
|
InvoiceNo = s.InvoiceNo,
|
|
|
|
@ -222,22 +187,70 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
//海运进口
|
|
|
|
|
//var ids2 = additions?.Where(x => x.BusinessType == BusinessType.OceanShippingImport).Select(x => x.BusinessId).ToArray();
|
|
|
|
|
|
|
|
|
|
return TenantDb.UnionAll(new List<ISugarQueryable<FeeAuditBusiness>> { query1 });
|
|
|
|
|
return TenantDb.UnionAll(new List<ISugarQueryable<FeeAuditBusinessQuery>> { query1 });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取整票审核列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<FeeAuditBusiness>>> GetBizListAsync(PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
List<FlowInstance> flowList = null;
|
|
|
|
|
if (string.Equals(request.OtherQueryCondition, Audit_Only))
|
|
|
|
|
{
|
|
|
|
|
flowList = await GetCurrentFlowsQuery([AuditType.FeeBusiness.ToString()]).ToListAsync();
|
|
|
|
|
|
|
|
|
|
//没有待审批的列表直接返回不再执行后续查询
|
|
|
|
|
if (flowList.Count == 0)
|
|
|
|
|
DataResult<List<FeeAuditBusiness>>.PageList(0, null, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var queryList = CreateBizQuery(flowList);
|
|
|
|
|
|
|
|
|
|
if (!request.QueryCondition.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
queryList = queryList.Where(whereList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = await queryList.Select<FeeAuditBusiness>().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 = 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;
|
|
|
|
|
|
|
|
|
|
if (item.OperatorId.HasValue)
|
|
|
|
|
{
|
|
|
|
|
item.Operator = Users.Find(x => x.Id == item.OperatorId.Value)?.UserName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建各项业务数据的查询并集
|
|
|
|
|
internal ISugarQueryable<FeeAuditBusiness> CreateBizQuery(IEnumerable<FlowInstance> additions)
|
|
|
|
|
internal ISugarQueryable<FeeAuditBusinessQuery> CreateBizQuery(IEnumerable<FlowInstance>? additions)
|
|
|
|
|
{
|
|
|
|
|
//海运出口
|
|
|
|
|
var ids1 = additions?.Where(x => x.BusinessType == BusinessType.OceanShippingExport).Select(x => x.BusinessId).ToArray();
|
|
|
|
|
var query1 = TenantDb.Queryable<SeaExport, BusinessFeeStatus, CodeSource, CodeSourceDetail>((s, b, cs, csd) => new JoinQueryInfos(
|
|
|
|
|
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.SourceDetailId == csd.Id
|
|
|
|
|
))
|
|
|
|
|
.WhereIF(ids1 != null && ids1.Length > 0, (s, b) => ids1.Contains(s.Id))
|
|
|
|
|
.GroupBy(s => s.Id)
|
|
|
|
|
.Select((s, b, cs, csd) => new FeeAuditBusiness
|
|
|
|
|
.Select((s, b, f, cs, csd) => new FeeAuditBusinessQuery
|
|
|
|
|
{
|
|
|
|
|
Id = s.Id,
|
|
|
|
|
AccountDate = s.AccountDate,
|
|
|
|
@ -266,6 +279,9 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
Doc = s.Doc,
|
|
|
|
|
ETD = s.ETD,
|
|
|
|
|
Forwarder = s.Forwarder,
|
|
|
|
|
FeeId = f.FeeId,
|
|
|
|
|
FeeCustomerId = f.CustomerId,
|
|
|
|
|
FeeCustomerName = f.CustomerName,
|
|
|
|
|
GoodsName = s.GoodsName,
|
|
|
|
|
HBLNO = s.HBLNO,
|
|
|
|
|
InvoiceNo = s.InvoiceNo,
|
|
|
|
@ -307,7 +323,15 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
//海运进口
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return TenantDb.UnionAll(new List<ISugarQueryable<FeeAuditBusiness>> { query1 });
|
|
|
|
|
return TenantDb.UnionAll(new List<ISugarQueryable<FeeAuditBusinessQuery>> { query1 });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取当前登录用户的待审批工作流的查询对象
|
|
|
|
|
internal ISugarQueryable<FlowInstance> GetCurrentFlowsQuery(string[] auditTypes)
|
|
|
|
|
{
|
|
|
|
|
return 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 });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -380,9 +404,7 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> AuditAsync(int yesOrNo, string remark)
|
|
|
|
|
{
|
|
|
|
|
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).ToArrayAsync();
|
|
|
|
|
var recordIds = await GetCurrentFlowsQuery(AuditTypes).Select(x => x.BusinessId).ToArrayAsync();
|
|
|
|
|
//没有待审批的列表直接返回不再执行后续查询
|
|
|
|
|
if (recordIds.Length == 0)
|
|
|
|
|
return DataResult.Failed("当前暂无待审批的费用");
|
|
|
|
@ -397,15 +419,31 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> AuditAsync(FeeBizAuditRequest request)
|
|
|
|
|
{
|
|
|
|
|
var list1 = request.Items.Select(x => x.Id).ToList();
|
|
|
|
|
var list2 = request.Items.Select(x => x.BusinessType).Distinct().ToList();
|
|
|
|
|
var recordIds = await TenantDb.Queryable<FeeRecord>().Where(x =>
|
|
|
|
|
var flowList = await GetCurrentFlowsQuery(AuditTypes).ToListAsync();
|
|
|
|
|
var query = CreateQuery(flowList);
|
|
|
|
|
|
|
|
|
|
if (!request.QueryCondition.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
query = query.Where(whereList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var bizList = await query.Select(x => new BizAudit { Id = x.Id, BusinessType = x.BusinessType }).ToArrayAsync();
|
|
|
|
|
//取所选业务与过滤条件所产生的并集
|
|
|
|
|
var intersects = request.Items.Intersect(bizList);
|
|
|
|
|
if (!intersects.Any())
|
|
|
|
|
return DataResult.Failed("暂无符合当前查询条件的待审批费用");
|
|
|
|
|
|
|
|
|
|
var list1 = intersects.Select(x => x.Id).ToList();
|
|
|
|
|
var list2 = intersects.Select(x => x.BusinessType).Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
var recordIds = await TenantDb.Queryable<FeeRecord>().Where(x =>
|
|
|
|
|
list1.Contains(x.BusinessId) && list2.Contains(x.BusinessType) && AuditStatusArray.Contains(x.FeeStatus))
|
|
|
|
|
.Select(x => x.Id).ToArrayAsync();
|
|
|
|
|
|
|
|
|
|
//没有待审批的列表直接返回不再执行后续查询
|
|
|
|
|
if (recordIds.Length == 0)
|
|
|
|
|
return DataResult.Failed("当前暂无待审批的费用");
|
|
|
|
|
return DataResult.Failed("暂无符合当前查询条件的待审批费用");
|
|
|
|
|
|
|
|
|
|
return await AuditAsync(request.Result, request.Remark, recordIds);
|
|
|
|
|
}
|
|
|
|
@ -678,84 +716,91 @@ namespace DS.WMS.Core.Fee.Method
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据查询条件获取费用明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="query"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<FeeAuditItem>>> GetFeesAsync(string query)
|
|
|
|
|
{
|
|
|
|
|
var query1 = TenantDb.Queryable<FeeRecord>()
|
|
|
|
|
.InnerJoin<SeaExport>((x, y) => x.BusinessId == y.Id)
|
|
|
|
|
.LeftJoin<InfoClient>((x, y, z) => x.CustomerId == z.Id)
|
|
|
|
|
.Select((f, s, i) => new FeeAuditItemQuery
|
|
|
|
|
{
|
|
|
|
|
Id = f.Id,
|
|
|
|
|
BusinessId = f.BusinessId,
|
|
|
|
|
BusinessType = f.BusinessType,
|
|
|
|
|
FeeStatus = f.FeeStatus,
|
|
|
|
|
FeeType = f.FeeType,
|
|
|
|
|
FeeId = f.FeeId,
|
|
|
|
|
FeeName = f.FeeName,
|
|
|
|
|
FeeEnName = f.FeeEnName,
|
|
|
|
|
FeeCustomerId = f.CustomerId,
|
|
|
|
|
CustomerName = s.CustomerName,
|
|
|
|
|
CustomerFullName = i.Description, //结算对象全称
|
|
|
|
|
CustomerType = f.CustomerType,
|
|
|
|
|
CustomerTypeText = f.CustomerTypeText,
|
|
|
|
|
Unit = f.Unit,
|
|
|
|
|
UnitText = f.UnitText,
|
|
|
|
|
UnitPrice = f.UnitPrice,
|
|
|
|
|
TaxUnitPrice = f.TaxUnitPrice,
|
|
|
|
|
Quantity = f.Quantity,
|
|
|
|
|
TaxRate = f.TaxRate,
|
|
|
|
|
NoTaxAmount = f.NoTaxAmount,
|
|
|
|
|
Amount = f.Amount,
|
|
|
|
|
Currency = f.Currency,
|
|
|
|
|
CurrencyText = f.CurrencyText,
|
|
|
|
|
ExchangeRate = f.ExchangeRate,
|
|
|
|
|
AccTaxRate = f.AccTaxRate,//销项汇率
|
|
|
|
|
Remark = f.Remark,
|
|
|
|
|
IsAdvancedPay = f.IsAdvancedPay,//是否垫付
|
|
|
|
|
IsInvoice = f.IsInvoice, //是否开发票
|
|
|
|
|
//FRT
|
|
|
|
|
CommissionRate = f.CommissionRate, //佣金比率
|
|
|
|
|
CreateBy = f.CreateBy,
|
|
|
|
|
CreateTime = f.CreateTime,
|
|
|
|
|
SettlementAmount = f.SettlementAmount,//结算金额
|
|
|
|
|
InvoiceAmount = f.InvoiceAmount,//开票金额
|
|
|
|
|
OrderAmount = f.OrderAmount,//申请金额
|
|
|
|
|
InvoiceNum = f.InvoiceNum,//发票号
|
|
|
|
|
Tax = f.Tax,//税额
|
|
|
|
|
DebitNo = f.DebitNo,//对账编号
|
|
|
|
|
SaleOrg = f.SaleOrg,
|
|
|
|
|
Reason = f.Reason,
|
|
|
|
|
|
|
|
|
|
CustomerNo = s.CustomerNo,
|
|
|
|
|
Vessel = s.Vessel,
|
|
|
|
|
Voyage = s.Voyno,
|
|
|
|
|
SaleId = s.SaleId,
|
|
|
|
|
CustomerId = s.CustomerId,
|
|
|
|
|
BusinessDate = s.BusinessDate,
|
|
|
|
|
SourceId = s.SourceId,
|
|
|
|
|
AccountDate = s.AccountDate,
|
|
|
|
|
OperatorId = s.OperatorId
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var queryList = TenantDb.UnionAll(new List<ISugarQueryable<FeeAuditItemQuery>> { query1 });
|
|
|
|
|
|
|
|
|
|
if (!query.IsNullOrEmpty())
|
|
|
|
|
{
|
|
|
|
|
var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(query);
|
|
|
|
|
queryList = queryList.Where(whereList);
|
|
|
|
|
}
|
|
|
|
|
var result = await queryList.Select<FeeAuditItem>().ToListAsync();
|
|
|
|
|
|
|
|
|
|
//public DataResult<List<FeeAudit>> GetListByPage(PageRequest request)
|
|
|
|
|
//{
|
|
|
|
|
// var whereList = Db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
|
|
|
|
|
|
|
|
|
// var query1 = TenantDb.Queryable<FeeRecord>()
|
|
|
|
|
// .InnerJoin<SeaExport>((x, y) => x.BusinessId == y.Id)
|
|
|
|
|
// .LeftJoin<InfoClient>((x, y, z) => x.CustomerId == z.Id)
|
|
|
|
|
// .Select((x, y, z) => new FeeAudit
|
|
|
|
|
// {
|
|
|
|
|
// Id = x.Id,
|
|
|
|
|
// BusinessId = x.BusinessId,
|
|
|
|
|
// BusinessType = x.BusinessType,
|
|
|
|
|
// FeeStatus = x.FeeStatus,
|
|
|
|
|
// FeeType = x.FeeType,
|
|
|
|
|
// FeeName = x.FeeName,
|
|
|
|
|
// FeeEnName = x.FeeEnName,
|
|
|
|
|
// CustomerName = x.CustomerName,
|
|
|
|
|
// CustomerFullName = z.Description, //结算对象全称
|
|
|
|
|
// CustomerType = x.CustomerType,
|
|
|
|
|
// CustomerTypeText = x.CustomerTypeText,
|
|
|
|
|
// Unit = x.Unit,
|
|
|
|
|
// UnitText = x.UnitText,
|
|
|
|
|
// UnitPrice = x.UnitPrice,
|
|
|
|
|
// TaxUnitPrice = x.TaxUnitPrice,
|
|
|
|
|
// Quantity = x.Quantity,
|
|
|
|
|
// TaxRate = x.TaxRate,
|
|
|
|
|
// NoTaxAmount = x.NoTaxAmount,
|
|
|
|
|
// Amount = x.Amount,
|
|
|
|
|
// Currency = x.Currency,
|
|
|
|
|
// CurrencyText = x.CurrencyText,
|
|
|
|
|
// ExchangeRate = x.ExchangeRate,
|
|
|
|
|
// AccTaxRate = x.AccTaxRate,//销项汇率
|
|
|
|
|
// Remark = x.Remark,
|
|
|
|
|
// IsAdvancedPay = x.IsAdvancedPay,//是否垫付
|
|
|
|
|
// IsInvoice = x.IsInvoice, //是否开发票
|
|
|
|
|
// //FRT
|
|
|
|
|
// CommissionRate = x.CommissionRate, //佣金比率
|
|
|
|
|
// CreateBy = x.CreateBy,
|
|
|
|
|
// CreateTime = x.CreateTime,
|
|
|
|
|
// AuditOperator = x.AuditOperator,
|
|
|
|
|
// AuditDate = x.AuditDate,
|
|
|
|
|
// SettlementAmount = x.SettlementAmount,//结算金额
|
|
|
|
|
// InvoiceAmount = x.InvoiceAmount,//开票金额
|
|
|
|
|
// OrderAmount = x.OrderAmount,//申请金额
|
|
|
|
|
// InvoiceNum = x.InvoiceNum,//发票号
|
|
|
|
|
// Tax = x.Tax,//税额
|
|
|
|
|
// DebitNo = x.DebitNo,//对账编号
|
|
|
|
|
// SubmitBy = x.SubmitBy,
|
|
|
|
|
// SubmitDate = x.SubmitDate,
|
|
|
|
|
// SaleOrg = x.SaleOrg,
|
|
|
|
|
// Reason = x.Reason,
|
|
|
|
|
// IsOpen = x.IsOpen,//是否机密
|
|
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// var queryList = TenantDb.UnionAll(new List<ISugarQueryable<FeeAudit>> { query1 });
|
|
|
|
|
// var result = queryList.Where(whereList).ToQueryPage(request.PageCondition);
|
|
|
|
|
|
|
|
|
|
// if (result.Data.Count > 0)
|
|
|
|
|
// {
|
|
|
|
|
// //关联用户名称
|
|
|
|
|
// var UserIds = result.Data.Where(x => x.SubmitBy.HasValue).Select(x => x.SubmitBy.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();
|
|
|
|
|
// foreach (var item in result.Data)
|
|
|
|
|
// {
|
|
|
|
|
// item.CreateByName = Users.Find(x => x.Id == item.CreateBy)?.UserName;
|
|
|
|
|
|
|
|
|
|
// if (item.SubmitBy.HasValue)
|
|
|
|
|
// {
|
|
|
|
|
// item.SubmitByName = Users.Find(x => x.Id == item.SubmitBy.Value)?.UserName;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// return result;
|
|
|
|
|
//}
|
|
|
|
|
if (result.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//关联用户名称
|
|
|
|
|
var UserIds = result.Select(x => x.CreateBy).Distinct();
|
|
|
|
|
var Users = Db.Queryable<SysUser>().Where(x => UserIds.Contains(x.Id)).Select(x => new { x.Id, x.UserName }).ToList();
|
|
|
|
|
foreach (var item in result)
|
|
|
|
|
{
|
|
|
|
|
item.CreateByName = Users.Find(x => x.Id == item.CreateBy)?.UserName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult<List<FeeAuditItem>>.Success(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|