| Line 165... |
Line 165... |
| 165 |
} catch (TException e1) {
|
165 |
} catch (TException e1) {
|
| 166 |
log.error("Unable to update status of transaction. Thrift Exception:", e1);
|
166 |
log.error("Unable to update status of transaction. Thrift Exception:", e1);
|
| 167 |
} catch (TransactionServiceException e) {
|
167 |
} catch (TransactionServiceException e) {
|
| 168 |
log.error("Unable to update status of transaction. Thrift Exception: ", e);
|
168 |
log.error("Unable to update status of transaction. Thrift Exception: ", e);
|
| 169 |
}
|
169 |
}
|
| 170 |
trackCouponUsage(transaction);
|
170 |
long sum = resetCart(transaction, userServiceClient);
|
| 171 |
resetCart(transaction, userServiceClient);
|
171 |
trackCouponUsage(transaction, sum);
|
| 172 |
}
|
172 |
}
|
| 173 |
|
173 |
|
| 174 |
/**
|
174 |
/**
|
| 175 |
* Marks a transaction as well as all its orders as failed.
|
175 |
* Marks a transaction as well as all its orders as failed.
|
| 176 |
*
|
176 |
*
|
| Line 217... |
Line 217... |
| 217 |
transactionClient.changeTransactionStatus(txnId, TransactionStatus.COD_IN_PROCESS, "COD payment awaited", PickUpType.COURIER.getValue(), orderType, OrderSource.WEBSITE);
|
217 |
transactionClient.changeTransactionStatus(txnId, TransactionStatus.COD_IN_PROCESS, "COD payment awaited", PickUpType.COURIER.getValue(), orderType, OrderSource.WEBSITE);
|
| 218 |
Transaction transaction = transactionClient.getTransaction(txnId);
|
218 |
Transaction transaction = transactionClient.getTransaction(txnId);
|
| 219 |
transactionClient.enqueueTransactionInfoEmail(txnId);
|
219 |
transactionClient.enqueueTransactionInfoEmail(txnId);
|
| 220 |
|
220 |
|
| 221 |
UserClient userServiceClient = new UserClient();
|
221 |
UserClient userServiceClient = new UserClient();
|
| 222 |
trackCouponUsage(transaction);
|
222 |
long sum = resetCart(transaction, userServiceClient);
|
| 223 |
resetCart(transaction, userServiceClient);
|
223 |
trackCouponUsage(transaction, sum);
|
| 224 |
} catch (TException e1) {
|
224 |
} catch (TException e1) {
|
| 225 |
log.error("Unable to update status of transaction. Thrift Exception:", e1);
|
225 |
log.error("Unable to update status of transaction. Thrift Exception:", e1);
|
| 226 |
} catch (TransactionServiceException e) {
|
226 |
} catch (TransactionServiceException e) {
|
| 227 |
log.error("Unable to update status of transaction. Thrift Exception: ", e);
|
227 |
log.error("Unable to update status of transaction. Thrift Exception: ", e);
|
| 228 |
} catch (Exception e) {
|
228 |
} catch (Exception e) {
|
| Line 235... |
Line 235... |
| 235 |
TransactionClient transactionServiceClient = new TransactionClient();
|
235 |
TransactionClient transactionServiceClient = new TransactionClient();
|
| 236 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
|
236 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
|
| 237 |
transactionClient.changeTransactionStatus(txnId, TransactionStatus.AUTHORIZED, "Payment by coupon successful", PickUpType.COURIER.getValue(), orderType, OrderSource.WEBSITE);
|
237 |
transactionClient.changeTransactionStatus(txnId, TransactionStatus.AUTHORIZED, "Payment by coupon successful", PickUpType.COURIER.getValue(), orderType, OrderSource.WEBSITE);
|
| 238 |
Transaction transaction = transactionClient.getTransaction(txnId);
|
238 |
Transaction transaction = transactionClient.getTransaction(txnId);
|
| 239 |
UserClient userServiceClient = new UserClient();
|
239 |
UserClient userServiceClient = new UserClient();
|
| 240 |
trackCouponUsage(transaction);
|
240 |
long sum = resetCart(transaction, userServiceClient);
|
| 241 |
resetCart(transaction, userServiceClient);
|
241 |
trackCouponUsage(transaction, sum);
|
| 242 |
} catch (TException e1) {
|
242 |
} catch (TException e1) {
|
| 243 |
log.error("Unable to update status of transaction. Thrift Exception:", e1);
|
243 |
log.error("Unable to update status of transaction. Thrift Exception:", e1);
|
| 244 |
} catch (TransactionServiceException e) {
|
244 |
} catch (TransactionServiceException e) {
|
| 245 |
log.error("Unable to update status of transaction. Thrift Exception: ", e);
|
245 |
log.error("Unable to update status of transaction. Thrift Exception: ", e);
|
| 246 |
} catch (Exception e) {
|
246 |
} catch (Exception e) {
|
| Line 291... |
Line 291... |
| 291 |
* @param transaction
|
291 |
* @param transaction
|
| 292 |
* The transaction whose items have to be removed from the
|
292 |
* The transaction whose items have to be removed from the
|
| 293 |
* shopping cart.
|
293 |
* shopping cart.
|
| 294 |
* @param userServiceClient
|
294 |
* @param userServiceClient
|
| 295 |
*/
|
295 |
*/
|
| 296 |
private static void resetCart(Transaction transaction, UserClient userServiceClient) {
|
296 |
private static long resetCart(Transaction transaction, UserClient userServiceClient) {
|
| - |
|
297 |
long sum = 0;
|
| 297 |
Map<Long, Double> items = new HashMap<Long, Double>();
|
298 |
Map<Long, Double> items = new HashMap<Long, Double>();
|
| 298 |
for(Order order: transaction.getOrders()){
|
299 |
for(Order order: transaction.getOrders()){
|
| - |
|
300 |
sum += order.getGvAmount();
|
| 299 |
for(LineItem lineitem: order.getLineitems()){
|
301 |
for(LineItem lineitem: order.getLineitems()){
|
| 300 |
Long itemId = lineitem.getItem_id();
|
302 |
Long itemId = lineitem.getItem_id();
|
| 301 |
Double quantity = items.get(itemId);
|
303 |
Double quantity = items.get(itemId);
|
| 302 |
if(quantity==null){
|
304 |
if(quantity==null){
|
| 303 |
quantity = lineitem.getQuantity();
|
305 |
quantity = lineitem.getQuantity();
|
| Line 318... |
Line 320... |
| 318 |
} catch (ShoppingCartException e) {
|
320 |
} catch (ShoppingCartException e) {
|
| 319 |
log.error("Error while reseting the cart in cart database.", e);
|
321 |
log.error("Error while reseting the cart in cart database.", e);
|
| 320 |
}catch (Exception e) {
|
322 |
}catch (Exception e) {
|
| 321 |
log.error("Unexpected exception", e);
|
323 |
log.error("Unexpected exception", e);
|
| 322 |
}
|
324 |
}
|
| - |
|
325 |
|
| - |
|
326 |
return sum;
|
| 323 |
}
|
327 |
}
|
| 324 |
|
328 |
|
| 325 |
/**
|
329 |
/**
|
| 326 |
* Mark the coupon associated with the given transaction as used.
|
330 |
* Mark the coupon associated with the given transaction as used.
|
| 327 |
*
|
331 |
*
|
| Line 329... |
Line 333... |
| 329 |
* The transaction to track coupon for.
|
333 |
* The transaction to track coupon for.
|
| 330 |
*
|
334 |
*
|
| 331 |
* @param userServiceClient
|
335 |
* @param userServiceClient
|
| 332 |
* The user service client instance to use.
|
336 |
* The user service client instance to use.
|
| 333 |
*/
|
337 |
*/
|
| 334 |
private static void trackCouponUsage(Transaction transaction) {
|
338 |
private static void trackCouponUsage(Transaction transaction, long sum) {
|
| 335 |
try {
|
339 |
try {
|
| 336 |
String couponCode = transaction.getCoupon_code();
|
340 |
String couponCode = transaction.getCoupon_code();
|
| 337 |
|
341 |
|
| 338 |
if (couponCode != null && !couponCode.isEmpty()) {
|
342 |
if (couponCode != null && !couponCode.isEmpty()) {
|
| 339 |
PromotionClient promotionServiceClient = new PromotionClient();
|
343 |
PromotionClient promotionServiceClient = new PromotionClient();
|
| 340 |
promotionServiceClient.getClient().trackCouponUsage(couponCode, transaction.getId(), transaction.getCustomer_id());
|
344 |
promotionServiceClient.getClient().trackCouponUsage(couponCode, transaction.getId(), transaction.getCustomer_id(), sum, true);
|
| 341 |
}
|
345 |
}
|
| 342 |
} catch (PromotionException e) {
|
346 |
} catch (PromotionException e) {
|
| 343 |
log.error("Promotion Exception: " + e);
|
347 |
log.error("Promotion Exception: " + e);
|
| 344 |
} catch (TException e) {
|
348 |
} catch (TException e) {
|
| 345 |
log.error("Transport from Promotion Service failed:", e);
|
349 |
log.error("Transport from Promotion Service failed:", e);
|