Subversion Repositories SmartDukaan

Rev

Rev 23526 | Rev 23568 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
21543 ashik.ali 1
package com.spice.profitmandi.common.util;
2
 
3
import java.io.File;
4
import java.io.IOException;
5
import java.io.InputStream;
6
import java.net.URISyntaxException;
7
import java.net.URL;
21902 ashik.ali 8
import java.util.ArrayList;
21543 ashik.ali 9
import java.util.Collections;
10
import java.util.HashMap;
23509 amit.gupta 11
import java.util.HashSet;
21543 ashik.ali 12
import java.util.List;
13
import java.util.Map;
23296 ashik.ali 14
import java.util.Set;
15
import java.util.TreeSet;
21894 ashik.ali 16
 
21543 ashik.ali 17
import org.apache.commons.io.FileUtils;
18
import org.apache.commons.io.IOUtils;
19
import org.apache.http.client.utils.URIBuilder;
22351 ashik.ali 20
import org.apache.thrift.TException;
21
import org.apache.thrift.transport.TTransportException;
21986 kshitij.so 22
import org.json.JSONObject;
21543 ashik.ali 23
import org.slf4j.Logger;
24
import org.slf4j.LoggerFactory;
22215 ashik.ali 25
import org.springframework.http.HttpHeaders;
26
import org.springframework.http.MediaType;
23074 ashik.ali 27
 
22215 ashik.ali 28
import com.spice.profitmandi.common.enumuration.SchemeType;
29
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
21894 ashik.ali 30
import com.spice.profitmandi.common.model.GstRate;
22351 ashik.ali 31
import com.spice.profitmandi.common.model.ProfitMandiConstants;
22215 ashik.ali 32
import com.spice.profitmandi.common.web.client.RestClient;
21894 ashik.ali 33
import com.spice.profitmandi.thrift.clients.CatalogClient;
34
import com.spice.profitmandi.thrift.clients.InventoryClient;
35
import com.spice.profitmandi.thrift.clients.TransactionClient;
22351 ashik.ali 36
import com.spice.profitmandi.thrift.clients.UserClient;
23509 amit.gupta 37
import com.spice.profitmandi.thrift.clients.WarehouseClient;
21894 ashik.ali 38
import com.spice.profitmandi.thrift.clients.config.ConfigClient;
21543 ashik.ali 39
 
21894 ashik.ali 40
import in.shop2020.model.v1.catalog.CatalogService;
41
import in.shop2020.model.v1.inventory.InventoryService;
42
import in.shop2020.model.v1.inventory.StateInfo;
23509 amit.gupta 43
import in.shop2020.model.v1.inventory.Warehouse;
21894 ashik.ali 44
import in.shop2020.model.v1.order.RechargeOrderStatus;
45
import in.shop2020.model.v1.order.RechargePlan;
46
import in.shop2020.model.v1.order.RechargeType;
23509 amit.gupta 47
import in.shop2020.model.v1.order.SellerInfo;
48
import in.shop2020.model.v1.order.WarehouseAddress;
22351 ashik.ali 49
import in.shop2020.model.v1.user.Sex;
50
import in.shop2020.model.v1.user.User;
51
import in.shop2020.model.v1.user.UserContextException;
23509 amit.gupta 52
import in.shop2020.warehouse.InventoryItem;
53
import in.shop2020.warehouse.WarehouseService;
21543 ashik.ali 54
 
21894 ashik.ali 55
 
56
 
21543 ashik.ali 57
public class Utils {
21986 kshitij.so 58
 
59
	private static final Logger logger = LoggerFactory.getLogger(Utils.class);
60
	public static final String EXPORT_ENTITIES_PATH = getExportPath();
61
	public static final String PRODUCT_PROPERTIES_SNIPPET = "ProductPropertiesSnippet.html";
62
	public static final String DOCUMENT_STORE = "/profitmandi/documents/";
23017 ashik.ali 63
	private static final Map<Integer, String> helpMap = new HashMap<>(6);
64
	private static final Map<Integer, String> dthIdAliasMap = new HashMap<>(7);
65
	private static Map<Long, List<RechargePlan>> operatorPlanMap = new HashMap<>(20);
21986 kshitij.so 66
	private static Map<Long, String> mobileProvidersMap;
67
	private static Map<Long, String> dthProvidersMap;
22757 amit.gupta 68
	//private static final String SMS_GATEWAY = "http://103.15.179.45:8085/SMSGateway/sendingSMS";
69
	private static final String SMS_GATEWAY = "http://103.15.179.45:8085/MessagingGateway/SendTransSMS";
21986 kshitij.so 70
	private static Map<Long, String> allProviders;
23017 ashik.ali 71
	public static Map<RechargeOrderStatus, String> rechargeStatusMap = new HashMap<>();
21646 kshitij.so 72
 
21986 kshitij.so 73
	static {
74
		helpMap.put(Integer.valueOf(1), "Your VC number starts with 0 and is 11 digits long.");
75
		helpMap.put(Integer.valueOf(2), "Smart card number starts with 2 and is 12 digits long.");
76
		helpMap.put(Integer.valueOf(3), "Smart card number starts with 4 and is 11 digits long.");
77
		helpMap.put(Integer.valueOf(4), "Subscriber ID starts with 1 and is 10 digits long.");
78
		helpMap.put(Integer.valueOf(5), "For customer ID, SMS ID to 9212012299 from your registered mobile no.");
79
		helpMap.put(Integer.valueOf(26), "Customer ID starts with 3 and is 10 digits long.");
21543 ashik.ali 80
 
21986 kshitij.so 81
		dthIdAliasMap.put(Integer.valueOf(1), "VC Number :");
82
		dthIdAliasMap.put(Integer.valueOf(2), "Smart Card Number :");
83
		dthIdAliasMap.put(Integer.valueOf(3), "Smart Card Number :");
84
		dthIdAliasMap.put(Integer.valueOf(4), "Subscriber Id :");
85
		dthIdAliasMap.put(Integer.valueOf(5), "Customer Id :");
86
		dthIdAliasMap.put(Integer.valueOf(0), "Account Number :");
87
		dthIdAliasMap.put(Integer.valueOf(26), "Customer Id :");
21543 ashik.ali 88
 
21986 kshitij.so 89
		rechargeStatusMap.put(RechargeOrderStatus.PAYMENT_FAILED, "Payment Unsuccessful");
90
		rechargeStatusMap.put(RechargeOrderStatus.PAYMENT_SUCCESSFUL, "Processing Recharge");
91
		rechargeStatusMap.put(RechargeOrderStatus.RECHARGE_FAILED, "Recharge Failed");
92
		rechargeStatusMap.put(RechargeOrderStatus.RECHARGE_FAILED_REFUNDED, "Recharge Failed Refunded");
93
		rechargeStatusMap.put(RechargeOrderStatus.RECHARGE_SUCCESSFUL, "Recharge Successful");
94
		rechargeStatusMap.put(RechargeOrderStatus.REFUNDED, "Amount Refunded");
95
		rechargeStatusMap.put(RechargeOrderStatus.PARTIALLY_REFUNDED, "Amount Refunded");
96
		rechargeStatusMap.put(RechargeOrderStatus.PAYMENT_PENDING, "Payment Failed");
97
		rechargeStatusMap.put(RechargeOrderStatus.INIT, "Payment Initiated");
98
		rechargeStatusMap.put(RechargeOrderStatus.RECHARGE_UNKNOWN, "Recharge In Process");
99
		rechargeStatusMap.put(RechargeOrderStatus.RECHARGE_IN_PROCESS, "Recharge In Process");
100
 
101
		TransactionClient tcl;
102
		try
103
		{
104
			tcl = new TransactionClient();
105
			mobileProvidersMap = tcl.getClient().getServiceProviders(RechargeType.MOBILE, true);
106
			dthProvidersMap = tcl.getClient().getServiceProviders(RechargeType.DTH, true);
107
			logger.info("mobileProvidersMap" + mobileProvidersMap);
108
			logger.info("dthProvidersMap" + dthProvidersMap);
22390 amit.gupta 109
			allProviders = new HashMap<>(mobileProvidersMap);
21986 kshitij.so 110
			logger.info("allProviders" + allProviders);
111
			allProviders.putAll(dthProvidersMap);
112
			logger.info("allProviders" + allProviders);
113
 
114
			for (Long operatorId : mobileProvidersMap.keySet()) {
115
				List<RechargePlan> plans = tcl.getClient().getPlansForOperator(operatorId.longValue());
116
				if (!plans.isEmpty())
117
					operatorPlanMap.put(operatorId, plans);
118
			}
119
		} catch (Exception e) {
120
			logger.error("Could not get providers", e);
121
		}
122
	}
123
 
124
 
23509 amit.gupta 125
	public static SellerInfo getSellerInfoBySellerId(int sellerId) throws Exception {
126
		TransactionClient tcl = new TransactionClient();
127
		return tcl.getClient().getSellerInfo((long)sellerId);
128
	}
129
 
21543 ashik.ali 130
	@SuppressWarnings("serial")
131
	public static final Map<String,String> MIME_TYPE = Collections.unmodifiableMap(
132
			new HashMap<String, String>(){
133
				{
134
					put("image/png", "png");
135
					put("image/jpeg", "jpeg");
136
					put("image/pjpeg", "jpeg");
137
					put("application/pdf","pdf");
138
				}
139
			});
140
 
141
	private static String getExportPath(){
142
		String exportPath=null;
143
 
144
		ConfigClient client = ConfigClient.getClient();
145
		try{
146
			exportPath = client.get("export_entities_path");
147
		}catch(Exception ce){
148
			logger.error("Unable to read export path from the config client: ", ce);
149
			logger.warn("Setting the default export path");
150
			exportPath = "/var/lib/tomcat7/webapps/export/html/entities/";
151
		}
152
		return exportPath;
153
	}
21986 kshitij.so 154
 
21646 kshitij.so 155
	public static String getRechargeDisplayStatus(RechargeOrderStatus status) {
21986 kshitij.so 156
		if (status == null) {
157
			status = RechargeOrderStatus.INIT;
158
		}
159
		String displayStatus = (String)rechargeStatusMap.get(status);
160
		if (displayStatus == null) {
161
			return "";
162
		}
163
		return displayStatus;
164
	}
21543 ashik.ali 165
 
166
	public static boolean copyDocument(String documentPath){
167
		File source = new File(documentPath);
168
		File dest = new File(DOCUMENT_STORE+source.getName());
169
		try {
170
			FileUtils.copyFile(source, dest);
171
		} catch (IOException e) {
172
			e.printStackTrace();
173
			return false;
174
		}
175
		return true;
176
	}
177
 
178
	public static Map<Long, String> getMobileProvidersMap() {
179
		return mobileProvidersMap;
180
	}
181
 
182
	public static Map<Long, String> getDthProvidersMap() {
183
		return dthProvidersMap;
184
	}
21986 kshitij.so 185
 
21543 ashik.ali 186
	public static Map<Long, String> getAllProviders() {
187
		return allProviders;
188
	}
21986 kshitij.so 189
 
21543 ashik.ali 190
	public static String getProvider(long operatorId) {
21986 kshitij.so 191
		return allProviders.get(operatorId);
192
	}
21543 ashik.ali 193
 
194
	public static void sendSms(String text, String mobileNumber) throws URISyntaxException, IOException{
195
		URIBuilder generalSearchUrl = new URIBuilder(SMS_GATEWAY);
22757 amit.gupta 196
		generalSearchUrl.addParameter("Mobile", "91"+mobileNumber);
197
		generalSearchUrl.addParameter("Username", "srlsaholic");                  
198
		generalSearchUrl.addParameter("Password", "sr18mar"); 					  
23376 amit.gupta 199
		generalSearchUrl.addParameter("SenderID", "SMTDKN");             			  
22757 amit.gupta 200
		generalSearchUrl.setParameter("Message", text);
201
		generalSearchUrl.setParameter("MessageType", "txt");
202
/*		generalSearchUrl.addParameter("ani", "91"+mobileNumber);
21543 ashik.ali 203
		generalSearchUrl.addParameter("uname", "srlsaholic");                  
204
		generalSearchUrl.addParameter("passwd", "sr18mar"); 					  
205
		generalSearchUrl.addParameter("cli", "PROFTM");             			  
206
		generalSearchUrl.setParameter("message", text);
22757 amit.gupta 207
*/		URL url = generalSearchUrl.build().toURL();
22889 amit.gupta 208
		System.out.println(url);
21543 ashik.ali 209
		InputStream is = url.openStream();
210
		String response;
211
		try{
212
			response = IOUtils.toString(is, "UTF-8");
213
			System.out.println("response sms gateway "+response);
214
		}
215
		finally{
216
			is.close();
217
		}
218
	}
22757 amit.gupta 219
 
220
	public static void sendMailWithAttachments(String email, String message, List<File> attachments){
221
 
222
	}
223
 
21543 ashik.ali 224
	public static String[] getOrderStatus(RechargeOrderStatus status){
225
		if (status == null){
226
			status = RechargeOrderStatus.INIT;
227
		}
228
		if(status.equals(RechargeOrderStatus.PAYMENT_FAILED)||status.equals(RechargeOrderStatus.PAYMENT_PENDING)){
229
			return new String[]{"false", "PAYMENT FAILED", "Payment failed at the payment gateway."};
230
		}
231
		else if(status.equals(RechargeOrderStatus.PAYMENT_SUCCESSFUL) || status.equals(RechargeOrderStatus.RECHARGE_UNKNOWN)) {
232
			if(status.equals(RechargeOrderStatus.PAYMENT_SUCCESSFUL)){
233
				return new String[]{"false", "PAYMENT SUCCESSFUL", "Your Payment was successful but due to some internal error with the operator's system we are not sure if the recharge was successful."
234
						+ " We have put your recharge under process."
235
						+ " As soon as we get a confirmation on this transaction, we will notify you."};
236
			}
237
			else{
238
				return new String[]{"false", "RECHARGE IN PROCESS", "Your Payment is successful.We have put your recharge under process." +
239
				" Please wait while we check with the operator."};
240
			}
241
		}
242
		else if (status.equals(RechargeOrderStatus.RECHARGE_FAILED) || status.equals(RechargeOrderStatus.RECHARGE_FAILED_REFUNDED)){
22391 amit.gupta 243
			return new String[]{"false", "RECHARGE FAILED", "Your Payment was successful but unfortunately the recharge failed.Don't worry your payment is safe with us."
21543 ashik.ali 244
					+ " The entire Amount has been refunded to your wallet."};
245
		} else if(status.equals(RechargeOrderStatus.RECHARGE_SUCCESSFUL)){
246
			return new String[] {"false", "SUCCESS", "Congratulations! Your device is successfully recharged."};
247
		} else if (status.equals(RechargeOrderStatus.PARTIALLY_REFUNDED) || status.equals(RechargeOrderStatus.REFUNDED)) {
248
			return new String[]{"false", "PAYMENT REFUNDED","The payment associated with this recharge order has been refunded."};
249
		} else {
250
			return new String[]{"true", "ERROR", "INVALID INPUT"};
251
		}
252
	}
21986 kshitij.so 253
 
254
 
255
	public static String getIconUrl(int entityId,String host, int port, String webapp){
23526 ashik.ali 256
		RestClient rc = new RestClient();
21986 kshitij.so 257
		Map<String, String> params = new HashMap<String, String>();
258
		String response = null;
259
		String uri = webapp+"/entity/"+entityId;
22215 ashik.ali 260
		Map<String, String> headers = new HashMap<>(1);
261
		headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
21986 kshitij.so 262
		try {
23526 ashik.ali 263
			response = rc.get(SchemeType.HTTP, host , port, uri, params, headers);
23376 amit.gupta 264
		} catch (Throwable e) {
21986 kshitij.so 265
			// TODO Auto-generated catch block
266
			e.printStackTrace();
267
			return "";
268
		}
269
		JSONObject obj = new JSONObject(response);
270
		String iconUrl = null;
271
		try{
272
		iconUrl = obj.getJSONObject("entity").getString("iconImageUrl");
273
		}
274
		catch(Exception e){
275
			return "";
276
		}
277
		return iconUrl==null?"":iconUrl;
278
	}
21894 ashik.ali 279
 
23147 ashik.ali 280
	public static Map<Integer, GstRate> getStateTaxRate(List<Integer> itemIds, int stateId) throws ProfitMandiBusinessException{
23152 ashik.ali 281
		List<Long> longItemIds = new ArrayList<>();
282
		for(int itemId : itemIds){
283
			longItemIds.add(Long.valueOf(itemId));
284
		}
23147 ashik.ali 285
		try{
286
			CatalogService.Client catalogClient = getCatalogClient();
23152 ashik.ali 287
			Map<Long, in.shop2020.model.v1.catalog.GstRate> totalTaxRateMap = catalogClient.getStateTaxRate(longItemIds, stateId);
23147 ashik.ali 288
			Map<Integer, GstRate> itemIdGstRateMap = new HashMap<>();
23152 ashik.ali 289
			for(Map.Entry<Long, in.shop2020.model.v1.catalog.GstRate> totalTaxRateEntry : totalTaxRateMap.entrySet()){
23147 ashik.ali 290
				GstRate gstRate = new GstRate();
291
				gstRate.setIgstRate(Double.valueOf(totalTaxRateEntry.getValue().getIgstRate()).floatValue());
292
				gstRate.setCgstRate(Double.valueOf(totalTaxRateEntry.getValue().getCgstRate()).floatValue());
293
				gstRate.setSgstRate(Double.valueOf(totalTaxRateEntry.getValue().getSgstRate()).floatValue());
23152 ashik.ali 294
				itemIdGstRateMap.put(totalTaxRateEntry.getKey().intValue(), gstRate);
23147 ashik.ali 295
			}
296
			return itemIdGstRateMap;
297
		}catch(Exception e){
298
			e.printStackTrace();
299
			throw new ProfitMandiBusinessException(ProfitMandiConstants.ITEM_ID + ", " + ProfitMandiConstants.STATE_ID, itemIds +", " + stateId, "");
300
		}
301
	}
302
 
303
	public static Map<Integer, Float> getIgstTaxRate(List<Integer> itemIds) throws ProfitMandiBusinessException{
23152 ashik.ali 304
		List<Long> longItemIds = new ArrayList<>();
305
		for(int itemId : itemIds){
306
			longItemIds.add(Long.valueOf(itemId));
307
		}
23147 ashik.ali 308
		try{
309
			CatalogService.Client catalogClient = getCatalogClient();
23152 ashik.ali 310
			Map<Long, Double> totalTaxRateMap = catalogClient.getIgstTaxRate(longItemIds);
23147 ashik.ali 311
			Map<Integer, Float> itemIdIgstRateMap = new HashMap<>();
23152 ashik.ali 312
			for(Map.Entry<Long, Double> totalTaxRateEntry : totalTaxRateMap.entrySet()){
313
				itemIdIgstRateMap.put(totalTaxRateEntry.getKey().intValue(), Double.valueOf(totalTaxRateEntry.getValue()).floatValue());
23147 ashik.ali 314
			}
315
			return itemIdIgstRateMap;
316
		}catch(Exception e){
317
			e.printStackTrace();
318
			throw new ProfitMandiBusinessException(ProfitMandiConstants.ITEM_ID, itemIds, "");
319
		}
320
	}
321
 
21915 ashik.ali 322
	private static CatalogService.Client getCatalogClient() throws Exception{
323
		try{
324
			CatalogClient client = new CatalogClient();
325
			CatalogService.Client catalogClient = client.getClient();
326
			return catalogClient;
327
		}catch (Exception e) {
328
			throw e;
329
		}
330
	}
23509 amit.gupta 331
 
332
	private static WarehouseService.Client getWarehouseClient() throws Exception{
333
		try{
334
			WarehouseClient client = new WarehouseClient();
335
			WarehouseService.Client warehouseClient = client.getClient();
336
			return warehouseClient;
337
		}catch (Exception e) {
338
			throw e;
339
		}
340
	}
21915 ashik.ali 341
 
342
 
23509 amit.gupta 343
	public static Map<String, Warehouse> getWarehouseByImeis(List<String> imeis) throws Exception{
344
		List<InventoryItem> inventoryItems = getWarehouseClient().getInventoryItemsBySerailNumbers(imeis);
345
		Map<String, InventoryItem> imeiInventoryItemMap = new HashMap<>();
346
		for(InventoryItem inventoryItem : inventoryItems) {
347
			imeiInventoryItemMap.put(inventoryItem.getSerialNumber(), inventoryItem);
348
		}
349
		Map<Integer, Warehouse> warehouseMap = new HashMap<>(); 
350
		Map<String, Warehouse> serialNumberWarehouseMap = new HashMap<>();
351
		InventoryClient client = new InventoryClient();
352
		InventoryService.Client inventoryClient = client.getClient();
353
		logger.info("[imeiInventoryItemMap] {}", imeiInventoryItemMap);
354
		for(InventoryItem inventory : new HashSet<>(imeiInventoryItemMap.values())) {
355
			Warehouse phWarehouse = null;
356
			if(warehouseMap.containsKey(inventory.getPhysicalWarehouseId())) {
357
				phWarehouse = warehouseMap.get((int)inventory.getPhysicalWarehouseId());
358
			} else {
359
				phWarehouse = inventoryClient.getWarehouse(inventory.getPhysicalWarehouseId());
360
				warehouseMap.put((int)inventory.getPhysicalWarehouseId(), phWarehouse);
361
			}
362
			serialNumberWarehouseMap.put(inventory.getSerialNumber(), phWarehouse);
363
 
364
		}
365
		return serialNumberWarehouseMap;
366
	}
367
 
368
 
21902 ashik.ali 369
	public static String getStateCode(String stateName) throws Exception{
370
		return getStateInfo(stateName).getStateCode();
371
	}
372
 
23539 amit.gupta 373
	public static long getStateId(String stateName) throws ProfitMandiBusinessException {
374
		try {
375
			return getStateInfo(stateName).getId();
376
		} catch(Exception e) {
377
			e.printStackTrace();
378
			throw new ProfitMandiBusinessException("State Name", stateName, "Could not fetch state");
379
		}
21902 ashik.ali 380
	}
381
 
23509 amit.gupta 382
	public static StateInfo getStateByStateId(long stateId) throws Exception{
383
		InventoryClient client = new InventoryClient();
384
		InventoryService.Client inventoryClient = client.getClient();
385
		Map<Long, StateInfo> map = inventoryClient.getStateMaster();
386
		return map.get(stateId);
387
	}
388
 
21902 ashik.ali 389
	public static StateInfo getStateInfo(String stateName) throws Exception{
21894 ashik.ali 390
		try{
391
			InventoryClient client = new InventoryClient();
392
			InventoryService.Client inventoryClient = client.getClient();
393
			Map<Long, StateInfo> map = inventoryClient.getStateMaster();
21902 ashik.ali 394
			List<StateInfo> stateInfos = new ArrayList<>(map.values());
22664 amit.gupta 395
			logger.info("State Name: {}", stateName);
21894 ashik.ali 396
			for(StateInfo stateInfo : stateInfos){
22664 amit.gupta 397
				logger.info("State Name from service: {}", stateInfo.getStateName());
22938 amit.gupta 398
				if(stateName.toUpperCase().equals(stateInfo.getStateName().toUpperCase())){
21902 ashik.ali 399
					return stateInfo;
21894 ashik.ali 400
				}
401
			}
21902 ashik.ali 402
			throw new Exception("Not found");
21894 ashik.ali 403
		}catch (Exception e) {
404
			e.printStackTrace();
405
			throw e;
406
		}
407
	}
22351 ashik.ali 408
 
23296 ashik.ali 409
	public static List<String> getAllStateNames(){
410
		List<String> sortedStateNames = new ArrayList<>();
411
		try{
412
			InventoryClient client = new InventoryClient();
413
			InventoryService.Client inventoryClient = client.getClient();
414
			Map<Long, StateInfo> map = inventoryClient.getStateMaster();
415
			List<StateInfo> stateInfos = new ArrayList<>(map.values());
416
			Set<String> stateNames = new TreeSet<>();
417
 
418
			for(StateInfo stateInfo : stateInfos){
419
				stateNames.add(stateInfo.getStateName());
420
			}
421
			sortedStateNames = new ArrayList<>(stateNames);
422
			return sortedStateNames;
423
		}catch (Exception e) {
424
			e.printStackTrace();
425
			return sortedStateNames;
426
		}
427
	}
23509 amit.gupta 428
 
429
	public static Map<Long, StateInfo> getAllStatesMap() throws Exception{
430
		InventoryClient client = new InventoryClient();
431
		InventoryService.Client inventoryClient = client.getClient();
432
		return  inventoryClient.getStateMaster();
433
 
434
	}
23296 ashik.ali 435
 
22351 ashik.ali 436
	public static User createSaholicUser(String emailId) throws ProfitMandiBusinessException{
437
		in.shop2020.model.v1.user.User user = new in.shop2020.model.v1.user.User();
438
		user.setEmail(emailId);
439
		user.setPassword("");
440
		user.setCommunicationEmail(emailId);
441
		user.setSex(Sex.WONT_SAY);
442
 
443
		try {
444
			UserClient userContextServiceClient = new UserClient();
445
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
446
			user = userClient.createUser(user);
447
			return user;
448
		}catch (UserContextException ux){
449
			logger.error("Unable to register user: " + ux.getMessage());
450
			throw new ProfitMandiBusinessException(ProfitMandiConstants.EMAIL_ID, emailId, "");
451
		} catch (TTransportException e) {
452
			logger.error("Unable to register user." + e);
453
			throw new ProfitMandiBusinessException(ProfitMandiConstants.EMAIL_ID, emailId, "");
454
		}catch (TException e) {
455
			logger.error("Unable to register user." + e);
456
			throw new ProfitMandiBusinessException(ProfitMandiConstants.EMAIL_ID, emailId, "");
457
		} 
458
	}
22757 amit.gupta 459
 
460
	public static void main (String[] args) throws Exception{
461
		Utils.sendSms("Hello", "9990381569");
462
	}
23509 amit.gupta 463
 
464
	public static WarehouseAddress getWarehouseByWarehouseId(int warehouseAddressId) throws Exception{
465
		TransactionClient tcl = new TransactionClient();
466
		return tcl.getClient().getWarehouseAddress((long)warehouseAddressId);
467
	}
23074 ashik.ali 468
 
469
 
21543 ashik.ali 470
}