| Line 28... |
Line 28... |
| 28 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
28 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 29 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
29 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 30 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
30 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 31 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
31 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
| 32 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
32 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
| - |
|
33 |
import com.spice.profitmandi.dao.model.AddCartRequest;
|
| - |
|
34 |
import com.spice.profitmandi.dao.model.CartItem;
|
| - |
|
35 |
import com.spice.profitmandi.dao.model.CartResponse;
|
| 33 |
import com.spice.profitmandi.dao.model.ProductPojo;
|
36 |
import com.spice.profitmandi.dao.model.ProductPojo;
|
| 34 |
import com.spice.profitmandi.dao.model.UserCart;
|
37 |
import com.spice.profitmandi.dao.model.UserCart;
|
| 35 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
38 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 36 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
39 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 37 |
import com.spice.profitmandi.dao.util.ContentPojoPopulator;
|
40 |
import com.spice.profitmandi.dao.util.ContentPojoPopulator;
|
| 38 |
import com.spice.profitmandi.dao.util.LogisticsService;
|
41 |
import com.spice.profitmandi.dao.util.LogisticsService;
|
| 39 |
import com.spice.profitmandi.service.inventory.ItemBucketService;
|
42 |
import com.spice.profitmandi.service.inventory.ItemBucketService;
|
| 40 |
import com.spice.profitmandi.thrift.clients.UserClient;
|
43 |
import com.spice.profitmandi.thrift.clients.UserClient;
|
| 41 |
import com.spice.profitmandi.web.req.AddCartRequest;
|
- |
|
| 42 |
import com.spice.profitmandi.web.req.CartItems;
|
- |
|
| 43 |
import com.spice.profitmandi.web.res.CartResponse;
|
- |
|
| 44 |
import com.spice.profitmandi.web.res.ValidateCartResponse;
|
44 |
import com.spice.profitmandi.web.res.ValidateCartResponse;
|
| 45 |
|
45 |
|
| 46 |
import in.shop2020.logistics.DeliveryType;
|
46 |
import in.shop2020.logistics.DeliveryType;
|
| 47 |
import in.shop2020.model.v1.user.ItemQuantity;
|
47 |
import in.shop2020.model.v1.user.ItemQuantity;
|
| 48 |
import in.shop2020.model.v1.user.UserContextService;
|
48 |
import in.shop2020.model.v1.user.UserContextService;
|
| Line 86... |
Line 86... |
| 86 |
public ResponseEntity<?> validateCart(HttpServletRequest request,
|
86 |
public ResponseEntity<?> validateCart(HttpServletRequest request,
|
| 87 |
@RequestParam(value = "pincode", defaultValue = "110001") String pincode, @RequestParam int bucketId)
|
87 |
@RequestParam(value = "pincode", defaultValue = "110001") String pincode, @RequestParam int bucketId)
|
| 88 |
throws Throwable {
|
88 |
throws Throwable {
|
| 89 |
|
89 |
|
| 90 |
AddCartRequest cartRequest = new AddCartRequest();
|
90 |
AddCartRequest cartRequest = new AddCartRequest();
|
| 91 |
List<CartItems> ci = new ArrayList<>();
|
91 |
List<CartItem> ci = new ArrayList<>();
|
| 92 |
itemBucketService.getBucketDetails(bucketId).stream().forEach(x -> {
|
92 |
itemBucketService.getBucketDetails(bucketId).stream().forEach(x -> {
|
| 93 |
ci.add(new CartItems(x.getQuantity(),x.getItemId()));
|
93 |
ci.add(new CartItem(x.getQuantity(),x.getItemId()));
|
| 94 |
});
|
94 |
});
|
| 95 |
cartRequest.setCartItems(ci.toArray(new CartItems[0]));
|
95 |
cartRequest.setCartItems(ci);
|
| 96 |
return this.validateCart(request, cartRequest, "110001");
|
96 |
return this.validateCart(request, cartRequest, "110001");
|
| 97 |
|
97 |
|
| 98 |
}
|
98 |
}
|
| 99 |
|
99 |
|
| 100 |
@RequestMapping(value = ProfitMandiConstants.URL_CART, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
100 |
@RequestMapping(value = ProfitMandiConstants.URL_CART, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| Line 109... |
Line 109... |
| 109 |
|
109 |
|
| 110 |
userAccount = userAccountRepository.selectByUserIdType(userId, AccountType.cartId);
|
110 |
userAccount = userAccountRepository.selectByUserIdType(userId, AccountType.cartId);
|
| 111 |
logger.info("UserAccount................." + userAccount);
|
111 |
logger.info("UserAccount................." + userAccount);
|
| 112 |
Map<String, Integer> brandQtyMap = new HashMap<>();
|
112 |
Map<String, Integer> brandQtyMap = new HashMap<>();
|
| 113 |
List<ItemQuantity> itemQuantities = new ArrayList<ItemQuantity>();
|
113 |
List<ItemQuantity> itemQuantities = new ArrayList<ItemQuantity>();
|
| 114 |
CartItems[] cartItems = cartRequest.getCartItems();
|
114 |
List<CartItem> cartItems = cartRequest.getCartItems();
|
| 115 |
List<Integer> itemsList = new ArrayList<Integer>();
|
115 |
List<Integer> itemsList = new ArrayList<Integer>();
|
| 116 |
// Only Keep Non Billable Stock if partner adds both
|
116 |
// Only Keep Non Billable Stock if partner adds both
|
| 117 |
boolean nogst = false;
|
117 |
boolean nogst = false;
|
| 118 |
|
118 |
|
| 119 |
for (CartItems ci : cartItems) {
|
119 |
for (CartItem ci : cartItems) {
|
| 120 |
if (ci.getQuantity() > 0 && itemRepository.selectById(ci.getItemId()).getHsnCode().equals("NOGST")) {
|
120 |
if (ci.getQuantity() > 0 && itemRepository.selectById(ci.getItemId()).getHsnCode().equals("NOGST")) {
|
| 121 |
nogst = true;
|
121 |
nogst = true;
|
| 122 |
}
|
122 |
}
|
| 123 |
}
|
123 |
}
|
| 124 |
|
124 |
|
| 125 |
JSONObject cartMessage = null;
|
125 |
JSONObject cartMessage = null;
|
| 126 |
for (CartItems ci : cartItems) {
|
126 |
for (CartItem ci : cartItems) {
|
| 127 |
if (nogst && !itemRepository.selectById(ci.getItemId()).getHsnCode().equals("NOGST")) {
|
127 |
if (nogst && !itemRepository.selectById(ci.getItemId()).getHsnCode().equals("NOGST")) {
|
| 128 |
if (cartMessage == null) {
|
128 |
if (cartMessage == null) {
|
| 129 |
cartMessage = new JSONObject();
|
129 |
cartMessage = new JSONObject();
|
| 130 |
cartMessage.put("messageText", "Billable items can't be billed along with non Billable items");
|
130 |
cartMessage.put("messageText", "Billable items can't be billed along with non Billable items");
|
| 131 |
}
|
131 |
}
|