select t2_1.purchase_id,t2_1.warehouse_code,t2_1.bailun_sku,sum(t2_1.count) as 'inboundQuantity' from dc_base_purchase_inbound as t2_1
t1.quantity_virtual,
where t2_1.warehouse_code=@warehouse_code and t2_1.bailun_sku=@bailun_sku
t1.quantity_process,
GROUP BY t2_1.warehouse_code,t2_1.bailun_sku,t2_1.purchase_id
t2.quantity as 'purchase_daily_quantity'
) as t2 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code and t1.purchase_id = t2.purchase_id
from dc_daily_inventory as t1
where t1.count>t2.inboundQuantity and t1.warehouse_code=@warehouse_code and t1.bailun_sku=@bailun_sku
left join ( select * from dc_daily_purchase where record_time>=@time and type=1) as t2 on t1.warehouse_code = t2.warehouse_code and t1.bailun_sku = t2.bailun_sku
where 1=1
";
varcountSql=@"
select
count(1)
from dc_daily_inventory as t1
left join ( select * from dc_daily_purchase where record_time>=@time and type=1) as t2 on t1.warehouse_code = t2.warehouse_code and t1.bailun_sku = t2.bailun_sku
return_connection.Query<Models.dc_auto_config_promotion>(@"select * from dc_auto_config_promotion where bailun_sku=@bailun_sku and warehouse_code=@warehouse_code and promotion_time>=@b_promotion_time and promotion_time=@e_promotion_time ",parameters);