| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.dao.cart;
|
1 |
package com.spice.profitmandi.dao.cart;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.time.LocalDateTime;
|
| 3 |
import java.util.ArrayList;
|
4 |
import java.util.ArrayList;
|
| 4 |
import java.util.Arrays;
|
5 |
import java.util.Arrays;
|
| 5 |
import java.util.HashMap;
|
6 |
import java.util.HashMap;
|
| 6 |
import java.util.HashSet;
|
7 |
import java.util.HashSet;
|
| 7 |
import java.util.List;
|
8 |
import java.util.List;
|
| Line 12... |
Line 13... |
| 12 |
import org.springframework.beans.factory.annotation.Autowired;
|
13 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 13 |
|
14 |
|
| 14 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
15 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 15 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
16 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 16 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
17 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 17 |
import com.spice.profitmandi.dao.entity.inventory.ItemAvailabilityCache;
|
- |
|
| 18 |
import com.spice.profitmandi.dao.entity.user.Cart;
|
18 |
import com.spice.profitmandi.dao.entity.user.Cart;
|
| 19 |
import com.spice.profitmandi.dao.entity.user.CartItem;
|
19 |
import com.spice.profitmandi.dao.entity.user.CartItem;
|
| - |
|
20 |
import com.spice.profitmandi.dao.entity.user.CartLine;
|
| 20 |
import com.spice.profitmandi.dao.entity.user.User;
|
21 |
import com.spice.profitmandi.dao.entity.user.User;
|
| 21 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
22 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 22 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
23 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 23 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
24 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 24 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
25 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 25 |
import com.spice.profitmandi.dao.repository.user.CartItemRepository;
|
26 |
import com.spice.profitmandi.dao.repository.user.CartItemRepository;
|
| - |
|
27 |
import com.spice.profitmandi.dao.repository.user.CartLineRepository;
|
| 26 |
import com.spice.profitmandi.dao.repository.user.CartRepository;
|
28 |
import com.spice.profitmandi.dao.repository.user.CartRepository;
|
| 27 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
29 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 28 |
|
30 |
|
| 29 |
public class CartServiceImpl implements CartService {
|
31 |
public class CartServiceImpl implements CartService {
|
| 30 |
|
32 |
|
| Line 48... |
Line 50... |
| 48 |
@Autowired
|
50 |
@Autowired
|
| 49 |
ItemRepository itemRepository;
|
51 |
ItemRepository itemRepository;
|
| 50 |
|
52 |
|
| 51 |
@Autowired
|
53 |
@Autowired
|
| 52 |
CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
54 |
CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
| - |
|
55 |
@Autowired
|
| - |
|
56 |
CartLineRepository cartLineRepository;
|
| 53 |
|
57 |
|
| 54 |
@Override
|
58 |
@Override
|
| 55 |
public CartModel addToCart(int cartId, int itemId, int quantity, float sellingPrice) {
|
59 |
public CartModel addToCart(int cartId, int itemId, int quantity, float sellingPrice) {
|
| 56 |
CartItem cartItem = cartItemRepository.selectByCartItem(cartId, itemId);
|
60 |
CartItem cartItem = cartItemRepository.selectByCartItem(cartId, itemId);
|
| 57 |
if (cartItem == null) {
|
61 |
if (cartItem == null) {
|
| Line 164... |
Line 168... |
| 164 |
List<TagListing> tags = tagListingRepository.selectByItemIdsAndTagIds(itemIds, tagIds);
|
168 |
List<TagListing> tags = tagListingRepository.selectByItemIdsAndTagIds(itemIds, tagIds);
|
| 165 |
return tags.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x.getSellingPrice()));
|
169 |
return tags.stream().collect(Collectors.toMap(x -> x.getItemId(), x -> x.getSellingPrice()));
|
| 166 |
|
170 |
|
| 167 |
}
|
171 |
}
|
| 168 |
|
172 |
|
| - |
|
173 |
@Override
|
| - |
|
174 |
public void addShoppingBag(int cartId, long qty) {
|
| - |
|
175 |
CartLine cl = new CartLine();
|
| - |
|
176 |
cl.setItemId(32046);
|
| - |
|
177 |
cl.setQuantity((int) qty);
|
| - |
|
178 |
cl.setCartId(cartId);
|
| - |
|
179 |
cl.setCreateTimestamp(LocalDateTime.now());
|
| - |
|
180 |
cl.setDataProtectionAmount(0);
|
| - |
|
181 |
cl.setEstimate(0);
|
| - |
|
182 |
cl.setInsuranceAmount((float) 0);
|
| - |
|
183 |
cl.setDataProtectionInsurer(0);
|
| - |
|
184 |
cl.setActualPrice((float) 0.01 * qty);
|
| - |
|
185 |
cartLineRepository.persist(cl);
|
| - |
|
186 |
|
| - |
|
187 |
}
|
| - |
|
188 |
|
| 169 |
}
|
189 |
}
|