Subversion Repositories SmartDukaan

Rev

Rev 37693 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37693 Rev 37735
Line 59... Line 59...
59
import com.spice.profitmandi.dao.repository.warehouse.WarehouseInventoryItemRepository;
59
import com.spice.profitmandi.dao.repository.warehouse.WarehouseInventoryItemRepository;
60
import com.spice.profitmandi.dao.repository.warehouse.WarehouseScanRepository;
60
import com.spice.profitmandi.dao.repository.warehouse.WarehouseScanRepository;
61
import com.spice.profitmandi.dao.service.LiquidationService;
61
import com.spice.profitmandi.dao.service.LiquidationService;
62
import com.spice.profitmandi.dao.service.LocationTrackingService;
62
import com.spice.profitmandi.dao.service.LocationTrackingService;
63
import com.spice.profitmandi.dao.service.SaleRewardService;
63
import com.spice.profitmandi.dao.service.SaleRewardService;
64
import com.spice.profitmandi.service.integrations.bharti.BAGService;
-
 
65
import com.spice.profitmandi.service.integrations.bharti.model.Sample;
-
 
66
import com.spice.profitmandi.service.integrations.gstpro.GstProAuthService;
64
import com.spice.profitmandi.service.integrations.gstpro.GstProAuthService;
67
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
65
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
68
import com.spice.profitmandi.service.integrations.oneassist.OneAssistService;
66
import com.spice.profitmandi.service.integrations.oneassist.OneAssistService;
69
import com.spice.profitmandi.service.integrations.oneassist.model.CancelPlanRequestModel;
67
import com.spice.profitmandi.service.integrations.oneassist.model.CancelPlanRequestModel;
70
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
68
import com.spice.profitmandi.service.integrations.zest.InsuranceService;
Line 319... Line 317...
319
    private PoStockApprovalDigestService poStockApprovalDigestService;*/
317
    private PoStockApprovalDigestService poStockApprovalDigestService;*/
320
 
318
 
321
    @Autowired
319
    @Autowired
322
    private RbmPerformanceRankingService rbmPerformanceRankingService;
320
    private RbmPerformanceRankingService rbmPerformanceRankingService;
323
 
321
 
324
    private static final String ACCOUNT_ID = "aZ6flHhrgPIEl18buHdPBdueEN4";
-
 
325
    private static final String SECRET_KEY = "a7rsX5B4UNNfTTx1-IJ19qdH48BT4YvBKlQJg3n3_KKNe7WWych55g";
-
 
326
 
-
 
327
    @Autowired
322
    @Autowired
328
    private WarehouseInventoryItemRepository warehouseInventoryItemRepository;
323
    private WarehouseInventoryItemRepository warehouseInventoryItemRepository;
329
 
324
 
330
    public void populateGrnTimestamp() {
325
    public void populateGrnTimestamp() {
331
        List<Purchase> allPurchases = purchaseRepository.selectAll();
326
        List<Purchase> allPurchases = purchaseRepository.selectAll();
Line 546... Line 541...
546
            }
541
            }
547
            cis.setReserved(value);
542
            cis.setReserved(value);
548
        });
543
        });
549
    }
544
    }
550
 
545
 
551
 
-
 
552
    public void fixWallet() throws Exception {
546
    public void fixWallet() throws Exception {
553
        List<FofoStore> fofoStores = fofoStoreRepository.selectAll();
547
        List<FofoStore> fofoStores = fofoStoreRepository.selectAll();
554
        System.out.println("id\tcode\tactive\tname\tcity\tstate\twallet amount\tsum\twallet amount-sum");
548
        System.out.println("id\tcode\tactive\tname\tcity\tstate\twallet amount\tsum\twallet amount-sum");
555
        for (FofoStore fofoStore : fofoStores) {
549
        for (FofoStore fofoStore : fofoStores) {
556
            UserWallet uw = userWalletRepository.selectByRetailerId(fofoStore.getId());
550
            UserWallet uw = userWalletRepository.selectByRetailerId(fofoStore.getId());
Line 1050... Line 1044...
1050
    }
1044
    }
1051
 
1045
 
1052
    @Autowired
1046
    @Autowired
1053
    PriceDropRepository priceDropRepository;
1047
    PriceDropRepository priceDropRepository;
1054
 
1048
 
1055
 
-
 
1056
    @Autowired
1049
    @Autowired
1057
    PriceDropIMEIRepository priceDropIMEIRepository;
1050
    PriceDropIMEIRepository priceDropIMEIRepository;
1058
 
1051
 
1059
    public void fixPriceDrop() throws ProfitMandiBusinessException {
1052
    public void fixPriceDrop() throws ProfitMandiBusinessException {
1060
        List<Integer> priceDropIds = Arrays.asList(609, 610, 611, 648, 649, 650, 651, 653, 667, 691, 692, 693, 695, 696, 697, 698, 645, 688);
1053
        List<Integer> priceDropIds = Arrays.asList(609, 610, 611, 648, 649, 650, 651, 653, 667, 691, 692, 693, 695, 696, 697, 698, 645, 688);
Line 1116... Line 1109...
1116
    public void updateSaholicCISTable() {
1109
    public void updateSaholicCISTable() {
1117
        saholicInventoryService.updateSaholicCIS();
1110
        saholicInventoryService.updateSaholicCIS();
1118
    }
1111
    }
1119
 
1112
 
1120
    @Autowired
1113
    @Autowired
1121
    BAGService bagService;
-
 
1122
 
-
 
1123
    public void testBag() throws Exception {
-
 
1124
        //bagService.getPlans(10006, 10000f);
-
 
1125
        //bagService.getBrandsMaster();
-
 
1126
        bagService.getAllPlans();
-
 
1127
    }
-
 
1128
 
-
 
1129
    @Autowired
-
 
1130
    private OneAssistService oneAssistService;
1114
    private OneAssistService oneAssistService;
1131
 
1115
 
1132
    public void cancelOnceAssist(String invoiceNumber) throws Exception {
1116
    public void cancelOnceAssist(String invoiceNumber) throws Exception {
1133
        FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
1117
        FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(invoiceNumber);
1134
        insuranceService.cancelInsurance(fofoOrder);
1118
        insuranceService.cancelInsurance(fofoOrder);
Line 1136... Line 1120...
1136
 
1120
 
1137
    public void cancelOnceAssistByMemberShipNumber(String applicationNo, String membershipId) throws Exception {
1121
    public void cancelOnceAssistByMemberShipNumber(String applicationNo, String membershipId) throws Exception {
1138
        insuranceService.cancelInsurance(applicationNo, membershipId);
1122
        insuranceService.cancelInsurance(applicationNo, membershipId);
1139
    }
1123
    }
1140
 
1124
 
1141
    public void mapBag() throws Exception {
-
 
1142
        List<Item> items = itemRepository.selectAllItems(10006, Arrays.asList("OnePlus", "Oppo", "Realme", "Samsung", "Vivo", "Xiaomi"));
-
 
1143
        items.stream().collect(Collectors.groupingBy(x -> x.getBrand()));
-
 
1144
 
-
 
1145
        List<CSVRecord> csvRecordList = FileUtil.readFile(new File("/home/amit/Documents/sample.csv"));
-
 
1146
        for (CSVRecord csvRecord : csvRecordList) {
-
 
1147
            Sample sample = new Sample(csvRecord.get(0), csvRecord.get(1), csvRecord.get(2));
-
 
1148
            //StringUtils.getLevenshteinDistance()
-
 
1149
        }
-
 
1150
    }
-
 
1151
 
-
 
1152
    public void reverseInvalidActivation(List<Integer> inventoryItemIds) throws Exception {
1125
    public void reverseInvalidActivation(List<Integer> inventoryItemIds) throws Exception {
1153
        orderService.reverseActivationScheme(inventoryItemIds);
1126
        orderService.reverseActivationScheme(inventoryItemIds);
1154
    }
1127
    }
1155
 
1128
 
1156
    public void processBids(ProfitMandiConstants.BID_CRON_ENUM schedule) throws Exception {
1129
    public void processBids(ProfitMandiConstants.BID_CRON_ENUM schedule) throws Exception {
Line 1168... Line 1141...
1168
    CartService cartService;
1141
    CartService cartService;
1169
 
1142
 
1170
    @Autowired
1143
    @Autowired
1171
    private CommonPaymentService commonPaymentService;
1144
    private CommonPaymentService commonPaymentService;
1172
 
1145
 
1173
 
-
 
1174
    @Autowired
1146
    @Autowired
1175
    LoanRepository loanRepository;
1147
    LoanRepository loanRepository;
1176
 
1148
 
1177
    @Autowired
1149
    @Autowired
1178
    LoanStatementRepository loanStatementRepository;
1150
    LoanStatementRepository loanStatementRepository;
1179
 
1151
 
1180
 
-
 
1181
    //Reverse CD of a specified Loan
1152
    //Reverse CD of a specified Loan
1182
    public void reverseCD() throws ProfitMandiBusinessException {
1153
    public void reverseCD() throws ProfitMandiBusinessException {
1183
        Loan loan = loanRepository.selectByLoanId(45975);
1154
        Loan loan = loanRepository.selectByLoanId(45975);
1184
        List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
1155
        List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
1185
        loanStatements.stream().filter(x->x.getLoanReferenceType().equals(LoanReferenceType.PRINCIPAL) && x.getAmount().compareTo(BigDecimal.ZERO) > 0).forEach(x->loanStatementRepository.delete(x));
1156
        loanStatements.stream().filter(x->x.getLoanReferenceType().equals(LoanReferenceType.PRINCIPAL) && x.getAmount().compareTo(BigDecimal.ZERO) > 0).forEach(x->loanStatementRepository.delete(x));
Line 1385... Line 1356...
1385
                "Total Sale Amount Reversal - {}, Total Wallet Amount Reversal {}, Total Scheme Reversal Amount - {}",
1356
                "Total Sale Amount Reversal - {}, Total Wallet Amount Reversal {}, Total Scheme Reversal Amount - {}",
1386
                saleAmount, totalAmount, schemeReverseAmount);
1357
                saleAmount, totalAmount, schemeReverseAmount);
1387
        // throw new Exception();
1358
        // throw new Exception();
1388
    }
1359
    }
1389
 
1360
 
1390
    public void createGeofence() throws IOException, ProfitMandiBusinessException {
-
 
1391
 
-
 
1392
        // List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
-
 
1393
        // for (FofoStore fofoStore : fofoStores) {
-
 
1394
        // if (fofoStore.getLatitude() != null && fofoStore.getLongitude() != null) {
-
 
1395
        CustomRetailer customRetailer = retailerService.getFofoRetailer(175138812);
-
 
1396
        JSONObject geofe = new JSONObject();
-
 
1397
        JSONArray geofences = new JSONArray();
-
 
1398
        JSONObject geometry = new JSONObject();
-
 
1399
        JSONObject geo = new JSONObject();
-
 
1400
        JSONArray coordinates = new JSONArray();
-
 
1401
        ArrayList<Double> crds = new ArrayList<>();
-
 
1402
        crds.add(79.739197);
-
 
1403
        crds.add(27.961215);
-
 
1404
        geo.put("type", "Point");
-
 
1405
        geo.put("coordinates", crds);
-
 
1406
        geometry.put("geometry", geo);
-
 
1407
        JSONObject metadata = new JSONObject();
-
 
1408
        metadata.put("name", customRetailer.getBusinessName());
-
 
1409
        metadata.put("city", customRetailer.getAddress().getCity());
-
 
1410
        metadata.put("Code", customRetailer.getCode());
-
 
1411
        geometry.put("metadata", metadata);
-
 
1412
        geometry.put("radius", 200);
-
 
1413
 
-
 
1414
        geofences.put(geometry);
-
 
1415
        geofe.put("geofences", geofences);
-
 
1416
        String authString = "Basic "
-
 
1417
                + Base64.getEncoder().encodeToString(String.format("%s:%s", ACCOUNT_ID, SECRET_KEY).getBytes());
-
 
1418
 
-
 
1419
        String responseBody = restClient.postJson("https://v3.api.hypertrack.com/geofences",
-
 
1420
                geofe.toString(), Collections.singletonMap("Authorization", authString));
-
 
1421
        JSONArray ja = new JSONArray(responseBody);
-
 
1422
        LOGGER.info("geofence" + ja);
-
 
1423
        LOGGER.info("jalength" + ja.length());
-
 
1424
        /*
-
 
1425
         * for (int i = 0; i < ja.length(); i++) { JSONObject c = ja.getJSONObject(i);
-
 
1426
         * String geofenceId = c.getString("geofence_id"); LOGGER.info("geofenceId" +
-
 
1427
         * geofenceId); FofoStoreGeofence fsg = new FofoStoreGeofence();
-
 
1428
         * fsg.setFofoId(customRetailer.getPartnerId()); fsg.setGeofenceId(geofenceId);
-
 
1429
         * fofoStoreGeofenceRepository.persist(fsg); }
-
 
1430
         *
-
 
1431
         * }
-
 
1432
         *
-
 
1433
         * }
-
 
1434
         */
-
 
1435
 
-
 
1436
    }
-
 
1437
 
-
 
1438
    public void getAllGeofences() throws Exception {
-
 
1439
        String authString = "Basic "
-
 
1440
                + Base64.getEncoder().encodeToString(String.format("%s:%s", ACCOUNT_ID, SECRET_KEY).getBytes());
-
 
1441
        String body = restClient.get("https://v3.api.hypertrack.com/geofences",
-
 
1442
                null, Collections.singletonMap("Authorization", authString));
-
 
1443
        LOGGER.info("response" + body);
-
 
1444
    }
-
 
1445
 
-
 
1446
    public void deleteGeofences(List<String> geofenceIds) throws IOException, ProfitMandiBusinessException {
-
 
1447
        String authString = "Basic "
-
 
1448
                + Base64.getEncoder().encodeToString(String.format("%s:%s", ACCOUNT_ID, SECRET_KEY).getBytes());
-
 
1449
 
-
 
1450
        try (CloseableHttpClient client = HttpClientFactory.apacheHttp()) {
-
 
1451
            for (String geofenceId : geofenceIds) {
-
 
1452
                HttpDelete delete = new HttpDelete("https://v3.api.hypertrack.com/geofences/" + geofenceId);
-
 
1453
                delete.setHeader("Authorization", authString);
-
 
1454
                LOGGER.info("geofenceId" + geofenceId);
-
 
1455
                try (CloseableHttpResponse response = client.execute(delete)) {
-
 
1456
                    String body = response.getEntity() != null ? EntityUtils.toString(response.getEntity()) : "";
-
 
1457
                    LOGGER.info("response" + body);
-
 
1458
                }
-
 
1459
            }
-
 
1460
        }
-
 
1461
    }
-
 
1462
 
-
 
1463
    public void processSchemeOut(int fofoId, int orderId) throws Exception {
1361
    public void processSchemeOut(int fofoId, int orderId) throws Exception {
1464
        schemeService.processSchemeOut(orderId, fofoId);
1362
        schemeService.processSchemeOut(orderId, fofoId);
1465
 
1363
 
1466
    }
1364
    }
1467
 
1365
 
Line 1836... Line 1734...
1836
 
1734
 
1837
    public void changeFulfillmentWarehouse(int orderId, int whId) throws ProfitMandiBusinessException {
1735
    public void changeFulfillmentWarehouse(int orderId, int whId) throws ProfitMandiBusinessException {
1838
        transactionService.changeFulfillmentWarehouse(orderId, whId);
1736
        transactionService.changeFulfillmentWarehouse(orderId, whId);
1839
    }
1737
    }
1840
 
1738
 
1841
 
-
 
1842
    public void findCNDiff() throws ProfitMandiBusinessException {
1739
    public void findCNDiff() throws ProfitMandiBusinessException {
1843
        LocalDate startDate = LocalDate.of(2022, 9, 01);
1740
        LocalDate startDate = LocalDate.of(2022, 9, 01);
1844
        List<UserWalletHistory> userWalletHistories = userWalletHistoryRepository.selectAllByDateType(startDate.atStartOfDay(), startDate.plusYears(3).atStartOfDay().withMonth(Month.JANUARY.getValue()), Arrays.asList(WalletReferenceType.ACTIVATION_SCHEME, WalletReferenceType.ADDITIONAL_SCHEME, WalletReferenceType.INVESTMENT_PAYOUT
1741
        List<UserWalletHistory> userWalletHistories = userWalletHistoryRepository.selectAllByDateType(startDate.atStartOfDay(), startDate.plusYears(3).atStartOfDay().withMonth(Month.JANUARY.getValue()), Arrays.asList(WalletReferenceType.ACTIVATION_SCHEME, WalletReferenceType.ADDITIONAL_SCHEME, WalletReferenceType.INVESTMENT_PAYOUT
1845
                , WalletReferenceType.SPECIAL_SUPPORT, WalletReferenceType.PRICE_DROP, WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
1742
                , WalletReferenceType.SPECIAL_SUPPORT, WalletReferenceType.PRICE_DROP, WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
1846
 
1743