Subversion Repositories SmartDukaan

Rev

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

Rev 3010 Rev 3063
Line 106... Line 106...
106
	// references has a performance overhead. Need to think more about this.
106
	// references has a performance overhead. Need to think more about this.
107
 
107
 
108
	/**
108
	/**
109
	 * Processes a successful transaction by:
109
	 * Processes a successful transaction by:
110
	 * <ol>
110
	 * <ol>
111
	 * <li>Marking the given transaction as 'in process'.</li>
111
	 * <li>Marking the given transaction as 'authorized'.</li>
112
	 * <li>Removing the items in the cart for which the given transaction was
112
	 * <li>Removing the items in the cart for which the given transaction was
113
	 * processed.</li>
113
	 * processed.</li>
114
	 * <li>Marking the coupon associated with this transaction, if any, as used
114
	 * <li>Marking the coupon associated with this transaction, if any, as used
115
	 * for this user.</li>
115
	 * for this user.</li>
116
	 * <li>Queuing the transaction successful email, containing transaction
116
	 * <li>Queuing the transaction successful email, containing transaction
Line 161... Line 161...
161
		} catch (TransactionServiceException e) {
161
		} catch (TransactionServiceException e) {
162
			log.error("Error while updating status information in transaction database.", e);
162
			log.error("Error while updating status information in transaction database.", e);
163
		}
163
		}
164
	}
164
	}
165
 
165
 
-
 
166
    /**
-
 
167
     * Processes a COD transaction by:
-
 
168
     * <ol>
-
 
169
     * <li>Setting the COD flag of all the orders and moving them to the INIT
-
 
170
     * state.
-
 
171
     * <li>Marking the given transaction to be in COD_IN_PROCESS state
-
 
172
     * <li>Marking the coupon associated with this transaction, if any, as used
-
 
173
     * for this user.</li>
-
 
174
     * <li>Queuing the transaction successful email, containing transaction
-
 
175
     * info, to be sent later by a batch job.</li>
-
 
176
     * </ol>
-
 
177
     * <br>
-
 
178
     * Please note that it's possible that a user has added items to the cart
-
 
179
     * and so it's not possible to simply wipe out their cart. Therefore, it's
-
 
180
     * important to ensure that we remove only as much quantity of items as for
-
 
181
     * which the order was processed.
-
 
182
     * 
-
 
183
     * @param txnId
-
 
184
     *            The COD transaction which should be marked as verification
-
 
185
     *            pending.
-
 
186
     */
-
 
187
	public static void processCodTxn(long txnId){
-
 
188
        try {            
-
 
189
            TransactionServiceClient transactionServiceClient = new TransactionServiceClient();
-
 
190
            in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
-
 
191
            transactionClient.changeTransactionStatus(txnId, TransactionStatus.COD_IN_PROCESS, "COD payment awaited");
-
 
192
            Transaction transaction = transactionClient.getTransaction(txnId);
-
 
193
            transactionClient.enqueueTransactionInfoEmail(txnId);
-
 
194
            
-
 
195
            UserContextServiceClient userServiceClient = new UserContextServiceClient();
-
 
196
            trackCouponUsage(transaction);
-
 
197
            resetCart(transaction, userServiceClient);
-
 
198
        } catch (TException e1) {
-
 
199
            log.error("Unable to update status of transaction. Thrift Exception:", e1);
-
 
200
        } catch (TransactionServiceException e) {
-
 
201
            log.error("Unable to update status of transaction. Thrift Exception: ", e);
-
 
202
        } catch (Exception e) {
-
 
203
            log.error("Unable to update status of transaction. Thrift Exception: ", e);
-
 
204
        }
-
 
205
	}
-
 
206
	
166
	/**
207
	/**
167
	 * Calculates the amount for the payment required for the given cart.
208
	 * Calculates the amount for the payment required for the given cart.
168
	 * 
209
	 * 
169
	 * @param cartId
210
	 * @param cartId
170
	 *            Id of the cart for which this payment amount has to be
211
	 *            Id of the cart for which this payment amount has to be
Line 226... Line 267...
226
				}
267
				}
227
				items.put(itemId, quantity);
268
				items.put(itemId, quantity);
228
			}
269
			}
229
		}
270
		}
230
		
271
		
231
		log.debug("Items to restr in cart are: " + items);
272
		log.debug("Items to reset in cart are: " + items);
232
		
273
		
233
		try {
274
		try {
234
			//TODO Optimize the function to send less data over the wire
275
			//TODO Optimize the function to send less data over the wire
235
            userServiceClient.getClient().resetCart(transaction.getShoppingCartid(), items);
276
            userServiceClient.getClient().resetCart(transaction.getShoppingCartid(), items);
236
		}catch (TException e) {
277
		}catch (TException e) {