Subversion Repositories SmartDukaan

Rev

Rev 7409 | Rev 7427 | 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>();
7423 anupam.sin 128
                setSearchResult(tClient.getOrdersForStore(number, Long.parseLong((String) request.getSession().getAttribute("STORE_ID")), -1, -1, statuses));
7343 anupam.sin 129
                if(searchResult.size() == 0) {
7423 anupam.sin 130
                    setSearchError("Could not find any orders with this number. Please try again.");
7343 anupam.sin 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);
7423 anupam.sin 149
        statuses.add(OrderStatus.SUBMITTED_FOR_PROCESSING);
150
        statuses.add(OrderStatus.ACCEPTED);
151
        statuses.add(OrderStatus.BILLED);
152
 
153
        List<Order> successfulOrders = tClient.getOrdersForStore(0, Long.parseLong((String) request.getSession().getAttribute("STORE_ID")), today, today, statuses);
7348 anupam.sin 154
        statuses.clear();
155
        statuses.add(OrderStatus.CANCELLED_ON_CUSTOMER_REQUEST);
156
        statuses.add(OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY);
7423 anupam.sin 157
        List<Order> refundedOrders = tClient.getOrdersForStore(0, Long.parseLong((String) request.getSession().getAttribute("STORE_ID")), today, today, statuses);
7348 anupam.sin 158
        ByteArrayOutputStream baos = generateCollectionReport(successfulOrders, refundedOrders);
7343 anupam.sin 159
        response.setContentType("application/vnd.ms-excel");
160
        String fileName = "collection-report";
161
        String todayDate = df4Filename.format(new Date(today));
162
        fileName = fileName + "-" + todayDate;
163
        fileName = fileName + ".xls";
164
        response.setHeader("Content-disposition", "inline; filename=" + fileName);
165
        ServletOutputStream sos;
166
        try {
167
            sos = response.getOutputStream();
168
            baos.writeTo(sos);
169
            sos.flush();
170
        } catch (IOException e) {
171
            e.printStackTrace();
172
        }
173
        return null;
174
 
175
    }
176
 
7348 anupam.sin 177
    private ByteArrayOutputStream generateCollectionReport(List<Order> successfulOrders,
178
                                                            List<Order> refundedOrders) {
7343 anupam.sin 179
        ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
180
        Workbook wb = new HSSFWorkbook();
181
        Sheet reportSheet = wb.createSheet("Recharge Report");
182
        Row reportSheetHeader = reportSheet.createRow((short)0);
183
        reportSheetHeader.createCell(0).setCellValue("Order ID");
184
        reportSheetHeader.createCell(1).setCellValue("Order Date");
7348 anupam.sin 185
        reportSheetHeader.createCell(2).setCellValue("Product");
186
        reportSheetHeader.createCell(3).setCellValue("Status");
187
        reportSheetHeader.createCell(4).setCellValue("Refund Date");
7349 anupam.sin 188
        reportSheetHeader.createCell(5).setCellValue("Order Value");
189
        reportSheetHeader.createCell(6).setCellValue("Collected Amount");
7343 anupam.sin 190
 
191
        int serialNo = 0;
192
 
7348 anupam.sin 193
        for(Order order : successfulOrders) {
7343 anupam.sin 194
            serialNo++;
195
            Row contentRow = reportSheet.createRow((short)serialNo);
7348 anupam.sin 196
            contentRow.createCell(0).setCellValue(order.getId());
197
            contentRow.createCell(1).setCellValue(formatter.format(new Date(order.getCreated_timestamp())));
198
            contentRow.createCell(2).setCellValue(getProductName(order.getLineitems().get(0)));
199
            contentRow.createCell(3).setCellValue(order.getStatusDescription());
200
            contentRow.createCell(4).setCellValue("N/A");
201
            contentRow.createCell(5).setCellValue(order.getTotal_amount());
7423 anupam.sin 202
            contentRow.createCell(6).setCellValue(order.getAdvanceAmount());
7343 anupam.sin 203
        }
204
 
7348 anupam.sin 205
        for(Order order : refundedOrders) {
7343 anupam.sin 206
            serialNo++;
207
            Row contentRow = reportSheet.createRow((short)serialNo);
7348 anupam.sin 208
            contentRow.createCell(0).setCellValue(order.getId());
209
            contentRow.createCell(1).setCellValue(formatter.format(new Date(order.getCreated_timestamp())));
210
            contentRow.createCell(2).setCellValue(getProductName(order.getLineitems().get(0)));
211
            contentRow.createCell(3).setCellValue(order.getStatusDescription());
212
            contentRow.createCell(4).setCellValue(formatter.format(new Date(order.getRefund_timestamp())));
213
            contentRow.createCell(5).setCellValue(order.getTotal_amount());
7423 anupam.sin 214
            contentRow.createCell(6).setCellValue(-order.getAdvanceAmount());
7343 anupam.sin 215
        }
216
 
217
        try {
218
            wb.write(baosXLS);
219
        } catch (IOException e) {
220
            // TODO Auto-generated catch block
221
            e.printStackTrace();
222
        }
223
        return baosXLS;
224
    }
225
 
226
 
227
    public String create() throws Exception{
228
        long sDate = -1;
229
        long eDate = -1;
230
        RechargeOrderStatus st = null;
231
        String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
232
        if(loginStatus == null || !loginStatus.equals("TRUE")){
233
            return "authfail";
234
        }
235
        if(dateselector.equals("1")) {
236
            sDate = new Date().getTime();
237
            eDate = sDate;
238
        }else if (dateselector.equals("2")) {
239
            sDate = new Date().getTime() - 86400*1000;
240
            eDate = sDate;
241
        }else {
242
            if(!(startDate.equals(""))) {
243
                sDate = dateFormatter.parse(startDate).getTime();
244
                startDate = dateFormatter.format(sDate);
245
            }
246
            if(!endDate.equals("")) {
247
                eDate = dateFormatter.parse(endDate).getTime();
248
                endDate = dateFormatter.format(sDate);
249
            }
250
        }
251
        if(!status.equals("-1")){
252
            st = RechargeOrderStatus.findByValue(Integer.parseInt(status));
253
        }
254
 
255
        ByteArrayOutputStream baos = generateReport(tClient.getRechargeTrans(Long.parseLong((String) request.getSession().getAttribute("STORE_ID")), sDate, eDate, st));
256
 
257
        response.setContentType("application/vnd.ms-excel");
258
        String st1 = "ALL";
259
        if(st!=null){
260
            st1 = st.name();
261
        }
262
        String fileName = st1 + "-recharge-report";
263
        if (!startDate.equals("")) {
264
            fileName = fileName + "-" + startDate.replaceAll("\\\\", "_") ;
265
        }
266
        if (!endDate.equals("")) {
267
            fileName = fileName + "-" + endDate.replaceAll("\\\\", "_") ;
268
        }
269
        fileName = fileName + ".xls";
270
        response.setHeader("Content-disposition", "inline; filename=" + fileName);
271
        ServletOutputStream sos;
272
        try {
273
            sos = response.getOutputStream();
274
            baos.writeTo(sos);
275
            sos.flush();
276
        } catch (IOException e) {
277
            e.printStackTrace();
278
        }
279
        return "index";
280
    }
281
 
282
 
283
    private ByteArrayOutputStream generateReport(
284
            List<RechargeTransaction> rechargeTrans) {
285
ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
286
 
287
        Workbook wb = new HSSFWorkbook();
288
 
289
        Sheet reportSheet = wb.createSheet("Recharge Report");
290
 
291
        Row reportSheetHeader = reportSheet.createRow((short)0);
292
        reportSheetHeader.createCell(0).setCellValue("Order ID");
293
        reportSheetHeader.createCell(1).setCellValue("Order Date");
294
        reportSheetHeader.createCell(2).setCellValue("Operator");
295
        reportSheetHeader.createCell(3).setCellValue("Device");
296
        reportSheetHeader.createCell(4).setCellValue("Status");
297
        reportSheetHeader.createCell(5).setCellValue("Recharge Amount");
298
        reportSheetHeader.createCell(6).setCellValue("Discount");
299
        reportSheetHeader.createCell(7).setCellValue("Net Amount");
300
        reportSheetHeader.createCell(8).setCellValue("Type");
301
        reportSheetHeader.createCell(9).setCellValue("Pay Method");
302
        reportSheetHeader.createCell(10).setCellValue("Refund Date");
303
 
304
        int serialNo = 0;
305
 
306
        for(RechargeTransaction transaction : rechargeTrans) {
307
            serialNo++;
308
            Row contentRow = reportSheet.createRow((short)serialNo);
309
            contentRow.createCell(0).setCellValue(transaction.getId());
310
            contentRow.createCell(1).setCellValue(formatter.format(new Date(transaction.getTransactionTime())));
311
//            contentRow.createCell(2).setCellValue(getOperatorName(transaction.getOperatorId()));
312
            contentRow.createCell(3).setCellValue(transaction.getDeviceNum());
313
            contentRow.createCell(4).setCellValue(transaction.getStatus().name());
314
            contentRow.createCell(5).setCellValue(transaction.getAmount());
315
            contentRow.createCell(6).setCellValue(transaction.getDiscount());
316
            contentRow.createCell(7).setCellValue(transaction.getPaymentAmount());
317
            contentRow.createCell(8).setCellValue(transaction.isIsFrc() ? "FRC" : "Normal");
318
            contentRow.createCell(9).setCellValue(transaction.getPayMethod().name());
319
            if(transaction.getStatus() == RechargeOrderStatus.RECHARGE_FAILED_REFUNDED) {
320
                contentRow.createCell(10).setCellValue(transaction.getResponseTime());
321
            } else {
322
                contentRow.createCell(10).setCellValue("N/A");
323
            }
324
        }
325
        try {
326
            wb.write(baosXLS);
327
        } catch (IOException e) {
328
            // TODO Auto-generated catch block
329
            e.printStackTrace();
330
        }
331
        return baosXLS;
332
    }
333
 
334
    public String downloadInvoice() {
335
        ByteBuffer buffer = null;
336
        try {
337
            if (number == null || number == 0) {
338
                log.error("rechargeId is 0");
339
                return "index";
340
            }
341
            TransactionClient transactionServiceClient = new TransactionClient();
342
            TransactionService.Client orderClient = transactionServiceClient.getClient();
7386 anupam.sin 343
            //TODO : dynamically get StoreId
7409 anupam.sin 344
            buffer = orderClient.getStoreOrderAdvanceInvoice(number, Long.parseLong((String) request.getSession().getAttribute("STORE_ID")));
7343 anupam.sin 345
            if(!buffer.hasArray()) {
7409 anupam.sin 346
                log.error("The invoice was not found for orderId : " + number);
7343 anupam.sin 347
            }
348
        } catch (Exception e) {
349
            System.out.println(e.getMessage());
350
        }
351
        response.setContentType("application/pdf");
7399 anupam.sin 352
        response.setHeader("Content-disposition", "attachment; filename=receipt-" + number.toString() + ".pdf");
7343 anupam.sin 353
 
354
        ServletOutputStream sos;
355
        try {
356
            sos = response.getOutputStream();
357
            sos.write(buffer.array());
358
            sos.flush();
359
        } catch (Exception e) {
360
            System.out.println("Unable to stream the invoice file");
361
        }
362
        return "index";
363
    }
364
 
365
    public String sendPassword() throws Exception {
366
        String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
367
        if(loginStatus == null || !loginStatus.equals("TRUE")){
368
            return "authfail";
369
        }
370
        Long storeId = Long.parseLong((String) request.getSession().getAttribute("STORE_ID"));
371
 
372
        char[] buf = new char[LENGTH];
373
        for (int i = 0; i < buf.length; i++) {
374
            buf[i] = chars.charAt(random.nextInt(chars.length()));
375
        }
376
        String password = new String(buf);
377
 
378
        try {
379
            TransactionClient tcl = new TransactionClient(); 
380
            HotspotStore hotSpotStore = tcl.getClient().getHotspotStore(storeId, "");
381
            boolean wasPasswordSet = tcl.getClient().updateHotspotStorePassword(storeId, password);
382
            if(!wasPasswordSet) {
383
                passwordGeneration = "FAIL";
384
                return index();
385
            }
386
            List<String> toList = new ArrayList<String>();
387
            toList.add(hotSpotStore.getEmail());
388
            HelperClient helperServiceClient = null;
389
            helperServiceClient = new HelperClient();
390
            in.shop2020.utils.HelperService.Client client = helperServiceClient.getClient();
391
 
392
 
393
            Mail mail = new Mail();
394
            mail.setSubject("New Password for Saholic Recharge");
395
            mail.setTo(toList);
396
            mail.setData("Your new password is : " + password);
397
            client.sendMail(mail);
398
        } catch(Exception e) {
399
            passwordGeneration = "FAIL";
400
            logger.error("Password generation/sending failed for storeId : " + storeId, e);
401
        }
402
        passwordGeneration = "SUCCESS";
403
        return index();
404
    }
405
 
406
    public String getDateTime(long milliseconds) {
407
        Calendar cal = Calendar.getInstance();
408
        cal.setTimeInMillis(milliseconds);
409
        return formatter.format(cal.getTime());
410
    }
7348 anupam.sin 411
 
412
    public String cancelRequest() {
413
        try{
414
        TransactionClient tcl = new TransactionClient();
7393 anupam.sin 415
        long storeId =  Long.parseLong((String) request.getSession().getAttribute("STORE_ID"));
416
        StoreOrderDetail sod = tcl.getClient().getStoreOrderDetail(orderId, storeId);
417
        tcl.getClient().saveRefundAmountsForStoreOrder(orderId, storeId, sod.getCashAmount(), sod.getCardAmount());
7399 anupam.sin 418
        tcl.getClient().markOrderCancellationRequestReceived(orderId);
419
        tcl.getClient().markOrderCancellationRequestConfirmed(orderId);
7386 anupam.sin 420
        tcl.getClient().refundOrder(orderId, "Store", "User requested for cancellation");
7348 anupam.sin 421
        } catch (Exception e) {
422
            logger.error("Could not mark order as cancellation requested for id : " + orderId.toString(), e);
423
            setSearchError("Request failed. Try again or call customer care.");
424
        }
425
        number = orderId;
426
        return search();
427
    }
428
 
429
    public String requestReturn() {
430
        try{
431
            TransactionClient tcl = new TransactionClient();
432
            if(returnType.equals("doa")) {
433
                tcl.getClient().markOrderDoaRequestReceived(orderId);
434
            } else if(returnType.equals("return")) {
435
                tcl.getClient().markOrderReturnRequestReceived(orderId);
436
            } else {
437
                setSearchError("Error in requesting return. Try Again.");
438
            }
439
        } catch (Exception e) {
440
            logger.error("Could not mark order as return requested for id : " + orderId.toString(), e);
441
            setSearchError("Request failed. Try again or call customer care.");
442
        }
443
        number = orderId;
444
        return search();
445
    }
7349 anupam.sin 446
 
447
    public String refundOrder() {
448
        number = orderId;
449
        try{
450
            TransactionClient tcl = new TransactionClient();
451
            Order order = tcl.getClient().getOrder(number);
452
            if(order.getTotal_amount() < refundAmount) {
453
                setSearchError("You cannot refund more than Rs. " + refundAmount.toString());
454
                return search();
455
            }
456
            tcl.getClient().refundOrder(orderId, "ANU", "Cancelled");
457
            setSearchError("SUCCESSFUL. Please refund Rs. " + refundAmount.toString() + " to the customer.");
458
        } catch (Exception e) {
459
            logger.error("Could not mark order as return requested for id : " + orderId.toString(), e);
460
            setSearchError("Could not refund. Try again or call customer care.");
461
        }
462
        return search();
463
    }
7343 anupam.sin 464
 
465
    public List<Order> getOrders(){
466
        return orders;
467
    }
468
 
469
    public void setServletRequest(HttpServletRequest req) {
470
        this.request = req;
471
        this.session = req.getSession();        
472
    }
473
 
474
    public void setServletContext(ServletContext context) {
475
        this.context = context;
476
    }
477
 
478
    public void setServletResponse(HttpServletResponse response) {
479
        this.response = response;
480
    }
481
 
482
    public String getServletContextPath() {
483
        return context.getContextPath();
484
    }
485
 
486
    public String getProductName(LineItem item) {
487
        return item.getBrand() 
488
                + (item.getModel_name() == null ? "" : " " + item.getModel_name())
489
                + (item.getModel_number() == null ? "" : " " + item.getModel_number())
490
                + (item.getColor() == null || item.getColor() == "" ? "" : " (" + item.getColor() + ")");
491
    }
492
 
493
    public String getStartDate() {
494
        return startDate;
495
    }
496
 
497
 
498
    public void setStartDate(String startDate) {
499
        this.startDate = startDate;
500
    }
501
 
502
    public String getEndDate() {
503
        return endDate;
504
    }
505
 
506
 
507
    public void setEndDate(String endDate) {
508
        this.endDate = endDate;
509
    }
510
 
511
    public String getStatus() {
512
        return status;
513
    }
514
 
515
 
516
    public void setStatus(String status) {
517
        this.status = status;
518
    }
519
 
520
 
521
    public String getDateselector() {
522
        return dateselector;
523
    }
524
 
525
 
526
    public void setDateselector(String dateselector) {
527
        this.dateselector = dateselector;
528
    }
529
 
530
 
531
    public void setSearchError(String searchError) {
532
        this.searchError = searchError;
533
    }
534
 
535
 
536
    public String getSearchError() {
537
        return searchError;
538
    }
539
 
540
 
541
    public void setNumber(Long number) {
542
        this.number = number;
543
    }
544
 
545
 
546
    public Long getNumber() {
547
        return number;
548
    }
549
 
550
 
551
    public void setSearchResult(List<Order> searchResult) {
552
        this.searchResult = searchResult;
553
    }
554
 
555
 
556
    public List<Order> getSearchResult() {
557
        if(searchResult == null)
558
            searchResult = new ArrayList<Order>();
559
        return searchResult;
560
    }
561
 
562
 
563
    public void setShowReprintColumn(boolean showReprintColumn) {
564
        this.showReprintColumn = showReprintColumn;
565
    }
566
 
567
 
568
    public boolean shouldShowReprintColumn() {
569
        return showReprintColumn;
570
    }
571
 
572
 
573
    public void setPasswordGeneration(String passwordGeneration) {
574
        this.passwordGeneration = passwordGeneration;
575
    }
576
 
577
 
578
    public String getPasswordGeneration() {
579
        return passwordGeneration;
580
    }
7348 anupam.sin 581
 
582
 
583
    public void setOrderId(Long orderId) {
584
        this.orderId = orderId;
585
    }
586
 
587
 
588
    public Long getOrderId() {
589
        return orderId;
590
    }
591
 
592
 
593
    public void setReturnType(String returnType) {
594
        this.returnType = returnType;
595
    }
596
 
597
 
598
    public String getReturnType() {
599
        return returnType;
600
    }
7349 anupam.sin 601
 
602
 
603
    public void setRefundAmount(Long refundAmount) {
604
        this.refundAmount = refundAmount;
605
    }
606
 
607
 
608
    public Long getRefundAmount() {
609
        return refundAmount;
610
    }
7343 anupam.sin 611
 
7386 anupam.sin 612
    public boolean isOrderPlacedOnSameDay(long orderTime) {
613
        Calendar calOrderDate = Calendar.getInstance();
614
        calOrderDate.setTimeInMillis(orderTime);
615
 
616
        Calendar cal = Calendar.getInstance();
617
        if(cal.get(Calendar.DATE) == calOrderDate.get(Calendar.DATE) 
618
                && cal.get(Calendar.MONTH) == calOrderDate.get(Calendar.MONTH)
619
                && cal.get(Calendar.YEAR) == calOrderDate.get(Calendar.YEAR)) {
620
            return true;
621
        }
622
        return false;
623
    }
7343 anupam.sin 624
 
625
}