Subversion Repositories SmartDukaan

Rev

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;
7386 anupam.sin 7
import in.shop2020.model.v1.order.HotspotStore;
7226 anupam.sin 8
import in.shop2020.thrift.clients.CatalogClient;
7386 anupam.sin 9
import in.shop2020.thrift.clients.TransactionClient;
7226 anupam.sin 10
 
11
public class OrderDetailsController  extends BaseController {
12
 
13
    /**
14
     * 
15
     */
16
    private static final long serialVersionUID = 1L;
17
    private long itemId = 9161;
18
    private long product_id = 9161;
19
    private Item item;
20
    private Double price;
21
    private Double advanceAmount;
22
    private Long deliveryDate;
23
    private String displayDate;
24
    private String dealText;
25
    private String pin;
7323 anupam.sin 26
    private String imageSource;
7226 anupam.sin 27
 
28
    public String index() {
7386 anupam.sin 29
        String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
30
        if(loginStatus == null || !loginStatus.equals("TRUE")){
31
            return "authfail";
32
        }
7226 anupam.sin 33
 
7386 anupam.sin 34
        storeId = Long.parseLong((String) request.getSession().getAttribute("STORE_ID"));
35
        if(!hotspotStores.containsKey(storeId)){
36
            try{
37
                HotspotStore hotSpotStore = (new TransactionClient()).getClient().getHotspotStore(storeId, "");
38
                hotspotStores.put(storeId, hotSpotStore);
39
            } catch (Exception e) {
40
                log.error("Unable to get store", e);
41
            }
42
        }
43
 
7226 anupam.sin 44
        /**
45
         * The following code should be in create method.*********************************************************************
46
         */
47
        try {
48
            CatalogClient csc = new CatalogClient();
7263 anupam.sin 49
            setItem(csc.getClient().getItem(product_id));
7226 anupam.sin 50
 
7323 anupam.sin 51
            //csc.getClient().getStorePricing(product_id).getBEstDEal
52
 
7386 anupam.sin 53
//            setDealText("Get a house free with this product");
7226 anupam.sin 54
 
55
       } catch (Exception e) {
56
           log.error("Unable to get item from catalog service", e);
57
       }
58
       /**
59
        * ****************END ************************************************************************************************
60
        */
61
 
62
       return INDEX;
63
    }
64
 
65
    public String create(){
66
        return index();
67
    }
68
 
69
    public String getProductName() {
70
        return item.getBrand() 
71
                + (item.getModelName() == null ? "" : " " + item.getModelName())
72
                + (item.getModelNumber() == null ? "" : " " + item.getModelNumber())
7323 anupam.sin 73
                + (item.getColor() == null || item.getColor() == "" ? "" : " (" + item.getColor() + ")");
7226 anupam.sin 74
    }
75
 
7386 anupam.sin 76
//    public String getPricingDetails() {
77
//
78
//        SimpleDateFormat sdf = new SimpleDateFormat("h:m a, d MMMM yyyy");
79
//        /**
80
//         * TODO : Ask for advance to be paid, price and DeliveryDate from catalog Service
81
//         */
82
//        
83
//        
84
//        price = 10000.0;
85
//        advanceAmount = 6000.0;
86
//        deliveryDate = 1367498907000L;
87
//        
88
//        setDisplayDate(sdf.format(new Date(deliveryDate)));
89
//        return "pricing-details";
90
//    }
7226 anupam.sin 91
 
92
    public void setItemId(long itemId) {
93
        this.itemId = itemId;
94
    }
95
    public long getItemId() {
96
        return itemId;
97
    }
98
 
99
    public void setItem(Item item) {
100
        this.item = item;
101
    }
102
 
103
    public Item getItem() {
104
        return item;
105
    }
106
 
107
    public Double getPrice() {
108
        return price;
109
    }
110
 
111
    public void setPrice(Double price) {
112
        this.price = price;
113
    }
114
 
115
    public Double getAdvanceAmount() {
116
        return advanceAmount;
117
    }
118
 
119
    public void setAdvanceAmount(Double advanceAmount) {
120
        this.advanceAmount = advanceAmount;
121
    }
122
 
123
    public Long getDeliveryDate() {
124
        return deliveryDate;
125
    }
126
 
127
    public void setDeliveryDate(Long deliveryDate) {
128
        this.deliveryDate = deliveryDate;
129
    }
130
 
131
    public void setDisplayDate(String displayDate) {
132
        this.displayDate = displayDate;
133
    }
134
 
135
    public String getDisplayDate() {
136
        return displayDate;
137
    }
138
 
139
    public void setDealText(String dealText) {
140
        this.dealText = dealText;
141
    }
142
 
143
    public String getDealText() {
144
        return dealText;
145
    }
146
 
147
    public void setPin(String pin) {
148
        this.pin = pin;
149
    }
150
 
151
    public String getPin() {
152
        return pin;
153
    }
154
 
155
    public void setProduct_id(long product_id) {
156
        this.itemId = product_id;
7323 anupam.sin 157
        this.product_id = product_id;
7226 anupam.sin 158
    }
159
 
7263 anupam.sin 160
    public long getProduct_id() {
161
        return product_id;
162
    }
163
 
7323 anupam.sin 164
    public String getImageSource() {
165
        return "/storewebsite/images/website/" + Long.toString(item.getCatalogItemId()) + "/default.jpg";
166
    }
167
 
168
    public void setImageSource(String imageSource) {
169
        this.imageSource = imageSource;
170
    }
171
 
7226 anupam.sin 172
}