@@ -464,7 +464,9 @@ left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join china_warehouse_stock as t3 on t1.bailun_sku = t3.bailun_sku and t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' )
left join china_warehouse_unshipped as t4 on t1.bailun_sku = t4.bailun_sku and t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' )
where ( t_db.hq_type!='国内仓' or t2.buyer_name not in ('张莹霞','张莹霞1') )
where
t1.warehouse_code in ('AU4PXBL','BLGZ03','DYGXC','GB4PXBL','GBBLJW','GBYKD','GZBLWH','QYBLZZ','US4PXBL','USGCBL')
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 )";
...
...
@@ -476,10 +478,18 @@ t1.warehouse_code,
now() as 'push_date',
2 as 'type' from dc_base_stock as t1
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 t2.quantity_purchase<=0 and t2.quantity_transfer<=0
and t1.warehouse_code in ('AU4PXBL','BLGZ03','DYGXC','GB4PXBL','GBBLJW','GBYKD','GZBLWH','QYBLZZ','US4PXBL','USGCBL')
and (
case
when t_db.hq_type='国内仓' then t2.quantity_purchase
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 )";