| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| - |
|
3 |
import com.spice.profitmandi.service.warehouse.BillingWarehouseService;
|
| - |
|
4 |
import java.util.LinkedHashMap;
|
| - |
|
5 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| - |
|
6 |
|
| 3 |
import com.spice.profitmandi.common.enumuration.ContentType;
|
7 |
import com.spice.profitmandi.common.enumuration.ContentType;
|
| 4 |
import com.spice.profitmandi.common.enumuration.CounterSize;
|
8 |
import com.spice.profitmandi.common.enumuration.CounterSize;
|
| 5 |
import com.spice.profitmandi.common.enumuration.FofoType;
|
9 |
import com.spice.profitmandi.common.enumuration.FofoType;
|
| 6 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
10 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 7 |
import com.spice.profitmandi.common.model.*;
|
11 |
import com.spice.profitmandi.common.model.*;
|
| Line 66... |
Line 70... |
| 66 |
|
70 |
|
| 67 |
@Controller
|
71 |
@Controller
|
| 68 |
@Transactional(rollbackFor = Throwable.class)
|
72 |
@Transactional(rollbackFor = Throwable.class)
|
| 69 |
public class RetailerController {
|
73 |
public class RetailerController {
|
| 70 |
|
74 |
|
| - |
|
75 |
@Autowired
|
| - |
|
76 |
private BillingWarehouseService billingWarehouseService;
|
| - |
|
77 |
|
| - |
|
78 |
|
| 71 |
private static final Logger LOGGER = LogManager.getLogger(RetailerController.class);
|
79 |
private static final Logger LOGGER = LogManager.getLogger(RetailerController.class);
|
| 72 |
private static final List<String> CHANGE_PARTNER_CATEGORY_PERMISSIONS = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com");
|
80 |
private static final List<String> CHANGE_PARTNER_CATEGORY_PERMISSIONS = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com");
|
| 73 |
@Autowired
|
81 |
@Autowired
|
| 74 |
PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
|
82 |
PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
|
| 75 |
@Autowired
|
83 |
@Autowired
|
| Line 152... |
Line 160... |
| 152 |
LOGGER.info("map - {}", map.get("trialForm"));
|
160 |
LOGGER.info("map - {}", map.get("trialForm"));
|
| 153 |
LOGGER.info("map - {}", map);
|
161 |
LOGGER.info("map - {}", map);
|
| 154 |
model.addAllAttributes(map);
|
162 |
model.addAllAttributes(map);
|
| 155 |
|
163 |
|
| 156 |
model.addAttribute("counterSizes", CounterSize.values());
|
164 |
model.addAttribute("counterSizes", CounterSize.values());
|
| 157 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
165 |
Map<Integer, String> warehouseMap = this.partnerZones(map.get("fofoStore"));
|
| 158 |
|
166 |
|
| 159 |
LOGGER.info("warehouseMap {}", warehouseMap);
|
167 |
LOGGER.info("warehouseMap {}", warehouseMap);
|
| 160 |
model.addAttribute("warehouses", warehouseMap);
|
168 |
model.addAttribute("warehouses", warehouseMap);
|
| 161 |
model.addAttribute("fofoTypes", FofoType.values());
|
169 |
model.addAttribute("fofoTypes", FofoType.values());
|
| 162 |
if (map.containsKey("retailer")) {
|
170 |
if (map.containsKey("retailer")) {
|
| Line 187... |
Line 195... |
| 187 |
Map<String, Object> map = retailerService.updateRetailerDetails(updateRetailerRequest);
|
195 |
Map<String, Object> map = retailerService.updateRetailerDetails(updateRetailerRequest);
|
| 188 |
//retailerService.up
|
196 |
//retailerService.up
|
| 189 |
|
197 |
|
| 190 |
model.addAllAttributes(map);
|
198 |
model.addAllAttributes(map);
|
| 191 |
model.addAttribute("counterSizes", CounterSize.values());
|
199 |
model.addAttribute("counterSizes", CounterSize.values());
|
| 192 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
200 |
Map<Integer, String> warehouseMap = this.partnerZones(map.get("fofoStore"));
|
| 193 |
LOGGER.info("warehouseMap", warehouseMap);
|
201 |
LOGGER.info("warehouseMap", warehouseMap);
|
| 194 |
model.addAttribute("warehouses", warehouseMap);
|
202 |
model.addAttribute("warehouses", warehouseMap);
|
| 195 |
model.addAttribute("fofoTypes", FofoType.values());
|
203 |
model.addAttribute("fofoTypes", FofoType.values());
|
| 196 |
return "retailer-details";
|
204 |
return "retailer-details";
|
| 197 |
}
|
205 |
}
|
| 198 |
|
206 |
|
| - |
|
207 |
// Partner zone = the warehouse a store's orders are allocated to, so only active ones are offered; a store already
|
| - |
|
208 |
// on a suspended one keeps it listed so the form does not silently move it on save.
|
| - |
|
209 |
private Map<Integer, String> partnerZones(Object fofoStore) {
|
| - |
|
210 |
Map<Integer, String> zones = new LinkedHashMap<>(billingWarehouseService.getActiveWarehouses());
|
| - |
|
211 |
if (fofoStore instanceof FofoStore) {
|
| - |
|
212 |
int warehouseId = ((FofoStore) fofoStore).getWarehouseId();
|
| - |
|
213 |
if (!zones.containsKey(warehouseId)) {
|
| - |
|
214 |
zones.put(warehouseId, billingWarehouseService.getName(warehouseId, String.valueOf(warehouseId))
|
| - |
|
215 |
+ " (" + String.valueOf(billingWarehouseService.getStatus(warehouseId)).toLowerCase() + ")");
|
| - |
|
216 |
}
|
| - |
|
217 |
}
|
| - |
|
218 |
return zones;
|
| - |
|
219 |
}
|
| - |
|
220 |
|
| 199 |
private void checkLoiCompletion(UpdateRetailerRequest updateRetailerRequest) throws ProfitMandiBusinessException {
|
221 |
private void checkLoiCompletion(UpdateRetailerRequest updateRetailerRequest) throws ProfitMandiBusinessException {
|
| 200 |
TrialForm trialForm;
|
222 |
TrialForm trialForm;
|
| 201 |
try {
|
223 |
try {
|
| 202 |
trialForm = trialFormRepository.selectByEmailOrMobile(updateRetailerRequest.getUserMobileNumber());
|
224 |
trialForm = trialFormRepository.selectByEmailOrMobile(updateRetailerRequest.getUserMobileNumber());
|
| 203 |
if (updateRetailerRequest.getFofoType().equals(FofoType.INTERNAL) || trialForm != null) {
|
225 |
if (updateRetailerRequest.getFofoType().equals(FofoType.INTERNAL) || trialForm != null) {
|