@@ -3728,14 +3728,17 @@ where t1.bailun_sku = t2.bailun_sku and t1.bailun_sku = t3.bailun_sku and t1.wee
{
varbtime3=DateTime.Now.AddMonths(-3);
_connection.Execute(@"-- 刷新首次采购时间
-- 刷新首次采购时间
set session transaction isolation level read uncommitted;
start transaction;
update dc_base_stock as t1,
(select t1.bailun_sku,t1.warehouse_into_code as 'warehouse_code',min(t1.create_time) as 'min_time' from dc_base_purchase_details as t1
where `status`!=-1 and t1.create_time>=@btime
GROUP BY t1.bailun_sku,t1.warehouse_into_code) as t2
(select t1.bailun_sku,(case when t1.isallot=0 then t1.warehouse_from_code else t1.warehouse_into_code end) as 'warehouse_code',min(t1.create_time) as 'min_time' from dc_base_purchase_details as t1
where `status`!=-1 -- and t1.create_time>=@btime
GROUP BY t1.bailun_sku,(case when t1.isallot=0 then t1.warehouse_from_code else t1.warehouse_into_code end)) as t2
set t1.first_purchase_date = t2.min_time
where t1.bailun_sku = t2.bailun_sku and t1.warehouse_code=t2.warehouse_code and t1.first_purchase_date is null ;