Subversion Repositories SmartDukaan

Rev

Rev 22954 | Rev 22965 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22954 Rev 22964
Line 179... Line 179...
179
		retailer.setRecharge(createRetailerRequest.getLineOfBusiness().isRecharge());
179
		retailer.setRecharge(createRetailerRequest.getLineOfBusiness().isRecharge());
180
		retailer.setMobile(createRetailerRequest.getLineOfBusiness().isMobile());
180
		retailer.setMobile(createRetailerRequest.getLineOfBusiness().isMobile());
181
		retailer.setAccessories(createRetailerRequest.getLineOfBusiness().isAccessories());
181
		retailer.setAccessories(createRetailerRequest.getLineOfBusiness().isAccessories());
182
		retailer.setOther1(createRetailerRequest.getLineOfBusiness().getOther1());
182
		retailer.setOther1(createRetailerRequest.getLineOfBusiness().getOther1());
183
		retailer.setOther2(createRetailerRequest.getLineOfBusiness().getOther2());
183
		retailer.setOther2(createRetailerRequest.getLineOfBusiness().getOther2());
-
 
184
		if(createRetailerRequest.getDocumentId() == 0){
-
 
185
			retailer.setDocumentId(null);
-
 
186
		}else{
184
		Document retailerDocument = documentRepository.selectById(createRetailerRequest.getDocumentId());
187
			Document retailerDocument = documentRepository.selectById(createRetailerRequest.getDocumentId());
185
		if(retailerRepository.isExistByDocumentId(retailerDocument.getId())){
188
			if(retailerRepository.isExistByDocumentId(retailerDocument.getId())){
186
			LOGGER.error("documet is already mapped with another retailer");
189
				LOGGER.error("documet is already mapped with another retailer");
187
			throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, retailerDocument.getId(), "DCMNT_1000");
190
				throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, retailerDocument.getId(), "DCMNT_1000");
-
 
191
			}
-
 
192
			retailer.setDocumentId(retailerDocument.getId());
-
 
193
			documentRepository.markDocumentAsPersisted(retailerDocument.getId());
188
		}
194
		}
-
 
195
		Shop shop = new Shop();
-
 
196
		shop.setName(createRetailerRequest.getShop().getName());
-
 
197
		
189
		retailer.setDocumentId(retailerDocument.getId());
198
		if(createRetailerRequest.getShop().getDocumentId() == 0){
-
 
199
			shop.setDocumentId(null);
-
 
200
		}else{
190
		final Document shopDocument = documentRepository.selectById(createRetailerRequest.getShop().getDocumentId());
201
			final Document shopDocument = documentRepository.selectById(createRetailerRequest.getShop().getDocumentId());
191
		if(shopRepository.isExistByDocumentId(shopDocument.getId())){
202
			if(shopRepository.isExistByDocumentId(shopDocument.getId())){
192
			throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, shopDocument.getId(), "DCMNT_1000");
203
				throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, shopDocument.getId(), "DCMNT_1000");
-
 
204
			}
-
 
205
			shop.setDocumentId(shopDocument.getId());
-
 
206
			documentRepository.markDocumentAsPersisted(shopDocument.getId());
193
		}
207
		}
194
		documentRepository.markDocumentAsPersisted(retailerDocument.getId());
-
 
195
		//This validation is not required
-
 
196
		/*if(retailerRepository.isExistByNumberAndType(retailer.getNumber(), retailer.getType())){
-
 
197
			throw new ProfitMandiBusinessException(ProfitMandiConstants.NUMBER + ", " + ProfitMandiConstants.TYPE, retailer.getNumber() + ", " + retailer.getType(), "RTLR_1001");
-
 
198
		}*/
208
		
199
		documentRepository.markDocumentAsPersisted(shopDocument.getId());
209
		shop.setRetailerId(retailer.getId());
-
 
210
		shopRepository.persist(shop);
200
		
211
		
201
		com.spice.profitmandi.dao.entity.user.User saholicUser = null;
212
		com.spice.profitmandi.dao.entity.user.User saholicUser = null;
202
		boolean foundRetailer = false;
213
		boolean foundRetailer = false;
203
		try {
214
		try {
204
			saholicUser = userUserRepository.selectByEmailId(user.getEmailId());
215
			saholicUser = userUserRepository.selectByEmailId(user.getEmailId());
Line 219... Line 230...
219
		}
230
		}
220
		//in.shop2020.model.v1.user.User saholicUser = Utils.createSaholicUser(user.getEmailId()); 
231
		//in.shop2020.model.v1.user.User saholicUser = Utils.createSaholicUser(user.getEmailId()); 
221
		retailer.setId(saholicUser.getId());
232
		retailer.setId(saholicUser.getId());
222
		retailerRepository.persist(retailer);
233
		retailerRepository.persist(retailer);
223
		
234
		
224
		Shop shop = new Shop();
235
		
225
		shop.setName(createRetailerRequest.getShop().getName());
-
 
226
		shop.setDocumentId(shopDocument.getId());
-
 
227
		shop.setRetailerId(retailer.getId());
-
 
228
		shopRepository.persist(shop);
-
 
229
		this.addBrandWithRetailer(retailer.getId(), createRetailerRequest.getCategories());
236
		this.addBrandWithRetailer(retailer.getId(), createRetailerRequest.getCategories());
230
		final Address addressRetailer = this.createAddress(createRetailerRequest.getAddress());
237
		final Address addressRetailer = this.createAddress(createRetailerRequest.getAddress());
231
		addressRetailer.setRetaierId(retailer.getId());
238
		addressRetailer.setRetaierId(retailer.getId());
232
		addressRepository.persist(addressRetailer);
239
		addressRepository.persist(addressRetailer);
233
		
240