SELECT
rpl.ID, rpl.DID, rpl.TRADE_TYPE, rpl.TRADE_TIME, rpl.CALL_TIME, rpl.TRADE_ADDR, rpl.RECEIVE_PHONE, rpl.CALL_TYPE, rpl.CREATE_DATE, rpl.CREATE_BY,
rpl.STATE, rpl.REMARK, umci.contact_name
FROM
R360_Phonedetaillist rpl
Left join User_Mobile_Contact_Info umci ON rpl.receive_phone = umci.contact_mobile_no
<if test="userId != '' and userId != null">
and umci.user_id = #{userId}
</if>
WHERE
rpl.did = #{did}
<if test="orderField != '' and orderField != null and orderDirection != '' and orderDirection != null">
ORDER by ${orderField} ${orderDirection}
</if>