( case when t5.`status`=0 or t5.`status` is null then 0 else 1 end ) as 'monitor_status'
from
dc_auto_forecast_fluctuation as t1
inner JOIN dc_auto_turnover as t2 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
left join dc_auto_purchase_ontheway as t4 on t1.bailun_sku = t4.bailun_sku and t1.warehouse_code = t4.warehouse_code
left join dc_auto_config_sku_warehouse as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
where 1 = 1
";
...
...
@@ -46,10 +48,11 @@ where 1 = 1
select t1.*,t3.sku_title_cn,
t2.history_sevenday_sales,
t2.history_fourteenday_sales,
t2.history_thirtyday_sales
from
dc_auto_forecast_fluctuation as t1
t2.history_thirtyday_sales,
( case when t5.`status`=0 or t5.`status` is null then 0 else 1 end ) as 'monitor_status'
from
dc_auto_forecast_fluctuation as t1
inner JOIN dc_auto_turnover as t2 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
left join dc_base_warehouse as dbw on t1.warehouse_code = dbw.warehouse_code
left join dc_auto_config_sku_warehouse as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
@@ -470,7 +470,7 @@ t1.warehouse_code in ('AU4PXBL','BLGZ03','DYGXC','GB4PXBL','GBBLJW','GBYKD','GZB
and ( t_db.hq_type!='国内仓' or t2.buyer_name not in ('张莹霞','张莹霞1') )
and t_db.hq_type!='fba仓'
and (case when t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) and t2.buyer_name not in ('张莹霞','张莹霞1') then (ifnull(t4.sum_unshipped_quantity,0) - ifnull(t3.sum_usable_stock,0)) else t1.quantity_out_stock end )>0
and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push.warehouse_code = t1.warehouse_code and dc_auto_shortage_push.bailun_sku = t1.bailun_sku )";
and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push.warehouse_code = t1.warehouse_code and dc_auto_shortage_push.bailun_sku = t1.bailun_sku and dc_auto_shortage_push.`type`=1 )";
left join dc_mid_transit as t2 on t1.warehouse_code =t2.warehouse_code and t1.bailun_sku =t2.bailun_sku
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
where t1.usable_stock<=0 and t1.bailun_sku!=''
and ( t_db.warehouse_code!='QYBLZZ' or t2.buyer_name not in ('张莹霞','张莹霞1','黄镜洁','赵美聪') )
and t1.warehouse_code in ('AU4PXBL','BLGZ03','DYGXC','GB4PXBL','GBBLJW','GBYKD','GZBLWH','QYBLZZ','US4PXBL','USGCBL')
and (
case
...
...
@@ -489,8 +490,20 @@ and (
else t2.quantity_transfer
end
)<=0
and not EXISTS ( select * from dc_base_stock as t_stock where t_stock.bailun_sku= t1.bailun_sku and t1.usable_stock>0 )
and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push.warehouse_code = t1.warehouse_code and dc_auto_shortage_push.bailun_sku = t1.bailun_sku )";
and not EXISTS (
select * from dc_base_stock as t_stock
left join dc_base_warehouse as t_stock_w on t_stock.warehouse_code = t_stock_w.warehouse_code
left join dc_mid_transit as t_stock_t on t_stock.warehouse_code =t_stock_t.warehouse_code and t_stock.bailun_sku =t_stock_t.bailun_sku
where ( ( t_stock_w.hq_type='国内仓' and t_db.hq_type='国内仓' ) or ( t_db.hq_type!='国内仓' and t_stock_w.hq_type!='国内仓' and t_db.area_id=t_stock_w.area_id ) ) and t_stock.bailun_sku= t1.bailun_sku and ( t_stock.usable_stock>0 or
(
case
when t_stock_w.hq_type='国内仓' then t_stock_t.quantity_purchase
else t_stock_t.quantity_transfer
end
)>0
)
) -- 同属性仓库 (是否国内) 有库存,就不算 0库存
and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push.warehouse_code = t1.warehouse_code and dc_auto_shortage_push.bailun_sku = t1.bailun_sku and dc_auto_shortage_push.`type`=2 )";