コード例 #1
0
 //	@Scheduled(cron = "0 0/1 * 1/1 * ?")	 //Call every one minutes
 @Scheduled(cron = "	0 0 12 1/1 * ? ") // Call at midnight every day
 @Transactional
 public void deactivateStoresWithNoSalesActivity() {
   // GET Those stoes with status=active and no sales activity for n months & email-notification
   // has been sent & crosses n-months after email is sent are deactiated.
   logger.info("Fetching all stores needed deactivation on " + DateUtil.getCurrentDate());
   List<Store> storeWithNoSaleActivity = getStoresForDeactivation();
   // Deactivate each stores
   for (Store store : storeWithNoSaleActivity) {
     store.setStoreStatus(false);
     store.setDeactivatedDate(DateUtil.getCurrentDate());
   }
   // Update each of the store in db.
   logger.info("Deactivating stores.");
   storeDao.saveOrUpdateAll(storeWithNoSaleActivity);
 }
コード例 #2
0
  @PostConstruct
  // @Scheduled(cron = "0 0/1 * 1/1 * ?")	 //Call every one minutes
  @Scheduled(cron = "0 0 12 1/1 * ? ") // Call at midnight every day
  @Transactional
  public void sendEmailToInactiveStore() {
    synchronized (OnionSquareSchedulingServiceImpl.class) {
      logger.debug(
          "Job started at" + new Date() + " By the thread  " + Thread.currentThread().getName());
      // Find out all stores with no-sale activity for no-of-months since created.
      List<Store> inActiveStoreList = getInactiveStoresForEmailNotification();
      List<Store> storesReceivingEmail = new ArrayList<Store>();
      for (Store inActiveStore : inActiveStoreList) {
        // Get the store's email

        sendEmailNotification(inActiveStore.getSeller().getUsername(), "OnionSquare.com");
        inActiveStore.setEmailStatus(true);
        storesReceivingEmail.add(inActiveStore);
        // Send email to the stores
      }
      storeDao.saveOrUpdateAll(storesReceivingEmail);
      logger.debug(
          "Job Ended at" + new Date() + " By the thread  " + Thread.currentThread().getName());
    }
  }