Subversion Repositories SmartDukaan

Rev

Rev 37480 | Rev 37503 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37480 Rev 37499
Line 14... Line 14...
14
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
14
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
15
import com.spice.profitmandi.dao.repository.cs.CsService;
15
import com.spice.profitmandi.dao.repository.cs.CsService;
16
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
16
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
17
import com.spice.profitmandi.dao.service.shopify.ShopifyProductSyncService;
17
import com.spice.profitmandi.dao.service.shopify.ShopifyProductSyncService;
18
import com.spice.profitmandi.dao.util.ContentPojoPopulator;
18
import com.spice.profitmandi.dao.util.ContentPojoPopulator;
-
 
19
import com.spice.profitmandi.service.NotificationService;
-
 
20
import com.spice.profitmandi.service.integrations.icicilombard.IciciLombardService;
-
 
21
import com.spice.profitmandi.service.integrations.icicilombard.model.LastTransactionsResponseModel;
19
import com.spice.profitmandi.service.integrations.samsung.upgradeoffer.UpgradeOfferService;
22
import com.spice.profitmandi.service.integrations.samsung.upgradeoffer.UpgradeOfferService;
20
import com.spice.profitmandi.service.mail.MailOutboxService;
23
import com.spice.profitmandi.service.mail.MailOutboxService;
21
import org.apache.logging.log4j.LogManager;
24
import org.apache.logging.log4j.LogManager;
22
import org.apache.logging.log4j.Logger;
25
import org.apache.logging.log4j.Logger;
23
import org.apache.velocity.app.VelocityEngine;
26
import org.apache.velocity.app.VelocityEngine;
Line 95... Line 98...
95
    BatchScheduledTasks batchScheduledTasks;
98
    BatchScheduledTasks batchScheduledTasks;
96
 
99
 
97
    @Autowired
100
    @Autowired
98
    private BeatMissDetectorRunner beatMissDetectorRunner;
101
    private BeatMissDetectorRunner beatMissDetectorRunner;
99
 
102
 
-
 
103
    @Autowired
-
 
104
    private IciciLombardService iciciLombardService;
-
 
105
 
100
    public static void main(String[] args) throws Throwable {
106
    public static void main(String[] args) throws Throwable {
101
        try {
107
        try {
102
            WebApplicationType webType = WebApplicationType.SERVLET;
108
            WebApplicationType webType = WebApplicationType.SERVLET;
103
            for (String arg : args) {
109
            for (String arg : args) {
104
                if (arg.contains("spring.main.web-application-type=none")) {
110
                if (arg.contains("spring.main.web-application-type=none")) {
Line 277... Line 283...
277
    KnowlarityCallMonitorScheduler knowlarityCallMonitorScheduler;
283
    KnowlarityCallMonitorScheduler knowlarityCallMonitorScheduler;
278
 
284
 
279
    @Autowired
285
    @Autowired
280
    MailOutboxService mailOutboxService;
286
    MailOutboxService mailOutboxService;
281
 
287
 
-
 
288
    @Autowired
-
 
289
    NotificationService notificationService;
-
 
290
 
282
    @Override
291
    @Override
283
    public void run(ApplicationArguments args) throws Exception {
292
    public void run(ApplicationArguments args) throws Exception {
284
        //scheduledTasks.test();
293
        //scheduledTasks.test();
285
        //System.exit();
294
        //System.exit();
286
        LOGGER.info("Called run method");
295
        LOGGER.info("Called run method");
Line 396... Line 405...
396
        if (args.containsOption("et")) {
405
        if (args.containsOption("et")) {
397
            ticketRelatedScheduledTask.escalateTicket();
406
            ticketRelatedScheduledTask.escalateTicket();
398
            ;
407
            ;
399
            System.exit(0);
408
            System.exit(0);
400
        }
409
        }
-
 
410
        if (args.containsOption("iciciBalance")) {
-
 
411
            System.out.println("Fetching ICICI CD balance manually");
-
 
412
            try {
-
 
413
                LastTransactionsResponseModel response = iciciLombardService.getLastTwentyFiveTransactions(null);
-
 
414
                System.out.println("Response: " + response);
-
 
415
                if (response != null
-
 
416
                        && response.getTransactionsDetails() != null
-
 
417
                        && !response.getTransactionsDetails().isEmpty()) {
-
 
418
                    LastTransactionsResponseModel.TransactionDetail latest = response.getTransactionsDetails().get(0);
-
 
419
                    System.out.println("Current available balance = " + latest.getAvailableBalance()
-
 
420
                            + " (as of " + latest.getEffectiveDate() + " — status: " + latest.getStatus() + ")");
-
 
421
                    System.out.println("Last 25 transactions:");
-
 
422
                    response.getTransactionsDetails().forEach(t -> System.out.println("  " + t));
-
 
423
                }
-
 
424
            } catch (Exception e) {
-
 
425
                e.printStackTrace();
-
 
426
            }
-
 
427
            System.exit(0);
-
 
428
        }
401
        if (args.containsOption("sr")) {
429
        if (args.containsOption("sr")) {
402
            List<String> schemeIds = args.getOptionValues("schemeId");
430
            List<String> schemeIds = args.getOptionValues("schemeId");
403
            System.out.println(schemeIds);
431
            System.out.println(schemeIds);
404
            scheduledTasks.schemeRollback(schemeIds);
432
            scheduledTasks.schemeRollback(schemeIds);
405
            System.exit(0);
433
            System.exit(0);
Line 464... Line 492...
464
            System.out.println("Processing pending mails...");
492
            System.out.println("Processing pending mails...");
465
            mailOutboxService.processPendingMails();
493
            mailOutboxService.processPendingMails();
466
            System.exit(0);
494
            System.exit(0);
467
        }
495
        }
468
 
496
 
-
 
497
        // Dispatch any notification_schedule rows whose scheduled_timestamp <= now.
-
 
498
        // Same code path as the hourly cron in NotificationDispatchScheduler, but callable
-
 
499
        // on demand from dev / staging where the isProd gate normally blocks the cron.
-
 
500
        // Usage: --dispatchScheduledNotifications [--batch=200]
-
 
501
        if (args.containsOption("dispatchScheduledNotifications")) {
-
 
502
            int batch = 200;
-
 
503
            if (args.containsOption("batch")) {
-
 
504
                try { batch = Integer.parseInt(args.getOptionValues("batch").get(0)); }
-
 
505
                catch (Exception ignored) { }
-
 
506
            }
-
 
507
            System.out.println("Dispatching due scheduled notifications (batch=" + batch + ")...");
-
 
508
            int attempted = notificationService.dispatchDueScheduled(batch);
-
 
509
            System.out.println("Attempted: " + attempted + " row(s)");
-
 
510
            System.exit(0);
-
 
511
        }
-
 
512
 
469
        if (args.containsOption("ticketClosed")) {
513
        if (args.containsOption("ticketClosed")) {
470
            // Redirected to TicketRelatedScheduledTask which handles auto-close as part of escalateTicket
514
            // Redirected to TicketRelatedScheduledTask which handles auto-close as part of escalateTicket
471
            ticketRelatedScheduledTask.escalateTicket();
515
            ticketRelatedScheduledTask.escalateTicket();
472
            System.exit(0);
516
            System.exit(0);
473
        }
517
        }
Line 908... Line 952...
908
                scheduledTasks.rollOutUpgardedMargins(Arrays.asList(175140172, 175140189));
952
                scheduledTasks.rollOutUpgardedMargins(Arrays.asList(175140172, 175140189));
909
            }
953
            }
910
            if (args.containsOption("pushRbmTargets")) {
954
            if (args.containsOption("pushRbmTargets")) {
911
                scheduledTasks.persistRbmTodayTargets();
955
                scheduledTasks.persistRbmTodayTargets();
912
            }
956
            }
-
 
957
            if (args.containsOption("pushSalesTargets")) {
-
 
958
                // Run this AFTER pushRbmTargets so today's RBM snapshots exist to roll up.
-
 
959
                scheduledTasks.persistSalesTodayTargets();
-
 
960
            }
-
 
961
            if (args.containsOption("pushSalesTargetsForDate")) {
-
 
962
                // Backfill / seed for a specific date, e.g. --pushSalesTargetsForDate=2026-08-25
-
 
963
                LocalDate d = LocalDate.parse(args.getOptionValues("pushSalesTargetsForDate").get(0));
-
 
964
                scheduledTasks.persistSalesTargetsForDate(d);
-
 
965
            }
-
 
966
            if (args.containsOption("pushSalesAchievements")) {
-
 
967
                // Daily Sales achievement snapshot (audit/history). Independent
-
 
968
                // of pushSalesTargets — can run any time after orders settle.
-
 
969
                scheduledTasks.persistSalesTodayAchievements();
-
 
970
            }
-
 
971
            if (args.containsOption("pushSalesAchievementsForDate")) {
-
 
972
                // Backfill / seed for a specific date, e.g. --pushSalesAchievementsForDate=2026-08-25
-
 
973
                LocalDate d = LocalDate.parse(args.getOptionValues("pushSalesAchievementsForDate").get(0));
-
 
974
                scheduledTasks.persistSalesAchievementsForDate(d);
-
 
975
            }
913
            if (args.containsOption("rollOutUpgardedMarginsNextMonth")) {
976
            if (args.containsOption("rollOutUpgardedMarginsNextMonth")) {
914
                System.out.println("In rollOutUpgardedMarginsNextMonth");
977
                System.out.println("In rollOutUpgardedMarginsNextMonth");
915
                scheduledTasks.rollOutUpgardedMarginsNextMonth(Arrays.asList(175140172, 175140189, 175138897));
978
                scheduledTasks.rollOutUpgardedMarginsNextMonth(Arrays.asList(175140172, 175140189, 175138897));
916
            }
979
            }
917
            if (args.containsOption("checkCancellationMargin")) {
980
            if (args.containsOption("checkCancellationMargin")) {