“mitao”
2026-04-17 d699da385dda6257677ee93bef47388c0635f64e
tcm-training-admin-backend/src/main/resources/mapper/CoursePurchaseOrderMapper.xml
@@ -162,9 +162,25 @@
        FROM tcm_course_purchase_order o
        WHERE o.deleted = 0
          AND o.course_type = 'HEALTH_COURSE'
          AND o.purchase_target_type = 'COURSE'
          AND o.status = 'PAID'
          AND o.app_user_id = #{appUserId}
          AND o.course_id IS NOT NULL
          AND NOT EXISTS (
            SELECT 1
            FROM tcm_course_purchase_order newer
            WHERE newer.deleted = 0
              AND newer.course_type = 'HEALTH_COURSE'
              AND newer.status = 'PAID'
              AND newer.app_user_id = #{appUserId}
              AND newer.course_id = o.course_id
              AND (
                IFNULL(newer.paid_at, newer.created_at) > IFNULL(o.paid_at, o.created_at)
                OR (
                    IFNULL(newer.paid_at, newer.created_at) = IFNULL(o.paid_at, o.created_at)
                    AND newer.id > o.id
                )
              )
          )
        ORDER BY o.paid_at DESC, o.id DESC
    </select>