| 21248 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 26636 |
amit.gupta |
3 |
import com.fasterxml.jackson.annotation.JsonProperty;
|
| 26646 |
amit.gupta |
4 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
| 21248 |
ashik.ali |
5 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
|
|
6 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 30295 |
amit.gupta |
7 |
import com.spice.profitmandi.common.model.*;
|
| 21282 |
ashik.ali |
8 |
import com.spice.profitmandi.common.util.JWTUtil;
|
| 30295 |
amit.gupta |
9 |
import com.spice.profitmandi.common.util.Utils;
|
| 21855 |
amit.gupta |
10 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| 21740 |
ashik.ali |
11 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 25366 |
tejbeer |
12 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 30295 |
amit.gupta |
13 |
import com.spice.profitmandi.dao.entity.dtr.*;
|
| 29011 |
amit.gupta |
14 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
|
|
15 |
import com.spice.profitmandi.dao.entity.fofo.PartnerOnBoardingPanel;
|
| 25622 |
amit.gupta |
16 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| 22355 |
ashik.ali |
17 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 25458 |
tejbeer |
18 |
import com.spice.profitmandi.dao.entity.user.Promoter;
|
|
|
19 |
import com.spice.profitmandi.dao.entity.user.Refferal;
|
| 25488 |
tejbeer |
20 |
import com.spice.profitmandi.dao.enumuration.dtr.RefferalStatus;
|
| 21735 |
ashik.ali |
21 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| 29892 |
tejbeer |
22 |
import com.spice.profitmandi.dao.enumuration.transaction.PartnerOnBoardingStatus;
|
| 25979 |
tejbeer |
23 |
import com.spice.profitmandi.dao.model.CreateRefferalRequest;
|
| 25488 |
tejbeer |
24 |
import com.spice.profitmandi.dao.model.DateRangeModel;
|
| 21643 |
ashik.ali |
25 |
import com.spice.profitmandi.dao.model.UserCart;
|
| 25366 |
tejbeer |
26 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 25619 |
amit.gupta |
27 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 30295 |
amit.gupta |
28 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
| 25622 |
amit.gupta |
29 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| 22355 |
ashik.ali |
30 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 25458 |
tejbeer |
31 |
import com.spice.profitmandi.dao.repository.user.PromoterRepository;
|
| 24491 |
amit.gupta |
32 |
import com.spice.profitmandi.service.AuthService;
|
| 23798 |
amit.gupta |
33 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 25366 |
tejbeer |
34 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 29011 |
amit.gupta |
35 |
import com.spice.profitmandi.service.user.StoreTimelineTatService;
|
| 23787 |
amit.gupta |
36 |
import com.spice.profitmandi.service.user.UserService;
|
| 26870 |
amit.gupta |
37 |
import com.spice.profitmandi.web.controller.checkout.OrderController;
|
| 21469 |
amit.gupta |
38 |
import com.spice.profitmandi.web.enumuration.UserStatus;
|
| 21277 |
ashik.ali |
39 |
import com.spice.profitmandi.web.processor.GoogleLoginProcessor;
|
| 25488 |
tejbeer |
40 |
import com.spice.profitmandi.web.req.RefferalEarning;
|
|
|
41 |
import com.spice.profitmandi.web.req.RefferalEarningModel;
|
| 21366 |
kshitij.so |
42 |
import com.spice.profitmandi.web.req.UserRequest;
|
| 25366 |
tejbeer |
43 |
import com.spice.profitmandi.web.res.Partner;
|
| 21469 |
amit.gupta |
44 |
import io.swagger.annotations.ApiImplicitParam;
|
|
|
45 |
import io.swagger.annotations.ApiImplicitParams;
|
| 30295 |
amit.gupta |
46 |
import org.apache.http.client.ClientProtocolException;
|
|
|
47 |
import org.apache.logging.log4j.LogManager;
|
|
|
48 |
import org.apache.logging.log4j.Logger;
|
|
|
49 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
50 |
import org.springframework.beans.factory.annotation.Value;
|
|
|
51 |
import org.springframework.http.MediaType;
|
|
|
52 |
import org.springframework.http.ResponseEntity;
|
|
|
53 |
import org.springframework.mail.javamail.JavaMailSender;
|
|
|
54 |
import org.springframework.mail.javamail.MimeMessageHelper;
|
|
|
55 |
import org.springframework.stereotype.Controller;
|
|
|
56 |
import org.springframework.transaction.annotation.Transactional;
|
|
|
57 |
import org.springframework.web.bind.annotation.*;
|
| 21469 |
amit.gupta |
58 |
|
| 30295 |
amit.gupta |
59 |
import javax.mail.MessagingException;
|
|
|
60 |
import javax.mail.internet.InternetAddress;
|
|
|
61 |
import javax.mail.internet.MimeMessage;
|
|
|
62 |
import javax.servlet.http.HttpServletRequest;
|
|
|
63 |
import java.io.IOException;
|
|
|
64 |
import java.io.UnsupportedEncodingException;
|
|
|
65 |
import java.time.LocalDate;
|
|
|
66 |
import java.time.LocalDateTime;
|
|
|
67 |
import java.time.YearMonth;
|
|
|
68 |
import java.time.ZoneOffset;
|
|
|
69 |
import java.util.*;
|
|
|
70 |
import java.util.stream.Collectors;
|
|
|
71 |
|
| 21248 |
ashik.ali |
72 |
/**
|
|
|
73 |
* @author ashikali
|
|
|
74 |
*/
|
|
|
75 |
@Controller
|
| 25366 |
tejbeer |
76 |
@Transactional(rollbackFor = Throwable.class)
|
| 21248 |
ashik.ali |
77 |
public class UserController {
|
| 21469 |
amit.gupta |
78 |
|
| 21448 |
ashik.ali |
79 |
@Autowired
|
| 22930 |
ashik.ali |
80 |
private ResponseSender<?> responseSender;
|
| 21469 |
amit.gupta |
81 |
|
| 23568 |
govind |
82 |
private static final Logger LOGGER = LogManager.getLogger(UserController.class);
|
| 21469 |
amit.gupta |
83 |
|
| 21855 |
amit.gupta |
84 |
@Value("${notifications.api.host}")
|
|
|
85 |
private String nodeHost;
|
| 25366 |
tejbeer |
86 |
|
| 26640 |
amit.gupta |
87 |
@Autowired
|
| 26636 |
amit.gupta |
88 |
private MobileAppSettingsRepository mobileAppSettingsRepository;
|
|
|
89 |
|
| 21855 |
amit.gupta |
90 |
@Value("${notifications.api.port}")
|
|
|
91 |
private int nodePort;
|
|
|
92 |
|
| 21414 |
kshitij.so |
93 |
@Value("${admin.token}")
|
|
|
94 |
private String validAdminToken;
|
| 21469 |
amit.gupta |
95 |
|
| 21278 |
ashik.ali |
96 |
@Autowired
|
| 22873 |
ashik.ali |
97 |
private UserRepository userRepository;
|
| 25366 |
tejbeer |
98 |
|
| 22355 |
ashik.ali |
99 |
@Autowired
|
| 22873 |
ashik.ali |
100 |
private com.spice.profitmandi.dao.repository.user.UserRepository userUserRepository;
|
| 21469 |
amit.gupta |
101 |
|
| 21278 |
ashik.ali |
102 |
@Autowired
|
| 22873 |
ashik.ali |
103 |
private RetailerRepository retailerRepository;
|
| 21485 |
amit.gupta |
104 |
|
|
|
105 |
@Autowired
|
| 22873 |
ashik.ali |
106 |
private UserRoleRepository userRoleRepository;
|
| 21469 |
amit.gupta |
107 |
|
| 29892 |
tejbeer |
108 |
@Autowired
|
| 25622 |
amit.gupta |
109 |
private PartnerTypeChangeService partnerTypeChangeService;
|
|
|
110 |
|
|
|
111 |
@Autowired
|
| 22873 |
ashik.ali |
112 |
private UserAccountRepository userAccountRepository;
|
| 25366 |
tejbeer |
113 |
|
| 22355 |
ashik.ali |
114 |
@Autowired
|
| 24491 |
amit.gupta |
115 |
private AuthService authService;
|
| 25366 |
tejbeer |
116 |
|
| 24491 |
amit.gupta |
117 |
@Autowired
|
| 22873 |
ashik.ali |
118 |
private AddressRepository addressRepository;
|
| 21469 |
amit.gupta |
119 |
|
| 21426 |
ashik.ali |
120 |
@Autowired
|
| 22873 |
ashik.ali |
121 |
private GoogleLoginProcessor googleLoginProcessor;
|
| 21855 |
amit.gupta |
122 |
|
| 21784 |
amit.gupta |
123 |
@Autowired
|
| 22873 |
ashik.ali |
124 |
private UserService userService;
|
| 25366 |
tejbeer |
125 |
|
| 23786 |
amit.gupta |
126 |
@Autowired
|
| 25619 |
amit.gupta |
127 |
private CsService csService;
|
|
|
128 |
|
|
|
129 |
@Autowired
|
| 23858 |
ashik.ali |
130 |
private RestClient restClient;
|
| 25366 |
tejbeer |
131 |
|
| 23858 |
ashik.ali |
132 |
@Autowired
|
| 23798 |
amit.gupta |
133 |
private RoleManager roleManager;
|
| 25366 |
tejbeer |
134 |
|
| 23786 |
amit.gupta |
135 |
@Autowired
|
|
|
136 |
private RoleRepository roleRepository;
|
| 21469 |
amit.gupta |
137 |
|
| 25366 |
tejbeer |
138 |
@Autowired
|
|
|
139 |
private AuthRepository authRepository;
|
| 26792 |
tejbeer |
140 |
|
| 25366 |
tejbeer |
141 |
@Autowired
|
| 26646 |
amit.gupta |
142 |
private ObjectMapper objectMapper;
|
| 26792 |
tejbeer |
143 |
|
| 26646 |
amit.gupta |
144 |
@Autowired
|
| 25366 |
tejbeer |
145 |
private RetailerService retailerService;
|
|
|
146 |
|
| 25458 |
tejbeer |
147 |
@Autowired
|
|
|
148 |
private RefferalRepository refferalRepository;
|
|
|
149 |
|
|
|
150 |
@Autowired
|
|
|
151 |
private PromoterRepository promoterRepository;
|
|
|
152 |
|
| 26792 |
tejbeer |
153 |
@Autowired
|
|
|
154 |
JavaMailSender mailSender;
|
|
|
155 |
|
| 21469 |
amit.gupta |
156 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_GOOGLE_LOGIN, method = RequestMethod.POST)
|
| 25366 |
tejbeer |
157 |
public ResponseEntity<?> googleLogin(HttpServletRequest request, @RequestBody GoogleLoginRequest googleLoginRequest)
|
| 30295 |
amit.gupta |
158 |
throws Exception {
|
|
|
159 |
String email = googleLoginProcessor.process(googleLoginRequest.getToken());
|
|
|
160 |
return responseSender.ok(getAuthTokenMap(email));
|
| 21277 |
ashik.ali |
161 |
}
|
| 26636 |
amit.gupta |
162 |
|
| 30295 |
amit.gupta |
163 |
private Map<String, Object> getAuthTokenMap(String email) throws Exception {
|
|
|
164 |
String name = authService.getNameByEmailId(email);
|
|
|
165 |
|
|
|
166 |
Map<String, Object> responseMap = new HashMap<>(2);
|
|
|
167 |
LOGGER.info("User Name from getNameByEmailId({}) is {}", email, name);
|
|
|
168 |
if (name != null) {
|
|
|
169 |
User registeredUser = null;
|
|
|
170 |
AuthUser authUser = authRepository.selectByGmailId(email);
|
| 31820 |
amit.gupta |
171 |
if (authUser != null) {
|
| 30295 |
amit.gupta |
172 |
registeredUser = userRepository.selectByEmailId(authUser.getEmailId());
|
| 31820 |
amit.gupta |
173 |
} else if (promoterRepository.selectMappedByEmailId(email) != null) {
|
|
|
174 |
Promoter promoter = promoterRepository.selectMappedByEmailId(email);
|
| 30295 |
amit.gupta |
175 |
int userId = userAccountRepository.selectUserIdByRetailerId(promoter.getRetailerId());
|
|
|
176 |
registeredUser = userRepository.selectById(userId);
|
|
|
177 |
} else if (userRepository.isExistBySecondryEmailId(email)) {
|
|
|
178 |
registeredUser = userRepository.selectBySecondryEmailId(email);
|
|
|
179 |
}
|
|
|
180 |
LOGGER.info("4");
|
|
|
181 |
List<Integer> roleIds = userRoleRepository.selectRoleIdsByUserId(registeredUser.getId());
|
|
|
182 |
String[] roleTypes = new String[roleIds.size()];
|
|
|
183 |
int index = 0;
|
|
|
184 |
for (int roleId : roleIds) {
|
|
|
185 |
roleTypes[index++] = String.valueOf(roleId);
|
|
|
186 |
}
|
|
|
187 |
int retailerId;
|
|
|
188 |
try {
|
|
|
189 |
retailerId = userAccountRepository.selectRetailerIdByUserId(registeredUser.getId());
|
|
|
190 |
} catch (Exception e) {
|
|
|
191 |
Set<Integer> authUserPartnerSet = csService.getAuthUserPartnerIdMapping().get(authUser.getEmailId());
|
|
|
192 |
if (authUserPartnerSet != null && authUserPartnerSet.size() > 0) {
|
|
|
193 |
retailerId = authUserPartnerSet.stream().findFirst().get();
|
|
|
194 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(retailerId);
|
|
|
195 |
retailerId = ProfitMandiConstants.WAREHOUSE_NSSPL_PARTNER_MAP.get(fs.getWarehouseId());
|
|
|
196 |
} else {
|
| 30546 |
tejbeer |
197 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository
|
|
|
198 |
.selectByEmailId(Utils.SYSTEM_PARTNER);
|
| 30295 |
amit.gupta |
199 |
retailerId = user.getId();
|
|
|
200 |
}
|
|
|
201 |
}
|
|
|
202 |
responseMap.put(ProfitMandiConstants.TOKEN,
|
|
|
203 |
JWTUtil.create(email, registeredUser.getId(), retailerId, roleTypes));
|
| 30546 |
tejbeer |
204 |
LOGGER.info("Param value for email, registeredUser.getId(), retailerId, roleTypes are {}, {}, {} and {}",
|
| 30295 |
amit.gupta |
205 |
email, registeredUser.getId(), retailerId, Arrays.asList(roleTypes));
|
|
|
206 |
responseMap.put(ProfitMandiConstants.REGISTERED, true);
|
|
|
207 |
return responseMap;
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
User user = null;
|
|
|
211 |
try {
|
|
|
212 |
user = userRepository.selectByEmailId(email);
|
|
|
213 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
|
|
214 |
|
|
|
215 |
}
|
|
|
216 |
if (user == null) {
|
|
|
217 |
try {
|
|
|
218 |
user = userRepository.selectByEmailId(email);
|
|
|
219 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
|
|
220 |
responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create(email));
|
|
|
221 |
responseMap.put(ProfitMandiConstants.REGISTERED, false);
|
|
|
222 |
}
|
|
|
223 |
} else {
|
|
|
224 |
List<Integer> roleIds = userRoleRepository.selectRoleIdsByUserId(user.getId());
|
|
|
225 |
int retailerId = userAccountRepository.selectRetailerIdByUserId(user.getId());
|
|
|
226 |
String[] roleTypes = new String[roleIds.size()];
|
|
|
227 |
int index = 0;
|
|
|
228 |
for (int roleId : roleIds) {
|
|
|
229 |
roleTypes[index++] = String.valueOf(roleId);
|
|
|
230 |
}
|
|
|
231 |
responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create(user.getId(), retailerId, roleTypes));
|
|
|
232 |
responseMap.put(ProfitMandiConstants.REGISTERED, true);
|
|
|
233 |
}
|
|
|
234 |
|
|
|
235 |
return responseMap;
|
|
|
236 |
}
|
|
|
237 |
|
| 26592 |
amit.gupta |
238 |
@RequestMapping(value = "/store/token/{storeCode}", method = RequestMethod.GET)
|
| 26590 |
amit.gupta |
239 |
public ResponseEntity<?> googleLogin(HttpServletRequest request, @PathVariable String storeCode)
|
|
|
240 |
throws ProfitMandiBusinessException {
|
| 26597 |
amit.gupta |
241 |
LOGGER.info("StoreCode {}", storeCode);
|
| 26590 |
amit.gupta |
242 |
return responseSender.ok(googleLoginProcessor.processStore(storeCode));
|
|
|
243 |
}
|
| 21469 |
amit.gupta |
244 |
|
|
|
245 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_TOKEN_IS_EXPIRED, method = RequestMethod.GET)
|
| 25366 |
tejbeer |
246 |
public ResponseEntity<?> tokenIsExpired(HttpServletRequest request, @RequestParam(name = "token") String token)
|
|
|
247 |
throws ProfitMandiBusinessException {
|
| 21469 |
amit.gupta |
248 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 22930 |
ashik.ali |
249 |
return responseSender.ok(JWTUtil.isExpired(token));
|
| 21282 |
ashik.ali |
250 |
}
|
| 21469 |
amit.gupta |
251 |
|
| 22355 |
ashik.ali |
252 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_DETAIL_BY_TOKEN, method = RequestMethod.GET)
|
| 21469 |
amit.gupta |
253 |
@ApiImplicitParams({
|
| 30546 |
tejbeer |
254 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 21469 |
amit.gupta |
255 |
public ResponseEntity<?> tokenInfo(HttpServletRequest request) throws Throwable {
|
|
|
256 |
Map<String, Object> responseMap = new HashMap<>();
|
|
|
257 |
UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
|
| 30547 |
tejbeer |
258 |
LOGGER.info("userinfo1 {}", userInfo);
|
| 21483 |
amit.gupta |
259 |
User user = null;
|
| 21855 |
amit.gupta |
260 |
if (userInfo.getUserId() > -1) {
|
| 21483 |
amit.gupta |
261 |
user = userRepository.selectById(userInfo.getUserId());
|
| 26533 |
amit.gupta |
262 |
String city = user.getCity();
|
| 30552 |
tejbeer |
263 |
|
| 30560 |
tejbeer |
264 |
if (!(userInfo.getEmail() == null || user.getEmailId().indexOf("@smartdukaan.com") == -1)) {
|
| 24491 |
amit.gupta |
265 |
String userName = null;
|
| 25366 |
tejbeer |
266 |
if (user.getSecondryEmailId() != null && user.getSecondryEmailId().equals(userInfo.getEmail())) {
|
| 30547 |
tejbeer |
267 |
|
| 24491 |
amit.gupta |
268 |
userName = user.getFirstName() + " " + user.getLastName();
|
|
|
269 |
} else {
|
| 28021 |
amit.gupta |
270 |
AuthUser authUser = authRepository.selectByGmailId(userInfo.getEmail());
|
| 30546 |
tejbeer |
271 |
LOGGER.info("authUser {}", authUser);
|
| 29878 |
tejbeer |
272 |
if (authUser == null || !authUser.isActive()) {
|
| 28021 |
amit.gupta |
273 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.NOT_REGISTERED.getValue());
|
|
|
274 |
responseMap.put(ProfitMandiConstants.EMAIL_ID, userInfo.getEmail());
|
|
|
275 |
return responseSender.ok(responseMap);
|
|
|
276 |
}
|
|
|
277 |
userName = authUser.getName();
|
| 24491 |
amit.gupta |
278 |
}
|
|
|
279 |
responseMap.put(ProfitMandiConstants.USER_ID, userInfo.getUserId());
|
|
|
280 |
responseMap.put(ProfitMandiConstants.USER_NAME, userName);
|
|
|
281 |
responseMap.put(ProfitMandiConstants.USER_STATUS, "fofoAssociate");
|
|
|
282 |
responseMap.put(ProfitMandiConstants.EMAIL_ID, userInfo.getEmail());
|
| 26570 |
amit.gupta |
283 |
responseMap.put("storeUrl", "");
|
| 24491 |
amit.gupta |
284 |
return responseSender.ok(responseMap);
|
|
|
285 |
}
|
| 21483 |
amit.gupta |
286 |
} else {
|
|
|
287 |
try {
|
| 30547 |
tejbeer |
288 |
|
|
|
289 |
LOGGER.info("userinfo4 {}", userInfo);
|
| 21483 |
amit.gupta |
290 |
user = userRepository.selectByEmailId(userInfo.getEmail());
|
|
|
291 |
} catch (ProfitMandiBusinessException e1) {
|
|
|
292 |
}
|
| 25366 |
tejbeer |
293 |
if (user == null) {
|
| 23204 |
ashik.ali |
294 |
try {
|
| 30548 |
tejbeer |
295 |
LOGGER.info("userinfo8 {}", userInfo);
|
| 23204 |
ashik.ali |
296 |
user = userRepository.selectBySecondryEmailId(userInfo.getEmail());
|
|
|
297 |
} catch (ProfitMandiBusinessException e1) {
|
|
|
298 |
LOGGER.info("Uneregistered user", userInfo.getEmail());
|
|
|
299 |
}
|
|
|
300 |
}
|
| 21483 |
amit.gupta |
301 |
}
|
|
|
302 |
if (user != null) {
|
| 23858 |
ashik.ali |
303 |
int retailerId = userAccountRepository.selectRetailerIdByUserId(user.getId());
|
| 21491 |
amit.gupta |
304 |
responseMap.put(ProfitMandiConstants.EMAIL_ID, user.getEmailId());
|
| 21526 |
amit.gupta |
305 |
responseMap.put(ProfitMandiConstants.USER_ID, user.getId());
|
| 22017 |
amit.gupta |
306 |
responseMap.put(ProfitMandiConstants.USER_NAME, user.getFirstName() + " " + user.getLastName());
|
| 23786 |
amit.gupta |
307 |
List<Integer> roleIds = userRoleRepository.selectRoleIdsByUserId(user.getId());
|
| 25366 |
tejbeer |
308 |
// LOGGER.info("userRoles {} ", userRoles);
|
| 22032 |
ashik.ali |
309 |
|
|
|
310 |
// generate new token if roles have been updated
|
| 23786 |
amit.gupta |
311 |
if (userInfo.getRoleIds() == null || roleIds.size() != userInfo.getRoleIds().size()) {
|
| 23858 |
ashik.ali |
312 |
String[] roleIdStrings = new String[roleIds.size()];
|
| 22603 |
amit.gupta |
313 |
int index = 0;
|
| 23786 |
amit.gupta |
314 |
for (int roleId : roleIds) {
|
| 23858 |
ashik.ali |
315 |
roleIdStrings[index++] = String.valueOf(roleId);
|
| 22603 |
amit.gupta |
316 |
}
|
| 23858 |
ashik.ali |
317 |
String newToken = JWTUtil.create(user.getId(), retailerId, roleIdStrings);
|
| 21483 |
amit.gupta |
318 |
responseMap.put("newAuthToken", newToken);
|
|
|
319 |
}
|
| 23858 |
ashik.ali |
320 |
// if user is retailer
|
| 23786 |
amit.gupta |
321 |
Set<Integer> roleIdsSet = new HashSet<Integer>(roleIds);
|
| 23858 |
ashik.ali |
322 |
if (roleManager.isRetailer(roleIdsSet)) {
|
| 22032 |
ashik.ali |
323 |
UserCart uc = userAccountRepository.getUserCart(userInfo.getUserId());
|
|
|
324 |
Retailer retailer = retailerRepository.selectById(uc.getUserId());
|
| 22370 |
amit.gupta |
325 |
com.spice.profitmandi.dao.entity.user.User saholicUser = userUserRepository.selectById(uc.getUserId());
|
| 25366 |
tejbeer |
326 |
if (saholicUser.getAddressId() != null) {
|
| 22370 |
amit.gupta |
327 |
Address address = addressRepository.selectById(saholicUser.getAddressId());
|
|
|
328 |
responseMap.put(ProfitMandiConstants.ADDRESS, address);
|
|
|
329 |
}
|
| 21485 |
amit.gupta |
330 |
// if retailer is activated 1 then verified retailer
|
|
|
331 |
// else if migrated is 1 then old retailer
|
| 25366 |
tejbeer |
332 |
// also lets incoporte old process i.e is user is activated then also retailer
|
|
|
333 |
// is verified retailer
|
| 21485 |
amit.gupta |
334 |
// else retailer is not verifed
|
| 22497 |
amit.gupta |
335 |
if (retailer.isActive() || user.isActivated()) {
|
| 23798 |
amit.gupta |
336 |
if (roleManager.isPartner(roleIdsSet)) {
|
| 22017 |
amit.gupta |
337 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.FOFO.getValue());
|
| 26533 |
amit.gupta |
338 |
responseMap.put("storeUrl", retailerService.getAllFofoRetailerIdUrlMap().get(uc.getUserId()));
|
| 29011 |
amit.gupta |
339 |
responseMap.put("timelineStatus", this.getTimeLineStatus(uc.getUserId()));
|
| 22017 |
amit.gupta |
340 |
} else {
|
|
|
341 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.VERIFIED_RETAILER.getValue());
|
|
|
342 |
}
|
| 22032 |
ashik.ali |
343 |
} else if (retailer.isMigrated()) {
|
| 21485 |
amit.gupta |
344 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.RETAILER.getValue());
|
| 21469 |
amit.gupta |
345 |
} else {
|
| 21485 |
amit.gupta |
346 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.NOT_VERIFIED_RETAILER.getValue());
|
| 21469 |
amit.gupta |
347 |
}
|
| 23798 |
amit.gupta |
348 |
} else if (roleManager.isUser(roleIdsSet)) {
|
| 22502 |
amit.gupta |
349 |
responseMap.put("userInfo", getRegisteredUserInfo(user));
|
| 21469 |
amit.gupta |
350 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.REGISTERED.getValue());
|
| 22032 |
ashik.ali |
351 |
}
|
| 21491 |
amit.gupta |
352 |
} else {
|
|
|
353 |
responseMap.put(ProfitMandiConstants.USER_STATUS, UserStatus.NOT_REGISTERED.getValue());
|
|
|
354 |
responseMap.put(ProfitMandiConstants.EMAIL_ID, userInfo.getEmail());
|
| 21469 |
amit.gupta |
355 |
}
|
| 22032 |
ashik.ali |
356 |
|
| 21469 |
amit.gupta |
357 |
return responseSender.ok(responseMap);
|
|
|
358 |
}
|
| 25366 |
tejbeer |
359 |
|
| 29011 |
amit.gupta |
360 |
@Autowired
|
|
|
361 |
FofoStoreRepository fofoStoreRepository;
|
|
|
362 |
@Autowired
|
|
|
363 |
PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
|
|
|
364 |
@Autowired
|
|
|
365 |
StoreTimelineTatService storeTimelineTatService;
|
| 29878 |
tejbeer |
366 |
|
| 29011 |
amit.gupta |
367 |
private boolean getTimeLineStatus(int fofoId) throws ProfitMandiBusinessException {
|
|
|
368 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(fofoId);
|
|
|
369 |
PartnerOnBoardingPanel partnerOnBoardingPanel = partnerOnBoardingPanelRepository.selectByCode(fs.getCode());
|
|
|
370 |
boolean status = true;
|
|
|
371 |
if (partnerOnBoardingPanel != null) {
|
|
|
372 |
|
|
|
373 |
status = storeTimelineTatService.getTimelineCompleted(partnerOnBoardingPanel.getId());
|
|
|
374 |
}
|
|
|
375 |
|
|
|
376 |
LOGGER.info("status" + status);
|
|
|
377 |
return status;
|
|
|
378 |
}
|
|
|
379 |
|
| 22502 |
amit.gupta |
380 |
private RegisteredUserInfo getRegisteredUserInfo(User user) throws Throwable {
|
| 22492 |
amit.gupta |
381 |
RegisteredUserInfo ri = new RegisteredUserInfo();
|
|
|
382 |
ri.setCity(user.getCity());
|
|
|
383 |
ri.setFirstName(user.getFirstName());
|
|
|
384 |
ri.setLastName(user.getLastName());
|
| 22493 |
amit.gupta |
385 |
ri.setPhone(user.getMobileNumber());
|
| 22492 |
amit.gupta |
386 |
ri.setPinCode(user.getPinCode());
|
| 22845 |
amit.gupta |
387 |
ri.setState(user.getState());
|
| 22492 |
amit.gupta |
388 |
return ri;
|
|
|
389 |
}
|
| 21469 |
amit.gupta |
390 |
|
|
|
391 |
@RequestMapping(value = ProfitMandiConstants.URL_USER, method = RequestMethod.POST)
|
| 21501 |
amit.gupta |
392 |
@ApiImplicitParams({
|
| 30546 |
tejbeer |
393 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 22032 |
ashik.ali |
394 |
public ResponseEntity<?> createUser(HttpServletRequest request, @RequestBody UserRequest userRequest)
|
| 22930 |
ashik.ali |
395 |
throws ProfitMandiBusinessException {
|
| 21469 |
amit.gupta |
396 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 21368 |
kshitij.so |
397 |
User user = new User();
|
|
|
398 |
user.setFirstName(userRequest.getFirstName());
|
|
|
399 |
user.setLastName(userRequest.getLastName());
|
|
|
400 |
user.setCity(userRequest.getCity());
|
|
|
401 |
user.setPinCode(Integer.valueOf(userRequest.getPinCode()));
|
| 22845 |
amit.gupta |
402 |
user.setState(userRequest.getState());
|
| 21708 |
amit.gupta |
403 |
user.setMobileNumber(userRequest.getMobieNumber());
|
| 21368 |
kshitij.so |
404 |
user.setEmailId(userRequest.getEmailId());
|
|
|
405 |
user.setUsername("");
|
|
|
406 |
user.setPassword("");
|
|
|
407 |
user.setMobile_verified(false);
|
|
|
408 |
user.setReferral_url("");
|
|
|
409 |
user.setGroup_id(1);
|
| 22504 |
amit.gupta |
410 |
user.setStatus(1);
|
| 21368 |
kshitij.so |
411 |
user.setActivated(false);
|
| 21501 |
amit.gupta |
412 |
user.setCreateTimestamp(LocalDateTime.now());
|
|
|
413 |
user.setUpdateTimestamp(LocalDateTime.now());
|
| 22930 |
ashik.ali |
414 |
userRepository.persist(user);
|
| 23858 |
ashik.ali |
415 |
Role role = roleRepository.selectByName(RoleType.USER.toString());
|
| 22930 |
ashik.ali |
416 |
UserRole userRole = new UserRole();
|
| 23858 |
ashik.ali |
417 |
userRole.setRoleId(role.getId());
|
| 22930 |
ashik.ali |
418 |
userRole.setUserId(user.getId());
|
|
|
419 |
userRoleRepository.persist(userRole);
|
|
|
420 |
return responseSender.ok(ResponseCodeHolder.getMessage("USR_OK_1000"));
|
| 25366 |
tejbeer |
421 |
|
| 21278 |
ashik.ali |
422 |
}
|
| 21469 |
amit.gupta |
423 |
|
|
|
424 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ID, method = RequestMethod.GET)
|
| 25366 |
tejbeer |
425 |
public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id)
|
|
|
426 |
throws ProfitMandiBusinessException {
|
| 21469 |
amit.gupta |
427 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 22930 |
ashik.ali |
428 |
return responseSender.ok(userRepository.selectById(id));
|
| 21248 |
ashik.ali |
429 |
}
|
| 21469 |
amit.gupta |
430 |
|
|
|
431 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_MOBILE_NUMBER, method = RequestMethod.GET)
|
|
|
432 |
public ResponseEntity<?> getByMobileNumber(HttpServletRequest request,
|
| 30546 |
tejbeer |
433 |
@RequestParam(name = "mobileNumber") String mobileNumber) throws ProfitMandiBusinessException {
|
| 21469 |
amit.gupta |
434 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 22930 |
ashik.ali |
435 |
return responseSender.ok(userRepository.selectByMobileNumber(mobileNumber));
|
| 21248 |
ashik.ali |
436 |
}
|
| 21469 |
amit.gupta |
437 |
|
| 21784 |
amit.gupta |
438 |
@ApiImplicitParams({
|
| 30546 |
tejbeer |
439 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 21501 |
amit.gupta |
440 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ACTIVATE, method = RequestMethod.POST)
|
|
|
441 |
public ResponseEntity<?> activateUser(HttpServletRequest request,
|
| 30546 |
tejbeer |
442 |
@RequestParam(name = "activationCode") String activationCode) throws Throwable {
|
| 21855 |
amit.gupta |
443 |
int userId = (int) request.getAttribute("userId");
|
| 21784 |
amit.gupta |
444 |
UserCart uc = userAccountRepository.getUserCart(userId);
|
|
|
445 |
return responseSender.ok(userService.updateActivation(userId, uc.getUserId(), activationCode));
|
|
|
446 |
}
|
| 21855 |
amit.gupta |
447 |
|
| 25458 |
tejbeer |
448 |
/*
|
|
|
449 |
* @ApiImplicitParams({
|
| 30295 |
amit.gupta |
450 |
*
|
| 25458 |
tejbeer |
451 |
* @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true,
|
|
|
452 |
* dataType = "string", paramType = "header") })
|
| 30295 |
amit.gupta |
453 |
*
|
| 25458 |
tejbeer |
454 |
* @RequestMapping(value = ProfitMandiConstants.URL_USER_NOTIFICATIONS, method =
|
|
|
455 |
* RequestMethod.GET) public ResponseEntity<?>
|
|
|
456 |
* getNofitications(HttpServletRequest request,
|
| 30295 |
amit.gupta |
457 |
*
|
| 25458 |
tejbeer |
458 |
* @RequestParam(name = "androidId") String androidId, @RequestParam(name =
|
|
|
459 |
* "pageNumber") int pageNumber,
|
| 30295 |
amit.gupta |
460 |
*
|
| 25458 |
tejbeer |
461 |
* @RequestParam(name = "pageSize") int pageSize) throws
|
|
|
462 |
* ProfitMandiBusinessException { int userId = (int)
|
|
|
463 |
* request.getAttribute("userId"); String restResponse = null; Map<String,
|
|
|
464 |
* String> params = new HashMap<>();
|
| 30295 |
amit.gupta |
465 |
*
|
| 25458 |
tejbeer |
466 |
* String uri = "/getAllNotifications"; params.put("user_id", userId + "");
|
|
|
467 |
* params.put("android_id", androidId); params.put("limit", pageSize + "");
|
|
|
468 |
* params.put("offset", "" + ((pageNumber - 1) * pageSize)); try { restResponse
|
|
|
469 |
* = restClient.get(SchemeType.HTTP, nodeHost, nodePort, uri, params); } catch
|
|
|
470 |
* (HttpHostConnectException e) { throw new ProfitMandiBusinessException("", "",
|
|
|
471 |
* "Could not Connect to host"); }
|
| 30295 |
amit.gupta |
472 |
*
|
| 25458 |
tejbeer |
473 |
* JsonArray result_json = Json.parse(restResponse).asArray();
|
| 30295 |
amit.gupta |
474 |
*
|
| 25458 |
tejbeer |
475 |
* List<Notification> notifications = new ArrayList<>();
|
| 30295 |
amit.gupta |
476 |
*
|
| 25458 |
tejbeer |
477 |
* for (JsonValue j : result_json) {
|
|
|
478 |
* notifications.add(toNotifiaction(j.asObject())); }
|
| 30295 |
amit.gupta |
479 |
*
|
| 25458 |
tejbeer |
480 |
* return responseSender.ok(notifications); }
|
| 30295 |
amit.gupta |
481 |
*
|
| 25458 |
tejbeer |
482 |
* private Notification toNotifiaction(JsonObject jsonObject) { Notification n =
|
|
|
483 |
* (Notification) (new Gson().fromJson(jsonObject.toString(),
|
|
|
484 |
* Notification.class)); if (n.getStatus().equals("opened") ||
|
|
|
485 |
* n.getStatus().equals("referrer") || n.getStatus().equals("seen")) {
|
|
|
486 |
* n.setSeen(true); } return n; }
|
|
|
487 |
*/
|
| 21855 |
amit.gupta |
488 |
|
| 21426 |
ashik.ali |
489 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_IS_EXIST_MOBILE_NUMBER, method = RequestMethod.GET)
|
| 21469 |
amit.gupta |
490 |
public ResponseEntity<?> isMobileNumberExist(HttpServletRequest request,
|
| 30546 |
tejbeer |
491 |
@RequestParam(name = "mobileNumber") String mobileNumber) {
|
| 21469 |
amit.gupta |
492 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 21448 |
ashik.ali |
493 |
return responseSender.ok(userRepository.isExistByMobileNumber(mobileNumber));
|
| 21426 |
ashik.ali |
494 |
}
|
| 21469 |
amit.gupta |
495 |
|
|
|
496 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_EMAIL_ID, method = RequestMethod.GET)
|
| 25366 |
tejbeer |
497 |
public ResponseEntity<?> getByEmailId(HttpServletRequest request, @RequestParam(name = "emailId") String emailId)
|
|
|
498 |
throws ProfitMandiBusinessException {
|
| 21469 |
amit.gupta |
499 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 23204 |
ashik.ali |
500 |
User user = null;
|
| 25366 |
tejbeer |
501 |
try {
|
| 23204 |
ashik.ali |
502 |
user = userRepository.selectByEmailId(emailId);
|
| 25366 |
tejbeer |
503 |
} catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
| 23204 |
ashik.ali |
504 |
user = userRepository.selectBySecondryEmailId(emailId);
|
|
|
505 |
}
|
|
|
506 |
return responseSender.ok(user);
|
| 21248 |
ashik.ali |
507 |
}
|
| 21469 |
amit.gupta |
508 |
|
|
|
509 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_ROLE_ALL, method = RequestMethod.GET)
|
|
|
510 |
public ResponseEntity<?> getAllRoles(HttpServletRequest request, @RequestParam(name = "id") int id) {
|
|
|
511 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 21448 |
ashik.ali |
512 |
return responseSender.ok(userRoleRepository.selectRolesByUserId(id));
|
| 21248 |
ashik.ali |
513 |
}
|
| 25366 |
tejbeer |
514 |
|
| 23204 |
ashik.ali |
515 |
@ApiImplicitParams({
|
| 30546 |
tejbeer |
516 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 23204 |
ashik.ali |
517 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_SECONDRY_EMAIL_ID_AND_FOFO_STORE_CODE, method = RequestMethod.GET)
|
| 25366 |
tejbeer |
518 |
public ResponseEntity<?> getSecondryEmailAndStoreCode(HttpServletRequest request)
|
|
|
519 |
throws ProfitMandiBusinessException {
|
| 23204 |
ashik.ali |
520 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
|
|
521 |
int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
|
|
|
522 |
return responseSender.ok(userService.getEmailsAndFofoStoreCodeByUserId(userId));
|
|
|
523 |
}
|
| 25366 |
tejbeer |
524 |
|
| 23204 |
ashik.ali |
525 |
@ApiImplicitParams({
|
| 30546 |
tejbeer |
526 |
@ApiImplicitParam(name = "Auth-Token", value = "-Token", required = true, dataType = "string", paramType = "header") })
|
| 23858 |
ashik.ali |
527 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_SECONDRY_EMAIL_ID, method = RequestMethod.PUT)
|
| 23204 |
ashik.ali |
528 |
public ResponseEntity<?> updateSecondryEmailId(HttpServletRequest request,
|
| 30546 |
tejbeer |
529 |
@RequestParam(name = ProfitMandiConstants.SECONDRY_EMAIL_ID) String secondryEmailId) throws Throwable {
|
| 25366 |
tejbeer |
530 |
int userId = (int) request.getAttribute("userId");
|
|
|
531 |
User user = userRepository.selectById(userId);
|
|
|
532 |
user.setSecondryEmailId(secondryEmailId);
|
|
|
533 |
userRepository.persist(user);
|
|
|
534 |
return responseSender.ok(ResponseCodeHolder.getMessage("USR_OK_1001"));
|
|
|
535 |
}
|
| 21414 |
kshitij.so |
536 |
|
|
|
537 |
@RequestMapping(value = ProfitMandiConstants.URL_ADMIN_TOKEN, method = RequestMethod.POST)
|
| 21469 |
amit.gupta |
538 |
public ResponseEntity<?> getAdminToken(HttpServletRequest request,
|
| 30546 |
tejbeer |
539 |
@RequestParam(name = "adminToken") String adminToken, @RequestParam(name = "emailId") String emailId)
|
|
|
540 |
throws Exception {
|
| 21469 |
amit.gupta |
541 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
|
|
542 |
if (!adminToken.equals(validAdminToken)) {
|
| 22930 |
ashik.ali |
543 |
return responseSender.forbidden(null);
|
| 21414 |
kshitij.so |
544 |
}
|
| 21469 |
amit.gupta |
545 |
|
| 30295 |
amit.gupta |
546 |
return responseSender.ok(this.getAuthTokenMap(emailId));
|
| 25366 |
tejbeer |
547 |
|
| 21414 |
kshitij.so |
548 |
}
|
| 25366 |
tejbeer |
549 |
|
| 26667 |
amit.gupta |
550 |
@RequestMapping(value = "/mobileappsettings")
|
| 25366 |
tejbeer |
551 |
public ResponseEntity<?> mobileAppSettings(HttpServletRequest request, @RequestParam(name = "t") int timestamp,
|
| 30546 |
tejbeer |
552 |
@RequestParam(name = "imeinumber") String imeinumber)
|
| 25366 |
tejbeer |
553 |
throws ProfitMandiBusinessException, ClientProtocolException, IOException {
|
| 26644 |
amit.gupta |
554 |
|
|
|
555 |
final String uri = "http://192.168.158.89/mobileappsettings?t=" + timestamp + "&imeinumber=" + imeinumber;
|
|
|
556 |
final String BASIC_AUTH = "Basic " + Base64.getEncoder().encodeToString("dtr:dtr18Feb2015".getBytes());
|
|
|
557 |
Map<String, String> headers = new HashMap<>();
|
|
|
558 |
Map<String, String> params = new HashMap<>();
|
|
|
559 |
headers.put("Authorization", BASIC_AUTH);
|
| 29878 |
tejbeer |
560 |
if (timestamp == 0) {
|
| 26870 |
amit.gupta |
561 |
return responseSender.ok(OrderController.APP_SETTINGS);
|
|
|
562 |
} else {
|
|
|
563 |
return responseSender.ok(OrderController.APP_SETTINGS_BLANK);
|
|
|
564 |
}
|
| 25300 |
tejbeer |
565 |
}
|
| 26792 |
tejbeer |
566 |
|
| 26645 |
amit.gupta |
567 |
@RequestMapping(value = "/mobileappsettings1", method = RequestMethod.POST)
|
|
|
568 |
public ResponseEntity<?> mobileAppSettings1(HttpServletRequest request, @RequestParam(name = "t") int timestamp,
|
| 30546 |
tejbeer |
569 |
@RequestParam(name = "imeinumber") String imeinumber)
|
| 26792 |
tejbeer |
570 |
throws ProfitMandiBusinessException, ClientProtocolException, IOException {
|
| 26645 |
amit.gupta |
571 |
LocalDateTime settingsLastUpdated = LocalDateTime.ofEpochSecond(timestamp, 0, ZoneOffset.ofHoursMinutes(5, 30));
|
|
|
572 |
List<MobileAppSetting> mobileAppSettings = mobileAppSettingsRepository.getSettingAftera(settingsLastUpdated);
|
| 26792 |
tejbeer |
573 |
|
| 26645 |
amit.gupta |
574 |
List<MobileAppSettingsWrapper> mobileSettingsWrappersList = mobileAppSettings.stream()
|
|
|
575 |
.map(x -> new MobileAppSettingsWrapper(x)).collect(Collectors.toList());
|
|
|
576 |
SettingsWrapper wrapper = new SettingsWrapper(mobileSettingsWrappersList);
|
| 26792 |
tejbeer |
577 |
|
| 26645 |
amit.gupta |
578 |
LOGGER.info("Wrapper {}", wrapper);
|
| 26646 |
amit.gupta |
579 |
return responseSender.ok(objectMapper.writeValueAsString(wrapper));
|
| 26645 |
amit.gupta |
580 |
}
|
| 22032 |
ashik.ali |
581 |
|
| 25366 |
tejbeer |
582 |
@RequestMapping(value = "/getPartners", method = RequestMethod.GET)
|
|
|
583 |
@ApiImplicitParams({
|
| 30546 |
tejbeer |
584 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 25366 |
tejbeer |
585 |
public ResponseEntity<?> getPartners(HttpServletRequest request, @RequestParam(name = "gmailId") String gmailId,
|
| 30546 |
tejbeer |
586 |
@RequestParam(value = "offset") int offset, @RequestParam(value = "limit") int limit)
|
| 25366 |
tejbeer |
587 |
throws ProfitMandiBusinessException {
|
|
|
588 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
|
|
589 |
|
| 25619 |
amit.gupta |
590 |
Map<String, Set<String>> storeGuyMap = csService.getAuthUserPartnerEmailMapping();
|
| 25366 |
tejbeer |
591 |
|
| 25619 |
amit.gupta |
592 |
Set<String> emails = storeGuyMap.get(authUser.getEmailId().toLowerCase());
|
| 25366 |
tejbeer |
593 |
LOGGER.info("emails" + emails);
|
| 25619 |
amit.gupta |
594 |
List<User> users = userRepository.selectAllByEmails(new ArrayList<>(emails), offset, limit);
|
| 25366 |
tejbeer |
595 |
List<Partner> partners = new ArrayList<>();
|
|
|
596 |
for (User user : users) {
|
| 25458 |
tejbeer |
597 |
|
| 25366 |
tejbeer |
598 |
UserAccount uc = userAccountRepository.selectSaholicByUserId(user.getId());
|
| 25458 |
tejbeer |
599 |
com.spice.profitmandi.dao.entity.user.User userInfo = userUserRepository.selectById(uc.getAccountKey());
|
| 25366 |
tejbeer |
600 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(userInfo.getId());
|
|
|
601 |
|
|
|
602 |
Partner partner = new Partner();
|
|
|
603 |
partner.setBusinessName(customRetailer.getBusinessName());
|
|
|
604 |
partner.setPartnerId(customRetailer.getPartnerId());
|
|
|
605 |
partner.setCartId(customRetailer.getCartId());
|
|
|
606 |
partner.setEmail(customRetailer.getEmail());
|
|
|
607 |
partner.setGstNumber(customRetailer.getGstNumber());
|
|
|
608 |
partner.setDisplayName(customRetailer.getDisplayName());
|
|
|
609 |
partner.setCity(customRetailer.getAddress().getCity());
|
|
|
610 |
partner.setUserId(user.getId());
|
|
|
611 |
partners.add(partner);
|
|
|
612 |
}
|
|
|
613 |
LOGGER.info("partners" + partners);
|
|
|
614 |
return responseSender.ok(partners);
|
|
|
615 |
}
|
|
|
616 |
|
| 25458 |
tejbeer |
617 |
@RequestMapping(value = "/user/refferal", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
618 |
@ApiImplicitParams({
|
| 30546 |
tejbeer |
619 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 25458 |
tejbeer |
620 |
public ResponseEntity<?> RefferalUser(HttpServletRequest request,
|
| 30546 |
tejbeer |
621 |
@RequestBody CreateRefferalRequest createRefferalRequest) throws Exception {
|
| 25458 |
tejbeer |
622 |
Refferal refferal = new Refferal();
|
|
|
623 |
refferal.setFirstName(createRefferalRequest.getFirstName());
|
|
|
624 |
refferal.setLastName(createRefferalRequest.getLastName());
|
|
|
625 |
refferal.setMobile(createRefferalRequest.getMobile());
|
|
|
626 |
refferal.setState(createRefferalRequest.getState());
|
|
|
627 |
refferal.setCity(createRefferalRequest.getCity());
|
|
|
628 |
refferal.setCreatedTimestamp(LocalDateTime.now());
|
|
|
629 |
refferal.setUpdatedTimestamp(LocalDateTime.now());
|
| 25496 |
tejbeer |
630 |
refferal.setStatus(RefferalStatus.pending);
|
| 25458 |
tejbeer |
631 |
if (createRefferalRequest.isFofoAssociate()) {
|
|
|
632 |
AuthUser authUser = authRepository.selectByGmailId(createRefferalRequest.getReffereeEmail());
|
| 25483 |
tejbeer |
633 |
if (authUser == null) {
|
| 25458 |
tejbeer |
634 |
Promoter promoter = promoterRepository.selectByEmailId(createRefferalRequest.getReffereeEmail());
|
|
|
635 |
refferal.setRefereeName(promoter.getName());
|
| 25483 |
tejbeer |
636 |
refferal.setRefereeEmail(promoter.getEmail());
|
| 25458 |
tejbeer |
637 |
refferal.setRefereeMobile(promoter.getMobile());
|
|
|
638 |
} else {
|
|
|
639 |
refferal.setRefereeName(authUser.getFirstName());
|
| 25483 |
tejbeer |
640 |
refferal.setRefereeEmail(authUser.getGmailId());
|
| 25458 |
tejbeer |
641 |
refferal.setRefereeMobile(authUser.getMobileNumber());
|
|
|
642 |
}
|
|
|
643 |
} else {
|
|
|
644 |
User user = userRepository.selectByEmailId(createRefferalRequest.getReffereeEmail());
|
|
|
645 |
refferal.setRefereeName(user.getFirstName());
|
| 25483 |
tejbeer |
646 |
refferal.setRefereeEmail(user.getEmailId());
|
| 25458 |
tejbeer |
647 |
refferal.setRefereeMobile(user.getMobileNumber());
|
|
|
648 |
}
|
|
|
649 |
|
|
|
650 |
refferalRepository.persist(refferal);
|
| 29892 |
tejbeer |
651 |
|
|
|
652 |
List<PartnerOnBoardingPanel> pobs = partnerOnBoardingPanelRepository
|
|
|
653 |
.selectAllByPhoneNumber((Long.parseLong(refferal.getMobile())));
|
|
|
654 |
|
|
|
655 |
if (!pobs.isEmpty()) {
|
|
|
656 |
|
|
|
657 |
List<PartnerOnBoardingStatus> ponbStatus = pobs.stream().map(x -> x.getStatus())
|
|
|
658 |
.collect(Collectors.toList());
|
|
|
659 |
|
|
|
660 |
if (ponbStatus.contains(PartnerOnBoardingStatus.open)) {
|
|
|
661 |
refferal.setStatus(RefferalStatus.rejected);
|
|
|
662 |
refferal.setRejectedReason("This is already a Smartdukaan Partner.");
|
|
|
663 |
} else if (ponbStatus.contains(PartnerOnBoardingStatus.pending)) {
|
|
|
664 |
refferal.setStatus(RefferalStatus.rejected);
|
|
|
665 |
refferal.setRejectedReason("This is already a Smartdukaan Partner.");
|
|
|
666 |
} else {
|
|
|
667 |
this.sendEmailToValidate(refferal);
|
|
|
668 |
}
|
|
|
669 |
|
|
|
670 |
} else {
|
|
|
671 |
|
|
|
672 |
this.sendEmailToValidate(refferal);
|
|
|
673 |
|
|
|
674 |
}
|
|
|
675 |
return responseSender.ok(true);
|
|
|
676 |
}
|
|
|
677 |
|
|
|
678 |
private void sendEmailToValidate(Refferal refferal) throws MessagingException, UnsupportedEncodingException {
|
|
|
679 |
|
| 26792 |
tejbeer |
680 |
String subject = "Referral Validate Request for " + refferal.getRefereeEmail();
|
|
|
681 |
String messageText = this.getMessageForReferral(refferal);
|
|
|
682 |
MimeMessage message = mailSender.createMimeMessage();
|
|
|
683 |
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
| 30546 |
tejbeer |
684 |
String[] email = { "kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "sm@smartdukaan.com" };
|
| 26792 |
tejbeer |
685 |
helper.setSubject(subject);
|
|
|
686 |
helper.setText(messageText, true);
|
|
|
687 |
helper.setTo(email);
|
|
|
688 |
InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smartdukaan Alerts");
|
|
|
689 |
helper.setFrom(senderAddress);
|
|
|
690 |
mailSender.send(message);
|
|
|
691 |
|
| 25458 |
tejbeer |
692 |
}
|
| 25488 |
tejbeer |
693 |
|
| 26792 |
tejbeer |
694 |
private String getMessageForReferral(Refferal referral) {
|
|
|
695 |
|
|
|
696 |
StringBuilder sb = new StringBuilder();
|
|
|
697 |
sb.append("<html><body><p>Alert</p><p> Referral Requests:-</p>"
|
|
|
698 |
+ "<br/><table style='border:1px solid black ;padding: 5px';>");
|
|
|
699 |
sb.append("<tbody>\n" + " <tr>\n"
|
|
|
700 |
+ " <th style='border:1px solid black;padding: 5px'>RefereeName</th>\n"
|
|
|
701 |
+ " <th style='border:1px solid black;padding: 5px'>Referee Email</th>\n"
|
|
|
702 |
+ " <th style='border:1px solid black;padding: 5px'>Referral Name</th>\n"
|
|
|
703 |
+ " <th style='border:1px solid black;padding: 5px'>Refferal Mobile</th>\n"
|
|
|
704 |
+ " <th style='border:1px solid black;padding: 5px'>city</th>\n"
|
|
|
705 |
+ " <th style='border:1px solid black;padding: 5px'>state</th>\n"
|
|
|
706 |
+ " </tr>");
|
|
|
707 |
|
|
|
708 |
sb.append("<tr>");
|
|
|
709 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + referral.getRefereeName() + "</td>");
|
|
|
710 |
|
|
|
711 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + referral.getRefereeEmail() + "</td>");
|
|
|
712 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + referral.getFirstName() + "</td>");
|
|
|
713 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + referral.getMobile() + "</td>");
|
|
|
714 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + referral.getCity() + "</td>");
|
|
|
715 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + referral.getState() + "</td>");
|
|
|
716 |
|
|
|
717 |
sb.append("</tr>");
|
|
|
718 |
|
|
|
719 |
sb.append("</tbody></table></body></html>");
|
|
|
720 |
|
|
|
721 |
return sb.toString();
|
|
|
722 |
}
|
|
|
723 |
|
| 25488 |
tejbeer |
724 |
@RequestMapping(value = "/user/refferalAmount", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
725 |
@ApiImplicitParams({
|
| 30546 |
tejbeer |
726 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 25488 |
tejbeer |
727 |
public ResponseEntity<?> RefferalAmount(HttpServletRequest request, @RequestParam String refereeEmail)
|
|
|
728 |
throws Exception {
|
|
|
729 |
LocalDateTime ldt = LocalDate.now().atStartOfDay().withDayOfMonth(16);
|
|
|
730 |
DateRangeModel drm = new DateRangeModel();
|
|
|
731 |
List<RefferalEarningModel> refferAmountModel = new ArrayList<RefferalEarningModel>();
|
|
|
732 |
RefferalEarningModel rfm = new RefferalEarningModel();
|
|
|
733 |
long currentMonthEstimaterefferal = 0;
|
|
|
734 |
long currentMonthConfirmedrefferal = 0;
|
|
|
735 |
if (LocalDateTime.now().isBefore(ldt)) {
|
|
|
736 |
List<Refferal> allPendingRefferalBeforeCurrentMonth = refferalRepository
|
|
|
737 |
.selectByEmailIdAndStatusAndbeforeCurrentMonth(refereeEmail, RefferalStatus.pending);
|
|
|
738 |
drm.setStartDate(LocalDateTime.now().minusMonths(1).withDayOfMonth(16));
|
|
|
739 |
drm.setEndDate(LocalDateTime.now().withDayOfMonth(1));
|
|
|
740 |
|
|
|
741 |
List<Refferal> previousMonthapprovedRefferalAfterSixteen = refferalRepository
|
|
|
742 |
.selectByEmailIdAndStatusAndDateRange(refereeEmail, RefferalStatus.approved, drm);
|
|
|
743 |
List<Refferal> previousMonthtransferredRefferalAfterSixteen = refferalRepository
|
|
|
744 |
.selectByEmailIdAndStatusAndDateRange(refereeEmail, RefferalStatus.transferred, drm);
|
|
|
745 |
|
|
|
746 |
drm.setStartDate(LocalDateTime.now().minusMonths(1).withDayOfMonth(1));
|
|
|
747 |
drm.setEndDate(LocalDateTime.now().minusMonths(1).withDayOfMonth(16));
|
|
|
748 |
|
|
|
749 |
List<Refferal> previousMonthapprovedRefferalbeforeSixteen = refferalRepository
|
|
|
750 |
.selectByEmailIdAndStatusAndDateRanges(refereeEmail, RefferalStatus.approved, drm);
|
|
|
751 |
List<Refferal> previousMonthtransferredRefferalbeforeSixteen = refferalRepository
|
|
|
752 |
.selectByEmailIdAndStatusAndDateRanges(refereeEmail, RefferalStatus.transferred, drm);
|
|
|
753 |
long pendingRefferalBeforeCurrentMonth = allPendingRefferalBeforeCurrentMonth.size();
|
|
|
754 |
long previousapprovedRefferalAfterSixteen = previousMonthapprovedRefferalAfterSixteen.size();
|
|
|
755 |
long previoustransferredRefferalAfterSixteen = previousMonthtransferredRefferalAfterSixteen.size();
|
|
|
756 |
long previousapprovedRefferalbeforeSixteen = previousMonthapprovedRefferalbeforeSixteen.size();
|
|
|
757 |
long previoustransferredRefferalbeforeSixteen = previousMonthtransferredRefferalbeforeSixteen.size();
|
|
|
758 |
long previousMonthEstimateRefferal = pendingRefferalBeforeCurrentMonth
|
|
|
759 |
+ previousapprovedRefferalAfterSixteen + previousapprovedRefferalbeforeSixteen;
|
|
|
760 |
long previousMonthConfirmedRefferal = previousapprovedRefferalAfterSixteen
|
|
|
761 |
+ previoustransferredRefferalAfterSixteen + previousapprovedRefferalbeforeSixteen
|
|
|
762 |
+ previoustransferredRefferalbeforeSixteen;
|
| 25490 |
tejbeer |
763 |
rfm = refferAmountEarning(pendingRefferalBeforeCurrentMonth, previousMonthConfirmedRefferal,
|
| 25488 |
tejbeer |
764 |
YearMonth.now().minusMonths(1));
|
|
|
765 |
refferAmountModel.add(rfm);
|
|
|
766 |
LOGGER.info("previousMonthPendingApprovedRefferal" + previousMonthEstimateRefferal);
|
|
|
767 |
LOGGER.info("previousMonthApprovedTransfferedRefferal" + previousMonthConfirmedRefferal);
|
|
|
768 |
|
| 25509 |
tejbeer |
769 |
List<Refferal> pendingofCurrentMonth = refferalRepository
|
|
|
770 |
.selectByEmailIdAndStatusAndBetweenDates(refereeEmail, RefferalStatus.pending, YearMonth.now());
|
| 25488 |
tejbeer |
771 |
List<Refferal> approvedofCurrentMonth = refferalRepository.selectByEmailIdAndStatusAndDatesBetweenTimestamp(
|
|
|
772 |
refereeEmail, RefferalStatus.approved, YearMonth.now());
|
|
|
773 |
List<Refferal> transferredofCurrentMonth = refferalRepository
|
|
|
774 |
.selectByEmailIdAndStatusAndDatesBetweenTimestamp(refereeEmail, RefferalStatus.transferred,
|
|
|
775 |
YearMonth.now());
|
| 25490 |
tejbeer |
776 |
LOGGER.info("pendingofCurrentMonth" + pendingofCurrentMonth);
|
| 25509 |
tejbeer |
777 |
long pendingofCurrentMonthCount = pendingofCurrentMonth.size();
|
| 25488 |
tejbeer |
778 |
currentMonthEstimaterefferal = pendingofCurrentMonth.size() + approvedofCurrentMonth.size();
|
|
|
779 |
currentMonthConfirmedrefferal = approvedofCurrentMonth.size() + transferredofCurrentMonth.size();
|
| 25509 |
tejbeer |
780 |
|
| 25490 |
tejbeer |
781 |
rfm = refferAmountEarning(pendingofCurrentMonthCount, currentMonthConfirmedrefferal, YearMonth.now());
|
| 25488 |
tejbeer |
782 |
|
|
|
783 |
refferAmountModel.add(rfm);
|
|
|
784 |
|
|
|
785 |
} else if (LocalDateTime.now().isAfter(ldt)) {
|
|
|
786 |
drm.setStartDate(LocalDateTime.now().minusMonths(1).withDayOfMonth(1));
|
| 25496 |
tejbeer |
787 |
drm.setEndDate(LocalDateTime.now().minusMonths(1).withDayOfMonth(16));
|
| 25488 |
tejbeer |
788 |
|
|
|
789 |
List<Refferal> previousMonthapprovedRefferalbeforeSixteen = refferalRepository
|
|
|
790 |
.selectByEmailIdAndStatusAndDateRanges(refereeEmail, RefferalStatus.approved, drm);
|
|
|
791 |
List<Refferal> previousMonthtransferredRefferalbeforeSixteen = refferalRepository
|
|
|
792 |
.selectByEmailIdAndStatusAndDateRanges(refereeEmail, RefferalStatus.transferred, drm);
|
|
|
793 |
|
|
|
794 |
drm.setStartDate(LocalDateTime.now().minusMonths(1).withDayOfMonth(16));
|
|
|
795 |
drm.setEndDate(LocalDateTime.now().withDayOfMonth(16));
|
|
|
796 |
|
|
|
797 |
List<Refferal> previousAndcurrentMonthapprovedRefferal = refferalRepository
|
|
|
798 |
.selectByEmailIdAndStatusAndDateRange(refereeEmail, RefferalStatus.approved, drm);
|
|
|
799 |
|
|
|
800 |
LocalDateTime currentMonthdate = LocalDateTime.now().withDayOfMonth(1);
|
|
|
801 |
|
|
|
802 |
List<Refferal> preCurrMonthapproved = previousAndcurrentMonthapprovedRefferal.stream()
|
|
|
803 |
.filter(x -> x.getCreatedTimestamp().isBefore(currentMonthdate)).collect(Collectors.toList());
|
|
|
804 |
List<Refferal> previousAndcurrentMonthtransferredRefferal = refferalRepository
|
|
|
805 |
.selectByEmailIdAndStatusAndDateRange(refereeEmail, RefferalStatus.transferred, drm);
|
|
|
806 |
List<Refferal> preCurrMonthtransferred = previousAndcurrentMonthtransferredRefferal.stream()
|
|
|
807 |
.filter(x -> x.getCreatedTimestamp().isBefore(currentMonthdate)).collect(Collectors.toList());
|
|
|
808 |
|
|
|
809 |
long approvedRefferal = previousMonthapprovedRefferalbeforeSixteen.size()
|
|
|
810 |
+ previousMonthtransferredRefferalbeforeSixteen.size() + preCurrMonthapproved.size()
|
|
|
811 |
+ preCurrMonthtransferred.size();
|
|
|
812 |
rfm = new RefferalEarningModel();
|
| 29878 |
tejbeer |
813 |
rfm.setActualEarning(approvedRefferal * 5000);
|
| 27595 |
tejbeer |
814 |
|
| 25488 |
tejbeer |
815 |
rfm.setYearMonth(YearMonth.now().minusMonths(1));
|
| 25490 |
tejbeer |
816 |
rfm.setPendingRefferal(0);
|
| 25509 |
tejbeer |
817 |
rfm.setApprovedRefferal(approvedRefferal);
|
| 25488 |
tejbeer |
818 |
refferAmountModel.add(rfm);
|
|
|
819 |
List<Refferal> allpendingRefferal = refferalRepository.selectByEmailIdAndStatus(refereeEmail,
|
|
|
820 |
RefferalStatus.pending);
|
|
|
821 |
LOGGER.info("allpendingRefferal" + allpendingRefferal);
|
|
|
822 |
|
|
|
823 |
drm.setStartDate(LocalDateTime.now().withDayOfMonth(16));
|
|
|
824 |
drm.setEndDate(LocalDateTime.now().plusMonths(1).withDayOfMonth(1));
|
|
|
825 |
|
|
|
826 |
List<Refferal> currentMonthapprovedRefferalAfterSixteen = refferalRepository
|
|
|
827 |
.selectByEmailIdAndStatusAndDateRange(refereeEmail, RefferalStatus.approved, drm);
|
|
|
828 |
List<Refferal> currentMonthtransferredRefferalAfterSixteen = refferalRepository
|
|
|
829 |
.selectByEmailIdAndStatusAndDateRange(refereeEmail, RefferalStatus.transferred, drm);
|
|
|
830 |
LOGGER.info("currentMonthapprovedRefferalAfterSixteen" + currentMonthapprovedRefferalAfterSixteen);
|
|
|
831 |
drm.setStartDate(LocalDateTime.now().withDayOfMonth(1));
|
|
|
832 |
drm.setEndDate(LocalDateTime.now().withDayOfMonth(16));
|
|
|
833 |
|
|
|
834 |
List<Refferal> currentMonthapprovedRefferalbeforeSixteen = refferalRepository
|
|
|
835 |
.selectByEmailIdAndStatusAndDateRanges(refereeEmail, RefferalStatus.approved, drm);
|
|
|
836 |
List<Refferal> currentMonthtransferredRefferalbeforeSixteen = refferalRepository
|
|
|
837 |
.selectByEmailIdAndStatusAndDateRanges(refereeEmail, RefferalStatus.transferred, drm);
|
|
|
838 |
LOGGER.info("currentMonthapprovedRefferalbeforeSixteen" + currentMonthapprovedRefferalbeforeSixteen);
|
| 25509 |
tejbeer |
839 |
long pendingrefferalcount = allpendingRefferal.size();
|
| 25488 |
tejbeer |
840 |
currentMonthConfirmedrefferal = currentMonthapprovedRefferalAfterSixteen.size()
|
|
|
841 |
+ currentMonthtransferredRefferalAfterSixteen.size()
|
|
|
842 |
+ currentMonthapprovedRefferalbeforeSixteen.size()
|
|
|
843 |
+ currentMonthtransferredRefferalbeforeSixteen.size();
|
| 25509 |
tejbeer |
844 |
|
|
|
845 |
rfm = refferAmountEarning(pendingrefferalcount, currentMonthConfirmedrefferal, YearMonth.now());
|
| 25488 |
tejbeer |
846 |
refferAmountModel.add(rfm);
|
|
|
847 |
LOGGER.info("currentMonthpendingApprovedrefferal" + currentMonthEstimaterefferal);
|
|
|
848 |
|
|
|
849 |
LOGGER.info("currentMonthapprovedTransferredrefferal" + currentMonthConfirmedrefferal);
|
|
|
850 |
|
|
|
851 |
}
|
|
|
852 |
RefferalEarning re = new RefferalEarning();
|
|
|
853 |
re.setTimestamp(LocalDateTime.now());
|
|
|
854 |
re.setRefferalEarningModel(refferAmountModel);
|
|
|
855 |
return responseSender.ok(re);
|
|
|
856 |
}
|
|
|
857 |
|
| 25490 |
tejbeer |
858 |
private RefferalEarningModel refferAmountEarning(long pendingRefferalValue, long confirmedRefferalValue,
|
| 30546 |
tejbeer |
859 |
YearMonth yearMonth) {
|
| 25488 |
tejbeer |
860 |
RefferalEarningModel rfm = new RefferalEarningModel();
|
|
|
861 |
rfm.setYearMonth(yearMonth);
|
| 25490 |
tejbeer |
862 |
rfm.setPendingRefferal(pendingRefferalValue);
|
|
|
863 |
rfm.setApprovedRefferal(confirmedRefferalValue);
|
| 25509 |
tejbeer |
864 |
long estimateRefferalValue = pendingRefferalValue + confirmedRefferalValue;
|
| 25488 |
tejbeer |
865 |
|
| 29878 |
tejbeer |
866 |
rfm.setMaximumEarning(estimateRefferalValue * 5000);
|
| 27595 |
tejbeer |
867 |
|
| 29878 |
tejbeer |
868 |
rfm.setMinimumEarning(confirmedRefferalValue * 5000);
|
| 27595 |
tejbeer |
869 |
|
| 25488 |
tejbeer |
870 |
return rfm;
|
|
|
871 |
}
|
| 25979 |
tejbeer |
872 |
|
| 29890 |
tejbeer |
873 |
@RequestMapping(value = "/user/getReferals", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
874 |
@ApiImplicitParams({
|
| 30546 |
tejbeer |
875 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 29890 |
tejbeer |
876 |
public ResponseEntity<?> getReferals(HttpServletRequest request, @RequestParam RefferalStatus status)
|
|
|
877 |
throws Exception {
|
|
|
878 |
int userId = (int) request.getAttribute("userId");
|
|
|
879 |
|
|
|
880 |
User user = userRepository.selectById(userId);
|
|
|
881 |
UserCart uc = userAccountRepository.getUserCart(userId);
|
|
|
882 |
|
|
|
883 |
List<Refferal> refferals = refferalRepository.selectByEmailIdAndStatus(user.getEmailId(), status);
|
|
|
884 |
return responseSender.ok(refferals);
|
|
|
885 |
}
|
|
|
886 |
|
| 25622 |
amit.gupta |
887 |
@RequestMapping(value = "/user/partnerTarget", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
888 |
@ApiImplicitParams({
|
| 30546 |
tejbeer |
889 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 25622 |
amit.gupta |
890 |
public ResponseEntity<?> PartnerTarget(HttpServletRequest request) throws Exception {
|
|
|
891 |
int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
|
|
|
892 |
int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
|
|
|
893 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(retailerId, LocalDate.now());
|
| 25979 |
tejbeer |
894 |
|
| 25622 |
amit.gupta |
895 |
return responseSender.ok(partnerType);
|
|
|
896 |
}
|
| 26636 |
amit.gupta |
897 |
|
| 27425 |
tejbeer |
898 |
@RequestMapping(value = "/user/authUser", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
899 |
@ApiImplicitParams({
|
| 30546 |
tejbeer |
900 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 27425 |
tejbeer |
901 |
public ResponseEntity<?> authUserDetail(HttpServletRequest request, @RequestParam int userId) throws Exception {
|
|
|
902 |
User user = userRepository.selectById(userId);
|
|
|
903 |
AuthUser authUser = authRepository.selectByEmailOrMobile(user.getEmailId());
|
|
|
904 |
return responseSender.ok(authUser);
|
|
|
905 |
}
|
|
|
906 |
|
| 21248 |
ashik.ali |
907 |
}
|
| 26636 |
amit.gupta |
908 |
|
|
|
909 |
class MobileAppSettingsWrapper {
|
|
|
910 |
@JsonProperty(value = "Mobileappsetting")
|
|
|
911 |
private MobileAppSetting mobileAppSettings;
|
|
|
912 |
|
|
|
913 |
public MobileAppSettingsWrapper(MobileAppSetting mobileAppSettings) {
|
|
|
914 |
super();
|
|
|
915 |
this.mobileAppSettings = mobileAppSettings;
|
|
|
916 |
}
|
| 26642 |
amit.gupta |
917 |
|
|
|
918 |
public MobileAppSetting getMobileAppSettings() {
|
|
|
919 |
return mobileAppSettings;
|
|
|
920 |
}
|
|
|
921 |
|
|
|
922 |
public void setMobileAppSettings(MobileAppSetting mobileAppSettings) {
|
|
|
923 |
this.mobileAppSettings = mobileAppSettings;
|
|
|
924 |
}
|
| 26643 |
amit.gupta |
925 |
|
|
|
926 |
@Override
|
|
|
927 |
public String toString() {
|
|
|
928 |
return "MobileAppSettingsWrapper [mobileAppSettings=" + mobileAppSettings + "]";
|
|
|
929 |
}
|
| 26644 |
amit.gupta |
930 |
|
| 26636 |
amit.gupta |
931 |
}
|
|
|
932 |
|
|
|
933 |
class SettingsWrapper {
|
|
|
934 |
private List<MobileAppSettingsWrapper> settings;
|
| 26644 |
amit.gupta |
935 |
|
| 26636 |
amit.gupta |
936 |
public SettingsWrapper(List<MobileAppSettingsWrapper> settings) {
|
|
|
937 |
super();
|
|
|
938 |
this.settings = settings;
|
|
|
939 |
}
|
|
|
940 |
|
| 26642 |
amit.gupta |
941 |
@Override
|
|
|
942 |
public String toString() {
|
|
|
943 |
return "SettingsWrapper [settings=" + settings + "]";
|
|
|
944 |
}
|
|
|
945 |
|
|
|
946 |
public List<MobileAppSettingsWrapper> getSettings() {
|
|
|
947 |
return settings;
|
|
|
948 |
}
|
|
|
949 |
|
|
|
950 |
public void setSettings(List<MobileAppSettingsWrapper> settings) {
|
|
|
951 |
this.settings = settings;
|
|
|
952 |
}
|
|
|
953 |
|
| 27425 |
tejbeer |
954 |
}
|