Subversion Repositories SmartDukaan

Rev

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

Rev 36978 Rev 36983
Line 355... Line 355...
355
        response = true;
355
        response = true;
356
        model.addAttribute("response1", mvcResponseSender.createResponseString(response));
356
        model.addAttribute("response1", mvcResponseSender.createResponseString(response));
357
        return "response";
357
        return "response";
358
    }
358
    }
359
 
359
 
-
 
360
    // Generate (only) the IMEI rows for a flagged price hike so they can be reviewed before
-
 
361
    // processing. Does NOT debit. Idempotent: priceDropStatus creates rows only when none exist.
-
 
362
    @RequestMapping(value = "/priceHike/generateImeis/{priceDropId}", method = RequestMethod.POST)
-
 
363
    public String generateHikeImeis(HttpServletRequest request, @PathVariable int priceDropId, Model model)
-
 
364
            throws Exception {
-
 
365
        PriceDrop priceDrop = priceDropRepository.selectById(priceDropId);
-
 
366
        if (priceDrop.getAmount() >= 0 || !priceDrop.isDeductOnHike()) {
-
 
367
            throw new ProfitMandiBusinessException("Generate hike IMEIs", String.valueOf(priceDropId),
-
 
368
                    "Not a price hike flagged for deduction (amount must be < 0 and deduct_on_hike = 1)");
-
 
369
        }
-
 
370
        priceDropService.priceDropStatus(priceDropId);
-
 
371
        List<PriceDropIMEI> rows = priceDropIMEIRepository.selectByPriceDropId(priceDropId);
-
 
372
        Map<String, Object> result = new HashMap<>();
-
 
373
        result.put("priceDropId", priceDropId);
-
 
374
        result.put("generatedCount", rows.size());
-
 
375
        result.put("statusBreakdown", rows.stream()
-
 
376
                .collect(Collectors.groupingBy(x -> x.getStatus().name(), Collectors.counting())));
-
 
377
        model.addAttribute("response1", mvcResponseSender.createResponseString(result));
-
 
378
        return "response";
-
 
379
    }
-
 
380
 
360
    @RequestMapping(value = "/priceDrop", method = RequestMethod.POST)
381
    @RequestMapping(value = "/priceDrop", method = RequestMethod.POST)
361
    public String addPriceDrop(HttpServletRequest request, Model model, @RequestBody PriceDropModel priceDropModel)
382
    public String addPriceDrop(HttpServletRequest request, Model model, @RequestBody PriceDropModel priceDropModel)
362
            throws Exception {
383
            throws Exception {
363
        boolean response = false;
384
        boolean response = false;
364
        priceDropModel.setAllColors(true);
385
        priceDropModel.setAllColors(true);