| Line 4... |
Line 4... |
| 4 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
4 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 5 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
5 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 6 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
6 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 7 |
import com.spice.profitmandi.dao.entity.cs.PartnerRegion;
|
7 |
import com.spice.profitmandi.dao.entity.cs.PartnerRegion;
|
| 8 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
8 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| - |
|
9 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| 9 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
|
10 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCISTable;
|
| 10 |
import com.spice.profitmandi.dao.entity.user.Cart;
|
11 |
import com.spice.profitmandi.dao.entity.user.Cart;
|
| 11 |
import com.spice.profitmandi.dao.entity.user.CartLine;
|
12 |
import com.spice.profitmandi.dao.entity.user.CartLine;
|
| 12 |
import com.spice.profitmandi.dao.entity.user.User;
|
13 |
import com.spice.profitmandi.dao.entity.user.User;
|
| 13 |
import com.spice.profitmandi.dao.model.*;
|
14 |
import com.spice.profitmandi.dao.model.*;
|
| Line 16... |
Line 17... |
| 16 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
17 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 17 |
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
|
18 |
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
|
| 18 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
19 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 19 |
import com.spice.profitmandi.dao.repository.dtr.RetailerBlockBrandsRepository;
|
20 |
import com.spice.profitmandi.dao.repository.dtr.RetailerBlockBrandsRepository;
|
| 20 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
21 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| - |
|
22 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| 21 |
import com.spice.profitmandi.dao.repository.inventory.SaholicCISTableRepository;
|
23 |
import com.spice.profitmandi.dao.repository.inventory.SaholicCISTableRepository;
|
| 22 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
24 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 23 |
import com.spice.profitmandi.dao.repository.user.CartLineRepository;
|
25 |
import com.spice.profitmandi.dao.repository.user.CartLineRepository;
|
| 24 |
import com.spice.profitmandi.dao.repository.user.CartRepository;
|
26 |
import com.spice.profitmandi.dao.repository.user.CartRepository;
|
| 25 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
27 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| Line 32... |
Line 34... |
| 32 |
import org.apache.logging.log4j.LogManager;
|
34 |
import org.apache.logging.log4j.LogManager;
|
| 33 |
import org.apache.logging.log4j.Logger;
|
35 |
import org.apache.logging.log4j.Logger;
|
| 34 |
import org.springframework.beans.factory.annotation.Autowired;
|
36 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 35 |
import org.springframework.stereotype.Component;
|
37 |
import org.springframework.stereotype.Component;
|
| 36 |
|
38 |
|
| - |
|
39 |
import java.time.LocalDate;
|
| 37 |
import java.time.LocalDateTime;
|
40 |
import java.time.LocalDateTime;
|
| 38 |
import java.util.*;
|
41 |
import java.util.*;
|
| 39 |
import java.util.Map.Entry;
|
42 |
import java.util.Map.Entry;
|
| 40 |
import java.util.stream.Collectors;
|
43 |
import java.util.stream.Collectors;
|
| 41 |
|
44 |
|
| Line 94... |
Line 97... |
| 94 |
private SaholicCISTableRepository saholicCISTableRepository;
|
97 |
private SaholicCISTableRepository saholicCISTableRepository;
|
| 95 |
|
98 |
|
| 96 |
@Autowired
|
99 |
@Autowired
|
| 97 |
private BrandRegionMappingRepository brandRegionMappingRepository;
|
100 |
private BrandRegionMappingRepository brandRegionMappingRepository;
|
| 98 |
|
101 |
|
| - |
|
102 |
@Autowired
|
| - |
|
103 |
private PartnerTypeChangeService partnerTypeChangeService;
|
| - |
|
104 |
|
| 99 |
@Override
|
105 |
@Override
|
| 100 |
// Unused method
|
106 |
// Unused method
|
| 101 |
public CartModel addToCart(int cartId, int itemId, int quantity, float sellingPrice) {
|
107 |
public CartModel addToCart(int cartId, int itemId, int quantity, float sellingPrice) {
|
| 102 |
CartLine cartItem = cartLineRepository.selectByCartItem(cartId, itemId);
|
108 |
CartLine cartItem = cartLineRepository.selectByCartItem(cartId, itemId);
|
| 103 |
if (cartItem == null) {
|
109 |
if (cartItem == null) {
|
| Line 198... |
Line 204... |
| 198 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
204 |
.collect(Collectors.toMap(x -> x.getItemId(), x -> x));
|
| 199 |
|
205 |
|
| 200 |
User user = saholicUserRepository.selectByCartId(cartId);
|
206 |
User user = saholicUserRepository.selectByCartId(cartId);
|
| 201 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(user.getId());
|
207 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(user.getId());
|
| 202 |
Map<Integer, Integer> warehouseItemQtyMap = saholicInventoryService.getSaholicNetAvailability(fs.getWarehouseId(), new ArrayList<>(itemIds));
|
208 |
Map<Integer, Integer> warehouseItemQtyMap = saholicInventoryService.getSaholicNetAvailability(fs.getWarehouseId(), new ArrayList<>(itemIds));
|
| 203 |
|
- |
|
| - |
|
209 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fs.getId(), LocalDate.now());
|
| 204 |
// Get in-transit data for this warehouse
|
210 |
// Get in-transit data for this warehouse
|
| 205 |
List<WarehouseIntransitDataModel> warehouseIntransitDataModels =
|
211 |
List<WarehouseIntransitDataModel> warehouseIntransitDataModels =
|
| 206 |
saholicInventoryService.getWarehouseIntransistDataList().stream()
|
212 |
saholicInventoryService.getWarehouseIntransistDataList().stream()
|
| 207 |
.filter(x -> x.getWarehouseId() == fs.getWarehouseId())
|
213 |
.filter(x -> x.getWarehouseId() == fs.getWarehouseId())
|
| 208 |
.collect(Collectors.toList());
|
214 |
.collect(Collectors.toList());
|
| Line 259... |
Line 265... |
| 259 |
cartLine.setActualPrice(tagListingsMap.get(itemId).getSellingPrice());
|
265 |
cartLine.setActualPrice(tagListingsMap.get(itemId).getSellingPrice());
|
| 260 |
if (item.getCategoryId() == 10006 || item.getCategoryId() == 10010) {
|
266 |
if (item.getCategoryId() == 10006 || item.getCategoryId() == 10010) {
|
| 261 |
nonAccessoryQuantity += cartItemResponseModel.getQuantity();
|
267 |
nonAccessoryQuantity += cartItemResponseModel.getQuantity();
|
| 262 |
cartItemResponseModel.setCategoryName("mobile");
|
268 |
cartItemResponseModel.setCategoryName("mobile");
|
| 263 |
}
|
269 |
}
|
| - |
|
270 |
if (cartItemResponseModel.getItemId() == ProfitMandiConstants.CARRY_BAG_ITEM_ID) {
|
| - |
|
271 |
if (partnerType.equals(PartnerType.SILVER) || partnerType.equals(PartnerType.BRONZE)) {
|
| - |
|
272 |
cartItemResponseModel.setSellingPrice(cartLine.getActualPrice());
|
| - |
|
273 |
} else {
|
| - |
|
274 |
cartItemResponseModel.setSellingPrice(1);
|
| - |
|
275 |
}
|
| - |
|
276 |
} else {
|
| 264 |
cartItemResponseModel.setSellingPrice(cartLine.getActualPrice());
|
277 |
cartItemResponseModel.setSellingPrice(cartLine.getActualPrice());
|
| - |
|
278 |
}
|
| 265 |
|
279 |
|
| 266 |
//if (availability > 0) {
|
280 |
//if (availability > 0) {
|
| 267 |
cart.setTotalPrice(cart.getTotalPrice() + (cartLine.getActualPrice() * cartLine.getQuantity()));
|
281 |
cart.setTotalPrice(cart.getTotalPrice() + (cartLine.getActualPrice() * cartLine.getQuantity()));
|
| 268 |
cartItemResponseModel.setQuantity(cartLine.getQuantity());
|
282 |
cartItemResponseModel.setQuantity(cartLine.getQuantity());
|
| 269 |
cartItemResponseModel.setEstimate(2);
|
283 |
cartItemResponseModel.setEstimate(2);
|