Subversion Repositories SmartDukaan

Rev

Rev 36983 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23819 govind 1
package com.spice.profitmandi.web.controller;
2
 
23945 amit.gupta 3
import com.fasterxml.jackson.databind.ObjectMapper;
29926 amit.gupta 4
import com.spice.profitmandi.common.enumuration.MessageType;
23819 govind 5
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
29926 amit.gupta 6
import com.spice.profitmandi.common.model.*;
23945 amit.gupta 7
import com.spice.profitmandi.common.services.ReporticoService;
23951 amit.gupta 8
import com.spice.profitmandi.common.util.FileUtil;
23945 amit.gupta 9
import com.spice.profitmandi.common.util.FormattingUtils;
28102 tejbeer 10
import com.spice.profitmandi.common.util.Utils;
23819 govind 11
import com.spice.profitmandi.dao.entity.catalog.Item;
23884 amit.gupta 12
import com.spice.profitmandi.dao.entity.catalog.TagListing;
32905 shampa 13
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
24822 amit.gupta 14
import com.spice.profitmandi.dao.entity.inventory.ItemPricingHistory;
23884 amit.gupta 15
import com.spice.profitmandi.dao.entity.inventory.VendorItemPricing;
23819 govind 16
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
24083 amit.gupta 17
import com.spice.profitmandi.dao.entity.transaction.PriceDropIMEI;
31903 amit.gupta 18
import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
24083 amit.gupta 19
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
31903 amit.gupta 20
import com.spice.profitmandi.dao.model.AmountModel;
23819 govind 21
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
23884 amit.gupta 22
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
35547 amit 23
import com.spice.profitmandi.dao.event.TagListingEventPublisher;
29926 amit.gupta 24
import com.spice.profitmandi.dao.repository.cs.CsService;
28136 tejbeer 25
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
28102 tejbeer 26
import com.spice.profitmandi.dao.repository.dtr.Mongo;
29926 amit.gupta 27
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
28102 tejbeer 28
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
24822 amit.gupta 29
import com.spice.profitmandi.dao.repository.inventory.ItemPricingHistoryRepository;
23884 amit.gupta 30
import com.spice.profitmandi.dao.repository.inventory.VendorItemPricingRepository;
23983 amit.gupta 31
import com.spice.profitmandi.dao.repository.transaction.LineItemImeisRepository;
24083 amit.gupta 32
import com.spice.profitmandi.dao.repository.transaction.PriceDropIMEIRepository;
23819 govind 33
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
29926 amit.gupta 34
import com.spice.profitmandi.service.NotificationService;
29951 amit.gupta 35
import com.spice.profitmandi.service.authentication.RoleManager;
32844 shampa 36
import com.spice.profitmandi.service.catalog.BrandsService;
23819 govind 37
import com.spice.profitmandi.service.inventory.InventoryService;
34651 aman.kumar 38
import com.spice.profitmandi.service.order.OrderService;
31903 amit.gupta 39
import com.spice.profitmandi.service.pricecircular.PriceCircularItemModelNew;
29788 amit.gupta 40
import com.spice.profitmandi.service.pricecircular.PriceCircularModel;
41
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
23983 amit.gupta 42
import com.spice.profitmandi.service.pricing.PriceDropService;
23968 amit.gupta 43
import com.spice.profitmandi.service.scheme.SchemeService;
23884 amit.gupta 44
import com.spice.profitmandi.service.transaction.TransactionService;
28102 tejbeer 45
import com.spice.profitmandi.service.user.RetailerService;
23819 govind 46
import com.spice.profitmandi.service.wallet.WalletService;
28102 tejbeer 47
import com.spice.profitmandi.web.model.LoginDetails;
48
import com.spice.profitmandi.web.util.CookiesProcessor;
23819 govind 49
import com.spice.profitmandi.web.util.MVCResponseSender;
29926 amit.gupta 50
import org.apache.commons.io.output.ByteArrayOutputStream;
51
import org.apache.logging.log4j.LogManager;
52
import org.apache.logging.log4j.Logger;
53
import org.springframework.beans.factory.annotation.Autowired;
54
import org.springframework.beans.factory.annotation.Qualifier;
55
import org.springframework.core.io.ByteArrayResource;
56
import org.springframework.http.HttpHeaders;
57
import org.springframework.http.HttpStatus;
58
import org.springframework.http.ResponseEntity;
59
import org.springframework.stereotype.Controller;
60
import org.springframework.transaction.annotation.Transactional;
61
import org.springframework.ui.Model;
62
import org.springframework.web.bind.annotation.*;
23819 govind 63
 
29926 amit.gupta 64
import javax.servlet.http.HttpServletRequest;
65
import java.io.Serializable;
66
import java.time.LocalDate;
67
import java.time.LocalDateTime;
68
import java.util.*;
69
import java.util.stream.Collectors;
70
 
23819 govind 71
@Controller
27071 amit.gupta 72
@Transactional(rollbackFor = Throwable.class)
23819 govind 73
public class PriceDropController {
74
 
31903 amit.gupta 75
    private static final Logger LOGGER = LogManager.getLogger(PriceDropController.class);
34317 amit.gupta 76
    /*private static final List<String> SELLINS = Arrays.asList("Base Payout", "Cash Discount", "Upfront Margin", "Modelwise");
31910 amit.gupta 77
    private static final List<String> SELLOUTS = Arrays.asList("Tertiary Payout", "Hygiene Payout", "Investment Payout", "Category Payout", "Activation Margin", "Special Support", "Sellout Support");
34317 amit.gupta 78
    private static final List<String> ALL_MARGINS = Arrays.asList(SELLINS, SELLOUTS).stream().flatMap(x -> x.stream()).collect(Collectors.toList());*/
31903 amit.gupta 79
    @Autowired
80
    ReporticoService reporticoService;
81
    @Autowired
82
    LineItemImeisRepository lineItemImeisRepository;
83
    @Autowired
84
    PriceCircularService priceCircularService;
85
    @Autowired
86
    private CsService csService;
87
    @Autowired
88
    private UserRepository dtrUserRepository;
89
    @Autowired
90
    private PriceDropRepository priceDropRepository;
91
    @Autowired
92
    private ObjectMapper objectMapper;
93
    @Autowired
94
    private VendorItemPricingRepository vendorItemPricingRepository;
95
    @Autowired
96
    @Qualifier("fofoInventoryService")
97
    private InventoryService inventoryService;
98
    @Autowired
99
    private MVCResponseSender mvcResponseSender;
100
    @Autowired
101
    private PriceDropService priceDropService;
102
    @Autowired
103
    private ItemPricingHistoryRepository itemPricingHistoryRepository;
104
    @Autowired
105
    private WalletService walletService;
106
    @Autowired
107
    private TagListingRepository tagListingRepository;
108
    @Autowired
109
    private TransactionService transactionService;
110
    @Autowired
111
    private PriceDropIMEIRepository priceDropIMEIRepository;
112
    @Autowired
113
    private RoleManager roleManager;
114
    @Autowired
115
    @Qualifier("catalogItemRepository")
116
    private ItemRepository itemRepository;
117
    @Autowired
118
    private SchemeService schemeService;
119
    @Autowired
120
    private Mongo mongoClient;
121
    @Autowired
122
    private CookiesProcessor cookiesProcessor;
123
    @Autowired
124
    private PartnerTypeChangeService partnerTypeChangeService;
125
    @Autowired
126
    private RetailerService retailerService;
127
    @Autowired
128
    private NotificationService notificationService;
129
    @Autowired
130
    private FofoStoreRepository fofoStoreRepository;
23819 govind 131
 
34651 aman.kumar 132
    @Autowired
133
    OrderService orderService;
134
 
35547 amit 135
    @Autowired
136
    private TagListingEventPublisher tagListingEventPublisher;
137
 
31903 amit.gupta 138
    @RequestMapping(value = "/getItemDescription", method = RequestMethod.GET)
139
    public String getItemDescription(HttpServletRequest request, Model model) throws Throwable {
140
        List<PriceDrop> priceDrops = priceDropRepository.selectAllIncomplete();
141
        Set<Integer> catalogIds = priceDrops.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
29926 amit.gupta 142
 
31903 amit.gupta 143
        List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds);
144
        Map<Integer, String> catalogDescription = items.stream().collect(Collectors.toMap(x -> x.getCatalogItemId(),
145
                x -> x.getItemDescriptionNoColor(), (description1, description2) -> description1));
146
        model.addAttribute("priceDrops", priceDrops);
147
        model.addAttribute("catalogDescription", catalogDescription);
148
        return "price-drop";
149
    }
29926 amit.gupta 150
 
34651 aman.kumar 151
    @RequestMapping(value = "/getPricedropByDate", method = RequestMethod.GET)
152
    public String getItemDescriptionByDate(
153
            HttpServletRequest request,
154
            @RequestParam LocalDateTime startDate,
155
            @RequestParam LocalDateTime endDate,
156
            Model model) throws Throwable {
34657 aman.kumar 157
        if (endDate.isAfter(LocalDateTime.now().plusDays(1)) || startDate.isAfter(LocalDateTime.now().plusDays(1))) {
34651 aman.kumar 158
            throw new ProfitMandiBusinessException("startData and end data must if before the today date ", "", "");
159
        }
160
        try {
161
            List<PriceDrop> priceDrops = priceDropRepository.selectAllByDatesBetweenSortByDate(startDate, endDate);
162
 
163
            Set<Integer> catalogIds = priceDrops.stream()
164
                    .map(PriceDrop::getCatalogItemId)
165
                    .collect(Collectors.toSet());
166
 
167
            List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds);
168
            Map<Integer, String> catalogDescription = items.stream()
169
                    .collect(Collectors.toMap(
170
                            Item::getCatalogItemId,
171
                            Item::getItemDescriptionNoColor,
172
                            (description1, description2) -> description1));
173
 
174
            model.addAttribute("priceDrops", priceDrops);
175
            model.addAttribute("catalogDescription", catalogDescription);
176
 
177
            return "price-drop-table";
178
 
179
        } catch (Exception e) {
180
            e.printStackTrace();
181
            return "price-drop";
182
        }
183
    }
184
    @RequestMapping(value = "/pricedropByDate/download", method = RequestMethod.GET)
185
    public ResponseEntity<?> dowloadItems(HttpServletRequest request, @PathVariable(name = "tagId") @RequestParam LocalDateTime startDate, @RequestParam LocalDateTime endDate)
186
            throws Throwable {
187
        List<PriceDrop> priceDrops = priceDropRepository.selectAllByDatesBetweenSortByDate(startDate, endDate);
188
        Set<Integer> catalogIds = priceDrops.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
189
        List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds);
190
        Map<Integer, String> catalogDescription = items.stream().collect(Collectors.toMap(x -> x.getCatalogItemId(),
191
                x -> x.getItemDescriptionNoColor(), (description1, description2) -> description1));
192
 
193
        List<List<?>> rows = new ArrayList<>();
194
        for (PriceDrop priceDrop : priceDrops) {
34720 aman.kumar 195
            rows.add(Arrays.asList(priceDrop.getId(), priceDrop.getCatalogItemId(), catalogDescription.get(priceDrop.getCatalogItemId()), priceDrop.getTp(), priceDrop.getOldDp(), priceDrop.getMop(),
34657 aman.kumar 196
                    priceDrop.getAmount(), priceDrop.getNewDp(), FormattingUtils.formatDate(priceDrop.getAffectedOn()), FormattingUtils.formatDate(priceDrop.getCreatedOn())
34651 aman.kumar 197
            ));
198
 
199
        }
200
        org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
34720 aman.kumar 201
                Arrays.asList("Drop Id", "Catalog Id", "Item Name", "TP", "DP", "Mop", "Price Drop",
34651 aman.kumar 202
                        "New DP", "Affected On", "Created On"),
203
                rows);
204
        ResponseEntity<?> responseEntity = orderService.downloadReportInCsv(baos, rows, "Price Drop ");
205
        return responseEntity;
206
    }
207
 
31903 amit.gupta 208
    @RequestMapping(value = "/getClosedPricedropItemDescription", method = RequestMethod.GET)
209
    public String getClosedPricedropItemDescription(HttpServletRequest request, Model model) throws Throwable {
210
        List<PriceDrop> priceDrops = priceDropRepository.selectAllComplete();
211
        int processOn = 1;
23819 govind 212
 
31903 amit.gupta 213
        List<PriceDrop> completePriceDrops = priceDrops.stream().filter(x -> x.getCompleteTimestamp() != null)
214
                .collect(Collectors.toList());
23945 amit.gupta 215
 
31903 amit.gupta 216
        Set<Integer> catalogIds = completePriceDrops.stream().map(x -> x.getCatalogItemId())
217
                .collect(Collectors.toSet());
218
        List<Item> items = itemRepository.selectAllByCatalogIds(catalogIds);
219
        LOGGER.info("catalogIds" + catalogIds);
23819 govind 220
 
31903 amit.gupta 221
        Map<Integer, String> catalogDescription = items.stream().collect(Collectors.toMap(x -> x.getCatalogItemId(),
222
                x -> x.getItemDescriptionNoColor(), (description1, description2) -> description1));
223
        model.addAttribute("priceDrops", completePriceDrops);
224
        model.addAttribute("processOn", processOn);
225
        model.addAttribute("catalogDescription", catalogDescription);
226
        return "price-drop";
227
    }
23945 amit.gupta 228
 
31903 amit.gupta 229
    @RequestMapping(value = "/item-pricing/{itemId}", method = RequestMethod.GET)
230
    public String getItemPricing(HttpServletRequest request, Model model, @PathVariable int itemId) throws Throwable {
23819 govind 231
 
31903 amit.gupta 232
        TagListing tagListing;
233
        PriceDropModel pm = new PriceDropModel();
234
        try {
235
            tagListing = tagListingRepository.selectByItemId(itemId);
236
            if (tagListing != null) {
237
                pm.setMop(tagListing.getMop());
238
                pm.setDp(tagListing.getSellingPrice());
239
                pm.setMrp(tagListing.getMrp());
240
                List<VendorItemPricing> vips = vendorItemPricingRepository.selectAll(itemId);
241
                if (vips.size() > 0) {
242
                    VendorItemPricing vip = vips.get(0);
243
                    pm.setNlc(vip.getNlc());
244
                    pm.setTp(vip.getTp());
245
                } else {
246
                    throw new ProfitMandiBusinessException("Item Id", itemId, "Vendor item pricing does not exist");
247
                }
248
            }
249
        } catch (Exception e) {
250
            LOGGER.info("Chose item that doesn't exist");
251
        }
252
        model.addAttribute("response1", mvcResponseSender.createResponseString(pm));
253
        return "response";
254
    }
27071 amit.gupta 255
 
31903 amit.gupta 256
    @RequestMapping(value = "/item", method = RequestMethod.GET)
257
    public String getItemPricing(HttpServletRequest request, Model model, @RequestParam String query,
258
                                 @RequestParam boolean anyColor) throws Throwable {
259
        String query1 = query.toLowerCase();
24083 amit.gupta 260
 
31903 amit.gupta 261
        List<ItemDescriptionModel> partnersItemDescription = inventoryService
262
                .getAllPartnerItemStringDescription(anyColor).parallelStream()
263
                .filter(x -> x.getItemDescription().toLowerCase().matches(".*?" + query1 + ".*?"))
264
                .collect(Collectors.toList());
265
        LOGGER.info("partnersItemDescription" + partnersItemDescription);
23819 govind 266
 
31903 amit.gupta 267
        model.addAttribute("response1", mvcResponseSender.createResponseString(partnersItemDescription));
268
        return "response";
269
    }
23945 amit.gupta 270
 
31903 amit.gupta 271
    @RequestMapping(value = "/price-drop/imes/download")
272
    public ResponseEntity<ByteArrayResource> downloadPriceDropImeis(HttpServletRequest request,
273
                                                                    @RequestParam LocalDateTime affectedDate, @RequestParam int itemId) throws Exception {
274
        Item item = itemRepository.selectById(itemId);
33198 amit.gupta 275
        ByteArrayOutputStream baos = getByteArrayOutputStream(affectedDate, item.getCatalogItemId(), null, Optional.empty());
31903 amit.gupta 276
        final HttpHeaders headers = new HttpHeaders();
277
        headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
278
        headers.set("Content-disposition", "inline; filename=\"imei-" + item.getItemDescriptionNoColor() + ".csv\"");
279
        byte[] byteArray = baos.toByteArray();
280
        headers.setContentLength(byteArray.length);
281
        return new ResponseEntity<ByteArrayResource>(new ByteArrayResource(byteArray), headers, HttpStatus.OK);
282
    }
23819 govind 283
 
31903 amit.gupta 284
    @RequestMapping(value = "/price-drop/addPayout", method = RequestMethod.POST)
285
    public String updatePriceDrop(HttpServletRequest request, @RequestBody PriceDropProcessModel priceDropProcessModel,
286
                                  Model model) throws Exception {
287
        boolean response = false;
288
        PriceDrop priceDrop = priceDropRepository.selectById(priceDropProcessModel.getPriceDropId());
289
        if (priceDrop.getProcessTimestamp() == null) {
290
            priceDrop.setPartnerPayout(priceDropProcessModel.getPartnerPayout());
291
            priceDrop.setPriceDropIn(priceDropProcessModel.getPriceDropIn());
292
            // priceDrop.setProcessTimestamp(LocalDateTime.now());
293
            priceDropRepository.persist(priceDrop);
294
            response = true;
295
        }
296
        model.addAttribute("response1", mvcResponseSender.createResponseString(response));
297
        return "response";
298
    }
24083 amit.gupta 299
 
31903 amit.gupta 300
    @RequestMapping(value = "/priceDropImeis/{priceDropId}", method = RequestMethod.GET)
301
    public String priceDropStatus(HttpServletRequest request, @PathVariable int priceDropId, Model model)
302
            throws Exception {
29951 amit.gupta 303
 
31903 amit.gupta 304
        PriceDropImeisModel priceDropImeisModel = new PriceDropImeisModel();
23819 govind 305
 
31903 amit.gupta 306
        // This call is used to persit imeis to pricedrop imeis in case its not there.
307
        // This should be called while creating price drop.
308
        // priceDropService.priceDropStatus(priceDropId);
24083 amit.gupta 309
 
31903 amit.gupta 310
        List<String> pendingImeis = new ArrayList<>();
311
        List<String> approvedImeis = new ArrayList<>();
312
        List<String> rejectedImeis = new ArrayList<>();
313
        List<String> holdImeis = new ArrayList<>();
314
        List<PriceDropIMEI> priceDropImeis = priceDropIMEIRepository.selectByPriceDropId(priceDropId);
315
        for (PriceDropIMEI priceDropIMEI : priceDropImeis) {
316
            if (priceDropIMEI.getStatus().equals(PriceDropImeiStatus.PENDING)) {
317
                pendingImeis.add(priceDropIMEI.getImei());
318
            } else if (priceDropIMEI.getStatus().equals(PriceDropImeiStatus.APPROVED)) {
319
                approvedImeis.add(priceDropIMEI.getImei());
320
            }
321
            if (priceDropIMEI.getStatus().equals(PriceDropImeiStatus.REJECTED)) {
322
                rejectedImeis.add(priceDropIMEI.getImei());
323
            } else if (priceDropIMEI.getStatus().equals(PriceDropImeiStatus.HOLD)) {
324
                holdImeis.add(priceDropIMEI.getImei());
24083 amit.gupta 325
 
31903 amit.gupta 326
            }
327
        }
328
        LOGGER.info("pendingImeis" + pendingImeis);
329
        LOGGER.info("approvedImeis" + approvedImeis);
330
        LOGGER.info("rejectedImeis" + rejectedImeis);
331
        LOGGER.info("priceDropImeis" + priceDropImeis);
23945 amit.gupta 332
 
31903 amit.gupta 333
        priceDropImeisModel.setPendingImeis(pendingImeis);
334
        priceDropImeisModel.setPriceDropId(priceDropId);
335
        priceDropImeisModel.setApprovedImeis(approvedImeis);
336
        priceDropImeisModel.setHoldImeis(holdImeis);
337
        priceDropImeisModel.setRejectedImeis(rejectedImeis);
338
        model.addAttribute("response1", mvcResponseSender.createResponseString(priceDropImeisModel));
339
        return "response";
340
    }
28102 tejbeer 341
 
31903 amit.gupta 342
    @RequestMapping(value = "/processPriceDrop", method = RequestMethod.POST)
343
    public String processPriceDrop(HttpServletRequest request, @RequestBody PriceDropProcessModel priceDropProcessModel,
344
                                   Model model) throws Exception {
345
        PriceDrop priceDrop = priceDropRepository.selectById(priceDropProcessModel.getPriceDropId());
346
        boolean response = false;
347
        if (priceDrop.getPartnerPayout() == 0) {
348
            priceDrop.setPartnerPayout(priceDropProcessModel.getPartnerPayout());
349
        }
350
        priceDrop.setProcessTimestamp(LocalDateTime.now());
36978 amit 351
        // Generate IMEI rows if missing — a manually-flagged hike has none yet (its priceDropStatus
352
        // ran at creation while deduct_on_hike was false). Idempotent: no-op once rows exist (drops).
353
        priceDropService.priceDropStatus(priceDrop.getId());
31903 amit.gupta 354
        priceDropService.processPriceDrop(priceDrop.getId(), priceDropProcessModel.isActivatedOnly());
355
        response = true;
356
        model.addAttribute("response1", mvcResponseSender.createResponseString(response));
357
        return "response";
358
    }
28102 tejbeer 359
 
36983 amit 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.
36985 amit 362
    @RequestMapping(value = "/priceHike/generateImeis/{priceDropId}", method = RequestMethod.GET)
36983 amit 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
 
31903 amit.gupta 381
    @RequestMapping(value = "/priceDrop", method = RequestMethod.POST)
382
    public String addPriceDrop(HttpServletRequest request, Model model, @RequestBody PriceDropModel priceDropModel)
383
            throws Exception {
384
        boolean response = false;
385
        priceDropModel.setAllColors(true);
386
        if (this.validatePriceDrop(priceDropModel)) {
387
            TagListing tagListing = tagListingRepository.selectByItemId(priceDropModel.getItemId());
388
            float oldDp = tagListing.getSellingPrice();
389
            float oldMop = tagListing.getMop();
390
            float oldTp = 0;
391
            float newDp = priceDropModel.getDp();
28102 tejbeer 392
 
31903 amit.gupta 393
            if (newDp != oldDp) {
394
                List<Item> allItems = null;
395
                Item currentItem = itemRepository.selectById(priceDropModel.getItemId());
396
                if (priceDropModel.isAllColors()) {
397
                    allItems = itemRepository.selectAllByCatalogItemId(currentItem.getCatalogItemId());
28102 tejbeer 398
 
31903 amit.gupta 399
                } else {
400
                    allItems = Arrays.asList(currentItem);
401
                }
402
                for (Item item : allItems) {
403
                    TagListing itemTagListing = tagListingRepository.selectByItemId(item.getId());
404
                    if (itemTagListing == null)
405
                        continue;
406
                    itemTagListing.setSellingPrice(newDp);
407
                    itemTagListing.setMop(priceDropModel.getMop());
408
                    List<VendorItemPricing> vipList = vendorItemPricingRepository.selectAll(item.getId());
409
                    for (VendorItemPricing vip : vipList) {
410
                        oldTp = vip.getNlc();
411
                        vip.setDp(newDp);
412
                        vip.setMop(priceDropModel.getMop());
413
                        //Lets not update NLC/TP as it has to be managed by Category Tea,
414
                        //vip.setNlc(priceDropModel.getTp());
415
                        //vip.setTp(priceDropModel.getTp());
416
                        vendorItemPricingRepository.persist(vip);
417
                    }
418
                    transactionService.updatePriceDrop(item.getId(), newDp);
419
                }
29926 amit.gupta 420
 
31903 amit.gupta 421
                // Add to itemPricing history
422
                ItemPricingHistory iph = new ItemPricingHistory();
423
                iph.setCatalogId(currentItem.getCatalogItemId());
424
                iph.setTp(priceDropModel.getTp());
425
                iph.setDp(priceDropModel.getDp());
426
                iph.setMop(priceDropModel.getMop());
427
                // TODO: changedBy
428
                iph.setChangedBy("me");
429
                iph.setCreateTimestamp(LocalDateTime.now());
430
                itemPricingHistoryRepository.persist(iph);
28136 tejbeer 431
 
31903 amit.gupta 432
                PriceDrop priceDrop = new PriceDrop();
433
                priceDrop.setAffectedOn(priceDropModel.getAffectedDate());
434
                priceDrop.setTp(oldTp);
435
                priceDrop.setNlc(oldTp);
436
                priceDrop.setMop(oldMop);
437
                priceDrop.setOldDp(oldDp);
438
                priceDrop.setAmount(oldDp - newDp);
439
                priceDrop.setNewDp(newDp);
440
                priceDrop.setCreatedOn(LocalDateTime.now());
441
                priceDrop.setCatalogItemId(currentItem.getCatalogItemId());
442
                priceDropRepository.persist(priceDrop);
443
                priceDropService.priceDropStatus(priceDrop.getId());
444
                response = true;
30471 amit.gupta 445
 
31903 amit.gupta 446
                this.sendPriceChangeNotification(priceDrop);
35547 amit 447
 
448
                // Publish event for real-time Solr update
449
                try {
450
                    tagListingEventPublisher.publishPriceChange(0, currentItem.getCatalogItemId());
451
                } catch (Exception e) {
452
                    LOGGER.error("Failed to publish price change event for catalogId: {}", currentItem.getCatalogItemId(), e);
453
                }
31903 amit.gupta 454
            } else {
455
                throw new ProfitMandiBusinessException("Price Drop", priceDropModel.getPd(),
456
                        "Price Drop Should be greater than 0");
457
            }
458
        }
459
        model.addAttribute("response1", mvcResponseSender.createResponseString(response));
460
        return "response";
461
    }
29654 tejbeer 462
 
31903 amit.gupta 463
    private void sendPriceChangeNotification(PriceDrop priceDrop) throws ProfitMandiBusinessException {
464
        List<Item> items = itemRepository.selectAllByCatalogItemId(priceDrop.getCatalogItemId());
465
        String title = "Price has been %s for %s";
24083 amit.gupta 466
 
28568 amit.gupta 467
 
31903 amit.gupta 468
        SendNotificationModel sendNotificationModel = new SendNotificationModel();
469
        sendNotificationModel.setCampaignName("pricechange");
470
        sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
471
        sendNotificationModel.setTitle("");
472
        StringBuffer sb = new StringBuffer();
473
        String message = null;
474
        if (priceDrop.getDropAmount() > 0) {
475
            title = String.format(title, "dropped", items.get(0).getItemDescriptionNoColor());
476
            message = String.format("Price has been dropped from Rs.%s. Old DP - Rs.%s, New DP - Rs.%s", FormattingUtils.formatDecimal(priceDrop.getDropAmount()),
477
                    FormattingUtils.formatDecimal(priceDrop.getOldDp()), FormattingUtils.formatDecimal(priceDrop.getNewDp()));
478
        } else {
479
            title = String.format(title, "increased", items.get(0).getItemDescriptionNoColor());
480
            message = String.format("Price has been increased from Rs.%s. Old DP - Rs.%s, New DP - Rs.%s", FormattingUtils.formatDecimal(-priceDrop.getDropAmount()),
481
                    FormattingUtils.formatDecimal(priceDrop.getOldDp()), FormattingUtils.formatDecimal(priceDrop.getNewDp()));
482
        }
483
        sendNotificationModel.setTitle(title);
484
        sendNotificationModel.setMessage(message);
485
        sendNotificationModel.setMessageType(MessageType.pricechange);
486
        notificationService.sendNotificationToAll(sendNotificationModel);
487
    }
28568 amit.gupta 488
 
31903 amit.gupta 489
    @RequestMapping(value = "/downloadtotalPriceDropIMEI/{priceDropId}", method = RequestMethod.GET)
490
    public ResponseEntity<?> downloadTotalPriceDropIMEI(HttpServletRequest request, @PathVariable int priceDropId,
491
                                                        Model model) throws ProfitMandiBusinessException, Exception {
28568 amit.gupta 492
 
31903 amit.gupta 493
        PriceDrop priceDrop = priceDropRepository.selectById(priceDropId);
494
        Map<String, PriceDropIMEI> priceDropIMEIsMap = priceDropIMEIRepository.selectByPriceDropId(priceDropId).stream()
495
                .collect(Collectors.toMap(x -> x.getImei(), x -> x));
496
        LOGGER.info("PriceDropImeis {}, priceDropId {}", priceDropIMEIsMap, priceDropId);
497
        Item item = itemRepository.selectAllByCatalogItemId(priceDrop.getCatalogItemId()).get(0);
498
        final HttpHeaders headers = new HttpHeaders();
499
        headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
500
        headers.set("Content-disposition",
501
                "inline; filename=pricedrop-" + item.getItemDescriptionNoColor().replaceAll("\\s?,\\s?", " ") + "-"
502
                        + FormattingUtils.formatDate(priceDrop.getAffectedOn()) + ".csv");
503
        ByteArrayOutputStream baos = null;
504
        if (priceDropIMEIsMap.size() == 0) {
505
            priceDropService.priceDropStatus(priceDrop.getId());
506
            baos = FileUtil.getCSVByteStream(Arrays.asList("IMEI Number", "Store Name", "Store Code", "Item ID", "Brand",
507
                    "Model Name", "Model Number", "Color", "Status", "Rejection Reason", "Last Scanned", "Vendor Name",
508
                    "Grn On", "Activation Timestamp", "Activation Added On"), new ArrayList<>());
509
        } else {
28568 amit.gupta 510
 
31903 amit.gupta 511
            LOGGER.info("In else block");
33198 amit.gupta 512
            baos = getByteArrayOutputStream(priceDrop.getAffectedOn(), priceDrop.getCatalogItemId(), priceDropIMEIsMap, Optional.of(priceDrop.getCreatedOn()));
31903 amit.gupta 513
        }
514
        byte[] byteArray = baos.toByteArray();
515
        headers.setContentLength(byteArray.length);
516
        return new ResponseEntity<ByteArrayResource>(new ByteArrayResource(byteArray), headers, HttpStatus.OK);
24083 amit.gupta 517
 
31903 amit.gupta 518
    }
24083 amit.gupta 519
 
31903 amit.gupta 520
    @RequestMapping(value = "/updatePriceDropImeis", method = RequestMethod.POST)
33470 amit.gupta 521
    public String updatePriceDropImeis(@RequestBody PriceDropImeisModel priceDropImeisModel,
522
                                       Model model) throws Exception {
32012 amit.gupta 523
        final PriceDropImeiStatus status;
28102 tejbeer 524
 
31903 amit.gupta 525
        switch (priceDropImeisModel.getUpdatedStatus()) {
526
            case "approved": {
527
                status = PriceDropImeiStatus.APPROVED;
528
                break;
529
            }
32012 amit.gupta 530
            case "pending": {
531
                status = PriceDropImeiStatus.PENDING;
31903 amit.gupta 532
                break;
533
            }
534
            case "rejected": {
535
                status = PriceDropImeiStatus.REJECTED;
536
                break;
537
            }
32012 amit.gupta 538
            case "hold": {
539
                status = PriceDropImeiStatus.HOLD;
540
                break;
541
            }
542
            default:
543
                throw new IllegalStateException("Unexpected value: " + priceDropImeisModel.getUpdatedStatus());
31903 amit.gupta 544
        }
24168 amit.gupta 545
 
31903 amit.gupta 546
        if (PriceDropImeiStatus.PENDING.equals(status)) {
32012 amit.gupta 547
            List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository.selectByStatuses(Arrays.asList(PriceDropImeiStatus.REJECTED, PriceDropImeiStatus.HOLD),
31903 amit.gupta 548
                    priceDropImeisModel.getPriceDropId());
549
            LOGGER.info("hello" + priceDropIMEIs);
32012 amit.gupta 550
            for (PriceDropIMEI priceDropIMEI : priceDropIMEIs) {
551
                if (priceDropIMEI.getStatus().equals(status) || !priceDropImeisModel.getUpdatedImeis().contains(priceDropIMEI.getImei())) {
552
                    continue;
31903 amit.gupta 553
                }
32012 amit.gupta 554
                priceDropIMEI.setStatus(PriceDropImeiStatus.PENDING);
31903 amit.gupta 555
            }
556
            model.addAttribute("response1", mvcResponseSender.createResponseString(true));
557
            return "response";
558
        }
23951 amit.gupta 559
 
32012 amit.gupta 560
        if (status.equals(PriceDropImeiStatus.APPROVED)) {
561
            priceDropService.processPriceDrop(priceDropImeisModel.getPriceDropId(),
562
                    priceDropImeisModel.getUpdatedImeis());
563
        }
564
 
31903 amit.gupta 565
        List<PriceDropIMEI> priceDropIMEIs = priceDropIMEIRepository
566
                .selectByPriceDropId(priceDropImeisModel.getPriceDropId());
567
        List<PriceDropIMEI> priceDropIMEIsToProcess = priceDropIMEIs.stream()
568
                .filter(x -> priceDropImeisModel.getUpdatedImeis().contains(x.getImei()))
32012 amit.gupta 569
                .filter(x -> !x.getStatus().equals(status)).collect(Collectors.toList());
31903 amit.gupta 570
        for (PriceDropIMEI priceDropImei : priceDropIMEIsToProcess) {
571
            if (status.equals(PriceDropImeiStatus.REJECTED)
572
                    && priceDropImei.getStatus().equals(PriceDropImeiStatus.PENDING)) {
573
                priceDropImei.setStatus(PriceDropImeiStatus.REJECTED);
574
                priceDropImei.setRejectionReason(priceDropImeisModel.getRejectionReason());
575
                priceDropImei.setRejectTimestamp(LocalDateTime.now());
576
            } else if (status.equals(PriceDropImeiStatus.HOLD)) {
577
                if (priceDropImei.getStatus().equals(PriceDropImeiStatus.PENDING)) {
578
                    priceDropImei.setStatus(PriceDropImeiStatus.HOLD);
579
                } else {
580
                    throw new ProfitMandiBusinessException("INVALID STATUS", status, "only  allowed For PENDING IMEIs");
581
                }
28568 amit.gupta 582
 
31903 amit.gupta 583
            }
28568 amit.gupta 584
 
31903 amit.gupta 585
        }
28568 amit.gupta 586
 
31903 amit.gupta 587
        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
588
        return "response";
24083 amit.gupta 589
 
31903 amit.gupta 590
    }
24083 amit.gupta 591
 
31903 amit.gupta 592
    private ByteArrayOutputStream getByteArrayOutputStream(LocalDateTime affectedOn, Integer catalogItemId,
33198 amit.gupta 593
                                                           Map<String, PriceDropIMEI> priceDropImeis, Optional<LocalDateTime> createdOn) throws Exception {
594
 
31903 amit.gupta 595
        List<ImeiDropSummaryModel> imeiDropSummaryModelList = priceDropService
33198 amit.gupta 596
                .getAllSerialNumbersByAffectedDate(affectedOn, catalogItemId, createdOn);
31903 amit.gupta 597
        List<List<?>> rows = new ArrayList<>();
598
        for (ImeiDropSummaryModel imeiDropSummaryModel : imeiDropSummaryModelList) {
599
            if (priceDropImeis == null) {
600
                rows.add(this.getRow(imeiDropSummaryModel, null));
601
            } else if (priceDropImeis.get(imeiDropSummaryModel.getSerialNumber()) != null) {
602
                rows.add(this.getRow(imeiDropSummaryModel, priceDropImeis.get(imeiDropSummaryModel.getSerialNumber())));
603
            }
604
        }
605
        return FileUtil.getCSVByteStream(Arrays.asList("IMEI Number", "Store Name", "Store Code", "Item ID", "Brand",
606
                "Model Name", "Model Number", "Color", "Status", "Rejection Reason", "Last Scanned", "Vendor Name",
607
                "Grn On", "Activation Timestamp", "Activation Added On"), rows);
608
    }
24083 amit.gupta 609
 
31903 amit.gupta 610
    private List<? extends Serializable> getRow(ImeiDropSummaryModel imeiDropSummaryModel,
611
                                                PriceDropIMEI priceDropIMEI) {
612
        List<Serializable> row = new ArrayList<>();
613
        row.add(imeiDropSummaryModel.getSerialNumber());
614
        row.add(imeiDropSummaryModel.getStoreName());
615
        row.add(imeiDropSummaryModel.getPartnerCode());
616
        row.add(imeiDropSummaryModel.getItemId());
617
        row.add(imeiDropSummaryModel.getBrand());
618
        row.add(imeiDropSummaryModel.getModelName());
619
        row.add(imeiDropSummaryModel.getModelNumber());
620
        row.add(imeiDropSummaryModel.getColor());
621
        if (priceDropIMEI != null) {
622
            row.add(priceDropIMEI.getStatus());
623
            row.add(priceDropIMEI.getRejectionReason());
624
        } else {
625
            row.add(PriceDropImeiStatus.PENDING);
626
            row.add("");
627
        }
628
        row.add(FormattingUtils.formatReporitcoDate(imeiDropSummaryModel.getLastScanned()));
629
        row.add(imeiDropSummaryModel.getVendorName());
630
        row.add(FormattingUtils.formatReporitcoDate(imeiDropSummaryModel.getGrnOn()));
631
        row.add(imeiDropSummaryModel.getActivationTimestamp());
632
        row.add(imeiDropSummaryModel.getActivationAddedOn());
633
        return row;
634
    }
23819 govind 635
 
31903 amit.gupta 636
    private boolean validatePriceDrop(PriceDropModel priceDropModel) throws ProfitMandiBusinessException {
637
        if (priceDropModel.getMop() > 0 && priceDropModel.getDp() > 0 && priceDropModel.getTp() > 0) {
638
            return true;
639
        }
640
        return false;
641
    }
23945 amit.gupta 642
 
32844 shampa 643
    @Autowired
644
    BrandsService brandsService;
33470 amit.gupta 645
 
31903 amit.gupta 646
    @RequestMapping(value = "/priceCircular")
647
    public String priceCircular(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
648
        int fofoId = Utils.SYSTEM_PARTNER_ID;
32844 shampa 649
        List<String> brands = brandsService.getBrandsToDisplay(3).stream().map(x -> x.getName()).collect(Collectors.toList());
31903 amit.gupta 650
        model.addAttribute("brands", brands);
651
        model.addAttribute("isAdmin", true);
652
        model.addAttribute("date", FormattingUtils.format(LocalDateTime.now()));
28102 tejbeer 653
 
31903 amit.gupta 654
        return "partner-price-circular";
655
    }
28102 tejbeer 656
 
31903 amit.gupta 657
    @RequestMapping(value = "/partnerPriceCircular")
658
    public String partnerPriceCircular(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
659
        int fofoId = Utils.SYSTEM_PARTNER_ID;
32844 shampa 660
        Set<String> brands = brandsService.getBrandsToDisplay(3).stream().map(x -> x.getName()).collect(Collectors.toSet());
661
        brands.addAll(brandsService.getBrandsToDisplay(6).stream().map(x -> (String) x.getName())
31903 amit.gupta 662
                .collect(Collectors.toSet()));
663
        model.addAttribute("brands", brands);
664
        model.addAttribute("isAdmin", false);
28102 tejbeer 665
 
31903 amit.gupta 666
        return "partner-price-circular";
667
    }
28102 tejbeer 668
 
31903 amit.gupta 669
    @RequestMapping(value = "/priceCircularByBrand")
670
    public String priceCircularByBrand(HttpServletRequest request, @RequestParam String brand, Model model, @RequestParam(defaultValue = "0", required = false) int fofoId)
671
            throws ProfitMandiBusinessException {
672
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
673
        if (fofoId > 0 && roleManager.isAdmin(loginDetails.getRoleIds())) {
674
        } else {
675
            fofoId = loginDetails.getFofoId();
676
        }
32905 shampa 677
        FofoStore fs = fofoStoreRepository.selectByRetailerId(fofoId);
678
 
31903 amit.gupta 679
        //.minusDays(2)
34317 amit.gupta 680
        PriceCircularModel priceCircularModel = priceCircularService.getPriceCircularByOffer(fofoId, brand, LocalDate.now());
35395 amit 681
        //Get slowmong/missign category for that brand
682
        //get stock with us missing as well as with partner missing
683
        //filter that stock
34317 amit.gupta 684
        return this.getPriceCircularView(priceCircularModel, model, fs.getCode());
32331 amit.gupta 685
    }
686
 
34317 amit.gupta 687
    public String getPriceCircularView(PriceCircularModel priceCircularModel, Model model, String partnerCode) {
688
        List<String> allMarginsSet = new ArrayList<>(this.getSchemeHeaders(priceCircularModel));
689
        List<String> sellins = SchemeType.IN_TYPES.stream().map(x -> x.getValue()).filter(x -> allMarginsSet.contains(x)).collect(Collectors.toList());
690
        List<String> sellouts = SchemeType.OUT_TYPES.stream().map(x -> x.getValue()).filter(x -> allMarginsSet.contains(x)).collect(Collectors.toList());
691
        List<String> allMargins = new ArrayList<>();
692
        allMargins.addAll(sellins);
693
        allMargins.addAll(sellouts);
31903 amit.gupta 694
        LOGGER.info("Sellins - {}", sellins);
695
        LOGGER.info("Sellouts - {}", sellouts);
34317 amit.gupta 696
        model.addAttribute("priceCircularItemModels", priceCircularModel.getPriceCircularItemModelNews());
31903 amit.gupta 697
        model.addAttribute("allMargins", allMargins);
698
        model.addAttribute("sellins", sellins);
699
        model.addAttribute("sellouts", sellouts);
34317 amit.gupta 700
        model.addAttribute("offers", priceCircularModel.getOffers());
701
        model.addAttribute("upgradeOffer", priceCircularModel.isUpgradeOffer());
31903 amit.gupta 702
        model.addAttribute("mvcResponseSender", mvcResponseSender);
32905 shampa 703
        model.addAttribute("partnerCode", partnerCode);
32331 amit.gupta 704
        return "price-circular-table";
31903 amit.gupta 705
    }
29951 amit.gupta 706
 
31903 amit.gupta 707
    private Set<String> getSchemeHeaders(PriceCircularModel priceCircular) {
708
        Set<String> schemeHeaders = new HashSet<>();
709
        priceCircular.getPriceCircularItemModelNews().stream().forEach(priceCircularItemModelNew -> {
710
            Map<String, AmountModel> headerMap = new HashMap<>();
711
            priceCircularItemModelNew.setHeaderSchemeModelsMap(headerMap);
712
            priceCircularItemModelNew.getSchemeSummaryModels().stream().forEach(schemeSummaryModel -> {
713
                if (schemeSummaryModel == null) return;
34317 amit.gupta 714
                schemeSummaryModel.setHeader(schemeSummaryModel.getSchemeType().getValue());
31903 amit.gupta 715
                if (!headerMap.containsKey(schemeSummaryModel.getHeader())) {
716
                    headerMap.put(schemeSummaryModel.getHeader(), new AmountModel(schemeSummaryModel.getAmount(), schemeSummaryModel.getAmountType()));
717
                } else {
718
                    AmountModel model = headerMap.get(schemeSummaryModel.getHeader());
719
                    model.setAmount(model.getAmount() + schemeSummaryModel.getAmount());
720
                }
721
                schemeHeaders.add(schemeSummaryModel.getHeader());
722
            });
723
        });
28102 tejbeer 724
 
31903 amit.gupta 725
        LOGGER.info("Scheme headers - {}", schemeHeaders);
726
        return schemeHeaders;
727
    }
30250 amit.gupta 728
 
31903 amit.gupta 729
    //private static final List<String> SELLINS = Arrays.asList("Base Payout", "Cash Discount", "Upfront Margin");
730
    //private static final List<String> SELLOUTS = Arrays.asList("Tertiary Payout", "Hygiene Payout", "Investment Payout", "Category Payout", "Activation Margin", "Special Support");
30471 amit.gupta 731
 
30562 amit.gupta 732
 
31903 amit.gupta 733
    @RequestMapping(value = "/downloadNlcByBrand")
734
    public ResponseEntity<ByteArrayResource> downloadNlcByBrand(HttpServletRequest request,
735
                                                                @RequestParam String brand, Model model, @RequestParam(defaultValue = "0", required = false) int fofoId) throws Exception {
736
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
737
        if (fofoId > 0 && roleManager.isAdmin(loginDetails.getRoleIds())) {
738
        } else {
739
            fofoId = loginDetails.getFofoId();
740
        }
741
        PriceCircularModel priceCircular = priceCircularService.getPriceCircularByOffer(fofoId, brand, LocalDate.now());
742
        /*List<Integer> catalogIds = priceCircular.getPriceCircularItemModelNews().stream().limit(10).map(x->x.getCatalogId()).collect(Collectors.toList());
743
        priceCircular = priceCircularService.getPriceCircularByOffer(fofoId, catalogIds, LocalDate.now());*/
744
        ByteArrayOutputStream baos = getNlcBaos(brand, priceCircular);
745
        final HttpHeaders headers = new HttpHeaders();
746
        headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
747
        headers.set("Content-disposition", "inline; filename=\"" + brand + ".csv\"");
748
        byte[] byteArray = baos.toByteArray();
749
        headers.setContentLength(byteArray.length);
750
        return new ResponseEntity<>(new ByteArrayResource(byteArray), headers, HttpStatus.OK);
751
    }
30471 amit.gupta 752
 
31903 amit.gupta 753
    private ByteArrayOutputStream getNlcBaos(String brand, PriceCircularModel priceCircular) throws Exception {
754
        List<List<?>> rows = new ArrayList<>();
755
        for (PriceCircularItemModelNew priceCircularItemModel : priceCircular.getPriceCircularItemModelNews()) {
756
            List<Serializable> row = new ArrayList<>();
757
            row.add(priceCircularItemModel.getCatalogId());
758
            row.add(brand);
759
            row.add(priceCircularItemModel.getCatalogSummaryModel().getModelName());
760
            row.add(priceCircularItemModel.getCatalogSummaryModel().getModelNumber());
761
            //TODO: fix nlc
762
            //row.add(priceCircularItemModel.getNetPrice());
763
            rows.add(row);
764
        }
765
        return FileUtil.getCSVByteStream(Arrays.asList("Model Id", "Brand", "Model Name", "Model Number", "Partner Landing"), rows);
766
    }
30471 amit.gupta 767
 
31903 amit.gupta 768
    @RequestMapping(value = "/selectPriceDropStatus", method = RequestMethod.GET)
769
    public String selectPriceDropStatus(HttpServletRequest request,
770
                                        @RequestParam(name = "selectedStatus", required = true, defaultValue = "") String selectedStatus,
771
                                        Model model) throws Exception {
30250 amit.gupta 772
 
31903 amit.gupta 773
        model.addAttribute("selectedStatus", selectedStatus);
774
        return "pricedrop-status-change";
775
    }
30250 amit.gupta 776
 
23819 govind 777
}