Hello. According to the Exit-Entry Administration Department of the Beijing Municipal Public Security Bureau, please provide your nationality. Based on your former description, the Moscow-Shanghai-Vietnam, Vietnam-Beijing-Moscow trip is in line with the 240-hour visa-free policy. The 240-hour visa-free policy does not have a time interval restriction, and the temporary entry card is required to be filled out for each entrance.
Since the answer to your question may vary depending on your actual situation, we advise you to contact the National Immigration Administration at +86 -10-12367 (foreign language services are available).
You can also check the following link that might be helpful: https://mp.weixin.qq.com/s/7zahK5m8B-9Nl0GMX0GlgA.
Thank you for your understanding and support!