| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
2 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 3 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
3 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 4 |
import com.spice.profitmandi.dao.entity.fofo.TrialForm;
|
4 |
import com.spice.profitmandi.dao.entity.fofo.TrialForm;
|
| 5 |
import com.spice.profitmandi.dao.repository.trialOnboarding.TrialFormRepository;
|
5 |
import com.spice.profitmandi.dao.repository.trialOnboarding.TrialFormRepository;
|
| - |
|
6 |
import com.spice.profitmandi.dao.service.TrialService;
|
| 6 |
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
|
7 |
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
|
| 7 |
import com.spice.profitmandi.service.integrations.gstpro.entity.GstDetails;
|
8 |
import com.spice.profitmandi.service.integrations.gstpro.entity.GstDetails;
|
| 8 |
import org.apache.logging.log4j.LogManager;
|
9 |
import org.apache.logging.log4j.LogManager;
|
| 9 |
import org.apache.logging.log4j.Logger;
|
10 |
import org.apache.logging.log4j.Logger;
|
| 10 |
import org.springframework.beans.factory.annotation.Autowired;
|
11 |
import org.springframework.beans.factory.annotation.Autowired;
|
| Line 18... |
Line 19... |
| 18 |
import javax.servlet.http.HttpServletRequest;
|
19 |
import javax.servlet.http.HttpServletRequest;
|
| 19 |
import javax.transaction.Transactional;
|
20 |
import javax.transaction.Transactional;
|
| 20 |
import java.time.LocalDateTime;
|
21 |
import java.time.LocalDateTime;
|
| 21 |
import java.util.Collections;
|
22 |
import java.util.Collections;
|
| 22 |
import java.util.List;
|
23 |
import java.util.List;
|
| 23 |
|
- |
|
| - |
|
24 |
import java.util.Map;
|
| 24 |
|
25 |
|
| 25 |
|
26 |
|
| 26 |
@Controller
|
27 |
@Controller
|
| 27 |
@Transactional
|
28 |
@Transactional
|
| 28 |
public class TrialUserController {
|
29 |
public class TrialUserController {
|
| Line 34... |
Line 35... |
| 34 |
TrialFormRepository trialOnboardingRepository;
|
35 |
TrialFormRepository trialOnboardingRepository;
|
| 35 |
|
36 |
|
| 36 |
@Autowired
|
37 |
@Autowired
|
| 37 |
ResponseSender responseSender;
|
38 |
ResponseSender responseSender;
|
| 38 |
|
39 |
|
| - |
|
40 |
|
| - |
|
41 |
@Autowired
|
| - |
|
42 |
TrialService trialService;
|
| - |
|
43 |
|
| 39 |
private static final Logger LOGGER = LogManager.getLogger(DealsController.class);
|
44 |
private static final Logger LOGGER = LogManager.getLogger(DealsController.class);
|
| 40 |
|
45 |
|
| 41 |
|
46 |
|
| 42 |
@RequestMapping(value = "/gstValidate", method = RequestMethod.GET)
|
47 |
@RequestMapping(value = "/gstValidate", method = RequestMethod.GET)
|
| 43 |
public ResponseEntity<?> gstValidate(HttpServletRequest request, @RequestParam String gstNo) throws Exception {
|
48 |
public ResponseEntity<?> gstValidate(HttpServletRequest request, @RequestParam String gstNo) throws Exception {
|
| Line 60... |
Line 65... |
| 60 |
return responseSender.badRequest("Mobile number is required");
|
65 |
return responseSender.badRequest("Mobile number is required");
|
| 61 |
}
|
66 |
}
|
| 62 |
try {
|
67 |
try {
|
| 63 |
TrialForm existingUser = trialOnboardingRepository.findByMobile(trialForm.getMobile());
|
68 |
TrialForm existingUser = trialOnboardingRepository.findByMobile(trialForm.getMobile());
|
| 64 |
if (existingUser != null) {
|
69 |
if (existingUser != null) {
|
| 65 |
return responseSender.internalServerError("User already exists");
|
70 |
return responseSender.badRequest("User already exists");
|
| 66 |
}
|
71 |
}
|
| 67 |
trialForm.setStatus(ProfitMandiConstants.Status.PENDING);
|
72 |
trialForm.setStatus(ProfitMandiConstants.Status.PENDING);
|
| 68 |
trialForm.setCreatedOn(LocalDateTime.now());
|
73 |
trialForm.setCreatedOn(LocalDateTime.now());
|
| 69 |
trialOnboardingRepository.persist(trialForm);
|
74 |
trialOnboardingRepository.persist(trialForm);
|
| - |
|
75 |
trialService.sentMailToTrialUser(trialForm);
|
| - |
|
76 |
trialService.sentMailForTrialUser(trialForm);
|
| 70 |
return responseSender.ok(trialForm);
|
77 |
return responseSender.ok(trialForm);
|
| 71 |
|
78 |
|
| 72 |
} catch (Exception e) {
|
79 |
} catch (Exception e) {
|
| 73 |
e.printStackTrace();
|
80 |
e.printStackTrace();
|
| 74 |
return responseSender.internalServerError("Registration failed: " + e.getMessage());
|
81 |
return responseSender.internalServerError("Registration failed: " + e.getMessage());
|
| 75 |
}
|
82 |
}
|
| 76 |
}
|
83 |
}
|
| - |
|
84 |
@RequestMapping(value = "/trial-consent", method = RequestMethod.POST)
|
| - |
|
85 |
public ResponseEntity<?> consent(@RequestBody Map<String, String> request) throws Exception {
|
| - |
|
86 |
String email = request.get("email");
|
| - |
|
87 |
TrialForm trialForm= trialOnboardingRepository.selectByEmailOrMobile(email);
|
| - |
|
88 |
trialService.sendInternalFranchiseUpgradeMail(trialForm);
|
| - |
|
89 |
trialService.sendUpgradeRequestMail(trialForm);
|
| - |
|
90 |
return responseSender.ok("We have sent upgrade mail successfully");
|
| 77 |
|
91 |
}
|
| 78 |
|
92 |
|
| 79 |
}
|
93 |
}
|