| Line 12... |
Line 12... |
| 12 |
import java.util.List;
|
12 |
import java.util.List;
|
| 13 |
import java.util.Map;
|
13 |
import java.util.Map;
|
| 14 |
import java.util.Set;
|
14 |
import java.util.Set;
|
| 15 |
import java.util.stream.Collectors;
|
15 |
import java.util.stream.Collectors;
|
| 16 |
|
16 |
|
| - |
|
17 |
import javax.mail.internet.InternetAddress;
|
| - |
|
18 |
import javax.mail.internet.MimeMessage;
|
| 17 |
import javax.servlet.http.HttpServletRequest;
|
19 |
import javax.servlet.http.HttpServletRequest;
|
| 18 |
|
20 |
|
| 19 |
import org.apache.http.client.ClientProtocolException;
|
21 |
import org.apache.http.client.ClientProtocolException;
|
| 20 |
import org.apache.logging.log4j.LogManager;
|
22 |
import org.apache.logging.log4j.LogManager;
|
| 21 |
import org.apache.logging.log4j.Logger;
|
23 |
import org.apache.logging.log4j.Logger;
|
| 22 |
import org.springframework.beans.factory.annotation.Autowired;
|
24 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23 |
import org.springframework.beans.factory.annotation.Value;
|
25 |
import org.springframework.beans.factory.annotation.Value;
|
| 24 |
import org.springframework.http.MediaType;
|
26 |
import org.springframework.http.MediaType;
|
| 25 |
import org.springframework.http.ResponseEntity;
|
27 |
import org.springframework.http.ResponseEntity;
|
| - |
|
28 |
import org.springframework.mail.javamail.JavaMailSender;
|
| - |
|
29 |
import org.springframework.mail.javamail.MimeMessageHelper;
|
| 26 |
import org.springframework.stereotype.Controller;
|
30 |
import org.springframework.stereotype.Controller;
|
| 27 |
import org.springframework.transaction.annotation.Transactional;
|
31 |
import org.springframework.transaction.annotation.Transactional;
|
| 28 |
import org.springframework.web.bind.annotation.PathVariable;
|
32 |
import org.springframework.web.bind.annotation.PathVariable;
|
| 29 |
import org.springframework.web.bind.annotation.RequestBody;
|
33 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 30 |
import org.springframework.web.bind.annotation.RequestMapping;
|
34 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| Line 153... |
Line 157... |
| 153 |
@Autowired
|
157 |
@Autowired
|
| 154 |
private RoleRepository roleRepository;
|
158 |
private RoleRepository roleRepository;
|
| 155 |
|
159 |
|
| 156 |
@Autowired
|
160 |
@Autowired
|
| 157 |
private AuthRepository authRepository;
|
161 |
private AuthRepository authRepository;
|
| 158 |
|
162 |
|
| 159 |
@Autowired
|
163 |
@Autowired
|
| 160 |
private ObjectMapper objectMapper;
|
164 |
private ObjectMapper objectMapper;
|
| 161 |
|
- |
|
| 162 |
|
165 |
|
| 163 |
@Autowired
|
166 |
@Autowired
|
| 164 |
private RetailerService retailerService;
|
167 |
private RetailerService retailerService;
|
| 165 |
|
168 |
|
| 166 |
@Autowired
|
169 |
@Autowired
|
| 167 |
private RefferalRepository refferalRepository;
|
170 |
private RefferalRepository refferalRepository;
|
| 168 |
|
171 |
|
| 169 |
@Autowired
|
172 |
@Autowired
|
| 170 |
private PromoterRepository promoterRepository;
|
173 |
private PromoterRepository promoterRepository;
|
| 171 |
|
174 |
|
| - |
|
175 |
@Autowired
|
| - |
|
176 |
JavaMailSender mailSender;
|
| - |
|
177 |
|
| 172 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_GOOGLE_LOGIN, method = RequestMethod.POST)
|
178 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_GOOGLE_LOGIN, method = RequestMethod.POST)
|
| 173 |
public ResponseEntity<?> googleLogin(HttpServletRequest request, @RequestBody GoogleLoginRequest googleLoginRequest)
|
179 |
public ResponseEntity<?> googleLogin(HttpServletRequest request, @RequestBody GoogleLoginRequest googleLoginRequest)
|
| 174 |
throws ProfitMandiBusinessException {
|
180 |
throws ProfitMandiBusinessException {
|
| 175 |
return responseSender.ok(googleLoginProcessor.process(googleLoginRequest.getToken()));
|
181 |
return responseSender.ok(googleLoginProcessor.process(googleLoginRequest.getToken()));
|
| 176 |
}
|
182 |
}
|
| Line 497... |
Line 503... |
| 497 |
|
503 |
|
| 498 |
List<MobileAppSettingsWrapper> mobileSettingsWrappersList = mobileAppSettings.stream()
|
504 |
List<MobileAppSettingsWrapper> mobileSettingsWrappersList = mobileAppSettings.stream()
|
| 499 |
.map(x -> new MobileAppSettingsWrapper(x)).collect(Collectors.toList());
|
505 |
.map(x -> new MobileAppSettingsWrapper(x)).collect(Collectors.toList());
|
| 500 |
SettingsWrapper wrapper = new SettingsWrapper(mobileSettingsWrappersList);
|
506 |
SettingsWrapper wrapper = new SettingsWrapper(mobileSettingsWrappersList);
|
| 501 |
|
507 |
|
| - |
|
508 |
/*
|
| 502 |
/*LOGGER.info("Wrapper {}", wrapper);
|
509 |
* LOGGER.info("Wrapper {}", wrapper); return responseSender.ok(wrapper);
|
| 503 |
return responseSender.ok(wrapper);*/
|
510 |
*/
|
| 504 |
final String uri = "http://192.168.158.89/mobileappsettings?t=" + timestamp + "&imeinumber=" + imeinumber;
|
511 |
final String uri = "http://192.168.158.89/mobileappsettings?t=" + timestamp + "&imeinumber=" + imeinumber;
|
| 505 |
final String BASIC_AUTH = "Basic " + Base64.getEncoder().encodeToString("dtr:dtr18Feb2015".getBytes());
|
512 |
final String BASIC_AUTH = "Basic " + Base64.getEncoder().encodeToString("dtr:dtr18Feb2015".getBytes());
|
| 506 |
Map<String, String> headers = new HashMap<>();
|
513 |
Map<String, String> headers = new HashMap<>();
|
| 507 |
Map<String, String> params = new HashMap<>();
|
514 |
Map<String, String> params = new HashMap<>();
|
| 508 |
headers.put("Authorization", BASIC_AUTH);
|
515 |
headers.put("Authorization", BASIC_AUTH);
|
| 509 |
headers.put("Authorization", BASIC_AUTH);
|
516 |
headers.put("Authorization", BASIC_AUTH);
|
| 510 |
return responseSender.ok(restClient.post(uri, params, headers));
|
517 |
return responseSender.ok(restClient.post(uri, params, headers));
|
| 511 |
}
|
518 |
}
|
| 512 |
|
519 |
|
| 513 |
@RequestMapping(value = "/mobileappsettings1", method = RequestMethod.POST)
|
520 |
@RequestMapping(value = "/mobileappsettings1", method = RequestMethod.POST)
|
| 514 |
public ResponseEntity<?> mobileAppSettings1(HttpServletRequest request, @RequestParam(name = "t") int timestamp,
|
521 |
public ResponseEntity<?> mobileAppSettings1(HttpServletRequest request, @RequestParam(name = "t") int timestamp,
|
| 515 |
@RequestParam(name = "imeinumber") String imeinumber)
|
522 |
@RequestParam(name = "imeinumber") String imeinumber)
|
| 516 |
throws ProfitMandiBusinessException, ClientProtocolException, IOException {
|
523 |
throws ProfitMandiBusinessException, ClientProtocolException, IOException {
|
| 517 |
LocalDateTime settingsLastUpdated = LocalDateTime.ofEpochSecond(timestamp, 0, ZoneOffset.ofHoursMinutes(5, 30));
|
524 |
LocalDateTime settingsLastUpdated = LocalDateTime.ofEpochSecond(timestamp, 0, ZoneOffset.ofHoursMinutes(5, 30));
|
| 518 |
List<MobileAppSetting> mobileAppSettings = mobileAppSettingsRepository.getSettingAftera(settingsLastUpdated);
|
525 |
List<MobileAppSetting> mobileAppSettings = mobileAppSettingsRepository.getSettingAftera(settingsLastUpdated);
|
| 519 |
|
526 |
|
| 520 |
List<MobileAppSettingsWrapper> mobileSettingsWrappersList = mobileAppSettings.stream()
|
527 |
List<MobileAppSettingsWrapper> mobileSettingsWrappersList = mobileAppSettings.stream()
|
| 521 |
.map(x -> new MobileAppSettingsWrapper(x)).collect(Collectors.toList());
|
528 |
.map(x -> new MobileAppSettingsWrapper(x)).collect(Collectors.toList());
|
| 522 |
SettingsWrapper wrapper = new SettingsWrapper(mobileSettingsWrappersList);
|
529 |
SettingsWrapper wrapper = new SettingsWrapper(mobileSettingsWrappersList);
|
| 523 |
|
530 |
|
| 524 |
LOGGER.info("Wrapper {}", wrapper);
|
531 |
LOGGER.info("Wrapper {}", wrapper);
|
| 525 |
return responseSender.ok(objectMapper.writeValueAsString(wrapper));
|
532 |
return responseSender.ok(objectMapper.writeValueAsString(wrapper));
|
| 526 |
}
|
533 |
}
|
| 527 |
|
534 |
|
| 528 |
@RequestMapping(value = "/getPartners", method = RequestMethod.GET)
|
535 |
@RequestMapping(value = "/getPartners", method = RequestMethod.GET)
|
| Line 592... |
Line 599... |
| 592 |
refferal.setRefereeEmail(user.getEmailId());
|
599 |
refferal.setRefereeEmail(user.getEmailId());
|
| 593 |
refferal.setRefereeMobile(user.getMobileNumber());
|
600 |
refferal.setRefereeMobile(user.getMobileNumber());
|
| 594 |
}
|
601 |
}
|
| 595 |
|
602 |
|
| 596 |
refferalRepository.persist(refferal);
|
603 |
refferalRepository.persist(refferal);
|
| - |
|
604 |
String subject = "Referral Validate Request for " + refferal.getRefereeEmail();
|
| - |
|
605 |
String messageText = this.getMessageForReferral(refferal);
|
| - |
|
606 |
MimeMessage message = mailSender.createMimeMessage();
|
| - |
|
607 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
| - |
|
608 |
String[] email = { "kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com" };
|
| - |
|
609 |
helper.setSubject(subject);
|
| - |
|
610 |
helper.setText(messageText, true);
|
| - |
|
611 |
helper.setTo(email);
|
| - |
|
612 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smartdukaan Alerts");
|
| - |
|
613 |
helper.setFrom(senderAddress);
|
| - |
|
614 |
mailSender.send(message);
|
| - |
|
615 |
|
| 597 |
return responseSender.ok(true);
|
616 |
return responseSender.ok(true);
|
| 598 |
}
|
617 |
}
|
| 599 |
|
618 |
|
| - |
|
619 |
private String getMessageForReferral(Refferal referral) {
|
| - |
|
620 |
|
| - |
|
621 |
StringBuilder sb = new StringBuilder();
|
| - |
|
622 |
sb.append("<html><body><p>Alert</p><p> Referral Requests:-</p>"
|
| - |
|
623 |
+ "<br/><table style='border:1px solid black ;padding: 5px';>");
|
| - |
|
624 |
sb.append("<tbody>\n" + " <tr>\n"
|
| - |
|
625 |
+ " <th style='border:1px solid black;padding: 5px'>RefereeName</th>\n"
|
| - |
|
626 |
+ " <th style='border:1px solid black;padding: 5px'>Referee Email</th>\n"
|
| - |
|
627 |
+ " <th style='border:1px solid black;padding: 5px'>Referral Name</th>\n"
|
| - |
|
628 |
+ " <th style='border:1px solid black;padding: 5px'>Refferal Mobile</th>\n"
|
| - |
|
629 |
+ " <th style='border:1px solid black;padding: 5px'>city</th>\n"
|
| - |
|
630 |
+ " <th style='border:1px solid black;padding: 5px'>state</th>\n"
|
| - |
|
631 |
+ " </tr>");
|
| - |
|
632 |
|
| - |
|
633 |
sb.append("<tr>");
|
| - |
|
634 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + referral.getRefereeName() + "</td>");
|
| - |
|
635 |
|
| - |
|
636 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + referral.getRefereeEmail() + "</td>");
|
| - |
|
637 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + referral.getFirstName() + "</td>");
|
| - |
|
638 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + referral.getMobile() + "</td>");
|
| - |
|
639 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + referral.getCity() + "</td>");
|
| - |
|
640 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + referral.getState() + "</td>");
|
| - |
|
641 |
|
| - |
|
642 |
sb.append("</tr>");
|
| - |
|
643 |
|
| - |
|
644 |
sb.append("</tbody></table></body></html>");
|
| - |
|
645 |
|
| - |
|
646 |
return sb.toString();
|
| - |
|
647 |
}
|
| - |
|
648 |
|
| 600 |
@RequestMapping(value = "/user/refferalAmount", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
649 |
@RequestMapping(value = "/user/refferalAmount", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 601 |
@ApiImplicitParams({
|
650 |
@ApiImplicitParams({
|
| 602 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
651 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 603 |
public ResponseEntity<?> RefferalAmount(HttpServletRequest request, @RequestParam String refereeEmail)
|
652 |
public ResponseEntity<?> RefferalAmount(HttpServletRequest request, @RequestParam String refereeEmail)
|
| 604 |
throws Exception {
|
653 |
throws Exception {
|