| 21248 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 25300 |
tejbeer |
3 |
import java.io.IOException;
|
| 21248 |
ashik.ali |
4 |
import java.time.LocalDateTime;
|
| 21855 |
amit.gupta |
5 |
import java.util.ArrayList;
|
| 25366 |
tejbeer |
6 |
import java.util.Arrays;
|
| 25300 |
tejbeer |
7 |
import java.util.Base64;
|
| 21428 |
amit.gupta |
8 |
import java.util.HashMap;
|
| 23786 |
amit.gupta |
9 |
import java.util.HashSet;
|
| 21855 |
amit.gupta |
10 |
import java.util.List;
|
| 21277 |
ashik.ali |
11 |
import java.util.Map;
|
| 23786 |
amit.gupta |
12 |
import java.util.Set;
|
| 21248 |
ashik.ali |
13 |
|
|
|
14 |
import javax.servlet.http.HttpServletRequest;
|
|
|
15 |
|
| 25300 |
tejbeer |
16 |
import org.apache.http.client.ClientProtocolException;
|
| 23532 |
amit.gupta |
17 |
import org.apache.http.conn.HttpHostConnectException;
|
| 23786 |
amit.gupta |
18 |
import org.apache.logging.log4j.LogManager;
|
| 23859 |
ashik.ali |
19 |
import org.apache.logging.log4j.Logger;
|
| 21278 |
ashik.ali |
20 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 21414 |
kshitij.so |
21 |
import org.springframework.beans.factory.annotation.Value;
|
| 25366 |
tejbeer |
22 |
import org.springframework.http.MediaType;
|
| 21248 |
ashik.ali |
23 |
import org.springframework.http.ResponseEntity;
|
|
|
24 |
import org.springframework.stereotype.Controller;
|
| 21702 |
ashik.ali |
25 |
import org.springframework.transaction.annotation.Transactional;
|
| 21366 |
kshitij.so |
26 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 21248 |
ashik.ali |
27 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
28 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
29 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
30 |
|
| 22015 |
ashik.ali |
31 |
import com.eclipsesource.json.Json;
|
| 21855 |
amit.gupta |
32 |
import com.eclipsesource.json.JsonArray;
|
|
|
33 |
import com.eclipsesource.json.JsonObject;
|
|
|
34 |
import com.eclipsesource.json.JsonValue;
|
|
|
35 |
import com.google.gson.Gson;
|
| 21248 |
ashik.ali |
36 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
| 21855 |
amit.gupta |
37 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
| 21248 |
ashik.ali |
38 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 25366 |
tejbeer |
39 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 22930 |
ashik.ali |
40 |
import com.spice.profitmandi.common.model.GoogleLoginRequest;
|
| 21248 |
ashik.ali |
41 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 22492 |
amit.gupta |
42 |
import com.spice.profitmandi.common.model.RegisteredUserInfo;
|
| 21469 |
amit.gupta |
43 |
import com.spice.profitmandi.common.model.UserInfo;
|
| 21282 |
ashik.ali |
44 |
import com.spice.profitmandi.common.util.JWTUtil;
|
| 21855 |
amit.gupta |
45 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 21740 |
ashik.ali |
46 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 25366 |
tejbeer |
47 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 21735 |
ashik.ali |
48 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
| 23858 |
ashik.ali |
49 |
import com.spice.profitmandi.dao.entity.dtr.Role;
|
| 21735 |
ashik.ali |
50 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
| 25366 |
tejbeer |
51 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
| 21735 |
ashik.ali |
52 |
import com.spice.profitmandi.dao.entity.dtr.UserRole;
|
| 22355 |
ashik.ali |
53 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 25458 |
tejbeer |
54 |
import com.spice.profitmandi.dao.entity.user.Promoter;
|
|
|
55 |
import com.spice.profitmandi.dao.entity.user.Refferal;
|
| 21735 |
ashik.ali |
56 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| 21643 |
ashik.ali |
57 |
import com.spice.profitmandi.dao.model.UserCart;
|
| 25366 |
tejbeer |
58 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 25458 |
tejbeer |
59 |
import com.spice.profitmandi.dao.repository.dtr.RefferalRepository;
|
| 21735 |
ashik.ali |
60 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
| 23786 |
amit.gupta |
61 |
import com.spice.profitmandi.dao.repository.dtr.RoleRepository;
|
| 21735 |
ashik.ali |
62 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
|
|
63 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
|
|
64 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
| 22355 |
ashik.ali |
65 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 25458 |
tejbeer |
66 |
import com.spice.profitmandi.dao.repository.user.PromoterRepository;
|
| 24491 |
amit.gupta |
67 |
import com.spice.profitmandi.service.AuthService;
|
| 23798 |
amit.gupta |
68 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 25366 |
tejbeer |
69 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 23787 |
amit.gupta |
70 |
import com.spice.profitmandi.service.user.UserService;
|
| 21469 |
amit.gupta |
71 |
import com.spice.profitmandi.web.enumuration.UserStatus;
|
| 21277 |
ashik.ali |
72 |
import com.spice.profitmandi.web.processor.GoogleLoginProcessor;
|
| 25458 |
tejbeer |
73 |
import com.spice.profitmandi.web.req.CreateAddMoneyRequest;
|
|
|
74 |
import com.spice.profitmandi.web.req.CreateRefferalRequest;
|
| 21366 |
kshitij.so |
75 |
import com.spice.profitmandi.web.req.UserRequest;
|
| 21855 |
amit.gupta |
76 |
import com.spice.profitmandi.web.res.Notification;
|
| 25366 |
tejbeer |
77 |
import com.spice.profitmandi.web.res.Partner;
|
| 21248 |
ashik.ali |
78 |
|
| 21469 |
amit.gupta |
79 |
import io.swagger.annotations.ApiImplicitParam;
|
|
|
80 |
import io.swagger.annotations.ApiImplicitParams;
|
|
|
81 |
|
| 21248 |
ashik.ali |
82 |
/**
|
|
|
83 |
* @author ashikali
|
|
|
84 |
*
|
|
|
85 |
*/
|
|
|
86 |
@Controller
|
| 25366 |
tejbeer |
87 |
@Transactional(rollbackFor = Throwable.class)
|
| 21248 |
ashik.ali |
88 |
public class UserController {
|
| 21469 |
amit.gupta |
89 |
|
| 21448 |
ashik.ali |
90 |
@Autowired
|
| 22930 |
ashik.ali |
91 |
private ResponseSender<?> responseSender;
|
| 21469 |
amit.gupta |
92 |
|
| 23568 |
govind |
93 |
private static final Logger LOGGER = LogManager.getLogger(UserController.class);
|
| 21469 |
amit.gupta |
94 |
|
| 21855 |
amit.gupta |
95 |
@Value("${notifications.api.host}")
|
|
|
96 |
private String nodeHost;
|
| 25366 |
tejbeer |
97 |
|
| 21855 |
amit.gupta |
98 |
@Value("${notifications.api.port}")
|
|
|
99 |
private int nodePort;
|
|
|
100 |
|
| 21414 |
kshitij.so |
101 |
@Value("${admin.token}")
|
|
|
102 |
private String validAdminToken;
|
| 21469 |
amit.gupta |
103 |
|
| 21278 |
ashik.ali |
104 |
@Autowired
|
| 22873 |
ashik.ali |
105 |
private UserRepository userRepository;
|
| 25366 |
tejbeer |
106 |
|
| 22355 |
ashik.ali |
107 |
@Autowired
|
| 22873 |
ashik.ali |
108 |
private com.spice.profitmandi.dao.repository.user.UserRepository userUserRepository;
|
| 21469 |
amit.gupta |
109 |
|
| 21278 |
ashik.ali |
110 |
@Autowired
|
| 22873 |
ashik.ali |
111 |
private RetailerRepository retailerRepository;
|
| 21485 |
amit.gupta |
112 |
|
|
|
113 |
@Autowired
|
| 22873 |
ashik.ali |
114 |
private UserRoleRepository userRoleRepository;
|
| 21469 |
amit.gupta |
115 |
|
| 21426 |
ashik.ali |
116 |
@Autowired
|
| 22873 |
ashik.ali |
117 |
private UserAccountRepository userAccountRepository;
|
| 25366 |
tejbeer |
118 |
|
| 22355 |
ashik.ali |
119 |
@Autowired
|
| 24491 |
amit.gupta |
120 |
private AuthService authService;
|
| 25366 |
tejbeer |
121 |
|
| 24491 |
amit.gupta |
122 |
@Autowired
|
| 22873 |
ashik.ali |
123 |
private AddressRepository addressRepository;
|
| 21469 |
amit.gupta |
124 |
|
| 21426 |
ashik.ali |
125 |
@Autowired
|
| 22873 |
ashik.ali |
126 |
private GoogleLoginProcessor googleLoginProcessor;
|
| 21855 |
amit.gupta |
127 |
|
| 21784 |
amit.gupta |
128 |
@Autowired
|
| 22873 |
ashik.ali |
129 |
private UserService userService;
|
| 25366 |
tejbeer |
130 |
|
| 23786 |
amit.gupta |
131 |
@Autowired
|
| 23858 |
ashik.ali |
132 |
private RestClient restClient;
|
| 25366 |
tejbeer |
133 |
|
| 23858 |
ashik.ali |
134 |
@Autowired
|
| 23798 |
amit.gupta |
135 |
private RoleManager roleManager;
|
| 25366 |
tejbeer |
136 |
|
| 23786 |
amit.gupta |
137 |
@Autowired
|
|
|
138 |
private RoleRepository roleRepository;
|
| 21469 |
amit.gupta |
139 |
|
| 25366 |
tejbeer |
140 |
@Autowired
|
|
|
141 |
private AuthRepository authRepository;
|
|
|
142 |
|
|
|
143 |
@Autowired
|
|
|
144 |
private RetailerService retailerService;
|
|
|
145 |
|
| 25458 |
tejbeer |
146 |
@Autowired
|
|
|
147 |
private RefferalRepository refferalRepository;
|
|
|
148 |
|
|
|
149 |
@Autowired
|
|
|
150 |
private PromoterRepository promoterRepository;
|
|
|
151 |
|
| 21469 |
amit.gupta |
152 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_GOOGLE_LOGIN, method = RequestMethod.POST)
|
| 25366 |
tejbeer |
153 |
public ResponseEntity<?> googleLogin(HttpServletRequest request, @RequestBody GoogleLoginRequest googleLoginRequest)
|
|
|
154 |
throws ProfitMandiBusinessException {
|
| 23698 |
amit.gupta |
155 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 24494 |
amit.gupta |
156 |
Map<String, Object> resultMap = googleLoginProcessor.process(googleLoginRequest);
|
|
|
157 |
LOGGER.info("Response sent is {}", resultMap);
|
| 23698 |
amit.gupta |
158 |
return responseSender.ok(googleLoginProcessor.process(googleLoginRequest));
|
| 21277 |
ashik.ali |
159 |
}
|
| 21469 |
amit.gupta |
160 |
|
|
|
161 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_TOKEN_IS_EXPIRED, method = RequestMethod.GET)
|
| 25366 |
tejbeer |
162 |
public ResponseEntity<?> tokenIsExpired(HttpServletRequest request, @RequestParam(name = "token") String token)
|
|
|
163 |
throws ProfitMandiBusinessException {
|
| 21469 |
amit.gupta |
164 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 22930 |
ashik.ali |
165 |
return responseSender.ok(JWTUtil.isExpired(token));
|
| 21282 |
ashik.ali |
166 |
}
|
| 21469 |
amit.gupta |
167 |
|
| 22355 |
ashik.ali |
168 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_DETAIL_BY_TOKEN, method = RequestMethod.GET)
|
| 21469 |
amit.gupta |
169 |
@ApiImplicitParams({
|
|
|
170 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
|
|
171 |
public ResponseEntity<?> tokenInfo(HttpServletRequest request) throws Throwable {
|
|
|
172 |
Map<String, Object> responseMap = new HashMap<>();
|
|
|
173 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 21483 |
amit.gupta |
174 |
User user = null;
|
| 21855 |
amit.gupta |
175 |
if (userInfo.getUserId() > -1) {
|
| 21483 |
amit.gupta |
176 |
user = userRepository.selectById(userInfo.getUserId());
|
| 25366 |
tejbeer |
177 |
if (!(userInfo.getEmail() == null || user.getEmailId().equalsIgnoreCase(userInfo.getEmail()))) {
|
| 24491 |
amit.gupta |
178 |
String userName = null;
|
| 25366 |
tejbeer |
179 |
if (user.getSecondryEmailId() != null && user.getSecondryEmailId().equals(userInfo.getEmail())) {
|
| 24491 |
amit.gupta |
180 |
userName = user.getFirstName() + " " + user.getLastName();
|
|
|
181 |
} else {
|
|
|
182 |
userName = authService.getNameByEmailId(userInfo.getEmail());
|
|
|
183 |
}
|
|
|
184 |
responseMap.put(ProfitMandiConstants.USER_ID, userInfo.getUserId());
|
|
|
185 |
responseMap.put(ProfitMandiConstants.USER_NAME, userName);
|
|
|
186 |
responseMap.put(ProfitMandiConstants.USER_STATUS, "fofoAssociate");
|
|
|
187 |
responseMap.put(ProfitMandiConstants.EMAIL_ID, userInfo.getEmail());
|
|
|
188 |
return responseSender.ok(responseMap);
|
|
|
189 |
}
|
| 21483 |
amit.gupta |
190 |
} else {
|
|
|
191 |
try {
|
|
|
192 |
user = userRepository.selectByEmailId(userInfo.getEmail());
|
|
|
193 |
} catch (ProfitMandiBusinessException e1) {
|
|
|
194 |
}
|
| 25366 |
tejbeer |
195 |
if (user == null) {
|
| 23204 |
ashik.ali |
196 |
try {
|
|
|
197 |
user = userRepository.selectBySecondryEmailId(userInfo.getEmail());
|
|
|
198 |
} catch (ProfitMandiBusinessException e1) {
|
|
|
199 |
LOGGER.info("Uneregistered user", userInfo.getEmail());
|
|
|
200 |
}
|
|
|
201 |
}
|
| 21483 |
amit.gupta |
202 |
}
|
|
|
203 |
if (user != null) {
|
| 23858 |
ashik.ali |
204 |
int retailerId = userAccountRepository.selectRetailerIdByUserId(user.getId());
|
| 21491 |
amit.gupta |
205 |
responseMap.put(ProfitMandiConstants.EMAIL_ID, user.getEmailId());
|
| 21526 |
amit.gupta |
206 |
responseMap.put(ProfitMandiConstants.USER_ID, user.getId());
|
| 22017 |
amit.gupta |
207 |
responseMap.put(ProfitMandiConstants.USER_NAME, user.getFirstName() + " " + user.getLastName());
|
| 23786 |
amit.gupta |
208 |
List<Integer> roleIds = userRoleRepository.selectRoleIdsByUserId(user.getId());
|
| 25366 |
tejbeer |
209 |
// LOGGER.info("userRoles {} ", userRoles);
|
| 22032 |
ashik.ali |
210 |
|
|
|
211 |
// generate new token if roles have been updated
|
| 23786 |
amit.gupta |
212 |
if (userInfo.getRoleIds() == null || roleIds.size() != userInfo.getRoleIds().size()) {
|
| 23858 |
ashik.ali |
213 |
String[] roleIdStrings = new String[roleIds.size()];
|
| 22603 |
amit.gupta |
214 |
int index = 0;
|
| 23786 |
amit.gupta |
215 |
for (int roleId : roleIds) {
|
| 23858 |
ashik.ali |
216 |
roleIdStrings[index++] = String.valueOf(roleId);
|
| 22603 |
amit.gupta |
217 |
}
|
| 23858 |
ashik.ali |
218 |
String newToken = JWTUtil.create(user.getId(), retailerId, roleIdStrings);
|
| 21483 |
amit.gupta |
219 |
responseMap.put("newAuthToken", newToken);
|
|
|
220 |
}
|
| 23858 |
ashik.ali |
221 |
// if user is retailer
|
| 23786 |
amit.gupta |
222 |
Set<Integer> roleIdsSet = new HashSet<Integer>(roleIds);
|
| 23858 |
ashik.ali |
223 |
if (roleManager.isRetailer(roleIdsSet)) {
|
| 22032 |
ashik.ali |
224 |
UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
|
|
|
225 |
Retailer retailer = retailerRepository.selectById(uc.getUserId());
|
| 22370 |
amit.gupta |
226 |
com.spice.profitmandi.dao.entity.user.User saholicUser = userUserRepository.selectById(uc.getUserId());
|
| 25366 |
tejbeer |
227 |
if (saholicUser.getAddressId() != null) {
|
| 22370 |
amit.gupta |
228 |
Address address = addressRepository.selectById(saholicUser.getAddressId());
|
|
|
229 |
responseMap.put(ProfitMandiConstants.ADDRESS, address);
|
|
|
230 |
}
|
| 21485 |
amit.gupta |
231 |
// if retailer is activated 1 then verified retailer
|
|
|
232 |
// else if migrated is 1 then old retailer
|
| 25366 |
tejbeer |
233 |
// also lets incoporte old process i.e is user is activated then also retailer
|
|
|
234 |
// is verified retailer
|
| 21485 |
amit.gupta |
235 |
// else retailer is not verifed
|
| 22497 |
amit.gupta |
236 |
if (retailer.isActive() || user.isActivated()) {
|
| 23798 |
amit.gupta |
237 |
if (roleManager.isPartner(roleIdsSet)) {
|
| 22017 |
amit.gupta |
238 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.FOFO.getValue());
|
|
|
239 |
} else {
|
|
|
240 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.VERIFIED_RETAILER.getValue());
|
|
|
241 |
}
|
| 22032 |
ashik.ali |
242 |
} else if (retailer.isMigrated()) {
|
| 21485 |
amit.gupta |
243 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.RETAILER.getValue());
|
| 21469 |
amit.gupta |
244 |
} else {
|
| 21485 |
amit.gupta |
245 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.NOT_VERIFIED_RETAILER.getValue());
|
| 21469 |
amit.gupta |
246 |
}
|
| 23798 |
amit.gupta |
247 |
} else if (roleManager.isUser(roleIdsSet)) {
|
| 22502 |
amit.gupta |
248 |
responseMap.put("userInfo", getRegisteredUserInfo(user));
|
| 21469 |
amit.gupta |
249 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.REGISTERED.getValue());
|
| 22032 |
ashik.ali |
250 |
}
|
| 21491 |
amit.gupta |
251 |
} else {
|
|
|
252 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.NOT_REGISTERED.getValue());
|
|
|
253 |
responseMap.put(ProfitMandiConstants.EMAIL_ID, userInfo.getEmail());
|
| 21469 |
amit.gupta |
254 |
}
|
| 22032 |
ashik.ali |
255 |
|
| 21469 |
amit.gupta |
256 |
return responseSender.ok(responseMap);
|
|
|
257 |
}
|
| 25366 |
tejbeer |
258 |
|
| 22502 |
amit.gupta |
259 |
private RegisteredUserInfo getRegisteredUserInfo(User user) throws Throwable {
|
| 22492 |
amit.gupta |
260 |
RegisteredUserInfo ri = new RegisteredUserInfo();
|
|
|
261 |
ri.setCity(user.getCity());
|
|
|
262 |
ri.setFirstName(user.getFirstName());
|
|
|
263 |
ri.setLastName(user.getLastName());
|
| 22493 |
amit.gupta |
264 |
ri.setPhone(user.getMobileNumber());
|
| 22492 |
amit.gupta |
265 |
ri.setPinCode(user.getPinCode());
|
| 22845 |
amit.gupta |
266 |
ri.setState(user.getState());
|
| 22492 |
amit.gupta |
267 |
return ri;
|
|
|
268 |
}
|
| 21469 |
amit.gupta |
269 |
|
|
|
270 |
@RequestMapping(value = ProfitMandiConstants.URL_USER, method = RequestMethod.POST)
|
| 21501 |
amit.gupta |
271 |
@ApiImplicitParams({
|
| 22032 |
ashik.ali |
272 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
|
|
273 |
public ResponseEntity<?> createUser(HttpServletRequest request, @RequestBody UserRequest userRequest)
|
| 22930 |
ashik.ali |
274 |
throws ProfitMandiBusinessException {
|
| 21469 |
amit.gupta |
275 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 21368 |
kshitij.so |
276 |
User user = new User();
|
|
|
277 |
user.setFirstName(userRequest.getFirstName());
|
|
|
278 |
user.setLastName(userRequest.getLastName());
|
|
|
279 |
user.setCity(userRequest.getCity());
|
|
|
280 |
user.setPinCode(Integer.valueOf(userRequest.getPinCode()));
|
| 22845 |
amit.gupta |
281 |
user.setState(userRequest.getState());
|
| 21708 |
amit.gupta |
282 |
user.setMobileNumber(userRequest.getMobieNumber());
|
| 21368 |
kshitij.so |
283 |
user.setEmailId(userRequest.getEmailId());
|
|
|
284 |
user.setUsername("");
|
|
|
285 |
user.setPassword("");
|
|
|
286 |
user.setMobile_verified(false);
|
|
|
287 |
user.setReferral_url("");
|
|
|
288 |
user.setGroup_id(1);
|
| 22504 |
amit.gupta |
289 |
user.setStatus(1);
|
| 21368 |
kshitij.so |
290 |
user.setActivated(false);
|
| 21501 |
amit.gupta |
291 |
user.setCreateTimestamp(LocalDateTime.now());
|
|
|
292 |
user.setUpdateTimestamp(LocalDateTime.now());
|
| 22930 |
ashik.ali |
293 |
userRepository.persist(user);
|
| 23858 |
ashik.ali |
294 |
Role role = roleRepository.selectByName(RoleType.USER.toString());
|
| 22930 |
ashik.ali |
295 |
UserRole userRole = new UserRole();
|
| 23858 |
ashik.ali |
296 |
userRole.setRoleId(role.getId());
|
| 22930 |
ashik.ali |
297 |
userRole.setUserId(user.getId());
|
|
|
298 |
userRoleRepository.persist(userRole);
|
|
|
299 |
return responseSender.ok(ResponseCodeHolder.getMessage("USR_OK_1000"));
|
| 25366 |
tejbeer |
300 |
|
| 21278 |
ashik.ali |
301 |
}
|
| 21469 |
amit.gupta |
302 |
|
|
|
303 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ID, method = RequestMethod.GET)
|
| 25366 |
tejbeer |
304 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id)
|
|
|
305 |
throws ProfitMandiBusinessException {
|
| 21469 |
amit.gupta |
306 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 22930 |
ashik.ali |
307 |
return responseSender.ok(userRepository.selectById(id));
|
| 21248 |
ashik.ali |
308 |
}
|
| 21469 |
amit.gupta |
309 |
|
|
|
310 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_MOBILE_NUMBER, method = RequestMethod.GET)
|
|
|
311 |
public ResponseEntity<?> getByMobileNumber(HttpServletRequest request,
|
| 25366 |
tejbeer |
312 |
@RequestParam(name = "mobileNumber") String mobileNumber) throws ProfitMandiBusinessException {
|
| 21469 |
amit.gupta |
313 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 22930 |
ashik.ali |
314 |
return responseSender.ok(userRepository.selectByMobileNumber(mobileNumber));
|
| 21248 |
ashik.ali |
315 |
}
|
| 21469 |
amit.gupta |
316 |
|
| 21784 |
amit.gupta |
317 |
@ApiImplicitParams({
|
| 21501 |
amit.gupta |
318 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
|
|
319 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ACTIVATE, method = RequestMethod.POST)
|
|
|
320 |
public ResponseEntity<?> activateUser(HttpServletRequest request,
|
| 21784 |
amit.gupta |
321 |
@RequestParam(name = "activationCode") String activationCode) throws Throwable {
|
| 21855 |
amit.gupta |
322 |
int userId = (int) request.getAttribute("userId");
|
| 21784 |
amit.gupta |
323 |
UserCart uc = userAccountRepository.getUserCart(userId);
|
|
|
324 |
return responseSender.ok(userService.updateActivation(userId, uc.getUserId(), activationCode));
|
|
|
325 |
}
|
| 21855 |
amit.gupta |
326 |
|
| 25458 |
tejbeer |
327 |
/*
|
|
|
328 |
* @ApiImplicitParams({
|
|
|
329 |
*
|
|
|
330 |
* @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true,
|
|
|
331 |
* dataType = "string", paramType = "header") })
|
|
|
332 |
*
|
|
|
333 |
* @RequestMapping(value = ProfitMandiConstants.URL_USER_NOTIFICATIONS, method =
|
|
|
334 |
* RequestMethod.GET) public ResponseEntity<?>
|
|
|
335 |
* getNofitications(HttpServletRequest request,
|
|
|
336 |
*
|
|
|
337 |
* @RequestParam(name = "androidId") String androidId, @RequestParam(name =
|
|
|
338 |
* "pageNumber") int pageNumber,
|
|
|
339 |
*
|
|
|
340 |
* @RequestParam(name = "pageSize") int pageSize) throws
|
|
|
341 |
* ProfitMandiBusinessException { int userId = (int)
|
|
|
342 |
* request.getAttribute("userId"); String restResponse = null; Map<String,
|
|
|
343 |
* String> params = new HashMap<>();
|
|
|
344 |
*
|
|
|
345 |
* String uri = "/getAllNotifications"; params.put("user_id", userId + "");
|
|
|
346 |
* params.put("android_id", androidId); params.put("limit", pageSize + "");
|
|
|
347 |
* params.put("offset", "" + ((pageNumber - 1) * pageSize)); try { restResponse
|
|
|
348 |
* = restClient.get(SchemeType.HTTP, nodeHost, nodePort, uri, params); } catch
|
|
|
349 |
* (HttpHostConnectException e) { throw new ProfitMandiBusinessException("", "",
|
|
|
350 |
* "Could not Connect to host"); }
|
|
|
351 |
*
|
|
|
352 |
* JsonArray result_json = Json.parse(restResponse).asArray();
|
|
|
353 |
*
|
|
|
354 |
* List<Notification> notifications = new ArrayList<>();
|
|
|
355 |
*
|
|
|
356 |
* for (JsonValue j : result_json) {
|
|
|
357 |
* notifications.add(toNotifiaction(j.asObject())); }
|
|
|
358 |
*
|
|
|
359 |
* return responseSender.ok(notifications); }
|
|
|
360 |
*
|
|
|
361 |
* private Notification toNotifiaction(JsonObject jsonObject) { Notification n =
|
|
|
362 |
* (Notification) (new Gson().fromJson(jsonObject.toString(),
|
|
|
363 |
* Notification.class)); if (n.getStatus().equals("opened") ||
|
|
|
364 |
* n.getStatus().equals("referrer") || n.getStatus().equals("seen")) {
|
|
|
365 |
* n.setSeen(true); } return n; }
|
|
|
366 |
*/
|
| 21855 |
amit.gupta |
367 |
|
| 21426 |
ashik.ali |
368 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_IS_EXIST_MOBILE_NUMBER, method = RequestMethod.GET)
|
| 21469 |
amit.gupta |
369 |
public ResponseEntity<?> isMobileNumberExist(HttpServletRequest request,
|
|
|
370 |
@RequestParam(name = "mobileNumber") String mobileNumber) {
|
|
|
371 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 21448 |
ashik.ali |
372 |
return responseSender.ok(userRepository.isExistByMobileNumber(mobileNumber));
|
| 21426 |
ashik.ali |
373 |
}
|
| 21469 |
amit.gupta |
374 |
|
|
|
375 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_EMAIL_ID, method = RequestMethod.GET)
|
| 25366 |
tejbeer |
376 |
public ResponseEntity<?> getByEmailId(HttpServletRequest request, @RequestParam(name = "emailId") String emailId)
|
|
|
377 |
throws ProfitMandiBusinessException {
|
| 21469 |
amit.gupta |
378 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 23204 |
ashik.ali |
379 |
User user = null;
|
| 25366 |
tejbeer |
380 |
try {
|
| 23204 |
ashik.ali |
381 |
user = userRepository.selectByEmailId(emailId);
|
| 25366 |
tejbeer |
382 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
| 23204 |
ashik.ali |
383 |
user = userRepository.selectBySecondryEmailId(emailId);
|
|
|
384 |
}
|
|
|
385 |
return responseSender.ok(user);
|
| 21248 |
ashik.ali |
386 |
}
|
| 21469 |
amit.gupta |
387 |
|
|
|
388 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_ALL, method = RequestMethod.GET)
|
|
|
389 |
public ResponseEntity<?> getAllRoles(HttpServletRequest request, @RequestParam(name = "id") int id) {
|
|
|
390 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 21448 |
ashik.ali |
391 |
return responseSender.ok(userRoleRepository.selectRolesByUserId(id));
|
| 21248 |
ashik.ali |
392 |
}
|
| 25366 |
tejbeer |
393 |
|
| 23204 |
ashik.ali |
394 |
@ApiImplicitParams({
|
| 25366 |
tejbeer |
395 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 23204 |
ashik.ali |
396 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_SECONDRY_EMAIL_ID_AND_FOFO_STORE_CODE, method = RequestMethod.GET)
|
| 25366 |
tejbeer |
397 |
public ResponseEntity<?> getSecondryEmailAndStoreCode(HttpServletRequest request)
|
|
|
398 |
throws ProfitMandiBusinessException {
|
| 23204 |
ashik.ali |
399 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
|
|
400 |
int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
|
|
|
401 |
return responseSender.ok(userService.getEmailsAndFofoStoreCodeByUserId(userId));
|
|
|
402 |
}
|
| 25366 |
tejbeer |
403 |
|
| 23204 |
ashik.ali |
404 |
@ApiImplicitParams({
|
| 25366 |
tejbeer |
405 |
@ApiImplicitParam(name = "Auth-Token", value = "-Token", required = true, dataType = "string", paramType = "header") })
|
| 23858 |
ashik.ali |
406 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_SECONDRY_EMAIL_ID, method = RequestMethod.PUT)
|
| 23204 |
ashik.ali |
407 |
public ResponseEntity<?> updateSecondryEmailId(HttpServletRequest request,
|
| 25366 |
tejbeer |
408 |
@RequestParam(name = ProfitMandiConstants.SECONDRY_EMAIL_ID) String secondryEmailId) throws Throwable {
|
|
|
409 |
int userId = (int) request.getAttribute("userId");
|
|
|
410 |
User user = userRepository.selectById(userId);
|
|
|
411 |
user.setSecondryEmailId(secondryEmailId);
|
|
|
412 |
userRepository.persist(user);
|
|
|
413 |
return responseSender.ok(ResponseCodeHolder.getMessage("USR_OK_1001"));
|
|
|
414 |
}
|
| 21414 |
kshitij.so |
415 |
|
|
|
416 |
@RequestMapping(value = ProfitMandiConstants.URL_ADMIN_TOKEN, method = RequestMethod.POST)
|
| 21469 |
amit.gupta |
417 |
public ResponseEntity<?> getAdminToken(HttpServletRequest request,
|
|
|
418 |
@RequestParam(name = "adminToken") String adminToken, @RequestParam(name = "emailId") String emailId) {
|
|
|
419 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
|
|
420 |
if (!adminToken.equals(validAdminToken)) {
|
| 22930 |
ashik.ali |
421 |
return responseSender.forbidden(null);
|
| 21414 |
kshitij.so |
422 |
}
|
| 21469 |
amit.gupta |
423 |
|
| 21414 |
kshitij.so |
424 |
Map<String, Object> responseMap = new HashMap<>(2);
|
| 23204 |
ashik.ali |
425 |
User user = null;
|
| 21469 |
amit.gupta |
426 |
try {
|
| 23204 |
ashik.ali |
427 |
user = userRepository.selectByEmailId(emailId);
|
|
|
428 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
| 25366 |
tejbeer |
429 |
|
| 23204 |
ashik.ali |
430 |
}
|
| 25366 |
tejbeer |
431 |
|
|
|
432 |
if (user == null) {
|
|
|
433 |
try {
|
| 23204 |
ashik.ali |
434 |
user = userRepository.selectBySecondryEmailId(emailId);
|
| 25366 |
tejbeer |
435 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
|
|
436 |
|
| 23204 |
ashik.ali |
437 |
}
|
|
|
438 |
}
|
| 25366 |
tejbeer |
439 |
if (user != null) {
|
| 23858 |
ashik.ali |
440 |
int retailerId = 0;
|
|
|
441 |
try {
|
|
|
442 |
retailerId = userAccountRepository.selectRetailerIdByUserId(user.getId());
|
|
|
443 |
} catch (ProfitMandiBusinessException e) {
|
|
|
444 |
// TODO Auto-generated catch block
|
|
|
445 |
e.printStackTrace();
|
|
|
446 |
}
|
|
|
447 |
List<Integer> roleIds = userRoleRepository.selectRoleIdsByUserId(user.getId());
|
|
|
448 |
String[] roleIdsString = new String[roleIds.size()];
|
| 21414 |
kshitij.so |
449 |
int index = 0;
|
| 23858 |
ashik.ali |
450 |
for (int roleId : roleIds) {
|
|
|
451 |
roleIdsString[index++] = String.valueOf(roleId);
|
| 21414 |
kshitij.so |
452 |
}
|
| 23858 |
ashik.ali |
453 |
responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create(user.getId(), retailerId, roleIdsString));
|
| 21414 |
kshitij.so |
454 |
responseMap.put(ProfitMandiConstants.REGISTERED, true);
|
| 25366 |
tejbeer |
455 |
} else {
|
| 21469 |
amit.gupta |
456 |
responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create(emailId));
|
| 21414 |
kshitij.so |
457 |
responseMap.put(ProfitMandiConstants.REGISTERED, false);
|
|
|
458 |
}
|
| 21448 |
ashik.ali |
459 |
return responseSender.ok(responseMap);
|
| 21469 |
amit.gupta |
460 |
|
| 21414 |
kshitij.so |
461 |
}
|
| 25366 |
tejbeer |
462 |
|
| 25300 |
tejbeer |
463 |
@RequestMapping(value = "/mobileappsettings", method = RequestMethod.POST)
|
| 25366 |
tejbeer |
464 |
public ResponseEntity<?> mobileAppSettings(HttpServletRequest request, @RequestParam(name = "t") int timestamp,
|
|
|
465 |
@RequestParam(name = "imeinumber") String imeinumber)
|
|
|
466 |
throws ProfitMandiBusinessException, ClientProtocolException, IOException {
|
|
|
467 |
|
|
|
468 |
final String uri = "http://api.profittill.com/mobileappsettings?t=" + timestamp + "&imeinumber=" + imeinumber;
|
| 25300 |
tejbeer |
469 |
final String BASIC_AUTH = "Basic " + Base64.getEncoder().encodeToString("dtr:dtr18Feb2015".getBytes());
|
|
|
470 |
Map<String, String> headers = new HashMap<>();
|
|
|
471 |
Map<String, String> params = new HashMap<>();
|
|
|
472 |
headers.put("Authorization", BASIC_AUTH);
|
|
|
473 |
return responseSender.ok(restClient.post(uri, params, headers));
|
|
|
474 |
}
|
| 22032 |
ashik.ali |
475 |
|
| 25366 |
tejbeer |
476 |
@RequestMapping(value = "/getPartners", method = RequestMethod.GET)
|
|
|
477 |
@ApiImplicitParams({
|
|
|
478 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
|
|
479 |
public ResponseEntity<?> getPartners(HttpServletRequest request, @RequestParam(name = "gmailId") String gmailId,
|
|
|
480 |
@RequestParam(value = "offset") int offset, @RequestParam(value = "limit") int limit)
|
|
|
481 |
throws ProfitMandiBusinessException {
|
|
|
482 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
|
|
483 |
|
|
|
484 |
Map<String, List<String>> storeGuyMap = new HashMap<>();
|
|
|
485 |
for (Map.Entry<String, List<String>> entry : storeManagerMap.entrySet()) {
|
|
|
486 |
String storeEmail = entry.getKey();
|
|
|
487 |
List<String> storeGuys = entry.getValue();
|
|
|
488 |
for (String storeGuy : storeGuys) {
|
|
|
489 |
if (!storeGuyMap.containsKey(storeGuy)) {
|
|
|
490 |
storeGuyMap.put(storeGuy, new ArrayList<>());
|
|
|
491 |
}
|
|
|
492 |
storeGuyMap.get(storeGuy).add(storeEmail);
|
|
|
493 |
}
|
|
|
494 |
|
|
|
495 |
}
|
|
|
496 |
storeGuyMap.remove("");
|
|
|
497 |
|
|
|
498 |
List<String> emails = storeGuyMap.get(authUser.getEmailId());
|
|
|
499 |
LOGGER.info("emails" + emails);
|
| 25458 |
tejbeer |
500 |
List<User> users = userRepository.selectAllByEmails(emails, offset, limit);
|
| 25366 |
tejbeer |
501 |
List<Partner> partners = new ArrayList<>();
|
|
|
502 |
for (User user : users) {
|
| 25458 |
tejbeer |
503 |
|
| 25366 |
tejbeer |
504 |
UserAccount uc = userAccountRepository.selectSaholicByUserId(user.getId());
|
| 25458 |
tejbeer |
505 |
com.spice.profitmandi.dao.entity.user.User userInfo = userUserRepository.selectById(uc.getAccountKey());
|
| 25366 |
tejbeer |
506 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(userInfo.getId());
|
|
|
507 |
|
|
|
508 |
Partner partner = new Partner();
|
|
|
509 |
partner.setBusinessName(customRetailer.getBusinessName());
|
|
|
510 |
partner.setPartnerId(customRetailer.getPartnerId());
|
|
|
511 |
partner.setCartId(customRetailer.getCartId());
|
|
|
512 |
partner.setEmail(customRetailer.getEmail());
|
|
|
513 |
partner.setGstNumber(customRetailer.getGstNumber());
|
|
|
514 |
partner.setDisplayName(customRetailer.getDisplayName());
|
|
|
515 |
partner.setCity(customRetailer.getAddress().getCity());
|
|
|
516 |
partner.setUserId(user.getId());
|
|
|
517 |
partners.add(partner);
|
|
|
518 |
}
|
|
|
519 |
LOGGER.info("partners" + partners);
|
|
|
520 |
return responseSender.ok(partners);
|
|
|
521 |
}
|
|
|
522 |
|
|
|
523 |
public static final Map<String, String> nameEmail = new HashMap<>();
|
|
|
524 |
|
|
|
525 |
public static final Map<String, List<String>> storeManagerMap = new HashMap<>();
|
|
|
526 |
|
|
|
527 |
static {
|
|
|
528 |
nameEmail.put("Amod", "amod.sen@smartdukaan.com");
|
|
|
529 |
nameEmail.put("Parmod", "parmod.kumar@smartdukaan.com");
|
|
|
530 |
nameEmail.put("Anis", "md.anis@smartdukaan.com");
|
|
|
531 |
nameEmail.put("Manoj", "manoj.singh@smartdukaan.com");
|
|
|
532 |
nameEmail.put("Adeel", "adeel.yazdani@smartdukaan.com");
|
|
|
533 |
nameEmail.put("Mohinder", "mohinder.mutreja@smartdukaan.com");
|
|
|
534 |
nameEmail.put("Dharmendar", "dharmender.verma@smartdukaan.com");
|
|
|
535 |
nameEmail.put("Rajat", "rajat.gupta@smartdukaan.com");
|
|
|
536 |
nameEmail.put("Ankit", "ankit.bhatia@smartdukaan.com");
|
|
|
537 |
nameEmail.put("Rajit", "rajit.alag@smartdukaan.com");
|
|
|
538 |
nameEmail.put("Gulshan", "gulshan.kumar@smartdukaan.com");
|
|
|
539 |
nameEmail.put("PramodSharma", "parmod.sharma@smartdukaan.com");
|
|
|
540 |
// nameEmail.put("Gulshan","");
|
| 25458 |
tejbeer |
541 |
storeManagerMap.put("themobileplanet03@gmail.com",
|
|
|
542 |
Arrays.asList("amod.sen@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
543 |
storeManagerMap.put("mobileplanet7599@gmail.com", Arrays.asList("parmod.sharma@smartdukaan.com",
|
|
|
544 |
"dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
545 |
storeManagerMap.put("robintelecom.snp@gmail.com", Arrays.asList("parmod.sharma@smartdukaan.com",
|
|
|
546 |
"dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
547 |
storeManagerMap.put("smartconnect4141@gmail.com",
|
|
|
548 |
Arrays.asList("amod.sen@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
549 |
storeManagerMap.put("bhimsain919@gmail.com", Arrays.asList("parmod.sharma@smartdukaan.com",
|
|
|
550 |
"dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
551 |
storeManagerMap.put("babitaranirk@gmail.com",
|
|
|
552 |
Arrays.asList("parmod.sharma@smartdukaan.com", "", "mohinder.mutreja@smartdukaan.com"));
|
|
|
553 |
storeManagerMap.put("dharmendery079@gmail.com",
|
|
|
554 |
Arrays.asList("manoj.singh@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
555 |
storeManagerMap.put("kkv.enterprises1@gmail.com",
|
|
|
556 |
Arrays.asList("parmod.sharma@smartdukaan.com", "", "mohinder.mutreja@smartdukaan.com"));
|
|
|
557 |
storeManagerMap.put("gulshersaifi74226@gmail.com",
|
|
|
558 |
Arrays.asList("amod.sen@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
559 |
storeManagerMap.put("deepak.lalwani1985@gmail.com",
|
|
|
560 |
Arrays.asList("manoj.singh@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
561 |
storeManagerMap.put("gupta.smartdukaan@gmail.com",
|
|
|
562 |
Arrays.asList("amod.sen@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
563 |
storeManagerMap.put("sachinindri2006@gmail.com", Arrays.asList("parmod.sharma@smartdukaan.com",
|
|
|
564 |
"dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
565 |
storeManagerMap.put("kambojanil83@gmail.com",
|
|
|
566 |
Arrays.asList("parmod.sharma@smartdukaan.com", "", "mohinder.mutreja@smartdukaan.com"));
|
|
|
567 |
storeManagerMap.put("uppal.neeraj82@gmail.com",
|
|
|
568 |
Arrays.asList("", "ankit.bhatia@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
569 |
storeManagerMap.put("thefonehousekarnal@gmail.com", Arrays.asList("parmod.sharma@smartdukaan.com",
|
|
|
570 |
"dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
571 |
storeManagerMap.put("richa9910763006@gmail.com",
|
|
|
572 |
Arrays.asList("manoj.singh@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
573 |
storeManagerMap.put("smartdukangzb@gmail.com",
|
|
|
574 |
Arrays.asList("manoj.singh@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
575 |
storeManagerMap.put("lovelymobile183@gmail.com",
|
|
|
576 |
Arrays.asList("manoj.singh@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
577 |
storeManagerMap.put("smartdukaan.sonepat@gmail.com", Arrays.asList("parmod.sharma@smartdukaan.com",
|
|
|
578 |
"dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
579 |
storeManagerMap.put("arunmittal299@gmail.com", Arrays.asList("parmod.sharma@smartdukaan.com",
|
|
|
580 |
"dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
581 |
storeManagerMap.put("gtc01100@gmail.com", Arrays.asList("parmod.sharma@smartdukaan.com",
|
|
|
582 |
"dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
583 |
storeManagerMap.put("sumittyagi1975@gmail.com",
|
|
|
584 |
Arrays.asList("manoj.singh@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
585 |
storeManagerMap.put("metrofurniture342@gmail.com", Arrays.asList("parmod.sharma@smartdukaan.com",
|
|
|
586 |
"dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
587 |
storeManagerMap.put("suryaelectronicskaithal@gmail.com",
|
|
|
588 |
Arrays.asList("Parmod", "", "mohinder.mutreja@smartdukaan.com"));
|
|
|
589 |
storeManagerMap.put("mmtelecomsec16@gmail.com",
|
|
|
590 |
Arrays.asList("amod.sen@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
591 |
storeManagerMap.put("omsonsindia08@gmail.com", Arrays.asList("parmod.sharma@smartdukaan.com",
|
|
|
592 |
"dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
593 |
storeManagerMap.put("smartenterprisespv@gmail.com",
|
|
|
594 |
Arrays.asList("amod.sen@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
595 |
storeManagerMap.put("cachaitnya@gmail.com",
|
|
|
596 |
Arrays.asList("amod.sen@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
597 |
storeManagerMap.put("ajaykumarkansal03@gmail.com",
|
|
|
598 |
Arrays.asList("manoj.singh@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
599 |
storeManagerMap.put("spurwar73@gmail.com", Arrays.asList("md.anis@smartdukaan.com",
|
|
|
600 |
"rajat.gupta@smartdukaan.com", "adeel.yazdani@smartdukaan.com"));
|
|
|
601 |
storeManagerMap.put("Shreemobile.ind@gmail.com", Arrays.asList("md.anis@smartdukaan.com",
|
|
|
602 |
"rajat.gupta@smartdukaan.com", "adeel.yazdani@smartdukaan.com"));
|
|
|
603 |
storeManagerMap.put("felixenterprises2017@rediffmail.com",
|
|
|
604 |
Arrays.asList("", "dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
605 |
storeManagerMap.put("nareandergupta@gmail.com",
|
|
|
606 |
Arrays.asList("", "dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
607 |
storeManagerMap.put("shreebalajielectronic2019@gmail.com",
|
|
|
608 |
Arrays.asList("manoj.singh@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
609 |
storeManagerMap.put("saranshary@gmail.com",
|
|
|
610 |
Arrays.asList("", "dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
611 |
storeManagerMap.put("gambhirsmartphone@gmail.com",
|
|
|
612 |
Arrays.asList("", "gulshan.kumar@smartdukaan.com", "adeel.yazdani@smartdukaan.com"));
|
|
|
613 |
storeManagerMap.put("Priyankaenterprises9910@gmail.com",
|
|
|
614 |
Arrays.asList("manoj.singh@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
615 |
storeManagerMap.put("pawan.dhimaan@gmail.com",
|
|
|
616 |
Arrays.asList("", "dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
617 |
storeManagerMap.put("lakshaydhulla62@gmail.com", Arrays.asList("parmod.sharma@smartdukaan.com",
|
|
|
618 |
"dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
619 |
storeManagerMap.put("parastelecom.stp@gmail.com", Arrays.asList("md.anis@smartdukaan.com",
|
|
|
620 |
"rajat.gupta@smartdukaan.com", "adeel.yazdani@smartdukaan.com"));
|
|
|
621 |
storeManagerMap.put("talwarmukesh298@gmail.com", Arrays.asList("parmod.sharma@smartdukaan.com",
|
|
|
622 |
"dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
623 |
storeManagerMap.put("sahilnarang0009@gmail.com",
|
|
|
624 |
Arrays.asList("parmod.sharma@smartdukaan.com", "", "mohinder.mutreja@smartdukaan.com"));
|
|
|
625 |
storeManagerMap.put("supertelecomjind@gmail.com",
|
|
|
626 |
Arrays.asList("", "ankit.bhatia@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
627 |
storeManagerMap.put("saketnagpal@gmail.com",
|
|
|
628 |
Arrays.asList("", "rajit.alag@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
629 |
storeManagerMap.put("DEEPAKGOYAL702.DG@GMAIL.COM",
|
|
|
630 |
Arrays.asList("", "ankit.bhatia@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
631 |
storeManagerMap.put("sambhav350@gmail.com", Arrays.asList("parmod.sharma@smartdukaan.com",
|
|
|
632 |
"dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
633 |
storeManagerMap.put("mayankarora98133@gmail.com",
|
|
|
634 |
Arrays.asList("", "ankit.bhatia@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
635 |
storeManagerMap.put("vijaymobilityandmoew@gmail.com",
|
|
|
636 |
Arrays.asList("manoj.singh@smartdukaan.com", "", "adeel.yazdani@smartdukaan.com"));
|
|
|
637 |
storeManagerMap.put("amitv70003@gmail.com",
|
|
|
638 |
Arrays.asList("", "ankit.bhatia@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
639 |
storeManagerMap.put("newagelucknow.123@gmail.com", Arrays.asList("md.anis@smartdukaan.com",
|
|
|
640 |
"rajat.gupta@smartdukaan.com", "adeel.yazdani@smartdukaan.com"));
|
|
|
641 |
storeManagerMap.put("Newagetechnologygomtinagar@gmail.com", Arrays.asList("md.anis@smartdukaan.com",
|
|
|
642 |
"rajat.gupta@smartdukaan.com", "adeel.yazdani@smartdukaan.com"));
|
|
|
643 |
storeManagerMap.put("rohitbatra106@gmail.com", Arrays.asList("parmod.sharma@smartdukaan.com",
|
|
|
644 |
"dharmender.verma@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
645 |
storeManagerMap.put("sonisunil9050873061@gmail.com",
|
|
|
646 |
Arrays.asList("", "ankit.bhatia@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
647 |
storeManagerMap.put("moderncohsr@gmail.com",
|
|
|
648 |
Arrays.asList("", "ankit.bhatia@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
649 |
storeManagerMap.put("raghubir.ngh@gmail.com",
|
|
|
650 |
Arrays.asList("", "ankit.bhatia@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
|
|
651 |
storeManagerMap.put("aman007singla@gmail.com",
|
|
|
652 |
Arrays.asList("", "rajit.alag@smartdukaan.com", "mohinder.mutreja@smartdukaan.com"));
|
| 25366 |
tejbeer |
653 |
}
|
| 25458 |
tejbeer |
654 |
|
|
|
655 |
@RequestMapping(value = "/user/refferal", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
656 |
@ApiImplicitParams({
|
|
|
657 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
|
|
658 |
public ResponseEntity<?> RefferalUser(HttpServletRequest request,
|
|
|
659 |
@RequestBody CreateRefferalRequest createRefferalRequest) throws Exception {
|
|
|
660 |
Refferal refferal = new Refferal();
|
|
|
661 |
refferal.setFirstName(createRefferalRequest.getFirstName());
|
|
|
662 |
refferal.setLastName(createRefferalRequest.getLastName());
|
|
|
663 |
refferal.setMobile(createRefferalRequest.getMobile());
|
|
|
664 |
refferal.setState(createRefferalRequest.getState());
|
|
|
665 |
refferal.setCity(createRefferalRequest.getCity());
|
|
|
666 |
refferal.setCreatedTimestamp(LocalDateTime.now());
|
|
|
667 |
refferal.setUpdatedTimestamp(LocalDateTime.now());
|
|
|
668 |
refferal.setStatus("pending");
|
|
|
669 |
if (createRefferalRequest.isFofoAssociate()) {
|
|
|
670 |
AuthUser authUser = authRepository.selectByGmailId(createRefferalRequest.getReffereeEmail());
|
|
|
671 |
if (authUser==null) {
|
|
|
672 |
Promoter promoter = promoterRepository.selectByEmailId(createRefferalRequest.getReffereeEmail());
|
|
|
673 |
refferal.setRefereeName(promoter.getName());
|
|
|
674 |
refferal.setReffereeEmail(promoter.getEmail());
|
|
|
675 |
refferal.setRefereeMobile(promoter.getMobile());
|
|
|
676 |
} else {
|
|
|
677 |
refferal.setRefereeName(authUser.getFirstName());
|
|
|
678 |
refferal.setReffereeEmail(authUser.getGmailId());
|
|
|
679 |
refferal.setRefereeMobile(authUser.getMobileNumber());
|
|
|
680 |
}
|
|
|
681 |
} else {
|
|
|
682 |
User user = userRepository.selectByEmailId(createRefferalRequest.getReffereeEmail());
|
|
|
683 |
refferal.setRefereeName(user.getFirstName());
|
|
|
684 |
refferal.setReffereeEmail(user.getEmailId());
|
|
|
685 |
refferal.setRefereeMobile(user.getMobileNumber());
|
|
|
686 |
}
|
|
|
687 |
|
|
|
688 |
refferalRepository.persist(refferal);
|
|
|
689 |
return responseSender.ok(true);
|
|
|
690 |
}
|
| 21248 |
ashik.ali |
691 |
}
|