Commit 05780e87 by lizefeng

fix 上周销量计算

parent 4de4bd74
......@@ -27,6 +27,7 @@ namespace AutoGeneratePurchaseAdvise
//PurchaseAdviseServices.Generate($"下午的补充周转 {DateTime.Now.ToString("HH: mm")}", DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 12:00:00")));
//PurchaseAdviseServices.Generate($"早上的全量周转 {DateTime.Now.ToString("HH: mm")}", DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")), is_clear_data: true);
//report.PurchaseWeekBackUp();
//report.ResetLastweekData();
}
catch (Exception ex)
{
......
......@@ -2176,8 +2176,12 @@ set t1.safe_stock = t2.history_fourteenday_sales * 2,date = now()
where t1.bailun_sku =t2.bailun_sku and t1.warehouse_code =t2.warehouse_code and t1.`type`=0 ", commandTimeout: 0);
}
//刷新上周的数据
public static void ResetLastweekData()
public static void ResetLastweekData(DateTime? now = null)
{
if (now == null)
{
now = DateTime.Now;
}
_connection.Execute(@" -- 刷新 sku 上周销量
-- 清空视图表的数据
Truncate table dc_base_lastweek_data_temp;
......@@ -2187,14 +2191,14 @@ sum(t1.bailun_sku_quantity_ordered) as 'sales',
sum(t1.bailun_sku_quantity_ordered * t1.amount_sales * t1.order_to_usd_exchange_rate) as 'sales_amount'
from dc_base_oms_sku_30 t1
join dc_base_oms_order t2 on t1.bailun_order_id=t2.bailun_order_id and t2.has_scalp=0 and t2.has_innersale=0
left join dc_base_oms_pick t3 on t1.bailun_order_id=t3.bailun_order_id and t1.bailun_sku=t3.bailun_sku and t3.has_delete=0
-- left join dc_base_oms_pick t3 on t1.bailun_order_id=t3.bailun_order_id and t1.bailun_sku=t3.bailun_sku and t3.has_delete=0
left join dc_base_sku t4 on t1.bailun_sku=t4.bailun_sku
left join dc_base_sku_source t5 on t4.source = t5.source
join dc_base_warehouse t6 on t3.warehouse_code=t6.warehouse_code
-- join dc_base_warehouse t6 on t3.warehouse_code=t6.warehouse_code
where t1.has_delete=0 and t1.company_id=1 and t2.bailun_order_status!='Canceled'
and ( t1.bailun_order_status!='CantHandle')
and t2.paid_time>=@btime and t2.paid_time<@etime
GROUP BY t1.bailun_sku,t1.warehouse_code ", new { btime = DateTime.Now.AddDays(-7).GetWeekFirstDayMon().ToDayHome(), etime = DateTime.Now.AddDays(-7).GetWeekLastDaySun().ToDayEnd() }).ToList();
GROUP BY t1.bailun_sku,t1.warehouse_code ", new { btime = now.Value.AddDays(-7).GetWeekFirstDayMon().ToDayHome(), etime = now.Value.AddDays(-7).GetWeekLastDaySun().ToDayEnd() }).ToList();
if (datas != null)
{
......
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