|
|
@@ -18,13 +18,16 @@ public interface PayBillMapper extends BaseMapper<PayBillEntity> {
|
|
|
* 统计消费金额 — 对应 Python stat_consume_amount_service
|
|
|
* 查询 pay_bill 表 (consume_type=CONSUME, status=PROCESSED)
|
|
|
* 单次 SQL 完成三个时间窗口聚合(参考 doStatAmount 模式)
|
|
|
+ *
|
|
|
+ * 使用 gmt_biz_create(业务创建时间)而非 gmt_recieve_pay(收款时间),
|
|
|
+ * 因为 gmt_recieve_pay 在通知回调中可能为空。时间戳由应用层传入,避免 CURRENT_DATE 时区问题。
|
|
|
*/
|
|
|
@Select("""
|
|
|
<script>
|
|
|
SELECT
|
|
|
- COALESCE(SUM(CASE WHEN gmt_recieve_pay >= CURRENT_DATE
|
|
|
+ COALESCE(SUM(CASE WHEN gmt_biz_create >= #{today}
|
|
|
THEN consume_amount ELSE 0 END), 0) as amount_of_today,
|
|
|
- COALESCE(SUM(CASE WHEN gmt_recieve_pay >= CURRENT_DATE - INTERVAL '7 days'
|
|
|
+ COALESCE(SUM(CASE WHEN gmt_biz_create >= #{weekAgo}
|
|
|
THEN consume_amount ELSE 0 END), 0) as amount_of_7days,
|
|
|
COALESCE(SUM(consume_amount), 0) as amount_of_all
|
|
|
FROM pay_bill
|
|
|
@@ -42,7 +45,9 @@ public interface PayBillMapper extends BaseMapper<PayBillEntity> {
|
|
|
""")
|
|
|
Map<String, BigDecimal> statConsumeAmount(@Param("tenantId") Long tenantId,
|
|
|
@Param("enterpriseId") String enterpriseId,
|
|
|
- @Param("payeeType") String payeeType);
|
|
|
+ @Param("payeeType") String payeeType,
|
|
|
+ @Param("today") java.time.OffsetDateTime today,
|
|
|
+ @Param("weekAgo") java.time.OffsetDateTime weekAgo);
|
|
|
|
|
|
/**
|
|
|
* 原子 upsert(通知处理用,跳过租户过滤)
|