Subversion Repositories SmartDukaan

Rev

Show changed files | Directory listing | RSS feed

Filtering Options

Rev Age Author Path Log message Diff
37100 3 d 12 h amit /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/hdfc/ Simplify HDFC push-credits: drop Redis, store only credited payments

- Remove the Redis UTR lock entirely. It was redundant with the DB
UNIQUE(utr) + INSERT IGNORE dedup, and actively harmful: a concurrent
HDFC retry hit the Redis lock, got acked 'Duplicate', and stopped
retrying while the original rolled back on a wallet lock conflict --
losing the credit (4 lost credits Jul-11..15, all recovered manually).

- Store ONLY credited payments. Missing/unmatched-VA transfers are internal
onboarding virtual accounts reconciled via the separate account-entries
ledger, so they are no longer captured here. Removes the merely-captured
row states and the credited-vs-captured ambiguity.

- Drop the lock-conflict rethrow / isLockConflict helper. A credit failure
now simply propagates -> class @Transactional(rollbackFor=Throwable)
rolls the row back -> HDFC's own retry re-credits cleanly (no Redis lock
to swallow the retry).

Dedup now: manual-approval check + selectByUtrNo (a stored row means
credited) + INSERT IGNORE for the concurrent-retry race.
 
36944 23 d 10 h amit /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/ hdfc add-money: guard manual approval on credited flag + fix checkManualPayments

WalletController.addAmountToWallet now blocks a manual add-money approval only
when the UTR was actually auto-credited (hdfcPayment.isCredited()), not on mere
hdfc_payment row existence — so post-r36927 captured-but-uncredited rows
(VA missing/unmatched) are approvable again.

HdfcPaymentController: set credited=true on the captured row after a successful
wallet credit; fix checkManualPayments to filter on getStatus() (was comparing
transaction_reference String to an enum, always false) so an already-approved
manual payment correctly short-circuits the auto-credit (closes the reverse
double-credit path).
 
36927 24 d 12 h amit /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/ HDFC push-credits: stop lost/uncaptured credits and cut burst contention

- Capture every payment in hdfc_payment before VA validation; never 500 a
missing/unmatched VA. Acknowledge as success so HDFC stops retrying, leaving
the row uncredited for reconciliation (dedupe against add_wallet_request).
- On a row-lock conflict (lock-wait/deadlock), roll back fully and let HDFC retry
instead of mis-acking as 'duplicate', which silently lost valid-partner credits.
- Resolve VA/retailer (cached, read-only) before the INSERT to shorten the
hdfc_payment index-lock window.
- Scope READ-COMMITTED to the push-credits transaction only (no app-wide change)
to drop gap-lock contention on concurrent hdfc_payment inserts.
- Lower innodb_lock_wait_timeout to 10s per HikariCP connection so blocked
transactions fail fast instead of starving the pool.
 
36572 64 d 12 h amit /trunk/ fix: add debit note PDF labels, HDFC UTR duplicate lock, AJAX error handlers in common.js  
36411 82 d 13 h amit /trunk/ Fix lock contention: REQUIRES_NEW for wallet lock in createLoanForBilling, handle HDFC payment deadlock as duplicate  
36401 83 d 12 h amit /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/ Replace mailSender (SendGrid) with gmailRelaySender - SendGrid API key expired/revoked  
36371 86 d 15 h amit /trunk/ HDFC webhook: INSERT IGNORE on hdfc_payment to fix concurrent-duplicate 500 storm

Replaces persist() with a native INSERT IGNORE so concurrent same-UTR webhook
retries serialize on the unique-index check, and the loser gets a 0-row no-op
(warning, not exception). Outer @Transactional session stays clean, Spring
commits normally, HDFC sees 200 on both the winner (Success) and the loser
(Duplicate) - retry amplification ends.

Flow:
persist(hdfcPayment) -> insertIgnore(hdfcPayment) + selectByUtrNo(utr)
- inserted == 1: proceed with wallet / sidbi side-effects using fetched id
- inserted == 0: respond Duplicate, skip side-effects (owned by winning tx)
- defensive: log warn if insertIgnore returned 0 but selectByUtrNo finds
no row (could mean IGNORE swallowed a non-duplicate issue like truncation)

Also drops HdfcProcessingHelper (r36366) which used REQUIRES_NEW for the same
goal; that approach required a second JDBC connection and is no longer needed
with SQL-level idempotency.

Does NOT touch the wallet-side lost-update hole (user_wallet read-modify-write
without FOR UPDATE). That is a separate commit.
 
36367 87 d 10 h amit /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/hdfc/ HDFC webhook: delegate writes to HdfcProcessingHelper; always respond OK

Fixes the concurrent-duplicate deadlock observed on hadb1 2026-04-23 12:54:11
(two HDFC retries inserting same utr='308490624083' → InnoDB deadlock →
LockAcquisitionException → 500 → HDFC retries again → amplification).

- addPayment: the HDFC row build + persist + wallet/sidbi is now a single call
to hdfcProcessingHelper.processPayment() which runs in REQUIRES_NEW. The
helper catches DataIntegrityViolationException and logs silently; our tx
is unaffected.
- The else branch (pre-select found an existing row) now returns the same
code=100 status=Success as the main path instead of code=200 Duplicate.
Per product direction: HDFC should see 'OK' regardless of whether the row
already existed from a prior webhook, manual entry, or reconciliation —
retries stop cleanly, no 'Duplicate' surface distinction.

Did NOT add @Transactional(readOnly=true) on the outer method despite its
read-heavy shape — checkManualPayments() at line 277 has a write side-effect
(rejecting pending manual wallet requests for the same utr) which would be
silently dropped in a read-only session. Kept class-level writable tx for
the outer; only HDFC writes moved to REQUIRES_NEW helper.
 
34965 318 d 8 h amit /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/hdfc/ Update  
34944 319 d 14 h amit /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/hdfc/ Update  
34435 456 d 11 h tejus.lohani /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/ upi payment capture details modification and remove admit check in wallet statement download and account statement download so that partner download his account and wallet statement  
33369 797 d 10 h amit.gupta /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/hdfc/ Fixed Order quantity avai  
33368 797 d 10 h amit.gupta /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/hdfc/ Fixed logic to handle virtual account issue  
33354 800 d 14 h amit.gupta /trunk/ Enhanced Sidbi Sanctions  
33175 839 d 6 h amit.gupta /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/ Fixed Logic to avoid duplicate payments based on utr number  
33110 855 d 10 h amit.gupta /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/hdfc/ patch for  
33045 867 d 14 h amit.gupta /trunk/ Added sidbi and improvements in credit note  
32408 1046 d 17 h amit.gupta /trunk/ Fixed front end related issues with add/remove row  
32196 1104 d 14 h amit.gupta /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/hdfc/ Fixed additional scheme logic  
32025 1158 d 8 h amit.gupta /trunk/ Added logic to validate utr  

Show All