Subversion Repositories SmartDukaan

Rev

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

Rev 31853 Rev 31903
Line 6... Line 6...
6
import com.spice.profitmandi.common.model.PartnerTargetModel;
6
import com.spice.profitmandi.common.model.PartnerTargetModel;
7
import com.spice.profitmandi.common.model.ProfitMandiConstants;
7
import com.spice.profitmandi.common.model.ProfitMandiConstants;
8
import com.spice.profitmandi.dao.entity.catalog.ItemCriteria;
8
import com.spice.profitmandi.dao.entity.catalog.ItemCriteria;
9
import com.spice.profitmandi.dao.entity.catalog.Offer;
9
import com.spice.profitmandi.dao.entity.catalog.Offer;
10
import com.spice.profitmandi.dao.entity.catalog.TagListing;
10
import com.spice.profitmandi.dao.entity.catalog.TagListing;
11
import com.spice.profitmandi.dao.entity.catalog.TargetSlab;
11
import com.spice.profitmandi.dao.entity.catalog.TargetSlabEntity;
12
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
12
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
13
import com.spice.profitmandi.dao.entity.fofo.OfferPayout;
13
import com.spice.profitmandi.dao.entity.fofo.OfferPayout;
14
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
14
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
15
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
15
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
16
import com.spice.profitmandi.dao.enumuration.catalog.OfferSchemeType;
16
import com.spice.profitmandi.dao.enumuration.catalog.OfferSchemeType;
17
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
17
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
-
 
18
import com.spice.profitmandi.dao.model.AmountModel;
18
import com.spice.profitmandi.dao.model.CreateOfferRequest;
19
import com.spice.profitmandi.dao.model.CreateOfferRequest;
19
import com.spice.profitmandi.dao.model.ItemCriteriaPayout;
20
import com.spice.profitmandi.dao.model.ItemCriteriaPayout;
20
import com.spice.profitmandi.dao.repository.catalog.*;
21
import com.spice.profitmandi.dao.repository.catalog.*;
21
import com.spice.profitmandi.dao.repository.fofo.OfferPayoutRepository;
22
import com.spice.profitmandi.dao.repository.fofo.OfferPayoutRepository;
22
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
23
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
Line 296... Line 297...
296
                                itemCriteria.setCriteria(gson.toJson(itemCriteriaPayout.getItemCriteria()));
297
                                itemCriteria.setCriteria(gson.toJson(itemCriteriaPayout.getItemCriteria()));
297
                                itemCriteriaRepository.persist(itemCriteria);
298
                                itemCriteriaRepository.persist(itemCriteria);
298
                            }
299
                            }
299
                        }
300
                        }
300
                        for (PayoutSlab payoutSlab : itemCriteriaPayout.getPayoutSlabs()) {
301
                        for (PayoutSlab payoutSlab : itemCriteriaPayout.getPayoutSlabs()) {
301
                            TargetSlab targetSlab1 = new TargetSlab();
302
                            TargetSlabEntity targetSlabEntity = new TargetSlabEntity();
302
                            targetSlab1.setOfferId(createOfferRequest.getId());
303
                            targetSlabEntity.setOfferId(createOfferRequest.getId());
303
                            targetSlab1.setOnwardsTarget(targetSlab.getOnwardsAmount());
304
                            targetSlabEntity.setOnwardsTarget(targetSlab.getOnwardsAmount());
304
                            targetSlab1.setTargetDescription(targetSlab.getTargetDescription());
305
                            targetSlabEntity.setTargetDescription(targetSlab.getTargetDescription());
305
                            targetSlab1.setPayoutTarget(payoutSlab.getOnwardsAmount());
306
                            targetSlabEntity.setPayoutTarget(payoutSlab.getOnwardsAmount());
306
                            targetSlab1.setPayoutValue(payoutSlab.getPayoutAmount());
307
                            targetSlabEntity.setPayoutValue(payoutSlab.getPayoutAmount());
307
                            targetSlab1.setItemCriteriaId(itemCriteria.getId());
308
                            targetSlabEntity.setItemCriteriaId(itemCriteria.getId());
308
                            targetSlab1.setAmountType(itemCriteriaPayout.getAmountType());
309
                            targetSlabEntity.setAmountType(itemCriteriaPayout.getAmountType());
309
                            offerTargetSlabRepository.persist(targetSlab1);
310
                            offerTargetSlabRepository.persist(targetSlabEntity);
310
                        }
311
                        }
311
                    }
312
                    }
312
                }
313
                }
313
            }
314
            }
314
 
315
 
Line 520... Line 521...
520
                    }
521
                    }
521
                }
522
                }
522
            }
523
            }
523
        }
524
        }
524
        return catalogSlabPayoutMap;
525
        return catalogSlabPayoutMap;
-
 
526
    }
-
 
527
 
-
 
528
    @Override
-
 
529
    @Cacheable(value = "slabPayoutMap", cacheManager = "oneDayCacheManager")
-
 
530
    public Map<Integer, Map<Integer, AmountModel>> getSlabPayoutMapNew(CreateOfferRequest createOfferRequest) {
-
 
531
        Map<Integer, Map<Integer, AmountModel>> catalogSlabPayoutMap = new HashMap<>();
-
 
532
        com.spice.profitmandi.dao.model.TargetSlab targetSlab = createOfferRequest.getTargetSlabs().get(0);
-
 
533
        List<ItemCriteriaPayout> payouts = targetSlab.getItemCriteriaPayouts();
-
 
534
 
-
 
535
        for (ItemCriteriaPayout itemCriteriaPayout : payouts) {
-
 
536
            com.spice.profitmandi.service.offers.ItemCriteria itemCriteria = itemCriteriaPayout.getItemCriteria();
-
 
537
            List<Integer> catalogIds = itemRepository.getCatalogIds(itemCriteria);
-
 
538
            for (PayoutSlab payoutSlab : Lists.reverse(itemCriteriaPayout.getPayoutSlabs())) {
-
 
539
                if (itemCriteriaPayout.getAmountType().equals(AmountType.FIXED)) {
-
 
540
                    for (Integer catalogId : catalogIds) {
-
 
541
                        if (!catalogSlabPayoutMap.containsKey(catalogId)) {
-
 
542
                            catalogSlabPayoutMap.put(catalogId, new LinkedHashMap<>());
-
 
543
                        }
-
 
544
                        AmountModel amountModel = new AmountModel();
-
 
545
                        amountModel.setAmountType(AmountType.FIXED);
-
 
546
                        amountModel.setAmount(payoutSlab.getPayoutAmount());
-
 
547
                        catalogSlabPayoutMap.get(catalogId).put(payoutSlab.getOnwardsAmount(),
-
 
548
                                amountModel);
-
 
549
                    }
-
 
550
                } else if (itemCriteriaPayout.getAmountType().equals(AmountType.SLAB_FIXED)) {
-
 
551
                    for (Integer catalogId : catalogIds) {
-
 
552
                        if (!catalogSlabPayoutMap.containsKey(catalogId)) {
-
 
553
                            catalogSlabPayoutMap.put(catalogId, new LinkedHashMap<>());
-
 
554
                        }
-
 
555
 
-
 
556
                        AmountModel amountModel = new AmountModel();
-
 
557
                        amountModel.setAmountType(AmountType.FIXED);
-
 
558
                        amountModel.setAmount(payoutSlab.getPayoutAmount() / payoutSlab.getOnwardsAmount());
-
 
559
                        catalogSlabPayoutMap.get(catalogId).put(payoutSlab.getOnwardsAmount(),
-
 
560
                                amountModel);
-
 
561
                    }
-
 
562
                } else if (itemCriteriaPayout.getAmountType().equals(AmountType.PERCENTAGE)) {
-
 
563
                    for (Integer catalogId : catalogIds) {
-
 
564
                        if (!catalogSlabPayoutMap.containsKey(catalogId)) {
-
 
565
                            catalogSlabPayoutMap.put(catalogId, new LinkedHashMap<>());
-
 
566
                        }
-
 
567
                        AmountModel amountModel = new AmountModel();
-
 
568
                        amountModel.setAmountType(AmountType.PERCENTAGE);
-
 
569
                        amountModel.setAmount(payoutSlab.getPayoutAmount());
-
 
570
                        catalogSlabPayoutMap.get(catalogId).put(payoutSlab.getOnwardsAmount(),
-
 
571
                                amountModel);
-
 
572
                    }
-
 
573
                }
-
 
574
            }
-
 
575
        }
-
 
576
        return catalogSlabPayoutMap;
525
    }
577
    }
526
 
578
 
527
}
579
}