Subversion Repositories SmartDukaan

Rev

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

Rev 33064 Rev 33078
Line 22... Line 22...
22
import com.spice.profitmandi.common.web.client.RestClient;
22
import com.spice.profitmandi.common.web.client.RestClient;
23
import com.spice.profitmandi.dao.Interface.Campaign;
23
import com.spice.profitmandi.dao.Interface.Campaign;
24
import com.spice.profitmandi.dao.cart.CartService;
24
import com.spice.profitmandi.dao.cart.CartService;
25
import com.spice.profitmandi.dao.entity.auth.AuthUser;
25
import com.spice.profitmandi.dao.entity.auth.AuthUser;
26
import com.spice.profitmandi.dao.entity.auth.PartnerCollectionRemark;
26
import com.spice.profitmandi.dao.entity.auth.PartnerCollectionRemark;
27
import com.spice.profitmandi.dao.entity.catalog.FocusedModel;
-
 
28
import com.spice.profitmandi.dao.entity.catalog.Item;
27
import com.spice.profitmandi.dao.entity.catalog.*;
29
import com.spice.profitmandi.dao.entity.catalog.Scheme;
-
 
30
import com.spice.profitmandi.dao.entity.catalog.TagListing;
28
import com.spice.profitmandi.dao.entity.cs.NonSdBuying;
31
import com.spice.profitmandi.dao.entity.cs.Position;
29
import com.spice.profitmandi.dao.entity.cs.Position;
32
import com.spice.profitmandi.dao.entity.cs.Ticket;
30
import com.spice.profitmandi.dao.entity.cs.Ticket;
33
import com.spice.profitmandi.dao.entity.dtr.User;
31
import com.spice.profitmandi.dao.entity.dtr.User;
34
import com.spice.profitmandi.dao.entity.dtr.*;
32
import com.spice.profitmandi.dao.entity.dtr.*;
35
import com.spice.profitmandi.dao.entity.fofo.*;
33
import com.spice.profitmandi.dao.entity.fofo.*;
Line 51... Line 49...
51
import com.spice.profitmandi.dao.enumuration.transaction.LoanReferenceType;
49
import com.spice.profitmandi.dao.enumuration.transaction.LoanReferenceType;
52
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
50
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
53
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
51
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
54
import com.spice.profitmandi.dao.model.*;
52
import com.spice.profitmandi.dao.model.*;
55
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
53
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
-
 
54
import com.spice.profitmandi.dao.repository.auth.NonSdBuyingRepository;
56
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionRemarkRepository;
55
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionRemarkRepository;
57
import com.spice.profitmandi.dao.repository.catalog.*;
56
import com.spice.profitmandi.dao.repository.catalog.*;
58
import com.spice.profitmandi.dao.repository.cs.CsService;
57
import com.spice.profitmandi.dao.repository.cs.CsService;
59
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
58
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
60
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
59
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
Line 68... Line 67...
68
import com.spice.profitmandi.dao.repository.warehouse.*;
67
import com.spice.profitmandi.dao.repository.warehouse.*;
69
import com.spice.profitmandi.dao.service.biuedart.BluedartAuthService;
68
import com.spice.profitmandi.dao.service.biuedart.BluedartAuthService;
70
import com.spice.profitmandi.dao.service.biuedart.BluedartService;
69
import com.spice.profitmandi.dao.service.biuedart.BluedartService;
71
import com.spice.profitmandi.dao.service.solr.FofoSolr;
70
import com.spice.profitmandi.dao.service.solr.FofoSolr;
72
import com.spice.profitmandi.service.*;
71
import com.spice.profitmandi.service.*;
-
 
72
import com.spice.profitmandi.service.catalog.BrandsService;
73
import com.spice.profitmandi.service.integrations.CCAvenuePaymentService;
73
import com.spice.profitmandi.service.integrations.CCAvenuePaymentService;
74
import com.spice.profitmandi.service.integrations.RazorpayPaymentService;
74
import com.spice.profitmandi.service.integrations.RazorpayPaymentService;
75
import com.spice.profitmandi.service.integrations.bharti.model.BAGInsuranceModel;
75
import com.spice.profitmandi.service.integrations.bharti.model.BAGInsuranceModel;
76
import com.spice.profitmandi.service.integrations.psismart.PsiSmartService;
76
import com.spice.profitmandi.service.integrations.psismart.PsiSmartService;
77
import com.spice.profitmandi.service.integrations.smartping.SmartPingService;
77
import com.spice.profitmandi.service.integrations.smartping.SmartPingService;
Line 346... Line 346...
346
 
346
 
347
    @Autowired
347
    @Autowired
348
    private RetailerService retailerService;
348
    private RetailerService retailerService;
349
 
349
 
350
    @Autowired
350
    @Autowired
-
 
351
    private BrandsRepository brandsRepository;
-
 
352
 
-
 
353
    @Autowired
351
    private TransactionService transactionService;
354
    private TransactionService transactionService;
352
 
355
 
353
    @Autowired
356
    @Autowired
354
    private ItemRepository itemRepository;
357
    private ItemRepository itemRepository;
355
 
358
 
Line 1027... Line 1030...
1027
    @Autowired
1030
    @Autowired
1028
    InvoiceService invoiceService;
1031
    InvoiceService invoiceService;
1029
 
1032
 
1030
    public void test() throws Exception {
1033
    public void test() throws Exception {
1031
 
1034
 
1032
        this.setInventoryItemIdToPriceDropImei();
1035
        // this.setInventoryItemIdToPriceDropImei();
-
 
1036
       // this.reviewNonSdBuyingBrand();
1033
        //fofoSolr.populateTagItems();
1037
        //fofoSolr.populateTagItems();
1034
        //System.out.println(smartPingService.getAllAgentsByEmail());
1038
        //System.out.println(smartPingService.getAllAgentsByEmail());
1035
        //System.out.println(psiSmartService.getRegistrationEndPoint("9990381569"));
1039
        //System.out.println(psiSmartService.getRegistrationEndPoint("9990381569"));
1036
        //migrateValentine();
1040
        //migrateValentine();
1037
        //Map<Integer, List<Offer>> offerMap = offerRepository.selectAllPublishedMapByPartner(YearMonth.now());
1041
        //Map<Integer, List<Offer>> offerMap = offerRepository.selectAllPublishedMapByPartner(YearMonth.now());
Line 3030... Line 3034...
3030
        sb.append("</tbody></table></body></html>");
3034
        sb.append("</tbody></table></body></html>");
3031
 
3035
 
3032
        return sb.toString();
3036
        return sb.toString();
3033
    }
3037
    }
3034
 
3038
 
-
 
3039
    private String getMessageForUnauthorizedBuying(List<NonSdBuying> nsb) throws
-
 
3040
            ProfitMandiBusinessException {
-
 
3041
        StringBuilder sb = new StringBuilder();
-
 
3042
        sb.append("<html><body><p>Alert</p><p>Unauthorized Buying-</p>" + "<br/>" +
-
 
3043
                "<table style='border:1px solid black ;padding: 5px';>");
-
 
3044
        sb.append("<tbody>" +
-
 
3045
                "<tr>" +
-
 
3046
                "<th style='border:1px solid black;padding: 5px'>PartnerName</th>" +
-
 
3047
                "<th style='border:1px solid black;padding: 5px'>Brand Name</th>" +
-
 
3048
                "<th style='border:1px solid black;padding: 5px'>Brand Value</th>" +
-
 
3049
                "<th style='border:1px solid black;padding: 5px'>Created At</th>" +
-
 
3050
                "<th style='border:1px solid black;padding: 5px'>Reason</th>" +
-
 
3051
                "</tr>");
-
 
3052
        for (NonSdBuying entry : nsb) {
-
 
3053
            CustomRetailer customRetailer = retailerService.getFofoRetailer(entry.getFofoId());
-
 
3054
            List<Integer> brandIds = Collections.singletonList(entry.getBrandId());
-
 
3055
            BrandCatalog brandsDisplay = brandsRepository.selectByIds(brandIds).get(0);
-
 
3056
            sb.append("<tr>");
-
 
3057
            sb.append("<td style='border:1px solid black;padding: 5px'>" + customRetailer.getBusinessName() + "(" + customRetailer.getCode() + ")" + "</td>");
-
 
3058
            sb.append("<td style='border:1px solid black;padding: 5px'>" + brandsDisplay.getName() + "</td>");
-
 
3059
            sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getBrandValue() + "</td>");
-
 
3060
            sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getCreateTimestamp().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + "</td>");
-
 
3061
            sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getReason() + "</td>");
-
 
3062
            sb.append("</tr>");
-
 
3063
        }
-
 
3064
 
-
 
3065
        sb.append("</tbody></table></body></html>");
-
 
3066
 
-
 
3067
        return sb.toString();
-
 
3068
    }
-
 
3069
 
3035
    public void reverseWallet() throws Exception {
3070
    public void reverseWallet() throws Exception {
3036
        LocalDate localDate = LocalDate.of(2020, 10, 28);
3071
        LocalDate localDate = LocalDate.of(2020, 10, 28);
3037
        List<UserWalletHistory> uwhList = userWalletHistoryRepository.selectAllByDateType(localDate.atStartOfDay(), localDate.plusDays(1).atStartOfDay(), Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
3072
        List<UserWalletHistory> uwhList = userWalletHistoryRepository.selectAllByDateType(localDate.atStartOfDay(), localDate.plusDays(1).atStartOfDay(), Arrays.asList(WalletReferenceType.SCHEME_IN, WalletReferenceType.SCHEME_OUT));
3038
        for (UserWalletHistory uwh : uwhList) {
3073
        for (UserWalletHistory uwh : uwhList) {
3039
            if (uwh.getBusinessTimestamp().getMonth().equals(Month.SEPTEMBER)) {
3074
            if (uwh.getBusinessTimestamp().getMonth().equals(Month.SEPTEMBER)) {
Line 3478... Line 3513...
3478
            }
3513
            }
3479
 
3514
 
3480
        }
3515
        }
3481
    }
3516
    }
3482
 
3517
 
-
 
3518
 
-
 
3519
    @Autowired
-
 
3520
    private NonSdBuyingRepository nonSdBuyingRepository;
-
 
3521
 
-
 
3522
    //Non Sd Buying
-
 
3523
    public void reviewNonSdBuyingBrand() throws
-
 
3524
            ProfitMandiBusinessException, MessagingException, UnsupportedEncodingException {
-
 
3525
        List<NonSdBuying> nonSdByuingActiveList = nonSdBuyingRepository.selectAllActiveNonSDBuyingList(true);
-
 
3526
        Map<Integer, NonSdBuying> unAuthorizedBuyingMap = nonSdByuingActiveList.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
-
 
3527
 
-
 
3528
        if (!unAuthorizedBuyingMap.isEmpty()) {
-
 
3529
            for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMappingByCategoryIds(Arrays.asList(ProfitMandiConstants.TICKET_CATEGORY_RBM, ProfitMandiConstants.TICKET_CATEGORY_SALES), true).entrySet()) {
-
 
3530
                List<NonSdBuying> unAuthorizedfilteredRows = storeGuyEntry.getValue().stream()
-
 
3531
                        .map(x -> unAuthorizedBuyingMap.get(x)).filter(x -> x != null).collect(Collectors.toList());
-
 
3532
                if(!unAuthorizedfilteredRows.isEmpty()){
-
 
3533
                    String subject = "Unauthorized Buying";
-
 
3534
                    String messageText = this.getMessageForUnauthorizedBuying(unAuthorizedfilteredRows);
-
 
3535
 
-
 
3536
                    MimeMessage message = mailSender.createMimeMessage();
-
 
3537
                    MimeMessageHelper helper = new MimeMessageHelper(message, true);
-
 
3538
                    String[] email = new String[]{storeGuyEntry.getKey()};
-
 
3539
                   // String[] email = {"ranu.rajput@smartdukaan.com"};
-
 
3540
 
-
 
3541
                    helper.setSubject(subject);
-
 
3542
                    helper.setText(messageText, true);
-
 
3543
                    helper.setTo(email);
-
 
3544
                    InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "Smartdukaan Alerts");
-
 
3545
                    helper.setFrom(senderAddress);
-
 
3546
                    mailSender.send(message);
-
 
3547
                    LOGGER.info("unAuthorizedfilteredRows {}", unAuthorizedfilteredRows);
-
 
3548
                }
-
 
3549
 
-
 
3550
 
-
 
3551
            }
-
 
3552
 
-
 
3553
        }
-
 
3554
    }
-
 
3555
 
3483
    @Autowired
3556
    @Autowired
3484
    private LoanRepository loanRepository;
3557
    private LoanRepository loanRepository;
3485
 
3558
 
3486
    @Autowired
3559
    @Autowired
3487
    private LoanStatementRepository loanStatementRepository;
3560
    private LoanStatementRepository loanStatementRepository;
Line 4216... Line 4289...
4216
            warehouseInventoryItem.setLastScanType(in.shop2020.warehouse.ScanType.PURCHASE);
4289
            warehouseInventoryItem.setLastScanType(in.shop2020.warehouse.ScanType.PURCHASE);
4217
            warehouseInventoryItem.setCurrentQuantity(warehouseInventoryItem.getCurrentQuantity() + warehouseScan.getQuantity());
4290
            warehouseInventoryItem.setCurrentQuantity(warehouseInventoryItem.getCurrentQuantity() + warehouseScan.getQuantity());
4218
        }
4291
        }
4219
 
4292
 
4220
        for (Order order : orderList) {
4293
        for (Order order : orderList) {
4221
            if(order.getBillingTimestamp()!=null) {
4294
            if (order.getBillingTimestamp() != null) {
4222
                order.setStatus(OrderStatus.ACCEPTED);
4295
                order.setStatus(OrderStatus.ACCEPTED);
4223
                order.setStatusDescription("Submitted for Processing");
4296
                order.setStatusDescription("Submitted for Processing");
4224
                order.setBillingTimestamp(null);
4297
                order.setBillingTimestamp(null);
4225
                order.setBilledBy(null);
4298
                order.setBilledBy(null);
4226
                order.setSerialNumber(null);
4299
                order.setSerialNumber(null);