JD.com's decision to build its own logistics network and offer free shipping during a brutal price war nearly bankrupted the company - then made it China's e-commerce powerhouse.