| Line 52... |
Line 52... |
| 52 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
52 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
| 53 |
import com.spice.profitmandi.service.inventory.StockAllocationService;
|
53 |
import com.spice.profitmandi.service.inventory.StockAllocationService;
|
| 54 |
import com.spice.profitmandi.service.user.RetailerService;
|
54 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 55 |
import com.spice.profitmandi.service.wallet.WalletService;
|
55 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 56 |
import com.spice.profitmandi.thrift.clients.PaymentClient;
|
56 |
import com.spice.profitmandi.thrift.clients.PaymentClient;
|
| 57 |
import com.spice.profitmandi.thrift.clients.TransactionClient;
|
- |
|
| 58 |
import com.spice.profitmandi.thrift.clients.UserClient;
|
57 |
import com.spice.profitmandi.thrift.clients.UserClient;
|
| 59 |
import com.spice.profitmandi.web.model.LoginDetails;
|
58 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 60 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
59 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 61 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
60 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 62 |
import in.shop2020.logistics.PickUpType;
|
61 |
import in.shop2020.model.v1.order.LineItem;
|
| - |
|
62 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 63 |
import in.shop2020.model.v1.order.*;
|
63 |
import in.shop2020.model.v1.order.Transaction;
|
| 64 |
import in.shop2020.model.v1.user.ItemPriceQuantity;
|
64 |
import in.shop2020.model.v1.user.ItemPriceQuantity;
|
| 65 |
import in.shop2020.model.v1.user.ShoppingCartException;
|
65 |
import in.shop2020.model.v1.user.ShoppingCartException;
|
| 66 |
import in.shop2020.model.v1.user.UserContextService.Client;
|
66 |
import in.shop2020.model.v1.user.UserContextService.Client;
|
| 67 |
import in.shop2020.payments.Attribute;
|
67 |
import in.shop2020.payments.Attribute;
|
| 68 |
import in.shop2020.payments.PaymentException;
|
68 |
import in.shop2020.payments.PaymentException;
|
| Line 590... |
Line 590... |
| 590 |
}
|
590 |
}
|
| 591 |
model.addAttribute("response1", true);
|
591 |
model.addAttribute("response1", true);
|
| 592 |
return "response";
|
592 |
return "response";
|
| 593 |
}
|
593 |
}
|
| 594 |
|
594 |
|
| 595 |
@RequestMapping(value = "/indent/create-po", method = RequestMethod.POST)
|
- |
|
| 596 |
public String raisePO(HttpServletRequest request, Model model) throws Exception {
|
- |
|
| 597 |
boolean success = false;
|
- |
|
| 598 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
- |
|
| 599 |
int fofoId = loginDetails.getFofoId();
|
- |
|
| 600 |
List<ItemPriceQuantity> itemQuantities = this.getItemQuantities(fofoId);
|
- |
|
| 601 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
- |
|
| 602 |
Client userClient = new UserClient().getClient();
|
- |
|
| 603 |
double totalAmount = itemQuantities.stream().mapToDouble(x -> x.getQty() * x.getPrice()).sum();
|
- |
|
| 604 |
|
- |
|
| 605 |
if (totalAmount > 0) {
|
- |
|
| 606 |
userClient.addItemPricingToCart(customRetailer.getCartId(), itemQuantities);
|
- |
|
| 607 |
User user = userRepository.selectById(loginDetails.getFofoId());
|
- |
|
| 608 |
userClient = new UserClient().getClient();
|
- |
|
| 609 |
LOGGER.info("Setting wallet amount in cart");
|
- |
|
| 610 |
long transactionId = userClient.createOrders(user.getActiveCartId(), "", 0, "", 0, loginDetails.getFofoId(),
|
- |
|
| 611 |
7890, OrderSource.WEBSITE.getValue(), true);
|
- |
|
| 612 |
LOGGER.info("Creating wallet payment for transactionId - {}", transactionId);
|
- |
|
| 613 |
createPayment(user, totalAmount, transactionId);
|
- |
|
| 614 |
TransactionService.Client transactionClient = new TransactionClient().getClient();
|
- |
|
| 615 |
transactionClient.changeTransactionStatus(transactionId, TransactionStatus.AUTHORIZED,
|
- |
|
| 616 |
"Payment received for the order", PickUpType.RUNNER.getValue(), OrderType.B2B, OrderSource.WEBSITE);
|
- |
|
| 617 |
transactionClient.changeTransactionStatus(Long.valueOf(transactionId), TransactionStatus.IN_PROCESS,
|
- |
|
| 618 |
"Paid fully through wallet", PickUpType.RUNNER.getValue(), OrderType.B2B, OrderSource.WEBSITE);
|
- |
|
| 619 |
LOGGER.info("Successfully created transaction: " + transactionId + " for amount: " + totalAmount);
|
- |
|
| 620 |
transactionClient = new TransactionClient().getClient();
|
- |
|
| 621 |
transactionClient.markOrderForRegisteredGstInvoice(Collections.singletonList(Long.valueOf(transactionId)));
|
- |
|
| 622 |
try {
|
- |
|
| 623 |
transactionClient.enqueueTransactionInfoEmail(transactionId);
|
- |
|
| 624 |
} catch (Exception e1) {
|
- |
|
| 625 |
e1.printStackTrace();
|
- |
|
| 626 |
LOGGER.error("Unable to update status of transaction. Thrift Exception:", e1);
|
- |
|
| 627 |
}
|
- |
|
| 628 |
resetCart(transactionClient.getTransaction(transactionId));
|
- |
|
| 629 |
}
|
- |
|
| 630 |
model.addAttribute("response1", mvcResponseSender.createResponseString(success));
|
- |
|
| 631 |
return "response";
|
- |
|
| 632 |
}
|
- |
|
| 633 |
|
- |
|
| 634 |
private void createPayment(User user, double totalAmount, long transactionId)
|
595 |
private void createPayment(User user, double totalAmount, long transactionId)
|
| 635 |
throws NumberFormatException, PaymentException, TException {
|
596 |
throws NumberFormatException, PaymentException, TException {
|
| 636 |
List<Attribute> paymentAttributes = new ArrayList<Attribute>();
|
597 |
List<Attribute> paymentAttributes = new ArrayList<Attribute>();
|
| 637 |
in.shop2020.payments.PaymentService.Client paymentClient = new PaymentClient().getClient();
|
598 |
in.shop2020.payments.PaymentService.Client paymentClient = new PaymentClient().getClient();
|
| 638 |
paymentAttributes.add(new Attribute("payMethod", "7890"));
|
599 |
paymentAttributes.add(new Attribute("payMethod", "7890"));
|
| Line 1722... |
Line 1683... |
| 1722 |
public String getPartnersBrandWiseDetail(HttpServletRequest request, Model model) throws Exception {
|
1683 |
public String getPartnersBrandWiseDetail(HttpServletRequest request, Model model) throws Exception {
|
| 1723 |
|
1684 |
|
| 1724 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
1685 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 1725 |
String email = loginDetails.getEmailId();
|
1686 |
String email = loginDetails.getEmailId();
|
| 1726 |
|
1687 |
|
| 1727 |
List<String> brands = Arrays.asList("Vivo", "Samsung", "Oppo", "Tecno", "Itel", "OnePlus", "Lava", "Realme",
|
1688 |
List<String> brands = Arrays.asList("Vivo", "Samsung", "Oppo", "Tecno", "POCO", "Itel", "OnePlus", "Lava", "Realme",
|
| 1728 |
"Xiaomi", "Nokia");
|
1689 |
"Xiaomi", "Nokia");
|
| 1729 |
|
1690 |
|
| 1730 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
1691 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
| 1731 |
Set<Integer> fofoIds = csService1.getAuthFofoIds(email, true);
|
1692 |
Set<Integer> fofoIds = csService1.getAuthFofoIds(email, true);
|
| 1732 |
|
1693 |
|