This paper presents a bi-level energy management framework that can help the retail market to coordinate peer-to-peer (P2P) energy trading among multiple prosumers. To this end, the interaction process is formulated as a cooperative Stackelberg game model, where a retailer acts as the leader that determines price discrimination for various prosumers, with the goal of maximizing the social welfare. On the other hand, prosumers act as followers and react to the leader’s decision in a cooperative manner. Based on a general Nash bargaining scheme, prosumers participate in P2P energy trading to share their idle energy resource with neighbors while allocating the cooperative revenue based on their contribution. Considering the uncertainty of renewable energy, a stochastic programming approach with Conditional Value at Risk (CVaR) is employed to characterize the expected losses by the retailer. The hierarchic energy interaction is formulated as a nonlinear bi-level programming model, a two-phase approach is proposed to address the formulation with a power function in the lower-level. By using Karush-Kuhn-Tucker conditions, a bi-level model is transformed into an equivalent single-level mixed-integer linear programming problem in first phase. Furthermore, the second phase completes the market clearing and determines the payments of the prosumers according to the scheduling results. Numerical cases are performed to demonstrate the effectiveness of the proposed model.