| Line 313... |
Line 313... |
| 313 |
}
|
313 |
}
|
| 314 |
model.addAttribute("response", mvcResponseSender.createResponseString(response));
|
314 |
model.addAttribute("response", mvcResponseSender.createResponseString(response));
|
| 315 |
return "response";
|
315 |
return "response";
|
| 316 |
}
|
316 |
}
|
| 317 |
|
317 |
|
| 318 |
@RequestMapping(value = "/updateMop", method = RequestMethod.POST)
|
- |
|
| 319 |
public String addMop(HttpServletRequest request, Model model, @RequestBody PriceDropModel priceDropModel)
|
- |
|
| 320 |
throws Exception {
|
- |
|
| 321 |
boolean response = false;
|
- |
|
| 322 |
priceDropModel.setAllColors(true);
|
- |
|
| 323 |
TagListing tagListing = tagListingRepository.selectByItemId(priceDropModel.getItemId());
|
- |
|
| 324 |
float newDp = tagListing.getSellingPrice() - priceDropModel.getPd();
|
- |
|
| 325 |
List<Item> allItems = null;
|
- |
|
| 326 |
Item currentItem = itemRepository.selectById(priceDropModel.getItemId());
|
- |
|
| 327 |
if (priceDropModel.isAllColors()) {
|
- |
|
| 328 |
allItems = itemRepository.selectAllByCatalogItemId(currentItem.getCatalogItemId());
|
- |
|
| 329 |
|
- |
|
| 330 |
} else {
|
- |
|
| 331 |
allItems = Arrays.asList(currentItem);
|
- |
|
| 332 |
}
|
- |
|
| 333 |
for (Item item : allItems) {
|
- |
|
| 334 |
TagListing itemTagListing = tagListingRepository.selectByItemId(item.getId());
|
- |
|
| 335 |
if (itemTagListing == null)
|
- |
|
| 336 |
continue;
|
- |
|
| 337 |
itemTagListing.setMop(priceDropModel.getMop());
|
- |
|
| 338 |
tagListingRepository.persist(tagListing);
|
- |
|
| 339 |
List<VendorItemPricing> vipList = vendorItemPricingRepository.selectAll(item.getId());
|
- |
|
| 340 |
for (VendorItemPricing vip : vipList) {
|
- |
|
| 341 |
vip.setDp(newDp);
|
- |
|
| 342 |
vip.setMop(priceDropModel.getMop());
|
- |
|
| 343 |
vendorItemPricingRepository.persist(vip);
|
- |
|
| 344 |
}
|
- |
|
| 345 |
transactionService.updatePriceDrop(item.getId(), newDp);
|
- |
|
| 346 |
}
|
- |
|
| 347 |
PriceDrop priceDrop = new PriceDrop();
|
- |
|
| 348 |
priceDrop.setAffectedOn(LocalDateTime.of(LocalDate.now(), LocalTime.MIDNIGHT));
|
- |
|
| 349 |
priceDrop.setOldDp(tagListing.getSellingPrice());
|
- |
|
| 350 |
priceDrop.setAmount(priceDropModel.getPd());
|
- |
|
| 351 |
priceDrop.setNewDp(tagListing.getSellingPrice());
|
- |
|
| 352 |
priceDrop.setNlc(priceDropModel.getNlc());
|
- |
|
| 353 |
priceDrop.setTp(priceDropModel.getTp());
|
- |
|
| 354 |
priceDrop.setCreatedOn(LocalDateTime.now());
|
- |
|
| 355 |
priceDrop.setCatalogItemId(currentItem.getCatalogItemId());
|
- |
|
| 356 |
priceDrop.setProcessTimestamp(LocalDateTime.now());
|
- |
|
| 357 |
priceDrop.setPartnerPayout(0);
|
- |
|
| 358 |
priceDrop.setPriceDropIn(0);
|
- |
|
| 359 |
priceDropRepository.persist(priceDrop);
|
- |
|
| 360 |
response = true;
|
- |
|
| 361 |
model.addAttribute("response", mvcResponseSender.createResponseString(response));
|
- |
|
| 362 |
return "response";
|
- |
|
| 363 |
}
|
- |
|
| 364 |
|
- |
|
| 365 |
@RequestMapping(value = "/priceDrop", method = RequestMethod.POST)
|
318 |
@RequestMapping(value = "/priceDrop", method = RequestMethod.POST)
|
| 366 |
public String addPriceDrop(HttpServletRequest request, Model model, @RequestBody PriceDropModel priceDropModel)
|
319 |
public String addPriceDrop(HttpServletRequest request, Model model, @RequestBody PriceDropModel priceDropModel)
|
| 367 |
throws Exception {
|
320 |
throws Exception {
|
| 368 |
boolean response = false;
|
321 |
boolean response = false;
|
| 369 |
priceDropModel.setAllColors(true);
|
322 |
priceDropModel.setAllColors(true);
|