Subversion Repositories SmartDukaan

Rev

Rev 37144 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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.web.util.ResponseSender;
35
import com.spice.profitmandi.dao.cart.CartService;
36
import com.spice.profitmandi.dao.entity.auth.AuthUser;
37
import com.spice.profitmandi.dao.entity.catalog.FocusedModelByPassRequest;
38
import com.spice.profitmandi.dao.entity.cs.Position;
39
import com.spice.profitmandi.dao.entity.dtr.User;
40
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
41
import com.spice.profitmandi.dao.entity.fofo.FofoPayment;
42
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
43
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
44
import com.spice.profitmandi.dao.enumuration.catalog.ByPassRequestStatus;
45
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
46
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
47
import com.spice.profitmandi.dao.enumuration.fofo.PaymentStatus;
48
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
49
import com.spice.profitmandi.dao.repository.catalog.FocusedModelByPassRepository;
50
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
51
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
52
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
53
import com.spice.profitmandi.dao.repository.cs.CsService;
54
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
55
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
56
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
57
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
58
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
59
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
60
import com.spice.profitmandi.dao.repository.fofo.FofoPaymentRepository;
61
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
62
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
63
import com.spice.profitmandi.dao.util.ContentPojoPopulator;
64
import com.spice.profitmandi.service.FofoUser;
65
import com.spice.profitmandi.service.NotificationService;
66
import com.spice.profitmandi.service.PartnerInvestmentService;
67
import com.spice.profitmandi.service.transaction.TransactionService;
68
import com.spice.profitmandi.service.user.RetailerService;
69
import com.spice.profitmandi.service.wallet.WalletService;
70
import com.spice.profitmandi.web.res.ValidateCartResponse;
71
 
72
import in.shop2020.model.v1.order.WalletReferenceType;
73
import io.swagger.annotations.ApiImplicitParam;
74
import io.swagger.annotations.ApiImplicitParams;
75
import io.swagger.annotations.ApiOperation;
76
 
77
@Controller
35458 amit 78
@Transactional(rollbackFor = Throwable.class)
33873 ranu 79
public class SmartCartController {
80
 
81
    private static final Logger logger = LogManager.getLogger(SmartCartController.class);
82
 
83
    @Autowired
84
    private ResponseSender<?> responseSender;
85
 
86
    @Autowired
87
    private UserAccountRepository userAccountRepository;
88
 
89
    @Autowired
90
    CartService cartService;
91
 
92
    @Autowired
93
    private SmartCartService smartCartService;
94
 
95
    @Autowired
96
    private SolrService solrService;
97
 
98
 
99
 
100
 
101
 
102
 
103
    @RequestMapping(value = "/cart/createSmartCart", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
104
    public ResponseEntity<?> createSmartCart(HttpServletRequest request, Model model) throws Exception {
105
 
106
        int userId = (int) request.getAttribute("userId");
107
        int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
108
 
109
        logger.info("retailerId- {}",retailerId);
110
 
111
        Set<Integer> smartCartReadyCatalogIds = smartCartService.getAllItemIdsForSmartCartOfPartner(retailerId);
112
 
113
        logger.info("smartCartReadyCatalogIds {}",smartCartReadyCatalogIds);
114
 
115
        List<FofoCatalogResponse> dealResponse = new ArrayList<>();
116
 
117
        if(smartCartReadyCatalogIds.size() >0 ){
118
 
119
            dealResponse = solrService.dealResponse(smartCartReadyCatalogIds,retailerId);
120
        }
121
 
122
        return responseSender.ok(dealResponse);
123
    }
124
 
125
 
126
}