What events caused the period of decline in the Shang dynasty and ultimately caused the Shang dynasty to lose the Mandate of Heaven?