From 6061c45849de0f3ac6d05fdfa2bac4b09c21179b Mon Sep 17 00:00:00 2001
From: “djh” <“3298565835@qq.com”>
Date: 星期四, 06 三月 2025 10:11:10 +0800
Subject: [PATCH] 考试缴费统计修改

---
 exam-system/src/main/resources/mapper/pay/CoalCategoryMapper.xml |   73 ++++++++++++++++++++++++++++++++++++
 1 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/exam-system/src/main/resources/mapper/pay/CoalCategoryMapper.xml b/exam-system/src/main/resources/mapper/pay/CoalCategoryMapper.xml
index 217268b..c0ea25b 100644
--- a/exam-system/src/main/resources/mapper/pay/CoalCategoryMapper.xml
+++ b/exam-system/src/main/resources/mapper/pay/CoalCategoryMapper.xml
@@ -137,5 +137,78 @@
     <select id="selectCoalTicket" resultType="com.gkhy.exam.pay.entity.CoalTicket">
             select id , ticket_company_name,ticket_company_code,drawer,`check`,company_code  from coal_ticket
     </select>
+    <select id="countCategory" resultType="com.gkhy.exam.pay.dto.rep.CategoryCount">
+        SELECT
+            cc.id,
+            cc.subject_name,
+            cc.amount,
+            cc.category_type,
+            COUNT(cps.`name`) num
+        FROM
+            coal_category cc
+                LEFT JOIN coal_pay_category cpc ON cc.id = cpc.coal_category_id
+                LEFT JOIN coal_pay cp ON cpc.coal_pay_id = cp.id
+                LEFT JOIN coal_pay_student cps on cp.id = cps.coal_pay_id
+        <where>
+            cc.del_flag = 0 and cp.del_flag = 0 and cps.del_flag = 0 and cc.category_type = 2 and cps.pay_status =1
+            <if test="year !=null and year != ''">
+                and cp.year = #{year}
+            </if>
+            <if test="quarter!=null">
+                and cp.quarter = #{quarter}
+            </if>
+            <if test="deptId !=null">
+                and cp.dept_id = #{deptId}
+            </if>
+        </where>
+        GROUP BY cc.id
+    </select>
+    <select id="countThroey" resultType="com.gkhy.exam.pay.dto.rep.CateGoryTheory">
+        WITH filtered_data AS (
+        SELECT
+        cp.id AS pay_id,
+        cp.pay_type,
+        cpc.coal_category_id AS category_id
+        FROM
+        coal_pay cp
+        LEFT JOIN coal_pay_category cpc ON cp.id = cpc.coal_pay_id
+        LEFT JOIN coal_category cc ON cpc.coal_category_id = cc.id
+        WHERE
+        cc.category_type = 1
+        <if test="year !=null and year != ''">
+            and cp.year = #{year}
+        </if>
+        <if test="quarter!=null">
+            and cp.quarter = #{quarter}
+        </if>
+          <if test="deptId!=null">
+              and cp.dept_id =#{deptId}
+          </if>
+        AND cp.del_flag = 0
+        ),
+        pay_type_data AS (
+        SELECT
+        CASE
+        WHEN fd.pay_type IN (1, 3) THEN '初训理论'
+        ELSE '复训理论'
+        END AS pay_type_name,
+        cps.id AS student_id,
+        cc.amount
+        FROM
+        filtered_data fd
+        LEFT JOIN coal_pay_student cps ON fd.pay_id = cps.coal_pay_id
+        LEFT JOIN coal_category cc ON fd.category_id = cc.id
+        WHERE
+        cps.del_flag = 0 and cps.pay_status = 1
+        )
+        SELECT
+        pay_type_name,
+        COUNT(student_id) AS num,
+        MAX(amount) AS amount  -- 假设需要汇总 amount
+        FROM
+        pay_type_data
+        GROUP BY
+        pay_type_name
+    </select>
 
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.2