delete from dc_report_stock_week where week_tag=@week_tag;
insert into dc_report_stock_week(`stock`,`week_tag`,`warehouse_code`,`bailun_sku`,`first_day_date`,`web_site`,`sku_tag`,`stock_amount`,`is_order`)
(
select
select
t1.stock,
t1.week_tag,
t1.warehouse_code,
...
...
@@ -2990,7 +2993,20 @@ from dc_base_oms_sku as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
left join dc_base_stock t3 on t1.bailun_sku = t3.bailun_sku and t1.warehouse_code = t3.warehouse_code
left join dc_base_sku as t4 on t1.bailun_sku = t4.bailun_sku
where t1.paid_time>=@btime and t1.paid_time<=@etime group by t1.warehouse_code,t1.bailun_sku ) as t1
where t1.paid_time>=@btime and t1.paid_time<=@etime
and t1.bailun_order_status = 'Handling'
and t1.bailun_interception_status in ('None', 'Failed')
and t1.warehouse_code != ''
and t1.platform_type != 'FBA'
and t1.company_id = 1
and t1.has_delete = 0
and t1.has_scalp = 0
and t1.has_buyer_remark = 0
and t1.has_platsku_remark = 0
and t1.has_fba_s = 0
and t1.has_innersale = 0
and t1.paid_time >= '2019-03-01 12:00:00'
group by t1.warehouse_code,t1.bailun_sku ) as t1
where t1.hq_type='第三方仓库'
);
insert ignore into dc_report_stock_week(`stock`,`week_tag`,`warehouse_code`,`bailun_sku`,`first_day_date`,`web_site`,`sku_tag`,`stock_amount`,`is_order`)
...
...
@@ -3178,5 +3194,78 @@ where t1.bailun_sku = t2.bailun_sku and t1.week_tag=@week_tag;
delete from dc_report_purchase_week where week_tag=@week_tag;
insert into dc_report_purchase_week(`week_tag`,`type`,`warehouse_code`,`bailun_sku`,`stock`,`unit_price`,`is_new`,`quantity_purchase`,`amount_paid`,`web_stie`,`first_day_date`)
(
select
@week_tag as 'week_tag',
2 as 'type',
t_p.targetwareno as 'warehouse_code',
t_ps.sku as 'bailun_sku',
t1.usable_stock as 'stock',
t3.unit_price,
(
case
when t1.usable_stock<=0 and t3.develop_time >=@eonthFirstDate then 1
else 0
end
) as 'is_new',
sum(t_ps.deliverycount) as 'quantity_purchase',
sum(t_ps.deliverycount * t3.unit_price) as 'amount_paid',
t2.area_name as 'web_stie',
@btime as 'first_day_date'
from dc_base_transfer_info as t_p
left join dc_base_transfer_info_skus as t_ps on t_p.`dataid` = t_ps.dataid
left join dc_base_stock as t1 on t1.bailun_sku =t_ps.sku and t1.warehouse_code = t_p.targetwareno
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku =t3.bailun_sku
where t2.hq_type='第三方仓库' and t3.buyer_name not in('张莹霞','张莹霞1','黄镜洁','古艳洋1')
and t_p.`isdeleted`=0 and t_p.creationtime>=@btime and t_p.creationtime<=@etime
GROUP BY t_ps.sku ,t_p.targetwareno
);
insert into dc_report_purchase_week(`week_tag`,`type`,`warehouse_code`,`bailun_sku`,`stock`,`unit_price`,`is_new`,`quantity_purchase`,`amount_paid`,`web_stie`,`first_day_date`)
(
select
@week_tag as 'week_tag',
1 as 'type',
t_p.warehouse_into_code as 'warehouse_code',
t_p.bailun_sku,
t1.usable_stock as 'stock',
t3.unit_price,
(
case
when t1.usable_stock<=0 and t3.develop_time >=@eonthFirstDate then 1
else 0
end
) as 'is_new',
sum(t_p.quantity_purchase) as 'quantity_purchase',
sum(t_p.amount_paid) as 'amount_paid',
t2.area_name as 'web_stie',
@btime as 'first_day_date'
from dc_base_purchase_details as t_p
left join dc_base_stock as t1 on t1.bailun_sku =t_p.bailun_sku and t1.warehouse_code = t_p.warehouse_into_code
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku =t3.bailun_sku
where t2.hq_type='第三方仓库'
and t_p.`status`!=-1 and t_p.create_time>=@btime and t_p.create_time<=@etime