Considering that Xiao Wang is a legal person in Company B, it is suggested to maintain the labor relationship of Company B (which requires social security) and change the relationship between Xiao Wang and Company A into a labor relationship (which does not require social security). If it is to save the company's social security cost, it is suggested that the wage agreement between Xiao Wang and Company B should be between 25% and 50% of the salary of the post industry.
Further reading: How to buy insurance, which is good, and teach you how to avoid these "pits" of insurance.