Subversion Repositories SmartDukaan

Rev

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

Rev 34391 Rev 34394
Line 184... Line 184...
184
    @ApiImplicitParams({
184
    @ApiImplicitParams({
185
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
185
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
186
 
186
 
187
    public ResponseEntity<?> LeadUser(@RequestBody CreateRefferalRequest createRefferalRequest) throws Exception {
187
    public ResponseEntity<?> LeadUser(@RequestBody CreateRefferalRequest createRefferalRequest) throws Exception {
188
        LOGGER.info("CreateRefferalRequest - " + createRefferalRequest);
188
        LOGGER.info("CreateRefferalRequest - " + createRefferalRequest);
189
        if(createRefferalRequest.getOutletName()==null || createRefferalRequest.getPotential() == 0){
189
        if (createRefferalRequest.getOutletName() == null || createRefferalRequest.getPotential() == 0) {
190
            throw new Exception("Outlet should not be empty and potential shoul be greator > 0");
190
            throw new Exception("Outlet should not be empty and potential shoul be greator > 0");
191
        }
191
        }
192
        Lead lead = new Lead();
192
        Lead lead = new Lead();
193
        lead.setFirstName(createRefferalRequest.getFirstName());
193
        lead.setFirstName(createRefferalRequest.getFirstName());
194
        lead.setLastName(createRefferalRequest.getLastName());
194
        lead.setLastName(createRefferalRequest.getLastName());
Line 200... Line 200...
200
        lead.setOutLetName(createRefferalRequest.getOutletName());
200
        lead.setOutLetName(createRefferalRequest.getOutletName());
201
        lead.setUpdatedTimestamp(LocalDateTime.now());
201
        lead.setUpdatedTimestamp(LocalDateTime.now());
202
        lead.setStatus(createRefferalRequest.getStatus());
202
        lead.setStatus(createRefferalRequest.getStatus());
203
        lead.setSource(createRefferalRequest.getSource());
203
        lead.setSource(createRefferalRequest.getSource());
204
        lead.setNotinterestedReason(createRefferalRequest.getReason());
204
        lead.setNotinterestedReason(createRefferalRequest.getReason());
-
 
205
        lead.setPotential(createRefferalRequest.getPotential());
205
        if (createRefferalRequest.getColorCheck() == true) {
206
        if (createRefferalRequest.getColorCheck() == true) {
206
            lead.setColor("Green");
207
            lead.setColor("Green");
207
        } else {
208
        } else {
208
            lead.setColor("Yellow");
209
            lead.setColor("Yellow");
209
        }
210
        }
Line 253... Line 254...
253
//        }
254
//        }
254
 
255
 
255
        LeadActivity leadActivity = new LeadActivity();
256
        LeadActivity leadActivity = new LeadActivity();
256
        leadActivity.setLeadId(lead.getId());
257
        leadActivity.setLeadId(lead.getId());
257
        leadActivity.setRemark(createRefferalRequest.getRemark());
258
        leadActivity.setRemark(createRefferalRequest.getRemark());
258
        leadActivity.setPotential(createRefferalRequest.getPotential());
-
 
259
        leadActivity.setOutletName(createRefferalRequest.getOutletName());
-
 
260
 
-
 
261
        leadActivity.setAuthId(authUser.getId());
259
        leadActivity.setAuthId(authUser.getId());
262
 
260
 
263
        if (createRefferalRequest.getStatus().equals(LeadStatus.followUp)) {
261
        if (createRefferalRequest.getStatus().equals(LeadStatus.followUp)) {
264
            leadActivity.setSchelduleTimestamp(createRefferalRequest.getSchelduleTimestamp());
262
            leadActivity.setSchelduleTimestamp(createRefferalRequest.getSchelduleTimestamp());
265
            leadActivity.setCommunicationType(createRefferalRequest.getCommunicationType());
263
            leadActivity.setCommunicationType(createRefferalRequest.getCommunicationType());
Line 368... Line 366...
368
                                        @RequestParam(name = "closureTimestamp") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime closureTimestamp,
366
                                        @RequestParam(name = "closureTimestamp") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime closureTimestamp,
369
                                        @RequestParam(name = "communicationType") CommunicationType communicationType)
367
                                        @RequestParam(name = "communicationType") CommunicationType communicationType)
370
            throws ProfitMandiBusinessException {
368
            throws ProfitMandiBusinessException {
371
 
369
 
372
        Lead lead = leadRepository.selectById(id);
370
        Lead lead = leadRepository.selectById(id);
373
        LeadActivity oldLeadActivity = leadActivityRepository.selectByLeadId(id);
-
 
374
 
371
 
375
 
372
 
376
        LeadActivity leadActivity = new LeadActivity();
373
        LeadActivity leadActivity = new LeadActivity();
377
        lead.setStatus(status);
374
        lead.setStatus(status);
378
        lead.setNotinterestedReason(reason);
375
        lead.setNotinterestedReason(reason);
379
        leadActivity.setRemark(remark);
376
        leadActivity.setRemark(remark);
380
        leadActivity.setLeadId(id);
377
        leadActivity.setLeadId(id);
381
        leadActivity.setOutletName(oldLeadActivity.getOutletName());
378
        leadActivity.setOutletName(lead.getOutLetName());
382
        leadActivity.setPotential(oldLeadActivity.getPotential());
379
        leadActivity.setPotential(lead.getPotential());
383
        leadActivity.setCreatedTimestamp(LocalDateTime.now());
380
        leadActivity.setCreatedTimestamp(LocalDateTime.now());
384
        leadActivity.setSchelduleTimestamp(null);
381
        leadActivity.setSchelduleTimestamp(null);
385
        leadActivity.setClosureTimestamp(null);
382
        leadActivity.setClosureTimestamp(null);
386
        leadActivity.setAuthId(lead.getAssignTo());
383
        leadActivity.setAuthId(lead.getAssignTo());
387
        lead.setUpdatedTimestamp(LocalDateTime.now());
384
        lead.setUpdatedTimestamp(LocalDateTime.now());
Line 541... Line 538...
541
    @ApiImplicitParams({
538
    @ApiImplicitParams({
542
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
539
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
543
    public ResponseEntity<?> FranchiseVisit(HttpServletRequest request,
540
    public ResponseEntity<?> FranchiseVisit(HttpServletRequest request,
544
                                            @RequestBody CreateFranchiseeRequest createFranchiseeRequest) throws Exception {
541
                                            @RequestBody CreateFranchiseeRequest createFranchiseeRequest) throws Exception {
545
 
542
 
546
        int rbmL1 = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_RBM,EscalationType.L1,createFranchiseeRequest.getFofoId());
543
        int rbmL1 = csService.getAuthUserId(ProfitMandiConstants.TICKET_CATEGORY_RBM, EscalationType.L1, createFranchiseeRequest.getFofoId());
547
 
544
 
548
        FranchiseeVisit franchiseeVisit = franchiseeVisitRepository.selectById(createFranchiseeRequest.getId());
545
        FranchiseeVisit franchiseeVisit = franchiseeVisitRepository.selectById(createFranchiseeRequest.getId());
549
        franchiseeVisit.setFofoId(createFranchiseeRequest.getFofoId());
546
        franchiseeVisit.setFofoId(createFranchiseeRequest.getFofoId());
550
        CustomRetailer customRetailer = retailerService.getFofoRetailer(createFranchiseeRequest.getFofoId());
547
        CustomRetailer customRetailer = retailerService.getFofoRetailer(createFranchiseeRequest.getFofoId());
551
        LOGGER.info("rbmL1 {}",rbmL1);
548
        LOGGER.info("rbmL1 {}", rbmL1);
552
        franchiseeVisit.setPartnerName(customRetailer.getBusinessName());
549
        franchiseeVisit.setPartnerName(customRetailer.getBusinessName());
553
        franchiseeVisit.setAgenda(createFranchiseeRequest.getAgenda());
550
        franchiseeVisit.setAgenda(createFranchiseeRequest.getAgenda());
554
        franchiseeVisit.setPartnerRemark(createFranchiseeRequest.getPartnerRemark());
551
        franchiseeVisit.setPartnerRemark(createFranchiseeRequest.getPartnerRemark());
555
        franchiseeVisit.setOutsideVisibity(createFranchiseeRequest.getOutsideVisibity());
552
        franchiseeVisit.setOutsideVisibity(createFranchiseeRequest.getOutsideVisibity());
556
        franchiseeVisit.setInstoreVisibility(createFranchiseeRequest.getInstoreVisibility());
553
        franchiseeVisit.setInstoreVisibility(createFranchiseeRequest.getInstoreVisibility());
Line 602... Line 599...
602
        franchiseeActivity.setCreatedTimestamp(LocalDateTime.now());
599
        franchiseeActivity.setCreatedTimestamp(LocalDateTime.now());
603
        franchiseeActivityRepository.persist(franchiseeActivity);
600
        franchiseeActivityRepository.persist(franchiseeActivity);
604
 
601
 
605
        franchiseeVisit.setFranchiseActivityId(franchiseeActivity.getId());
602
        franchiseeVisit.setFranchiseActivityId(franchiseeActivity.getId());
606
 
603
 
607
        if(!createFranchiseeRequest.getOutsideVisibityReason().isEmpty()){
604
        if (!createFranchiseeRequest.getOutsideVisibityReason().isEmpty()) {
608
            csService.createTicket(createFranchiseeRequest.getFofoId(), ProfitMandiConstants.TICKET_CATEGORY_DESIGN, ProfitMandiConstants.TICKET_CATEGORY_DESIGNING_BRANDING_EXTERNAL_VISIBILITY, createFranchiseeRequest.getOutsideVisibityReason(), authUser.getId());
605
            csService.createTicket(createFranchiseeRequest.getFofoId(), ProfitMandiConstants.TICKET_CATEGORY_DESIGN, ProfitMandiConstants.TICKET_CATEGORY_DESIGNING_BRANDING_EXTERNAL_VISIBILITY, createFranchiseeRequest.getOutsideVisibityReason(), authUser.getId());
609
        }
606
        }
610
 
607
 
611
        if(!createFranchiseeRequest.getInstoreVisibilityReason().isEmpty()){
608
        if (!createFranchiseeRequest.getInstoreVisibilityReason().isEmpty()) {
612
            csService.createTicket(createFranchiseeRequest.getFofoId(), ProfitMandiConstants.TICKET_CATEGORY_DESIGN, ProfitMandiConstants.TICKET_CATEGORY_DESIGNING_BRANDING_INTERNAL_VISIBILITY, createFranchiseeRequest.getInstoreVisibilityReason(), authUser.getId());
609
            csService.createTicket(createFranchiseeRequest.getFofoId(), ProfitMandiConstants.TICKET_CATEGORY_DESIGN, ProfitMandiConstants.TICKET_CATEGORY_DESIGNING_BRANDING_INTERNAL_VISIBILITY, createFranchiseeRequest.getInstoreVisibilityReason(), authUser.getId());
613
        }
610
        }
614
 
611
 
615
        if(!createFranchiseeRequest.getOutsideStockReason().isEmpty()){
612
        if (!createFranchiseeRequest.getOutsideStockReason().isEmpty()) {
616
            csService.createTicket(createFranchiseeRequest.getFofoId(), ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_SALES_OUTSIDE_STOCK, createFranchiseeRequest.getOutsideStockReason(), authUser.getId());
613
            csService.createTicket(createFranchiseeRequest.getFofoId(), ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_SALES_OUTSIDE_STOCK, createFranchiseeRequest.getOutsideStockReason(), authUser.getId());
617
        }
614
        }
618
 
615
 
619
        if(!createFranchiseeRequest.getSystemKnowledgeReason().isEmpty()){
616
        if (!createFranchiseeRequest.getSystemKnowledgeReason().isEmpty()) {
620
            csService.createTicket(createFranchiseeRequest.getFofoId(), ProfitMandiConstants.TICKET_CATEGORY_TRAINING, ProfitMandiConstants.TICKET_CATEGORY_TRAINING_NEED, createFranchiseeRequest.getSystemKnowledgeReason(), authUser.getId());
617
            csService.createTicket(createFranchiseeRequest.getFofoId(), ProfitMandiConstants.TICKET_CATEGORY_TRAINING, ProfitMandiConstants.TICKET_CATEGORY_TRAINING_NEED, createFranchiseeRequest.getSystemKnowledgeReason(), authUser.getId());
621
        }
618
        }
622
 
619
 
623
        if(!createFranchiseeRequest.getLatestDummiesReason().isEmpty()){
620
        if (!createFranchiseeRequest.getLatestDummiesReason().isEmpty()) {
624
            csService.createTicket(createFranchiseeRequest.getFofoId(), ProfitMandiConstants.TICKET_CATEGORY_MARKETING, ProfitMandiConstants.TICKET_CATEGORY_MARKETING_DUMMIES, createFranchiseeRequest.getLatestDummiesReason(), authUser.getId());
621
            csService.createTicket(createFranchiseeRequest.getFofoId(), ProfitMandiConstants.TICKET_CATEGORY_MARKETING, ProfitMandiConstants.TICKET_CATEGORY_MARKETING_DUMMIES, createFranchiseeRequest.getLatestDummiesReason(), authUser.getId());
625
        }
622
        }
626
 
623
 
627
        if(!createFranchiseeRequest.getInvestmentReason().isEmpty()){
624
        if (!createFranchiseeRequest.getInvestmentReason().isEmpty()) {
628
            csService.createTicket(createFranchiseeRequest.getFofoId(), ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_SALES_LOW_INVESTMENT, createFranchiseeRequest.getInvestmentReason(), authUser.getId());
625
            csService.createTicket(createFranchiseeRequest.getFofoId(), ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_SALES_LOW_INVESTMENT, createFranchiseeRequest.getInvestmentReason(), authUser.getId());
629
        }
626
        }
630
 
627
 
631
        if(!createFranchiseeRequest.getHygieneReason().isEmpty()){
628
        if (!createFranchiseeRequest.getHygieneReason().isEmpty()) {
632
            csService.createTicket(createFranchiseeRequest.getFofoId(), ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_SALES_LOW_DATA_ACCURACY, createFranchiseeRequest.getHygieneReason(), authUser.getId());
629
            csService.createTicket(createFranchiseeRequest.getFofoId(), ProfitMandiConstants.TICKET_CATEGORY_SALES, ProfitMandiConstants.TICKET_CATEGORY_SALES_LOW_DATA_ACCURACY, createFranchiseeRequest.getHygieneReason(), authUser.getId());
633
        }
630
        }
634
 
631
 
635
 
632
 
636
 
-
 
637
        return responseSender.ok(true);
633
        return responseSender.ok(true);
638
 
634
 
639
    }
635
    }
640
 
636
 
641
    @RequestMapping(value = "/getFranchiseVisit", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
637
    @RequestMapping(value = "/getFranchiseVisit", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
Line 1648... Line 1644...
1648
 
1644
 
1649
        return responseSender.ok("Rating submitted successfully.");
1645
        return responseSender.ok("Rating submitted successfully.");
1650
    }
1646
    }
1651
 
1647
 
1652
 
1648
 
1653
 
-
 
1654
}
1649
}
1655
1650