From 2b2286576fa6585190ca871c18b37a5aec7f6622 Mon Sep 17 00:00:00 2001 From: alan Date: Fri, 19 Jun 2026 23:44:08 +0800 Subject: [PATCH] update --- config.py | 4 +-- logs/plutus_detailed.log.5 | 0 repositories/payment_repository.py | 58 +++++++++++++++--------------- 3 files changed, 31 insertions(+), 31 deletions(-) create mode 100644 logs/plutus_detailed.log.5 diff --git a/config.py b/config.py index cc21e6f..7cdd01a 100644 --- a/config.py +++ b/config.py @@ -36,8 +36,8 @@ class Config: MODE = 'payintent' # Threading configuration - MAX_PAYMENT_THREADS = 15 # Number of concurrent payment processing threads - THREAD_TIMEOUT = 30 # Timeout in seconds for payment processing threads + MAX_PAYMENT_THREADS = 6 # Number of concurrent payment processing threads + THREAD_TIMEOUT = 2 # Timeout in seconds for payment processing threads # Stripe API Keys STRIPE_LIVE_API_KEY = os.environ.get('STRIPE_LIVE_API_KEY') or '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' diff --git a/logs/plutus_detailed.log.5 b/logs/plutus_detailed.log.5 new file mode 100644 index 0000000..e69de29 diff --git a/repositories/payment_repository.py b/repositories/payment_repository.py index cf3ac06..7ec4cfe 100644 --- a/repositories/payment_repository.py +++ b/repositories/payment_repository.py @@ -354,6 +354,29 @@ class PaymentRepository: placeholders = ','.join(['%s'] * len(payment_methods)) + #query = f""" + #SELECT DISTINCT + # cb.customer_id, + # cb.deposit, + # cb.payment_method, + # pad.field_1 AS stripe_customer_id + #FROM customer_billing cb + #LEFT OUTER JOIN payment_account_data pad ON cb.customer_id = pad.customer_id + #WHERE cb.payment_method IN ({placeholders}) + #AND cb.deposit < %s + #AND pad.field_1 IS NOT NULL + #AND NOT EXISTS ( + # SELECT 1 + # FROM invoices i + # WHERE i.customer_id = cb.customer_id + # AND i.status = 'pending' + #) + #GROUP BY cb.customer_id, cb.deposit, cb.payment_method, pad.field_1 + #ORDER BY cb.payment_method ASC, cb.customer_id ASC + #LIMIT %s + #""" + + ###### Multi-month billing runs query = f""" SELECT DISTINCT cb.customer_id, @@ -371,40 +394,17 @@ class PaymentRepository: WHERE i.customer_id = cb.customer_id AND i.status = 'pending' ) + AND EXISTS ( + SELECT 1 + FROM invoices i + WHERE i.customer_id = cb.customer_id + AND i.date_till <= '2026-06-19' + ) GROUP BY cb.customer_id, cb.deposit, cb.payment_method, pad.field_1 ORDER BY cb.payment_method ASC, cb.customer_id ASC LIMIT %s """ - ###### Multi-month billing runs - #query = """ - #SELECT DISTINCT - # cb.customer_id, - # cb.deposit, - # cb.payment_method, - # pad.field_1 AS stripe_customer_id - #FROM customer_billing cb - #LEFT OUTER JOIN payment_account_data pad ON cb.customer_id = pad.customer_id - #WHERE cb.payment_method = %s - #AND cb.deposit < %s - #AND pad.field_1 IS NOT NULL - #AND NOT EXISTS ( - # SELECT 1 - # FROM invoices i - # WHERE i.customer_id = cb.customer_id - # AND i.status = 'pending' - #) - #AND EXISTS ( - # SELECT 1 - # FROM invoices i - # WHERE i.customer_id = cb.customer_id - # AND i.date_till = '2026-01-20' - #) - #GROUP BY cb.customer_id, cb.deposit, cb.payment_method, pad.field_1 - #ORDER BY cb.payment_method ASC, cb.customer_id ASC - #LIMIT %s - #""" - ## Need to fix "date_till" #####################