Subversion Repositories SmartDukaan

Rev

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

Rev 30209 Rev 30329
Line 76... Line 76...
76
 
76
 
77
		Response response = okHttpClient.newCall(request).execute();
77
		Response response = okHttpClient.newCall(request).execute();
78
		LOGGER.info("cookie {}", this.cookieStore.values());
78
		LOGGER.info("cookie {}", this.cookieStore.values());
79
 
79
 
80
		LOGGER.info("vivoSupportUrl" + vivoSupportUrl);
80
		LOGGER.info("vivoSupportUrl" + vivoSupportUrl);
81
		LOGGER.info("request" + request);
-
 
82
		LOGGER.info("request" + request);
-
 
83
 
81
 
84
		String filePath = "/tmp/captcha.avif";
82
		String filePath = "/tmp/captcha.avif";
85
		Files.write(Paths.get(filePath), response.body().bytes());
83
		Files.write(Paths.get(filePath), response.body().bytes());
86
 
84
 
87
		// Get all relevent imes from activatedImei and inventoryItem for vivo
85
		// Get all relevent imes from activatedImei and inventoryItem for vivo
88
 
86
 
89
		String captchaBreak = captchaService.getCaptchaCode(filePath);
87
		String captchaBreak = captchaService.getCaptchaCode(filePath);
90
 
-
 
-
 
88
		System.out.println("Captcha is " + captchaBreak);
91
		return captchaBreak;
89
		return captchaBreak;
92
	}
90
	}
93
 
91
 
94
	public void getImeiActivation(String captchaBreak, OkHttpClient okHttpClient,
92
	public void getImeiActivation(String captchaBreak, OkHttpClient okHttpClient,
95
								  List<ImeiActivationTimestampModel> imeisActivationList) throws Exception {
93
								  List<ImeiActivationTimestampModel> imeisActivationList) throws Exception {
Line 99... Line 97...
99
			RequestBody formBody = new FormBody.Builder().add("imei", imei).add("code", captchaBreak).build();
97
			RequestBody formBody = new FormBody.Builder().add("imei", imei).add("code", captchaBreak).build();
100
 
98
 
101
			Request request1 = new Request.Builder().url("https://www.vivo.com/in/support/checkCode").post(formBody)
99
			Request request1 = new Request.Builder().url("https://www.vivo.com/in/support/checkCode").post(formBody)
102
					.build();
100
					.build();
103
 
101
 
-
 
102
			System.out.println("Getting Response from captcha");
104
			Response response2 = okHttpClient.newCall(request1).execute();
103
			Response response2 = okHttpClient.newCall(request1).execute();
105
			JSONObject imeiActivationJson = new JSONObject(response2.body().string());
104
			JSONObject imeiActivationJson = new JSONObject(response2.body().string());
106
			JSONObject data = imeiActivationJson.getJSONObject("data");
105
			JSONObject data = imeiActivationJson.getJSONObject("data");
107
 
106
 
108
			int status = data.getInt("status");
107
			int status = data.getInt("status");
109
			if (status == 0) {
108
			if (status == 0) {
-
 
109
				System.out.println("Invalid captcha " + captchaBreak);
110
				captchaBreak = this.getNewCaptcha(okHttpClient);
110
				captchaBreak = this.getNewCaptcha(okHttpClient);
-
 
111
				System.exit(0);
111
				continue;
112
				//continue;
112
			} else if (status == 2) {
113
			} else if (status == 2) {
113
				LOGGER.info("Received status 2 for {}", imei);
114
				LOGGER.info("Received status 2 for {}, data {}", imei, data);
-
 
115
				System.exit(0);
114
				continue;
116
				continue;
115
			}
117
			}
116
 
118
 
117
			JSONObject imeiQueryDto = data.getJSONObject("imeiQueryDto");
119
			JSONObject imeiQueryDto = data.getJSONObject("imeiQueryDto");
118
 
120
 
Line 120... Line 122...
120
			String dueTimeString = dueTimeObject.toString();
122
			String dueTimeString = dueTimeObject.toString();
121
 
123
 
122
			DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
124
			DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
123
			String dueTimeSplit = dueTimeString.split(" ")[0];
125
			String dueTimeSplit = dueTimeString.split(" ")[0];
124
 
126
 
125
			
-
 
126
 
127
 
127
			if (!StringUtils.isEmpty(dueTimeSplit)) {
128
			if (!StringUtils.isEmpty(dueTimeSplit)) {
128
				LocalDate dateTime = LocalDate.parse(dueTimeSplit, formatter);
129
				LocalDate dateTime = LocalDate.parse(dueTimeSplit, formatter);
129
				ActivatedImei activatedImei = activatedImeiRepository.selectBySerialNumber(imei);
130
				ActivatedImei activatedImei = activatedImeiRepository.selectBySerialNumber(imei);
130
				if (activatedImei == null) {
131
				if (activatedImei == null) {
Line 143... Line 144...
143
 
144
 
144
				LOGGER.info("vivoImeiStatusModel" + dateTime.atStartOfDay());
145
				LOGGER.info("vivoImeiStatusModel" + dateTime.atStartOfDay());
145
 
146
 
146
			}
147
			}
147
 
148
 
148
			
149
 
149
		}
150
		}
150
	}
151
	}
151
}
152
}
152
153