SELECT bailun_sku,warehouse_code,sum(cost_first) as total_cost_first,sum(quantity) as total_count FROM dc_mid_cost_first_order GROUP BY bailun_sku,warehouse_code order by id asc limit #{v1}, #{v2}
SELECT tb2.* from (SELECT warehouse_code,area_id FROM dc_base_warehouse WHERE warehouse_code=#{warehouseCode}) tb1 LEFT JOIN dc_mid_cost_first_config tb2 on tb2.bailun_sku=#{bailunSku}
and (tb2.area_id = 0 or tb1.area_id=tb2.area_id or tb1.warehouse_code=tb2.warehouse_code)
order by tb2.warehouse_code desc ,tb2.area_id desc limit 1