Commit aedd9d85 by DESKTOP-732ATD8\BLT

修改功能:减:营业外支出 增加存货报损

parent 3c4db5eb
......@@ -948,7 +948,7 @@ ON s2.id = s1.order_fee_config_id WHERE s1.month = @month ");
else if (input.FeeName.Contains("减:营业外支出"))
{
//2021-09-23陈文静提出需求 营业外收入的mx站点数值小于0的话,就放入营业外支出
sql.Append("AND s2.datacenter_col LIKE '%营业外支出' or (s2.datacenter_col LIKE '%营业外收入' and s1.platform = '亚马逊' and LOWER(s1.website) = 'mx' and amountval_rmb < 0)");
sql.Append("AND (s2.datacenter_col LIKE '%营业外支出' or (s2.datacenter_col LIKE '%营业外收入' and s1.platform = '亚马逊' and LOWER(s1.website) = 'mx' and amountval_rmb < 0))");
}
else
{
......@@ -973,7 +973,46 @@ ON s2.id = s1.order_fee_config_id WHERE s1.month = @month ");
}
if (isSum)
{
sql.Append(" GROUP BY s1.platform,s1.website");
sql.Append(" GROUP BY s1.platform,s1.website ");
sql.Append(@"UNION ALL
SELECT
'存货报损' as platform_type
,'' as website
,SUM( t1.cost_product ) AS original_amount
,SUM( t1.cost_product ) AS total_amount_sales
,COUNT(*) AS total_order
FROM
order_fee_damaged t1
WHERE
t1.`month` = @month
AND isdelete = 0
AND status_name = '盘亏'");
}
else if (string.IsNullOrWhiteSpace(input.PlatformType) || input.PlatformType == "存货报损")
{
sql.Append($@"UNION ALL
SELECT
'存货报损' AS PlatForm
,'' AS WebSite
,bailun_sku_original AS Orderno
,operation_time AS DataTime
,cost_product AS AmountVal
,'营业外支出' AS FeeType
,'' AS Subjectcode
,'' AS ProjectCode
,'' AS FinanceCategory
,'营业外支出' AS DatacenterCol
,'人民币' AS Currency
,'人民币' AS EbayCurrency
,'1.000000' AS ExchangeRate
,cost_product AS AmountValRmb
,`MONTH` AS `MONTH`
FROM
order_fee_damaged t1
WHERE
t1.`month` = @month
AND isdelete = 0
AND status_name = '盘亏'");
}
return sql.ToString();
}
......@@ -1098,6 +1137,27 @@ AND s2.datacenter_col like '%{input.FeeName}' group by s2.platform,s1.website ";
}
return data.Sum(x => x.total);
}
public decimal GetMonthFeeDamagedSummary(string month)
{
decimal? damaged = default(decimal?);
var parameters = new DynamicParameters();
var sql = $@"SELECT SUM(t1.cost_product) as cost_product
from order_fee_damaged t1
WHERE t1.`month` = @month and isdelete = 0 and status_name = '盘亏'";
parameters.Add("month", month);
using (var db = new MySqlConnection(GlobalConfig.ConnectionString_DW))
{
if (db.State == ConnectionState.Closed)
{
db.Open();
}
damaged = db.QueryFirstOrDefault<decimal?>(sql, parameters);
}
return damaged ?? 0;
}
/// <summary>
/// 退款分页明细
/// </summary>
......@@ -1537,8 +1597,8 @@ t1.exchange_rate AS ExchangeRate,t1.amountval_rmb AS AmountValRmb,t1.month AS Mo
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "营业外收入" }), 2);
//减:营业外支出
oldData.pay_non_operating = Math.Abs(Math.Round((SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "营业外支出" }) + Math.Abs(groupMx)), 2)) * (-1);
oldData.pay_non_operating = Math.Round(Math.Abs(SyncMonthProfitFeePlatformFeeSummary(
new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "营业外支出" })) + Math.Abs(groupMx) + Math.Abs(GetMonthFeeDamagedSummary(time)), 2) * (-1);
//销售费用-税金
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment