| Line 37... |
Line 37... |
| 37 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
37 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
| 38 |
import com.spice.profitmandi.dao.entity.dtr.UserRole;
|
38 |
import com.spice.profitmandi.dao.entity.dtr.UserRole;
|
| 39 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
39 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 40 |
import com.spice.profitmandi.dao.entity.user.Address;
|
40 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 41 |
import com.spice.profitmandi.dao.entity.user.Cart;
|
41 |
import com.spice.profitmandi.dao.entity.user.Cart;
|
| 42 |
import com.spice.profitmandi.dao.entity.user.Counter;
|
- |
|
| 43 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUser;
|
- |
|
| 44 |
import com.spice.profitmandi.dao.entity.user.PrivateDealUserAddressMapping;
|
- |
|
| 45 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
42 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
| 46 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
43 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| 47 |
import com.spice.profitmandi.dao.model.RetailerFofoInterest;
|
44 |
import com.spice.profitmandi.dao.model.RetailerFofoInterest;
|
| 48 |
import com.spice.profitmandi.dao.repository.dtr.BrandRepository;
|
45 |
import com.spice.profitmandi.dao.repository.dtr.BrandRepository;
|
| 49 |
import com.spice.profitmandi.dao.repository.dtr.DistrictMasterRepository;
|
46 |
import com.spice.profitmandi.dao.repository.dtr.DistrictMasterRepository;
|
| Line 60... |
Line 57... |
| 60 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
57 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 61 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
58 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
| 62 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
59 |
import com.spice.profitmandi.dao.repository.dtr.UserRoleRepository;
|
| 63 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
60 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 64 |
import com.spice.profitmandi.dao.repository.user.CartRepository;
|
61 |
import com.spice.profitmandi.dao.repository.user.CartRepository;
|
| 65 |
import com.spice.profitmandi.dao.repository.user.CounterRepository;
|
- |
|
| 66 |
import com.spice.profitmandi.dao.repository.user.PrivateDealUserAddressMappingRepository;
|
- |
|
| 67 |
import com.spice.profitmandi.dao.repository.user.PrivateDealUserRepository;
|
- |
|
| 68 |
import com.spice.profitmandi.service.user.RetailerService;
|
62 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 69 |
import com.spice.profitmandi.web.req.Category;
|
63 |
import com.spice.profitmandi.web.req.Category;
|
| 70 |
import com.spice.profitmandi.web.req.CreateRetailerAddressRequest;
|
64 |
import com.spice.profitmandi.web.req.CreateRetailerAddressRequest;
|
| 71 |
import com.spice.profitmandi.web.req.CreateRetailerRequest;
|
65 |
import com.spice.profitmandi.web.req.CreateRetailerRequest;
|
| 72 |
import com.spice.profitmandi.web.req.RetailerAddBrandRequest;
|
66 |
import com.spice.profitmandi.web.req.RetailerAddBrandRequest;
|
| Line 133... |
Line 127... |
| 133 |
|
127 |
|
| 134 |
@Autowired
|
128 |
@Autowired
|
| 135 |
private RetailerBrandRepository retailerBrandRepository;
|
129 |
private RetailerBrandRepository retailerBrandRepository;
|
| 136 |
|
130 |
|
| 137 |
@Autowired
|
131 |
@Autowired
|
| 138 |
private CounterRepository counterRepository;
|
- |
|
| 139 |
|
- |
|
| 140 |
@Autowired
|
- |
|
| 141 |
private PrivateDealUserRepository privateDealUserRepository;
|
- |
|
| 142 |
|
- |
|
| 143 |
@Autowired
|
- |
|
| 144 |
private PrivateDealUserAddressMappingRepository privateDealUserAddressMappingRepository;
|
- |
|
| 145 |
|
- |
|
| 146 |
@Autowired
|
- |
|
| 147 |
private CartRepository cartRepository;
|
132 |
private CartRepository cartRepository;
|
| 148 |
|
133 |
|
| 149 |
@Autowired
|
134 |
@Autowired
|
| 150 |
private DistrictMasterRepository districtMasterRepository;
|
135 |
private DistrictMasterRepository districtMasterRepository;
|
| 151 |
|
136 |
|
| Line 286... |
Line 271... |
| 286 |
ur.setUserId(user.getId());
|
271 |
ur.setUserId(user.getId());
|
| 287 |
userRoleRepository.persist(ur);
|
272 |
userRoleRepository.persist(ur);
|
| 288 |
|
273 |
|
| 289 |
if(foundRetailerFlag){
|
274 |
if(foundRetailerFlag){
|
| 290 |
LOGGER.info("\n\n\n****retailer found\n\n\n");
|
275 |
LOGGER.info("\n\n\n****retailer found\n\n\n");
|
| 291 |
PrivateDealUser privateDealUser = null;
|
- |
|
| 292 |
try{
|
- |
|
| 293 |
privateDealUser = privateDealUserRepository.selectById(saholicUser.getId());
|
- |
|
| 294 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
- |
|
| 295 |
LOGGER.error("PrivateDealUser not found : ", profitMandiBusinessException);
|
- |
|
| 296 |
}
|
- |
|
| 297 |
if(privateDealUser == null) {
|
- |
|
| 298 |
privateDealUser = new PrivateDealUser();
|
- |
|
| 299 |
privateDealUser.setActive(true);
|
- |
|
| 300 |
privateDealUser.setId(saholicUser.getId());
|
- |
|
| 301 |
privateDealUserRepository.persist(privateDealUser);
|
- |
|
| 302 |
PrivateDealUserAddressMapping privateDealUserAddressMapping = new PrivateDealUserAddressMapping();
|
- |
|
| 303 |
privateDealUserAddressMapping.setUserId(retailer.getId());
|
- |
|
| 304 |
privateDealUserAddressMapping.setAddressId(addressRetailer.getId());
|
- |
|
| 305 |
privateDealUserAddressMappingRepository.persist(privateDealUserAddressMapping);
|
- |
|
| 306 |
}
|
- |
|
| 307 |
if(privateDealUser.getCounterId() == null){
|
- |
|
| 308 |
Integer counterId = this.createCounter(user.getEmailId(), createRetailerRequest.getGstNumber(), user.getMobileNumber(), retailer.getName(), addressRetailer.getId());
|
- |
|
| 309 |
privateDealUser.setCounterId(counterId);
|
- |
|
| 310 |
privateDealUserRepository.persist(privateDealUser);
|
- |
|
| 311 |
}
|
- |
|
| 312 |
}else{
|
276 |
}else{
|
| 313 |
LOGGER.info("retailer not found");
|
277 |
LOGGER.info("retailer not found");
|
| 314 |
//gst number intergration with counter
|
- |
|
| 315 |
Integer counterId = this.createCounter(user.getEmailId(), createRetailerRequest.getGstNumber(), user.getMobileNumber(), retailer.getName(), addressRetailer.getId());
|
- |
|
| 316 |
|
- |
|
| 317 |
|
- |
|
| 318 |
PrivateDealUser privateDealUser = null;
|
- |
|
| 319 |
try{
|
- |
|
| 320 |
privateDealUser = privateDealUserRepository.selectById(saholicUser.getId());
|
- |
|
| 321 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
- |
|
| 322 |
LOGGER.warn("PrivateDealUser not found");
|
- |
|
| 323 |
}
|
- |
|
| 324 |
|
- |
|
| 325 |
if(privateDealUser != null){
|
- |
|
| 326 |
//LOGGER.info("PrivateDealUser found with id [{}]", saholicUser.getId());
|
- |
|
| 327 |
privateDealUser.setCounterId(counterId);
|
- |
|
| 328 |
privateDealUserRepository.update(privateDealUser);
|
- |
|
| 329 |
}else{
|
- |
|
| 330 |
LOGGER.info("PrivateDealUser not found with id [{}], creating it", saholicUser.getId());
|
- |
|
| 331 |
privateDealUser = new PrivateDealUser();
|
- |
|
| 332 |
privateDealUser.setActive(true);
|
- |
|
| 333 |
privateDealUser.setId(saholicUser.getId());
|
- |
|
| 334 |
privateDealUser.setCounterId(counterId);
|
- |
|
| 335 |
privateDealUserRepository.persist(privateDealUser);
|
- |
|
| 336 |
}
|
- |
|
| 337 |
PrivateDealUserAddressMapping privateDealUserAddressMapping = new PrivateDealUserAddressMapping();
|
- |
|
| 338 |
privateDealUserAddressMapping.setUserId(retailer.getId());
|
- |
|
| 339 |
privateDealUserAddressMapping.setAddressId(addressRetailer.getId());
|
- |
|
| 340 |
privateDealUserAddressMappingRepository.persist(privateDealUserAddressMapping);
|
- |
|
| 341 |
|
- |
|
| 342 |
saholicUser.setAddressId(addressRetailer.getId());
|
278 |
saholicUser.setAddressId(addressRetailer.getId());
|
| 343 |
userUserRepository.persist(saholicUser);
|
279 |
userUserRepository.persist(saholicUser);
|
| 344 |
}
|
280 |
}
|
| 345 |
}
|
281 |
}
|
| 346 |
|
282 |
|
| 347 |
private Integer createCounter(String emailId, String gstNumber, String mobileNumber, String name, int addressId){
|
- |
|
| 348 |
if(gstNumber != null && !gstNumber.isEmpty()){
|
- |
|
| 349 |
Counter counter = new Counter();
|
- |
|
| 350 |
counter.setEmailId(emailId);
|
- |
|
| 351 |
counter.setGstin(gstNumber);
|
- |
|
| 352 |
counter.setMobileNumber(mobileNumber);
|
- |
|
| 353 |
counter.setName(name);
|
- |
|
| 354 |
counter.setAddressId(addressId);
|
- |
|
| 355 |
counter.setCreatedOn(LocalDateTime.now());
|
- |
|
| 356 |
counterRepository.persist(counter);
|
- |
|
| 357 |
return counter.getId();
|
- |
|
| 358 |
}else{
|
- |
|
| 359 |
return null;
|
- |
|
| 360 |
}
|
- |
|
| 361 |
}
|
- |
|
| 362 |
|
- |
|
| 363 |
|
283 |
|
| 364 |
private void addBrandWithRetailer(int retailerId, Set<Category> categories)
|
284 |
private void addBrandWithRetailer(int retailerId, Set<Category> categories)
|
| 365 |
throws ProfitMandiBusinessException{
|
285 |
throws ProfitMandiBusinessException{
|
| 366 |
for(Category category : categories){
|
286 |
for(Category category : categories){
|
| 367 |
for(com.spice.profitmandi.web.req.Brand brandModel : category.getBrands()){
|
287 |
for(com.spice.profitmandi.web.req.Brand brandModel : category.getBrands()){
|
| 368 |
Brand brand = brandRepository.selectByIdAndName(brandModel.getId(), brandModel.getName());
|
288 |
Brand brand = brandRepository.selectByIdAndName(brandModel.getId(), brandModel.getName());
|