| | |
| | | id, app_user_id, application_vip_id, application_time, status, shop_point, share_point, direct_vip_num, direct_agent_num, bind_shop_num, remark, del_flag, create_time |
| | | </sql> |
| | | <select id="pageList" resultType="com.ruoyi.account.api.model.AgentApplication"> |
| | | select |
| | | SELECT |
| | | * |
| | | FROM |
| | | ( |
| | | SELECT |
| | | t1.*, |
| | | t1.id as idStr, |
| | | t2.name as userName, |
| | | t2.phone as userPhone |
| | | from t_agent_application t1 |
| | | left join t_app_user t2 on t1.app_user_id = t2.id |
| | | t1.id AS idStr, |
| | | t2.NAME AS userName, |
| | | t2.phone AS userPhone, |
| | | 1 AS sort_order |
| | | FROM |
| | | t_agent_application t1 |
| | | LEFT JOIN t_app_user t2 ON t1.app_user_id = t2.id |
| | | WHERE |
| | | t1.`status` = 1 UNION ALL |
| | | SELECT |
| | | t1.*, |
| | | t1.id AS idStr, |
| | | t2.NAME AS userName, |
| | | t2.phone AS userPhone, |
| | | 2 AS sort_order |
| | | FROM |
| | | t_agent_application t1 |
| | | LEFT JOIN t_app_user t2 ON t1.app_user_id = t2.id |
| | | WHERE |
| | | t1.`status` != 1 |
| | | ) AS combined_results |
| | | <where> |
| | | <if test="agentQuery.name !=null and agentQuery.name !=''"> |
| | | and t2.name like concat('%',#{agentQuery.name},'%') |
| | | and userName like concat('%',#{agentQuery.name},'%') |
| | | </if> |
| | | <if test="agentQuery.phone !=null and agentQuery.phone !=''"> |
| | | and t2.phone like concat('%',#{agentQuery.phone},'%') |
| | | and userPhone like concat('%',#{agentQuery.phone},'%') |
| | | </if> |
| | | <if test="agentQuery.vipId !=null"> |
| | | and t2.vip_id = #{agentQuery.vipId} |
| | | and vip_id = #{agentQuery.vipId} |
| | | </if> |
| | | <if test="agentQuery.status !=null"> |
| | | and t1.status = #{agentQuery.status} |
| | | and status = #{agentQuery.status} |
| | | </if> |
| | | </where> |
| | | order by |
| | | t1.STATUS ASC, |
| | | t1.application_time ASC, |
| | | t1.create_time desc |
| | | ORDER BY |
| | | sort_order, |
| | | CASE |
| | | |
| | | WHEN sort_order = 1 THEN |
| | | application_time ELSE NULL |
| | | END ASC, |
| | | CASE |
| | | |
| | | WHEN sort_order = 2 THEN |
| | | application_time ELSE NULL |
| | | END DESC |
| | | </select> |
| | | |
| | | </mapper> |