left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku
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 dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
...
@@ -491,7 +492,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh
...
@@ -491,7 +492,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh
";
";
if(!is_all)
if(!is_all)
{
{
sql+=$" 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 and dc_auto_shortage_push.platform='{platform}' ) ";
sql+=$" 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 and dc_auto_shortage_push.platform='{platform}' and dc_auto_shortage_push.has_return_goods=0 ) ";
left join dc_mid_transit as t2 on t1.warehouse_code =t2.warehouse_code and t1.bailun_sku =t2.bailun_sku
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
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
...
@@ -527,7 +529,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh
...
@@ -527,7 +529,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh
";
";
if(!is_all)
if(!is_all)
{
{
no_library_sql+=$" 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 and dc_auto_shortage_push.platform='{platform}' ) ";
no_library_sql+=$" 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 and dc_auto_shortage_push.platform='{platform}' and dc_auto_shortage_push.has_return_goods=0 ) ";
left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku
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 dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
...
@@ -574,7 +577,7 @@ and ( ifnull(t6.usable_stock,0)<ifnull(t7.quantity_unshipped,0) ) -- 有缺货
...
@@ -574,7 +577,7 @@ and ( ifnull(t6.usable_stock,0)<ifnull(t7.quantity_unshipped,0) ) -- 有缺货
";
";
if(!is_all)
if(!is_all)
{
{
sql+=$" 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 and dc_auto_shortage_push.platform='{platform}' ) ";
sql+=$" 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 and dc_auto_shortage_push.platform='{platform}' and dc_auto_shortage_push.has_return_goods=0 ) ";
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join (
left join (
...
@@ -595,7 +599,7 @@ left join (
...
@@ -595,7 +599,7 @@ left join (
) as t6 on t1.bailun_sku = t6.bailun_sku and t_db.area_id = t6.area_id
) as t6 on t1.bailun_sku = t6.bailun_sku and t_db.area_id = t6.area_id
where t1.warehouse_code in @warehouse_codes
where t1.warehouse_code in @warehouse_codes
and ifnull(t6.usable_stock,0)<=0
and ifnull(t6.usable_stock,0)<=0
and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_shortage_push_not_config.warehouse_code=t1.warehouse_code and dc_auto_shortage_push_not_config.bailun_sku=t1.bailun_sku )
and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_shortage_push_not_config.warehouse_code=t1.warehouse_code and dc_auto_shortage_push_not_config.bailun_sku=t1.bailun_sku and dc_auto_shortage_push.has_return_goods=0 )
";
";
if(!is_all)
if(!is_all)
{
{
...
@@ -714,10 +718,11 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh
...
@@ -714,10 +718,11 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh
conn.Execute(" update dc_auto_shortage_push set has_return_goods=0 where id in @ids ",new{ids=datas});
}
}
...
@@ -905,7 +910,7 @@ left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
...
@@ -905,7 +910,7 @@ left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join china_warehouse_unshipped as t5 on t1.bailun_sku = t5.bailun_sku and t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' )
left join china_warehouse_unshipped as t5 on t1.bailun_sku = t5.bailun_sku and t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' )
left join dc_base_stock as t_stock on t1.bailun_sku = t_stock.bailun_sku and t1.warehouse_code = t_stock.warehouse_code
left join dc_base_stock as t_stock on t1.bailun_sku = t_stock.bailun_sku and t1.warehouse_code = t_stock.warehouse_code
left join dc_auto_config_sku_warehouse as t7 on t1.bailun_sku = t7.bailun_sku and t1.warehouse_code = t7.warehouse_code
left join dc_auto_config_sku_warehouse as t7 on t1.bailun_sku = t7.bailun_sku and t1.warehouse_code = t7.warehouse_code
where t1.platform=@platform
where t1.platform=@platform and t1.has_return_goods=0
and (case
and (case
when t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) and t2.buyer_name not in ('张莹霞','张莹霞1') and (ifnull(t4.sum_usable_stock, 0) - ifnull(t5.sum_unshipped_quantity, 0) > 0) then 1
when t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) and t2.buyer_name not in ('张莹霞','张莹霞1') and (ifnull(t4.sum_usable_stock, 0) - ifnull(t5.sum_unshipped_quantity, 0) > 0) then 1
when(t3.quantity_out_stock is null or t3.quantity_out_stock <= 0) and ifnull(t_stock.usable_stock,0)> ifnull(t3.quantity_unshipped, 0) then 1
when(t3.quantity_out_stock is null or t3.quantity_out_stock <= 0) and ifnull(t_stock.usable_stock,0)> ifnull(t3.quantity_unshipped, 0) then 1