Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
7226 anupam.sin 1
package in.shop2020.serving.controllers;
2
 
3
import java.text.SimpleDateFormat;
4
import java.util.Date;
5
 
6
import in.shop2020.model.v1.catalog.Item;
7
import in.shop2020.thrift.clients.CatalogClient;
8
 
9
public class OrderDetailsController  extends BaseController {
10
 
11
    /**
12
     * 
13
     */
14
    private static final long serialVersionUID = 1L;
15
    private long itemId = 9161;
16
    private long product_id = 9161;
17
    private Item item;
18
    private Double price;
19
    private Double advanceAmount;
20
    private Long deliveryDate;
21
    private String displayDate;
22
    private String dealText;
23
    private String pin;
24
 
25
    public String index() {
26
 
27
        /**
28
         * The following code should be in create method.*********************************************************************
29
         */
30
        try {
31
            CatalogClient csc = new CatalogClient();
7263 anupam.sin 32
            setItem(csc.getClient().getItem(product_id));
7226 anupam.sin 33
 
34
            setDealText("Get a house free with this product");
35
 
36
       } catch (Exception e) {
37
           log.error("Unable to get item from catalog service", e);
38
       }
39
       /**
40
        * ****************END ************************************************************************************************
41
        */
42
 
43
       return INDEX;
44
    }
45
 
46
    public String create(){
47
        return index();
48
    }
49
 
50
    public String getProductName() {
51
        return item.getBrand() 
52
                + (item.getModelName() == null ? "" : " " + item.getModelName())
53
                + (item.getModelNumber() == null ? "" : " " + item.getModelNumber())
54
                + (item.getColor() == null ? "" : " (" + item.getColor() + ")");
55
    }
56
 
57
    public String getPricingDetails() {
58
 
7248 anupam.sin 59
        SimpleDateFormat sdf = new SimpleDateFormat("h:m a, d MMMM yyyy");
7226 anupam.sin 60
        /**
61
         * TODO : Ask for advance to be paid, price and DeliveryDate from catalog Service
62
         */
7263 anupam.sin 63
 
64
 
7226 anupam.sin 65
        price = 10000.0;
66
        advanceAmount = 6000.0;
67
        deliveryDate = 1367498907000L;
68
 
69
        setDisplayDate(sdf.format(new Date(deliveryDate)));
70
        return "pricing-details";
71
    }
72
 
73
    public void setItemId(long itemId) {
74
        this.itemId = itemId;
75
    }
76
    public long getItemId() {
77
        return itemId;
78
    }
79
 
80
    public void setItem(Item item) {
81
        this.item = item;
82
    }
83
 
84
    public Item getItem() {
85
        return item;
86
    }
87
 
88
    public Double getPrice() {
89
        return price;
90
    }
91
 
92
    public void setPrice(Double price) {
93
        this.price = price;
94
    }
95
 
96
    public Double getAdvanceAmount() {
97
        return advanceAmount;
98
    }
99
 
100
    public void setAdvanceAmount(Double advanceAmount) {
101
        this.advanceAmount = advanceAmount;
102
    }
103
 
104
    public Long getDeliveryDate() {
105
        return deliveryDate;
106
    }
107
 
108
    public void setDeliveryDate(Long deliveryDate) {
109
        this.deliveryDate = deliveryDate;
110
    }
111
 
112
    public void setDisplayDate(String displayDate) {
113
        this.displayDate = displayDate;
114
    }
115
 
116
    public String getDisplayDate() {
117
        return displayDate;
118
    }
119
 
120
    public void setDealText(String dealText) {
121
        this.dealText = dealText;
122
    }
123
 
124
    public String getDealText() {
125
        return dealText;
126
    }
127
 
128
    public void setPin(String pin) {
129
        this.pin = pin;
130
    }
131
 
132
    public String getPin() {
133
        return pin;
134
    }
135
 
136
    public void setProduct_id(long product_id) {
137
        this.itemId = product_id;
138
    }
139
 
7263 anupam.sin 140
    public long getProduct_id() {
141
        return product_id;
142
    }
143
 
7226 anupam.sin 144
}