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