shinnosuke
2026-08-31 cb5a42c97fe9ae23b891bdc3231dc8eb100de218
talent-card-server/src/main/java/com/talentcard/server/mapper/MerchantSettlementStatisticsMapper.java
@@ -27,6 +27,8 @@
            <script>
            select count(*)
            from (
                select base.period_key, base.merchant_id
                from (
                select case
                           when #{periodType} = 'MONTH' then date_format(coalesce(v.verify_time, o.updated_at, o.created_at), '%Y-%m')
                           else date_format(coalesce(v.verify_time, o.updated_at, o.created_at), '%Y-%m-%d')
@@ -47,7 +49,23 @@
                  <if test="merchantType != null and merchantType != ''">and m.merchant_type_code = #{merchantType}</if>
                  <if test="startTime != null">and coalesce(v.verify_time, o.updated_at, o.created_at) &gt;= #{startTime}</if>
                  <if test="endTime != null">and coalesce(v.verify_time, o.updated_at, o.created_at) &lt; #{endTime}</if>
                group by period_key, o.merchant_id
                    union all
                    select case
                               when #{periodType} = 'MONTH' then date_format(r.verify_time, '%Y-%m')
                               else date_format(r.verify_time, '%Y-%m-%d')
                           end as period_key,
                           r.merchant_id
                    from verify_record r
                    join merchant m on m.id = r.merchant_id and m.deleted = 0
                    where r.status = 1
                      and r.order_id is null
                      and upper(r.verify_type) = 'HOTEL_FREE'
                      <if test="merchantId != null">and r.merchant_id = #{merchantId}</if>
                      <if test="merchantType != null and merchantType != ''">and m.merchant_type_code = #{merchantType}</if>
                      <if test="startTime != null">and r.verify_time &gt;= #{startTime}</if>
                      <if test="endTime != null">and r.verify_time &lt; #{endTime}</if>
                ) base
                group by base.period_key, base.merchant_id
            ) grouped
            </script>
            """)