Subversion Repositories SmartDukaan

Rev

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

Filtering Options

Rev Age Author Path Log message Diff Changes
37102 6 d 8 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/ Remove dead Counter/PrivateDealUser code: drop unused isFofo, bulkShipmentAmountLimit, verifiedOn, documentVerified fields and accessors; remove dead selectByIds repo methods; drop redundant Counter/PrivateDealUser repository injections in OrderServiceImpl and InvoiceService  
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/entity/user/Counter.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/entity/user/PrivateDealUser.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/user/CounterRepository.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/user/CounterRepositoryImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/user/PrivateDealUserRepository.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/user/PrivateDealUserRepositoryImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/util/MigrationUtil.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/transaction/invoicing/InvoiceService.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/user/RetailerServiceImpl.java
37067 12 d 3 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/ Fix null state code on FOFO partner-to-customer sale-return credit note: populate partner/customer address state codes via StateRepository lookup (were unset)  
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
36958 22 d 8 h amit /trunk/profitmandi-dao/src/main/ Flagship credit: fire interest-free limits at billing + per-IMEI conversion

- createLoanForBilling now detects flagship lines inside the billing transaction (fixes the
REQUIRES_NEW visibility bug where flagship detection re-queried uncommitted invoice_number and
never fired). Creates one combined flagship limit (is_flagship=1, limit_block=1, 30-day deadline)
plus one transaction.loan_imei row per device.
- convertFlagshipOnSale / IMEI activation now convert only the sold device's slice (matched by IMEI),
so same-model siblings and other billing tranches keep their interest-free window; full convert at
30-day expiry. Lock order aligned (loan -> loan_imei) to avoid sale/expiry deadlock.
- New transaction.loan_imei table + LoanImei entity/repository (migration_loan_imei_table.sql).
- selectAllLoansByInvoice: PurchaseReturn now settles BOTH the real loan and the flagship limit on a
flagship-invoice return (prevents credit leak from a stranded limit).
- Cap guard (flagship credit never exceeds amount drawn) and robust limit settlement (paisa threshold
instead of exact float equality).
 
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/entity/transaction/LoanImei.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/transaction/LoanImeiRepository.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/transaction/LoanImeiRepositoryImpl.java
/trunk/profitmandi-dao/src/main/resources/sql/migration_loan_imei_table.sql
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/transaction/LoanRepository.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/transaction/LoanRepositoryImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/inventory/InventoryServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/inventory/PurchaseReturnServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/transaction/SDCreditService.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/transaction/SDCreditServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/transaction/TransactionServiceImpl.java
36578 66 d 8 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/ Flagship credit: fix sale conversion to use invoice reference, add IMEI activation trigger

- Sale flow: removed unnecessary model_flagship table lookup at sale time. The flagship loan's invoice number already links to the purchase orders, making the date-based check redundant and incorrect (would miss conversions if flagship entry removed after billing).
- IMEI activation: added flagship conversion in addActivatedImeis() for newly activated serials. Groups by partner, checks flagship limits, converts via invoice matching. Covers Samsung/Vivo/Oppo/Realme activation crons and manual UI uploads.
- Repository: added date-parameterized selectActiveFlagshipCatalogIds(catalogIds, asOfDate) overload for future use. Existing method delegates with LocalDate.now().
 
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/catalog/ModelFlagshipRepository.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/catalog/ModelFlagshipRepositoryImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/inventory/InventoryServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/transaction/SDCreditService.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/transaction/SDCreditServiceImpl.java
36562 67 d 10 h amit /trunk/profitmandi-dao/src/main/ Flagship credit: date-wise model_flagship table, sale-time conversion with pessimistic locking, batch queries, extracted doConvertFlagshipToLoan helper, removed Catalog.isFlagship  
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/entity/catalog/ModelFlagship.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/catalog/ModelFlagshipRepository.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/catalog/ModelFlagshipRepositoryImpl.java
/trunk/profitmandi-dao/src/main/resources/sql/model_flagship_schema.sql
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/entity/catalog/Catalog.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/transaction/SDCreditService.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/transaction/SDCreditServiceImpl.java
36560 67 d 11 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/ Flagship credit: sale-time conversion with FOR UPDATE locking and performance optimizations

- convertFlagshipOnSale: partial conversion at billed price when retailer sells flagship stock
- hasActiveFlagshipLimits: cheap COUNT check to skip catalog lookup for non-flagship partners
- selectActiveFlagshipLimitBlocksForUpdate: pessimistic lock prevents double-conversion from concurrent sales/cron
- selectFlagshipLoansForConversion: added FOR UPDATE lock for cron expiry path
- Batch order fetch instead of per-limit queries
- Wired into OrderServiceImpl.createOrder after stock update
 
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/transaction/LoanRepository.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/transaction/LoanRepositoryImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/transaction/SDCreditService.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/transaction/SDCreditServiceImpl.java
36362 91 d 3 h amit /trunk/profitmandi-dao/src/main/ Make fofo_order creation idempotent on (fofo_id, invoice_number)

Fixes insert-intention gap-lock deadlocks on idx_invoice_number observed in
SHOW ENGINE INNODB STATUS at 2026-04-22 13:01:54 — two concurrent requests
inserting the same invoice_number for the same customer (client retry /
upstream webhook retry pattern).

- OrderServiceImpl.createAndGetFofoOrder: select-then-insert idempotency.
Fast path returns existing row if already created; slow-race path catches
DataIntegrityViolationException and re-selects the winner's row.
- add_uk_fofo_order_fofo_invoice.sql: adds UNIQUE KEY (fofo_id, invoice_number)
so the loser of a concurrent-insert race gets a clean DIVE instead of a
silent duplicate row (pre-check showed zero existing dup groups, safe).

findExistingFofoOrder wraps the repo call to swallow the repo's declared
ProfitMandiBusinessException — the impl actually returns null on not-found
(constructs an exception but never throws), so the swallow matches reality.
 
/trunk/profitmandi-dao/src/main/resources/sql/add_uk_fofo_order_fofo_invoice.sql
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
36305 94 d 15 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  
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/entity/transaction/CronBatch.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/entity/transaction/CronBatchItem.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/enumuration/transaction/CronBatchItemStatus.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/enumuration/transaction/CronBatchStatus.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/transaction/CronBatchItemRepository.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/transaction/CronBatchItemRepositoryImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/transaction/CronBatchRepository.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/transaction/CronBatchRepositoryImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/offers/OfferPartnerPayoutData.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/offers/SellinPartnerPayoutData.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/transaction/PartnerLimitUpdateData.java
/trunk/profitmandi-dao/src/main/resources/sql/create_cron_batch_tables.sql
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/config/CacheConfig.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/transaction/OrderRepositoryImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/PartnerInvestmentService.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/PartnerInvestmentServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/offers/OfferService.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/offers/OfferServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/transaction/TransactionServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/wallet/WalletServiceImpl.java
36126 112 d 10 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/ Change FOFO invoice PDF title from Retailer Invoice to Tax Invoice  
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
36093 117 d 3 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/ Remove WOD brand eligibility check from tertiary billing flow  
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
35896 143 d 1 h amit /trunk/profitmandi-dao/src/main/ Simplify partner GST: read/write from fofo_store.gst_number instead of Counter chain

- Set fofo_store.gst_number when store code is created/updated in RetailerServiceImpl
- Replace PrivateDealUser->Counter->gstin reads with FofoStore.getGstNumber() in:
RetailerServiceImpl, OrderServiceImpl, InvoiceService
- Remove unnecessary PrivateDealUser/Counter batch fetches in getFofoRetailers/getFofoRetailerUserId
- Add migration script to backfill existing GST from counter to fofo_store
 
/trunk/profitmandi-dao/src/main/resources/sql/migration_gst_to_fofo_store.sql
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/transaction/invoicing/InvoiceService.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/user/RetailerServiceImpl.java
35800 153 d 4 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/ Optimize credit note generation (bulk query), fix brand code NPE, add dealer code order validation, add @Profile guard on SolrStartupSync  
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/event/SolrStartupSync.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/transaction/CreditNoteRepository.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/transaction/CreditNoteRepositoryImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/catalog/BrandsServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/transaction/CreditNoteServiceImpl.java
35736 161 d 7 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/ Fix remaining coding issues in FOFO order creation

- Remove unused changedTotalBillAmount dead code
- Fix NPE when serializedInventoryItemMap returns null for an item
- Replace break-in-loop with iterator().next() in createAndGetFofoOrderItem
- Replace e.printStackTrace() with proper LOGGER.error()
- Log actual exception in state rate lookup instead of swallowing it
- Skip processScratchOffer when no smartphone in order
 
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
35733 161 d 8 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/ Fix noGST bug, remove dead price validation code, optimize live demo query in order creation

- noGST: compute once before loop with anyMatch instead of last-item-wins
- Remove pricingService.getPurchasePriceMopPriceNotFound call and empty validateDpPrice/validateMopPrice (disabled since 11 sep 2025)
- Replace selectAllSerialNumber full table load with targeted selectBySerialNumbers for order serials only
 
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
35695 163 d 11 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/ Perf: N+1 fix in FOFO OrderServiceImpl.createOrder - batch fetch live demo serials and collect FofoOrderItems during loop  
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/fofo/LiveDemoBillingRespository.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/fofo/LiveDemoBillingRespositoryImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
35493 210 d 0 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/ N+1 query optimization for B2B order creation flow

- OrderServiceImpl: Batch fetch PendingOrderItems before validation loop (line 402)
- OrderServiceImpl: Batch update opening stock using minusOpeningStockBatch
- OrderServiceImpl: Pre-fetch tagListings and GST rates before createAndGetFofoOrderItem loop
- OrderServiceImpl: Batch fetch PendingOrderItems for status update (line 719)
- CartServiceImpl: Pre-fetch items before getCartValidation loop
- SchemeServiceImpl: Batch fetch SchemeInOut records in processSchemeOut
- SmartCartService: Added minusOpeningStockBatch method for batch updates
- TagListingRepository: Added selectByItemIds batch method
- FofoOpeningStockRepository: Added findByFofoIdAndCatalogIds batch method
- PendingOrderItemRepository: Added selectByIds batch method

Performance improvement: ~70-100 DB queries reduced per order (10 items avg)
 
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/cart/CartServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/cart/SmartCartService.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/cart/SmartCartServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/catalog/TagListingRepository.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/catalog/TagListingRepositoryImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/fofo/FofoOpeningStockRepository.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/fofo/FofoOpeningStockRepositoryImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/fofo/PendingOrderItemRepository.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/fofo/PendingOrderItemRepositoryImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/scheme/SchemeServiceImpl.java
35236 268 d 5 h amit /trunk/ Fixed notification related issues with scheme also stopped using mongo for brands Schema  
/trunk/profitmandi-common/src/main/java/com/spice/profitmandi/common/services/mandii/MandiiService.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/dtr/Mongo.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/NotificationServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/scheme/SchemeServiceImpl.java
/trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/IndentController.java
/trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/PerformanceController.java
/trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/PlacementPlanController.java
/trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/RetailerController.java
35232 271 d 7 h ranu /trunk/ insurance can we add both same time  
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
/trunk/profitmandi-fofo/src/main/webapp/resources/js/create-order.js
/trunk/profitmandi-fofo/src/main/webapp/resources/js/order.js
35209 280 d 6 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/ Samsung Upgrade Logic Added  
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java
35156 286 d 10 h aman /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/ Fix:Customer gender null check  
/trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/order/OrderServiceImpl.java

Show All