Rev 3121 | Rev 4484 | 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.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 List<OrderStatus> statuses = Arrays.asList(new OrderStatus[] {OrderStatus.PAYMENT_FAILED,OrderStatus.REFUNDED,OrderStatus.REJECTED,OrderStatus.DOA_INVALID_REFUNDED,OrderStatus.DOA_INVALID_RESHIPPED,OrderStatus.DOA_VALID_REFUNDED,OrderStatus.DOA_RESHIPPED,OrderStatus.SALES_RET_REFUNDED,OrderStatus.SALES_RET_RESHIPPED});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(), statuses);//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);}}