<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="cn.stylefeng.guns.modular.business.mapper.CounsellingUserMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="cn.stylefeng.guns.modular.business.entity.CounsellingUser">
|
<id column="id" property="id" />
|
<result column="counselling_info_id" property="counsellingInfoId" />
|
<result column="user_id" property="userId" />
|
<result column="consultant_user_id" property="consultantUserId" />
|
<result column="companion_user_id" property="companionUserId" />
|
<result column="phone" property="phone" />
|
<result column="effective_begin_time" property="effectiveBeginTime" />
|
<result column="effective_end_time" property="effectiveEndTime" />
|
<result column="class_hours" property="classHours" />
|
<result column="residue_class_hours" property="residueClassHours" />
|
<result column="user_info_json" property="userInfoJson" />
|
<result column="status_flag" property="statusFlag" />
|
<result column="is_delete" property="isDelete" />
|
<result column="create_time" property="createTime" />
|
<result column="create_user" property="createUser" />
|
<result column="update_user" property="updateUser" />
|
<result column="update_time" property="updateTime" />
|
<result column="first_appointment_date" property="firstAppointmentDate" />
|
<result column="first_appointment_times" property="firstAppointmentTimes" />
|
<result column="is_first_appointment" property="isFirstAppointment" />
|
<result column="counsellingName" property="counsellingName"/>
|
<result column="userName" property="userName"/>
|
<result column="lastTime" property="lastTime"/>
|
<result column="coverImageUrl" property="coverImageUrl"/>
|
<result column="listingStatus" property="listingStatus"/>
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, counselling_info_id, user_id, consultant_user_id, companion_user_id, phone, effective_begin_time, effective_end_time, class_hours, residue_class_hours, user_info_json, status_flag, is_delete, create_time, create_user, update_user, update_time, first_appointment_date, first_appointment_times, is_first_appointment
|
</sql>
|
<select id="findCounsellingUserPage" resultMap="BaseResultMap">
|
SELECT
|
tco.*,toci.nick_name counsellingName,toc1.nick_name userName,toc2.nick_name companionUserName,toc3.nick_name consultantUserName,tci.counselling_type counsellingType,
|
tci.cover_image_url coverImageUrl,tci.listing_status listingStatus,tcor.lastTime
|
FROM t_counselling_user tco
|
LEFT JOIN toc_customer toc1 ON toc1.customer_id = tco.user_id
|
LEFT JOIN toc_customer toc2 ON toc2.customer_id = tco.companion_user_id
|
LEFT JOIN toc_customer toc3 ON toc3.customer_id = tco.consultant_user_id
|
LEFT JOIN t_counselling_info tci ON tci.id = tco.counselling_info_id
|
LEFT JOIN toc_customer toci ON toci.customer_id = tci.user_id
|
LEFT JOIN (
|
SELECT counselling_info_id,user_id,MAX(reservation_begin_time) lastTime FROM
|
t_counselling_order_reservation
|
WHERE stauts IN (2,3,4)
|
GROUP BY counselling_info_id,user_id
|
) tcor ON tcor.counselling_info_id = tco.counselling_info_id and tcor.user_id = tco.user_id
|
<where>
|
AND tco.is_delete = 0 AND tco.status_flag NOT IN (0,9,10)
|
<if test="param.counsellingName != null and param.counsellingName != ''">
|
AND toci.nick_name LIKE CONCAT('%',#{param.counsellingName},'%')
|
</if>
|
<if test="param.userName != null and param.userName != ''">
|
AND toc1.nick_name LIKE CONCAT('%',#{param.userName},'%')
|
</if>
|
<if test="param.companionUserName != null and param.companionUserName != ''">
|
AND toc2.nick_name LIKE CONCAT('%',#{param.companionUserName},'%')
|
</if>
|
<if test="param.consultantUserName != null and param.consultantUserName != ''">
|
AND toc3.nick_name LIKE CONCAT('%',#{param.consultantUserName},'%')
|
</if>
|
<if test="param.phone != null and param.phone != ''">
|
AND tco.phone LIKE CONCAT('%',#{param.phone},'%')
|
</if>
|
|
<if test="param.statusFlag != null">
|
AND tco.status_flag = #{param.statusFlag}
|
</if>
|
<if test="param.userId != null">
|
AND tco.user_id = #{param.userId}
|
</if>
|
<if test="param.counsellingInfoId != null">
|
AND tco.counselling_info_id = #{param.counsellingInfoId}
|
</if>
|
<if test="param.customerId != null">
|
AND ( tco.companion_user_id = #{param.customerId} OR tco.consultant_user_id = #{param.customerId} OR tci.user_id = #{param.customerId} )
|
</if>
|
</where>
|
ORDER BY tco.create_time DESC
|
|
</select>
|
|
</mapper>
|