| Line 265... |
Line 265... |
| 265 |
|
265 |
|
| 266 |
public static final String APP_DOWNLOAD_BILLING_TEMPLATE_ID = "1507163542403945677";
|
266 |
public static final String APP_DOWNLOAD_BILLING_TEMPLATE_ID = "1507163542403945677";
|
| 267 |
|
267 |
|
| 268 |
public static final String APP_DOWNLOAD_BILLING_OFFER = "Dear Customer, Thank you for purchasing from SmartDukaan pls click %s to download our app to see you invoice and special offers. SmartDukaan";
|
268 |
public static final String APP_DOWNLOAD_BILLING_OFFER = "Dear Customer, Thank you for purchasing from SmartDukaan pls click %s to download our app to see you invoice and special offers. SmartDukaan";
|
| 269 |
|
269 |
|
| - |
|
270 |
List<Double> PRICE_RANGE = Arrays.asList(0.0, 12001.0, 35001.0, Double.MAX_VALUE);
|
| - |
|
271 |
|
| - |
|
272 |
static Map<Double, List<ScratchedGift>> GIFT_SERIES = new TreeMap<>(Comparator.reverseOrder());
|
| - |
|
273 |
|
| - |
|
274 |
private void persistNonSerializedWithCustomSerialNumber(CustomFofoOrderItem customFofoOrderItem, int orderItemId) {
|
| - |
|
275 |
// Create a new instance of FofoNonSerializeSerial
|
| - |
|
276 |
for (String accSerialNumber : customFofoOrderItem.getCustomSerialNumbers()) {
|
| - |
|
277 |
if (!accSerialNumber.isEmpty()) {
|
| - |
|
278 |
FofoNonSerializeSerial nonSerializeSerial = new FofoNonSerializeSerial();
|
| - |
|
279 |
|
| - |
|
280 |
// Populate the entity with relevant information
|
| - |
|
281 |
nonSerializeSerial.setOrderItemId(orderItemId);
|
| - |
|
282 |
nonSerializeSerial.setSerialNumber(accSerialNumber);
|
| - |
|
283 |
|
| - |
|
284 |
// Save the entity to the database
|
| - |
|
285 |
fofoNonSerializeSerialRepository.persist(nonSerializeSerial);
|
| - |
|
286 |
}
|
| - |
|
287 |
|
| - |
|
288 |
}
|
| - |
|
289 |
}
|
| - |
|
290 |
|
| - |
|
291 |
|
| - |
|
292 |
public void sendAppDownloadBillingOffer(String mobileNumber) throws Exception {
|
| - |
|
293 |
String sdurl = "http://surl.li/anhfn";
|
| - |
|
294 |
try {
|
| - |
|
295 |
if (prodEnv) {
|
| - |
|
296 |
this.sendSms(APP_DOWNLOAD_BILLING_TEMPLATE_ID, String.format(APP_DOWNLOAD_BILLING_OFFER, sdurl), mobileNumber);
|
| - |
|
297 |
}
|
| - |
|
298 |
} catch (Exception e) {
|
| - |
|
299 |
e.printStackTrace();
|
| - |
|
300 |
}
|
| - |
|
301 |
|
| - |
|
302 |
}
|
| - |
|
303 |
|
| - |
|
304 |
public void sendSms(String dltTemplateId, String message, String mobileNumber) throws Exception {
|
| - |
|
305 |
Map<String, String> map = new HashMap<>();
|
| - |
|
306 |
|
| - |
|
307 |
map.put("sender", SENDER);
|
| - |
|
308 |
map.put("messagetype", "TXT");
|
| - |
|
309 |
map.put("apikey", "b866f7-c6c483-682ff5-054420-ad9e2c");
|
| - |
|
310 |
|
| - |
|
311 |
map.put("numbers", "91" + mobileNumber);
|
| - |
|
312 |
LOGGER.info("Message {}", message);
|
| - |
|
313 |
// OTP Message Template
|
| - |
|
314 |
map.put("message", message);
|
| - |
|
315 |
map.put("dlttempid", dltTemplateId);
|
| - |
|
316 |
|
| - |
|
317 |
String response = restClient.post(SMS_GATEWAY, map, new HashMap<>());
|
| - |
|
318 |
LOGGER.info(response);
|
| - |
|
319 |
|
| - |
|
320 |
}
|
| - |
|
321 |
|
| - |
|
322 |
|
| - |
|
323 |
private void createScratchOffer(int fofoId, String invoiceNumber, int customerId) {
|
| - |
|
324 |
|
| - |
|
325 |
//ScratchedGift gift = getScratchedGiftRandom(fofoId, customerId);
|
| - |
|
326 |
|
| - |
|
327 |
|
| - |
|
328 |
// LocalDateTime endDate = LocalDateTime.of(LocalDate.now().getYear(), LocalDate.now().getMonth(), 27, 21, 00);
|
| - |
|
329 |
List<ScratchOffer> scratchOffers = scratchOfferRepository.selectBycCustomerIdAndDate(customerId, ProfitMandiConstants.SCRATCH_OFFER_START_DATE, ProfitMandiConstants.SCRATCH_OFFER_END_DATE);
|
| - |
|
330 |
if (scratchOffers.size() == 0) {
|
| - |
|
331 |
ScratchOffer so2 = new ScratchOffer();
|
| - |
|
332 |
so2.setInvoiceNumber(invoiceNumber);
|
| - |
|
333 |
so2.setScratched(false);
|
| - |
|
334 |
so2.setCreatedTimestamp(LocalDateTime.now());
|
| - |
|
335 |
so2.setExpiredTimestamp(ProfitMandiConstants.SCRATCH_OFFER_END_DATE.plusDays(1).atTime(LocalTime.MAX));
|
| - |
|
336 |
so2.setOfferName(ScratchedGift.BLNT);
|
| - |
|
337 |
so2.setCustomerId(customerId);
|
| - |
|
338 |
|
| - |
|
339 |
LocalDateTime today830PM = LocalDate.now().atTime(20, 30);
|
| - |
|
340 |
LocalDateTime today9PM = LocalDate.now().atTime(21, 0);
|
| - |
|
341 |
so2.setUnlockedAt(LocalDateTime.now());
|
| - |
|
342 |
|
| - |
|
343 |
// if (LocalDateTime.now().isAfter(today830PM)) {
|
| - |
|
344 |
// so2.setUnlockedAt(today9PM.plusDays(0));
|
| - |
|
345 |
// } else {
|
| - |
|
346 |
// so2.setUnlockedAt(today9PM);
|
| - |
|
347 |
// }
|
| - |
|
348 |
scratchOfferRepository.persist(so2);
|
| - |
|
349 |
}
|
| - |
|
350 |
}
|
| - |
|
351 |
|
| - |
|
352 |
private static Map<ScratchedGift, Integer> GIFT_QUANTITIES = new HashMap<>();
|
| - |
|
353 |
|
| - |
|
354 |
static {
|
| - |
|
355 |
GIFT_QUANTITIES.put(ScratchedGift.CASSROLE, 120);
|
| - |
|
356 |
GIFT_QUANTITIES.put(ScratchedGift.NECK_BAND, 920);
|
| - |
|
357 |
GIFT_QUANTITIES.put(ScratchedGift.JUICE_JUG, 160);
|
| - |
|
358 |
GIFT_QUANTITIES.put(ScratchedGift.INSULATED_FLASK, 140);
|
| - |
|
359 |
GIFT_QUANTITIES.put(ScratchedGift.ACCESSORIES_50_PERCENT_OFF, 1000);
|
| - |
|
360 |
GIFT_QUANTITIES.put(ScratchedGift.EW, 3000);
|
| - |
|
361 |
}
|
| - |
|
362 |
|
| - |
|
363 |
static {
|
| - |
|
364 |
GIFT_SERIES.put(0.0, Arrays.asList(ScratchedGift.ACCESSORIES_50_PERCENT_OFF, ScratchedGift.EW));
|
| - |
|
365 |
GIFT_SERIES.put(12001.0, Arrays.asList(ScratchedGift.CASSROLE, ScratchedGift.NECK_BAND, ScratchedGift.JUICE_JUG, ScratchedGift.INSULATED_FLASK));
|
| - |
|
366 |
GIFT_SERIES.put(35001.0, Arrays.asList(ScratchedGift.CASSROLE, ScratchedGift.NECK_BAND, ScratchedGift.JUICE_JUG, ScratchedGift.INSULATED_FLASK));
|
| - |
|
367 |
}
|
| - |
|
368 |
|
| 270 |
@Override
|
369 |
@Override
|
| 271 |
public int createOrder(CreateOrderRequest createOrderRequest, int fofoId, boolean accessoriesDeals) throws ProfitMandiBusinessException {
|
370 |
public int createOrder(CreateOrderRequest createOrderRequest, int fofoId, boolean accessoriesDeals) throws ProfitMandiBusinessException {
|
| 272 |
LOGGER.info("fofoId -- {} Order Request -- {}", fofoId, createOrderRequest);
|
371 |
LOGGER.info("fofoId -- {} Order Request -- {}", fofoId, createOrderRequest);
|
| 273 |
CustomCustomer customCustomer = createOrderRequest.getCustomer();
|
372 |
CustomCustomer customCustomer = createOrderRequest.getCustomer();
|
| 274 |
Customer customer = customerRepository.selectById(customCustomer.getCustomerId());
|
373 |
Customer customer = customerRepository.selectById(customCustomer.getCustomerId());
|
| Line 651... |
Line 750... |
| 651 |
}
|
750 |
}
|
| 652 |
}
|
751 |
}
|
| 653 |
}
|
752 |
}
|
| 654 |
|
753 |
|
| 655 |
// Update Partner Opening Stock current qty
|
754 |
// Update Partner Opening Stock current qty
|
| 656 |
if (fofoOrder.getId() > 0){
|
755 |
if (fofoOrder.getId() > 0) {
|
| 657 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
756 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
| 658 |
for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
|
757 |
for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
|
| 659 |
Item item = itemRepository.selectById(fofoOrderItem.getItemId());
|
758 |
Item item = itemRepository.selectById(fofoOrderItem.getItemId());
|
| 660 |
smartCartService.minusOpeningStock(item.getId(),fofoOrder.getFofoId(),fofoOrderItem.getQuantity());
|
759 |
smartCartService.minusOpeningStock(item.getId(), fofoOrder.getFofoId(), fofoOrderItem.getQuantity());
|
| 661 |
}
|
760 |
}
|
| 662 |
}
|
761 |
}
|
| 663 |
|
762 |
|
| 664 |
|
763 |
|
| 665 |
return fofoOrder.getId();
|
764 |
return fofoOrder.getId();
|
| 666 |
}
|
765 |
}
|
| 667 |
|
766 |
|
| 668 |
static Map<Double, List<ScratchedGift>> GIFT_SERIES = new TreeMap<>(Comparator.reverseOrder());
|
- |
|
| 669 |
|
- |
|
| 670 |
private void persistNonSerializedWithCustomSerialNumber(CustomFofoOrderItem customFofoOrderItem, int orderItemId) {
|
- |
|
| 671 |
// Create a new instance of FofoNonSerializeSerial
|
- |
|
| 672 |
for (String accSerialNumber : customFofoOrderItem.getCustomSerialNumbers()) {
|
- |
|
| 673 |
if (!accSerialNumber.isEmpty()) {
|
- |
|
| 674 |
FofoNonSerializeSerial nonSerializeSerial = new FofoNonSerializeSerial();
|
- |
|
| 675 |
|
- |
|
| 676 |
// Populate the entity with relevant information
|
- |
|
| 677 |
nonSerializeSerial.setOrderItemId(orderItemId);
|
- |
|
| 678 |
nonSerializeSerial.setSerialNumber(accSerialNumber);
|
- |
|
| 679 |
|
- |
|
| 680 |
// Save the entity to the database
|
- |
|
| 681 |
fofoNonSerializeSerialRepository.persist(nonSerializeSerial);
|
- |
|
| 682 |
}
|
- |
|
| 683 |
|
- |
|
| 684 |
}
|
- |
|
| 685 |
}
|
- |
|
| 686 |
|
- |
|
| 687 |
|
- |
|
| 688 |
public void sendAppDownloadBillingOffer(String mobileNumber) throws Exception {
|
- |
|
| 689 |
String sdurl = "http://surl.li/anhfn";
|
- |
|
| 690 |
try {
|
- |
|
| 691 |
if (prodEnv) {
|
- |
|
| 692 |
this.sendSms(APP_DOWNLOAD_BILLING_TEMPLATE_ID, String.format(APP_DOWNLOAD_BILLING_OFFER, sdurl), mobileNumber);
|
- |
|
| 693 |
}
|
- |
|
| 694 |
} catch (Exception e) {
|
- |
|
| 695 |
e.printStackTrace();
|
- |
|
| 696 |
}
|
- |
|
| 697 |
|
- |
|
| 698 |
}
|
- |
|
| 699 |
|
- |
|
| 700 |
public void sendSms(String dltTemplateId, String message, String mobileNumber) throws Exception {
|
- |
|
| 701 |
Map<String, String> map = new HashMap<>();
|
- |
|
| 702 |
|
- |
|
| 703 |
map.put("sender", SENDER);
|
- |
|
| 704 |
map.put("messagetype", "TXT");
|
- |
|
| 705 |
map.put("apikey", "b866f7-c6c483-682ff5-054420-ad9e2c");
|
- |
|
| 706 |
|
- |
|
| 707 |
map.put("numbers", "91" + mobileNumber);
|
- |
|
| 708 |
LOGGER.info("Message {}", message);
|
- |
|
| 709 |
// OTP Message Template
|
- |
|
| 710 |
map.put("message", message);
|
- |
|
| 711 |
map.put("dlttempid", dltTemplateId);
|
- |
|
| 712 |
|
- |
|
| 713 |
String response = restClient.post(SMS_GATEWAY, map, new HashMap<>());
|
- |
|
| 714 |
LOGGER.info(response);
|
- |
|
| 715 |
|
- |
|
| 716 |
}
|
- |
|
| 717 |
|
- |
|
| 718 |
|
- |
|
| 719 |
private void createScratchOffer(int fofoId, String invoiceNumber, int customerId) {
|
- |
|
| 720 |
|
- |
|
| 721 |
//ScratchedGift gift = getScratchedGiftRandom(fofoId, customerId);
|
- |
|
| 722 |
|
- |
|
| 723 |
|
- |
|
| 724 |
// LocalDateTime endDate = LocalDateTime.of(LocalDate.now().getYear(), LocalDate.now().getMonth(), 27, 21, 00);
|
- |
|
| 725 |
List<ScratchOffer> scratchOffers = scratchOfferRepository.selectBycCustomerIdAndDate(customerId, ProfitMandiConstants.SCRATCH_OFFER_START_DATE, ProfitMandiConstants.SCRATCH_OFFER_END_DATE);
|
- |
|
| 726 |
if (scratchOffers.size() == 0) {
|
- |
|
| 727 |
ScratchOffer so2 = new ScratchOffer();
|
- |
|
| 728 |
so2.setInvoiceNumber(invoiceNumber);
|
- |
|
| 729 |
so2.setScratched(false);
|
- |
|
| 730 |
so2.setCreatedTimestamp(LocalDateTime.now());
|
- |
|
| 731 |
so2.setExpiredTimestamp(ProfitMandiConstants.SCRATCH_OFFER_END_DATE.plusDays(1).atTime(LocalTime.MAX));
|
- |
|
| 732 |
so2.setOfferName(ScratchedGift.BLNT);
|
- |
|
| 733 |
so2.setCustomerId(customerId);
|
- |
|
| 734 |
|
- |
|
| 735 |
LocalDateTime today830PM = LocalDate.now().atTime(20, 30);
|
- |
|
| 736 |
LocalDateTime today9PM = LocalDate.now().atTime(21, 0);
|
- |
|
| 737 |
so2.setUnlockedAt(LocalDateTime.now());
|
- |
|
| 738 |
|
- |
|
| 739 |
// if (LocalDateTime.now().isAfter(today830PM)) {
|
- |
|
| 740 |
// so2.setUnlockedAt(today9PM.plusDays(0));
|
- |
|
| 741 |
// } else {
|
- |
|
| 742 |
// so2.setUnlockedAt(today9PM);
|
- |
|
| 743 |
// }
|
- |
|
| 744 |
scratchOfferRepository.persist(so2);
|
- |
|
| 745 |
}
|
- |
|
| 746 |
}
|
- |
|
| 747 |
private static Map<ScratchedGift, Integer> GIFT_QUANTITIES = new HashMap<>();
|
- |
|
| 748 |
|
- |
|
| 749 |
static {
|
- |
|
| 750 |
GIFT_QUANTITIES.put(ScratchedGift.CASSROLE, 120);
|
- |
|
| 751 |
GIFT_QUANTITIES.put(ScratchedGift.NECK_BAND, 920);
|
- |
|
| 752 |
GIFT_QUANTITIES.put(ScratchedGift.JUICE_JUG, 160);
|
- |
|
| 753 |
GIFT_QUANTITIES.put(ScratchedGift.INSULATED_FLASK, 140);
|
- |
|
| 754 |
GIFT_QUANTITIES.put(ScratchedGift.ACCESSORIES_50_PERCENT_OFF, 1000);
|
- |
|
| 755 |
GIFT_QUANTITIES.put(ScratchedGift.EW, 3000);
|
- |
|
| 756 |
}
|
- |
|
| 757 |
|
- |
|
| 758 |
static {
|
- |
|
| 759 |
GIFT_SERIES.put(0.0, Arrays.asList(ScratchedGift.ACCESSORIES_50_PERCENT_OFF, ScratchedGift.EW));
|
- |
|
| 760 |
GIFT_SERIES.put(12001.0, Arrays.asList(ScratchedGift.CASSROLE, ScratchedGift.NECK_BAND, ScratchedGift.JUICE_JUG, ScratchedGift.INSULATED_FLASK));
|
- |
|
| 761 |
GIFT_SERIES.put(35001.0, Arrays.asList(ScratchedGift.CASSROLE, ScratchedGift.NECK_BAND, ScratchedGift.JUICE_JUG, ScratchedGift.INSULATED_FLASK));
|
- |
|
| 762 |
}
|
- |
|
| 763 |
|
- |
|
| 764 |
List<Double> PRICE_RANGE = Arrays.asList(0.0, 12001.0,35001.0);
|
- |
|
| 765 |
|
- |
|
| 766 |
@Override
|
767 |
@Override
|
| 767 |
public void processScratchOffer(FofoOrder fofoOrder) throws ProfitMandiBusinessException {
|
768 |
public void processScratchOffer(FofoOrder fofoOrder) throws ProfitMandiBusinessException {
|
| 768 |
boolean isSmartPhonePurchased = false;
|
769 |
boolean isSmartPhonePurchased = false;
|
| 769 |
float maxPurchaseValue = 0;
|
770 |
float maxPurchaseValue = 0;
|
| 770 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
771 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
| Line 792... |
Line 793... |
| 792 |
} catch (Exception e) {
|
793 |
} catch (Exception e) {
|
| 793 |
// TODO Auto-generated catch block
|
794 |
// TODO Auto-generated catch block
|
| 794 |
e.printStackTrace();
|
795 |
e.printStackTrace();
|
| 795 |
}
|
796 |
}
|
| 796 |
if (specificPriceOffer) {
|
797 |
if (specificPriceOffer) {
|
| 797 |
this.createSpecificPriceScratchOffer(fofoOrder.getInvoiceNumber(), fofoOrder.getCustomerId(),fofoOrder.getFofoId(), maxPurchaseValue);
|
798 |
this.createSpecificPriceScratchOffer(fofoOrder.getInvoiceNumber(), fofoOrder.getCustomerId(), fofoOrder.getFofoId(), maxPurchaseValue);
|
| 798 |
} else if (randomOffer) {
|
799 |
} else if (randomOffer) {
|
| 799 |
this.createRandomScratchOffer(fofoOrder.getInvoiceNumber(), fofoOrder.getCustomerId());
|
800 |
this.createRandomScratchOffer(fofoOrder.getInvoiceNumber(), fofoOrder.getCustomerId());
|
| 800 |
LOGGER.info("randomOffer {}", randomOffer);
|
801 |
LOGGER.info("randomOffer {}", randomOffer);
|
| 801 |
} else {
|
802 |
} else {
|
| 802 |
this.createScratchOffer(fofoOrder.getFofoId(), fofoOrder.getInvoiceNumber(), fofoOrder.getCustomerId());
|
803 |
this.createScratchOffer(fofoOrder.getFofoId(), fofoOrder.getInvoiceNumber(), fofoOrder.getCustomerId());
|
| Line 805... |
Line 806... |
| 805 |
}
|
806 |
}
|
| 806 |
}
|
807 |
}
|
| 807 |
}
|
808 |
}
|
| 808 |
|
809 |
|
| 809 |
@Override
|
810 |
@Override
|
| 810 |
public ScratchedGift getSelectedGift(double purchaseAmount,int fofoId) throws ProfitMandiBusinessException {
|
811 |
public ScratchedGift getSelectedGift(double purchaseAmount, int fofoId) throws ProfitMandiBusinessException {
|
| 811 |
//Iterating map in reverse order of values
|
812 |
//Iterating map in reverse order of values
|
| 812 |
Map<ScratchedGift, Long> scratchOfferCountMap = scratchOfferRepository.countOffersByDateRange(ProfitMandiConstants.SCRATCH_OFFER_START_DATE, ProfitMandiConstants.SCRATCH_OFFER_END_DATE);
|
813 |
Map<ScratchedGift, Long> scratchOfferCountMap = scratchOfferRepository.countOffersByDateRange(ProfitMandiConstants.SCRATCH_OFFER_START_DATE, ProfitMandiConstants.SCRATCH_OFFER_END_DATE);
|
| 813 |
RandomCollection<ScratchedGift> giftRandomCollection = createDynamicGiftSeries(scratchOfferCountMap, purchaseAmount,fofoId);
|
814 |
RandomCollection<ScratchedGift> giftRandomCollection = createDynamicGiftSeries(scratchOfferCountMap, purchaseAmount, fofoId);
|
| 814 |
if (giftRandomCollection.size() > 0) {
|
815 |
if (giftRandomCollection.size() > 0) {
|
| 815 |
return giftRandomCollection.next();
|
816 |
return giftRandomCollection.next();
|
| 816 |
} else if (purchaseAmount < 35000) {
|
817 |
} else if (purchaseAmount < 35000) {
|
| 817 |
// Default gift if no match found
|
818 |
// Default gift if no match found
|
| 818 |
return ScratchedGift.EW;
|
819 |
return ScratchedGift.EW;
|
| Line 822... |
Line 823... |
| 822 |
}
|
823 |
}
|
| 823 |
|
824 |
|
| 824 |
public RandomCollection<ScratchedGift> createDynamicGiftSeries(Map<ScratchedGift, Long> soldGiftContMap, Double sellingPrice, int fofoId) throws ProfitMandiBusinessException {
|
825 |
public RandomCollection<ScratchedGift> createDynamicGiftSeries(Map<ScratchedGift, Long> soldGiftContMap, Double sellingPrice, int fofoId) throws ProfitMandiBusinessException {
|
| 825 |
int index = 0;
|
826 |
int index = 0;
|
| 826 |
RandomCollection<ScratchedGift> randomCollection = new RandomCollection<>();
|
827 |
RandomCollection<ScratchedGift> randomCollection = new RandomCollection<>();
|
| 827 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId,LocalDate.now());
|
828 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
|
| 828 |
LOGGER.info("partnerType {}",partnerType);
|
829 |
LOGGER.info("partnerType {}", partnerType);
|
| - |
|
830 |
|
| 829 |
if (partnerType.equals(PartnerType.BRONZE)) {
|
831 |
if (partnerType.equals(PartnerType.BRONZE)) {
|
| 830 |
LOGGER.info("partnerType if- {}",partnerType);
|
832 |
LOGGER.info("partnerType if- {}", partnerType);
|
| 831 |
sellingPrice = 0.0;
|
833 |
sellingPrice = 0.0;
|
| 832 |
}
|
834 |
}
|
| - |
|
835 |
|
| - |
|
836 |
for (int i = 0; i < PRICE_RANGE.size(); i++) {
|
| 833 |
for (Double price : PRICE_RANGE) {
|
837 |
Double price = PRICE_RANGE.get(i);
|
| - |
|
838 |
Double nextPrice = Double.MAX_VALUE;
|
| 834 |
if (sellingPrice >= price) {
|
839 |
if (i != PRICE_RANGE.size() - 1) {
|
| - |
|
840 |
nextPrice = PRICE_RANGE.get(i + 1);
|
| - |
|
841 |
}
|
| 835 |
// If we find a matching price range, add gifts and exit the loop
|
842 |
if (sellingPrice >= price && sellingPrice < nextPrice) {
|
| 836 |
int divisor = PRICE_RANGE.size() - index;
|
843 |
int divisor = PRICE_RANGE.size() - index;
|
| - |
|
844 |
LOGGER.info("Processing price range: {}, sellingPrice: {}", price, sellingPrice);
|
| - |
|
845 |
|
| 837 |
for (ScratchedGift gift : GIFT_SERIES.get(price)) {
|
846 |
for (ScratchedGift gift : GIFT_SERIES.get(price)) {
|
| 838 |
int remainingQty = GIFT_QUANTITIES.get(gift) - soldGiftContMap.getOrDefault(gift, 0L).intValue();
|
847 |
int remainingQty = GIFT_QUANTITIES.get(gift) - soldGiftContMap.getOrDefault(gift, 0L).intValue();
|
| - |
|
848 |
LOGGER.info("Checking gift: {}, remainingQty: {}", gift, remainingQty);
|
| - |
|
849 |
|
| 839 |
if (remainingQty > 0) {
|
850 |
if (remainingQty > 0) {
|
| 840 |
int weight = (remainingQty > divisor) ? remainingQty / divisor : remainingQty;
|
851 |
int weight = (remainingQty > divisor) ? remainingQty / divisor : remainingQty;
|
| 841 |
randomCollection.add(weight, gift);
|
852 |
randomCollection.add(weight, gift);
|
| - |
|
853 |
LOGGER.info("Added gift: {}, weight: {}", gift, weight);
|
| 842 |
}
|
854 |
}
|
| 843 |
}
|
855 |
}
|
| 844 |
break; // Exit loop once matching price range is processed
|
856 |
break; // Exit the loop once the correct price range is processed
|
| 845 |
}
|
857 |
}
|
| 846 |
index++;
|
858 |
index++;
|
| 847 |
}
|
859 |
}
|
| - |
|
860 |
|
| - |
|
861 |
// If no gifts were added, log and handle potential issues here
|
| - |
|
862 |
if (randomCollection.size() == 0) {
|
| - |
|
863 |
LOGGER.info("No gifts added for sellingPrice: {} in createDynamicGiftSeries", sellingPrice);
|
| - |
|
864 |
}
|
| - |
|
865 |
|
| 848 |
LOGGER.info("randomCollectionSize {}, partnerType {}, price {},", randomCollection.size(), partnerType, sellingPrice);
|
866 |
LOGGER.info("randomCollectionSize {}, partnerType {}, sellingPrice {}", randomCollection.size(), partnerType, sellingPrice);
|
| 849 |
return randomCollection;
|
867 |
return randomCollection;
|
| 850 |
}
|
868 |
}
|
| 851 |
|
869 |
|
| - |
|
870 |
|
| - |
|
871 |
|
| 852 |
/*static {
|
872 |
/*static {
|
| 853 |
RandomCollection<ScratchedGift> map1 = new RandomCollection<ScratchedGift>().
|
873 |
RandomCollection<ScratchedGift> map1 = new RandomCollection<ScratchedGift>().
|
| 854 |
add(100d, ScratchedGift.GIFT_BOWL);
|
874 |
add(100d, ScratchedGift.GIFT_BOWL);
|
| 855 |
GIFT_SERIES.put(0.0, map1);
|
875 |
GIFT_SERIES.put(0.0, map1);
|
| 856 |
//Map<ScratchedGift, Double> map2 = new HashMap<>();
|
876 |
//Map<ScratchedGift, Double> map2 = new HashMap<>();
|
| Line 880... |
Line 900... |
| 880 |
GIFT_SERIES.put(50001.0, map5);
|
900 |
GIFT_SERIES.put(50001.0, map5);
|
| 881 |
}*/
|
901 |
}*/
|
| 882 |
|
902 |
|
| 883 |
|
903 |
|
| 884 |
private void createSpecificPriceScratchOffer(String invoiceNumber, int customerId, int fofoId, float purchaseAmount) throws ProfitMandiBusinessException {
|
904 |
private void createSpecificPriceScratchOffer(String invoiceNumber, int customerId, int fofoId, float purchaseAmount) throws ProfitMandiBusinessException {
|
| 885 |
ScratchedGift selectedGift = getSelectedGift(purchaseAmount,fofoId);
|
905 |
ScratchedGift selectedGift = getSelectedGift(purchaseAmount, fofoId);
|
| 886 |
List<ScratchOffer> scratchOffers = scratchOfferRepository.selectBycCustomerIdAndDate(customerId, ProfitMandiConstants.SCRATCH_OFFER_START_DATE, ProfitMandiConstants.SCRATCH_OFFER_END_DATE);
|
906 |
List<ScratchOffer> scratchOffers = scratchOfferRepository.selectBycCustomerIdAndDate(customerId, ProfitMandiConstants.SCRATCH_OFFER_START_DATE, ProfitMandiConstants.SCRATCH_OFFER_END_DATE);
|
| 887 |
if (scratchOffers.size() == 0) {
|
907 |
if (scratchOffers.size() == 0) {
|
| 888 |
ScratchOffer so2 = new ScratchOffer();
|
908 |
ScratchOffer so2 = new ScratchOffer();
|
| 889 |
so2.setInvoiceNumber(invoiceNumber);
|
909 |
so2.setInvoiceNumber(invoiceNumber);
|
| 890 |
so2.setScratched(false);
|
910 |
so2.setScratched(false);
|