Subversion Repositories SmartDukaan

Rev

Rev 35458 | 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.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.UserAccountRepository;
59
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
60
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
61
import com.spice.profitmandi.dao.repository.fofo.FofoPaymentRepository;
62
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
63
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
64
import com.spice.profitmandi.dao.util.ContentPojoPopulator;
65
import com.spice.profitmandi.service.FofoUser;
66
import com.spice.profitmandi.service.NotificationService;
67
import com.spice.profitmandi.service.PartnerInvestmentService;
68
import com.spice.profitmandi.service.transaction.TransactionService;
69
import com.spice.profitmandi.service.user.RetailerService;
70
import com.spice.profitmandi.service.wallet.WalletService;
71
import com.spice.profitmandi.web.res.ValidateCartResponse;
72
 
73
import in.shop2020.model.v1.order.WalletReferenceType;
74
import io.swagger.annotations.ApiImplicitParam;
75
import io.swagger.annotations.ApiImplicitParams;
76
import io.swagger.annotations.ApiOperation;
77
 
78
@Controller
35458 amit 79
@Transactional(rollbackFor = Throwable.class)
33873 ranu 80
public class SmartCartController {
81
 
82
    private static final Logger logger = LogManager.getLogger(SmartCartController.class);
83
 
84
    @Autowired
85
    private ResponseSender<?> responseSender;
86
 
87
    @Autowired
88
    private UserAccountRepository userAccountRepository;
89
 
90
    @Autowired
91
    CartService cartService;
92
 
93
    @Autowired
94
    private SmartCartService smartCartService;
95
 
96
    @Autowired
97
    private SolrService solrService;
98
 
99
 
100
 
101
 
102
 
103
 
104
    @RequestMapping(value = "/cart/createSmartCart", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
105
    public ResponseEntity<?> createSmartCart(HttpServletRequest request, Model model) throws Exception {
106
 
107
        int userId = (int) request.getAttribute("userId");
108
        int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
109
 
110
        logger.info("retailerId- {}",retailerId);
111
 
112
        Set<Integer> smartCartReadyCatalogIds = smartCartService.getAllItemIdsForSmartCartOfPartner(retailerId);
113
 
114
        logger.info("smartCartReadyCatalogIds {}",smartCartReadyCatalogIds);
115
 
116
        List<FofoCatalogResponse> dealResponse = new ArrayList<>();
117
 
118
        if(smartCartReadyCatalogIds.size() >0 ){
119
 
120
            dealResponse = solrService.dealResponse(smartCartReadyCatalogIds,retailerId);
121
        }
122
 
123
        return responseSender.ok(dealResponse);
124
    }
125
 
126
 
127
}