Rev 3121 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.serving.controllers;import in.shop2020.model.v1.order.Order;import in.shop2020.model.v1.order.OrderStatus;import in.shop2020.serving.utils.FormattingUtils;import in.shop2020.thrift.clients.TransactionServiceClient;import java.text.SimpleDateFormat;import java.util.Collections;import java.util.Date;import java.util.List;import org.apache.log4j.Logger;import org.apache.struts2.convention.annotation.InterceptorRef;import org.apache.struts2.convention.annotation.InterceptorRefs;import org.apache.struts2.convention.annotation.Result;import org.apache.struts2.convention.annotation.Results;@SuppressWarnings("serial")@InterceptorRefs({@InterceptorRef("myDefault"),@InterceptorRef("login")})@Results({@Result(name="redirect", type="redirectAction",params = {"actionName" , "login"})})public class FailedOrdersController extends BaseController {private static Logger logger = Logger.getLogger(FailedOrdersController.class);private FormattingUtils formattingUtils = new FormattingUtils();List<Order> orders = null;SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa");public String index(){logger.info("this.request=" + this.request);try {TransactionServiceClient transactionServiceClient = new TransactionServiceClient();in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();orders = orderClient.getOrdersForCustomer(userinfo.getUserId(), 0, (new Date()).getTime(), OrderStatus.PAYMENT_FAILED);//Reverse the list of order. Last come should be displayed first.Collections.reverse(orders);} catch (Exception e) {logger.error("Unable to get the failed orders of the customer", e);}return "index";}public String formatPrice(double price) {return formattingUtils.formatPrice(price);}public List<Order> getOrders() {return orders;}public String getOrderCreationDate(Order order){Date orderedOn = new Date(order.getCreated_timestamp());return dateformat.format(orderedOn);}}