Subversion Repositories SmartDukaan

Rev

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

Rev 34902 Rev 34917
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.affiliate.AffiliateLinks;
10
import com.spice.profitmandi.dao.entity.affiliate.AffiliateEarnings;
11
import com.spice.profitmandi.dao.entity.affiliate.AffiliateProduct;
11
import com.spice.profitmandi.dao.entity.affiliate.AffiliateProduct;
12
import com.spice.profitmandi.dao.entity.catalog.LiquidationDetail;
12
import com.spice.profitmandi.dao.entity.catalog.LiquidationDetail;
13
import com.spice.profitmandi.common.solr.SolrService;
13
import com.spice.profitmandi.common.solr.SolrService;
14
import com.spice.profitmandi.common.util.FormattingUtils;
14
import com.spice.profitmandi.common.util.FormattingUtils;
15
import com.spice.profitmandi.common.util.PdfUtils;
15
import com.spice.profitmandi.common.util.PdfUtils;
Line 40... Line 40...
40
import com.spice.profitmandi.dao.repository.fofo.*;
40
import com.spice.profitmandi.dao.repository.fofo.*;
41
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
41
import com.spice.profitmandi.dao.repository.inventory.ItemAvailabilityCacheRepository;
42
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
42
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
43
import com.spice.profitmandi.dao.repository.user.UserRepository;
43
import com.spice.profitmandi.dao.repository.user.UserRepository;
44
import com.spice.profitmandi.dao.repository.webRepository.NavBarRepository;
44
import com.spice.profitmandi.dao.repository.webRepository.NavBarRepository;
-
 
45
import com.spice.profitmandi.dao.service.AffiliateService;
45
import com.spice.profitmandi.dao.service.BidService;
46
import com.spice.profitmandi.dao.service.BidService;
46
import com.spice.profitmandi.dao.service.OTPResponse;
47
import com.spice.profitmandi.dao.service.OTPResponse;
47
import com.spice.profitmandi.service.CustomerService;
48
import com.spice.profitmandi.service.CustomerService;
48
import com.spice.profitmandi.service.EmailService;
49
import com.spice.profitmandi.service.EmailService;
49
import com.spice.profitmandi.service.NotificationService;
50
import com.spice.profitmandi.service.NotificationService;
Line 88... Line 89...
88
import javax.servlet.http.HttpServletResponse;
89
import javax.servlet.http.HttpServletResponse;
89
import java.io.ByteArrayInputStream;
90
import java.io.ByteArrayInputStream;
90
import java.io.ByteArrayOutputStream;
91
import java.io.ByteArrayOutputStream;
91
import java.io.IOException;
92
import java.io.IOException;
92
import java.io.InputStream;
93
import java.io.InputStream;
93
import java.time.LocalDate;
-
 
94
import java.time.LocalDateTime;
94
import java.time.LocalDateTime;
95
import java.time.LocalTime;
95
import java.time.LocalTime;
96
import java.time.format.DateTimeFormatter;
96
import java.time.format.DateTimeFormatter;
97
import java.util.*;
97
import java.util.*;
98
import java.util.stream.Collectors;
98
import java.util.stream.Collectors;
Line 241... Line 241...
241
    WalletService walletService;
241
    WalletService walletService;
242
 
242
 
243
    @Autowired
243
    @Autowired
244
    AffiliateLinkRepository affiliateLinkRepository;
244
    AffiliateLinkRepository affiliateLinkRepository;
245
 
245
 
-
 
246
    @Autowired
-
 
247
    AffiliateService affiliateService;
-
 
248
 
246
    List<String> filterableParams = Arrays.asList("brand");
249
    List<String> filterableParams = Arrays.asList("brand");
247
 
250
 
248
    @RequestMapping(value = "/store/entity/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
251
    @RequestMapping(value = "/store/entity/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
249
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
252
    @ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
250
    @ApiOperation(value = "Get unit deal object")
253
    @ApiOperation(value = "Get unit deal object")
Line 336... Line 339...
336
    public ResponseEntity<?> checkRegistrationUsingMobile(HttpServletRequest request, @PathVariable String mobile ,@RequestParam(required = false, defaultValue = "false") boolean isSmartSeller) throws Exception {
339
    public ResponseEntity<?> checkRegistrationUsingMobile(HttpServletRequest request, @PathVariable String mobile ,@RequestParam(required = false, defaultValue = "false") boolean isSmartSeller) throws Exception {
337
        try {
340
        try {
338
            Customer customer = customerRepository.selectByMobileNumber(mobile);
341
            Customer customer = customerRepository.selectByMobileNumber(mobile);
339
            customer.setPasswordExist(StringUtils.isNotEmpty(customer.getPassword()));
342
            customer.setPasswordExist(StringUtils.isNotEmpty(customer.getPassword()));
340
            if(isSmartSeller){
343
            if(isSmartSeller){
-
 
344
                //ToDo: Send welcome mail
341
                customer.setSmartSeller(isSmartSeller);
345
                customer.setSmartSeller(isSmartSeller);
-
 
346
                List<String> bccTo = Arrays.asList("sdtech@smartdukaan.com", "sriwant.wariz@smartdukaan.com");
-
 
347
                String[] userEmail = new String[]{customer.getEmailId()};
-
 
348
                emailService.sendMailWithAttachments("Welcome to SmartDukaan's SmartSeller", "welcome-smartseller.vm", null, userEmail, null, bccTo.toArray(new String[0]));
342
            }
349
            }
343
            return responseSender.ok(new CustomerModel(true, customer));
350
            return responseSender.ok(new CustomerModel(true, customer));
344
        } catch (Exception e) {
351
        } catch (Exception e) {
345
            return responseSender.ok(new CustomerModel(false, null));
352
            return responseSender.ok(new CustomerModel(false, null));
346
        }
353
        }
Line 401... Line 408...
401
        customer.setEmailId(userModel.getEmail());
408
        customer.setEmailId(userModel.getEmail());
402
        customer.setFirstName(userModel.getFirstName());
409
        customer.setFirstName(userModel.getFirstName());
403
        customer.setLastName(userModel.getLastName());
410
        customer.setLastName(userModel.getLastName());
404
        customer.setMobileNumber(userModel.getMobile());
411
        customer.setMobileNumber(userModel.getMobile());
405
        customer.setSmartSeller(userModel.getIsSmartSeller());
412
        customer.setSmartSeller(userModel.getIsSmartSeller());
-
 
413
        if (userModel.getIsSmartSeller()){
-
 
414
            if (userModel.getReferralCode() != null && !userModel.getReferralCode().isEmpty()) {
-
 
415
                int referrerId = Integer.parseInt(userModel.getReferralCode().substring(2));
-
 
416
                AffiliateEarnings earnings = new AffiliateEarnings();
-
 
417
                earnings.setType(ProfitMandiConstants.EARNING_TYPE.REFERRAL);
-
 
418
                earnings.setAffiliateCode(userModel.getReferralCode());
-
 
419
                earnings.setPoints(ProfitMandiConstants.SMARTSELLER_REFERRAL_POINTS);
-
 
420
                earnings.setAmount((float) ProfitMandiConstants.SMARTSELLER_REFERRAL_POINTS);
-
 
421
                earnings.setCustomerId(referrerId);
-
 
422
                earnings.setOrderId(referrerId);
-
 
423
                earnings.setItemId(referrerId);
-
 
424
                earnings.setExpireAt(LocalDateTime.now().plusYears(1));
-
 
425
                affiliateService.createEarnings(earnings);
-
 
426
                customer.setReferralCode(userModel.getReferralCode());
-
 
427
            }
-
 
428
            List<String> bccTo = Arrays.asList("sdtech@smartdukaan.com", "sriwant.wariz@smartdukaan.com");
-
 
429
            String[] userEmail = new String[]{userModel.getEmail()};
-
 
430
            emailService.sendMailWithAttachments("Welcome to SmartDukaan's SmartSeller", "welcome-smartseller.vm", null, userEmail, null, bccTo.toArray(new String[0]));
-
 
431
        }
406
        return responseSender.ok(customerService.addCustomer(customer));
432
        return responseSender.ok(customerService.addCustomer(customer));
407
    }
433
    }
408
    @RequestMapping(value = "/store/signinWithOtp", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
434
    @RequestMapping(value = "/store/signinWithOtp", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
409
    public ResponseEntity<?> signInWithOtp(HttpServletRequest request,
435
    public ResponseEntity<?> signInWithOtp(HttpServletRequest request,
410
                                           @RequestBody OtpLoginRequest otpLoginRequest) throws Exception {
436
                                           @RequestBody OtpLoginRequest otpLoginRequest) throws Exception {
Line 534... Line 560...
534
 
560
 
535
            emailIds.addAll(
561
            emailIds.addAll(
536
                    csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_MARKETING, Arrays.asList(EscalationType.L1, EscalationType.L2, EscalationType.L3, EscalationType.L4)).stream().map(x -> x.getEmailId()).collect(Collectors.toList()));
562
                    csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_MARKETING, Arrays.asList(EscalationType.L1, EscalationType.L2, EscalationType.L3, EscalationType.L4)).stream().map(x -> x.getEmailId()).collect(Collectors.toList()));
537
            emailIds.add("tarun.verma@smartdukaan.com");
563
            emailIds.add("tarun.verma@smartdukaan.com");
538
            emailIds.add("devkinandan.lal@smartdukaan.com");
564
            emailIds.add("devkinandan.lal@smartdukaan.com");
-
 
565
            emailIds.add("sdtech@smartdukaan.com");
539
            emailIds.add("vikas.jangra@smartdukaan.com");
566
            emailIds.add("sourcing@smartdukaan.com");
540
            List<User> user = dtrUserRepository.selectAllByEmailIds(emailIds);
567
            List<User> user = dtrUserRepository.selectAllByEmailIds(emailIds);
541
            List<Integer> userIds = user.stream().map(x -> x.getId()).collect(Collectors.toList());
568
            List<Integer> userIds = user.stream().map(x -> x.getId()).collect(Collectors.toList());
542
 
569
 
543
            logger.info("userIds" + userIds);
570
            logger.info("userIds" + userIds);
544
            SendNotificationModel sendNotificationModel = new SendNotificationModel();
571
            SendNotificationModel sendNotificationModel = new SendNotificationModel();