Subversion Repositories SmartDukaan

Rev

Rev 3994 | Rev 4172 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3994 Rev 4004
Line 1... Line 1...
1
package in.shop2020.hotspot.dashbaord.shared.actions;
1
package in.shop2020.hotspot.dashbaord.shared.actions;
2
 
2
 
-
 
3
import java.util.Date;
-
 
4
 
3
import com.google.gwt.user.client.rpc.IsSerializable;
5
import com.google.gwt.user.client.rpc.IsSerializable;
4
 
6
 
5
public class Order implements IsSerializable{
7
public class Order implements IsSerializable{
6
	
8
	
7
	private static final long serialVersionUID = 5804421607858217477L;
9
	private static final long serialVersionUID = 5804421607858217477L;
-
 
10
	
-
 
11
	private static final long MS_IN_HOUR  = 3600000;
8
 
12
 
9
	private long orderId;
13
	private long orderId;
10
	private long customerId;
14
	private long customerId;
11
	private String customerName;
15
	private String customerName;
12
	private String customerMobileNumber;
16
	private String customerMobileNumber;
Line 16... Line 20...
16
	private String customerCity;
20
	private String customerCity;
17
	private String customerState;
21
	private String customerState;
18
	private String customerEmail;
22
	private String customerEmail;
19
	
23
	
20
	private long createdOn;
24
	private long createdOn;
-
 
25
	private long shippedAt;
-
 
26
	private long verifiedAt;
21
	private long expectedDeliveryTime;
27
	private long expectedDeliveryTime;
22
	private long promisedDeliveryTime;
28
	private long promisedDeliveryTime;
-
 
29
	private long expectedShippingTime;
23
	
30
	
24
	private long status;
31
	private long status;
25
	private String statusMessage;
32
	private String statusMessage;
26
	
33
	
27
	private long itemId;
34
	private long itemId;
Line 41... Line 48...
41
	private long jacketNumber;
48
	private long jacketNumber;
42
	private String itemNumber;
49
	private String itemNumber;
43
	private long imeiNumber;
50
	private long imeiNumber;
44
	private long batchNo;
51
	private long batchNo;
45
	private long serialNo;
52
	private long serialNo;
46
	private boolean alert;
-
 
47
	
53
	
48
	private boolean doaFlag;
54
	private boolean doaFlag;
49
	private String pickupRequestNo;
55
	private String pickupRequestNo;
50
	private boolean cod;
56
	private boolean cod;
51
	
57
	
52
	private String delayReason;
58
	private String delayReason;
53
	
59
	
-
 
60
	private Alert alert;
-
 
61
	
54
	@SuppressWarnings("unused")
62
	@SuppressWarnings("unused")
55
	private Order(){}
63
	private Order(){}
56
 
64
 
57
	public Order(long orderId, long customerId, String customerName,
65
	public Order(long orderId, long customerId, String customerName,
58
			String customerMobileNumber, String customerPincode,
66
			String customerMobileNumber, String customerPincode,
59
			String customerAddress1, String customerAddress2, String customerCity, String customerState, String customerEmail, long createdOn,
67
			String customerAddress1, String customerAddress2, String customerCity, String customerState, String customerEmail, long createdOn,
-
 
68
			long shippedAt,
-
 
69
			long verifiedAt,
-
 
70
			long expectedDeliveryTime,
-
 
71
			long promisedDeliveryTime,
-
 
72
			long expectedShippingTime,
60
			long expectedDeliveryTime, long promisedDeliveryTime, long status, String statusMessage,
73
			long status, String statusMessage,
61
			long itemId, String productGroup, String brand, String modelName,
74
			long itemId, String productGroup, String brand, String modelName,
62
			String modelNumber, String color, String extraInfo, double totalAmount,
75
			String modelNumber, String color, String extraInfo, double totalAmount,
63
			double totalWeight, String airwayBillNo, String billedBy,
76
			double totalWeight, String airwayBillNo, String billedBy,
64
			String invoiceNumber, long jacketNumber, String itemNumber,
77
			String invoiceNumber, long jacketNumber, String itemNumber,
65
			long imeiNumber, long batchNo, long serialNo, boolean alert,
78
			long imeiNumber, long batchNo, long serialNo,
66
			boolean doaFlag, String pickupRequestNo, boolean cod, String delayReason) {
79
			boolean doaFlag, String pickupRequestNo, boolean cod, String delayReason) {
67
		super();
80
		super();
68
		this.orderId = orderId;
81
		this.orderId = orderId;
69
		this.customerId = customerId;
82
		this.customerId = customerId;
70
		this.customerName = customerName;
83
		this.customerName = customerName;
Line 74... Line 87...
74
		this.customerAddress2 = customerAddress2;
87
		this.customerAddress2 = customerAddress2;
75
		this.customerCity = customerCity;
88
		this.customerCity = customerCity;
76
		this.customerState = customerState;
89
		this.customerState = customerState;
77
		this.customerEmail = customerEmail;
90
		this.customerEmail = customerEmail;
78
		this.createdOn = createdOn;
91
		this.createdOn = createdOn;
-
 
92
		this.shippedAt = shippedAt;
-
 
93
		this.verifiedAt = verifiedAt;
79
		this.expectedDeliveryTime = expectedDeliveryTime;
94
		this.expectedDeliveryTime = expectedDeliveryTime;
80
		this.promisedDeliveryTime = promisedDeliveryTime;
95
		this.promisedDeliveryTime = promisedDeliveryTime;
-
 
96
		this.expectedShippingTime = expectedShippingTime;
81
		this.status = status;
97
		this.status = status;
82
		this.statusMessage = statusMessage;
98
		this.statusMessage = statusMessage;
83
		this.itemId = itemId;
99
		this.itemId = itemId;
84
		this.productGroup = productGroup;
100
		this.productGroup = productGroup;
85
		this.brand = brand;
101
		this.brand = brand;
Line 95... Line 111...
95
		this.jacketNumber = jacketNumber;
111
		this.jacketNumber = jacketNumber;
96
		this.itemNumber = itemNumber;
112
		this.itemNumber = itemNumber;
97
		this.imeiNumber = imeiNumber;
113
		this.imeiNumber = imeiNumber;
98
		this.batchNo = batchNo;
114
		this.batchNo = batchNo;
99
		this.serialNo = serialNo;
115
		this.serialNo = serialNo;
100
		this.alert = alert;
-
 
101
		this.doaFlag = doaFlag;
116
		this.doaFlag = doaFlag;
102
		this.pickupRequestNo = pickupRequestNo;
117
		this.pickupRequestNo = pickupRequestNo;
103
		this.cod = cod;
118
		this.cod = cod;
104
		this.delayReason = delayReason;
119
		this.delayReason = delayReason;
-
 
120
		checkForAlerts();
105
	}
121
	}
106
 
122
 
-
 
123
	private void checkForAlerts(){
-
 
124
	    this.alert = Alert.NONE;
-
 
125
	    Date date = new Date();
-
 
126
	    long currentTime = date.getTime();
-
 
127
	    if(this.expectedDeliveryTime <= currentTime && this.status < 12){
-
 
128
	        //Orders whose delivery dates have passed but which are not yet delivered
-
 
129
	        this.alert = Alert.DELIVERY_TIME_EXCEEDED;
-
 
130
	        return;
-
 
131
	    }
-
 
132
	    
-
 
133
	    if(this.expectedShippingTime <= currentTime && this.status < 9){
-
 
134
	        //Orders whose expected shipping dates have passed but which have not been shipped yet
-
 
135
	        this.alert = Alert.SHIPPING_TIME_EXCEEDED;
-
 
136
	        return;
-
 
137
	    }
-
 
138
	    
-
 
139
	    if(this.createdOn <= currentTime - 2 * MS_IN_HOUR && this.status == 3 && !this.cod){
-
 
140
            //A prepaid order has neither been accepted nor marked out of stock after 2 hours of order creation
-
 
141
            this.alert = Alert.ACCEPTANCE_DELAYED_TOO_MUCH;
-
 
142
            return;
-
 
143
        }
-
 
144
	    
-
 
145
	    if(this.verifiedAt <= currentTime - 2 * MS_IN_HOUR && this.status == 3 && this.cod){
-
 
146
	        //A COD order has neither been accepted nor marked out of stock after 2 hours of order verification
-
 
147
            this.alert = Alert.ACCEPTANCE_DELAYED_TOO_MUCH;
-
 
148
            return;
-
 
149
	    }
-
 
150
	    
-
 
151
	    if(this.shippedAt <= currentTime - 27 * MS_IN_HOUR && this.status == 9){
-
 
152
            //A shipped order has not been picked up even after 6 hours of pickup mismatch being reported
-
 
153
            this.alert = Alert.ORDER_NOT_CONNECTED_FOR_TOO_LONG;
-
 
154
            return;
-
 
155
        }
-
 
156
	    
-
 
157
	    if(this.cod && this.status == 2 && this.createdOn <= currentTime - MS_IN_HOUR){
-
 
158
	        //A COD order has not been verified for an hour
-
 
159
	        this.alert = Alert.VERIFICATION_DELAYED;
-
 
160
            return;
-
 
161
	    }
-
 
162
	    
-
 
163
        if(this.createdOn <= currentTime - MS_IN_HOUR && this.status == 3 && !this.cod){
-
 
164
            //A prepaid order has neither been accepted nor marked out of stock after 1 hour of order creation
-
 
165
            this.alert = Alert.ACCEPTANCE_DELAYED;
-
 
166
            return;
-
 
167
        }
-
 
168
	    
-
 
169
        if(this.verifiedAt <= currentTime - MS_IN_HOUR && this.status == 3 && this.cod){
-
 
170
            //A COD order has neither been accepted nor marked out of stock after an hour of order verification
-
 
171
            this.alert = Alert.ACCEPTANCE_DELAYED;
-
 
172
            return;
-
 
173
        }
-
 
174
        
-
 
175
	    if(this.status == 9 && this.shippedAt <= currentTime - 20 * MS_IN_HOUR){
-
 
176
            //A shipped order has not been picked up
-
 
177
            this.alert = Alert.ORDER_NOT_CONNECTED;
-
 
178
            return;
-
 
179
	    }
-
 
180
	}
-
 
181
	
107
	public long getCustomerId() {
182
	public long getCustomerId() {
108
		return customerId;
183
		return customerId;
109
	}
184
	}
110
 
185
 
111
	public long getCreatedOn() {
186
	public long getCreatedOn() {
Line 126... Line 201...
126
	
201
	
127
	public String getStatusMessage() {
202
	public String getStatusMessage() {
128
		return statusMessage;
203
		return statusMessage;
129
	}
204
	}
130
 
205
 
131
	public boolean isAlert() {
-
 
132
		return alert;
-
 
133
	}
-
 
134
 
-
 
135
	public void setAlert(boolean alert) {
-
 
136
		this.alert = alert;
-
 
137
	}
-
 
138
 
-
 
139
	public void setOrderId(long orderId) {
206
	public void setOrderId(long orderId) {
140
		this.orderId = orderId;
207
		this.orderId = orderId;
141
	}
208
	}
142
 
209
 
143
	public long getOrderId() {
210
	public long getOrderId() {
Line 373... Line 440...
373
    }
440
    }
374
 
441
 
375
    public String getDelayReason() {
442
    public String getDelayReason() {
376
        return delayReason;
443
        return delayReason;
377
    }
444
    }
-
 
445
 
-
 
446
    public void setAlert(Alert alert) {
-
 
447
        this.alert = alert;
-
 
448
    }
-
 
449
 
-
 
450
    public Alert getAlert() {
-
 
451
        return alert;
-
 
452
    }
378
}
453
}