Subversion Repositories SmartDukaan

Rev

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

Rev 4172 Rev 4398
Line 56... Line 56...
56
	private String pickupRequestNo;
56
	private String pickupRequestNo;
57
	private boolean cod;
57
	private boolean cod;
58
	
58
	
59
	private String delayReason;
59
	private String delayReason;
60
	
60
	
61
	private Alert alert;
61
	private OrderAlert alert;
62
	
62
	
63
	@SuppressWarnings("unused")
63
	@SuppressWarnings("unused")
64
	private Order(){}
64
	private Order(){}
65
 
65
 
66
	public Order(long orderId, long customerId, String customerName,
66
	public Order(long orderId, long customerId, String customerName,
Line 121... Line 121...
121
		this.delayReason = delayReason;
121
		this.delayReason = delayReason;
122
		checkForAlerts();
122
		checkForAlerts();
123
	}
123
	}
124
 
124
 
125
	private void checkForAlerts(){
125
	private void checkForAlerts(){
126
	    this.alert = Alert.NONE;
126
	    this.alert = OrderAlert.NONE;
127
	    Date date = new Date();
127
	    Date date = new Date();
128
	    long currentTime = date.getTime();
128
	    long currentTime = date.getTime();
129
	    if(this.expectedDeliveryTime <= currentTime && this.status < 12){
129
	    if(this.expectedDeliveryTime <= currentTime && this.status < 12){
130
	        //Orders whose delivery dates have passed but which are not yet delivered
130
	        //Orders whose delivery dates have passed but which are not yet delivered
131
	        this.alert = Alert.DELIVERY_TIME_EXCEEDED;
131
	        this.alert = OrderAlert.DELIVERY_TIME_EXCEEDED;
132
	        return;
132
	        return;
133
	    }
133
	    }
134
	    
134
	    
135
	    if(this.expectedShippingTime <= currentTime && this.status < 9){
135
	    if(this.expectedShippingTime <= currentTime && this.status < 9){
136
	        //Orders whose expected shipping dates have passed but which have not been shipped yet
136
	        //Orders whose expected shipping dates have passed but which have not been shipped yet
137
	        this.alert = Alert.SHIPPING_TIME_EXCEEDED;
137
	        this.alert = OrderAlert.SHIPPING_TIME_EXCEEDED;
138
	        return;
138
	        return;
139
	    }
139
	    }
140
	    
140
	    
141
	    if(this.createdOn <= currentTime - 2 * MS_IN_HOUR && this.status == 3 && !this.cod){
141
	    if(this.createdOn <= currentTime - 2 * MS_IN_HOUR && this.status == 3 && !this.cod){
142
            //A prepaid order has neither been accepted nor marked out of stock after 2 hours of order creation
142
            //A prepaid order has neither been accepted nor marked out of stock after 2 hours of order creation
143
            this.alert = Alert.ACCEPTANCE_DELAYED_TOO_MUCH;
143
            this.alert = OrderAlert.ACCEPTANCE_DELAYED_TOO_MUCH;
144
            return;
144
            return;
145
        }
145
        }
146
	    
146
	    
147
	    if(this.verifiedAt <= currentTime - 2 * MS_IN_HOUR && this.status == 3 && this.cod){
147
	    if(this.verifiedAt <= currentTime - 2 * MS_IN_HOUR && this.status == 3 && this.cod){
148
	        //A COD order has neither been accepted nor marked out of stock after 2 hours of order verification
148
	        //A COD order has neither been accepted nor marked out of stock after 2 hours of order verification
149
            this.alert = Alert.ACCEPTANCE_DELAYED_TOO_MUCH;
149
            this.alert = OrderAlert.ACCEPTANCE_DELAYED_TOO_MUCH;
150
            return;
150
            return;
151
	    }
151
	    }
152
	    
152
	    
153
	    if(this.shippedAt <= currentTime - 27 * MS_IN_HOUR && this.status == 9){
153
	    if(this.shippedAt <= currentTime - 27 * MS_IN_HOUR && this.status == 9){
154
            //A shipped order has not been picked up even after 6 hours of pickup mismatch being reported
154
            //A shipped order has not been picked up even after 6 hours of pickup mismatch being reported
155
            this.alert = Alert.ORDER_NOT_CONNECTED_FOR_TOO_LONG;
155
            this.alert = OrderAlert.ORDER_NOT_CONNECTED_FOR_TOO_LONG;
156
            return;
156
            return;
157
        }
157
        }
158
	    
158
	    
159
	    if(this.cod && this.status == 2 && this.createdOn <= currentTime - MS_IN_HOUR){
159
	    if(this.cod && this.status == 2 && this.createdOn <= currentTime - MS_IN_HOUR){
160
	        //A COD order has not been verified for an hour
160
	        //A COD order has not been verified for an hour
161
	        this.alert = Alert.VERIFICATION_DELAYED;
161
	        this.alert = OrderAlert.VERIFICATION_DELAYED;
162
            return;
162
            return;
163
	    }
163
	    }
164
	    
164
	    
165
        if(this.createdOn <= currentTime - MS_IN_HOUR && this.status == 3 && !this.cod){
165
        if(this.createdOn <= currentTime - MS_IN_HOUR && this.status == 3 && !this.cod){
166
            //A prepaid order has neither been accepted nor marked out of stock after 1 hour of order creation
166
            //A prepaid order has neither been accepted nor marked out of stock after 1 hour of order creation
167
            this.alert = Alert.ACCEPTANCE_DELAYED;
167
            this.alert = OrderAlert.ACCEPTANCE_DELAYED;
168
            return;
168
            return;
169
        }
169
        }
170
	    
170
	    
171
        if(this.verifiedAt <= currentTime - MS_IN_HOUR && this.status == 3 && this.cod){
171
        if(this.verifiedAt <= currentTime - MS_IN_HOUR && this.status == 3 && this.cod){
172
            //A COD order has neither been accepted nor marked out of stock after an hour of order verification
172
            //A COD order has neither been accepted nor marked out of stock after an hour of order verification
173
            this.alert = Alert.ACCEPTANCE_DELAYED;
173
            this.alert = OrderAlert.ACCEPTANCE_DELAYED;
174
            return;
174
            return;
175
        }
175
        }
176
        
176
        
177
	    if(this.status == 9 && this.shippedAt <= currentTime - 20 * MS_IN_HOUR){
177
	    if(this.status == 9 && this.shippedAt <= currentTime - 20 * MS_IN_HOUR){
178
            //A shipped order has not been picked up
178
            //A shipped order has not been picked up
179
            this.alert = Alert.ORDER_NOT_CONNECTED;
179
            this.alert = OrderAlert.ORDER_NOT_CONNECTED;
180
            return;
180
            return;
181
	    }
181
	    }
182
	}
182
	}
183
	
183
	
184
	public long getCustomerId() {
184
	public long getCustomerId() {
Line 443... Line 443...
443
 
443
 
444
    public String getDelayReason() {
444
    public String getDelayReason() {
445
        return delayReason;
445
        return delayReason;
446
    }
446
    }
447
 
447
 
448
    public void setAlert(Alert alert) {
448
    public void setAlert(OrderAlert alert) {
449
        this.alert = alert;
449
        this.alert = alert;
450
    }
450
    }
451
 
451
 
452
    public Alert getAlert() {
452
    public OrderAlert getAlert() {
453
        return alert;
453
        return alert;
454
    }
454
    }
455
    
455
    
456
	public String getDealText() {
456
	public String getDealText() {
457
		return dealText;
457
		return dealText;