| Line 787... |
Line 787... |
| 787 |
|
787 |
|
| 788 |
List<Order> orders = criteriaOrdersMap.get(criteriaId);
|
788 |
List<Order> orders = criteriaOrdersMap.get(criteriaId);
|
| 789 |
if (orders == null || orders.isEmpty()) continue;
|
789 |
if (orders == null || orders.isEmpty()) continue;
|
| 790 |
|
790 |
|
| 791 |
QtyAmountModel criteriaModel = calculateSellinQtyAndValue(orders);
|
791 |
QtyAmountModel criteriaModel = calculateSellinQtyAndValue(orders);
|
| 792 |
int totalBaseQty = criteriaModel.getQty();
|
792 |
int criteriaQty = criteriaModel.getQty();
|
| - |
|
793 |
int totalBaseQty = criteriaQty;
|
| 793 |
int totalBaseValue = (int) criteriaModel.getAmount();
|
794 |
int totalBaseValue = (int) criteriaModel.getAmount();
|
| 794 |
if (userBaseQty != null) {
|
795 |
if (userBaseQty != null) {
|
| 795 |
totalBaseQty = userBaseQty;
|
796 |
totalBaseQty = userBaseQty;
|
| 796 |
totalBaseValue = userBaseValue;
|
797 |
totalBaseValue = userBaseValue;
|
| 797 |
}
|
798 |
}
|
| Line 805... |
Line 806... |
| 805 |
qtyAmountModel.setQty(totalBaseQty);
|
806 |
qtyAmountModel.setQty(totalBaseQty);
|
| 806 |
qtyAmountModel.setAmount(totalBaseValue);
|
807 |
qtyAmountModel.setAmount(totalBaseValue);
|
| 807 |
|
808 |
|
| 808 |
PayoutSlab eligibleSlab = findEligibleSlab(itemCriteriaPayout.getPayoutSlabs(), purchasedValue);
|
809 |
PayoutSlab eligibleSlab = findEligibleSlab(itemCriteriaPayout.getPayoutSlabs(), purchasedValue);
|
| 809 |
setSlabProgress(itemCriteriaPayout, eligibleSlab, purchasedValue);
|
810 |
setSlabProgress(itemCriteriaPayout, eligibleSlab, purchasedValue);
|
| - |
|
811 |
// For FIXED (per pc) payout, use per-criteria qty not base value
|
| - |
|
812 |
int sellinValueForFixed = itemCriteriaPayout.getAmountType().equals(AmountType.FIXED) ? criteriaQty : purchasedValue;
|
| 810 |
double finalPayout = calculateFinalPayout(eligibleSlab, itemCriteriaPayout.getAmountType(),
|
813 |
double finalPayout = calculateFinalPayout(eligibleSlab, itemCriteriaPayout.getAmountType(),
|
| 811 |
purchasedValue, purchasedValue);
|
814 |
purchasedValue, sellinValueForFixed);
|
| 812 |
qtyAmountModel.setFinalPayout(finalPayout);
|
815 |
qtyAmountModel.setFinalPayout(finalPayout);
|
| 813 |
}
|
816 |
}
|
| 814 |
return criteriaQtyAmountMap;
|
817 |
return criteriaQtyAmountMap;
|
| 815 |
}
|
818 |
}
|
| 816 |
|
819 |
|
| Line 919... |
Line 922... |
| 919 |
if (createOfferRequest.getTargetType().equals(AchievementType.QUANTITY)) {
|
922 |
if (createOfferRequest.getTargetType().equals(AchievementType.QUANTITY)) {
|
| 920 |
eligibleSale = eligibleBaseQty;
|
923 |
eligibleSale = eligibleBaseQty;
|
| 921 |
eligibleCriteriaSale = eligibleQty;
|
924 |
eligibleCriteriaSale = eligibleQty;
|
| 922 |
}
|
925 |
}
|
| 923 |
|
926 |
|
| - |
|
927 |
// For FIXED (per pc) payout, always use qty regardless of target type
|
| - |
|
928 |
int valueForFixed = itemCriteriaPayout.getAmountType().equals(AmountType.FIXED) ? eligibleQty : eligibleCriteriaSale;
|
| - |
|
929 |
|
| 924 |
PayoutSlab eligibleSlab = findEligibleSlab(itemCriteriaPayout.getPayoutSlabs(), eligibleSale);
|
930 |
PayoutSlab eligibleSlab = findEligibleSlab(itemCriteriaPayout.getPayoutSlabs(), eligibleSale);
|
| 925 |
setSlabProgress(itemCriteriaPayout, eligibleSlab, eligibleSale);
|
931 |
setSlabProgress(itemCriteriaPayout, eligibleSlab, eligibleSale);
|
| 926 |
double finalPayout = calculateFinalPayout(eligibleSlab, itemCriteriaPayout.getAmountType(),
|
932 |
double finalPayout = calculateFinalPayout(eligibleSlab, itemCriteriaPayout.getAmountType(),
|
| 927 |
eligibleCriteriaSaleDp, eligibleCriteriaSale);
|
933 |
eligibleCriteriaSaleDp, valueForFixed);
|
| 928 |
if (eligibleSlab != null) {
|
934 |
if (eligibleSlab != null) {
|
| 929 |
LOGGER.info("Eligible Slab {}", eligibleSlab);
|
935 |
LOGGER.info("Eligible Slab {}", eligibleSlab);
|
| 930 |
}
|
936 |
}
|
| 931 |
criteriaQtyAmountModel.setFinalPayout(finalPayout);
|
937 |
criteriaQtyAmountModel.setFinalPayout(finalPayout);
|
| 932 |
LOGGER.info("Final Payout - {}", finalPayout);
|
938 |
LOGGER.info("Final Payout - {}", finalPayout);
|
| Line 1086... |
Line 1092... |
| 1086 |
}
|
1092 |
}
|
| 1087 |
}
|
1093 |
}
|
| 1088 |
if (AmountType.PERCENTAGE.equals(itemCriteriaPayout.getAmountType())) {
|
1094 |
if (AmountType.PERCENTAGE.equals(itemCriteriaPayout.getAmountType())) {
|
| 1089 |
finalPayout = (eligiblePayoutValue * eligibleCriteriaSaleDp) / 100;
|
1095 |
finalPayout = (eligiblePayoutValue * eligibleCriteriaSaleDp) / 100;
|
| 1090 |
} else if (AmountType.FIXED.equals(itemCriteriaPayout.getAmountType())) {
|
1096 |
} else if (AmountType.FIXED.equals(itemCriteriaPayout.getAmountType())) {
|
| - |
|
1097 |
// FIXED = per piece, always use qty regardless of target type
|
| 1091 |
finalPayout = eligiblePayoutValue * eligibleCriteriaSale;
|
1098 |
finalPayout = eligiblePayoutValue * eligibleQty;
|
| 1092 |
} else {
|
1099 |
} else {
|
| 1093 |
Map<Integer, Double> fofoCriteriaMap = fixedSlabCriteriaPartnerMap.get(criteriaId);
|
1100 |
Map<Integer, Double> fofoCriteriaMap = fixedSlabCriteriaPartnerMap.get(criteriaId);
|
| 1094 |
LOGGER.info("fofoCriteriaMap {}", fofoCriteriaMap);
|
1101 |
LOGGER.info("fofoCriteriaMap {}", fofoCriteriaMap);
|
| 1095 |
finalPayout = eligiblePayoutValue;
|
1102 |
finalPayout = eligiblePayoutValue;
|
| 1096 |
if (fofoCriteriaMap != null) {
|
1103 |
if (fofoCriteriaMap != null) {
|
| Line 1278... |
Line 1285... |
| 1278 |
float eligiblePayoutValue = eligibleSlab.getPayoutAmount();
|
1285 |
float eligiblePayoutValue = eligibleSlab.getPayoutAmount();
|
| 1279 |
double finalPayout;
|
1286 |
double finalPayout;
|
| 1280 |
if (AmountType.PERCENTAGE.equals(itemCriteriaPayout.getAmountType())) {
|
1287 |
if (AmountType.PERCENTAGE.equals(itemCriteriaPayout.getAmountType())) {
|
| 1281 |
finalPayout = (eligiblePayoutValue * purchasedValue) / 100;
|
1288 |
finalPayout = (eligiblePayoutValue * purchasedValue) / 100;
|
| 1282 |
} else if (AmountType.FIXED.equals(itemCriteriaPayout.getAmountType())) {
|
1289 |
} else if (AmountType.FIXED.equals(itemCriteriaPayout.getAmountType())) {
|
| - |
|
1290 |
// FIXED = per piece, use per-criteria qty not base value
|
| 1283 |
finalPayout = eligiblePayoutValue * purchasedValue;
|
1291 |
finalPayout = eligiblePayoutValue * totalQty;
|
| 1284 |
} else {
|
1292 |
} else {
|
| 1285 |
Map<Integer, Double> fofoCriteriaPayoutMap = fixedSlabCriteriaPartnerMap.get(criteriaId);
|
1293 |
Map<Integer, Double> fofoCriteriaPayoutMap = fixedSlabCriteriaPartnerMap.get(criteriaId);
|
| 1286 |
LOGGER.info("fofoCriteriaMap {}", fofoCriteriaPayoutMap);
|
1294 |
LOGGER.info("fofoCriteriaMap {}", fofoCriteriaPayoutMap);
|
| 1287 |
finalPayout = eligiblePayoutValue;
|
1295 |
finalPayout = eligiblePayoutValue;
|
| 1288 |
if (fofoCriteriaPayoutMap != null && fofoCriteriaPayoutMap.containsKey(fofoId)) {
|
1296 |
if (fofoCriteriaPayoutMap != null && fofoCriteriaPayoutMap.containsKey(fofoId)) {
|