| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
import java.time.LocalDateTime;
|
3 |
import java.time.LocalDateTime;
|
| 4 |
import java.util.List;
|
4 |
import java.util.List;
|
| 5 |
|
5 |
|
| 6 |
import javax.servlet.http.HttpServletRequest;
|
6 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
7 |
|
| 7 |
import org.apache.logging.log4j.LogManager;
|
8 |
import org.apache.logging.log4j.LogManager;
|
| 8 |
import org.apache.logging.log4j.Logger;
|
9 |
import org.apache.logging.log4j.Logger;
|
| 9 |
|
- |
|
| 10 |
|
- |
|
| 11 |
import org.springframework.beans.factory.annotation.Autowired;
|
10 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 12 |
import org.springframework.beans.factory.annotation.Value;
|
11 |
import org.springframework.beans.factory.annotation.Value;
|
| 13 |
import org.springframework.scheduling.annotation.Scheduled;
|
12 |
import org.springframework.scheduling.annotation.Scheduled;
|
| 14 |
import org.springframework.stereotype.Controller;
|
13 |
import org.springframework.stereotype.Controller;
|
| 15 |
import org.springframework.transaction.annotation.Transactional;
|
14 |
import org.springframework.transaction.annotation.Transactional;
|
| Line 19... |
Line 18... |
| 19 |
|
18 |
|
| 20 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
19 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
| 21 |
import com.spice.profitmandi.common.web.client.RestClient;
|
20 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 22 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
21 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 23 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
22 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| - |
|
23 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
| 24 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
24 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| 25 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
25 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| - |
|
26 |
import com.spice.profitmandi.service.recharge.provider.OxigenRechargeProviderService;
|
| - |
|
27 |
import com.spice.profitmandi.service.recharge.provider.ThinkWalnutDigitalRechargeProviderService;
|
| 26 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
28 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 27 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
29 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 28 |
|
30 |
|
| 29 |
@Controller
|
31 |
@Controller
|
| 30 |
@Transactional(rollbackFor=Throwable.class)
|
32 |
@Transactional(rollbackFor=Throwable.class)
|
| Line 35... |
Line 37... |
| 35 |
|
37 |
|
| 36 |
@Autowired
|
38 |
@Autowired
|
| 37 |
SchemeService schemeService;
|
39 |
SchemeService schemeService;
|
| 38 |
|
40 |
|
| 39 |
@Autowired
|
41 |
@Autowired
|
| - |
|
42 |
RechargeTransactionRepository rechargeTransactionRepository;
|
| - |
|
43 |
|
| - |
|
44 |
@Autowired
|
| 40 |
FofoOrderRepository fofoOrderRepository;
|
45 |
FofoOrderRepository fofoOrderRepository;
|
| 41 |
|
46 |
|
| 42 |
@Autowired
|
47 |
@Autowired
|
| - |
|
48 |
ThinkWalnutDigitalRechargeProviderService thinkWalnutDigitalRechargeProviderService;
|
| - |
|
49 |
|
| - |
|
50 |
@Autowired
|
| - |
|
51 |
OxigenRechargeProviderService oxigenRechargeProviderService;
|
| - |
|
52 |
|
| - |
|
53 |
@Autowired
|
| 43 |
private RestClient restClient;
|
54 |
private RestClient restClient;
|
| 44 |
|
55 |
|
| 45 |
@Autowired
|
56 |
@Autowired
|
| 46 |
private MVCResponseSender mvcResponseSender;
|
57 |
private MVCResponseSender mvcResponseSender;
|
| 47 |
|
58 |
|
| 48 |
@Value("${prod}")
|
59 |
@Value("${prod}")
|
| 49 |
private boolean prod;
|
60 |
private boolean prod;
|
| 50 |
|
61 |
|
| 51 |
|
62 |
|
| 52 |
private static final Logger LOGGER =LogManager.getLogger(CronController.class);
|
63 |
private static final Logger LOGGER = LogManager.getLogger(CronController.class);
|
| 53 |
|
64 |
|
| 54 |
@Scheduled(cron = "0 45 6 * * *")
|
65 |
@Scheduled(cron = "0 45 6 * * *")
|
| 55 |
public void executeJob() throws Exception {
|
66 |
public void executeJob() throws Exception {
|
| 56 |
if(prod) {
|
67 |
if(prod) {
|
| 57 |
String uri = "/cron/process-schemes";
|
68 |
String uri = "/cron/process-schemes";
|
| 58 |
restClient.get(SchemeType.HTTP, "localhost", 8080, uri, null);
|
69 |
restClient.get(SchemeType.HTTP, "localhost", 8080, uri, null);
|
| 59 |
}
|
70 |
}
|
| 60 |
}
|
71 |
}
|
| 61 |
|
72 |
|
| - |
|
73 |
/* @RequestMapping(value = "/cron/reconcile-recharge", method = RequestMethod.GET)
|
| - |
|
74 |
public String reconcileRecharge() {
|
| - |
|
75 |
LocalDateTime fromDate = LocalDateTime.now().minusDays(18);
|
| - |
|
76 |
LocalDateTime toDate = LocalDateTime.now();
|
| - |
|
77 |
RechargeTransaction rt = new RechargeTransaction();
|
| - |
|
78 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository.selectAllBetweenTimestamp(fromDate, toDate);
|
| - |
|
79 |
for(RechargeTransaction rechargeTransaction : rechargeTransactions) {
|
| - |
|
80 |
int providerId = rechargeTransaction.getProviderId();
|
| - |
|
81 |
if(providerId==1) {
|
| - |
|
82 |
oxigenRechargeProviderService.doCheckStatusRequest(rechargeTransaction)
|
| - |
|
83 |
}
|
| - |
|
84 |
}
|
| - |
|
85 |
}*/
|
| - |
|
86 |
|
| 62 |
@RequestMapping(value = "/cron/process-schemes", method = RequestMethod.GET)
|
87 |
@RequestMapping(value = "/cron/process-schemes", method = RequestMethod.GET)
|
| 63 |
public String createScheme(HttpServletRequest request, Model model) throws Exception {
|
88 |
public String createScheme(HttpServletRequest request, Model model) throws Exception {
|
| 64 |
LocalDateTime fromDate = LocalDateTime.now().minusDays(15);
|
89 |
LocalDateTime fromDate = LocalDateTime.now().minusDays(15);
|
| 65 |
LOGGER.info("Started execution at {}", LocalDateTime.now());
|
90 |
LOGGER.info("Started execution at {}", LocalDateTime.now());
|
| 66 |
List<Purchase> purchases = purchaseRepository.selectFromPurchaseCompleteDate(fromDate);
|
91 |
List<Purchase> purchases = purchaseRepository.selectFromPurchaseCompleteDate(fromDate);
|