sql+=" and ( t_not_stock.success_sales>=1 and TIMESTAMPDIFF(day,t2.push_time,now())>=7 ) ";
sql+=" and ( t_not_stock.success_sales>=1 and TIMESTAMPDIFF(day,t2.push_time,now())>=7 ) ";
sqlCount+=" and ( t_not_stock.success_sales>=1 and TIMESTAMPDIFF(day,t2.push_time,now())>=7 ) ";
}
if(search.success_states==2)
{
// 失败
sql+=" and ( t_not_stock.test_sales<=0 and TIMESTAMPDIFF(day,t2.push_time,now())>=21 ) ";
sqlCount+=" and ( t_not_stock.test_sales<=0 and TIMESTAMPDIFF(day,t2.push_time,now())>=21 ) ";
}
if(search.success_states==3)
{
// 待定
sql+=" and !( t_not_stock.success_sales>=1 and TIMESTAMPDIFF(day,t2.push_time,now())>=7 ) and !( t_not_stock.test_sales<=0 and TIMESTAMPDIFF(day,t2.push_time,now())>=21 ) ";
sqlCount+=" and !( t_not_stock.success_sales>=1 and TIMESTAMPDIFF(day,t2.push_time,now())>=7 ) and !( t_not_stock.test_sales<=0 and TIMESTAMPDIFF(day,t2.push_time,now())>=21 ) ";
replace into dc_auto_config_sku_warehouse_copy1(`bailun_sku`,`sku_title`,`warehouse_code`,`warehouse_name`,`gmt_create`,`gmt_modified`,`status`,`bl_operator`)
(
select
bailun_sku,
'' as 'sku_title',
'BLGZ03',
'广州-03仓' as 'warehouse_name',
now() as 'gmt_create',
now() as 'gmt_modified',
1 as 'status',
'' as 'bl_operator'
from dc_base_sku where product_inner_code in @product_inner_codes
t1.*,t2.warehouse_name,t3.sku_title_cn as 'sku_name',t4.create_time,t3.buyer_name,
t1.*,t2.warehouse_name,t3.sku_title_cn as 'sku_name',t4.create_time,t3.buyer_name,
(t5.quantity_safe_inventory) as 'quantity_safe_inventory', -- 日均加权销量
(t5.quantity_safe_inventory) as 'quantity_safe_inventory', -- 安全库存
(t5.daily_weighted_sales) as 'daily_weighted_sales', -- 日均加权
(t5.quantity_out_stock) as 'quantity_out_stock', -- 缺货
(t5.quantity_out_stock) as 'quantity_out_stock', -- 缺货
(t5.quantity_transfer) as 'quantity_transfer', -- 调拨在途
(t5.quantity_transfer) as 'quantity_transfer', -- 调拨在途
(t5.quantity_purchase) as 'quantity_purchase', -- 采购在途
(t5.quantity_purchase) as 'quantity_purchase', -- 采购在途
(t5.quantity_inventory) as 'quantity_inventory', -- 库存数
(t5.quantity_inventory) as 'quantity_inventory', -- 库存数
t3.suppliers_link,
(t3.unit_price * (case when t1.quantity_actual>0 then t1.quantity_actual else t1.quantity_final_advise end ) ) as 'quantity_final_advise_price', -- 采购金额
(t3.unit_price * (case when t1.quantity_actual>0 then t1.quantity_actual else t1.quantity_final_advise end ) ) as 'quantity_final_advise_price', -- 采购金额
t3.suppliers_name,
t3.suppliers_name,
(t1.history_fourteenday_sales - t5.forecast_fourteenday_sales) as 'sudden_increase' -- 突增关注
(t1.history_fourteenday_sales - t5.forecast_fourteenday_sales) as 'sudden_increase' -- 突增关注