Designing Distribution Networks and Applications to Online Sales