@@ -1189,27 +1189,75 @@ AND s2.datacenter_col like '%{input.FeeName}' group by s2.platform,s1.website ";
varend=start.AddMonths(1).Date;
if(isSummary)//根据平台分组明细汇总
{
sql.Append(@"select platform_type AS Platform,SUM(amount_refund_rmb) AS RefundRmb,
SUM(amount_refund_usd) AS RefundUsd,Count(*) AS Totals
from dc_base_crm_refund
where refund_time >= @start and refund_time < @end and shipping_status in ('TotalShipping','PartShipping') AND is_deleted = 0 AND is_freeze = 0 AND company_id = 1
group by platform_type ");
sql.Append(@"SELECT
t1.platform_type AS Platform
,SUM( IFNULL(ROUND( (t1.amount_refund * t2.exchange_rate),3 ),t1.amount_refund_rmb) ) AS RefundRmb
,SUM( t1.amount_refund_usd ) AS RefundUsd
,Count(*) AS Totals
FROM dc_base_crm_refund t1
LEFT JOIN dc_exchange_rate_finance t2
ON t1.order_currency = t2.`code`
AND DATE_FORMAT( t1.refund_time, '%Y-%m' ) = t2.`month`
-- 2021年10月之后除Aliexpress平台之外都使用财务汇率
AND t2.`month` >= '2021-10'
AND t1.platform_type <> 'Aliexpress'
WHERE 1 = 1
AND t1.refund_time >= @start
AND t1.refund_time < @end
AND t1.shipping_status IN ( 'TotalShipping', 'PartShipping' )
AND t1.is_deleted = 0
AND t1.is_freeze = 0
AND t1.company_id = 1
GROUP BY
t1.platform_type ");
parameters.Add("start",start);
parameters.Add("end",end);
returnsql.ToString();
}
if(isSum)
{
sql.Append($@"
select sum(t1.amount_refund_rmb) AS RefundRmb,sum(t1.amount_refund_usd) AS RefundUsd from dc_base_crm_refund t1
where t1.refund_time >= @start and t1.refund_time < @end and shipping_status in ('TotalShipping','PartShipping') AND is_deleted = 0 AND is_freeze = 0 AND company_id = 1");
sql.Append($@"SELECT
SUM( IFNULL(ROUND( (t1.amount_refund * t2.exchange_rate),3),t1.amount_refund_rmb) ) AS RefundRmb
,SUM( t1.amount_refund_usd ) AS RefundUsd
FROM dc_base_crm_refund t1
LEFT JOIN dc_exchange_rate_finance t2
ON t1.order_currency = t2.`code`
AND DATE_FORMAT( t1.refund_time, '%Y-%m' ) = t2.`month`
-- 2021年10月之后除Aliexpress平台之外都使用财务汇率
AND t2.`month` >= '2021-10'
AND t1.platform_type <> 'Aliexpress'
WHERE 1 = 1
AND t1.refund_time >= @start
AND t1.refund_time < @end
AND t1.shipping_status IN ( 'TotalShipping', 'PartShipping' )
AND t1.is_deleted = 0
AND t1.is_freeze = 0
AND t1.company_id = 1 ");
}
else
{
sql.Append($@"
select t1.platform_type AS PlatformType, t1.bailun_account AS BailunAccount, t1.website AS WebSite,
t1.origin_order_id AS OriginOrderId, t1.amount_refund_rmb AS RefundRmb, t1.amount_refund_usd AS RefundUsd, t1.refund_time AS RefundTime from dc_base_crm_refund t1
where t1.refund_time >= @start and t1.refund_time < @end and shipping_status in ('TotalShipping','PartShipping') AND is_deleted = 0 AND is_freeze = 0 AND company_id = 1");
sql.Append($@"SELECT
t1.platform_type AS PlatformType
,t1.bailun_account AS BailunAccount
,t1.website AS WebSite
,t1.origin_order_id AS OriginOrderId
,IFNULL(ROUND( (t1.amount_refund * t2.exchange_rate),3),t1.amount_refund_rmb) AS RefundRmb
,t1.amount_refund_usd AS RefundUsd
,t1.refund_time AS RefundTime
FROM dc_base_crm_refund t1
LEFT JOIN dc_exchange_rate_finance t2
ON t1.order_currency = t2.`code`
AND DATE_FORMAT( t1.refund_time, '%Y-%m' ) = t2.`month`
-- 2021年10月之后除Aliexpress平台之外都使用财务汇率
AND t2.`month` >= '2021-10'
AND t1.platform_type <> 'Aliexpress'
WHERE 1 = 1
AND t1.refund_time >= @start
AND t1.refund_time < @end
AND t1.shipping_status IN ( 'TotalShipping', 'PartShipping' )