SELECT
	M.CALC_MONTH AS 结算月,
	U.USER_NAME AS 会员编号,
	U.REAL_NAME AS 会员姓名,
	U2.USER_NAME AS 推荐人编号,
	U2.REAL_NAME AS 推荐人姓名,
	D.LEVEL_NAME AS 结算时会员级别,
	E.LEVEL_NAME AS 结算时会员聘级,
	M.PV_PCS AS 个人业绩,
	M.VIP_PV_1L_ZC AS 一市场新增报单业绩,
	M.VIP_PV_2L_ZC AS 二市场新增报单业绩,
	M.VIP_PV_3L_ZC AS 三市场新增报单业绩,
	M.VIP_SURPLUS_1L_ZC AS 一市场月剩余报单业绩,
	M.VIP_SURPLUS_2L_ZC AS 二市场月剩余报单业绩,
	M.VIP_SURPLUS_3L_ZC AS 三市场月剩余报单业绩,
	M.PV_PSS AS 月新增团队业绩,
	M.PV_PSS_TOTAL AS 月累计团队业绩,
	DATE_FORMAT(FROM_UNIXTIME(M.CREATED_AT),'%Y-%m-%d %H:%i:%s') AS 创建时间
FROM
	ar_perf_month M
	LEFT JOIN ar_user U ON U.ID = M.USER_ID
	LEFT JOIN ar_user_relation_new R ON R.USER_ID = U.ID
	LEFT JOIN ar_user U2 ON U2.ID = R.PARENT_UID
	LEFT JOIN ar_employ_level E ON E.ID = M.LAST_EMP_LV
	LEFT JOIN ar_declaration_level D ON D.ID = M.LAST_DEC_LV
	WHERE M.CALC_MONTH = 202104