Subversion Repositories SmartDukaan

Rev

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

Rev 35289 Rev 35306
Line 883... Line 883...
883
            //Check for Trial users here
883
            //Check for Trial users here
884
            int nextStoreCodeInt = fofoStoreRepository.selectLatestStore().getCodeInt() + 1;
884
            int nextStoreCodeInt = fofoStoreRepository.selectLatestStore().getCodeInt() + 1;
885
 
885
 
886
            String fofoStoreCode = StringUtils.generateFofoStoreSequence(
886
            String fofoStoreCode = StringUtils.generateFofoStoreSequence(
887
                    districtMaster.getStateShortName() + districtMaster.getShortName(), nextStoreCodeInt);
887
                    districtMaster.getStateShortName() + districtMaster.getShortName(), nextStoreCodeInt);
-
 
888
            try {
888
            TrialForm trialForm = trialFormRepository.selectByEmailOrMobile(updateRetailerRequest.getUserMobileNumber());
889
                TrialForm trialForm = trialFormRepository.selectByEmailOrMobile(updateRetailerRequest.getUserMobileNumber());
889
            if (trialForm != null) {
890
                if (trialForm != null) {
890
                fofoStoreCode = "T-" + fofoStoreCode;
891
                    fofoStoreCode = "T-" + fofoStoreCode;
891
                fofoStore.setTrial(true);
892
                    fofoStore.setTrial(true);
892
                fofoStore.setTrialStart(LocalDate.now());
893
                    fofoStore.setTrialStart(LocalDate.now());
893
                fofoStore.setTrialEnd(LocalDate.now().plusDays(31));
894
                    fofoStore.setTrialEnd(LocalDate.now().plusDays(31));
894
                trialForm.setStatus(ProfitMandiConstants.Status.APPROVED);
895
                    trialForm.setStatus(ProfitMandiConstants.Status.APPROVED);
895
                //TODO:Amit G, Send store code notification to retailer.
896
                    //TODO:Amit G, Send store code notification to retailer.
-
 
897
                }
-
 
898
            } catch (ProfitMandiBusinessException e) {
896
            }
899
            }
897
            fofoStore.setCode(fofoStoreCode);
900
            fofoStore.setCode(fofoStoreCode);
898
            fofoStore.setCodeInt(nextStoreCodeInt);
901
            fofoStore.setCodeInt(nextStoreCodeInt);
899
            fofoStore.setBagsLastCredited(LocalDateTime.now());
902
            fofoStore.setBagsLastCredited(LocalDateTime.now());
900
            if (retailerAddress.getName().contains(ProfitMandiConstants.COMPANY_NAME) || retailerAddress.getName().contains(ProfitMandiConstants.COMPANY_SHORT_NAME)) {
903
            if (retailerAddress.getName().contains(ProfitMandiConstants.COMPANY_NAME) || retailerAddress.getName().contains(ProfitMandiConstants.COMPANY_SHORT_NAME)) {
Line 933... Line 936...
933
                pincodePartnerRepository.perist(pinPartner);
936
                pincodePartnerRepository.perist(pinPartner);
934
            }
937
            }
935
        }
938
        }
936
 
939
 
937
        if (fofoStore.isTrial()) {
940
        if (fofoStore.isTrial()) {
938
            this.sendTrialStoreCreationMail(fofoStore, updateRetailerRequest);
941
            storeTimelineTatService.sendTrialStoreCreationMail(fofoStore, updateRetailerRequest);
939
        }
942
        }
940
 
943
 
941
        return fofoStore;
944
        return fofoStore;
942
    }
945
    }
943
 
946
 
944
    private void sendTrialStoreCreationMail(FofoStore fofoStore, UpdateRetailerRequest updateRetailerRequest) {
-
 
945
 
-
 
946
        try {
-
 
947
 
-
 
948
            String subject = String.format("Trial Store Created - %s");
-
 
949
            String message = new StringBuffer("New Trial Store Created. Please align for Training and Engagement. Assign ABMs and RBMs and BMs")
-
 
950
                    .append(String.format("Address - %s, %s\n", updateRetailerRequest.getAddress().getLine1(), updateRetailerRequest.getAddress().getLine2()))
-
 
951
                    .append(String.format("City - %s, ", updateRetailerRequest.getAddress().getCity()))
-
 
952
                    .append(String.format("Pincode - %s, ", updateRetailerRequest.getAddress().getPinCode()))
-
 
953
                    .append(String.format("State - %s", updateRetailerRequest.getAddress().getState())).toString();
-
 
954
 
-
 
955
            LOGGER.info("message" + message);
-
 
956
 
-
 
957
 
-
 
958
            //String [] mailTo = {"tarun.verma@smartdukaan.com", "neeraj.gupta@smartdukaan.com", "kamini.sharma@smartdukaan.com"}
-
 
959
            String[] mailTo = {"amit.gupta@smartdukaan.com"};
-
 
960
            Utils.sendMailWithAttachments(googleMailSender, new String[]{}, null, subject, message);
-
 
961
        } catch (Exception e) {
-
 
962
 
-
 
963
            e.printStackTrace();
-
 
964
 
-
 
965
        }
-
 
966
 
-
 
967
    }
-
 
968
 
-
 
969
    @Override
947
    @Override
970
    public FofoStore createFofoStoreCodeByUserId(int userId, String districtName, String
948
    public FofoStore createFofoStoreCodeByUserId(int userId, String districtName, String
971
            stateName, UpdateRetailerRequest updateRetailerRequest) throws ProfitMandiBusinessException {
949
            stateName, UpdateRetailerRequest updateRetailerRequest) throws ProfitMandiBusinessException {
972
        User user = userRepository.selectById(userId);
950
        User user = userRepository.selectById(userId);
973
        // = userAccountRepository.selectRetailerIdByUserId(user.getId());
951
        // = userAccountRepository.selectRetailerIdByUserId(user.getId());