| Line 4... |
Line 4... |
| 4 |
import com.spice.profitmandi.common.enumuration.CounterSize;
|
4 |
import com.spice.profitmandi.common.enumuration.CounterSize;
|
| 5 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
5 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 6 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
6 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 7 |
import com.spice.profitmandi.common.model.*;
|
7 |
import com.spice.profitmandi.common.model.*;
|
| 8 |
import com.spice.profitmandi.common.util.FileUtil;
|
8 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 9 |
import com.spice.profitmandi.common.util.Utils;
|
- |
|
| 10 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
9 |
import com.spice.profitmandi.common.util.Utils.Attachment;
|
| 11 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
10 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 12 |
import com.spice.profitmandi.service.mail.MailOutboxService;
|
11 |
import com.spice.profitmandi.service.mail.MailOutboxService;
|
| 13 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
12 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 14 |
import com.spice.profitmandi.dao.entity.catalog.*;
|
13 |
import com.spice.profitmandi.dao.entity.catalog.*;
|
| Line 20... |
Line 19... |
| 20 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
19 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 21 |
import com.spice.profitmandi.dao.entity.transaction.SDCreditRequirement;
|
20 |
import com.spice.profitmandi.dao.entity.transaction.SDCreditRequirement;
|
| 22 |
import com.spice.profitmandi.dao.model.BulkCreditSummary;
|
21 |
import com.spice.profitmandi.dao.model.BulkCreditSummary;
|
| 23 |
import com.spice.profitmandi.service.transaction.SDCreditService;
|
22 |
import com.spice.profitmandi.service.transaction.SDCreditService;
|
| 24 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
23 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 25 |
import com.spice.profitmandi.dao.entity.user.User;
|
- |
|
| 26 |
import com.spice.profitmandi.dao.entity.warehouse.BrandRegionMapping;
|
24 |
import com.spice.profitmandi.dao.entity.warehouse.BrandRegionMapping;
|
| 27 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
25 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 28 |
import com.spice.profitmandi.dao.enumuration.inventory.CatalogMovingEnum;
|
26 |
import com.spice.profitmandi.dao.enumuration.inventory.CatalogMovingEnum;
|
| 29 |
import com.spice.profitmandi.dao.event.TagListingEventPublisher;
|
27 |
import com.spice.profitmandi.dao.event.TagListingEventPublisher;
|
| 30 |
import com.spice.profitmandi.dao.model.*;
|
28 |
import com.spice.profitmandi.dao.model.*;
|
| Line 52... |
Line 50... |
| 52 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
50 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 53 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
51 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
| 54 |
import com.spice.profitmandi.service.inventory.*;
|
52 |
import com.spice.profitmandi.service.inventory.*;
|
| 55 |
import com.spice.profitmandi.service.user.RetailerService;
|
53 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 56 |
import com.spice.profitmandi.service.wallet.WalletService;
|
54 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 57 |
import com.spice.profitmandi.thrift.clients.PaymentClient;
|
- |
|
| 58 |
import com.spice.profitmandi.thrift.clients.UserClient;
|
- |
|
| 59 |
import com.spice.profitmandi.web.model.LoginDetails;
|
55 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 60 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
56 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 61 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
57 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 62 |
import in.shop2020.model.v1.order.LineItem;
|
- |
|
| 63 |
import in.shop2020.model.v1.order.OrderStatus;
|
58 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 64 |
import in.shop2020.model.v1.order.Transaction;
|
- |
|
| 65 |
import in.shop2020.model.v1.user.ItemPriceQuantity;
|
- |
|
| 66 |
import in.shop2020.model.v1.user.ShoppingCartException;
|
- |
|
| 67 |
import in.shop2020.model.v1.user.UserContextService.Client;
|
- |
|
| 68 |
import in.shop2020.payments.Attribute;
|
- |
|
| 69 |
import in.shop2020.payments.PaymentException;
|
- |
|
| 70 |
import in.shop2020.payments.PaymentStatus;
|
- |
|
| 71 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
59 |
import org.apache.commons.io.output.ByteArrayOutputStream;
|
| 72 |
import org.apache.logging.log4j.LogManager;
|
60 |
import org.apache.logging.log4j.LogManager;
|
| 73 |
import org.apache.logging.log4j.Logger;
|
61 |
import org.apache.logging.log4j.Logger;
|
| 74 |
import org.apache.thrift.TException;
|
- |
|
| 75 |
import org.json.JSONArray;
|
62 |
import org.json.JSONArray;
|
| 76 |
import org.json.JSONObject;
|
63 |
import org.json.JSONObject;
|
| 77 |
import org.springframework.beans.factory.annotation.Autowired;
|
64 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 78 |
import org.springframework.core.io.ByteArrayResource;
|
65 |
import org.springframework.core.io.ByteArrayResource;
|
| 79 |
import org.springframework.http.HttpHeaders;
|
66 |
import org.springframework.http.HttpHeaders;
|
| Line 102... |
Line 89... |
| 102 |
@Controller
|
89 |
@Controller
|
| 103 |
@Transactional(rollbackFor = Throwable.class)
|
90 |
@Transactional(rollbackFor = Throwable.class)
|
| 104 |
public class IndentController {
|
91 |
public class IndentController {
|
| 105 |
|
92 |
|
| 106 |
private static final Logger LOGGER = LogManager.getLogger(IndentController.class);
|
93 |
private static final Logger LOGGER = LogManager.getLogger(IndentController.class);
|
| 107 |
private static final int WALLET_GATEWAY_ID = 8;
|
- |
|
| 108 |
private static final Set<Integer> defaultTags = new HashSet<Integer>(Arrays.asList(4));
|
94 |
private static final Set<Integer> defaultTags = new HashSet<Integer>(Arrays.asList(4));
|
| 109 |
|
95 |
|
| 110 |
private final List<OrderStatus> partnerPendingOrderList = Arrays.asList(OrderStatus.ACCEPTED,
|
96 |
private final List<OrderStatus> partnerPendingOrderList = Arrays.asList(OrderStatus.ACCEPTED,
|
| 111 |
OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.BILLED, OrderStatus.SHIPPED_FROM_WH,
|
97 |
OrderStatus.SUBMITTED_FOR_PROCESSING, OrderStatus.BILLED, OrderStatus.SHIPPED_FROM_WH,
|
| 112 |
OrderStatus.SHIPPED_TO_DESTINATION_CITY, OrderStatus.SHIPPED_TO_LOGST,
|
98 |
OrderStatus.SHIPPED_TO_DESTINATION_CITY, OrderStatus.SHIPPED_TO_LOGST,
|
| Line 667... |
Line 653... |
| 667 |
|
653 |
|
| 668 |
model.addAttribute("response1", true);
|
654 |
model.addAttribute("response1", true);
|
| 669 |
return "response";
|
655 |
return "response";
|
| 670 |
}
|
656 |
}
|
| 671 |
|
657 |
|
| 672 |
private void createPayment(User user, double totalAmount, long transactionId)
|
- |
|
| 673 |
throws NumberFormatException, PaymentException, TException {
|
- |
|
| 674 |
List<Attribute> paymentAttributes = new ArrayList<Attribute>();
|
- |
|
| 675 |
in.shop2020.payments.PaymentService.Client paymentClient = new PaymentClient().getClient();
|
- |
|
| 676 |
paymentAttributes.add(new Attribute("payMethod", "7890"));
|
- |
|
| 677 |
long paymentId = paymentClient.createPayment(user.getId(), totalAmount, WALLET_GATEWAY_ID, transactionId,
|
- |
|
| 678 |
false);
|
- |
|
| 679 |
paymentClient.updatePaymentDetails(paymentId, null, null, null, null, null, null, null, null,
|
- |
|
| 680 |
PaymentStatus.SUCCESS, null, paymentAttributes);
|
- |
|
| 681 |
}
|
- |
|
| 682 |
|
- |
|
| 683 |
@RequestMapping(value = "/indent/loadIndent")
|
658 |
@RequestMapping(value = "/indent/loadIndent")
|
| 684 |
public String loadOpenIndent(HttpServletRequest request, Model model,
|
659 |
public String loadOpenIndent(HttpServletRequest request, Model model,
|
| 685 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
660 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
| 686 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
661 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
| 687 |
|
662 |
|
| Line 934... |
Line 909... |
| 934 |
model.addAttribute("totalPcs", totalPcs);
|
909 |
model.addAttribute("totalPcs", totalPcs);
|
| 935 |
return "open-indent";
|
910 |
return "open-indent";
|
| 936 |
|
911 |
|
| 937 |
}
|
912 |
}
|
| 938 |
|
913 |
|
| 939 |
private long resetCart(Transaction transaction) {
|
- |
|
| 940 |
long sum = 0;
|
- |
|
| 941 |
Map<Long, Double> items = new HashMap<Long, Double>();
|
- |
|
| 942 |
for (in.shop2020.model.v1.order.Order order : transaction.getOrders()) {
|
- |
|
| 943 |
sum += order.getGvAmount();
|
- |
|
| 944 |
for (LineItem lineitem : order.getLineitems()) {
|
- |
|
| 945 |
Long itemId = lineitem.getItem_id();
|
- |
|
| 946 |
Double quantity = items.get(itemId);
|
- |
|
| 947 |
if (quantity == null) {
|
- |
|
| 948 |
quantity = lineitem.getQuantity();
|
- |
|
| 949 |
} else {
|
- |
|
| 950 |
quantity = quantity + lineitem.getQuantity();
|
- |
|
| 951 |
}
|
- |
|
| 952 |
items.put(itemId, quantity);
|
- |
|
| 953 |
}
|
- |
|
| 954 |
}
|
- |
|
| 955 |
|
- |
|
| 956 |
LOGGER.debug("Items to reset in cart are: " + items);
|
- |
|
| 957 |
|
- |
|
| 958 |
try {
|
- |
|
| 959 |
Client userClient = new UserClient().getClient();
|
- |
|
| 960 |
userClient.resetCart(transaction.getShoppingCartid(), items);
|
- |
|
| 961 |
} catch (TException e) {
|
- |
|
| 962 |
LOGGER.error("Error while updating information in payment database.", e);
|
- |
|
| 963 |
} catch (ShoppingCartException e) {
|
- |
|
| 964 |
LOGGER.error("Error while reseting the cart in cart database.", e);
|
- |
|
| 965 |
} catch (Exception e) {
|
- |
|
| 966 |
LOGGER.error("Unexpected exception", e);
|
- |
|
| 967 |
}
|
- |
|
| 968 |
return sum;
|
- |
|
| 969 |
}
|
- |
|
| 970 |
|
- |
|
| 971 |
private List<ItemPriceQuantity> getItemQuantities(int fofoId) throws ProfitMandiBusinessException {
|
- |
|
| 972 |
List<ItemPriceQuantity> itemQuantities = new ArrayList<>();
|
- |
|
| 973 |
/*
|
- |
|
| 974 |
* Map<Integer, ItemIdAvailability> itemCisMap = null; List<ItemIdAvailability>
|
- |
|
| 975 |
* currentInventorySnapshots = currentInventorySnapshotRepository
|
- |
|
| 976 |
* .selectItemsStock(fofoId); itemCisMap =
|
- |
|
| 977 |
* currentInventorySnapshots.stream().filter(x -> x.getAvailability() > 0)
|
- |
|
| 978 |
* .collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
- |
|
| 979 |
* List<StockAllocationModel> stockAllocationList =
|
- |
|
| 980 |
* stockAllocationService.getStockAllocation(fofoId, true);
|
- |
|
| 981 |
*
|
- |
|
| 982 |
* Map<Integer, StockAllocationModel> itemStockAllocationMap =
|
- |
|
| 983 |
* stockAllocationList.stream() .collect(Collectors.toMap(x -> x.catalogId(), x
|
- |
|
| 984 |
* -> x)); Map<Integer, Integer> itemsInTransit = null;
|
- |
|
| 985 |
* LOGGER.info("Item Stock Allocation Model Map {}", itemStockAllocationMap);
|
- |
|
| 986 |
* List<TagListing> tagListings = tagListingRepository.selectAll(false);
|
- |
|
| 987 |
* List<Order> inTransitOrders = orderRepository.selectOrders(fofoId,
|
- |
|
| 988 |
* validOrderStatusList); inTransitOrders =
|
- |
|
| 989 |
* this.filterValidOrders(inTransitOrders); itemsInTransit =
|
- |
|
| 990 |
* inTransitOrders.stream().collect(Collectors.groupingBy(x ->
|
- |
|
| 991 |
* x.getLineItem().getItemId(), Collectors.summingInt(x ->
|
- |
|
| 992 |
* x.getLineItem().getQuantity())));
|
- |
|
| 993 |
*
|
- |
|
| 994 |
* Iterator<TagListing> iterator = tagListings.iterator();
|
- |
|
| 995 |
*
|
- |
|
| 996 |
* int toBeOrdered = 0; while (iterator.hasNext()) { TagListing tagListing =
|
- |
|
| 997 |
* iterator.next(); LOGGER.info(" tagListing.setAllocatedQuantity {}",
|
- |
|
| 998 |
* tagListing.getAllocatedQuantity()); if
|
- |
|
| 999 |
* (!itemCisMap.containsKey(tagListing.getItemId()) &&
|
- |
|
| 1000 |
* !itemStockAllocationMap.containsKey(tagListing.getItemId())) {
|
- |
|
| 1001 |
* iterator.remove(); continue; } ItemIdAvailability itemIdAvailability =
|
- |
|
| 1002 |
* itemCisMap.get(tagListing.getItemId());
|
- |
|
| 1003 |
* tagListing.setStockInHand(itemIdAvailability == null ? 0 :
|
- |
|
| 1004 |
* itemIdAvailability.getAvailability()); StockAllocationModel
|
- |
|
| 1005 |
* stockAllocationModel = itemStockAllocationMap.get(tagListing.getItemId());
|
- |
|
| 1006 |
*
|
- |
|
| 1007 |
* if (itemsInTransit.containsKey(tagListing.getItemId())) {
|
- |
|
| 1008 |
* tagListing.setInTransitQuantity(itemsInTransit.get(tagListing.getItemId()));
|
- |
|
| 1009 |
* } else { tagListing.setInTransitQuantity(0); } if (stockAllocationModel !=
|
- |
|
| 1010 |
* null) { tagListing.setAllocatedQuantity(stockAllocationModel.getQuantity());
|
- |
|
| 1011 |
* toBeOrdered = Math.max(tagListing.getAllocatedQuantity() -
|
- |
|
| 1012 |
* tagListing.getInTransitQuantity() - tagListing.getStockInHand(), 0); if
|
- |
|
| 1013 |
* (toBeOrdered > 0) { ItemPriceQuantity ipq = new ItemPriceQuantity();
|
- |
|
| 1014 |
* ipq.setItemId(tagListing.getItemId()); ipq.setQty((long) toBeOrdered);
|
- |
|
| 1015 |
* ipq.setPrice(tagListing.getSellingPrice()); itemQuantities.add(ipq); } } }
|
- |
|
| 1016 |
*/
|
- |
|
| 1017 |
return itemQuantities;
|
- |
|
| 1018 |
|
- |
|
| 1019 |
}
|
- |
|
| 1020 |
|
- |
|
| 1021 |
@RequestMapping(value = "/indent/loadIndentPreviousMonth")
|
914 |
@RequestMapping(value = "/indent/loadIndentPreviousMonth")
|
| 1022 |
public String previousMonthLoadOpenIndent(HttpServletRequest request, Model model,
|
915 |
public String previousMonthLoadOpenIndent(HttpServletRequest request, Model model,
|
| 1023 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
916 |
@RequestParam(required = false, defaultValue = "0") int fofoId,
|
| 1024 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
917 |
@RequestParam(defaultValue = "TEN_LAC") CounterSize counterSize) throws Exception {
|
| 1025 |
LocalDate planMonthStart = null;
|
918 |
LocalDate planMonthStart = null;
|