Rev 4684 | 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.model.v1.order.OrderStatusGroups;import in.shop2020.serving.utils.FormattingUtils;import in.shop2020.thrift.clients.TransactionClient;import java.text.SimpleDateFormat;import java.util.Arrays;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 static final OrderStatusGroups statusGroup = new OrderStatusGroups();private static final List<OrderStatus> failedOrderStatuses = statusGroup.getFailedOrders();private FormattingUtils formattingUtils = new FormattingUtils();SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa");List<Order> orders = null;public String index(){logger.info("this.request=" + this.request);try {TransactionClient transactionServiceClient = new TransactionClient();in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();orders = orderClient.getOrdersForCustomer(userinfo.getUserId(), 0, (new Date()).getTime(), failedOrderStatuses);//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);}}