shinnosuke
2026-08-27 b0edd6c4bd7912e706ef3af5a221caf0d6c78fac
talent-card-server/src/main/java/com/talentcard/server/mapper/AdminWorkbenchStatisticsMapper.java
@@ -37,10 +37,14 @@
              coalesce((select count(*) from talent_user u
                         where u.deleted = 0
                           and date(u.created_at) = date_sub(current_date, interval 1 day)), 0) as talentCompare,
              coalesce((select count(*) from verify_record v
                         where v.status = 1
                           and v.verify_time >= date_sub(current_date, interval 1 day)
                           and v.verify_time < current_date), 0) as monthlyVerificationCompare,
              (coalesce((select count(*) from verify_record current_month_verify
                          where current_month_verify.status = 1
                            and current_month_verify.verify_time >= date_format(current_date, '%Y-%m-01')
                            and current_month_verify.verify_time < date_add(last_day(current_date), interval 1 day)), 0)
               - coalesce((select count(*) from verify_record previous_month_verify
                            where previous_month_verify.status = 1
                              and previous_month_verify.verify_time >= date_sub(date_format(current_date, '%Y-%m-01'), interval 1 month)
                              and previous_month_verify.verify_time < date_format(current_date, '%Y-%m-01')), 0)) as monthlyVerificationCompare,
              coalesce(sum(case
                when coalesce(o.subsidy_amount, 0) > 0
                     and (o.product_id is null or coalesce(p.is_government_subsidy, 0) = 1)
@@ -61,6 +65,46 @@
    Map<String, Object> selectCompareSummary();
    @Select("""
            select date_format(days.bucket_day, '%c/%e') as time,
                   (select count(*)
                      from talent_user u
                     where u.deleted = 0
                       and u.created_at < date_add(days.bucket_day, interval 1 day)) as talent,
                   (select count(*)
                      from verify_record v
                     where v.status = 1
                       and v.verify_time >= days.bucket_day
                       and v.verify_time < date_add(days.bucket_day, interval 1 day)) as verification,
                   round(coalesce((select sum(case
                       when coalesce(o.subsidy_amount, 0) > 0
                            and (o.product_id is null or coalesce(p.is_government_subsidy, 0) = 1)
                         then o.subsidy_amount else 0 end)
                      from benefit_order o
                      left join merchant_product p on p.id = o.product_id and p.deleted = 0
                     where o.deleted = 0
                       and o.order_status = 1
                       and o.verify_status = 1
                       and exists (
                         select 1
                           from verify_record subsidy_verify
                          where subsidy_verify.order_id = o.id
                            and subsidy_verify.status = 1
                            and subsidy_verify.verify_time < date_add(days.bucket_day, interval 1 day)
                       )), 0) / 100, 2) as subsidy
              from (
                select date_sub(current_date, interval 6 day) as bucket_day union all
                select date_sub(current_date, interval 5 day) union all
                select date_sub(current_date, interval 4 day) union all
                select date_sub(current_date, interval 3 day) union all
                select date_sub(current_date, interval 2 day) union all
                select date_sub(current_date, interval 1 day) union all
                select current_date
              ) days
             order by days.bucket_day
            """)
    List<Map<String, Object>> selectSummaryTrend();
    @Select("""
            select buckets.bucket_time as time,
                   coalesce(count(v.id), 0) as `order`,
                   round(coalesce(sum(v.verify_amount), 0) / 100, 2) as amount