| Line 8... |
Line 8... |
| 8 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
8 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 9 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
9 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 10 |
import com.spice.profitmandi.dao.entity.brandFee.BrandFee;
|
10 |
import com.spice.profitmandi.dao.entity.brandFee.BrandFee;
|
| 11 |
import com.spice.profitmandi.dao.entity.brandFee.BrandFeeCollection;
|
11 |
import com.spice.profitmandi.dao.entity.brandFee.BrandFeeCollection;
|
| 12 |
import com.spice.profitmandi.dao.entity.dtr.Otp;
|
12 |
import com.spice.profitmandi.dao.entity.dtr.Otp;
|
| - |
|
13 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 13 |
import com.spice.profitmandi.dao.entity.fofo.PaymentOption;
|
14 |
import com.spice.profitmandi.dao.entity.fofo.PaymentOption;
|
| 14 |
import com.spice.profitmandi.dao.entity.onBoarding.*;
|
15 |
import com.spice.profitmandi.dao.entity.onBoarding.*;
|
| 15 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
16 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 16 |
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
|
17 |
import com.spice.profitmandi.dao.enumuration.dtr.OtpType;
|
| 17 |
import com.spice.profitmandi.dao.enumuration.dtr.StoreTimeline;
|
18 |
import com.spice.profitmandi.dao.enumuration.dtr.StoreTimeline;
|
| - |
|
19 |
import com.spice.profitmandi.dao.enumuration.onBorading.OnboardingType;
|
| 18 |
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.FeePaymentStatus;
|
20 |
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.FeePaymentStatus;
|
| 19 |
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.LoiStatus;
|
21 |
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.LoiStatus;
|
| 20 |
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.StoreType;
|
22 |
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.StoreType;
|
| 21 |
import com.spice.profitmandi.dao.model.LoiFormModel;
|
23 |
import com.spice.profitmandi.dao.model.LoiFormModel;
|
| 22 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
24 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 23 |
import com.spice.profitmandi.dao.repository.brandFee.BrandFeeCollectionRepository;
|
25 |
import com.spice.profitmandi.dao.repository.brandFee.BrandFeeCollectionRepository;
|
| 24 |
import com.spice.profitmandi.dao.repository.brandFee.BrandFeeRepository;
|
26 |
import com.spice.profitmandi.dao.repository.brandFee.BrandFeeRepository;
|
| 25 |
import com.spice.profitmandi.dao.repository.catalog.BrandCategoryRepository;
|
27 |
import com.spice.profitmandi.dao.repository.catalog.BrandCategoryRepository;
|
| 26 |
import com.spice.profitmandi.dao.repository.catalog.BrandsRepository;
|
28 |
import com.spice.profitmandi.dao.repository.catalog.BrandsRepository;
|
| 27 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
29 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 28 |
import com.spice.profitmandi.dao.repository.dtr.DistrictMasterRepository;
|
- |
|
| 29 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
- |
|
| 30 |
import com.spice.profitmandi.dao.repository.dtr.OtpRepository;
|
30 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
| 31 |
import com.spice.profitmandi.dao.repository.dtr.PartnerOnBoardingPanelRepository;
|
- |
|
| 32 |
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
|
31 |
import com.spice.profitmandi.dao.repository.fofo.PaymentOptionRepository;
|
| 33 |
import com.spice.profitmandi.dao.repository.inventory.PartnerOnboardingService;
|
32 |
import com.spice.profitmandi.dao.repository.inventory.PartnerOnboardingService;
|
| 34 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
33 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| 35 |
import com.spice.profitmandi.dao.repository.onboarding.*;
|
34 |
import com.spice.profitmandi.dao.repository.onboarding.*;
|
| 36 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
35 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| Line 130... |
Line 129... |
| 130 |
|
129 |
|
| 131 |
@Autowired
|
130 |
@Autowired
|
| 132 |
PaymentOptionRepository paymentOptionRepository;
|
131 |
PaymentOptionRepository paymentOptionRepository;
|
| 133 |
|
132 |
|
| 134 |
@Autowired
|
133 |
@Autowired
|
| - |
|
134 |
FofoStoreRepository fofoStoreRepository;
|
| - |
|
135 |
|
| - |
|
136 |
@Autowired
|
| 135 |
ResponseSender responseSender;
|
137 |
ResponseSender responseSender;
|
| 136 |
|
138 |
|
| 137 |
List<String> agreedBrandFeeChangerEmail = Arrays.asList("sm@smartdukaan.com", "kamini.sharma@smartdukaan.com");
|
139 |
List<String> agreedBrandFeeChangerEmail = Arrays.asList("sm@smartdukaan.com", "kamini.sharma@smartdukaan.com");
|
| 138 |
|
140 |
|
| 139 |
// Loi Form
|
141 |
// Loi Form
|
| Line 185... |
Line 187... |
| 185 |
// Save Loi data in fofo.loi_form table
|
187 |
// Save Loi data in fofo.loi_form table
|
| 186 |
@RequestMapping(value = "/submitLoiForm", method = RequestMethod.POST)
|
188 |
@RequestMapping(value = "/submitLoiForm", method = RequestMethod.POST)
|
| 187 |
public String submitLoiForm(HttpServletRequest request, @RequestBody LoiFormData loiFormData, Model model) throws Exception {
|
189 |
public String submitLoiForm(HttpServletRequest request, @RequestBody LoiFormData loiFormData, Model model) throws Exception {
|
| 188 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
190 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 189 |
LOGGER.info("filledBy - " + loginDetails.getEmailId());
|
191 |
LOGGER.info("filledBy - " + loginDetails.getEmailId());
|
| - |
|
192 |
|
| - |
|
193 |
String validationError = validateOnboardingTypeFields(loiFormData);
|
| - |
|
194 |
if (validationError != null) {
|
| - |
|
195 |
LOGGER.warn("LOI submit rejected for " + loginDetails.getEmailId() + ": " + validationError);
|
| - |
|
196 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
| - |
|
197 |
return "response";
|
| - |
|
198 |
}
|
| - |
|
199 |
|
| 190 |
boolean isDataCreated = loiFormService.createLoiForm(loiFormData, loginDetails.getEmailId());
|
200 |
boolean isDataCreated = loiFormService.createLoiForm(loiFormData, loginDetails.getEmailId());
|
| 191 |
if (isDataCreated) {
|
201 |
if (isDataCreated) {
|
| 192 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
202 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 193 |
return "response";
|
203 |
return "response";
|
| 194 |
} else {
|
204 |
} else {
|
| 195 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
205 |
model.addAttribute("response1", mvcResponseSender.createResponseString(false));
|
| 196 |
return "response";
|
206 |
return "response";
|
| 197 |
}
|
207 |
}
|
| 198 |
}
|
208 |
}
|
| 199 |
|
209 |
|
| - |
|
210 |
// Returns null if valid, else an error message. NEW is default; only REVIVAL / ANY_OTHER need extras.
|
| - |
|
211 |
private String validateOnboardingTypeFields(LoiFormData loiFormData) throws ProfitMandiBusinessException {
|
| - |
|
212 |
String rawType = loiFormData.getOnboardingType();
|
| - |
|
213 |
if (rawType == null || rawType.trim().isEmpty()) {
|
| - |
|
214 |
loiFormData.setOnboardingType(OnboardingType.NEW.name());
|
| - |
|
215 |
return null;
|
| - |
|
216 |
}
|
| - |
|
217 |
OnboardingType type;
|
| - |
|
218 |
try {
|
| - |
|
219 |
type = OnboardingType.valueOf(rawType.trim().toUpperCase());
|
| - |
|
220 |
} catch (IllegalArgumentException e) {
|
| - |
|
221 |
return "Invalid onboarding type: " + rawType;
|
| - |
|
222 |
}
|
| - |
|
223 |
if (type == OnboardingType.NEW) return null;
|
| - |
|
224 |
|
| - |
|
225 |
String reason = loiFormData.getRevivalReason();
|
| - |
|
226 |
if (reason == null || reason.trim().isEmpty()) {
|
| - |
|
227 |
return "Reason is mandatory for " + type + " onboarding";
|
| - |
|
228 |
}
|
| - |
|
229 |
|
| - |
|
230 |
if (type == OnboardingType.REVIVAL) {
|
| - |
|
231 |
String oldCode = loiFormData.getOldStoreCode();
|
| - |
|
232 |
if (oldCode == null || oldCode.trim().isEmpty()) {
|
| - |
|
233 |
return "Old Store Code is mandatory for REVIVAL";
|
| - |
|
234 |
}
|
| - |
|
235 |
FofoStore existing = fofoStoreRepository.selectByStoreCode(oldCode.trim());
|
| - |
|
236 |
if (existing == null) {
|
| - |
|
237 |
return "Old Store Code " + oldCode + " does not exist";
|
| - |
|
238 |
}
|
| - |
|
239 |
boolean stillActive = fofoStoreRepository.selectActiveStores().stream()
|
| - |
|
240 |
.anyMatch(s -> oldCode.trim().equalsIgnoreCase(s.getCode()));
|
| - |
|
241 |
if (stillActive) {
|
| - |
|
242 |
return "Old Store Code " + oldCode + " is still active — revival is only for closed stores";
|
| - |
|
243 |
}
|
| - |
|
244 |
}
|
| - |
|
245 |
return null;
|
| - |
|
246 |
}
|
| - |
|
247 |
|
| 200 |
// show all pending loi form to specific auth user who have filled the form(type based)
|
248 |
// show all pending loi form to specific auth user who have filled the form(type based)
|
| 201 |
@RequestMapping(value = "/pendingLoiForm", method = RequestMethod.GET)
|
249 |
@RequestMapping(value = "/pendingLoiForm", method = RequestMethod.GET)
|
| 202 |
public String pendingLoiForm(HttpServletRequest request, Model model) throws Exception {
|
250 |
public String pendingLoiForm(HttpServletRequest request, Model model) throws Exception {
|
| 203 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
251 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 204 |
String email = loginDetails.getEmailId();
|
252 |
String email = loginDetails.getEmailId();
|