Subversion Repositories SmartDukaan

Rev

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

Rev 34527 Rev 34631
Line 158... Line 158...
158
 
158
 
159
    @RequestMapping(value = "/retailerDetails", method = RequestMethod.PUT)
159
    @RequestMapping(value = "/retailerDetails", method = RequestMethod.PUT)
160
    public String updateRetailerDetails(HttpServletRequest request,
160
    public String updateRetailerDetails(HttpServletRequest request,
161
                                        @RequestBody UpdateRetailerRequest updateRetailerRequest, Model model) throws ProfitMandiBusinessException {
161
                                        @RequestBody UpdateRetailerRequest updateRetailerRequest, Model model) throws ProfitMandiBusinessException {
162
        LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), updateRetailerRequest);
162
        LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), updateRetailerRequest);
163
        if (!updateRetailerRequest.getFofoType().equals(FofoType.INTERNAL)) {
-
 
164
            LoiForm loiForm = null;
-
 
165
            loiForm = loiFormRepository.selectByEmailOrMobile(updateRetailerRequest.getUserMobileNumber());
-
 
166
            if (loiForm == null) {
-
 
167
                loiForm = loiFormRepository.selectByEqualsKeyValue("gstNo", updateRetailerRequest.getGstNumber());
-
 
168
                if (loiForm == null) {
-
 
169
                    throw new ProfitMandiBusinessException("Loi Not Available of this User", "Message - ", "Please fill the LOI_FORM and try again");
-
 
170
                }
-
 
171
            }
-
 
172
 
163
 
-
 
164
        if (!updateRetailerRequest.getFofoType().equals(FofoType.INTERNAL)) {
-
 
165
            checkLoiCompletion(updateRetailerRequest);
173
        }
166
        }
174
        Map<String, Object> map = retailerService.updateRetailerDetails(updateRetailerRequest);
167
        Map<String, Object> map = retailerService.updateRetailerDetails(updateRetailerRequest);
175
        //retailerService.up
168
        //retailerService.up
176
 
169
 
177
        model.addAllAttributes(map);
170
        model.addAllAttributes(map);
Line 181... Line 174...
181
        model.addAttribute("warehouses", warehouseMap);
174
        model.addAttribute("warehouses", warehouseMap);
182
        model.addAttribute("fofoTypes", FofoType.values());
175
        model.addAttribute("fofoTypes", FofoType.values());
183
        return "retailer-details";
176
        return "retailer-details";
184
    }
177
    }
185
 
178
 
-
 
179
    private void checkLoiCompletion(UpdateRetailerRequest updateRetailerRequest) throws ProfitMandiBusinessException {
-
 
180
        if (updateRetailerRequest.getFofoType().equals(FofoType.INTERNAL)) {
-
 
181
            return; // Early return for internal type
-
 
182
        }
-
 
183
        String userMobile = updateRetailerRequest.getUserMobileNumber();
-
 
184
        String gstNumber = updateRetailerRequest.getGstNumber();
-
 
185
        LoiForm loiForm = findLoiForm(userMobile, gstNumber);
-
 
186
        if (loiForm == null) {
-
 
187
            throw new ProfitMandiBusinessException("Loi Not Available","Message - ","Please fill the LOI_FORM and try again");
-
 
188
        }
-
 
189
        if (loiForm.getOnBoardingId() <= 0) {
-
 
190
            throw new ProfitMandiBusinessException("Loi not completed", "Message - ", "Please Complete LOI_FORM and try again");
-
 
191
        }
-
 
192
    }
-
 
193
    
-
 
194
    private LoiForm findLoiForm(String mobile, String gstNumber) throws ProfitMandiBusinessException {
-
 
195
        LoiForm form = loiFormRepository.selectByEmailOrMobile(mobile);
-
 
196
        if (form == null && gstNumber != null) {
-
 
197
            form = loiFormRepository.selectByEqualsKeyValue("gstNo", gstNumber);
-
 
198
        }
-
 
199
        return form;
-
 
200
    }
-
 
201
 
186
    @RequestMapping(value = "/retailer/update-email", method = RequestMethod.POST)
202
    @RequestMapping(value = "/retailer/update-email", method = RequestMethod.POST)
187
    public String updateRetailerEmail(@RequestParam("newEmail") String newEmail, @RequestParam("fofoID") int fofoID) throws ProfitMandiBusinessException {
203
    public String updateRetailerEmail(@RequestParam("newEmail") String newEmail, @RequestParam("fofoID") int fofoID) throws ProfitMandiBusinessException {
188
        retailerService.updateRetailerEmail(fofoID, newEmail);
204
        retailerService.updateRetailerEmail(fofoID, newEmail);
189
        return "retailer-details";
205
        return "retailer-details";
190
    }
206
    }