| Line 6... |
Line 6... |
| 6 |
import com.spice.profitmandi.common.model.*;
|
6 |
import com.spice.profitmandi.common.model.*;
|
| 7 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
7 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 8 |
import com.spice.profitmandi.common.util.StringUtils;
|
8 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 9 |
import com.spice.profitmandi.common.util.Utils;
|
9 |
import com.spice.profitmandi.common.util.Utils;
|
| 10 |
import com.spice.profitmandi.common.web.client.RestClient;
|
10 |
import com.spice.profitmandi.common.web.client.RestClient;
|
| - |
|
11 |
import com.spice.profitmandi.dao.entity.catalog.CustomerOfferItem;
|
| 11 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
12 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 12 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
13 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| - |
|
14 |
import com.spice.profitmandi.dao.entity.catalog.UpgradeOffer;
|
| 13 |
import com.spice.profitmandi.dao.entity.dtr.*;
|
15 |
import com.spice.profitmandi.dao.entity.dtr.*;
|
| 14 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
16 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
| 15 |
import com.spice.profitmandi.dao.entity.inventory.State;
|
17 |
import com.spice.profitmandi.dao.entity.inventory.State;
|
| 16 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
18 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 17 |
import com.spice.profitmandi.dao.entity.user.Address;
|
19 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| Line 23... |
Line 25... |
| 23 |
import com.spice.profitmandi.dao.enumuration.fofo.ReturnType;
|
25 |
import com.spice.profitmandi.dao.enumuration.fofo.ReturnType;
|
| 24 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
26 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
| 25 |
import com.spice.profitmandi.dao.enumuration.fofo.SettlementType;
|
27 |
import com.spice.profitmandi.dao.enumuration.fofo.SettlementType;
|
| 26 |
import com.spice.profitmandi.dao.enumuration.inventory.ScratchedGift;
|
28 |
import com.spice.profitmandi.dao.enumuration.inventory.ScratchedGift;
|
| 27 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
29 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
| 28 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
30 |
import com.spice.profitmandi.dao.repository.catalog.*;
|
| 29 |
import com.spice.profitmandi.dao.repository.catalog.StateGstRateRepository;
|
- |
|
| 30 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
- |
|
| 31 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
31 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
| 32 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
32 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
| 33 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
33 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| 34 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
34 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 35 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
35 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| Line 238... |
Line 238... |
| 238 |
RestClient restClient;
|
238 |
RestClient restClient;
|
| 239 |
|
239 |
|
| 240 |
@Autowired
|
240 |
@Autowired
|
| 241 |
UpSaleOrderRepository upSaleOrderRepository;
|
241 |
UpSaleOrderRepository upSaleOrderRepository;
|
| 242 |
|
242 |
|
| - |
|
243 |
@Autowired
|
| - |
|
244 |
private CustomerOfferRepository customerOfferRepository;
|
| - |
|
245 |
|
| - |
|
246 |
@Autowired
|
| - |
|
247 |
private CustomerOfferItemRepository customerOfferItemRepository;
|
| - |
|
248 |
|
| - |
|
249 |
@Autowired
|
| - |
|
250 |
private UpgradeOfferRepository upgradeOfferRepository;
|
| - |
|
251 |
|
| 243 |
@Value("${prod}")
|
252 |
@Value("${prod}")
|
| 244 |
private boolean prodEnv;
|
253 |
private boolean prodEnv;
|
| 245 |
|
254 |
|
| 246 |
private static final String SMS_GATEWAY = "http://api.pinnacle.in/index.php/sms/send";
|
255 |
private static final String SMS_GATEWAY = "http://api.pinnacle.in/index.php/sms/send";
|
| 247 |
private static final String SENDER = "SMTDKN";
|
256 |
private static final String SENDER = "SMTDKN";
|
| Line 584... |
Line 593... |
| 584 |
|
593 |
|
| 585 |
}
|
594 |
}
|
| 586 |
//Process scratch
|
595 |
//Process scratch
|
| 587 |
this.processScratchOffer(fofoOrder);
|
596 |
this.processScratchOffer(fofoOrder);
|
| 588 |
|
597 |
|
| - |
|
598 |
// persist the data of upgrade offer table
|
| - |
|
599 |
for (CustomFofoOrderItem customFofoOrderItem : createOrderRequest.getFofoOrderItems()) {
|
| - |
|
600 |
if (customFofoOrderItem.getCustomerOfferItemId() > 0) {
|
| - |
|
601 |
UpgradeOffer upgradeOffer = new UpgradeOffer();
|
| - |
|
602 |
upgradeOffer.setOrderId(fofoOrder.getId());
|
| - |
|
603 |
upgradeOffer.setCustomerOfferItemId(customFofoOrderItem.getCustomerOfferItemId());
|
| - |
|
604 |
upgradeOffer.setItemId(customFofoOrderItem.getItemId());
|
| - |
|
605 |
|
| - |
|
606 |
Set<SerialNumberDetail> serialNumberDetails = customFofoOrderItem.getSerialNumberDetails();
|
| - |
|
607 |
|
| - |
|
608 |
if (!customFofoOrderItem.getSerialNumberDetails().isEmpty()) {
|
| - |
|
609 |
String serialNumber = serialNumberDetails.iterator().next().getSerialNumber();
|
| - |
|
610 |
upgradeOffer.setSerialNumber(serialNumber);
|
| - |
|
611 |
|
| - |
|
612 |
// Set<String> serialNumbersSet = this.serialNumberDetailsToSerialNumbers(customFofoOrderItem.getSerialNumberDetails());
|
| - |
|
613 |
// LOGGER.info("serialNumbersSet.toString() {}",serialNumbersSet.toString());
|
| - |
|
614 |
// upgradeOffer.setSerialNumber(serialNumbersSet.toString());
|
| - |
|
615 |
} else {
|
| - |
|
616 |
upgradeOffer.setSerialNumber(null); // Handle case where there is no serial number detail
|
| - |
|
617 |
}
|
| - |
|
618 |
upgradeOffer.setCreatedTimestamp(LocalDateTime.now());
|
| - |
|
619 |
upgradeOfferRepository.persist(upgradeOffer);
|
| - |
|
620 |
}
|
| - |
|
621 |
}
|
| - |
|
622 |
|
| 589 |
// unable it fo upsell call
|
623 |
// enable it fo upsell call
|
| 590 |
if (smartPhone) {
|
624 |
if (smartPhone) {
|
| 591 |
if (fofoOrder.getId() > 0) {
|
625 |
if (fofoOrder.getId() > 0) {
|
| 592 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository
|
626 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository
|
| 593 |
.selectByRetailerIdInvoiceNumber(fofoOrder.getInvoiceNumber());
|
627 |
.selectByRetailerIdInvoiceNumber(fofoOrder.getInvoiceNumber());
|
| 594 |
if (insurancePolicies.isEmpty()) {
|
628 |
if (insurancePolicies.isEmpty()) {
|
| Line 1159... |
Line 1193... |
| 1159 |
List<PaymentOptionTransaction> paymentOptionTransactions = paymentOptionTransactionRepository.selectByReferenceIdAndTypes(fofoOrder.getId(), Arrays.asList(PaymentOptionReferenceType.ORDER, PaymentOptionReferenceType.INSURANCE));
|
1193 |
List<PaymentOptionTransaction> paymentOptionTransactions = paymentOptionTransactionRepository.selectByReferenceIdAndTypes(fofoOrder.getId(), Arrays.asList(PaymentOptionReferenceType.ORDER, PaymentOptionReferenceType.INSURANCE));
|
| 1160 |
|
1194 |
|
| 1161 |
List<CustomPaymentOption> paymentOptions = new ArrayList<>();
|
1195 |
List<CustomPaymentOption> paymentOptions = new ArrayList<>();
|
| 1162 |
|
1196 |
|
| 1163 |
InvoicePdfModel pdfModel = new InvoicePdfModel();
|
1197 |
InvoicePdfModel pdfModel = new InvoicePdfModel();
|
| - |
|
1198 |
|
| - |
|
1199 |
|
| - |
|
1200 |
List<FofoOrderItem> fofoOrderItems = this.getByOrderId(fofoOrder.getId());
|
| - |
|
1201 |
|
| - |
|
1202 |
double upgradePartnerDiscount = 0;
|
| - |
|
1203 |
|
| - |
|
1204 |
for (FofoOrderItem fofoOrderItem : fofoOrderItems) {
|
| - |
|
1205 |
|
| - |
|
1206 |
Set<String> serialNumbers = this.toSerialNumbers(fofoOrderItem.getFofoLineItems());
|
| - |
|
1207 |
for (String serialNumber : serialNumbers) {
|
| - |
|
1208 |
UpgradeOffer upgradeOffer = upgradeOfferRepository.selectBySerialNumber(serialNumber);
|
| - |
|
1209 |
if (upgradeOffer != null) {
|
| - |
|
1210 |
CustomerOfferItem customerOfferItem = customerOfferItemRepository.selectById(upgradeOffer.getCustomerOfferItemId());
|
| - |
|
1211 |
upgradePartnerDiscount += customerOfferItem.getDealerPayout();
|
| - |
|
1212 |
} else {
|
| - |
|
1213 |
upgradePartnerDiscount += 0;
|
| - |
|
1214 |
}
|
| - |
|
1215 |
}
|
| - |
|
1216 |
|
| - |
|
1217 |
|
| - |
|
1218 |
}
|
| - |
|
1219 |
|
| - |
|
1220 |
boolean hasSamsungUpgrade = paymentOptionTransactions.stream()
|
| - |
|
1221 |
.anyMatch(transaction ->
|
| - |
|
1222 |
"SAMSUNG UPGRADE".equals(paymentOptionRepository
|
| - |
|
1223 |
.selectById(transaction.getPaymentOptionId())
|
| - |
|
1224 |
.getName()));
|
| - |
|
1225 |
|
| - |
|
1226 |
LOGGER.info("paymentOptionTransactions - {}", paymentOptionTransactions);
|
| - |
|
1227 |
LOGGER.info("hasSamsungUpgrade - {}", hasSamsungUpgrade);
|
| - |
|
1228 |
|
| - |
|
1229 |
double cashDiscount = paymentOptionTransactions.stream()
|
| - |
|
1230 |
.filter(x -> "CASH DISCOUNT".equals(paymentOptionRepository.selectById(x.getPaymentOptionId()).getName())).mapToDouble(x -> x.getAmount()).findFirst().orElse(0);
|
| - |
|
1231 |
|
| - |
|
1232 |
LOGGER.info("cashDiscount - {}", cashDiscount);
|
| - |
|
1233 |
|
| 1164 |
for (PaymentOptionTransaction paymentOptionTransaction : paymentOptionTransactions) {
|
1234 |
for (PaymentOptionTransaction paymentOptionTransaction : paymentOptionTransactions) {
|
| - |
|
1235 |
String paymentOptionName = paymentOptionRepository.selectById(paymentOptionTransaction.getPaymentOptionId()).getName();
|
| - |
|
1236 |
|
| 1165 |
CustomPaymentOption cpi = new CustomPaymentOption();
|
1237 |
CustomPaymentOption cpi = new CustomPaymentOption();
|
| - |
|
1238 |
LOGGER.info("paymentOptionName {}", paymentOptionName);
|
| - |
|
1239 |
|
| 1166 |
cpi.setAmount(paymentOptionTransaction.getAmount());
|
1240 |
float amountToSet = paymentOptionTransaction.getAmount();
|
| - |
|
1241 |
|
| - |
|
1242 |
if ("SAMSUNG UPGRADE".equals(paymentOptionName) && hasSamsungUpgrade) {
|
| - |
|
1243 |
if (cashDiscount > upgradePartnerDiscount) {
|
| - |
|
1244 |
amountToSet += (float) upgradePartnerDiscount;
|
| - |
|
1245 |
} else {
|
| - |
|
1246 |
amountToSet += (float) cashDiscount;
|
| - |
|
1247 |
}
|
| - |
|
1248 |
|
| - |
|
1249 |
} else if ("CASH".equals(paymentOptionName) && !hasSamsungUpgrade) {
|
| - |
|
1250 |
amountToSet += ((float) cashDiscount - (float) upgradePartnerDiscount);
|
| - |
|
1251 |
|
| - |
|
1252 |
} else if ("CASH".equals(paymentOptionName) && hasSamsungUpgrade && (cashDiscount > upgradePartnerDiscount)) {
|
| - |
|
1253 |
amountToSet += ((float) cashDiscount - (float) upgradePartnerDiscount);
|
| - |
|
1254 |
|
| - |
|
1255 |
}
|
| - |
|
1256 |
|
| 1167 |
cpi.setPaymentOption(
|
1257 |
cpi.setAmount(amountToSet);
|
| 1168 |
paymentOptionRepository.selectById(paymentOptionTransaction.getPaymentOptionId()).getName());
|
1258 |
cpi.setPaymentOption(paymentOptionName);
|
| - |
|
1259 |
|
| 1169 |
paymentOptions.add(cpi);
|
1260 |
paymentOptions.add(cpi);
|
| 1170 |
}
|
1261 |
}
|
| 1171 |
List<FofoOrderItem> fofoOrderItems = this.getByOrderId(fofoOrder.getId());
|
- |
|
| - |
|
1262 |
|
| 1172 |
|
1263 |
|
| 1173 |
pdfModel.setTitle("Retailer Invoice");
|
1264 |
pdfModel.setTitle("Retailer Invoice");
|
| 1174 |
Optional<FofoOrderItem> fofoOrderItemOptional = fofoOrderItems.stream().findAny();
|
1265 |
Optional<FofoOrderItem> fofoOrderItemOptional = fofoOrderItems.stream().findAny();
|
| 1175 |
if (fofoOrderItemOptional.isPresent() && fofoOrderItemOptional.get().equals("NOGST")) {
|
1266 |
if (fofoOrderItemOptional.isPresent() && fofoOrderItemOptional.get().equals("NOGST")) {
|
| 1176 |
pdfModel.setTitle("Security Deposit Receipt");
|
1267 |
pdfModel.setTitle("Security Deposit Receipt");
|
| Line 1289... |
Line 1380... |
| 1289 |
tncs.add("I agree that goods received are in good working condition");
|
1380 |
tncs.add("I agree that goods received are in good working condition");
|
| 1290 |
tncs.add("Goods once sold cannot be exchanged or taken back");
|
1381 |
tncs.add("Goods once sold cannot be exchanged or taken back");
|
| 1291 |
tncs.add("Warranty for the goods received by me is the responsibility of the manufacturer only.");
|
1382 |
tncs.add("Warranty for the goods received by me is the responsibility of the manufacturer only.");
|
| 1292 |
tncs.add("Customer needs to activate the handset at the time of delivery to be eligible for the discount");
|
1383 |
tncs.add("Customer needs to activate the handset at the time of delivery to be eligible for the discount");
|
| 1293 |
tncs.add(
|
1384 |
tncs.add(
|
| 1294 |
"Tempered Glass Replacement will be done only for the Mobile Phone which was purchased from SmartDukaan");
|
- |
|
| 1295 |
tncs.add(
|
- |
|
| 1296 |
"Customers requesting Tempered Glass Replacement will have to bring the broken tempered glass, either pasted on the phone or along with the phone");
|
1385 |
"Customers requesting Tempered Glass Replacement will have to bring the broken tempered glass, either pasted on the phone or along with the phone");
|
| 1297 |
tncs.add("Service fee of Rs.20 will be chargeable for each Tempered Glass Replacement");
|
1386 |
tncs.add("Service fee of Rs.20 will be chargeable for each Tempered Glass Replacement");
|
| 1298 |
if (pdfModel.getInsurancePolicies() != null && pdfModel.getInsurancePolicies().size() > 0) {
|
1387 |
if (pdfModel.getInsurancePolicies() != null && pdfModel.getInsurancePolicies().size() > 0) {
|
| 1299 |
tncs.add("Damage protection provided is the responisibility of Protection Provider only");
|
1388 |
tncs.add("Damage protection provided is the responisibility of Protection Provider only");
|
| 1300 |
}
|
1389 |
}
|