This commit is contained in:
Lx 2025-07-09 11:23:52 +08:00
parent 7a5532b658
commit 32ab7f6652

View File

@ -309,6 +309,7 @@
dsco.order_remark,
dsco.cashier_confirm,
dsco.cashier_confirm_remark,
dsco.cashier_confirm_time,
dss.source,
dsco.payment_account,
MAX(CASE WHEN dsp.subject = 2 THEN COALESCE(dsp.coach_name, '') END) AS subject2CoachName,
@ -367,18 +368,17 @@
<if test="entity.isSign != null">
AND dsco.is_sign = #{entity.isSign}
</if>
<if test="entity.cashierConfirm != null and entity.cashierConfirm != '' ">
<if test="entity.cashierConfirm != ''">
<choose>
<when test="entity.cashierConfirm == '1'">
<when test="entity.cashierConfirm == 1">
AND dsco.cashier_confirm = 1
</when>
<when test="entity.cashierConfirm == '0'">
<when test="entity.cashierConfirm == 0">
AND dsco.cashier_confirm = 0
</when>
<otherwise>
<when test="entity.cashierConfirm == null">
AND dsco.cashier_confirm IS NULL
</otherwise>
</when>
</choose>
</if>
<if test="entity.source != null and entity.source != '' ">
@ -420,16 +420,15 @@
<select id="getOrderStatistics" resultType="cn.iocoder.yudao.module.course.vo.CourseOrderStatisticsVO">
SELECT
COUNT(DISTINCT dsco.user_id) AS studentCount,
COUNT(DISTINCT dss.user_id) AS studentCount,
SUM(dsco.reserve_money) AS totalAmount,
SUM(IFNULL(sub.subject2Deduct, 0)) AS subject2DeductTotal,
SUM(IFNULL(sub.subject3Deduct, 0)) AS subject3DeductTotal
FROM drive_school_course_order dsco
LEFT JOIN drive_school_student dss
ON dsco.user_id = dss.user_id AND dss.deleted = 0
-- 子查询先聚合提成,防止 JOIN 多条数据导致金额翻倍
FROM drive_school_student dss
LEFT JOIN drive_school_course_order dsco
ON dss.user_id = dsco.user_id
AND dsco.deleted = 0
AND dsco.if_end = 0
LEFT JOIN (
SELECT
dscd.course_id,
@ -449,19 +448,35 @@
)
)
)
WHERE dsco.deleted = 0
AND dsco.if_end = 0
WHERE dss.deleted = 0
AND dsco.user_id IS NOT NULL
AND dsco.is_sign = 1
<!-- 筛选条件部分 -->
<if test="entity.courseId != null and entity.courseId != '' ">
AND dsco.course_id = #{entity.courseId}
<if test="entity.studentName != null and entity.studentName != '' ">
AND dss.name LIKE CONCAT('%', #{entity.studentName}, '%')
</if>
<if test="entity.studentPhone != null and entity.studentPhone != '' ">
AND dsco.user_phone LIKE CONCAT('%', #{entity.studentPhone}, '%')
AND dss.phone LIKE CONCAT('%', #{entity.studentPhone}, '%')
</if>
<if test="entity.studentName != null and entity.studentName != '' ">
AND dsco.user_name LIKE CONCAT('%', #{entity.studentName}, '%')
<if test="entity.source != null and entity.source != '' ">
AND dss.source = #{entity.source}
</if>
<if test="entity.studentIdCard != null and entity.studentIdCard != '' ">
<choose>
<when test="entity.studentIdCard.length() == 18">
AND dss.id_card = #{entity.studentIdCard}
</when>
<when test="entity.studentIdCard.length() == 4">
AND RIGHT(dss.id_card, 4) = #{entity.studentIdCard}
</when>
<otherwise>
AND dss.id_card LIKE CONCAT('%', #{entity.studentIdCard}, '%')
</otherwise>
</choose>
</if>
<if test="entity.courseId != null and entity.courseId != '' ">
AND dsco.course_id = #{entity.courseId}
</if>
<if test="entity.coachId != null and entity.coachId != '' ">
AND dsco.coach_user_id = #{entity.coachId}
@ -493,33 +508,17 @@
<if test="entity.isSign != null">
AND dsco.is_sign = #{entity.isSign}
</if>
<if test="entity.cashierConfirm != null and entity.cashierConfirm != '' ">
<if test="entity.cashierConfirm != ''">
<choose>
<when test="entity.cashierConfirm == '1'">
<when test="entity.cashierConfirm == 1">
AND dsco.cashier_confirm = 1
</when>
<when test="entity.cashierConfirm == '0'">
<when test="entity.cashierConfirm == 0">
AND dsco.cashier_confirm = 0
</when>
<otherwise>
<when test="entity.cashierConfirm == null">
AND dsco.cashier_confirm IS NULL
</otherwise>
</choose>
</if>
<if test="entity.source != null and entity.source != '' ">
AND dss.source = #{entity.source}
</if>
<if test="entity.studentIdCard != null and entity.studentIdCard != '' ">
<choose>
<when test="entity.studentIdCard.length() == 18">
AND dsco.user_no = #{entity.studentIdCard}
</when>
<when test="entity.studentIdCard.length() == 4">
AND RIGHT(dsco.user_no, 4) = #{entity.studentIdCard}
</when>
<otherwise>
AND dsco.user_no LIKE CONCAT('%', #{entity.studentIdCard}, '%')
</otherwise>
</choose>
</if>
</select>