Subversion Repositories SmartDukaan

Rev

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

Rev 34082 Rev 34111
Line 4... Line 4...
4
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
4
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
5
import com.spice.profitmandi.common.model.CustomAddress;
5
import com.spice.profitmandi.common.model.CustomAddress;
6
import com.spice.profitmandi.common.model.CustomPaymentOption;
6
import com.spice.profitmandi.common.model.CustomPaymentOption;
7
import com.spice.profitmandi.common.model.InsuranceModel;
7
import com.spice.profitmandi.common.model.InsuranceModel;
8
import com.spice.profitmandi.common.model.ProfitMandiConstants;
8
import com.spice.profitmandi.common.model.ProfitMandiConstants;
-
 
9
import com.spice.profitmandi.common.util.FileUtil;
9
import com.spice.profitmandi.common.web.util.ResponseSender;
10
import com.spice.profitmandi.common.web.util.ResponseSender;
10
import com.spice.profitmandi.dao.entity.auth.AuthUser;
11
import com.spice.profitmandi.dao.entity.auth.AuthUser;
11
import com.spice.profitmandi.dao.entity.catalog.Item;
12
import com.spice.profitmandi.dao.entity.catalog.Item;
12
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
13
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
13
import com.spice.profitmandi.dao.entity.dtr.PaymentOptionTransaction;
14
import com.spice.profitmandi.dao.entity.dtr.PaymentOptionTransaction;
14
import com.spice.profitmandi.dao.entity.fofo.*;
15
import com.spice.profitmandi.dao.entity.fofo.*;
15
import com.spice.profitmandi.dao.entity.inventory.State;
16
import com.spice.profitmandi.dao.entity.inventory.State;
16
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
17
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
17
import com.spice.profitmandi.dao.enumuration.transaction.UpSaleCallStatus;
18
import com.spice.profitmandi.dao.enumuration.transaction.UpSaleCallStatus;
18
import com.spice.profitmandi.dao.model.PaymentLinkDetailModel;
19
import com.spice.profitmandi.dao.model.PaymentLinkDetailModel;
-
 
20
import com.spice.profitmandi.dao.model.UpsellingReportModel;
19
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
21
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
20
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
22
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
21
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
23
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
22
import com.spice.profitmandi.dao.repository.cs.CsService;
24
import com.spice.profitmandi.dao.repository.cs.CsService;
23
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
25
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
Line 45... Line 47...
45
import org.springframework.ui.Model;
47
import org.springframework.ui.Model;
46
import org.springframework.web.bind.annotation.*;
48
import org.springframework.web.bind.annotation.*;
47
 
49
 
48
import javax.servlet.http.HttpServletRequest;
50
import javax.servlet.http.HttpServletRequest;
49
import java.time.Instant;
51
import java.time.Instant;
-
 
52
import java.time.LocalDate;
50
import java.time.LocalDateTime;
53
import java.time.LocalDateTime;
51
import java.time.ZoneId;
54
import java.time.ZoneId;
-
 
55
import java.time.format.DateTimeFormatter;
52
import java.util.*;
56
import java.util.*;
53
import java.util.stream.Collectors;
57
import java.util.stream.Collectors;
54
 
58
 
55
 
59
 
56
@Controller
60
@Controller
Line 527... Line 531...
527
        FofoOrder fofoOrder = fofoOrderRepository.selectByOrderId(orderId);
531
        FofoOrder fofoOrder = fofoOrderRepository.selectByOrderId(orderId);
528
        fofoOrder.setCustomerAddressId(addressId);
532
        fofoOrder.setCustomerAddressId(addressId);
529
        return responseSender.ok(true);
533
        return responseSender.ok(true);
530
    }
534
    }
531
 
535
 
-
 
536
    @RequestMapping(value = "/downloadUpsellingReport", method = RequestMethod.GET)
-
 
537
    public ResponseEntity<?> downloadUpsellingReport(HttpServletRequest request,
-
 
538
                                                     @RequestParam(name = "startDate") LocalDateTime startDate,
-
 
539
                                                     @RequestParam(name = "endDate") LocalDateTime endDate, Model model)
-
 
540
            throws Exception {
-
 
541
 
-
 
542
        List<List<?>> rows = new ArrayList<>();
-
 
543
 
-
 
544
        LocalDate startLocalDate = startDate.toLocalDate();
-
 
545
        LocalDate endLocalDate = endDate.toLocalDate();
-
 
546
 
-
 
547
        List<UpsellingReportModel> upsellingReportModels = upSaleCallRepository.getUpsellingReport(startLocalDate, endLocalDate.plusDays(1));
-
 
548
 
-
 
549
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
-
 
550
 
-
 
551
        for (
-
 
552
                UpsellingReportModel report : upsellingReportModels) {
-
 
553
 
-
 
554
            rows.add(Arrays.asList(
-
 
555
                    report.getAgentEmail(),
-
 
556
                    report.getOrderId(),
-
 
557
                    report.getCustomerNumber(),
-
 
558
                    report.getCallingDate(),
-
 
559
                    report.getPaymentStatus(),
-
 
560
                    report.getInsuranceStatus(),
-
 
561
                    report.getPolicySoldAmount(),
-
 
562
                    report.getInvoiceNumber(),
-
 
563
                    report.getSerialNumber()
-
 
564
            ));
-
 
565
 
-
 
566
        }
-
 
567
 
-
 
568
 
-
 
569
        org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
-
 
570
                .getCSVByteStream(Arrays.asList("Agent Email", "Order Id", "Customer Mobile Number", "Calling Date", "Payment Status", "Insurance Status", "Policy Sold Amount", "Invoice Number", "Serial Number"), rows);
-
 
571
        ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, " Upselling Report");
-
 
572
 
-
 
573
        return responseEntity;
-
 
574
 
-
 
575
    }
-
 
576
 
-
 
577
    @RequestMapping(value = "/getUpsellingReport", method = RequestMethod.GET)
-
 
578
    public String getUpsellingReport(
-
 
579
            HttpServletRequest request,
-
 
580
            @RequestParam(name = "startDate") LocalDateTime startDate,
-
 
581
            @RequestParam(name = "endDate") LocalDateTime endDate, Model model
-
 
582
    ) throws Exception {
-
 
583
 
-
 
584
        LocalDate startLocalDate = startDate.toLocalDate();
-
 
585
        LocalDate endLocalDate = endDate.toLocalDate();
-
 
586
 
-
 
587
        List<UpsellingReportModel> upsellingReportModels = upSaleCallRepository.getUpsellingReport(startLocalDate, endLocalDate.plusDays(1));
-
 
588
 
-
 
589
        model.addAttribute("upsellingReportModels", upsellingReportModels);
-
 
590
 
-
 
591
        return "upselling-report";
-
 
592
    }
-
 
593
 
-
 
594
    @RequestMapping(value = "/upsellingCallingList", method = RequestMethod.GET)
-
 
595
    public String upsellingCallingList(
-
 
596
            HttpServletRequest request, Model model) throws Exception {
-
 
597
 
-
 
598
        return "upselling-calling-list";
-
 
599
    }
532
 
600
 
533
}
601
}