<?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.CounsellingOrderReservationMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="cn.stylefeng.guns.modular.business.entity.CounsellingOrderReservation">
|
<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="counselling_order_id" property="counsellingOrderId" />
|
<result column="reservation_begin_time" property="reservationBeginTime" />
|
<result column="reservation_end_time" property="reservationEndTime" />
|
<result column="stauts" property="stauts" />
|
<result column="create_time" property="createTime" />
|
<result column="service_begin_time" property="serviceBeginTime" />
|
<result column="service_end_time" property="serviceEndTime" />
|
<result column="service_approve_time" property="serviceApproveTime" />
|
<result column="servie_complete_time" property="servieCompleteTime" />
|
<result column="consume_course_hour" property="consumeCourseHour" />
|
<result column="reservation_type" property="reservationType"/>
|
<result column="counsellingInfoName" property="counsellingInfoName"/>
|
<result column="userName" property="userName"/>
|
<result column="workNum" property="workNum"/>
|
<result column="phone" property="phone"/>
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, counselling_info_id, user_id, consultant_user_id, companion_user_id, counselling_order_id, reservation_begin_time, reservation_end_time, stauts, create_time, service_begin_time, service_end_time, service_approve_time, servie_complete_time, consume_course_hour
|
</sql>
|
|
<select id="findPage" resultMap="BaseResultMap">
|
SELECT tcor.*,tco.phone,tc.nick_name userName,tcus.nick_name counsellingInfoName,
|
(
|
SELECT count(1) FROM t_counselling_reservation_work WHERE is_delete = 0 and counselling_order_reservation_id = tcor.id
|
) workNum
|
FROM t_counselling_order_reservation tcor
|
INNER JOIN toc_customer tc on tc.customer_id = tcor.user_id
|
INNER JOIN t_counselling_info tci on tci.id = tcor.counselling_info_id
|
INNER JOIN toc_customer tcus on tcus.customer_id = tci.user_id
|
INNER JOIN t_counselling_user tco on tco.counselling_info_id = tcor.counselling_info_id and tco.user_id = tcor.user_id
|
<where>
|
tcor.stauts !=5
|
<if test="params.stauts != null">
|
AND tcor.stauts = #{params.stauts}
|
</if>
|
<if test="params.userName != null and params.userName != ''">
|
AND tc.nick_name LIKE CONCAT('%',#{params.userName},'%')
|
</if>
|
<if test="params.counsellingInfoName != null and params.counsellingInfoName != ''">
|
AND tcus.nick_name LIKE CONCAT('%',#{params.counsellingInfoName},'%')
|
</if>
|
<if test="params.phone != null and params.phone != ''">
|
AND tco.phone LIKE CONCAT('%',#{params.phone},'%')
|
</if>
|
<if test="params.searchBeginTime != null and params.searchBeginTime != ''">
|
AND tcor.reservation_begin_time >= #{params.searchBeginTime}
|
</if>
|
<if test="params.searchEndTime != null and params.searchEndTime != ''">
|
AND tcor.reservation_end_time <= #{params.searchEndTime}
|
</if>
|
<if test="params.reservationType != null">
|
AND tcor.reservation_type = #{params.reservationType}
|
</if>
|
<if test="params.counsellingInfoId != null">
|
AND tcor.counselling_info_id = #{params.counsellingInfoId}
|
</if>
|
<if test="params.counsellingOrderId != null">
|
AND tcor.counselling_order_id = #{params.counsellingOrderId}
|
</if>
|
<if test="params.customerId != null">
|
AND tcor.user_id = #{params.customerId}
|
</if>
|
</where>
|
ORDER BY tcor.reservation_begin_time DESC
|
</select>
|
|
|
<select id="findWorkPage" resultMap="BaseResultMap">
|
SELECT tcor.*,tco.phone,tc.nick_name userName,tcus.nick_name counsellingInfoName FROM t_counselling_order_reservation tcor
|
INNER JOIN toc_customer tc on tc.customer_id = tcor.user_id
|
INNER JOIN t_counselling_info tci on tci.id = tcor.counselling_info_id
|
INNER JOIN toc_customer tcus on tcus.customer_id = tci.user_id
|
INNER JOIN t_counselling_user tco on tco.counselling_info_id = tcor.counselling_info_id and tco.user_id = tcor.user_id
|
<where>
|
<if test="params.stauts != null">
|
AND tcor.stauts = #{params.stauts}
|
</if>
|
<if test="params.userName != null and params.userName != ''">
|
AND tc.nick_name LIKE CONCAT('%',#{params.userName},'%')
|
</if>
|
<if test="params.counsellingInfoName != null and params.counsellingInfoName != ''">
|
AND tcus.nick_name LIKE CONCAT('%',#{params.counsellingInfoName},'%')
|
</if>
|
<if test="params.phone != null and params.phone != ''">
|
AND tco.phone LIKE CONCAT('%',#{params.phone},'%')
|
</if>
|
<if test="params.searchBeginTime != null and params.searchBeginTime != ''">
|
AND tcor.reservation_begin_time >= #{params.searchBeginTime}
|
</if>
|
<if test="params.searchEndTime != null and params.searchEndTime != ''">
|
AND tcor.reservation_end_time <= #{params.searchEndTime}
|
</if>
|
<if test="params.reservationType != null">
|
AND tcor.reservation_type = #{params.reservationType}
|
</if>
|
<if test="params.counsellingInfoId != null">
|
AND tcor.counselling_info_id = #{params.counsellingInfoId}
|
</if>
|
<if test="params.counsellingOrderId != null">
|
AND tcor.counselling_order_id = #{params.counsellingOrderId}
|
</if>
|
<if test="params.customerId != null">
|
AND (tcor.consultant_user_id = #{params.customerId} or tcor.companion_user_id = #{params.customerId}
|
or tci.user_id = #{params.customerId} )
|
</if>
|
<if test="params.searchType != null and params.searchType == 1">
|
AND tcor.stauts IN (2,3,4)
|
</if>
|
</where>
|
ORDER BY tcor.reservation_begin_time DESC
|
|
</select>
|
<select id="findOrderReservationByUserIdPage"
|
resultType="cn.stylefeng.guns.modular.business.entity.CounsellingOrderReservation">
|
SELECT tcor.*,tco.phone,tc.nick_name userName,tcus.nick_name counsellingInfoName FROM t_counselling_order_reservation tcor
|
INNER JOIN toc_customer tc on tc.customer_id = tcor.user_id
|
INNER JOIN t_counselling_info tci on tci.id = tcor.counselling_info_id
|
INNER JOIN toc_customer tcus on tcus.customer_id = tci.user_id
|
INNER JOIN t_counselling_user tco on tco.counselling_info_id = tcor.counselling_info_id and tco.user_id = tcor.user_id
|
<where>
|
<if test="params.stauts != null">
|
AND tcor.stauts = #{params.stauts}
|
</if>
|
<if test="params.customerId != null and params.customerId != ''">
|
AND tc.customer_id = #{params.customerId}
|
</if>
|
<if test="params.counsellingInfoName != null and params.counsellingInfoName != ''">
|
AND tcus.nick_name LIKE CONCAT('%',#{params.counsellingInfoName},'%')
|
</if>
|
|
</where>
|
ORDER BY tcor.reservation_begin_time DESC
|
|
</select>
|
<select id="getCounsellingNumTotalByUserId"
|
resultType="cn.stylefeng.guns.modular.business.dto.UserCounsellingTotalDTO"
|
parameterType="cn.stylefeng.guns.modular.business.dto.request.UserCounsellingOrderReservationRequestDTO">
|
SELECT IFNUll(SUM(tco.class_hours),0) totalNum,IFNULL(SUM(tco.residue_class_hours),0) residueClassHoursNum FROM t_counselling_user tco
|
INNER JOIN t_counselling_info tci ON tci.id = tco.counselling_info_id
|
INNER JOIN toc_customer tc ON tc.customer_id = tci.user_id
|
<where>
|
<if test="counsellingInfoName != null and counsellingInfoName != ''">
|
AND tc.nick_name LIKE CONCAT('%',#{counsellingInfoName},'%')
|
</if>
|
<if test="customerId != null and customerId != ''">
|
AND tco.user_id = #{customerId}
|
</if>
|
</where>
|
|
|
</select>
|
<select id="findReservationPage"
|
resultType="cn.stylefeng.guns.modular.business.entity.CounsellingOrderReservation">
|
SELECT tcor.*,tco.phone,tc.nick_name userName,tcus.nick_name counsellingInfoName,
|
(
|
SELECT count(1) FROM t_counselling_reservation_work WHERE is_delete = 0 and counselling_order_reservation_id = tcor.id
|
) workNum
|
FROM t_counselling_order_reservation tcor
|
INNER JOIN t_counselling_order tcord ON tcord.id = tcor.counselling_order_id AND tcord.status_flag NOT IN (9,10)
|
INNER JOIN toc_customer tc on tc.customer_id = tcor.user_id
|
INNER JOIN t_counselling_info tci on tci.id = tcor.counselling_info_id
|
INNER JOIN toc_customer tcus on tcus.customer_id = tci.user_id
|
INNER JOIN t_counselling_user tco on tco.counselling_info_id = tcor.counselling_info_id and tco.user_id = tcor.user_id
|
<where>
|
AND ((tcor.reservation_type = 1 AND tcor.stauts != 5) OR (tcor.reservation_type = 2))
|
<if test="params.stauts != null">
|
AND tcor.stauts = #{params.stauts}
|
</if>
|
<if test="params.userName != null and params.userName != ''">
|
AND tc.nick_name LIKE CONCAT('%',#{params.userName},'%')
|
</if>
|
<if test="params.counsellingInfoName != null and params.counsellingInfoName != ''">
|
AND tcus.nick_name LIKE CONCAT('%',#{params.counsellingInfoName},'%')
|
</if>
|
<if test="params.phone != null and params.phone != ''">
|
AND tco.phone LIKE CONCAT('%',#{params.phone},'%')
|
</if>
|
<if test="params.searchBeginTime != null and params.searchBeginTime != ''">
|
AND tcor.reservation_begin_time >= #{params.searchBeginTime}
|
</if>
|
<if test="params.searchEndTime != null and params.searchEndTime != ''">
|
AND tcor.reservation_end_time <= #{params.searchEndTime}
|
</if>
|
<if test="params.reservationType != null">
|
AND tcor.reservation_type = #{params.reservationType}
|
</if>
|
<if test="params.counsellingInfoId != null">
|
AND tcor.counselling_info_id = #{params.counsellingInfoId}
|
</if>
|
<if test="params.counsellingOrderId != null">
|
AND tcor.counselling_order_id = #{params.counsellingOrderId}
|
</if>
|
<if test="params.customerId != null">
|
AND tcor.user_id = #{params.customerId}
|
</if>
|
</where>
|
ORDER BY tcor.create_time DESC
|
|
</select>
|
|
</mapper>
|