| Line 18... |
Line 18... |
| 18 |
import org.springframework.beans.factory.annotation.Value;
|
18 |
import org.springframework.beans.factory.annotation.Value;
|
| 19 |
import org.springframework.scheduling.annotation.Scheduled;
|
19 |
import org.springframework.scheduling.annotation.Scheduled;
|
| 20 |
import org.springframework.stereotype.Component;
|
20 |
import org.springframework.stereotype.Component;
|
| 21 |
import org.springframework.transaction.annotation.Transactional;
|
21 |
import org.springframework.transaction.annotation.Transactional;
|
| 22 |
import org.springframework.ui.Model;
|
22 |
import org.springframework.ui.Model;
|
| 23 |
import org.springframework.web.bind.annotation.RequestMapping;
|
- |
|
| 24 |
import org.springframework.web.bind.annotation.RequestMethod;
|
- |
|
| 25 |
|
23 |
|
| 26 |
import com.smartdukaan.cron.monitored.NagiosMonitorTasks;
|
24 |
import com.smartdukaan.cron.monitored.NagiosMonitorTasks;
|
| 27 |
import com.spice.profitmandi.common.enumuration.RechargeStatus;
|
25 |
import com.spice.profitmandi.common.enumuration.RechargeStatus;
|
| 28 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
- |
|
| 29 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
26 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
| 30 |
import com.spice.profitmandi.common.web.client.RestClient;
|
27 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 31 |
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
|
28 |
import com.spice.profitmandi.dao.entity.dtr.DailyRecharge;
|
| 32 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
29 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProvider;
|
| 33 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
|
30 |
import com.spice.profitmandi.dao.entity.dtr.RechargeProviderCreditWalletHistory;
|
| Line 109... |
Line 106... |
| 109 |
private RechargeProviderRepository rechargeProviderRepository;
|
106 |
private RechargeProviderRepository rechargeProviderRepository;
|
| 110 |
|
107 |
|
| 111 |
@Autowired
|
108 |
@Autowired
|
| 112 |
private DailyRechargeRepository dailyRechargeRepository;
|
109 |
private DailyRechargeRepository dailyRechargeRepository;
|
| 113 |
|
110 |
|
| 114 |
@Autowired
|
- |
|
| 115 |
private RestClient restClient;
|
- |
|
| 116 |
|
- |
|
| 117 |
@Value("${prod}")
|
111 |
@Value("${prod}")
|
| 118 |
private boolean prod;
|
112 |
private boolean prod;
|
| 119 |
|
113 |
|
| 120 |
private static final Logger LOGGER = LoggerFactory.getLogger(NagiosMonitorTasks.class);
|
114 |
private static final Logger LOGGER = LoggerFactory.getLogger(NagiosMonitorTasks.class);
|
| 121 |
|
115 |
|
| Line 190... |
Line 184... |
| 190 |
});
|
184 |
});
|
| 191 |
LOGGER.info("executio");
|
185 |
LOGGER.info("executio");
|
| 192 |
}
|
186 |
}
|
| 193 |
|
187 |
|
| 194 |
@Scheduled(cron = "0 45 * * * *")
|
188 |
@Scheduled(cron = "0 45 * * * *")
|
| 195 |
public String reconcileRecharge(Model model) throws Exception {
|
189 |
public void reconcileRecharge() throws Exception {
|
| 196 |
LocalDateTime fromDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS).minusDays(30);
|
190 |
LocalDateTime fromDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS).minusDays(30);
|
| 197 |
LocalDateTime toDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);
|
191 |
LocalDateTime toDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);
|
| 198 |
List<RechargeStatus> nonSuccessRechargeStatuses = new ArrayList<>(Arrays.asList(RechargeStatus.values()));
|
192 |
List<RechargeStatus> nonSuccessRechargeStatuses = new ArrayList<>(Arrays.asList(RechargeStatus.values()));
|
| 199 |
LOGGER.info("nonSuccessRechargeStatuses {} ", nonSuccessRechargeStatuses);
|
193 |
LOGGER.info("nonSuccessRechargeStatuses {} ", nonSuccessRechargeStatuses);
|
| 200 |
nonSuccessRechargeStatuses.remove(RechargeStatus.SUCCESS);
|
194 |
nonSuccessRechargeStatuses.remove(RechargeStatus.SUCCESS);
|
| Line 224... |
Line 218... |
| 224 |
}
|
218 |
}
|
| 225 |
} catch (Exception e) {
|
219 |
} catch (Exception e) {
|
| 226 |
LOGGER.info("Could not check status for Request {}", rechargeTransaction.getRequestId());
|
220 |
LOGGER.info("Could not check status for Request {}", rechargeTransaction.getRequestId());
|
| 227 |
}
|
221 |
}
|
| 228 |
}
|
222 |
}
|
| 229 |
return "response";
|
223 |
LOGGER.info("Reconcile recharge ran successfully");
|
| 230 |
}
|
224 |
}
|
| 231 |
|
225 |
|
| 232 |
@Scheduled(cron = "0 45 0 * * *")
|
226 |
@Scheduled(cron = "0 45 0 * * *")
|
| 233 |
public void processScheme(HttpServletRequest request, Model model) throws Exception {
|
227 |
public void processScheme() throws Exception {
|
| 234 |
LocalDateTime fromDate = LocalDateTime.now().minusDays(15);
|
228 |
LocalDateTime fromDate = LocalDateTime.now().minusDays(15);
|
| 235 |
LOGGER.info("Started execution at {}", LocalDateTime.now());
|
229 |
LOGGER.info("Started execution at {}", LocalDateTime.now());
|
| 236 |
List<Purchase> purchases = purchaseRepository.selectFromPurchaseCompleteDate(fromDate);
|
230 |
List<Purchase> purchases = purchaseRepository.selectFromPurchaseCompleteDate(fromDate);
|
| 237 |
for (Purchase purchase : purchases) {
|
231 |
for (Purchase purchase : purchases) {
|
| 238 |
try {
|
232 |
try {
|