China’s economy contracted in the three months ending in June compared with the previous quarter after Shanghai and other cities shut down to fight coronavirus outbreaks, but the government said a “stable recovery” is under way after businesses reopened.