The present invention belongs to the technical field of pharmaceuticals, and particularly relates to a compound of formula (I), a pharmaceutically acceptable salt thereof, an ester thereof or a stereoisomer of the compound, the salt or the ester, wherein R1, X1, X2, M, Ar, ring A, ring B and L are as defined in the specification. The present invention also relates to: a preparation method for the compound, a pharmaceutically acceptable salt thereof, an ester thereof or a stereoisomer of the compound, the salt or the ester; a pharmaceutical composition and pharmaceutical formulation containing the compound, the pharmaceutically acceptable salt, the ester or the stereoisomer of the compound, the salt or the ester; and a use of the compound, the pharmaceutically acceptable salt, the ester or the stereoisomer of the compound, the salt or the ester in the preparation of a medicament for treating and/or preventing FXR-mediated diseases.