| Line 183... |
Line 183... |
| 183 |
retailer.setOther1(createRetailerRequest.getLineOfBusiness().getOther1());
|
183 |
retailer.setOther1(createRetailerRequest.getLineOfBusiness().getOther1());
|
| 184 |
retailer.setOther2(createRetailerRequest.getLineOfBusiness().getOther2());
|
184 |
retailer.setOther2(createRetailerRequest.getLineOfBusiness().getOther2());
|
| 185 |
if(createRetailerRequest.getDocumentId() == 0){
|
185 |
if(createRetailerRequest.getDocumentId() == 0){
|
| 186 |
retailer.setDocumentId(null);
|
186 |
retailer.setDocumentId(null);
|
| 187 |
}else{
|
187 |
}else{
|
| 188 |
Document retailerDocument = documentRepository.selectById(createRetailerRequest.getDocumentId());
|
188 |
/*Document retailerDocument = documentRepository.selectById(createRetailerRequest.getDocumentId());
|
| 189 |
if(retailerRepository.isExistByDocumentId(retailerDocument.getId())){
|
189 |
if(retailerRepository.isExistByDocumentId(retailerDocument.getId())){
|
| 190 |
LOGGER.error("documet is already mapped with another retailer");
|
190 |
LOGGER.error("documet is already mapped with another retailer");
|
| 191 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, retailerDocument.getId(), "DCMNT_1000");
|
191 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, retailerDocument.getId(), "DCMNT_1000");
|
| 192 |
}
|
192 |
}*/
|
| 193 |
retailer.setDocumentId(retailerDocument.getId());
|
193 |
retailer.setDocumentId(createRetailerRequest.getDocumentId());
|
| 194 |
documentRepository.markDocumentAsPersisted(retailerDocument.getId());
|
194 |
documentRepository.markDocumentAsPersisted(createRetailerRequest.getDocumentId());
|
| 195 |
}
|
195 |
}
|
| 196 |
Shop shop = new Shop();
|
196 |
Shop shop = new Shop();
|
| 197 |
shop.setName(createRetailerRequest.getShop().getName());
|
197 |
shop.setName(createRetailerRequest.getShop().getName());
|
| 198 |
|
198 |
|
| 199 |
if(createRetailerRequest.getShop().getDocumentId() == 0){
|
199 |
if(createRetailerRequest.getShop().getDocumentId() == 0){
|
| 200 |
shop.setDocumentId(null);
|
200 |
shop.setDocumentId(null);
|
| 201 |
}else{
|
201 |
}else{
|
| 202 |
final Document shopDocument = documentRepository.selectById(createRetailerRequest.getShop().getDocumentId());
|
202 |
/*final Document shopDocument = documentRepository.selectById(createRetailerRequest.getShop().getDocumentId());
|
| 203 |
if(shopRepository.isExistByDocumentId(shopDocument.getId())){
|
203 |
if(shopRepository.isExistByDocumentId(shopDocument.getId())){
|
| 204 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, shopDocument.getId(), "DCMNT_1000");
|
204 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, shopDocument.getId(), "DCMNT_1000");
|
| 205 |
}
|
205 |
}*/
|
| 206 |
shop.setDocumentId(shopDocument.getId());
|
206 |
shop.setDocumentId(createRetailerRequest.getShop().getDocumentId());
|
| 207 |
documentRepository.markDocumentAsPersisted(shopDocument.getId());
|
207 |
documentRepository.markDocumentAsPersisted(createRetailerRequest.getShop().getDocumentId());
|
| 208 |
}
|
208 |
}
|
| 209 |
|
209 |
|
| 210 |
com.spice.profitmandi.dao.entity.user.User saholicUser = null;
|
210 |
com.spice.profitmandi.dao.entity.user.User saholicUser = null;
|
| 211 |
boolean foundRetailer = false;
|
211 |
boolean foundRetailer = false;
|
| 212 |
try {
|
212 |
try {
|
| Line 226... |
Line 226... |
| 226 |
}else{
|
226 |
}else{
|
| 227 |
foundRetailer = true;
|
227 |
foundRetailer = true;
|
| 228 |
}
|
228 |
}
|
| 229 |
try{
|
229 |
try{
|
| 230 |
retailerRepository.selectById(saholicUser.getId());
|
230 |
retailerRepository.selectById(saholicUser.getId());
|
| 231 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
- |
|
| 232 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.EMAIL_ID, saholicUser.getEmailId(), "RTLR_1011");
|
231 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.EMAIL_ID, saholicUser.getEmailId(), "RTLR_1011");
|
| - |
|
232 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| - |
|
233 |
LOGGER.info("Retailer is not registered");
|
| 233 |
}
|
234 |
}
|
| 234 |
//in.shop2020.model.v1.user.User saholicUser = Utils.createSaholicUser(user.getEmailId());
|
235 |
//in.shop2020.model.v1.user.User saholicUser = Utils.createSaholicUser(user.getEmailId());
|
| 235 |
retailer.setId(saholicUser.getId());
|
236 |
retailer.setId(saholicUser.getId());
|
| 236 |
retailerRepository.persist(retailer);
|
237 |
retailerRepository.persist(retailer);
|
| 237 |
|
238 |
|
| 238 |
shop.setRetailerId(retailer.getId());
|
239 |
shop.setRetailerId(retailer.getId());
|
| 239 |
LOGGER.info("Shop is persisting ... [{}]",shop);
|
240 |
//LOGGER.info("Shop is persisting ... [{}]",shop);
|
| 240 |
shopRepository.persist(shop);
|
241 |
shopRepository.persist(shop);
|
| 241 |
|
242 |
|
| 242 |
this.addBrandWithRetailer(retailer.getId(), createRetailerRequest.getCategories());
|
243 |
this.addBrandWithRetailer(retailer.getId(), createRetailerRequest.getCategories());
|
| 243 |
final Address addressRetailer = this.createAddress(createRetailerRequest.getAddress());
|
244 |
final Address addressRetailer = this.createAddress(createRetailerRequest.getAddress());
|
| 244 |
addressRetailer.setRetaierId(retailer.getId());
|
245 |
addressRetailer.setRetaierId(retailer.getId());
|