| Line 1... |
Line 1... |
| 1 |
package in.shop2020.serving.services;
|
1 |
package in.shop2020.serving.services;
|
| 2 |
|
2 |
|
| - |
|
3 |
import in.shop2020.logistics.PickUpType;
|
| 3 |
import in.shop2020.model.v1.order.EmiScheme;
|
4 |
import in.shop2020.model.v1.order.EmiScheme;
|
| 4 |
import in.shop2020.model.v1.order.LineItem;
|
5 |
import in.shop2020.model.v1.order.LineItem;
|
| 5 |
import in.shop2020.model.v1.order.Order;
|
6 |
import in.shop2020.model.v1.order.Order;
|
| 6 |
import in.shop2020.model.v1.order.OrderSource;
|
7 |
import in.shop2020.model.v1.order.OrderSource;
|
| - |
|
8 |
import in.shop2020.model.v1.order.OrderType;
|
| 7 |
import in.shop2020.model.v1.order.RechargeOrder;
|
9 |
import in.shop2020.model.v1.order.RechargeOrder;
|
| 8 |
import in.shop2020.model.v1.order.Transaction;
|
10 |
import in.shop2020.model.v1.order.Transaction;
|
| 9 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
11 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 10 |
import in.shop2020.model.v1.order.TransactionStatus;
|
12 |
import in.shop2020.model.v1.order.TransactionStatus;
|
| 11 |
import in.shop2020.model.v1.order.OrderType;
|
13 |
import in.shop2020.model.v1.user.PrivateDealUser;
|
| 12 |
import in.shop2020.model.v1.user.PromotionException;
|
14 |
import in.shop2020.model.v1.user.PromotionException;
|
| 13 |
import in.shop2020.model.v1.user.ShoppingCartException;
|
15 |
import in.shop2020.model.v1.user.ShoppingCartException;
|
| 14 |
import in.shop2020.logistics.PickUpType;
|
- |
|
| 15 |
import in.shop2020.payments.Payment;
|
16 |
import in.shop2020.payments.Payment;
|
| 16 |
import in.shop2020.payments.PaymentException;
|
17 |
import in.shop2020.payments.PaymentException;
|
| 17 |
import in.shop2020.payments.PaymentStatus;
|
18 |
import in.shop2020.payments.PaymentStatus;
|
| 18 |
import in.shop2020.serving.controllers.ProceedToPayController;
|
19 |
import in.shop2020.serving.controllers.ProceedToPayController;
|
| 19 |
import in.shop2020.thrift.clients.PaymentClient;
|
20 |
import in.shop2020.thrift.clients.PaymentClient;
|
| Line 25... |
Line 26... |
| 25 |
import java.util.List;
|
26 |
import java.util.List;
|
| 26 |
import java.util.Map;
|
27 |
import java.util.Map;
|
| 27 |
|
28 |
|
| 28 |
import org.apache.log4j.Logger;
|
29 |
import org.apache.log4j.Logger;
|
| 29 |
import org.apache.thrift.TException;
|
30 |
import org.apache.thrift.TException;
|
| - |
|
31 |
import org.apache.thrift.transport.TTransportException;
|
| 30 |
|
32 |
|
| 31 |
/**
|
33 |
/**
|
| 32 |
* This class has methods to be used to process non-gateway-specific aspects of
|
34 |
* This class has methods to be used to process non-gateway-specific aspects of
|
| 33 |
* payments and transactions.
|
35 |
* payments and transactions.
|
| 34 |
*
|
36 |
*
|
| Line 154... |
Line 156... |
| 154 |
tStatus = TransactionStatus.FLAGGED;
|
156 |
tStatus = TransactionStatus.FLAGGED;
|
| 155 |
description = "Payment flagged for the order";
|
157 |
description = "Payment flagged for the order";
|
| 156 |
}
|
158 |
}
|
| 157 |
try {
|
159 |
try {
|
| 158 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
|
160 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
|
| 159 |
transactionClient.changeTransactionStatus(txnId, tStatus, description, PickUpType.COURIER.getValue(), OrderType.B2C, OrderSource.WEBSITE);
|
- |
|
| 160 |
transaction = transactionClient.getTransaction(txnId);
|
161 |
transaction = transactionClient.getTransaction(txnId);
|
| - |
|
162 |
|
| - |
|
163 |
transactionClient.changeTransactionStatus(txnId, tStatus, description, PickUpType.COURIER.getValue(), getOrderType(transaction.getCustomer_id()), OrderSource.WEBSITE);
|
| 161 |
transactionClient.enqueueTransactionInfoEmail(txnId);
|
164 |
transactionClient.enqueueTransactionInfoEmail(txnId);
|
| 162 |
} catch (TException e1) {
|
165 |
} catch (TException e1) {
|
| 163 |
log.error("Unable to update status of transaction. Thrift Exception:", e1);
|
166 |
log.error("Unable to update status of transaction. Thrift Exception:", e1);
|
| 164 |
} catch (TransactionServiceException e) {
|
167 |
} catch (TransactionServiceException e) {
|
| 165 |
log.error("Unable to update status of transaction. Thrift Exception: ", e);
|
168 |
log.error("Unable to update status of transaction. Thrift Exception: ", e);
|
| Line 205... |
Line 208... |
| 205 |
*
|
208 |
*
|
| 206 |
* @param txnId
|
209 |
* @param txnId
|
| 207 |
* The COD transaction which should be marked as verification
|
210 |
* The COD transaction which should be marked as verification
|
| 208 |
* pending.
|
211 |
* pending.
|
| 209 |
*/
|
212 |
*/
|
| 210 |
public static void processCodTxn(long txnId){
|
213 |
public static void processCodTxn(long txnId, OrderType orderType){
|
| 211 |
try {
|
214 |
try {
|
| 212 |
TransactionClient transactionServiceClient = new TransactionClient();
|
215 |
TransactionClient transactionServiceClient = new TransactionClient();
|
| 213 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
|
216 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
|
| 214 |
transactionClient.changeTransactionStatus(txnId, TransactionStatus.COD_IN_PROCESS, "COD payment awaited", PickUpType.COURIER.getValue(), OrderType.B2C, OrderSource.WEBSITE);
|
217 |
transactionClient.changeTransactionStatus(txnId, TransactionStatus.COD_IN_PROCESS, "COD payment awaited", PickUpType.COURIER.getValue(), orderType, OrderSource.WEBSITE);
|
| 215 |
Transaction transaction = transactionClient.getTransaction(txnId);
|
218 |
Transaction transaction = transactionClient.getTransaction(txnId);
|
| 216 |
transactionClient.enqueueTransactionInfoEmail(txnId);
|
219 |
transactionClient.enqueueTransactionInfoEmail(txnId);
|
| 217 |
|
220 |
|
| 218 |
UserClient userServiceClient = new UserClient();
|
221 |
UserClient userServiceClient = new UserClient();
|
| 219 |
trackCouponUsage(transaction);
|
222 |
trackCouponUsage(transaction);
|
| Line 225... |
Line 228... |
| 225 |
} catch (Exception e) {
|
228 |
} catch (Exception e) {
|
| 226 |
log.error("Unable to update status of transaction. Thrift Exception: ", e);
|
229 |
log.error("Unable to update status of transaction. Thrift Exception: ", e);
|
| 227 |
}
|
230 |
}
|
| 228 |
}
|
231 |
}
|
| 229 |
|
232 |
|
| 230 |
public static void processCouponTxn(long txnId){
|
233 |
public static void processCouponTxn(long txnId, OrderType orderType){
|
| 231 |
try {
|
234 |
try {
|
| 232 |
TransactionClient transactionServiceClient = new TransactionClient();
|
235 |
TransactionClient transactionServiceClient = new TransactionClient();
|
| 233 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
|
236 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
|
| 234 |
transactionClient.changeTransactionStatus(txnId, TransactionStatus.AUTHORIZED, "Payment by coupon successful", PickUpType.COURIER.getValue(), OrderType.B2C, OrderSource.WEBSITE);
|
237 |
transactionClient.changeTransactionStatus(txnId, TransactionStatus.AUTHORIZED, "Payment by coupon successful", PickUpType.COURIER.getValue(), orderType, OrderSource.WEBSITE);
|
| 235 |
Transaction transaction = transactionClient.getTransaction(txnId);
|
238 |
Transaction transaction = transactionClient.getTransaction(txnId);
|
| 236 |
UserClient userServiceClient = new UserClient();
|
239 |
UserClient userServiceClient = new UserClient();
|
| 237 |
trackCouponUsage(transaction);
|
240 |
trackCouponUsage(transaction);
|
| 238 |
resetCart(transaction, userServiceClient);
|
241 |
resetCart(transaction, userServiceClient);
|
| 239 |
} catch (TException e1) {
|
242 |
} catch (TException e1) {
|
| Line 392... |
Line 395... |
| 392 |
System.out.println(miscCharges);
|
395 |
System.out.println(miscCharges);
|
| 393 |
if(miscCharges != null & !miscCharges.isEmpty()){
|
396 |
if(miscCharges != null & !miscCharges.isEmpty()){
|
| 394 |
System.out.println( miscCharges.get(1L));;
|
397 |
System.out.println( miscCharges.get(1L));;
|
| 395 |
}
|
398 |
}
|
| 396 |
}
|
399 |
}
|
| - |
|
400 |
|
| - |
|
401 |
private static OrderType getOrderType(Long userId) throws TTransportException, TException{
|
| - |
|
402 |
OrderType ot = OrderType.B2C;
|
| - |
|
403 |
try {
|
| - |
|
404 |
|
| - |
|
405 |
in.shop2020.model.v1.user.UserContextService.Client uc = new UserClient().getClient();
|
| - |
|
406 |
PrivateDealUser pdu = uc.getPrivateDealUser(userId);
|
| - |
|
407 |
if(pdu.getTin() != null && !pdu.getTin().trim().equals("")){
|
| - |
|
408 |
ot = OrderType.B2B;
|
| - |
|
409 |
}
|
| - |
|
410 |
} catch (TTransportException e) {
|
| - |
|
411 |
log.error("Unable to get user service client.", e);
|
| - |
|
412 |
}
|
| - |
|
413 |
return ot;
|
| - |
|
414 |
}
|
| 397 |
}
|
415 |
}
|