Subversion Repositories SmartDukaan

Rev

Show changed files | Details | Compare with Previous | Blame | RSS feed

Filtering Options

Rev Age Author Path Log message Diff
37588 10 d 11 h amit /trunk/profitmandi-dao/src/main/ Serve partner investment from a 2-minute snapshot instead of a 3-hour cache

getInvestment() was @Cacheable on a 3-hour Redis cache that addAmountToWallet
evicted but consumeAmountFromWallet did not. A partner whose advance payment was
swept straight to a loan had the money counted twice - once as a still-cached
wallet balance, once as the reduced utilisation - overstating their credit limit
by the payment x their tier until the cache expired.

Replaced with fofo.partner_investment, refreshed every 2 minutes by
PartnerInvestmentSweepService. Every coupled term is read in one pass, so wallet
and utilisation (and in-stock and aged-Apple) can never come from different
moments. A shorter TTL would only have made the error rarer - it scales with the
payment, not the delay.

- PartnerInvestment entity/repository + partner_investment_snapshot.sql
- PartnerInvestmentSweepService: 9 batched reads, stores base_value for change
detection, refreshes aged-Apple for partners whose stock moved intra-day
- getInvestment/getInvestmentsForFofoStores both read the snapshot, so the two
paths no longer disagree; live compute retained as fallback
- selectActivatedStockAmountByFofoIds: batches an N+1 that cost 233ms x 1690
partners (6.6 min -> 1.0 s)
- getFirstBillingDates: batches another N+1 (4.6 s -> 0.67 s)
- selectPendingGrnOrders(List) now applies the same SD_START_DATE floor as the
single-partner overload; the two were reporting different GRN-pending
- selectPartnerStockValueMap takes excludeActivated: an activated Apple handset
held past the aging window was added once to in-stock and subtracted twice
(activated stock, then the aged haircut). 90 units, 24 partners, Rs 65.19 lakh
double-deducted. Live-demo passes false - no overlap there.
- applyManualAdjustment: routes the two hand-rolled admin wallet adjustments
through WalletServiceImpl so they take the FOR UPDATE lock
- add_idx_order_grn_pending.sql: covering index, GRN query 1320ms -> 514ms
 
36777 109 d 15 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/ Remove unused getOpeningTillExcludingPurchase (no callers)  
36513 134 d 10 h amit /trunk/ Add running_balance to userwallethistory: persist wallet balance after each transaction for instant ledger display. Populate at all write paths (WalletService, adjustTransaction). Read directly in wallet statement template and CSV download. Includes backfill migration SQL. Renamed walletSummart to walletSummary.  
36372 150 d 16 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/ Wallet: SELECT FOR UPDATE on user_wallet mutations to close lost-update hole

addAmountToWallet/consumeAmountFromWallet(x2)/rollbackAmountFromWallet all
follow a read-modify-write pattern on user_wallet with no pessimistic lock
and no @Version, so two concurrent tx for the same partner both read the
same pre-snapshot amount, compute their own deltas, and commit - the second
UPDATE silently overwrites the first's credit/debit. user_wallet_history
still gets both rows, so balance drifts vs sum(history) with no exception.

Replaces the misnamed (and body-broken) selectByIdForUpdate - whose
implementation was a plain selectById, not a lock - with a new
selectByRetailerIdForUpdate that issues SELECT ... FOR UPDATE via
LockModeType.PESSIMISTIC_WRITE, mirroring the idiom already used in
GenericRepositoryImpl.selectByIdForUpdate and OrderRepositoryImpl.
Preserves the create-on-missing behavior of selectByRetailerId so
first-time partners keep working.

Switches the four read-modify-write call sites in WalletServiceImpl from
selectByRetailerId to the new locking variant. Read-only callers
(getUserWalletByUserId, getUserWalletHistoryByUserId, etc.) keep using
the non-locking selectByRetailerId - MVCC snapshot reads stay non-blocking
for display/statement endpoints.

Also drops the stale commented-out selectByIdForUpdate line in
rollbackAmountFromWallet and removes the broken method from the
UserWalletRepository interface / impl - it had zero live callers.

Blast radius: every write call to these three wallet methods now holds
an X-lock on the target user_wallet row for the rest of the outer tx.
Concurrent write tx for the same partner will briefly serialize at the
SELECT FOR UPDATE - correct serialization instead of silent drift.
Read-only traffic is unaffected (MVCC).
 
36305 155 d 20 h amit /trunk/profitmandi-dao/src/main/ Batch processing infrastructure + per-partner offer processing + partner limit optimization + investment cache eviction on billing/payment/cancellation with 3hr TTL  
35828 210 d 14 h amit /trunk/ Optimize order creation: reduce DB queries, fix Hibernate batching, move filters to SQL  
34966 382 d 10 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/ Removed wallet Credit  
34752 444 d 5 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/ Fixed Activation Scheme Logic  
34674 460 d 11 h aman.kumar /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/ show the partner name when wallet amount is not sufficient on bulk order  
34575 492 d 12 h vikas.jangra /trunk/ Liquidation/Bidding auto approval  
34261 566 d 12 h tejus.lohani /trunk/ Give (a pending,approved,reject)add-wallet-req report  
33861 712 d 13 h tejus.lohani /trunk/ check fullStockPayment and orderDispatch and auto mark billing and fullstock payment  
33848 716 d 5 h tejus.lohani /trunk/ fix bm approval flow - loi generate after approval  
33845 716 d 15 h tejus.lohani /trunk/ new flow of Onboarding process and wod-fin report ,  
33547 808 d 8 h tejus.lohani /trunk/ changes in Max negative wallet value  
33421 842 d 6 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/ Added amount  
33247 884 d 14 h ranu /trunk/ warehouse billing phase one and added signature exception  
33194 895 d 15 h amit.gupta /trunk/ Added 10K for Referral  
33180 900 d 14 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/ patch for  
33172 905 d 12 h tejus.lohani /trunk/ add bulk order service in admin dashboard  
32871 976 d 11 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/ AA  
32494 1088 d 15 h amit.gupta /trunk/ Merged changes related to Smartdukaan  
31921 1234 d 14 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/ Fixed scheme depenedncy issue  
31521 1328 d 11 h amit.gupta /trunk/ Change Cutoff investment to 40
and MIN_INVESTMENT_PERCENT to 20
 
31420 1353 d 9 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/ Fixed net availability to SaholicCIS Table  
30998 1449 d 9 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/ Can now pay for Damage protection even when insufficient wallet. Wallet is allowed to go negative in this case.  
30889 1487 d 12 h amit.gupta /trunk/ Fixed commit  
30748 1518 d 17 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/ Added scheme in processing for specified scheme ids  
30747 1518 d 17 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/ Recharge not allowed for low insvestments  
30744 1519 d 9 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/ Added scheme in processing for specified scheme ids  
30743 1519 d 9 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/ Added scheme in processing for specified scheme ids  
30742 1519 d 9 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/ Added scheme in processing for specified scheme ids  
30741 1519 d 11 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/ Added scheme in processing for specified scheme ids  
30740 1519 d 11 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/ Added scheme in processing for specified scheme ids  
30677 1546 d 8 h amit.gupta /trunk/ Added scheme in processing for specified scheme ids  
30449 1585 d 12 h amit.gupta /trunk/ Added Offer Changes  
30066 1673 d 10 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/ Fixed logic to purchase/sales based value  
30025 1679 d 13 h amit.gupta /trunk/ Added notification for all credit  
29538 1787 d 12 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/  
29498 1789 d 15 h amit.gupta /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/