Subversion Repositories SmartDukaan

Rev

Rev 7226 | Rev 7323 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package in.shop2020.serving.controllers;

import java.text.SimpleDateFormat;
import java.util.Date;

import in.shop2020.model.v1.catalog.Item;
import in.shop2020.thrift.clients.CatalogClient;

public class OrderDetailsController  extends BaseController {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private long itemId = 9161;
    private long product_id = 9161;
    private Item item;
    private Double price;
    private Double advanceAmount;
    private Long deliveryDate;
    private String displayDate;
    private String dealText;
    private String pin;
    
    public String index() {
        
        /**
         * The following code should be in create method.*********************************************************************
         */
        try {
            CatalogClient csc = new CatalogClient();
            setItem(csc.getClient().getItem(itemId));
            
            setDealText("Get a house free with this product");
            
       } catch (Exception e) {
           log.error("Unable to get item from catalog service", e);
       }
       /**
        * ****************END ************************************************************************************************
        */
       
       return INDEX;
    }
    
    public String create(){
        return index();
    }
    
    public String getProductName() {
        return item.getBrand() 
                + (item.getModelName() == null ? "" : " " + item.getModelName())
                + (item.getModelNumber() == null ? "" : " " + item.getModelNumber())
                + (item.getColor() == null ? "" : " (" + item.getColor() + ")");
    }
    
    public String getPricingDetails() {

        SimpleDateFormat sdf = new SimpleDateFormat("h:m a, d MMMM yyyy");
        /**
         * TODO : Ask for advance to be paid, price and DeliveryDate from catalog Service
         */
        price = 10000.0;
        advanceAmount = 6000.0;
        deliveryDate = 1367498907000L;
        
        setDisplayDate(sdf.format(new Date(deliveryDate)));
        return "pricing-details";
    }
    
    public void setItemId(long itemId) {
        this.itemId = itemId;
    }
    public long getItemId() {
        return itemId;
    }

    public void setItem(Item item) {
        this.item = item;
    }

    public Item getItem() {
        return item;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Double getAdvanceAmount() {
        return advanceAmount;
    }

    public void setAdvanceAmount(Double advanceAmount) {
        this.advanceAmount = advanceAmount;
    }

    public Long getDeliveryDate() {
        return deliveryDate;
    }

    public void setDeliveryDate(Long deliveryDate) {
        this.deliveryDate = deliveryDate;
    }

    public void setDisplayDate(String displayDate) {
        this.displayDate = displayDate;
    }

    public String getDisplayDate() {
        return displayDate;
    }

    public void setDealText(String dealText) {
        this.dealText = dealText;
    }

    public String getDealText() {
        return dealText;
    }

    public void setPin(String pin) {
        this.pin = pin;
    }

    public String getPin() {
        return pin;
    }

    public void setProduct_id(long product_id) {
        this.itemId = product_id;
    }

}