@@ -1189,27 +1189,75 @@ AND s2.datacenter_col like '%{input.FeeName}' group by s2.platform,s1.website ";
...
@@ -1189,27 +1189,75 @@ AND s2.datacenter_col like '%{input.FeeName}' group by s2.platform,s1.website ";
varend=start.AddMonths(1).Date;
varend=start.AddMonths(1).Date;
if(isSummary)//根据平台分组明细汇总
if(isSummary)//根据平台分组明细汇总
{
{
sql.Append(@"select platform_type AS Platform,SUM(amount_refund_rmb) AS RefundRmb,
sql.Append(@"SELECT
SUM(amount_refund_usd) AS RefundUsd,Count(*) AS Totals
t1.platform_type AS Platform
from dc_base_crm_refund
,SUM( IFNULL(ROUND( (t1.amount_refund * t2.exchange_rate),3 ),t1.amount_refund_rmb) ) AS RefundRmb
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
,SUM( t1.amount_refund_usd ) AS RefundUsd
group by platform_type ");
,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("start",start);
parameters.Add("end",end);
parameters.Add("end",end);
returnsql.ToString();
returnsql.ToString();
}
}
if(isSum)
if(isSum)
{
{
sql.Append($@"
sql.Append($@"SELECT
select sum(t1.amount_refund_rmb) AS RefundRmb,sum(t1.amount_refund_usd) AS RefundUsd from dc_base_crm_refund t1
SUM( IFNULL(ROUND( (t1.amount_refund * t2.exchange_rate),3),t1.amount_refund_rmb) ) AS RefundRmb
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");
,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
else
{
{
sql.Append($@"
sql.Append($@"SELECT
select t1.platform_type AS PlatformType, t1.bailun_account AS BailunAccount, t1.website AS WebSite,
t1.platform_type AS PlatformType
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
,t1.bailun_account AS BailunAccount
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");
,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' )