The invention belongs to the technical field of medicine and particularly relates to a compound shown as formula (I) that is shown in the description, and its pharmaceutically acceptable salts, estersor stereoisomers, with R1, R2, R3, M1, M2, Q, L, ring A, ring B and m defined as in the description and the claims. The invention also relates to a preparation method these compounds, pharmaceuticalpreparations and their application in the preparation of drugs for the treatment and / or prevention of FXR-mediated non-alcoholic fatty liver disease, primary biliary cirrhosis, lipid metabolism disorder, diabetic complications, malignant tumors and related diseases.