Subversion Repositories SmartDukaan

Rev

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

Rev 32703 Rev 32737
Line 16... Line 16...
16
 
16
 
17
import javax.servlet.http.HttpServletRequest;
17
import javax.servlet.http.HttpServletRequest;
18
 
18
 
19
import com.spice.profitmandi.common.enumuration.ActivationType;
19
import com.spice.profitmandi.common.enumuration.ActivationType;
20
import com.spice.profitmandi.common.web.client.RestClient;
20
import com.spice.profitmandi.common.web.client.RestClient;
-
 
21
import com.spice.profitmandi.dao.entity.fofo.RetailerContact;
21
import com.spice.profitmandi.service.FofoUser;
22
import com.spice.profitmandi.service.FofoUser;
-
 
23
import com.spice.profitmandi.service.smartping.SmartPingAgentModel;
-
 
24
import com.spice.profitmandi.service.smartping.SmartPingService;
22
import org.apache.commons.csv.CSVRecord;
25
import org.apache.commons.csv.CSVRecord;
23
import org.apache.logging.log4j.LogManager;
26
import org.apache.logging.log4j.LogManager;
24
import org.apache.logging.log4j.Logger;
27
import org.apache.logging.log4j.Logger;
25
import org.springframework.beans.factory.annotation.Autowired;
28
import org.springframework.beans.factory.annotation.Autowired;
26
import org.springframework.format.annotation.DateTimeFormat;
29
import org.springframework.format.annotation.DateTimeFormat;
Line 767... Line 770...
767
        LOGGER.info("partnerTicketCount {}", partnerTicketCount);
770
        LOGGER.info("partnerTicketCount {}", partnerTicketCount);
768
 
771
 
769
        List<PartnerTargetAchievementModel> ptams = new ArrayList<>();
772
        List<PartnerTargetAchievementModel> ptams = new ArrayList<>();
770
 
773
 
771
        if (fofoIds != null && fofoIds.size() > 0) {
774
        if (fofoIds != null && fofoIds.size() > 0) {
772
            LOGGER.info("fofoIds {}", fofoIds );
775
            LOGGER.info("fofoIds {}", fofoIds);
773
            List<Integer> fofoIdList = fofoStoreRepository.selectByRetailerIds(new ArrayList<>(fofoIds)).stream()
776
            List<Integer> fofoIdList = fofoStoreRepository.selectByRetailerIds(new ArrayList<>(fofoIds)).stream()
774
                    .filter(x -> (!x.isInternal() && (activationType == null || x.getActivationType().equals(activationType))))
777
                    .filter(x -> (!x.isInternal() && (activationType == null || x.getActivationType().equals(activationType))))
775
                    .map(x -> x.getId()).collect(Collectors.toList());
778
                    .map(x -> x.getId()).collect(Collectors.toList());
776
            LOGGER.info("fofoIdList {}", fofoIdList );
779
            LOGGER.info("fofoIdList {}", fofoIdList);
777
            LocalDateTime startDate = LocalDate.now().atStartOfDay();
780
            LocalDateTime startDate = LocalDate.now().atStartOfDay();
778
 
781
 
779
            if (dayValue.equals("previous")) {
782
            if (dayValue.equals("previous")) {
780
                startDate = LocalDate.now().minusDays(1).atStartOfDay();
783
                startDate = LocalDate.now().minusDays(1).atStartOfDay();
781
 
784
 
Line 1013... Line 1016...
1013
 
1016
 
1014
        }
1017
        }
1015
        return responseSender.ok(tm);
1018
        return responseSender.ok(tm);
1016
 
1019
 
1017
    }
1020
    }
-
 
1021
 
1018
//TODO:Amit
1022
    //TODO:Amit
1019
    @RequestMapping(value = "/target", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
1023
    @RequestMapping(value = "/target", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
1020
    @ApiImplicitParams({
1024
    @ApiImplicitParams({
1021
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
1025
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
1022
    public ResponseEntity<?> createPartnerTarget(HttpServletRequest request,
1026
    public ResponseEntity<?> createPartnerTarget(HttpServletRequest request,
1023
                                                 @RequestBody PartnerTargetAchievementModel ptam) throws ProfitMandiBusinessException {
1027
                                                 @RequestBody PartnerTargetAchievementModel ptam) throws ProfitMandiBusinessException {
Line 1301... Line 1305...
1301
    }
1305
    }
1302
 
1306
 
1303
    @Autowired
1307
    @Autowired
1304
    RestClient restClient;
1308
    RestClient restClient;
1305
 
1309
 
-
 
1310
    @Autowired
-
 
1311
    SmartPingService smartPingService;
-
 
1312
 
-
 
1313
    @RequestMapping(value = "/retailer/contacts/{fofoId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
1314
    public ResponseEntity<?> getContacts(HttpServletRequest request, @PathVariable int fofoId) throws Exception {
-
 
1315
        return responseSender.ok(retailerService.getContactsByFofoId(fofoId, true));
-
 
1316
    }
-
 
1317
 
1306
    @RequestMapping(value = "/click2call/{fofoId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
1318
    @RequestMapping(value = "/click2call/{toMobile}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
1307
    public ResponseEntity<?> createPartnerCollectionRemark(HttpServletRequest request, @PathVariable int fofoId) throws Exception {
1319
    public ResponseEntity<?> makeCallOnAgentBehalf(HttpServletRequest request, @PathVariable String toMobile) throws Exception {
1308
        int id = (int) request.getAttribute("userId");
1320
        int id = (int) request.getAttribute("userId");
1309
        User user = userRepository.selectById(id);
1321
        User user = userRepository.selectById(id);
1310
        AuthUser authUser = authRepository.selectByEmailOrMobile(user.getEmailId());
1322
        AuthUser authUser = authRepository.selectByEmailOrMobile(user.getEmailId());
1311
        String fromMobile = authUser.getMobileNumber();
1323
        String fromMobile = authUser.getMobileNumber();
1312
 
1324
 
1313
        com.spice.profitmandi.dao.entity.user.User fofoUser = userUserRepository.selectById(fofoId);
-
 
1314
        String toMobile = retailerService.getAllFofoRetailers().get(fofoId).getMobileNumber();
1325
        SmartPingAgentModel smartPingAgentModel = smartPingService.getAllAgents().get(toMobile);
1315
 
1326
 
1316
        //https://ccs1.smartpingcc.io/v2/clickToCall/para?&user_id=71287091&token=InCfClzwFUtLUW610faI&from=18086&fromType=Agent&fromCLI=%2B918645310932&to=XXXXXXXXXX&toCLI=%2B918645310932
1327
        String urlTemplate = "https://ccs1.smartpingcc.io/v2/clickToCall/para?&user_id=71287091&token=InCfClzwFUtLUW610faI&from=%d&fromType=Agent&fromCLI=&to=%s&toCLI=%s";
1317
 
1328
 
-
 
1329
        String url  = String.format(urlTemplate, smartPingAgentModel.getAgentId(), smartPingAgentModel.getAllowDid().get(0), toMobile, smartPingAgentModel.getAllowDid().get(0));
1318
 
1330
 
1319
        String url = String.format("https://ccs1.smartpingcc.io/v2/clickToCall/para?&user_id=71287091&token=InCfClzwFUtLUW610faI&from=%s&to=%s", fromMobile, toMobile);
-
 
1320
        restClient.get(url, null, null);
1331
        restClient.get(url, null, null);
1321
 
1332
 
1322
        return responseSender.ok(true);
1333
        return responseSender.ok(true);
1323
    }
1334
    }
1324
 
1335
 
1325
    @RequestMapping(value = "/createPartnerColectionRemark", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
1336
    @RequestMapping(value = "/createPartnerColectionRemark", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
1326
    @ApiImplicitParams({
1337
    @ApiImplicitParams({
1327
 
1338
 
1328
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
1339
            @ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
1329
    public ResponseEntity<?> createPartnerCollectionRemark(HttpServletRequest request,
1340
    public ResponseEntity<?> createPartnerCollectionRemark(HttpServletRequest request,
1330
                                                          @RequestBody PartnerCollectionRemarkModel partnerCollectionRemarkModel)
1341
                                                           @RequestBody PartnerCollectionRemarkModel partnerCollectionRemarkModel)
1331
            throws ProfitMandiBusinessException {
1342
            throws ProfitMandiBusinessException {
1332
        AuthUser authUser = authRepository.selectByGmailId(partnerCollectionRemarkModel.getGmailId());
1343
        AuthUser authUser = authRepository.selectByGmailId(partnerCollectionRemarkModel.getGmailId());
1333
 
1344
 
1334
        PartnerCollectionRemark pcr = new PartnerCollectionRemark();
1345
        PartnerCollectionRemark pcr = new PartnerCollectionRemark();
1335
        pcr.setFofoId(partnerCollectionRemarkModel.getFofoId());
1346
        pcr.setFofoId(partnerCollectionRemarkModel.getFofoId());