Subversion Repositories SmartDukaan

Rev

Rev 7263 | Rev 7386 | 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;
7323 anupam.sin 24
    private String imageSource;
7226 anupam.sin 25
 
26
    public String index() {
27
 
28
        /**
29
         * The following code should be in create method.*********************************************************************
30
         */
31
        try {
32
            CatalogClient csc = new CatalogClient();
7263 anupam.sin 33
            setItem(csc.getClient().getItem(product_id));
7226 anupam.sin 34
 
7323 anupam.sin 35
            //csc.getClient().getStorePricing(product_id).getBEstDEal
36
 
7226 anupam.sin 37
            setDealText("Get a house free with this product");
38
 
39
       } catch (Exception e) {
40
           log.error("Unable to get item from catalog service", e);
41
       }
42
       /**
43
        * ****************END ************************************************************************************************
44
        */
45
 
46
       return INDEX;
47
    }
48
 
49
    public String create(){
50
        return index();
51
    }
52
 
53
    public String getProductName() {
54
        return item.getBrand() 
55
                + (item.getModelName() == null ? "" : " " + item.getModelName())
56
                + (item.getModelNumber() == null ? "" : " " + item.getModelNumber())
7323 anupam.sin 57
                + (item.getColor() == null || item.getColor() == "" ? "" : " (" + item.getColor() + ")");
7226 anupam.sin 58
    }
59
 
60
    public String getPricingDetails() {
61
 
7248 anupam.sin 62
        SimpleDateFormat sdf = new SimpleDateFormat("h:m a, d MMMM yyyy");
7226 anupam.sin 63
        /**
64
         * TODO : Ask for advance to be paid, price and DeliveryDate from catalog Service
65
         */
7263 anupam.sin 66
 
67
 
7226 anupam.sin 68
        price = 10000.0;
69
        advanceAmount = 6000.0;
70
        deliveryDate = 1367498907000L;
71
 
72
        setDisplayDate(sdf.format(new Date(deliveryDate)));
73
        return "pricing-details";
74
    }
75
 
76
    public void setItemId(long itemId) {
77
        this.itemId = itemId;
78
    }
79
    public long getItemId() {
80
        return itemId;
81
    }
82
 
83
    public void setItem(Item item) {
84
        this.item = item;
85
    }
86
 
87
    public Item getItem() {
88
        return item;
89
    }
90
 
91
    public Double getPrice() {
92
        return price;
93
    }
94
 
95
    public void setPrice(Double price) {
96
        this.price = price;
97
    }
98
 
99
    public Double getAdvanceAmount() {
100
        return advanceAmount;
101
    }
102
 
103
    public void setAdvanceAmount(Double advanceAmount) {
104
        this.advanceAmount = advanceAmount;
105
    }
106
 
107
    public Long getDeliveryDate() {
108
        return deliveryDate;
109
    }
110
 
111
    public void setDeliveryDate(Long deliveryDate) {
112
        this.deliveryDate = deliveryDate;
113
    }
114
 
115
    public void setDisplayDate(String displayDate) {
116
        this.displayDate = displayDate;
117
    }
118
 
119
    public String getDisplayDate() {
120
        return displayDate;
121
    }
122
 
123
    public void setDealText(String dealText) {
124
        this.dealText = dealText;
125
    }
126
 
127
    public String getDealText() {
128
        return dealText;
129
    }
130
 
131
    public void setPin(String pin) {
132
        this.pin = pin;
133
    }
134
 
135
    public String getPin() {
136
        return pin;
137
    }
138
 
139
    public void setProduct_id(long product_id) {
140
        this.itemId = product_id;
7323 anupam.sin 141
        this.product_id = product_id;
7226 anupam.sin 142
    }
143
 
7263 anupam.sin 144
    public long getProduct_id() {
145
        return product_id;
146
    }
147
 
7323 anupam.sin 148
    public String getImageSource() {
149
        return "/storewebsite/images/website/" + Long.toString(item.getCatalogItemId()) + "/default.jpg";
150
    }
151
 
152
    public void setImageSource(String imageSource) {
153
        this.imageSource = imageSource;
154
    }
155
 
7226 anupam.sin 156
}