Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
1901 vikas 1
package in.shop2020.support.controllers;
2
 
2340 vikas 3
import in.shop2020.model.v1.order.LineItem;
4
import in.shop2020.model.v1.order.Order;
2980 vikas 5
import in.shop2020.model.v1.order.OrderStatus;
1901 vikas 6
import in.shop2020.model.v1.user.Affiliate;
7
import in.shop2020.model.v1.user.MasterAffiliate;
8
import in.shop2020.model.v1.user.TrackLog;
3378 vikas 9
import in.shop2020.model.v1.user.TrackLogType;
3213 chandransh 10
import in.shop2020.model.v1.user.UserAffiliateException;
1901 vikas 11
import in.shop2020.model.v1.user.UserContextService.Client;
2340 vikas 12
import in.shop2020.payments.Payment;
3293 vikas 13
import in.shop2020.support.utils.ReportsUtils;
3125 rajveer 14
import in.shop2020.thrift.clients.PaymentClient;
15
import in.shop2020.thrift.clients.TransactionClient;
16
import in.shop2020.thrift.clients.UserClient;
1901 vikas 17
 
18
import java.io.ByteArrayOutputStream;
19
import java.io.IOException;
3293 vikas 20
import java.text.DateFormat;
21
import java.text.ParseException;
22
import java.text.SimpleDateFormat;
2501 vikas 23
import java.util.ArrayList;
3293 vikas 24
import java.util.Calendar;
1901 vikas 25
import java.util.Date;
26
import java.util.HashMap;
2393 vikas 27
import java.util.HashSet;
1901 vikas 28
import java.util.List;
29
import java.util.Map;
3315 vikas 30
import java.util.Map.Entry;
2393 vikas 31
import java.util.Set;
3315 vikas 32
import java.util.SortedSet;
33
import java.util.TimeZone;
34
import java.util.TreeSet;
1901 vikas 35
 
36
import javax.servlet.ServletOutputStream;
37
import javax.servlet.http.HttpServletRequest;
38
import javax.servlet.http.HttpServletResponse;
3293 vikas 39
import javax.servlet.http.HttpSession;
1901 vikas 40
 
41
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
42
import org.apache.poi.ss.usermodel.Cell;
43
import org.apache.poi.ss.usermodel.CellStyle;
44
import org.apache.poi.ss.usermodel.CreationHelper;
45
import org.apache.poi.ss.usermodel.Font;
46
import org.apache.poi.ss.usermodel.Row;
47
import org.apache.poi.ss.usermodel.Sheet;
48
import org.apache.poi.ss.usermodel.Workbook;
49
import org.apache.poi.ss.util.CellRangeAddress;
3293 vikas 50
import org.apache.struts2.convention.annotation.InterceptorRef;
51
import org.apache.struts2.convention.annotation.InterceptorRefs;
3936 chandransh 52
import org.apache.struts2.convention.annotation.Result;
53
import org.apache.struts2.convention.annotation.Results;
1901 vikas 54
import org.apache.struts2.interceptor.ServletRequestAware;
55
import org.apache.struts2.interceptor.ServletResponseAware;
3213 chandransh 56
import org.apache.thrift.TException;
57
import org.slf4j.Logger;
58
import org.slf4j.LoggerFactory;
1901 vikas 59
 
2904 chandransh 60
/**
61
 * Provides reports about successful registrations and orders place through an
62
 * affiliate.
63
 * 
64
 * @author Vikas Malik
65
 * 
66
 */
3293 vikas 67
@InterceptorRefs({
68
    @InterceptorRef("defaultStack"),
69
    @InterceptorRef("login")
70
})
3936 chandransh 71
@Results({
72
    @Result(name="authfail", type="redirectAction", params = {"actionName" , "reports"})
73
})
3293 vikas 74
public class AffiliateController implements ServletRequestAware, ServletResponseAware{
1901 vikas 75
 
3293 vikas 76
    private static Logger log = LoggerFactory.getLogger(AffiliateController.class);
3213 chandransh 77
 
1901 vikas 78
	private HttpServletResponse response;
79
	private HttpServletRequest request;
3293 vikas 80
	private HttpSession session;
81
 
1901 vikas 82
	private String errorMsg = "";
83
	private List<MasterAffiliate> masterAffiliates;
3315 vikas 84
	private Date startDate = null;
85
	private Date endDate = null;
1901 vikas 86
 
87
	@Override
88
	public void setServletResponse(HttpServletResponse res) {
89
		this.response = res;
90
	}
91
 
92
	@Override
93
    public void setServletRequest(HttpServletRequest req) {
94
	    this.request = req;
3293 vikas 95
        this.session = req.getSession();
1901 vikas 96
    }
97
 
98
	public String index()  {
3293 vikas 99
	    log.info(request.getServletPath());
100
        if (!ReportsUtils.canAccessReport(
101
                (Long) session.getAttribute(ReportsUtils.ROLE),
102
                request.getServletPath())) 
103
        {
3936 chandransh 104
            return "authfail";
3293 vikas 105
        }
1901 vikas 106
        try {
3125 rajveer 107
        	UserClient userContextServiceClient = new UserClient();
1901 vikas 108
            Client userClient = userContextServiceClient.getClient();
109
            masterAffiliates = userClient.getAllMasterAffiliates();
110
        } catch (Exception e) {
3293 vikas 111
            log.error("Error while getting all affiliates", e);
1901 vikas 112
        }
113
        return "report";
114
    }
115
 
116
	public String create()	{
117
	    try   {
118
	        long mAfId = Long.parseLong(request.getParameter("masterAffiliate"));
3315 vikas 119
	        String mAffName;
3293 vikas 120
	        String startDateStr = request.getParameter("startDate");
121
	        String endDateStr = request.getParameter("endDate");
122
 
123
	        DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
3315 vikas 124
	        df.setTimeZone(TimeZone.getTimeZone("IST"));
3293 vikas 125
	        try {
126
	            startDate = df.parse(startDateStr);
127
	            endDate = df.parse(endDateStr);
128
	            Calendar cal = Calendar.getInstance();
129
	            cal.setTime(endDate);
130
	            endDate.setTime(cal.getTimeInMillis());
131
	        } catch (ParseException pe) {
132
	            errorMsg = "Please enter start and end dates in format MM/dd/yyyy";
133
	            return "report";
134
	        }
135
 
3125 rajveer 136
	        UserClient userContextServiceClient = new UserClient();
137
            PaymentClient paymentServiceClient = new PaymentClient();
138
            TransactionClient transactionServiceClient = new TransactionClient();
2340 vikas 139
 
1901 vikas 140
            Client userClient = userContextServiceClient.getClient();
2340 vikas 141
            in.shop2020.payments.PaymentService.Client paymentClient = paymentServiceClient.getClient();
142
 
2501 vikas 143
            List<Affiliate> affiliates;
144
            if (mAfId == -1) {
3315 vikas 145
                mAffName = "All";
2501 vikas 146
                affiliates = new ArrayList<Affiliate>();
147
                for(MasterAffiliate mAffiliate : userClient.getAllMasterAffiliates()) {
148
                    affiliates.addAll(userClient.getAffiliatesByMasterAffiliate(mAffiliate.getId()));
149
                }
150
            }
151
            else {
152
                affiliates = userClient.getAffiliatesByMasterAffiliate(mAfId);
3315 vikas 153
                mAffName = userClient.getMasterAffiliateById(mAfId).getName();
2501 vikas 154
            }
2980 vikas 155
 
3315 vikas 156
            SortedSet<Date> dates = new TreeSet<Date>();
157
            Map<Date, Long> registerCountMap = new HashMap<Date, Long>();
158
            Map<Date, Double> saleQuantityMap = new HashMap<Date, Double>();
159
            Map<Date, Double> saleAmountMap = new HashMap<Date, Double>();
160
 
161
            Map<Date, Map<String, Double>> productQuantityMap = new HashMap<Date, Map<String, Double>>();
4598 anupam.sin 162
            Map<Date, Map<Long, String>> dateTxnProductMap = new HashMap<Date, Map<Long, String>>();
3315 vikas 163
            Map<Date, Map<String, Double>> productAmountMap = new HashMap<Date, Map<String,Double>>();
164
 
2501 vikas 165
            for (Affiliate aff : affiliates) {
3315 vikas 166
                Set<Long> Payments = new HashSet<Long>(); // To deal with multiple refreshes on pay-success page.
3293 vikas 167
                for (TrackLog tracklog : userClient.getTrackLogsByAffiliate(aff.getId(), startDate.getTime(), endDate.getTime())) {
3315 vikas 168
                    Date date = df.parse(df.format(new Date(tracklog.getAddedOn())));
169
                    dates.add(date);
3378 vikas 170
                    if (tracklog.getEventType() == TrackLogType.NEW_REGISTRATION) {
3315 vikas 171
                        if (registerCountMap.containsKey(date)) {
172
                            Long count = registerCountMap.get(date);
173
                            registerCountMap.put(date, ++count);
174
                        }
175
                        else {
176
                            registerCountMap.put(date, 1l);
177
                        }
178
                    }
3378 vikas 179
                    else if (tracklog.getEventType() == TrackLogType.PAYMENT_SUCCESS) {
3343 vikas 180
                        long paymentId = Long.parseLong(tracklog.getData().replaceAll("\\(.*\\)", ""));
3315 vikas 181
                        if (Payments.contains(paymentId)) {
182
                            continue;
183
                        }
184
                        Payments.add(paymentId);
185
                        Payment payment = paymentClient.getPayment(paymentId);
186
                        List<Order> orders = transactionServiceClient.getClient().getOrdersForTransaction(
187
                                        payment.getMerchantTxnId(),
188
                                        payment.getUserId());
189
                        for (Order order : orders) {
3341 vikas 190
                            if (order.getStatus() == OrderStatus.DELIVERY_SUCCESS) {
3315 vikas 191
                                List<LineItem> items = order.getLineitems();
192
                                if (saleAmountMap.containsKey(date)) {
193
                                    Double amount = saleAmountMap.get(date);
194
                                    amount += order.getTotal_amount();
195
                                    saleAmountMap.put(date, amount);
2980 vikas 196
                                }
3315 vikas 197
                                else {
198
                                    saleAmountMap.put(date, order.getTotal_amount());
199
                                }
2340 vikas 200
                                for (LineItem item : items) {
3315 vikas 201
                                    if (saleQuantityMap.containsKey(date)) {
202
                                        Double quantity = saleQuantityMap.get(date);
203
                                        quantity += item.getQuantity();
204
                                        saleQuantityMap.put(date, quantity);
205
                                    }
206
                                    else {
207
                                        saleQuantityMap.put(date, item.getQuantity());
208
                                    }
209
 
210
                                    String productName = item.getBrand() + " "
2340 vikas 211
                                            + item.getModel_name() + " "
3315 vikas 212
                                            + item.getModel_number();
213
                                    productName = productName.replace("null", "").replaceAll("  ", " ").trim();
4598 anupam.sin 214
 
3315 vikas 215
                                    if (productQuantityMap.containsKey(date)) {
216
                                        Map<String, Double> pQuantityMap = productQuantityMap.get(date);
217
                                        if (pQuantityMap.containsKey(productName)) {
218
                                            Double quantity = pQuantityMap.get(productName);
219
                                            quantity += item.getQuantity();
220
                                            pQuantityMap.put(productName, quantity);
221
                                        }
222
                                        else {
223
                                            pQuantityMap.put(productName, item.getQuantity());
224
                                        }
225
                                    }
226
                                    else {
227
                                        Map<String, Double> pQuantityMap = new HashMap<String, Double>();
228
                                        pQuantityMap.put(productName, item.getQuantity());
229
                                        productQuantityMap.put(date, pQuantityMap);
230
                                    }
231
 
4598 anupam.sin 232
                                    if (dateTxnProductMap.containsKey(date)) {
233
                                        Map<Long, String> txnProductMap = dateTxnProductMap.get(date);
234
                                        txnProductMap.put(order.getTransactionId(), productName);
235
                                    }
236
                                    else {
237
                                        Map<Long, String> txnProductMap = new HashMap<Long, String>();
238
                                        txnProductMap.put(order.getTransactionId(), productName);
239
                                        dateTxnProductMap.put(date, txnProductMap);
240
                                    }
241
 
3315 vikas 242
                                    if (productAmountMap.containsKey(date)) {
243
                                        Map<String, Double> pAmountMap = productAmountMap.get(date);
244
                                        if (pAmountMap.containsKey(productName)) {
245
                                            Double amount = pAmountMap.get(productName);
246
                                            amount += item.getTotal_price();
247
                                            pAmountMap.put(productName, amount);
248
                                        }
249
                                        else {
250
                                            pAmountMap.put(productName, item.getTotal_price());
251
                                        }
252
                                    }
253
                                    else {
254
                                        Map<String, Double> pAmountMap = new HashMap<String, Double>();
255
                                        pAmountMap.put(productName, item.getTotal_price());
256
                                        productAmountMap.put(date, pAmountMap);
257
                                    }
2340 vikas 258
                                }
259
                            }
260
                        }
261
                    }
1901 vikas 262
                }
263
            }
3315 vikas 264
 
1901 vikas 265
            // Preparing XLS file for output
266
            response.setContentType("application/vnd.ms-excel");
267
 
3315 vikas 268
            response.setHeader("Content-disposition", "inline; filename=" + mAffName + "-affiliate-report" + ".xls");
1901 vikas 269
 
270
            ServletOutputStream sos;
271
            try {
4598 anupam.sin 272
                ByteArrayOutputStream baos = getSpreadSheetData(mAffName,
273
                                                                   dates,
274
                                                                   registerCountMap, 
275
                                                                   saleQuantityMap, 
276
                                                                   saleAmountMap, 
277
                                                                   productQuantityMap, 
278
                                                                   dateTxnProductMap, 
279
                                                                   productAmountMap);
1901 vikas 280
                sos = response.getOutputStream();
281
                baos.writeTo(sos);
282
                sos.flush();
283
            } catch (IOException e) {
3293 vikas 284
                log.error("Unable to stream the affiliates report", e);
1901 vikas 285
                errorMsg = "Failed to write to response.";
286
            }
3213 chandransh 287
        } catch (UserAffiliateException e) {
3293 vikas 288
            log.error("Error while getting affiliated users", e);
1901 vikas 289
            errorMsg = e.getMessage();
3213 chandransh 290
        } catch (TException e) {
3293 vikas 291
            log.error("Unable to get affiliated users", e);
3213 chandransh 292
            errorMsg = e.getMessage();
293
        } catch (Exception e) {
3293 vikas 294
            log.error("Unexpected exception", e);
3213 chandransh 295
            errorMsg = e.getMessage();
1901 vikas 296
        }
297
        return null;
298
	}
299
 
3315 vikas 300
    // Prepares the XLS worksheet object and fills in the data with proper formatting
301
	private ByteArrayOutputStream getSpreadSheetData(String mAffName, 
302
	        SortedSet<Date> dates,
303
            Map<Date, Long> registerCountMap,
304
            Map<Date, Double> saleQuantityMap,
4598 anupam.sin 305
            Map<Date, Double> saleAmountMap,
3315 vikas 306
            Map<Date, Map<String, Double>> productQuantityMap,
4598 anupam.sin 307
            Map<Date, Map<Long, String>> dateTxnProductMap,
3315 vikas 308
            Map<Date, Map<String, Double>> productAmountMap)
1901 vikas 309
	{
310
	    ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
311
 
312
		Workbook wb = new HSSFWorkbook();
313
 
314
	    Font font = wb.createFont();
315
	    font.setBoldweight(Font.BOLDWEIGHT_BOLD);
316
	    CellStyle style = wb.createCellStyle();
317
	    style.setFont(font);
318
 
319
	    CreationHelper createHelper = wb.getCreationHelper();
320
	    CellStyle dateCellStyle = wb.createCellStyle();
3315 vikas 321
	    dateCellStyle.setDataFormat(createHelper.createDataFormat().getFormat("DD/MM/YYYY"));
1901 vikas 322
 
3315 vikas 323
	    createSummarySheet(mAffName, dates, registerCountMap, saleQuantityMap, saleAmountMap, wb, style, dateCellStyle);
4598 anupam.sin 324
	    createSaleDetailSheet(mAffName, dates, dateTxnProductMap, productQuantityMap, productAmountMap, wb, style, dateCellStyle);
1901 vikas 325
 
326
		// Write the workbook to the output stream
327
		try {
328
			wb.write(baosXLS);
329
			baosXLS.close();
330
		} catch (IOException e) {
3293 vikas 331
			log.error("Unable to get the byte array for the affiliate report", e);
1901 vikas 332
		}		
333
		return baosXLS;
334
	}
335
 
3315 vikas 336
    private void createSaleDetailSheet(String mAffName, SortedSet<Date> dates,
4598 anupam.sin 337
            Map<Date, Map<Long, String>> dateTxnProductMap,
3315 vikas 338
            Map<Date, Map<String, Double>> productQuantityMap,
339
            Map<Date, Map<String, Double>> productAmountMap, Workbook wb,
340
            CellStyle style, CellStyle dateCellStyle) {
341
        // Product Sales SHEET
342
        Sheet affSheet = wb.createSheet("Product Sales Report");
343
        short affSerialNo = 0;
344
 
345
        DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
346
 
347
        Row affTitleRow = affSheet.createRow(affSerialNo ++);
348
        Cell affTitleCell = affTitleRow.createCell(0);
349
        affTitleCell.setCellValue("Modelwise Sales Report");
350
        affTitleCell.setCellStyle(style);
351
        affSheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
352
 
353
        affSheet.createRow(affSerialNo ++);
354
        Row affNameRow = affSheet.createRow(affSerialNo ++);
355
        Cell affNameCell = affNameRow.createCell(0);
356
        affNameCell.setCellValue("Affiliate : " + mAffName);
357
        affNameCell.setCellStyle(style);
358
        affSheet.addMergedRegion(new CellRangeAddress(2, 2, 0, 6));
359
 
360
        Row affDateRangeRow = affSheet.createRow(affSerialNo ++);
361
        Cell affDateRangeCell = affDateRangeRow.createCell(0);
362
        affDateRangeCell.setCellValue("Date Range : " + df.format(startDate) + " - " + df.format(endDate));
363
        affDateRangeCell.setCellStyle(style);
364
        affSheet.addMergedRegion(new CellRangeAddress(3, 3, 0, 6));
365
 
366
        affSheet.createRow(affSerialNo ++);affSheet.createRow(affSerialNo ++);
367
 
368
        Row affHeaderRow = affSheet.createRow(affSerialNo++);
369
        affHeaderRow.createCell(0).setCellValue("Date");
370
        affHeaderRow.createCell(1).setCellValue("ProductName");
4598 anupam.sin 371
        affHeaderRow.createCell(2).setCellValue("Transaction Id");
3315 vikas 372
        affHeaderRow.createCell(3).setCellValue("Amount");
373
        for (int i=0; i<4 ;i++) {
374
            affHeaderRow.getCell(i).setCellStyle(style);
375
        }
376
 
3343 vikas 377
        Double totalQuantity = 0d;
378
        Double totalAmount = 0d;
3315 vikas 379
        for(Date date : dates) {
4598 anupam.sin 380
            if (!dateTxnProductMap.containsKey(date)) {
3315 vikas 381
                continue;
382
            }
4598 anupam.sin 383
            //HashSet<String> tmpProductSet = new HashSet<String>();
384
            String prodName = null;
385
            Row commContentRow = null;
386
            for (Entry<Long, String> txnEntry : dateTxnProductMap.get(date).entrySet()) {
3315 vikas 387
                affSerialNo++;
4598 anupam.sin 388
                prodName = txnEntry.getValue();
389
                Long txn = txnEntry.getKey();
390
                commContentRow = affSheet.createRow(affSerialNo);
3315 vikas 391
                commContentRow.createCell(0).setCellValue(date);
392
                commContentRow.getCell(0).setCellStyle(dateCellStyle);
393
                commContentRow.createCell(1).setCellValue(prodName);
4598 anupam.sin 394
                commContentRow.createCell(2).setCellValue(txn);
395
                Double amount = productAmountMap.get(date).get(prodName);
396
                amount = amount/(productQuantityMap.get(date).get(prodName));
397
                totalAmount += amount;
3315 vikas 398
                commContentRow.createCell(3).setCellValue(amount);
4598 anupam.sin 399
                totalQuantity++;
3315 vikas 400
            }
401
        }
3343 vikas 402
        affSerialNo+=2;
403
        Row commContentRow = affSheet.createRow(affSerialNo);
404
        commContentRow.createCell(0).setCellValue("Total");
405
        commContentRow.createCell(1).setCellValue("");
406
        commContentRow.createCell(2).setCellValue(totalQuantity);
407
        commContentRow.createCell(3).setCellValue(totalAmount);
408
 
409
        for (int i = 0; i<4; i++) {
410
            affSheet.autoSizeColumn(i);
411
        }
3315 vikas 412
    }
413
 
414
    private void createSummarySheet(String mAffName, 
415
            SortedSet<Date> dates,
416
            Map<Date, Long> registerCountMap,
417
            Map<Date, Double> saleQuantityMap,
418
            Map<Date, Double> saleAmountMap, 
419
            Workbook wb, 
420
            CellStyle style,
421
            CellStyle dateCellStyle) 
422
    {
423
		// Summary SHEET
424
	    Sheet affSheet = wb.createSheet("Summary Report");
1901 vikas 425
	    short affSerialNo = 0;
3315 vikas 426
 
427
	    DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
1901 vikas 428
 
429
	    Row affTitleRow = affSheet.createRow(affSerialNo ++);
430
	    Cell affTitleCell = affTitleRow.createCell(0);
3315 vikas 431
	    affTitleCell.setCellValue("Daily Stats Report");
1901 vikas 432
	    affTitleCell.setCellStyle(style);
433
	    affSheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
434
 
435
	    affSheet.createRow(affSerialNo ++);
3315 vikas 436
	    Row affNameRow = affSheet.createRow(affSerialNo ++);
437
        Cell affNameCell = affNameRow.createCell(0);
438
        affNameCell.setCellValue("Affiliate : " + mAffName);
439
        affNameCell.setCellStyle(style);
440
        affSheet.addMergedRegion(new CellRangeAddress(2, 2, 0, 6));
441
 
442
        Row affDateRangeRow = affSheet.createRow(affSerialNo ++);
443
        Cell affDateRangeCell = affDateRangeRow.createCell(0);
444
        affDateRangeCell.setCellValue("Date Range : " + df.format(startDate) + " - " + df.format(endDate));
445
        affDateRangeCell.setCellStyle(style);
446
        affSheet.addMergedRegion(new CellRangeAddress(3, 3, 0, 6));
447
 
448
	    affSheet.createRow(affSerialNo ++);affSheet.createRow(affSerialNo ++);
1901 vikas 449
 
450
	    Row affHeaderRow = affSheet.createRow(affSerialNo++);
3315 vikas 451
	    affHeaderRow.createCell(0).setCellValue("Date");
452
	    affHeaderRow.createCell(1).setCellValue("New Registrations");
453
	    affHeaderRow.createCell(2).setCellValue("Sales Count");
454
	    affHeaderRow.createCell(3).setCellValue("Amount");
455
	    for (int i=0; i<4 ;i++) {
1901 vikas 456
	        affHeaderRow.getCell(i).setCellStyle(style);
457
	    }
458
 
3343 vikas 459
	    Double totalregisterCount = 0d;
460
        Double totalQuantity = 0d;
461
	    Double totalAmount = 0d;
462
        for(Date date : dates) {
3315 vikas 463
		    affSerialNo++;
1901 vikas 464
			Row commContentRow = affSheet.createRow(affSerialNo);
3315 vikas 465
			Long registerCount = registerCountMap.get(date);
466
			Double saleQuantity = saleQuantityMap.get(date);
467
			Double saleAmount = saleAmountMap.get(date);
468
			if (registerCount == null) {
469
			    registerCount = 0l;
2340 vikas 470
			}
3315 vikas 471
			if (saleQuantity == null) {
472
                saleQuantity = 0d;
473
            }
474
			if (saleAmount == null) {
475
                saleAmount = 0d;
476
            }
3343 vikas 477
			totalregisterCount += registerCount;
478
            totalQuantity += saleQuantity;
479
			totalAmount += saleAmount;
480
            commContentRow.createCell(0).setCellValue(date);
3315 vikas 481
			commContentRow.getCell(0).setCellStyle(dateCellStyle);
482
            commContentRow.createCell(1).setCellValue(registerCount);
483
			commContentRow.createCell(2).setCellValue(saleQuantity);
484
			commContentRow.createCell(3).setCellValue(saleAmount);
1901 vikas 485
		}
3343 vikas 486
        affSerialNo+=2;
487
        Row commContentRow = affSheet.createRow(affSerialNo);
488
        commContentRow.createCell(0).setCellValue("Total");
489
        commContentRow.createCell(1).setCellValue(totalregisterCount);
490
        commContentRow.createCell(2).setCellValue(totalQuantity);
491
        commContentRow.createCell(3).setCellValue(totalAmount);
492
 
3315 vikas 493
        for (int i = 0; i<4; i++) {
1901 vikas 494
            affSheet.autoSizeColumn(i);
495
        }
496
	}
497
 
498
	public String getErrorMsg() {
499
		return errorMsg;
500
	}
501
 
502
	public List<MasterAffiliate> getMasterAffiliates() {
503
        return masterAffiliates;
504
    }
2340 vikas 505
}