new_data.id=conn.QuerySingleOrDefault<int>(" select id from base_supplier_holiday_time where source_sys_id=@source_sys_id ",new{source_sys_id=new_data.source_sys_id});
if(new_data.id>0)
{
conn.Update(new_data);
}
else
{
new_data.gmt_create_time=DateTime.Now;
conn.Insert(new_data);
}
}
}
if(datas!=null&&datas.Count>=1)
{
conn.Execute(" update base_supplier_holiday_time set status=0,gmt_update_time=now() where source_sys_id not in @source_sys_ids ",new{source_sys_ids=datas.Select(s=>s.Id).ToList()});
}
else
{
conn.Execute(" update base_supplier_holiday_time set status=0,gmt_update_time=now() ");
from (select * from dc_mid_transit where warehouse_code in ( 'GZBLWH','BLGZ03','YWWH01' ) ) as t1
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 (
...
...
@@ -496,7 +497,9 @@ left join (
left join dc_base_stock as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
left join dc_auto_config_sku_warehouse as t6 on t1.bailun_sku = t6.bailun_sku and t1.warehouse_code = t6.warehouse_code
left join ( select * from dc_auto_monitor_sku_type where warehouse_type='国内仓') as t7 on t1.bailun_sku = t7.bailun_sku
left join holiday_supplier_view as t_sp on t2.suppliers_id = t_sp.supplier_id
where
t_sp.supplier_id is not null or
( t1.warehouse_code in ('GZBLWH','BLGZ03') or ( t1.warehouse_code in ('YWWH01') and ( t2.`status`=1 or t6.`status`=1 ) ) ) -- 义务仓 只要停止监控 或者停售就推送
and t1.bailun_sku not in ('942904501')
and ( t1.quantity_purchase<=0 and (ifnull(t4.sum_unshipped_quantity,0) - ifnull(t3.sum_usable_stock,0))>0 ) -- 有缺货
...
...
@@ -525,7 +528,9 @@ now() as 'push_date',
0 as 'has_return_goods',
t3.buyer_name,
t_db.hq_type as 'warehouse_type',
2 as 'type' from dc_base_stock as t1
2 as 'type' ,
t_sp.title as 'supplier_holiday_time'
from ( select * from dc_base_stock where warehouse_code in ( 'GZBLWH','BLGZ03','YWWH01' ) ) 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
left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
...
...
@@ -542,7 +547,10 @@ left join (
) as t5 on t1.bailun_sku = t5.bailun_sku and t_db.area_id = t5.area_id
left join dc_auto_config_sku_warehouse as t6 on t1.bailun_sku = t6.bailun_sku and t1.warehouse_code = t6.warehouse_code
left join ( select * from dc_auto_monitor_sku_type where warehouse_type='国内仓') as t7 on t1.bailun_sku = t7.bailun_sku
where t1.usable_stock<=0 and t1.bailun_sku!=''
left join holiday_supplier_view as t_sp on t3.suppliers_id = t_sp.supplier_id
where
t_sp.supplier_id is not null or
t1.usable_stock<=0 and t1.bailun_sku!=''
and ( t1.warehouse_code in ('GZBLWH','BLGZ03') or ( t1.warehouse_code in ('YWWH01') and ( t3.`status`=1 or t6.`status`=1 ) ) ) -- 义务仓 只要停止监控 或者停售就推送
and t1.bailun_sku not in ('942904501')
and ( case
...
...
@@ -585,13 +593,16 @@ t5.usable_stock as 'stocks',
@platform as 'platform',
0 as 'has_return_goods',
t2.buyer_name,
t_db.hq_type as 'warehouse_type'
t_db.hq_type as 'warehouse_type',
t_sp.title as 'supplier_holiday_time'
from dc_mid_transit as t1
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_stock as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
left join dc_auto_config_sku_warehouse as t6 on t1.bailun_sku = t6.bailun_sku and t1.warehouse_code = t6.warehouse_code
left join holiday_supplier_view as t_sp on t2.suppliers_id = t_sp.supplier_id
where
t_sp.supplier_id is not null or
( t1.warehouse_code in ('GZBLWH','BLGZ03','YWWH01') ) -- 义务仓 只要停止监控 或者停售就推送
and ( t2.`status`=1 or t6.`status`=1 )
and (ifnull(t1.quantity_unshipped,0) - ifnull(t5.usable_stock,0))>0 -- 有缺货
...
...
@@ -612,12 +623,17 @@ now() as 'push_date',
0 as 'has_return_goods',
t3.buyer_name,
t_db.hq_type as 'warehouse_type',
2 as 'type' from dc_base_stock as t1
2 as 'type' ,
t_sp.title as 'supplier_holiday_time'
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
left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
left join dc_auto_config_sku_warehouse as t6 on t1.bailun_sku = t6.bailun_sku and t1.warehouse_code = t6.warehouse_code
where t1.usable_stock<=0 and t1.bailun_sku!=''
left join holiday_supplier_view as t_sp on t3.suppliers_id = t_sp.supplier_id
where
t_sp.supplier_id is not null or
t1.usable_stock<=0 and t1.bailun_sku!=''
and ( t1.warehouse_code in ('GZBLWH','BLGZ03','YWWH01'))
and ( t3.`status`=1 or t6.`status`=1)
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 )
...
...
@@ -652,11 +668,13 @@ t5.usable_stock as 'stocks',
@platform as 'platform',
0 as 'has_return_goods',
t2.buyer_name,
t_db.hq_type as 'warehouse_type'
from dc_mid_transit as t1
t_db.hq_type as 'warehouse_type',
t_sp.title as 'supplier_holiday_time'
from (select * from dc_mid_transit where warehouse_code in @warehouse_codes ) as t1
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_stock as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
left join (
select t1.bailun_sku,t2.area_id,sum(t1.usable_stock) as 'usable_stock' from dc_base_stock as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
...
...
@@ -672,7 +690,9 @@ left join (
-- and t3.bailun_sku_warehouse_code not in ( select bailun_sku_warehouse_code from dc_auto_shortage_push_ignore )
GROUP BY t1.bailun_sku,t2.area_id
) as t7 on t1.bailun_sku = t7.bailun_sku and t_db.area_id = t7.area_id
left join holiday_supplier_view as t_sp on t2.suppliers_id = t_sp.supplier_id
where
t_sp.supplier_id is not null or
t1.warehouse_code in @warehouse_codes
-- and t5.bailun_sku_warehouse_code not in ( select bailun_sku_warehouse_code from dc_auto_shortage_push_ignore )
and ( ifnull(t6.usable_stock,0)<ifnull(t7.quantity_unshipped,0) ) -- 有缺货
...
...
@@ -694,8 +714,9 @@ now() as 'push_date',
2 as 'type' ,
0 as 'has_return_goods',
t2.buyer_name,
t_db.hq_type as 'warehouse_type'
from dc_base_stock as t1
t_db.hq_type as 'warehouse_type',
t_sp.title as 'supplier_holiday_time'
from ( select * from dc_base_stock where warehouse_code in @warehouse_codes ) as t1
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku
left join (
...
...
@@ -705,7 +726,10 @@ left join (
-- and t1.bailun_sku_warehouse_code not in ( select bailun_sku_warehouse_code from dc_auto_shortage_push_ignore )
GROUP BY t1.bailun_sku,t2.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
left join holiday_supplier_view as t_sp on t2.suppliers_id = t_sp.supplier_id
where
t_sp.supplier_id is not null or
t1.warehouse_code in @warehouse_codes
-- and t1.bailun_sku_warehouse_code not in ( select bailun_sku_warehouse_code from dc_auto_shortage_push_ignore )
and ifnull(t6.usable_stock,0)<=0 -- (case when t2.buyer_name in ('张莹霞','张莹霞1') and @platform='ebay' then 2 else 0 end )
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 )
...
...
@@ -1021,7 +1045,8 @@ when t_db.hq_type in ( '国内仓' ) then ifnull(tc1.sum_usable_stock,0) - ifn
else ifnull(tnc1.usable_stock,0)
end
) as 'stocks',
t2.buyer_name
t2.buyer_name,
t_sp.title as 'supplier_holiday_time'
from dc_auto_shortage_push as t1
left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku
left join dc_mid_transit as t3 on t1.bailun_sku = t3.bailun_sku and t1.warehouse_code = t3.warehouse_code
...
...
@@ -1054,10 +1079,10 @@ left join dc_base_stock as t3 on t1.warehouse_code = t3.warehouse_code and t1.ba
-- and t3.bailun_sku_warehouse_code not in ( select bailun_sku_warehouse_code from dc_auto_shortage_push_ignore )
GROUP BY t1.bailun_sku,t2.area_id
) as tnc2 on t1.bailun_sku = tnc2.bailun_sku and t_db.area_id = tnc2.area_id
where 1=1
-- t_stock.bailun_sku_warehouse_code not in ( select bailun_sku_warehouse_code from dc_auto_shortage_push_ignore )
and t1.platform=@platform and t1.has_return_goods=0
left join holiday_supplier_view as t_sp on t2.suppliers_id = t_sp.supplier_id