<?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.CounsellingOrderMapper">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="cn.stylefeng.guns.modular.business.entity.CounsellingOrder">
|
<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="order_type" property="orderType" />
|
<result column="phone" property="phone" />
|
<result column="effective_begin_time" property="effectiveBeginTime" />
|
<result column="effective_end_time" property="effectiveEndTime" />
|
<result column="counselling_set_meal_id" property="counsellingSetMealId" />
|
<result column="set_meal_json" property="setMealJson" />
|
<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="order_no" property="orderNo" />
|
<result column="order_amount" property="orderAmount" />
|
<result column="pay_amount" property="payAmount" />
|
<result column="pay_time" property="payTime" />
|
<result column="pay_type" property="payType" />
|
<result column="transaction_no" property="transactionNo" />
|
<result column="refund_amount" property="refundAmount" />
|
<result column="refund_time" property="refundTime" />
|
<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"/>
|
</resultMap>
|
|
<resultMap id="BaseDtoMap" type="cn.stylefeng.guns.modular.business.dto.CounsellingOrderResponseDTO" extends="BaseResultMap">
|
<result column="counsellingName" property="counsellingName"/>
|
<result column="userName" property="userName"/>
|
<result column="companionUserName" property="companionUserName"/>
|
<result column="consultantUserName" property="consultantUserName"/>
|
<result column="lastTime" property="lastTime"/>
|
<result column="coverImageUrl" property="coverImageUrl"/>
|
<result column="isFirstAppointment" property="isFirstAppointment"/>
|
<result column="listingStatus" property="listingStatus"/>
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, counselling_info_id, user_id, consultant_user_id, companion_user_id, order_type, phone, effective_begin_time, effective_end_time, counselling_set_meal_id, set_meal_json, class_hours, residue_class_hours, user_info_json, status_flag, is_delete, create_time, create_user, order_no, order_amount, pay_amount, pay_time, pay_type, transaction_no, refund_amount, refund_time
|
</sql>
|
|
<select id="findCounsellingOrderPage" resultMap="BaseDtoMap">
|
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,tcu.is_first_appointment isFirstAppointment,tci.listing_status listingStatus
|
FROM t_counselling_order 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 t_counselling_user tcu on tcu.counselling_info_id = tco.counselling_info_id and tcu.user_id = tco.user_id
|
<where>
|
AND tco.is_delete = 0
|
<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.orderType != null">
|
AND tco.order_type = #{param.orderType}
|
</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.searchType != null and param.searchType == 2">
|
AND tco.status_flag IN (1,2)
|
</if>
|
|
</where>
|
ORDER BY tco.create_time DESC
|
|
</select>
|
<select id="findWorkCounsellingOrderPage" resultMap="BaseDtoMap">
|
SELECT
|
tcu.*,toci.nick_name counsellingName,toc1.nick_name userName,toc2.nick_name companionUserName,toc3.nick_name consultantUserName,
|
tcor.lastTime,tci.listing_status listingStatus,tci.cover_image_url coverImageUrl,tcu.is_first_appointment isFirstAppointment
|
FROM t_counselling_user tcu
|
LEFT JOIN toc_customer toc1 ON toc1.customer_id = tcu.user_id
|
LEFT JOIN toc_customer toc2 ON toc2.customer_id = tcu.companion_user_id
|
LEFT JOIN toc_customer toc3 ON toc3.customer_id = tcu.consultant_user_id
|
LEFT JOIN t_counselling_info tci ON tci.id = tcu.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) and reservation_type =2
|
GROUP BY counselling_info_id,user_id
|
) tcor ON tcor.counselling_info_id = tcu.counselling_info_id and tcor.user_id = tcu.user_id
|
|
<where>
|
AND tcu.is_delete = 0 AND tcu.is_first_appointment = 3
|
<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 tcu.phone LIKE CONCAT('%',#{param.phone},'%')
|
</if>
|
|
<if test="param.userId != null">
|
AND tcu.user_id = #{param.userId}
|
</if>
|
<if test="param.counsellingInfoId != null">
|
AND tcu.counselling_info_id = #{param.counsellingInfoId}
|
</if>
|
<if test="param.customerId != null">
|
AND ( tcu.companion_user_id = #{param.customerId} OR tcu.consultant_user_id = #{param.customerId} OR tci.user_id = #{param.customerId} )
|
</if>
|
</where>
|
ORDER BY tcu.create_time DESC
|
|
</select>
|
|
</mapper>
|