Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
7343 anupam.sin 1
package in.shop2020.serving.controllers;
2
 
3
 
4
import in.shop2020.model.v1.order.HotspotStore;
5
import in.shop2020.model.v1.order.LineItem;
6
import in.shop2020.model.v1.order.Order;
7
import in.shop2020.model.v1.order.OrderStatus;
8
import in.shop2020.model.v1.order.RechargeOrderStatus;
9
import in.shop2020.model.v1.order.RechargeTransaction;
7393 anupam.sin 10
import in.shop2020.model.v1.order.StoreOrderDetail;
7343 anupam.sin 11
import in.shop2020.model.v1.order.TransactionService;
12
import in.shop2020.thrift.clients.HelperClient;
13
import in.shop2020.thrift.clients.TransactionClient;
14
import in.shop2020.utils.Mail;
15
 
16
import java.io.ByteArrayOutputStream;
17
import java.io.IOException;
18
import java.nio.ByteBuffer;
19
import java.text.DateFormat;
20
import java.text.SimpleDateFormat;
21
import java.util.ArrayList;
22
import java.util.Calendar;
23
import java.util.Date;
24
import java.util.List;
25
import java.util.Random;
26
 
27
import javax.servlet.ServletContext;
28
import javax.servlet.ServletOutputStream;
29
import javax.servlet.http.HttpServletRequest;
30
import javax.servlet.http.HttpServletResponse;
31
import javax.servlet.http.HttpSession;
32
 
33
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
34
import org.apache.poi.ss.usermodel.Row;
35
import org.apache.poi.ss.usermodel.Sheet;
36
import org.apache.poi.ss.usermodel.Workbook;
7348 anupam.sin 37
import org.apache.thrift.meta_data.SetMetaData;
7343 anupam.sin 38
import org.slf4j.Logger;
39
import org.slf4j.LoggerFactory;
40
 
7386 anupam.sin 41
public class ReportController extends BaseController {
7343 anupam.sin 42
 
43
    /**
44
     * 
45
     */
46
    private static final long serialVersionUID = 1L;
47
 
48
    private static Logger logger = LoggerFactory.getLogger(ReportController.class);
49
 
50
    protected HttpServletRequest request;
51
    protected HttpSession session;
52
    protected HttpServletResponse response;
53
    private ServletContext context;
54
    private String startDate;
55
    private String endDate;
56
    private String status;
57
    private String dateselector;
58
    private String searchError = "";
59
    private Long number = null;
60
    private String passwordGeneration = "";
61
 
62
    private static final String chars = "0123456789";
63
    private static final int LENGTH = 4;
64
    private static final Random random = new Random();
65
    private TransactionClient tsc;
66
    private in.shop2020.model.v1.order.TransactionService.Client tClient;
67
 
68
    private final DateFormat formatter = new SimpleDateFormat("EEE, dd-MMM-yyyy hh:mm a");
69
    private final DateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy");
70
    private final DateFormat df4Filename = new SimpleDateFormat("EEE_dd_MMM");
71
 
7348 anupam.sin 72
    private String returnType;
7343 anupam.sin 73
    private List<Order> orders = null;
74
    private List<Order> searchResult = null;
7348 anupam.sin 75
    private Long orderId;
7343 anupam.sin 76
 
7349 anupam.sin 77
    private Long refundAmount;
78
 
7343 anupam.sin 79
    private boolean showReprintColumn = false;
80
 
81
    public ReportController(){
7386 anupam.sin 82
        super();
7343 anupam.sin 83
        try {
84
            tsc = new TransactionClient();
85
            tClient = tsc.getClient();
86
        } catch (Exception e) {
87
            logger.error("Error connecting to one of the user, order or payment service", e);
88
        }
89
    }
90
 
91
 
92
    public String index() {
7386 anupam.sin 93
      String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
94
        if(loginStatus == null || !loginStatus.equals("TRUE")){
95
            return "authfail";
96
        }
97
 
98
        storeId = Long.parseLong((String) request.getSession().getAttribute("STORE_ID"));
7343 anupam.sin 99
        if(!hotspotStores.containsKey(storeId)){
100
            try{
101
                HotspotStore hotSpotStore = (new TransactionClient()).getClient().getHotspotStore(storeId, "");
102
                hotspotStores.put(storeId, hotSpotStore);
103
            } catch (Exception e) {
104
                logger.error("Unable to get store", e);
105
            }
106
        }
107
 
108
        long today = -1;
109
        today = new Date().getTime();
110
        try {
111
            List<OrderStatus> statuses = new ArrayList<OrderStatus>();
112
            orders = tClient.getOrdersForStore(0, storeId, today, today, statuses);
113
        } catch (Exception e) {
114
            setSearchError("Error getting all transactions for today. Please try again.");
115
            logger.error("Unable to get all Transactions for today", e);
116
        }
117
        return "index";
118
    }
119
 
7348 anupam.sin 120
    public String search() {
7386 anupam.sin 121
        String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
122
        if(loginStatus == null || !loginStatus.equals("TRUE")){
123
            return "authfail";
124
        }
7343 anupam.sin 125
        if(number != null) {
126
            try {
127
                List<OrderStatus> statuses = new ArrayList<OrderStatus>();
128
                setSearchResult(tClient.getOrdersForStore(number, 1, -1, -1, statuses));
129
                if(searchResult.size() == 0) {
130
                    setSearchError("Could not find any recharges with this number. Please try again.");
131
                }
132
            } catch(Exception e) {
133
                setSearchError("Some error occured. Please try again.");
134
                logger.error("Error during search", e);
135
            }
136
        }
137
        return index();
138
    }
139
 
140
    public String getCollection() throws Exception{
7386 anupam.sin 141
        String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
142
        if(loginStatus == null || !loginStatus.equals("TRUE")){
143
            return "authfail";
144
        }
7343 anupam.sin 145
        long today = -1;
146
        today = new Date().getTime();
7346 anupam.sin 147
        List<OrderStatus> statuses = new ArrayList<OrderStatus>();
148
        statuses.add(OrderStatus.DELIVERY_SUCCESS);
7348 anupam.sin 149
        List<Order> successfulOrders = tClient.getOrdersForStore(0, 1, today, today, statuses);
150
        statuses.clear();
151
        statuses.add(OrderStatus.CANCELLED_ON_CUSTOMER_REQUEST);
152
        statuses.add(OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY);
153
        List<Order> refundedOrders = tClient.getOrdersForStore(0, 1, today, today, statuses);
154
        ByteArrayOutputStream baos = generateCollectionReport(successfulOrders, refundedOrders);
7343 anupam.sin 155
        response.setContentType("application/vnd.ms-excel");
156
        String fileName = "collection-report";
157
        String todayDate = df4Filename.format(new Date(today));
158
        fileName = fileName + "-" + todayDate;
159
        fileName = fileName + ".xls";
160
        response.setHeader("Content-disposition", "inline; filename=" + fileName);
161
        ServletOutputStream sos;
162
        try {
163
            sos = response.getOutputStream();
164
            baos.writeTo(sos);
165
            sos.flush();
166
        } catch (IOException e) {
167
            e.printStackTrace();
168
        }
169
        return null;
170
 
171
    }
172
 
7348 anupam.sin 173
    private ByteArrayOutputStream generateCollectionReport(List<Order> successfulOrders,
174
                                                            List<Order> refundedOrders) {
7343 anupam.sin 175
        ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
176
        Workbook wb = new HSSFWorkbook();
177
        Sheet reportSheet = wb.createSheet("Recharge Report");
178
        Row reportSheetHeader = reportSheet.createRow((short)0);
179
        reportSheetHeader.createCell(0).setCellValue("Order ID");
180
        reportSheetHeader.createCell(1).setCellValue("Order Date");
7348 anupam.sin 181
        reportSheetHeader.createCell(2).setCellValue("Product");
182
        reportSheetHeader.createCell(3).setCellValue("Status");
183
        reportSheetHeader.createCell(4).setCellValue("Refund Date");
7349 anupam.sin 184
        reportSheetHeader.createCell(5).setCellValue("Order Value");
185
        reportSheetHeader.createCell(6).setCellValue("Collected Amount");
7343 anupam.sin 186
 
187
        int serialNo = 0;
188
 
7348 anupam.sin 189
        for(Order order : successfulOrders) {
7343 anupam.sin 190
            serialNo++;
191
            Row contentRow = reportSheet.createRow((short)serialNo);
7348 anupam.sin 192
            contentRow.createCell(0).setCellValue(order.getId());
193
            contentRow.createCell(1).setCellValue(formatter.format(new Date(order.getCreated_timestamp())));
194
            contentRow.createCell(2).setCellValue(getProductName(order.getLineitems().get(0)));
195
            contentRow.createCell(3).setCellValue(order.getStatusDescription());
196
            contentRow.createCell(4).setCellValue("N/A");
197
            contentRow.createCell(5).setCellValue(order.getTotal_amount());
7349 anupam.sin 198
            contentRow.createCell(5).setCellValue(order.getAdvanceAmount());
7343 anupam.sin 199
        }
200
 
7348 anupam.sin 201
        for(Order order : refundedOrders) {
7343 anupam.sin 202
            serialNo++;
203
            Row contentRow = reportSheet.createRow((short)serialNo);
7348 anupam.sin 204
            contentRow.createCell(0).setCellValue(order.getId());
205
            contentRow.createCell(1).setCellValue(formatter.format(new Date(order.getCreated_timestamp())));
206
            contentRow.createCell(2).setCellValue(getProductName(order.getLineitems().get(0)));
207
            contentRow.createCell(3).setCellValue(order.getStatusDescription());
208
            contentRow.createCell(4).setCellValue(formatter.format(new Date(order.getRefund_timestamp())));
209
            contentRow.createCell(5).setCellValue(order.getTotal_amount());
7343 anupam.sin 210
        }
211
 
212
        try {
213
            wb.write(baosXLS);
214
        } catch (IOException e) {
215
            // TODO Auto-generated catch block
216
            e.printStackTrace();
217
        }
218
        return baosXLS;
219
    }
220
 
221
 
222
    public String create() throws Exception{
223
        long sDate = -1;
224
        long eDate = -1;
225
        RechargeOrderStatus st = null;
226
        String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
227
        if(loginStatus == null || !loginStatus.equals("TRUE")){
228
            return "authfail";
229
        }
230
        if(dateselector.equals("1")) {
231
            sDate = new Date().getTime();
232
            eDate = sDate;
233
        }else if (dateselector.equals("2")) {
234
            sDate = new Date().getTime() - 86400*1000;
235
            eDate = sDate;
236
        }else {
237
            if(!(startDate.equals(""))) {
238
                sDate = dateFormatter.parse(startDate).getTime();
239
                startDate = dateFormatter.format(sDate);
240
            }
241
            if(!endDate.equals("")) {
242
                eDate = dateFormatter.parse(endDate).getTime();
243
                endDate = dateFormatter.format(sDate);
244
            }
245
        }
246
        if(!status.equals("-1")){
247
            st = RechargeOrderStatus.findByValue(Integer.parseInt(status));
248
        }
249
 
250
        ByteArrayOutputStream baos = generateReport(tClient.getRechargeTrans(Long.parseLong((String) request.getSession().getAttribute("STORE_ID")), sDate, eDate, st));
251
 
252
        response.setContentType("application/vnd.ms-excel");
253
        String st1 = "ALL";
254
        if(st!=null){
255
            st1 = st.name();
256
        }
257
        String fileName = st1 + "-recharge-report";
258
        if (!startDate.equals("")) {
259
            fileName = fileName + "-" + startDate.replaceAll("\\\\", "_") ;
260
        }
261
        if (!endDate.equals("")) {
262
            fileName = fileName + "-" + endDate.replaceAll("\\\\", "_") ;
263
        }
264
        fileName = fileName + ".xls";
265
        response.setHeader("Content-disposition", "inline; filename=" + fileName);
266
        ServletOutputStream sos;
267
        try {
268
            sos = response.getOutputStream();
269
            baos.writeTo(sos);
270
            sos.flush();
271
        } catch (IOException e) {
272
            e.printStackTrace();
273
        }
274
        return "index";
275
    }
276
 
277
 
278
    private ByteArrayOutputStream generateReport(
279
            List<RechargeTransaction> rechargeTrans) {
280
ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
281
 
282
        Workbook wb = new HSSFWorkbook();
283
 
284
        Sheet reportSheet = wb.createSheet("Recharge Report");
285
 
286
        Row reportSheetHeader = reportSheet.createRow((short)0);
287
        reportSheetHeader.createCell(0).setCellValue("Order ID");
288
        reportSheetHeader.createCell(1).setCellValue("Order Date");
289
        reportSheetHeader.createCell(2).setCellValue("Operator");
290
        reportSheetHeader.createCell(3).setCellValue("Device");
291
        reportSheetHeader.createCell(4).setCellValue("Status");
292
        reportSheetHeader.createCell(5).setCellValue("Recharge Amount");
293
        reportSheetHeader.createCell(6).setCellValue("Discount");
294
        reportSheetHeader.createCell(7).setCellValue("Net Amount");
295
        reportSheetHeader.createCell(8).setCellValue("Type");
296
        reportSheetHeader.createCell(9).setCellValue("Pay Method");
297
        reportSheetHeader.createCell(10).setCellValue("Refund Date");
298
 
299
        int serialNo = 0;
300
 
301
        for(RechargeTransaction transaction : rechargeTrans) {
302
            serialNo++;
303
            Row contentRow = reportSheet.createRow((short)serialNo);
304
            contentRow.createCell(0).setCellValue(transaction.getId());
305
            contentRow.createCell(1).setCellValue(formatter.format(new Date(transaction.getTransactionTime())));
306
//            contentRow.createCell(2).setCellValue(getOperatorName(transaction.getOperatorId()));
307
            contentRow.createCell(3).setCellValue(transaction.getDeviceNum());
308
            contentRow.createCell(4).setCellValue(transaction.getStatus().name());
309
            contentRow.createCell(5).setCellValue(transaction.getAmount());
310
            contentRow.createCell(6).setCellValue(transaction.getDiscount());
311
            contentRow.createCell(7).setCellValue(transaction.getPaymentAmount());
312
            contentRow.createCell(8).setCellValue(transaction.isIsFrc() ? "FRC" : "Normal");
313
            contentRow.createCell(9).setCellValue(transaction.getPayMethod().name());
314
            if(transaction.getStatus() == RechargeOrderStatus.RECHARGE_FAILED_REFUNDED) {
315
                contentRow.createCell(10).setCellValue(transaction.getResponseTime());
316
            } else {
317
                contentRow.createCell(10).setCellValue("N/A");
318
            }
319
        }
320
        try {
321
            wb.write(baosXLS);
322
        } catch (IOException e) {
323
            // TODO Auto-generated catch block
324
            e.printStackTrace();
325
        }
326
        return baosXLS;
327
    }
328
 
329
    public String downloadInvoice() {
330
        ByteBuffer buffer = null;
331
        try {
332
            if (number == null || number == 0) {
333
                log.error("rechargeId is 0");
334
                return "index";
335
            }
336
            TransactionClient transactionServiceClient = new TransactionClient();
337
            TransactionService.Client orderClient = transactionServiceClient.getClient();
7386 anupam.sin 338
            //TODO : dynamically get StoreId
7409 anupam.sin 339
            buffer = orderClient.getStoreOrderAdvanceInvoice(number, Long.parseLong((String) request.getSession().getAttribute("STORE_ID")));
7343 anupam.sin 340
            if(!buffer.hasArray()) {
7409 anupam.sin 341
                log.error("The invoice was not found for orderId : " + number);
7343 anupam.sin 342
            }
343
        } catch (Exception e) {
344
            System.out.println(e.getMessage());
345
        }
346
        response.setContentType("application/pdf");
7399 anupam.sin 347
        response.setHeader("Content-disposition", "attachment; filename=receipt-" + number.toString() + ".pdf");
7343 anupam.sin 348
 
349
        ServletOutputStream sos;
350
        try {
351
            sos = response.getOutputStream();
352
            sos.write(buffer.array());
353
            sos.flush();
354
        } catch (Exception e) {
355
            System.out.println("Unable to stream the invoice file");
356
        }
357
        return "index";
358
    }
359
 
360
    public String sendPassword() throws Exception {
361
        String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
362
        if(loginStatus == null || !loginStatus.equals("TRUE")){
363
            return "authfail";
364
        }
365
        Long storeId = Long.parseLong((String) request.getSession().getAttribute("STORE_ID"));
366
 
367
        char[] buf = new char[LENGTH];
368
        for (int i = 0; i < buf.length; i++) {
369
            buf[i] = chars.charAt(random.nextInt(chars.length()));
370
        }
371
        String password = new String(buf);
372
 
373
        try {
374
            TransactionClient tcl = new TransactionClient(); 
375
            HotspotStore hotSpotStore = tcl.getClient().getHotspotStore(storeId, "");
376
            boolean wasPasswordSet = tcl.getClient().updateHotspotStorePassword(storeId, password);
377
            if(!wasPasswordSet) {
378
                passwordGeneration = "FAIL";
379
                return index();
380
            }
381
            List<String> toList = new ArrayList<String>();
382
            toList.add(hotSpotStore.getEmail());
383
            HelperClient helperServiceClient = null;
384
            helperServiceClient = new HelperClient();
385
            in.shop2020.utils.HelperService.Client client = helperServiceClient.getClient();
386
 
387
 
388
            Mail mail = new Mail();
389
            mail.setSubject("New Password for Saholic Recharge");
390
            mail.setTo(toList);
391
            mail.setData("Your new password is : " + password);
392
            client.sendMail(mail);
393
        } catch(Exception e) {
394
            passwordGeneration = "FAIL";
395
            logger.error("Password generation/sending failed for storeId : " + storeId, e);
396
        }
397
        passwordGeneration = "SUCCESS";
398
        return index();
399
    }
400
 
401
    public String getDateTime(long milliseconds) {
402
        Calendar cal = Calendar.getInstance();
403
        cal.setTimeInMillis(milliseconds);
404
        return formatter.format(cal.getTime());
405
    }
7348 anupam.sin 406
 
407
    public String cancelRequest() {
408
        try{
409
        TransactionClient tcl = new TransactionClient();
7393 anupam.sin 410
        long storeId =  Long.parseLong((String) request.getSession().getAttribute("STORE_ID"));
411
        StoreOrderDetail sod = tcl.getClient().getStoreOrderDetail(orderId, storeId);
412
        tcl.getClient().saveRefundAmountsForStoreOrder(orderId, storeId, sod.getCashAmount(), sod.getCardAmount());
7399 anupam.sin 413
        tcl.getClient().markOrderCancellationRequestReceived(orderId);
414
        tcl.getClient().markOrderCancellationRequestConfirmed(orderId);
7386 anupam.sin 415
        tcl.getClient().refundOrder(orderId, "Store", "User requested for cancellation");
7348 anupam.sin 416
        } catch (Exception e) {
417
            logger.error("Could not mark order as cancellation requested for id : " + orderId.toString(), e);
418
            setSearchError("Request failed. Try again or call customer care.");
419
        }
420
        number = orderId;
421
        return search();
422
    }
423
 
424
    public String requestReturn() {
425
        try{
426
            TransactionClient tcl = new TransactionClient();
427
            if(returnType.equals("doa")) {
428
                tcl.getClient().markOrderDoaRequestReceived(orderId);
429
            } else if(returnType.equals("return")) {
430
                tcl.getClient().markOrderReturnRequestReceived(orderId);
431
            } else {
432
                setSearchError("Error in requesting return. Try Again.");
433
            }
434
        } catch (Exception e) {
435
            logger.error("Could not mark order as return requested for id : " + orderId.toString(), e);
436
            setSearchError("Request failed. Try again or call customer care.");
437
        }
438
        number = orderId;
439
        return search();
440
    }
7349 anupam.sin 441
 
442
    public String refundOrder() {
443
        number = orderId;
444
        try{
445
            TransactionClient tcl = new TransactionClient();
446
            Order order = tcl.getClient().getOrder(number);
447
            if(order.getTotal_amount() < refundAmount) {
448
                setSearchError("You cannot refund more than Rs. " + refundAmount.toString());
449
                return search();
450
            }
451
            tcl.getClient().refundOrder(orderId, "ANU", "Cancelled");
452
            setSearchError("SUCCESSFUL. Please refund Rs. " + refundAmount.toString() + " to the customer.");
453
        } catch (Exception e) {
454
            logger.error("Could not mark order as return requested for id : " + orderId.toString(), e);
455
            setSearchError("Could not refund. Try again or call customer care.");
456
        }
457
        return search();
458
    }
7343 anupam.sin 459
 
460
    public List<Order> getOrders(){
461
        return orders;
462
    }
463
 
464
    public void setServletRequest(HttpServletRequest req) {
465
        this.request = req;
466
        this.session = req.getSession();        
467
    }
468
 
469
    public void setServletContext(ServletContext context) {
470
        this.context = context;
471
    }
472
 
473
    public void setServletResponse(HttpServletResponse response) {
474
        this.response = response;
475
    }
476
 
477
    public String getServletContextPath() {
478
        return context.getContextPath();
479
    }
480
 
481
    public String getProductName(LineItem item) {
482
        return item.getBrand() 
483
                + (item.getModel_name() == null ? "" : " " + item.getModel_name())
484
                + (item.getModel_number() == null ? "" : " " + item.getModel_number())
485
                + (item.getColor() == null || item.getColor() == "" ? "" : " (" + item.getColor() + ")");
486
    }
487
 
488
    public String getStartDate() {
489
        return startDate;
490
    }
491
 
492
 
493
    public void setStartDate(String startDate) {
494
        this.startDate = startDate;
495
    }
496
 
497
    public String getEndDate() {
498
        return endDate;
499
    }
500
 
501
 
502
    public void setEndDate(String endDate) {
503
        this.endDate = endDate;
504
    }
505
 
506
    public String getStatus() {
507
        return status;
508
    }
509
 
510
 
511
    public void setStatus(String status) {
512
        this.status = status;
513
    }
514
 
515
 
516
    public String getDateselector() {
517
        return dateselector;
518
    }
519
 
520
 
521
    public void setDateselector(String dateselector) {
522
        this.dateselector = dateselector;
523
    }
524
 
525
 
526
    public void setSearchError(String searchError) {
527
        this.searchError = searchError;
528
    }
529
 
530
 
531
    public String getSearchError() {
532
        return searchError;
533
    }
534
 
535
 
536
    public void setNumber(Long number) {
537
        this.number = number;
538
    }
539
 
540
 
541
    public Long getNumber() {
542
        return number;
543
    }
544
 
545
 
546
    public void setSearchResult(List<Order> searchResult) {
547
        this.searchResult = searchResult;
548
    }
549
 
550
 
551
    public List<Order> getSearchResult() {
552
        if(searchResult == null)
553
            searchResult = new ArrayList<Order>();
554
        return searchResult;
555
    }
556
 
557
 
558
    public void setShowReprintColumn(boolean showReprintColumn) {
559
        this.showReprintColumn = showReprintColumn;
560
    }
561
 
562
 
563
    public boolean shouldShowReprintColumn() {
564
        return showReprintColumn;
565
    }
566
 
567
 
568
    public void setPasswordGeneration(String passwordGeneration) {
569
        this.passwordGeneration = passwordGeneration;
570
    }
571
 
572
 
573
    public String getPasswordGeneration() {
574
        return passwordGeneration;
575
    }
7348 anupam.sin 576
 
577
 
578
    public void setOrderId(Long orderId) {
579
        this.orderId = orderId;
580
    }
581
 
582
 
583
    public Long getOrderId() {
584
        return orderId;
585
    }
586
 
587
 
588
    public void setReturnType(String returnType) {
589
        this.returnType = returnType;
590
    }
591
 
592
 
593
    public String getReturnType() {
594
        return returnType;
595
    }
7349 anupam.sin 596
 
597
 
598
    public void setRefundAmount(Long refundAmount) {
599
        this.refundAmount = refundAmount;
600
    }
601
 
602
 
603
    public Long getRefundAmount() {
604
        return refundAmount;
605
    }
7343 anupam.sin 606
 
7386 anupam.sin 607
    public boolean isOrderPlacedOnSameDay(long orderTime) {
608
        Calendar calOrderDate = Calendar.getInstance();
609
        calOrderDate.setTimeInMillis(orderTime);
610
 
611
        Calendar cal = Calendar.getInstance();
612
        if(cal.get(Calendar.DATE) == calOrderDate.get(Calendar.DATE) 
613
                && cal.get(Calendar.MONTH) == calOrderDate.get(Calendar.MONTH)
614
                && cal.get(Calendar.YEAR) == calOrderDate.get(Calendar.YEAR)) {
615
            return true;
616
        }
617
        return false;
618
    }
7343 anupam.sin 619
 
620
}