|
@@ -7741,7 +7741,6 @@ WHERE
|
|
|
|
|
|
#region 企业利润
|
|
|
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 企业利润 infos
|
|
|
/// </summary>
|
|
@@ -8055,6 +8054,21 @@ WHERE
|
|
|
|
|
|
var groupItems = await _sqlSugar.SqlQueryable<CorporateProfitInfo>(sql).ToArrayAsync();
|
|
|
|
|
|
+ if (groupItems.Any())
|
|
|
+ {
|
|
|
+ var groupIds = groupItems.Select(x => x.Id).ToArray();
|
|
|
+
|
|
|
+ var feeCountInfos = await CorporateProfitFeeCount(groupIds);
|
|
|
+ if (feeCountInfos.Any())
|
|
|
+ {
|
|
|
+ foreach (var item in groupItems)
|
|
|
+ {
|
|
|
+ var tips = feeCountInfos.FirstOrDefault(x => x.Id == item.Id)?.FeeCountTipsLabel ?? "";
|
|
|
+ if (!string.IsNullOrEmpty(tips)) item.FeeCountTipsLabel = tips;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
var dailySql = string.Format(@"SELECT
|
|
|
dfp.Id,
|
|
|
dfp.CompanyId,
|
|
@@ -8101,6 +8115,165 @@ ORDER BY
|
|
|
return view;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 企业利润
|
|
|
+ /// 团组费用条数统计
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="groupIds"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private async Task<CorporateProfitFeeCount[]> CorporateProfitFeeCount(int[] groupIds)
|
|
|
+ {
|
|
|
+ if (!groupIds.Any()) return Array.Empty<CorporateProfitFeeCount>();
|
|
|
+
|
|
|
+ //含未审核SQL
|
|
|
+ string sql = string.Format(@"SELECT
|
|
|
+ ROW_NUMBER() OVER(
|
|
|
+ ORDER BY
|
|
|
+ di.VisitDate Asc
|
|
|
+ ) AS 'RowIndex',
|
|
|
+ di.Id,
|
|
|
+ di.TeamName,
|
|
|
+ di.VisitDate,
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ Count(1)
|
|
|
+ FROM
|
|
|
+ OA2023DB.dbo.Fin_ForeignReceivables ffr
|
|
|
+ WHERE
|
|
|
+ ffr.IsDel = 0
|
|
|
+ AND ffr.Diid = di.Id
|
|
|
+ ) 'ReceivableTotal',
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ Count(1)
|
|
|
+ FROM
|
|
|
+ OA2023DB.dbo.Fin_ProceedsReceived fpr
|
|
|
+ WHERE
|
|
|
+ fpr.IsDel = 0
|
|
|
+ AND fpr.DIId = di.Id
|
|
|
+ ) 'ReceivedTotal',
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ Count(1)
|
|
|
+ FROM
|
|
|
+ Fin_PaymentRefundAndOtherMoney prom
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON prom.Id = ccp.CId
|
|
|
+ AND prom.DiId = ccp.DIId
|
|
|
+ WHERE
|
|
|
+ prom.IsDel = 0
|
|
|
+ AND prom.PayType = 1
|
|
|
+ AND ccp.CTable = 285
|
|
|
+ --AND ccp.IsAuditGM = 1
|
|
|
+ AND ccp.IsAuditGM != 2
|
|
|
+ AND prom.DiId = di.Id
|
|
|
+ ) AS 'RefundedTotal',
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ Count(1)
|
|
|
+ FROM
|
|
|
+ Grp_HotelReservations hr
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON hr.Id = ccp.CId
|
|
|
+ WHERE
|
|
|
+ hr.IsDel = 0
|
|
|
+ AND ccp.IsDel = 0
|
|
|
+ AND ccp.CTable = 76 -- AND (
|
|
|
+ -- ccp.IsAuditGM = 1
|
|
|
+ -- OR ccp.IsAuditGM = 3
|
|
|
+ -- )
|
|
|
+ AND ccp.IsAuditGM != 2
|
|
|
+ AND hr.DiId = di.Id
|
|
|
+ ) AS 'HotelTotal',
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ Count(1)
|
|
|
+ FROM
|
|
|
+ Grp_CarTouristGuideGroundReservations ctggr
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON ccp.IsDel = 0
|
|
|
+ AND ccp.CTable = 79
|
|
|
+ AND ctggr.Id = ccp.CId
|
|
|
+ WHERE
|
|
|
+ ctggr.IsDel = 0 -- AND (
|
|
|
+ -- ccp.IsAuditGM = 1
|
|
|
+ -- OR ccp.IsAuditGM = 3
|
|
|
+ -- )
|
|
|
+ AND ccp.IsAuditGM != 2
|
|
|
+ AND ctggr.DiId = di.Id
|
|
|
+ ) AS 'LocalGuideTotal',
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ Count(1)
|
|
|
+ FROM
|
|
|
+ Grp_AirTicketReservations atr
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
|
|
|
+ AND ccp.CTable = 85
|
|
|
+ AND atr.Id = ccp.CId
|
|
|
+ WHERE
|
|
|
+ atr.IsDel = 0 -- AND ccp.IsAuditGM = 1
|
|
|
+ AND ccp.IsAuditGM != 2
|
|
|
+ AND atr.DIId = di.Id
|
|
|
+ ) AS 'AirTicketToal',
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ Count(1)
|
|
|
+ FROM
|
|
|
+ Grp_VisaInfo vi
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
|
|
|
+ AND ccp.CTable = 80
|
|
|
+ AND vi.Id = ccp.CId
|
|
|
+ WHERE
|
|
|
+ vi.IsDel = 0 -- AND ccp.IsAuditGM = 1
|
|
|
+ AND ccp.IsAuditGM != 2
|
|
|
+ AND vi.DIId = di.Id
|
|
|
+ ) AS 'VisaTotal',
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ Count(1)
|
|
|
+ FROM
|
|
|
+ Grp_InvitationOfficialActivities ioa
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
|
|
|
+ AND ccp.CTable = 81
|
|
|
+ AND ioa.Id = ccp.CId
|
|
|
+ WHERE
|
|
|
+ ioa.IsDel = 0 -- AND ccp.IsAuditGM = 1
|
|
|
+ AND ccp.IsAuditGM != 2
|
|
|
+ AND ioa.DiId = di.Id
|
|
|
+ ) AS 'OATotal',
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ Count(1)
|
|
|
+ FROM
|
|
|
+ Grp_Customers ic
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
|
|
|
+ AND ccp.CTable = 82
|
|
|
+ AND ic.Id = ccp.CId
|
|
|
+ WHERE
|
|
|
+ ic.IsDel = 0 -- AND ccp.IsAuditGM = 1
|
|
|
+ AND ccp.IsAuditGM != 2
|
|
|
+ AND ic.DiId = di.Id
|
|
|
+ ) AS 'InsureTotal',
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ Count(1)
|
|
|
+ FROM
|
|
|
+ Grp_DecreasePayments dp
|
|
|
+ INNER JOIN Grp_CreditCardPayment ccp ON ccp.isdel = 0
|
|
|
+ AND ccp.CTable = 98
|
|
|
+ AND dp.Id = ccp.CId
|
|
|
+ WHERE
|
|
|
+ dp.IsDel = 0 -- AND ccp.IsAuditGM = 1
|
|
|
+ AND ccp.IsAuditGM != 2
|
|
|
+ AND dp.Diid = di.Id
|
|
|
+ ) AS 'OtherTotal'
|
|
|
+FROM
|
|
|
+ OA2023DB.dbo.Grp_DelegationInfo di
|
|
|
+ LEFT JOIN Sys_SetData ss ON di.TeamDid = ss.Id
|
|
|
+WHERE
|
|
|
+ di.IsDel = 0
|
|
|
+ AND di.IsBid = 0
|
|
|
+ AND di.Id IN({0})", string.Join(",", groupIds));
|
|
|
+
|
|
|
+ return await _sqlSugar.SqlQueryable<CorporateProfitFeeCount>(sql).ToArrayAsync();
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 团组利润item详情
|