To seek an earth-abundant and environmentally friendly absorber for thin-film solar cells, Cu3PSe4 is investigated by first-principles calculations and device simulations. We demonstrate that the compound has a suitable band gap width of 1.3 eV as well as a high sunlight absorption coefficient. However, drawbacks like small electron affinity, high hole concentration, large lattice mismatch with CdS, etc., are revealed, which may degrade the photovoltaic performance. To address those shortcomings, we propose (1) to optimize the carrier concentration by preparing the samples at low temperature and under a Cu-rich environment, (2) to replace the CdS buffer layer by a more suitable wide-gap semiconductor with smaller lattice mismatch, and (3) that the selected buffer layer should have small electron affinity in order to reduce the open-circuit voltage losses. After implementation of these optimization approaches, the device simulations demonstrate that the power conversion efficiency reaches 17.7% for a solar cell with the configuration Mo/Cu3PSe4/WS2/n-ZnO. The combination of first-principles calculations at the atomistic level and device simulations at the macroscopic level provides an appropriate approach to design ideal solar cells.