Subversion Repositories SmartDukaan

Rev

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