| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.time.LocalDateTime;
|
3 |
import java.time.LocalDateTime;
|
| - |
|
4 |
import java.time.temporal.ChronoUnit;
|
| - |
|
5 |
import java.util.Arrays;
|
| - |
|
6 |
import java.util.HashMap;
|
| 4 |
import java.util.List;
|
7 |
import java.util.List;
|
| - |
|
8 |
import java.util.Map;
|
| 5 |
|
9 |
|
| 6 |
import javax.servlet.http.HttpServletRequest;
|
10 |
import javax.servlet.http.HttpServletRequest;
|
| 7 |
|
11 |
|
| - |
|
12 |
import org.apache.commons.collections.map.HashedMap;
|
| 8 |
import org.apache.logging.log4j.LogManager;
|
13 |
import org.apache.logging.log4j.LogManager;
|
| 9 |
import org.apache.logging.log4j.Logger;
|
14 |
import org.apache.logging.log4j.Logger;
|
| 10 |
import org.springframework.beans.factory.annotation.Autowired;
|
15 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 11 |
import org.springframework.beans.factory.annotation.Value;
|
16 |
import org.springframework.beans.factory.annotation.Value;
|
| 12 |
import org.springframework.scheduling.annotation.Scheduled;
|
17 |
import org.springframework.scheduling.annotation.Scheduled;
|
| Line 14... |
Line 19... |
| 14 |
import org.springframework.transaction.annotation.Transactional;
|
19 |
import org.springframework.transaction.annotation.Transactional;
|
| 15 |
import org.springframework.ui.Model;
|
20 |
import org.springframework.ui.Model;
|
| 16 |
import org.springframework.web.bind.annotation.RequestMapping;
|
21 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 17 |
import org.springframework.web.bind.annotation.RequestMethod;
|
22 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 18 |
|
23 |
|
| - |
|
24 |
import com.spice.profitmandi.common.enumuration.RechargeStatus;
|
| 19 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
25 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
| - |
|
26 |
import com.spice.profitmandi.common.model.RechargeCredential;
|
| 20 |
import com.spice.profitmandi.common.web.client.RestClient;
|
27 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| - |
|
28 |
import com.spice.profitmandi.dao.entity.dtr.RechargeTransaction;
|
| 21 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
29 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 22 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
30 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| 23 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
31 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
| 24 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
32 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| 25 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
33 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| Line 29... |
Line 37... |
| 29 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
37 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 30 |
|
38 |
|
| 31 |
@Controller
|
39 |
@Controller
|
| 32 |
@Transactional(rollbackFor=Throwable.class)
|
40 |
@Transactional(rollbackFor=Throwable.class)
|
| 33 |
public class CronController {
|
41 |
public class CronController {
|
| - |
|
42 |
|
| - |
|
43 |
@Value("${oxigen.recharge.enquiry.url}")
|
| - |
|
44 |
private String oxigenRechargeEnquiryUrl;
|
| - |
|
45 |
|
| - |
|
46 |
@Value("${oxigen.recharge.auth.key}")
|
| - |
|
47 |
private String oxigenRechargeAuthKey;
|
| - |
|
48 |
|
| - |
|
49 |
@Value("${oxigen.recharge.validation.url}")
|
| - |
|
50 |
private String oxigenRechargeValidationUrl;
|
| - |
|
51 |
|
| - |
|
52 |
@Value("${oxigen.recharge.validation.auth.key}")
|
| - |
|
53 |
private String oxigenRechargeValidationAuthKey;
|
| - |
|
54 |
|
| - |
|
55 |
@Value("${think.walnut.digital.recharge.transaction.mobile.url}")
|
| - |
|
56 |
private String thinkWalnutDigitalRechargeTransactionMobileUrl;
|
| - |
|
57 |
|
| - |
|
58 |
@Value("${think.walnut.digital.recharge.transaction.mobile.username}")
|
| - |
|
59 |
private String thinkWalnutDigitalRechargeTransactionMobileUserName;
|
| - |
|
60 |
|
| - |
|
61 |
@Value("${think.walnut.digital.recharge.transaction.mobile.password}")
|
| - |
|
62 |
private String thinkWalnutDigitalRechargeTransactionMobilePassword;
|
| - |
|
63 |
|
| - |
|
64 |
@Value("${think.walnut.digital.recharge.transaction.dth.url}")
|
| - |
|
65 |
private String thinkWalnutDigitalRechargeTransactionDthUrl;
|
| - |
|
66 |
|
| - |
|
67 |
@Value("${think.walnut.digital.recharge.transaction.dth.username}")
|
| - |
|
68 |
private String thinkWalnutDigitalRechargeTransactionDthUserName;
|
| - |
|
69 |
|
| - |
|
70 |
@Value("${think.walnut.digital.recharge.transaction.dth.password}")
|
| - |
|
71 |
private String thinkWalnutDigitalRechargeTransactionDthPassword;
|
| - |
|
72 |
|
| - |
|
73 |
@Value("${think.walnut.digital.recharge.enquiry.url}")
|
| - |
|
74 |
private String thinkWalnutDigitalRechargeEnquiryUrl;
|
| - |
|
75 |
|
| - |
|
76 |
@Value("${think.walnut.digital.recharge.enquiry.username}")
|
| - |
|
77 |
private String thinkWalnutDigitalRechargeEnquiryUserName;
|
| - |
|
78 |
|
| - |
|
79 |
@Value("${think.walnut.digital.recharge.enquiry.password}")
|
| - |
|
80 |
private String thinkWalnutDigitalRechargeEnquiryPassword;
|
| - |
|
81 |
|
| - |
|
82 |
@Value("${think.walnut.digital.recharge.auth.key}")
|
| - |
|
83 |
private String thinkWalnutDigitalRechargeAuthKey;
|
| 34 |
|
84 |
|
| 35 |
@Autowired
|
85 |
@Autowired
|
| 36 |
PurchaseRepository purchaseRepository;
|
86 |
PurchaseRepository purchaseRepository;
|
| 37 |
|
87 |
|
| 38 |
@Autowired
|
88 |
@Autowired
|
| Line 68... |
Line 118... |
| 68 |
String uri = "/cron/process-schemes";
|
118 |
String uri = "/cron/process-schemes";
|
| 69 |
restClient.get(SchemeType.HTTP, "localhost", 8080, uri, null);
|
119 |
restClient.get(SchemeType.HTTP, "localhost", 8080, uri, null);
|
| 70 |
}
|
120 |
}
|
| 71 |
}
|
121 |
}
|
| 72 |
|
122 |
|
| 73 |
/* @RequestMapping(value = "/cron/reconcile-recharge", method = RequestMethod.GET)
|
123 |
@RequestMapping(value = "/cron/reconcile-recharge", method = RequestMethod.GET)
|
| 74 |
public String reconcileRecharge() {
|
124 |
public String reconcileRecharge(Model model) throws Exception {
|
| 75 |
LocalDateTime fromDate = LocalDateTime.now().minusDays(18);
|
125 |
LocalDateTime fromDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS).minusDays(30);
|
| 76 |
LocalDateTime toDate = LocalDateTime.now();
|
126 |
LocalDateTime toDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);
|
| 77 |
RechargeTransaction rt = new RechargeTransaction();
|
127 |
RechargeTransaction rt = new RechargeTransaction();
|
| - |
|
128 |
List<RechargeStatus> nonSuccessRechargeStatuses = Arrays.asList(RechargeStatus.values());
|
| - |
|
129 |
nonSuccessRechargeStatuses.remove(RechargeStatus.SUCCESS);
|
| - |
|
130 |
nonSuccessRechargeStatuses.remove(RechargeStatus.FAILED);
|
| - |
|
131 |
RechargeCredential thinkWalnutDigitalRechargeEnquiryCredential = new RechargeCredential();
|
| - |
|
132 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeUrl(thinkWalnutDigitalRechargeEnquiryUrl);
|
| - |
|
133 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeUserName(thinkWalnutDigitalRechargeEnquiryUserName);
|
| - |
|
134 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargePassword(thinkWalnutDigitalRechargeEnquiryPassword);
|
| - |
|
135 |
thinkWalnutDigitalRechargeEnquiryCredential.setRechargeAuthKey(thinkWalnutDigitalRechargeAuthKey);
|
| - |
|
136 |
Map<String, RechargeStatus> requestRechargeStatusChanged = new HashMap<>();
|
| 78 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository.selectAllBetweenTimestamp(fromDate, toDate);
|
137 |
List<RechargeTransaction> rechargeTransactions = rechargeTransactionRepository.selectAllBetweenTimestamp(nonSuccessRechargeStatuses,fromDate, toDate);
|
| 79 |
for(RechargeTransaction rechargeTransaction : rechargeTransactions) {
|
138 |
for(RechargeTransaction rechargeTransaction : rechargeTransactions) {
|
| 80 |
int providerId = rechargeTransaction.getProviderId();
|
139 |
int providerId = rechargeTransaction.getProviderId();
|
| 81 |
if(providerId==1) {
|
140 |
if(providerId==1) {
|
| 82 |
oxigenRechargeProviderService.doCheckStatusRequest(rechargeTransaction)
|
141 |
oxigenRechargeProviderService.doCheckStatusRequest(oxigenRechargeEnquiryUrl, oxigenRechargeAuthKey, rechargeTransaction);
|
| - |
|
142 |
} else if(providerId==2) {
|
| - |
|
143 |
thinkWalnutDigitalRechargeProviderService.doCheckStatusRequest(thinkWalnutDigitalRechargeEnquiryCredential, rechargeTransaction);
|
| - |
|
144 |
}
|
| - |
|
145 |
if(rechargeTransaction.getStatus().equals(RechargeStatus.SUCCESS) || rechargeTransaction.getStatus().equals(RechargeStatus.FAILED)) {
|
| - |
|
146 |
requestRechargeStatusChanged.put(rechargeTransaction.getRequestId(), rechargeTransaction.getStatus());
|
| 83 |
}
|
147 |
}
|
| 84 |
}
|
148 |
}
|
| - |
|
149 |
model.addAttribute("response", mvcResponseSender.createResponseString(requestRechargeStatusChanged));
|
| - |
|
150 |
return "response";
|
| 85 |
}*/
|
151 |
}
|
| 86 |
|
152 |
|
| 87 |
@RequestMapping(value = "/cron/process-schemes", method = RequestMethod.GET)
|
153 |
@RequestMapping(value = "/cron/process-schemes", method = RequestMethod.GET)
|
| 88 |
public String createScheme(HttpServletRequest request, Model model) throws Exception {
|
154 |
public String createScheme(HttpServletRequest request, Model model) throws Exception {
|
| 89 |
LocalDateTime fromDate = LocalDateTime.now().minusDays(15);
|
155 |
LocalDateTime fromDate = LocalDateTime.now().minusDays(15);
|
| 90 |
LOGGER.info("Started execution at {}", LocalDateTime.now());
|
156 |
LOGGER.info("Started execution at {}", LocalDateTime.now());
|