From e825aefcd7285facc06fcb5bf69cdd5afc402b2d Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 08 十二月 2023 16:58:02 +0800
Subject: [PATCH] 11.27,9

---
 cloud-server-course/src/main/resources/mapper/TCoursePackagePaymentMapper.xml |   61 ++++++++++++------------------
 1 files changed, 25 insertions(+), 36 deletions(-)

diff --git a/cloud-server-course/src/main/resources/mapper/TCoursePackagePaymentMapper.xml b/cloud-server-course/src/main/resources/mapper/TCoursePackagePaymentMapper.xml
index 1024ba2..3b96861 100644
--- a/cloud-server-course/src/main/resources/mapper/TCoursePackagePaymentMapper.xml
+++ b/cloud-server-course/src/main/resources/mapper/TCoursePackagePaymentMapper.xml
@@ -191,48 +191,37 @@
         group by a.appUserId, a.studentId, a.coursePackageId
     </select>
     <select id="pacQueryDto" resultType="map">
-
-        SELECT
-        coursePackageId,
-        SUM( cashPayment ) AS cashPayment,
-        SUM( totalClassHours ) AS totalClassHours,
-        SUM( totalClassHours - laveClassHours ) AS hasHours,
-        ROUND( SUM(( totalClassHours - laveClassHours ) * ( cashPayment / totalClassHours )), 2 ) AS lavePay,
-        cp.`name` ,
-        cp.province,
-        cp.city,
-        cp.storeId,cp.cityCode,cp.provinceCode,py.insertTime
-        FROM
-        t_course_package_payment py
-        LEFT JOIN t_course_package cp ON py.coursePackageId = cp.id
-        <where>
-            <if test="storeIds != null and storeIds.size()>0">
-                AND cp.id IN
-                <foreach collection="storeIds" separator="," item="id" open="(" close=")">
-                    #{id}
+        select
+        id,
+        name,
+        province,
+        city,
+        storeId,
+        count(1) as number
+        from (
+            select
+            b.id,
+            b.`name`,
+            b.province,
+            b.city,
+            b.storeId
+            from t_course_package_scheduling a
+            left join t_course_package b on (a.coursePackageId = b.id)
+            where a.`status` != 4 and b.status != 4 and b.auditStatus = 2 and b.state = 1
+            <if test="null != storeIds and storeIds.size() > 0">
+                and b.storeId in
+                <foreach collection="storeIds" item="item" index="index" open="(" separator="," close=")">
+                    #{item}
                 </foreach>
             </if>
             <if test="null != start and '' != start and null != end and '' != end">
-                py.insertTime between #{start} and #{end}
+                and DATE_FORMAT(a.classDate, '%Y-%m-%d') between #{start} and #{end}
             </if>
-            <if test="null != cityCode and '' != cityCode">
-                and cityCode =#{cityCode}
-            </if>
-
-            <if test="null != provinceCode and '' != provinceCode">
-                and provinceCode =#{provinceCode}
-            </if>
-
             <if test="null != name and '' != name">
-                and name like CONCAT('%', #{name}, '%')
+                and b.name like CONCAT('%', #{name}, '%')
             </if>
-
-
-        </where>
-        GROUP BY
-        coursePackageId
-
-
+            order by classDate
+        ) as aa group by aa.id, aa.name, aa.province, aa.city, aa.storeId
     </select>
 
     <select id="listOne" resultType="com.dsh.course.entity.TCoursePackagePayment">

--
Gitblit v1.7.1