| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
import java.io.IOException;
|
3 |
import java.io.IOException;
|
| 4 |
import java.time.LocalDate;
|
4 |
import java.time.LocalDate;
|
| 5 |
import java.time.LocalDateTime;
|
5 |
import java.time.LocalDateTime;
|
| 6 |
import java.time.YearMonth;
|
6 |
import java.time.YearMonth;
|
| - |
|
7 |
import java.time.ZoneOffset;
|
| 7 |
import java.util.ArrayList;
|
8 |
import java.util.ArrayList;
|
| 8 |
import java.util.Base64;
|
- |
|
| 9 |
import java.util.HashMap;
|
9 |
import java.util.HashMap;
|
| 10 |
import java.util.HashSet;
|
10 |
import java.util.HashSet;
|
| 11 |
import java.util.List;
|
11 |
import java.util.List;
|
| 12 |
import java.util.Map;
|
12 |
import java.util.Map;
|
| 13 |
import java.util.Set;
|
13 |
import java.util.Set;
|
| Line 28... |
Line 28... |
| 28 |
import org.springframework.web.bind.annotation.RequestBody;
|
28 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 29 |
import org.springframework.web.bind.annotation.RequestMapping;
|
29 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 30 |
import org.springframework.web.bind.annotation.RequestMethod;
|
30 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 31 |
import org.springframework.web.bind.annotation.RequestParam;
|
31 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 32 |
|
32 |
|
| - |
|
33 |
import com.fasterxml.jackson.annotation.JsonProperty;
|
| 33 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
34 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
| 34 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
35 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 35 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
36 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 36 |
import com.spice.profitmandi.common.model.GoogleLoginRequest;
|
37 |
import com.spice.profitmandi.common.model.GoogleLoginRequest;
|
| 37 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
38 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| Line 39... |
Line 40... |
| 39 |
import com.spice.profitmandi.common.model.UserInfo;
|
40 |
import com.spice.profitmandi.common.model.UserInfo;
|
| 40 |
import com.spice.profitmandi.common.util.JWTUtil;
|
41 |
import com.spice.profitmandi.common.util.JWTUtil;
|
| 41 |
import com.spice.profitmandi.common.web.client.RestClient;
|
42 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 42 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
43 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 43 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
44 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| - |
|
45 |
import com.spice.profitmandi.dao.entity.dtr.MobileAppSetting;
|
| 44 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
46 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
| 45 |
import com.spice.profitmandi.dao.entity.dtr.Role;
|
47 |
import com.spice.profitmandi.dao.entity.dtr.Role;
|
| 46 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
48 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
| 47 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
49 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
| 48 |
import com.spice.profitmandi.dao.entity.dtr.UserRole;
|
50 |
import com.spice.profitmandi.dao.entity.dtr.UserRole;
|
| Line 55... |
Line 57... |
| 55 |
import com.spice.profitmandi.dao.model.CreateRefferalRequest;
|
57 |
import com.spice.profitmandi.dao.model.CreateRefferalRequest;
|
| 56 |
import com.spice.profitmandi.dao.model.DateRangeModel;
|
58 |
import com.spice.profitmandi.dao.model.DateRangeModel;
|
| 57 |
import com.spice.profitmandi.dao.model.UserCart;
|
59 |
import com.spice.profitmandi.dao.model.UserCart;
|
| 58 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
60 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 59 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
61 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| - |
|
62 |
import com.spice.profitmandi.dao.repository.dtr.MobileAppSettingsRepository;
|
| 60 |
import com.spice.profitmandi.dao.repository.dtr.RefferalRepository;
|
63 |
import com.spice.profitmandi.dao.repository.dtr.RefferalRepository;
|
| 61 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
64 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
| 62 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
65 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
| 63 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
66 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 64 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
67 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
| Line 70... |
Line 73... |
| 70 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
73 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 71 |
import com.spice.profitmandi.service.user.RetailerService;
|
74 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 72 |
import com.spice.profitmandi.service.user.UserService;
|
75 |
import com.spice.profitmandi.service.user.UserService;
|
| 73 |
import com.spice.profitmandi.web.enumuration.UserStatus;
|
76 |
import com.spice.profitmandi.web.enumuration.UserStatus;
|
| 74 |
import com.spice.profitmandi.web.processor.GoogleLoginProcessor;
|
77 |
import com.spice.profitmandi.web.processor.GoogleLoginProcessor;
|
| 75 |
|
- |
|
| 76 |
import com.spice.profitmandi.web.req.RefferalEarning;
|
78 |
import com.spice.profitmandi.web.req.RefferalEarning;
|
| 77 |
import com.spice.profitmandi.web.req.RefferalEarningModel;
|
79 |
import com.spice.profitmandi.web.req.RefferalEarningModel;
|
| 78 |
import com.spice.profitmandi.web.req.UserRequest;
|
80 |
import com.spice.profitmandi.web.req.UserRequest;
|
| 79 |
import com.spice.profitmandi.web.res.Partner;
|
81 |
import com.spice.profitmandi.web.res.Partner;
|
| 80 |
|
82 |
|
| Line 95... |
Line 97... |
| 95 |
private static final Logger LOGGER = LogManager.getLogger(UserController.class);
|
97 |
private static final Logger LOGGER = LogManager.getLogger(UserController.class);
|
| 96 |
|
98 |
|
| 97 |
@Value("${notifications.api.host}")
|
99 |
@Value("${notifications.api.host}")
|
| 98 |
private String nodeHost;
|
100 |
private String nodeHost;
|
| 99 |
|
101 |
|
| - |
|
102 |
private MobileAppSettingsRepository mobileAppSettingsRepository;
|
| - |
|
103 |
|
| 100 |
@Value("${notifications.api.port}")
|
104 |
@Value("${notifications.api.port}")
|
| 101 |
private int nodePort;
|
105 |
private int nodePort;
|
| 102 |
|
106 |
|
| 103 |
@Value("${admin.token}")
|
107 |
@Value("${admin.token}")
|
| 104 |
private String validAdminToken;
|
108 |
private String validAdminToken;
|
| Line 160... |
Line 164... |
| 160 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_GOOGLE_LOGIN, method = RequestMethod.POST)
|
164 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_GOOGLE_LOGIN, method = RequestMethod.POST)
|
| 161 |
public ResponseEntity<?> googleLogin(HttpServletRequest request, @RequestBody GoogleLoginRequest googleLoginRequest)
|
165 |
public ResponseEntity<?> googleLogin(HttpServletRequest request, @RequestBody GoogleLoginRequest googleLoginRequest)
|
| 162 |
throws ProfitMandiBusinessException {
|
166 |
throws ProfitMandiBusinessException {
|
| 163 |
return responseSender.ok(googleLoginProcessor.process(googleLoginRequest.getToken()));
|
167 |
return responseSender.ok(googleLoginProcessor.process(googleLoginRequest.getToken()));
|
| 164 |
}
|
168 |
}
|
| - |
|
169 |
|
| 165 |
@RequestMapping(value = "/store/token/{storeCode}", method = RequestMethod.GET)
|
170 |
@RequestMapping(value = "/store/token/{storeCode}", method = RequestMethod.GET)
|
| 166 |
public ResponseEntity<?> googleLogin(HttpServletRequest request, @PathVariable String storeCode)
|
171 |
public ResponseEntity<?> googleLogin(HttpServletRequest request, @PathVariable String storeCode)
|
| 167 |
throws ProfitMandiBusinessException {
|
172 |
throws ProfitMandiBusinessException {
|
| 168 |
LOGGER.info("StoreCode {}", storeCode);
|
173 |
LOGGER.info("StoreCode {}", storeCode);
|
| 169 |
return responseSender.ok(googleLoginProcessor.processStore(storeCode));
|
174 |
return responseSender.ok(googleLoginProcessor.processStore(storeCode));
|
| Line 183... |
Line 188... |
| 183 |
Map<String, Object> responseMap = new HashMap<>();
|
188 |
Map<String, Object> responseMap = new HashMap<>();
|
| 184 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
189 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 185 |
User user = null;
|
190 |
User user = null;
|
| 186 |
if (userInfo.getUserId() > -1) {
|
191 |
if (userInfo.getUserId() > -1) {
|
| 187 |
user = userRepository.selectById(userInfo.getUserId());
|
192 |
user = userRepository.selectById(userInfo.getUserId());
|
| 188 |
|
193 |
|
| 189 |
String city = user.getCity();
|
194 |
String city = user.getCity();
|
| 190 |
if (!(userInfo.getEmail() == null || user.getEmailId().equalsIgnoreCase(userInfo.getEmail()))) {
|
195 |
if (!(userInfo.getEmail() == null || user.getEmailId().equalsIgnoreCase(userInfo.getEmail()))) {
|
| 191 |
String userName = null;
|
196 |
String userName = null;
|
| 192 |
if (user.getSecondryEmailId() != null && user.getSecondryEmailId().equals(userInfo.getEmail())) {
|
197 |
if (user.getSecondryEmailId() != null && user.getSecondryEmailId().equals(userInfo.getEmail())) {
|
| 193 |
userName = user.getFirstName() + " " + user.getLastName();
|
198 |
userName = user.getFirstName() + " " + user.getLastName();
|
| Line 477... |
Line 482... |
| 477 |
|
482 |
|
| 478 |
@RequestMapping(value = "/mobileappsettings", method = RequestMethod.POST)
|
483 |
@RequestMapping(value = "/mobileappsettings", method = RequestMethod.POST)
|
| 479 |
public ResponseEntity<?> mobileAppSettings(HttpServletRequest request, @RequestParam(name = "t") int timestamp,
|
484 |
public ResponseEntity<?> mobileAppSettings(HttpServletRequest request, @RequestParam(name = "t") int timestamp,
|
| 480 |
@RequestParam(name = "imeinumber") String imeinumber)
|
485 |
@RequestParam(name = "imeinumber") String imeinumber)
|
| 481 |
throws ProfitMandiBusinessException, ClientProtocolException, IOException {
|
486 |
throws ProfitMandiBusinessException, ClientProtocolException, IOException {
|
| - |
|
487 |
LocalDateTime settingsLastUpdated = LocalDateTime.ofEpochSecond(timestamp, 0, ZoneOffset.ofHoursMinutes(5, 30));
|
| - |
|
488 |
List<MobileAppSettingsWrapper> mobileAppSettings = mobileAppSettingsRepository
|
| - |
|
489 |
.getSettingAftera(settingsLastUpdated).stream().map(x -> new MobileAppSettingsWrapper(x))
|
| - |
|
490 |
.collect(Collectors.toList());
|
| - |
|
491 |
SettingsWrapper wrapper = new SettingsWrapper(mobileAppSettings);
|
| 482 |
|
492 |
/*
|
| 483 |
final String uri = "http://192.168.158.89/mobileappsettings?t=" + timestamp + "&imeinumber=" + imeinumber;
|
493 |
* final String uri = "http://192.168.158.89/mobileappsettings?t=" + timestamp +
|
| 484 |
final String BASIC_AUTH = "Basic " + Base64.getEncoder().encodeToString("dtr:dtr18Feb2015".getBytes());
|
494 |
* "&imeinumber=" + imeinumber; final String BASIC_AUTH = "Basic " +
|
| 485 |
Map<String, String> headers = new HashMap<>();
|
495 |
* Base64.getEncoder().encodeToString("dtr:dtr18Feb2015".getBytes());
|
| 486 |
Map<String, String> params = new HashMap<>();
|
496 |
* Map<String, String> headers = new HashMap<>(); Map<String, String> params =
|
| 487 |
headers.put("Authorization", BASIC_AUTH);
|
497 |
* new HashMap<>(); headers.put("Authorization", BASIC_AUTH);
|
| - |
|
498 |
*/
|
| 488 |
return responseSender.ok(restClient.post(uri, params, headers));
|
499 |
return responseSender.ok(wrapper);
|
| 489 |
}
|
500 |
}
|
| 490 |
|
501 |
|
| 491 |
@RequestMapping(value = "/getPartners", method = RequestMethod.GET)
|
502 |
@RequestMapping(value = "/getPartners", method = RequestMethod.GET)
|
| 492 |
@ApiImplicitParams({
|
503 |
@ApiImplicitParams({
|
| 493 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
504 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| Line 732... |
Line 743... |
| 732 |
int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
|
743 |
int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
|
| 733 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(retailerId, LocalDate.now());
|
744 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(retailerId, LocalDate.now());
|
| 734 |
|
745 |
|
| 735 |
return responseSender.ok(partnerType);
|
746 |
return responseSender.ok(partnerType);
|
| 736 |
}
|
747 |
}
|
| - |
|
748 |
|
| 737 |
}
|
749 |
}
|
| - |
|
750 |
|
| - |
|
751 |
class MobileAppSettingsWrapper {
|
| - |
|
752 |
@JsonProperty(value = "Mobileappsetting")
|
| - |
|
753 |
private MobileAppSetting mobileAppSettings;
|
| - |
|
754 |
|
| - |
|
755 |
public MobileAppSettingsWrapper(MobileAppSetting mobileAppSettings) {
|
| - |
|
756 |
super();
|
| - |
|
757 |
this.mobileAppSettings = mobileAppSettings;
|
| - |
|
758 |
}
|
| - |
|
759 |
}
|
| - |
|
760 |
|
| - |
|
761 |
class SettingsWrapper {
|
| - |
|
762 |
private List<MobileAppSettingsWrapper> settings;
|
| - |
|
763 |
|
| - |
|
764 |
public SettingsWrapper(List<MobileAppSettingsWrapper> settings) {
|
| - |
|
765 |
super();
|
| - |
|
766 |
this.settings = settings;
|
| - |
|
767 |
}
|
| - |
|
768 |
|
| - |
|
769 |
}
|
| 738 |
|
770 |
|