<?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.OrderMentalTestMapper">
|
|
<select id="getPage" resultType="cn.stylefeng.guns.modular.business.dto.OrderMentalTestPageDTO">
|
SELECT
|
o.id id, o.order_no,
|
o.create_time test_create_time,
|
tt.*, tt.id topicId,
|
tu.nick_name, tu.telephone
|
FROM
|
t_order_mental_test o
|
LEFT JOIN t_mental_test_topic tt ON o.goods_id = tt.id
|
LEFT JOIN toc_customer tu ON tu.customer_id = o.user_id
|
<where>
|
<if test="adminView != null and adminView == 1">
|
AND o.status_flag = 1 AND ( ( tt.test_type = 0 AND o.test_flag = 1 ) OR tt.test_type = 1 OR o.is_back = 1 )
|
</if>
|
<if test="title != null and title != ''">
|
AND tt.title LIKE CONCAT('%', #{title}, '%')
|
</if>
|
<if test="testType != null">
|
AND tt.test_type = #{testType}
|
</if>
|
<if test="statusFlag != null">
|
AND o.status_flag = #{statusFlag}
|
</if>
|
<if test="nickName != null and nickName != ''">
|
AND tu.nick_name LIKE CONCAT('%', #{nickName}, '%')
|
</if>
|
<if test="telephone != null and telephone != ''">
|
AND tu.telephone LIKE CONCAT('%', #{telephone}, '%')
|
</if>
|
</where>
|
ORDER BY o.create_time DESC
|
</select>
|
|
<select id="getInfoById" resultType="cn.stylefeng.guns.modular.business.dto.OrderMentalTestDetailDTO">
|
SELECT
|
o.*,
|
t.*, t.id topicId,
|
tr.*,
|
worker.nick_name consultWorkerName
|
FROM
|
t_order_mental_test o
|
LEFT JOIN t_mental_test_topic t ON o.goods_id = t.id
|
LEFT JOIN t_mental_test_record tr ON tr.answer_no = o.order_no
|
LEFT JOIN toc_customer worker ON worker.customer_id = tr.consult_worker_id
|
<where>
|
AND o.id = #{id}
|
</where>
|
LIMIT 1
|
</select>
|
|
<select id="getStatOrderList" resultType="java.util.Map">
|
SELECT
|
DATE_FORMAT( create_time, #{dateFormat} ) `time`,
|
SUM( order_amount ) `data`,
|
COUNT( 1 ) `number`
|
FROM
|
t_order_mental_test o
|
<where>
|
<if test="statusList != null and statusList.size != 0">
|
AND o.status_flag IN
|
<foreach collection="statusList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="orderNoList != null and orderNoList.size != 0">
|
AND o.order_no IN
|
<foreach collection="orderNoList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="workerId != null">
|
AND o.user_id = #{workerId}
|
</if>
|
<if test="beginTime != null and beginTime != ''">
|
AND o.create_time <![CDATA[ >= ]]> #{beginTime}
|
</if>
|
<if test="endTime != null and endTime != ''">
|
AND o.create_time <![CDATA[ <= ]]> #{endTime}
|
</if>
|
</where>
|
GROUP BY `time`
|
</select>
|
|
</mapper>
|