44323
2023-10-08 7808456a1e50af2dbd67488278eac85a558bd8f9
cloud-server-course/src/main/resources/mapper/TCoursePackagePaymentMapper.xml
@@ -134,6 +134,77 @@
    </select>
    <select id="getStudentTotal" resultType="map">
        SELECT * from(
                         SELECT studentId, totalClassHours, name as courseName, laveClassHours,cashPayment as cashPayment,hasHours,appUserId,insertTime
                         FROM (
                                  SELECT studentId, totalClassHours, name, laveClassHours,cashPayment, (totalClassHours - laveClassHours) AS hasHours,py.appUserId,py.insertTime
                                  FROM t_course_package_payment py
                                           LEFT JOIN t_course_package cp ON py.coursePackageId = cp.id
                                  UNION ALL
                                  SELECT studentId, SUM(totalClassHours) AS totalClassHours,'总计' as name, SUM(laveClassHours) AS laveClassHours, SUM(cashPayment) AS cashPayment,
                                         (SUM(totalClassHours) - SUM(laveClassHours)) AS hasHours,py.appUserId,py.insertTime
                                  FROM t_course_package_payment py
                                           LEFT JOIN t_course_package cp ON py.coursePackageId = cp.id
                                  GROUP BY studentId
                                  ORDER BY studentId, totalClassHours
                              ) subquery
                     ) a
        <where>
            <if test="null != start and '' != start and null != end and '' != end">
                  a.insertTime between #{start} and #{end}
            </if>
        </where>
    </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="null != start and '' != start and null != end and '' != end">
                py.insertTime 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}, '%')
            </if>
        </where>
        GROUP BY
            coursePackageId
    </select>
    <select id="listOne" resultType="com.dsh.course.entity.TCoursePackagePayment">
        select * from t_course_package_payment where appUserId in <foreach collection="ids" separator="," open="(" item="id" close=")">#{id}</foreach>
    </select>
    <update id="updateBytime">
        update  t_course_package_payment