| | |
| | | t2.NAME AS name, |
| | | t2.phone AS phone, |
| | | CONCAT( t2.NAME, ' ', t2.phone ) AS user_search, |
| | | COALESCE ( t_course.course_name, t_information.information_name ) AS good_name, |
| | | COALESCE ( t_course.course_name, t_information.information_name,t_generated_records.recordsName ) AS good_name, |
| | | COALESCE ( t_course.course_cover, t_information.information_cover ) AS cover, |
| | | CONCAT(COALESCE ( t_course.course_name, t_information.information_name ),' ',t1.code) as orderSearch |
| | | FROM |
| | |
| | | AND t1.good_type = 1 |
| | | LEFT JOIN ( SELECT id, information_name AS information_name,information_cover FROM t_information ) t_information ON t1.good_id = t_information.id |
| | | AND t1.good_type = 2 |
| | | LEFT JOIN ( SELECT id, `name` AS recordsName,user_id FROM t_generated_records order by create_time DESC limit 1) t_generated_records ON t1.user_id = t_generated_records.user_id |
| | | AND t1.good_type = 3 |
| | | <where> |
| | | t1.is_delete = 0 |
| | | <if test="orderQuery.orderSearch != null and orderQuery.orderSearch != ''"> |
| | | AND ( t1.code LIKE concat('%',#{orderQuery.orderSearch},'%') or t_course.course_name LIKE concat('%',#{orderQuery.orderSearch},'%') or t_information.information_name LIKE concat('%',#{orderQuery.orderSearch},'%')) |
| | | AND ( t1.code LIKE concat('%',#{orderQuery.orderSearch},'%') |
| | | or t_course.course_name LIKE concat('%',#{orderQuery.orderSearch},'%') |
| | | or t_information.information_name LIKE concat('%',#{orderQuery.orderSearch},'%') |
| | | or t_generated_records.recordsName LIKE concat('%',#{orderQuery.orderSearch},'%')) |
| | | </if> |
| | | <if test="orderQuery.userSearch != null and orderQuery.userSearch != ''"> |
| | | AND (user_name LIKE concat('%',#{orderQuery.userSearch},'%') OR user_phone LIKE concat('%',#{orderQuery.userSearch},'%')) |
| | | AND (t2.name LIKE concat('%',#{orderQuery.userSearch},'%') OR t2.phone LIKE concat('%',#{orderQuery.userSearch},'%')) |
| | | </if> |
| | | <if test="orderQuery.goodType != null "> |
| | | AND t1.good_type = #{orderQuery.goodType} |
| | |
| | | SUM(CASE WHEN o.payment_status = 2 THEN 1 ELSE 0 END) AS paid_count, |
| | | SUM(CASE WHEN o.payment_status = 3 THEN 1 ELSE 0 END) AS cancelled_count, |
| | | count(1) AS refunded_count, |
| | | SUM(CASE WHEN o.payment_status = 2 THEN o.payment_amount ELSE 0 END) AS payment_amount |
| | | |
| | | <if test="orderQuery.paymentType != null and orderQuery.paymentType == 1"> |
| | | SUM(CASE WHEN o.payment_status = 1 THEN o.payment_amount ELSE 0 END) AS payment_amount |
| | | </if> |
| | | <if test="orderQuery.paymentType != null and orderQuery.paymentType == 2"> |
| | | SUM(CASE WHEN o.payment_status = 2 THEN o.payment_amount ELSE 0 END) AS payment_amount |
| | | </if> |
| | | <if test="orderQuery.paymentType != null and orderQuery.paymentType == 3"> |
| | | SUM(CASE WHEN o.payment_status = 3 THEN o.payment_amount ELSE 0 END) AS payment_amount |
| | | </if> |
| | | <if test="orderQuery.paymentType == null"> |
| | | SUM(CASE WHEN (o.payment_status = 1 OR o.payment_status = 2 OR o.payment_status = 3) THEN o.payment_amount ELSE 0 END) AS payment_amount |
| | | </if> |
| | | from ( |
| | | SELECT |
| | | t1.*, |
| | |
| | | AND t1.good_type = 1 |
| | | LEFT JOIN ( SELECT id, information_name AS information_name,information_cover FROM t_information ) t_information ON t1.good_id = t_information.id |
| | | AND t1.good_type = 2 |
| | | LEFT JOIN ( SELECT id, `name` AS recordsName,user_id FROM t_generated_records order by create_time DESC limit 1) t_generated_records ON t1.user_id = t_generated_records.user_id |
| | | AND t1.good_type = 3 |
| | | <where> |
| | | t1.is_delete = 0 |
| | | <if test="orderQuery.orderSearch != null and orderQuery.orderSearch != ''"> |
| | | AND ( t1.code LIKE concat('%',#{orderQuery.orderSearch},'%') or t_course.course_name LIKE concat('%',#{orderQuery.orderSearch},'%') or t_information.information_name LIKE concat('%',#{orderQuery.orderSearch},'%')) |
| | | AND ( t1.code LIKE concat('%',#{orderQuery.orderSearch},'%') |
| | | or t_course.course_name LIKE concat('%',#{orderQuery.orderSearch},'%') |
| | | or t_information.information_name LIKE concat('%',#{orderQuery.orderSearch},'%') |
| | | or t_generated_records.recordsName LIKE concat('%',#{orderQuery.orderSearch},'%')) |
| | | </if> |
| | | <if test="orderQuery.userSearch != null and orderQuery.userSearch != ''"> |
| | | AND (user_name LIKE concat('%',#{orderQuery.userSearch},'%') OR user_phone LIKE concat('%',#{orderQuery.userSearch},'%')) |
| | | AND (t2.name LIKE concat('%',#{orderQuery.userSearch},'%') OR t2.phone LIKE concat('%',#{orderQuery.userSearch},'%')) |
| | | </if> |
| | | <if test="orderQuery.goodType != null "> |
| | | AND t1.good_type = #{orderQuery.goodType} |
| | |
| | | <if test="orderQuery.createTime2 != null"> |
| | | AND DATE(t1.create_time) <= #{orderQuery.createTime2} |
| | | </if> |
| | | <if test="orderQuery.userId != null "> |
| | | AND t1.user_id = #{orderQuery.userId} |
| | | </if> |
| | | </where> |
| | | ) o |
| | | |