| 33873 |
ranu |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
|
|
3 |
import java.time.LocalDateTime;
|
|
|
4 |
import java.util.*;
|
|
|
5 |
import java.util.stream.Collectors;
|
|
|
6 |
|
|
|
7 |
import javax.servlet.http.HttpServletRequest;
|
|
|
8 |
|
|
|
9 |
import com.spice.profitmandi.dao.cart.SmartCartService;
|
|
|
10 |
import com.spice.profitmandi.dao.entity.cs.PartnerRegion;
|
|
|
11 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
|
|
12 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
|
|
13 |
import com.spice.profitmandi.dao.model.*;
|
|
|
14 |
import com.spice.profitmandi.service.inventory.*;
|
|
|
15 |
import com.spice.profitmandi.web.services.SolrService;
|
|
|
16 |
import org.apache.logging.log4j.LogManager;
|
|
|
17 |
import org.apache.logging.log4j.Logger;
|
|
|
18 |
import org.json.JSONObject;
|
|
|
19 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
20 |
import org.springframework.http.MediaType;
|
|
|
21 |
import org.springframework.http.ResponseEntity;
|
|
|
22 |
import org.springframework.stereotype.Controller;
|
|
|
23 |
import org.springframework.transaction.annotation.Transactional;
|
|
|
24 |
import org.springframework.ui.Model;
|
|
|
25 |
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
26 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
27 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
28 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
29 |
|
|
|
30 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
|
|
31 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
|
|
32 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
|
|
33 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
|
|
34 |
import com.spice.profitmandi.common.services.mandii.MandiiService;
|
|
|
35 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
|
|
36 |
import com.spice.profitmandi.dao.cart.CartService;
|
|
|
37 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
|
|
38 |
import com.spice.profitmandi.dao.entity.catalog.FocusedModelByPassRequest;
|
|
|
39 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
|
|
40 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
|
|
41 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
|
|
42 |
import com.spice.profitmandi.dao.entity.fofo.FofoPayment;
|
|
|
43 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
|
|
44 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
|
|
45 |
import com.spice.profitmandi.dao.enumuration.catalog.ByPassRequestStatus;
|
|
|
46 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
|
|
47 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
|
|
48 |
import com.spice.profitmandi.dao.enumuration.fofo.PaymentStatus;
|
|
|
49 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
|
|
50 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelByPassRepository;
|
|
|
51 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
|
|
|
52 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
|
|
53 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
|
|
54 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
|
|
55 |
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
|
|
|
56 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
|
|
57 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
|
|
58 |
import com.spice.profitmandi.dao.repository.dtr.RetailerBlockBrandsRepository;
|
|
|
59 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
|
|
60 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
|
|
61 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
|
|
62 |
import com.spice.profitmandi.dao.repository.fofo.FofoPaymentRepository;
|
|
|
63 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
|
|
64 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
|
|
65 |
import com.spice.profitmandi.dao.util.ContentPojoPopulator;
|
|
|
66 |
import com.spice.profitmandi.service.FofoUser;
|
|
|
67 |
import com.spice.profitmandi.service.NotificationService;
|
|
|
68 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
|
|
69 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
|
|
70 |
import com.spice.profitmandi.service.user.RetailerService;
|
|
|
71 |
import com.spice.profitmandi.service.wallet.WalletService;
|
|
|
72 |
import com.spice.profitmandi.web.res.ValidateCartResponse;
|
|
|
73 |
|
|
|
74 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
|
|
75 |
import io.swagger.annotations.ApiImplicitParam;
|
|
|
76 |
import io.swagger.annotations.ApiImplicitParams;
|
|
|
77 |
import io.swagger.annotations.ApiOperation;
|
|
|
78 |
|
|
|
79 |
@Controller
|
| 35458 |
amit |
80 |
@Transactional(rollbackFor = Throwable.class)
|
| 33873 |
ranu |
81 |
public class SmartCartController {
|
|
|
82 |
|
|
|
83 |
private static final Logger logger = LogManager.getLogger(SmartCartController.class);
|
|
|
84 |
|
|
|
85 |
@Autowired
|
|
|
86 |
private ResponseSender<?> responseSender;
|
|
|
87 |
|
|
|
88 |
@Autowired
|
|
|
89 |
private UserAccountRepository userAccountRepository;
|
|
|
90 |
|
|
|
91 |
@Autowired
|
|
|
92 |
CartService cartService;
|
|
|
93 |
|
|
|
94 |
@Autowired
|
|
|
95 |
private SmartCartService smartCartService;
|
|
|
96 |
|
|
|
97 |
@Autowired
|
|
|
98 |
private SolrService solrService;
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
@RequestMapping(value = "/cart/createSmartCart", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
106 |
public ResponseEntity<?> createSmartCart(HttpServletRequest request, Model model) throws Exception {
|
|
|
107 |
|
|
|
108 |
int userId = (int) request.getAttribute("userId");
|
|
|
109 |
int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
|
|
|
110 |
|
|
|
111 |
logger.info("retailerId- {}",retailerId);
|
|
|
112 |
|
|
|
113 |
Set<Integer> smartCartReadyCatalogIds = smartCartService.getAllItemIdsForSmartCartOfPartner(retailerId);
|
|
|
114 |
|
|
|
115 |
logger.info("smartCartReadyCatalogIds {}",smartCartReadyCatalogIds);
|
|
|
116 |
|
|
|
117 |
List<FofoCatalogResponse> dealResponse = new ArrayList<>();
|
|
|
118 |
|
|
|
119 |
if(smartCartReadyCatalogIds.size() >0 ){
|
|
|
120 |
|
|
|
121 |
dealResponse = solrService.dealResponse(smartCartReadyCatalogIds,retailerId);
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
return responseSender.ok(dealResponse);
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
|
|
|
128 |
}
|