Subversion Repositories SmartDukaan

Rev

Rev 34371 | Rev 34446 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34371 Rev 34444
Line 5... Line 5...
5
import com.google.gson.reflect.TypeToken;
5
import com.google.gson.reflect.TypeToken;
6
import com.spice.profitmandi.common.enumuration.MessageType;
6
import com.spice.profitmandi.common.enumuration.MessageType;
7
import com.spice.profitmandi.common.enumuration.SchemeType;
7
import com.spice.profitmandi.common.enumuration.SchemeType;
8
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
8
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
9
import com.spice.profitmandi.common.model.*;
9
import com.spice.profitmandi.common.model.*;
-
 
10
import com.spice.profitmandi.dao.entity.catalog.LiquidationDetail;
10
import com.spice.profitmandi.common.solr.SolrService;
11
import com.spice.profitmandi.common.solr.SolrService;
11
import com.spice.profitmandi.common.util.FormattingUtils;
12
import com.spice.profitmandi.common.util.FormattingUtils;
12
import com.spice.profitmandi.common.util.PdfUtils;
13
import com.spice.profitmandi.common.util.PdfUtils;
13
import com.spice.profitmandi.common.util.Utils;
14
import com.spice.profitmandi.common.util.Utils;
14
import com.spice.profitmandi.common.web.client.RestClient;
15
import com.spice.profitmandi.common.web.client.RestClient;
15
import com.spice.profitmandi.common.web.util.ResponseSender;
16
import com.spice.profitmandi.common.web.util.ResponseSender;
16
import com.spice.profitmandi.dao.cart.CartItemMessage;
-
 
17
import com.spice.profitmandi.dao.entity.WebEntity.NavBar;
17
import com.spice.profitmandi.dao.entity.WebEntity.NavBar;
-
 
18
import com.spice.profitmandi.dao.entity.catalog.Bid;
18
import com.spice.profitmandi.dao.entity.catalog.Item;
19
import com.spice.profitmandi.dao.entity.catalog.Item;
-
 
20
import com.spice.profitmandi.dao.entity.catalog.Liquidation;
19
import com.spice.profitmandi.dao.entity.catalog.TagListing;
21
import com.spice.profitmandi.dao.entity.catalog.TagListing;
20
import com.spice.profitmandi.dao.entity.dtr.*;
22
import com.spice.profitmandi.dao.entity.dtr.*;
21
import com.spice.profitmandi.dao.entity.fofo.*;
23
import com.spice.profitmandi.dao.entity.fofo.*;
22
import com.spice.profitmandi.dao.entity.inventory.State;
24
import com.spice.profitmandi.dao.entity.inventory.State;
23
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
25
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
24
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
26
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
25
import com.spice.profitmandi.dao.enumuration.dtr.WebListingSource;
27
import com.spice.profitmandi.dao.enumuration.dtr.WebListingSource;
26
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
28
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
27
import com.spice.profitmandi.dao.model.*;
29
import com.spice.profitmandi.dao.model.*;
28
import com.spice.profitmandi.dao.model.pendingOrder.PendingOrderDetail;
30
import com.spice.profitmandi.dao.model.pendingOrder.PendingOrderDetail;
-
 
31
import com.spice.profitmandi.dao.repository.catalog.BidRepository;
29
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
32
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
-
 
33
import com.spice.profitmandi.dao.repository.catalog.LiquidationRepository;
30
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
34
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
31
import com.spice.profitmandi.dao.repository.cs.CsService;
35
import com.spice.profitmandi.dao.repository.cs.CsService;
32
import com.spice.profitmandi.dao.repository.dtr.*;
36
import com.spice.profitmandi.dao.repository.dtr.*;
33
import com.spice.profitmandi.dao.repository.fofo.*;
37
import com.spice.profitmandi.dao.repository.fofo.*;
34
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
38
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
35
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
39
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
36
import com.spice.profitmandi.dao.repository.user.AddressRepository;
-
 
37
import com.spice.profitmandi.dao.repository.user.UserRepository;
40
import com.spice.profitmandi.dao.repository.user.UserRepository;
38
import com.spice.profitmandi.dao.repository.webRepository.NavBarRepository;
41
import com.spice.profitmandi.dao.repository.webRepository.NavBarRepository;
39
import com.spice.profitmandi.service.CustomerService;
42
import com.spice.profitmandi.service.CustomerService;
40
import com.spice.profitmandi.service.EmailService;
43
import com.spice.profitmandi.service.EmailService;
41
import com.spice.profitmandi.service.NotificationService;
44
import com.spice.profitmandi.service.NotificationService;
42
import com.spice.profitmandi.service.authentication.RoleManager;
45
import com.spice.profitmandi.service.authentication.RoleManager;
-
 
46
import com.spice.profitmandi.service.catalog.BiddingModel;
43
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
47
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
44
import com.spice.profitmandi.service.integrations.zest.MobileInsurancePlan;
48
import com.spice.profitmandi.service.integrations.zest.MobileInsurancePlan;
45
import com.spice.profitmandi.service.inventory.*;
49
import com.spice.profitmandi.service.inventory.*;
46
import com.spice.profitmandi.service.order.OrderService;
50
import com.spice.profitmandi.service.order.OrderService;
47
import com.spice.profitmandi.service.scheme.SchemeService;
51
import com.spice.profitmandi.service.scheme.SchemeService;
48
import com.spice.profitmandi.service.user.RetailerService;
52
import com.spice.profitmandi.service.user.RetailerService;
49
import com.spice.profitmandi.dao.service.OtpProcessor;
53
import com.spice.profitmandi.dao.service.OtpProcessor;
50
import com.spice.profitmandi.web.req.Address;
-
 
51
import com.spice.profitmandi.web.res.DealBrands;
54
import com.spice.profitmandi.web.res.DealBrands;
52
import com.spice.profitmandi.web.res.DealObjectResponse;
55
import com.spice.profitmandi.web.res.DealObjectResponse;
53
import com.spice.profitmandi.web.res.DealsResponse;
56
import com.spice.profitmandi.web.res.DealsResponse;
54
import com.spice.profitmandi.web.res.ValidateCartResponse;
57
import com.spice.profitmandi.web.res.ValidateCartResponse;
55
import com.spice.profitmandi.web.services.PartnerIndexService;
58
import com.spice.profitmandi.web.services.PartnerIndexService;
56
import io.swagger.annotations.ApiImplicitParam;
59
import io.swagger.annotations.ApiImplicitParam;
57
import io.swagger.annotations.ApiImplicitParams;
60
import io.swagger.annotations.ApiImplicitParams;
58
import io.swagger.annotations.ApiOperation;
61
import io.swagger.annotations.ApiOperation;
59
import org.apache.commons.lang.ObjectUtils;
-
 
60
import org.apache.commons.lang3.StringUtils;
62
import org.apache.commons.lang3.StringUtils;
61
import org.apache.http.conn.HttpHostConnectException;
63
import org.apache.http.conn.HttpHostConnectException;
62
import org.apache.logging.log4j.LogManager;
64
import org.apache.logging.log4j.LogManager;
63
import org.apache.logging.log4j.Logger;
65
import org.apache.logging.log4j.Logger;
64
import org.json.JSONArray;
66
import org.json.JSONArray;
Line 207... Line 209...
207
 
209
 
208
    @Autowired
210
    @Autowired
209
    InsurancePolicyRepository insurancePolicyRepository;
211
    InsurancePolicyRepository insurancePolicyRepository;
210
 
212
 
211
    @Autowired
213
    @Autowired
-
 
214
    LiquidationRepository liquidationRepository;
-
 
215
 
-
 
216
    @Autowired
212
    PendingOrderPlanRepository pendingOrderPlanRepository;
217
    PendingOrderPlanRepository pendingOrderPlanRepository;
213
 
218
 
214
    @Autowired
219
    @Autowired
215
    private ScratchOfferRepository scratchOfferRepository;
220
    private ScratchOfferRepository scratchOfferRepository;
216
    private static final List<String> offlineOrders = Arrays.asList("EMIOD", "POD");
221
    private static final List<String> offlineOrders = Arrays.asList("EMIOD", "POD");
217
 
222
 
218
    @Autowired
223
    @Autowired
219
    NavBarRepository navBarRepository;
224
    NavBarRepository navBarRepository;
220
 
225
 
-
 
226
    @Autowired
-
 
227
    BidRepository bidRepository;
-
 
228
 
221
    List<String> filterableParams = Arrays.asList("brand");
229
    List<String> filterableParams = Arrays.asList("brand");
222
 
230
 
223
    @RequestMapping(value = "/store/entity/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
231
    @RequestMapping(value = "/store/entity/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
224
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
232
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
225
    @ApiOperation(value = "Get unit deal object")
233
    @ApiOperation(value = "Get unit deal object")
Line 316... Line 324...
316
        } catch (Exception e) {
324
        } catch (Exception e) {
317
            return responseSender.ok(new CustomerModel(false, null));
325
            return responseSender.ok(new CustomerModel(false, null));
318
        }
326
        }
319
    }
327
    }
320
 
328
 
321
 
-
 
322
    @RequestMapping(value = "/store/getCustomerById/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
329
    @RequestMapping(value = "/store/getCustomerById/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
323
    public ResponseEntity<?> getCustomerById(HttpServletRequest request, @PathVariable int id) throws Exception {
330
    public ResponseEntity<?> getCustomerById(HttpServletRequest request, @PathVariable int id) throws Exception {
324
 
331
 
325
        Customer customer = customerRepository.selectById(id);
332
        Customer customer = customerRepository.selectById(id);
326
        customer.setPasswordExist(StringUtils.isNotEmpty(customer.getPassword()));
333
        customer.setPasswordExist(StringUtils.isNotEmpty(customer.getPassword()));
Line 551... Line 558...
551
        }
558
        }
552
        defaultAddress.setDefault(true);
559
        defaultAddress.setDefault(true);
553
        return responseSender.ok("Default address updated successfully.");
560
        return responseSender.ok("Default address updated successfully.");
554
    }
561
    }
555
 
562
 
556
 
-
 
557
    @RequestMapping(value = "/store/address/{pincode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
563
    @RequestMapping(value = "/store/address/{pincode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
558
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
564
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
559
    @ApiOperation(value = "Get brand list and count for category")
565
    @ApiOperation(value = "Get brand list and count for category")
560
    public ResponseEntity<?> getStoresByPincode(HttpServletRequest request, @PathVariable String pincode) throws Exception {
566
    public ResponseEntity<?> getStoresByPincode(HttpServletRequest request, @PathVariable String pincode) throws Exception {
561
        List<PincodePartner> pincodePartners = pincodePartnerRepository.selectPartnersByPincode(pincode);
567
        List<PincodePartner> pincodePartners = pincodePartnerRepository.selectPartnersByPincode(pincode);
Line 643... Line 649...
643
 
649
 
644
        logger.info("customerRetailers" + customerRetailers);
650
        logger.info("customerRetailers" + customerRetailers);
645
        return responseSender.ok(customerRetailers);
651
        return responseSender.ok(customerRetailers);
646
    }
652
    }
647
 
653
 
648
 
-
 
649
    @RequestMapping(value = "/store/order", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
654
    @RequestMapping(value = "/store/order", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
650
    public ResponseEntity<?> getOrderDetail(HttpServletRequest request, @RequestParam(value = "id") int id, @RequestParam(name = "offset") int offset, @RequestParam(name = "limit") int limit) throws Exception {
655
    public ResponseEntity<?> getOrderDetail(HttpServletRequest request, @RequestParam(value = "id") int id, @RequestParam(name = "offset") int offset, @RequestParam(name = "limit") int limit) throws Exception {
651
 
656
 
652
        List<PendingOrderDetail> pendingOrderDetails = new ArrayList<>();
657
        List<PendingOrderDetail> pendingOrderDetails = new ArrayList<>();
653
        List<Integer> catalogIds = new ArrayList<>();
658
        List<Integer> catalogIds = new ArrayList<>();
Line 971... Line 976...
971
 
976
 
972
    }
977
    }
973
 
978
 
974
    @RequestMapping(value = "/store/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
979
    @RequestMapping(value = "/store/partnerStock", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
975
    public ResponseEntity<?> partnerStock(HttpServletRequest request, @RequestParam(required = false, defaultValue = "3") String categoryId, @RequestParam int offset,
980
    public ResponseEntity<?> partnerStock(HttpServletRequest request, @RequestParam(required = false, defaultValue = "3") String categoryId, @RequestParam int offset,
976
                                          @RequestParam int limit, @RequestParam(required = false) String sort, @RequestParam(required = false) String brand,
981
      @RequestParam int limit, @RequestParam(required = false) String sort, @RequestParam(required = false) String brand,
977
                                          @RequestParam(value = "subCategoryId", required = false) int subCategoryId, @RequestParam(required = false) String queryTerm,
982
      @RequestParam(value = "subCategoryId", required = false) int subCategoryId, @RequestParam(required = false) String queryTerm,
978
                                          @RequestParam(required = false) String listing, @RequestParam(required = false, defaultValue = "true") boolean partnerStockOnly) throws Throwable {
983
      @RequestParam(required = false) String listing, @RequestParam(required = false, defaultValue = "true") boolean partnerStockOnly) throws Throwable {
979
        List<FofoCatalogResponse> dealResponse = new ArrayList<>();
984
        List<FofoCatalogResponse> dealResponse = new ArrayList<>();
980
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
985
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
981
        FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
986
        FofoStore fs = fofoStoreRepository.selectByRetailerId(userInfo.getRetailerId());
982
        sort = "w" + fs.getWarehouseId() + "_i desc";
987
        sort = "w" + fs.getWarehouseId() + "_i desc";
983
        dealResponse = this.getCatalogResponse(
988
        dealResponse = this.getCatalogResponse(
Line 1259... Line 1264...
1259
        scratchOffer.setScracthedAt(LocalDateTime.now());
1264
        scratchOffer.setScracthedAt(LocalDateTime.now());
1260
 
1265
 
1261
        return responseSender.ok(true);
1266
        return responseSender.ok(true);
1262
    }
1267
    }
1263
 
1268
 
1264
 
-
 
1265
    @RequestMapping(value = "/store/navbar", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
1269
    @RequestMapping(value = "/store/navbar", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
1266
    public ResponseEntity<?> navBars() throws Exception {
1270
    public ResponseEntity<?> navBars() throws Exception {
1267
        List<NavBar> navBars = navBarRepository.selectAllActive();
1271
        List<NavBar> navBars = navBarRepository.selectAllActive();
1268
        return responseSender.ok(navBars);
1272
        return responseSender.ok(navBars);
1269
    }
1273
    }
1270
 
1274
 
-
 
1275
    @RequestMapping(value = "/store/clearance", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
1276
    public ResponseEntity<?> getLiquidations() throws Exception {
-
 
1277
        List<Integer> catalogIds = new ArrayList<>();
-
 
1278
        Map<Integer, JSONObject> contentMap = null;
-
 
1279
        List<Liquidation> liquidations = liquidationRepository.selectAllByStatus(ProfitMandiConstants.LIQUIDATION_ENUM.ACTIVE);
-
 
1280
 
-
 
1281
        if (!liquidations.isEmpty()) {
-
 
1282
            for (Liquidation liquidation : liquidations) catalogIds.add(liquidation.getCatalogId());
-
 
1283
            contentMap = commonSolrService.getContentByCatalogIds(catalogIds);
-
 
1284
        }
-
 
1285
 
-
 
1286
        List<LiquidationDetail> resultList = new ArrayList<>();
-
 
1287
 
-
 
1288
        if (contentMap != null) {
-
 
1289
            for (Liquidation liquidation : liquidations) {
-
 
1290
                List<Bid> bidList = bidRepository.selectBidByLiquidationId(liquidation.getId());
-
 
1291
                LiquidationDetail liquidationDetail = new LiquidationDetail();
-
 
1292
                if(contentMap.containsKey(liquidation.getCatalogId())) {
-
 
1293
                    JSONObject jsonObj = contentMap.get(liquidation.getCatalogId());
-
 
1294
                    liquidationDetail.setLiquidationId(liquidation.getId());
-
 
1295
                    liquidationDetail.setImageURL(jsonObj.getString("imageUrl_s"));
-
 
1296
                    liquidationDetail.setItemName(jsonObj.getString("title_s"));
-
 
1297
                    liquidationDetail.setBrand(jsonObj.getString("title_s"));
-
 
1298
                    liquidationDetail.setCatalogId(jsonObj.getInt("catalogId_i"));
-
 
1299
                    liquidationDetail.setMrp(jsonObj.getFloat("mop_f"));
-
 
1300
                    liquidationDetail.setMop(jsonObj.getFloat("mop_f"));
-
 
1301
                    liquidationDetail.setDp(jsonObj.getFloat("dp_f"));
-
 
1302
                    liquidationDetail.setSuperCatalogs(jsonObj.getString("superCatalogVariants_s"));
-
 
1303
                    liquidationDetail.setStartDate(liquidation.getStartDate());
-
 
1304
                    liquidationDetail.setEndDate(liquidation.getEndDate());
-
 
1305
                    liquidationDetail.setSellingPrice(liquidation.getPrice());
-
 
1306
                    liquidationDetail.setAvailableQuantity(liquidation.getQuantity());
-
 
1307
                    liquidationDetail.setBidList(bidList);
-
 
1308
                    resultList.add(liquidationDetail);
-
 
1309
                }
-
 
1310
            }
-
 
1311
        }
-
 
1312
 
-
 
1313
        return responseSender.ok(resultList);
-
 
1314
    }
-
 
1315
 
-
 
1316
    @RequestMapping(value = "/store/clearance/bid", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
1317
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
-
 
1318
    public ResponseEntity<?> saveBidding(HttpServletRequest request, @RequestBody BiddingModel biddingModel) throws Exception {
-
 
1319
        Bid bid = null;
-
 
1320
        UserInfo userInfo = (UserInfo) request.getAttribute("userInfo");
-
 
1321
        if (biddingModel.getId() != null && biddingModel.getId() > 0) {
-
 
1322
            bid = bidRepository.selectById(biddingModel.getId());
-
 
1323
            if (bid == null) {
-
 
1324
                throw new Exception("Bidding record not found with ID: " + biddingModel.getId());
-
 
1325
            }
-
 
1326
        } else {
-
 
1327
            bid = new Bid();
-
 
1328
        }
-
 
1329
        bid.setLiquidationId(biddingModel.getLiquidationId());
-
 
1330
        bid.setBiddingAmount(biddingModel.getBiddingAmount());
-
 
1331
        bid.setFofoId(userInfo.getRetailerId());
-
 
1332
        bid.setItemName(biddingModel.getItemName());
-
 
1333
        bid.setQuantity(biddingModel.getBidQty());
-
 
1334
        bid.setStatus(ProfitMandiConstants.BID_ENUM.PENDING);
-
 
1335
        bid.setCreatedAt(LocalDateTime.now());
-
 
1336
        if (biddingModel.getId() == null) {
-
 
1337
            bidRepository.persist(bid);
-
 
1338
        }
-
 
1339
        return responseSender.ok("true");
-
 
1340
    }
-
 
1341
 
1271
 
1342
 
1272
}
1343
}
1273
1344