) as tnc2 on t1.bailun_sku = tnc2.bailun_sku and t_db.area_id = tnc2.area_id
where t1.platform=@platform and t1.has_return_goods=0
and (case
when ifnull(tc2.sum_unshipped_quantity,0) < ifnull(tc1.sum_usable_stock,0) then 1
when ifnull(tnc2.quantity_unshipped,0) < ifnull(tnc1.usable_stock,0) then 1
else 0
end
) = 1
and
(
case
when t2.buyer_name in ('张莹霞','张莹霞1') and t_db.hq_type not in ( '国内仓' ) and t1.platform='ebay'
then ifnull(tnc1.usable_stock,0) - ifnull(tnc2.quantity_unshipped,0) >=2
else
(
case
when ifnull(tc2.sum_unshipped_quantity,0) < ifnull(tc1.sum_usable_stock,0) then 1
when ifnull(tnc2.quantity_unshipped,0) < ifnull(tnc1.usable_stock,0) then 1