| Line 267... |
Line 267... |
| 267 |
|
267 |
|
| 268 |
@SuppressWarnings("unchecked")
|
268 |
@SuppressWarnings("unchecked")
|
| 269 |
@Override
|
269 |
@Override
|
| 270 |
public Map<String, Object> updateRetailerDetails(UpdateRetailerRequest updateRetailerRequest) throws ProfitMandiBusinessException {
|
270 |
public Map<String, Object> updateRetailerDetails(UpdateRetailerRequest updateRetailerRequest) throws ProfitMandiBusinessException {
|
| 271 |
Map<String, Object> map = this.getByEmailIdOrMobileNumber(updateRetailerRequest.getEmailIdOrMobileNumber());
|
271 |
Map<String, Object> map = this.getByEmailIdOrMobileNumber(updateRetailerRequest.getEmailIdOrMobileNumber());
|
| 272 |
User user = (User) map.get("user");
|
272 |
User dtrUser = (User) map.get("user");
|
| 273 |
|
273 |
|
| 274 |
user = this.createUser(user, updateRetailerRequest);
|
274 |
dtrUser = this.createUser(dtrUser, updateRetailerRequest);
|
| 275 |
|
275 |
|
| 276 |
map.put("user", user);
|
276 |
map.put("user", dtrUser);
|
| 277 |
List<UserRole> userRoles = (List<UserRole>) map.get("userRoles");
|
277 |
List<UserRole> userRoles = (List<UserRole>) map.get("userRoles");
|
| 278 |
Role roleUser = roleRepository.selectByName(RoleType.USER.toString());
|
278 |
Role roleUser = roleRepository.selectByName(RoleType.USER.toString());
|
| 279 |
userRoles = this.addRole(userRoles, user.getId(), roleUser.getId());
|
279 |
userRoles = this.addRole(userRoles, dtrUser.getId(), roleUser.getId());
|
| 280 |
Retailer retailer = (Retailer) map.get("retailer");
|
280 |
Retailer retailer = (Retailer) map.get("retailer");
|
| 281 |
retailer = this.updateRetailer(user, retailer, updateRetailerRequest);
|
281 |
retailer = this.updateRetailer(dtrUser, retailer, updateRetailerRequest);
|
| 282 |
|
282 |
|
| 283 |
map.put("retailer", retailer);
|
283 |
map.put("retailer", retailer);
|
| 284 |
|
284 |
|
| 285 |
List<String> retailerBlockBrands = retailerBlockBrandsRepository.selectAllByRetailer(retailer.getId()).stream().map(x -> x.getBlockBrands()).collect(Collectors.toList());
|
285 |
List<String> retailerBlockBrands = retailerBlockBrandsRepository.selectAllByRetailer(retailer.getId()).stream().map(x -> x.getBlockBrands()).collect(Collectors.toList());
|
| 286 |
|
286 |
|
| Line 300... |
Line 300... |
| 300 |
}
|
300 |
}
|
| 301 |
map.put("retailerBlockBrands", retailerBlockBrands);
|
301 |
map.put("retailerBlockBrands", retailerBlockBrands);
|
| 302 |
|
302 |
|
| 303 |
Role roleRetailer = roleRepository.selectByName(RoleType.RETAILER.toString());
|
303 |
Role roleRetailer = roleRepository.selectByName(RoleType.RETAILER.toString());
|
| 304 |
|
304 |
|
| 305 |
userRoles = this.addRole(userRoles, user.getId(), roleRetailer.getId());
|
305 |
userRoles = this.addRole(userRoles, dtrUser.getId(), roleRetailer.getId());
|
| 306 |
|
306 |
|
| 307 |
Role roleFofo = roleRepository.selectByName(RoleType.FOFO.toString());
|
307 |
Role roleFofo = roleRepository.selectByName(RoleType.FOFO.toString());
|
| 308 |
|
308 |
|
| 309 |
if (updateRetailerRequest.isFofo()) {
|
309 |
if (updateRetailerRequest.isFofo()) {
|
| 310 |
userRoles = this.addRole(userRoles, user.getId(), roleFofo.getId());
|
310 |
userRoles = this.addRole(userRoles, dtrUser.getId(), roleFofo.getId());
|
| 311 |
} else {
|
311 |
} else {
|
| 312 |
userRoles = this.removeRole(userRoles, user.getId(), roleFofo.getId());
|
312 |
userRoles = this.removeRole(userRoles, dtrUser.getId(), roleFofo.getId());
|
| 313 |
}
|
313 |
}
|
| 314 |
map.put("fofoRole", this.containsRoleType(userRoles, roleFofo.getId()));
|
314 |
map.put("fofoRole", this.containsRoleType(userRoles, roleFofo.getId()));
|
| 315 |
|
315 |
|
| 316 |
if (this.containsRoleType(userRoles, roleFofo.getId())) {
|
316 |
if (this.containsRoleType(userRoles, roleFofo.getId())) {
|
| 317 |
this.createDefaultPaymentOption(retailer.getId());
|
317 |
this.createDefaultPaymentOption(retailer.getId());
|
| Line 328... |
Line 328... |
| 328 |
FofoStore fofoStore = this.createFofoStoreCodeByRetailerId(retailer.getId(), updateRetailerRequest.getDistrictName(), retailerAddress.getState(), updateRetailerRequest);
|
328 |
FofoStore fofoStore = this.createFofoStoreCodeByRetailerId(retailer.getId(), updateRetailerRequest.getDistrictName(), retailerAddress.getState(), updateRetailerRequest);
|
| 329 |
map.put("fofoStore", fofoStore);
|
329 |
map.put("fofoStore", fofoStore);
|
| 330 |
fofoStore.setActive(updateRetailerRequest.isActive());
|
330 |
fofoStore.setActive(updateRetailerRequest.isActive());
|
| 331 |
}
|
331 |
}
|
| 332 |
|
332 |
|
| 333 |
this.createPrivateDealUser(user, updateRetailerRequest.isFofo(), updateRetailerRequest.getGstNumber(), retailer, retailerAddress.getId());
|
333 |
this.createPrivateDealUser(dtrUser, updateRetailerRequest.isFofo(), updateRetailerRequest.getGstNumber(), retailer, retailerAddress.getId());
|
| 334 |
map.put("gstNumber", updateRetailerRequest.getGstNumber());
|
334 |
map.put("gstNumber", updateRetailerRequest.getGstNumber());
|
| 335 |
this.updateSaholicUser(retailer.getId(), retailerAddress.getId());
|
335 |
this.updateSaholicUser(retailer.getId(), retailerAddress.getId());
|
| 336 |
|
336 |
|
| 337 |
List<Shop> shops = (List<Shop>) map.get("shops");
|
337 |
List<Shop> shops = (List<Shop>) map.get("shops");
|
| 338 |
if (shops == null) {
|
338 |
if (shops == null) {
|
| Line 362... |
Line 362... |
| 362 |
fofoPartnerPaymentOptionRepository.persist(fofoPartnerPaymentOption);
|
362 |
fofoPartnerPaymentOptionRepository.persist(fofoPartnerPaymentOption);
|
| 363 |
}
|
363 |
}
|
| 364 |
|
364 |
|
| 365 |
}
|
365 |
}
|
| 366 |
|
366 |
|
| 367 |
private User createUser(User user, UpdateRetailerRequest updateRetailerRequest) {
|
367 |
private User createUser(User user, UpdateRetailerRequest updateRetailerRequest) throws ProfitMandiBusinessException {
|
| - |
|
368 |
User dtrUser = userRepository.selectByMobileNumber(updateRetailerRequest.getUserMobileNumber());
|
| - |
|
369 |
if(dtrUser != null) throw new ProfitMandiBusinessException("Mobile already exist", updateRetailerRequest.getUserMobileNumber(),"");
|
| - |
|
370 |
User dtrUserByEmail = userRepository.selectByMobileNumber(updateRetailerRequest.getUserEmailId());
|
| - |
|
371 |
if(dtrUserByEmail != null) throw new ProfitMandiBusinessException("Email already exist", updateRetailerRequest.getUserEmailId(),"");
|
| - |
|
372 |
|
| - |
|
373 |
|
| 368 |
if (user == null) {
|
374 |
if (user == null) {
|
| 369 |
user = new User();
|
375 |
user = new User();
|
| 370 |
user.setCity("");
|
376 |
user.setCity("");
|
| 371 |
user.setPinCode(0);
|
377 |
user.setPinCode(0);
|
| 372 |
user.setState("");
|
378 |
user.setState("");
|
| Line 375... |
Line 381... |
| 375 |
user.setReferral_url("");
|
381 |
user.setReferral_url("");
|
| 376 |
user.setGroup_id(1);
|
382 |
user.setGroup_id(1);
|
| 377 |
user.setStatus(1);
|
383 |
user.setStatus(1);
|
| 378 |
user.setActivated(true);
|
384 |
user.setActivated(true);
|
| 379 |
user.setCreateTimestamp(LocalDateTime.now());
|
385 |
user.setCreateTimestamp(LocalDateTime.now());
|
| 380 |
user.setEmailId(" ");
|
- |
|
| 381 |
|
- |
|
| 382 |
}
|
386 |
}
|
| 383 |
user.setActivated(updateRetailerRequest.isActive());
|
387 |
user.setActivated(updateRetailerRequest.isActive());
|
| 384 |
user.setFirstName(updateRetailerRequest.getUserFirstName());
|
388 |
user.setFirstName(updateRetailerRequest.getUserFirstName());
|
| 385 |
user.setLastName(updateRetailerRequest.getUserLastName());
|
389 |
user.setLastName(updateRetailerRequest.getUserLastName());
|
| 386 |
user.setMobileNumber(updateRetailerRequest.getUserMobileNumber());
|
390 |
user.setMobileNumber(updateRetailerRequest.getUserMobileNumber());
|
| Line 425... |
Line 429... |
| 425 |
}
|
429 |
}
|
| 426 |
return saholicUser.getId();
|
430 |
return saholicUser.getId();
|
| 427 |
}
|
431 |
}
|
| 428 |
|
432 |
|
| 429 |
private com.spice.profitmandi.dao.entity.user.User createSaholicUser(
|
433 |
private com.spice.profitmandi.dao.entity.user.User createSaholicUser(
|
| 430 |
LoginRequestResponseModel loginRequestResponseModel) {
|
434 |
LoginRequestResponseModel loginRequestResponseModel) {
|
| 431 |
com.spice.profitmandi.dao.entity.user.User saholicUser = null;
|
435 |
com.spice.profitmandi.dao.entity.user.User saholicUser = null;
|
| 432 |
try {
|
436 |
try {
|
| 433 |
saholicUser = userUserRepository.selectByEmailId(loginRequestResponseModel.getEmail());
|
437 |
saholicUser = userUserRepository.selectByEmailId(loginRequestResponseModel.getEmail());
|
| 434 |
saholicUser.setCreateTimestamp(LocalDateTime.now());
|
438 |
saholicUser.setCreateTimestamp(LocalDateTime.now());
|
| 435 |
} catch (ProfitMandiBusinessException e) {
|
439 |
} catch (ProfitMandiBusinessException e) {
|
| Line 1272... |
Line 1276... |
| 1272 |
fofoUser.setEmailId(newEmail);
|
1276 |
fofoUser.setEmailId(newEmail);
|
| 1273 |
thisDtrUser.setEmailId(newEmail);
|
1277 |
thisDtrUser.setEmailId(newEmail);
|
| 1274 |
}
|
1278 |
}
|
| 1275 |
|
1279 |
|
| 1276 |
|
1280 |
|
| 1277 |
|
- |
|
| 1278 |
// @Override
|
1281 |
// @Override
|
| 1279 |
@Cacheable(value = "getContactsByFofoId", cacheManager = "oneDayCacheManager")
|
1282 |
@Cacheable(value = "getContactsByFofoId", cacheManager = "oneDayCacheManager")
|
| 1280 |
public List<RetailerContact> getContactsByFofoId(int fofoId, boolean activeOnly) throws ProfitMandiBusinessException {
|
1283 |
public List<RetailerContact> getContactsByFofoId(int fofoId, boolean activeOnly) throws ProfitMandiBusinessException {
|
| 1281 |
List<RetailerContact> retailerContacts = retailerContactRepository.selectAllByRetailerId(fofoId, activeOnly);
|
1284 |
List<RetailerContact> retailerContacts = retailerContactRepository.selectAllByRetailerId(fofoId, activeOnly);
|
| 1282 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(fofoId);
|
1285 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(fofoId);
|
| 1283 |
RetailerContact retailerContact = new RetailerContact();
|
1286 |
RetailerContact retailerContact = new RetailerContact();
|