| 21378 |
kshitij.so |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 28742 |
tejbeer |
3 |
import java.time.LocalDateTime;
|
| 21378 |
kshitij.so |
4 |
import java.util.ArrayList;
|
| 28742 |
tejbeer |
5 |
import java.util.Arrays;
|
| 29327 |
tejbeer |
6 |
import java.util.Collections;
|
| 24422 |
amit.gupta |
7 |
import java.util.HashMap;
|
| 29327 |
tejbeer |
8 |
import java.util.HashSet;
|
|
|
9 |
import java.util.LinkedHashMap;
|
| 21378 |
kshitij.so |
10 |
import java.util.List;
|
| 24422 |
amit.gupta |
11 |
import java.util.Map;
|
| 29327 |
tejbeer |
12 |
import java.util.Map.Entry;
|
| 28742 |
tejbeer |
13 |
import java.util.Set;
|
| 29325 |
tejbeer |
14 |
import java.util.stream.Collectors;
|
| 21378 |
kshitij.so |
15 |
|
|
|
16 |
import javax.servlet.http.HttpServletRequest;
|
|
|
17 |
|
| 23959 |
amit.gupta |
18 |
import org.apache.logging.log4j.LogManager;
|
|
|
19 |
import org.apache.logging.log4j.Logger;
|
| 21378 |
kshitij.so |
20 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
21 |
import org.springframework.http.MediaType;
|
|
|
22 |
import org.springframework.http.ResponseEntity;
|
|
|
23 |
import org.springframework.stereotype.Controller;
|
| 21707 |
amit.gupta |
24 |
import org.springframework.transaction.annotation.Transactional;
|
| 28742 |
tejbeer |
25 |
import org.springframework.ui.Model;
|
| 21378 |
kshitij.so |
26 |
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
27 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
28 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 21393 |
amit.gupta |
29 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 21378 |
kshitij.so |
30 |
|
| 28742 |
tejbeer |
31 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
|
|
32 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
33 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 29327 |
tejbeer |
34 |
import com.spice.profitmandi.common.model.FocusedModelShortageModel;
|
| 21378 |
kshitij.so |
35 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 28742 |
tejbeer |
36 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
| 21741 |
ashik.ali |
37 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 28653 |
amit.gupta |
38 |
import com.spice.profitmandi.dao.cart.CartService;
|
| 28742 |
tejbeer |
39 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
|
|
40 |
import com.spice.profitmandi.dao.entity.catalog.FocusedModelByPassRequest;
|
| 29327 |
tejbeer |
41 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
|
|
42 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
|
|
43 |
import com.spice.profitmandi.dao.entity.cs.PartnerRegion;
|
| 28742 |
tejbeer |
44 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
|
|
45 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
| 23273 |
ashik.ali |
46 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
| 29327 |
tejbeer |
47 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
|
|
48 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
|
|
49 |
import com.spice.profitmandi.dao.entity.inventory.SaholicCIS;
|
| 28742 |
tejbeer |
50 |
import com.spice.profitmandi.dao.enumuration.catalog.ByPassRequestStatus;
|
|
|
51 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 21735 |
ashik.ali |
52 |
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
|
| 26607 |
amit.gupta |
53 |
import com.spice.profitmandi.dao.model.AddCartRequest;
|
|
|
54 |
import com.spice.profitmandi.dao.model.CartItem;
|
| 28653 |
amit.gupta |
55 |
import com.spice.profitmandi.dao.model.CartItemResponseModel;
|
| 26607 |
amit.gupta |
56 |
import com.spice.profitmandi.dao.model.CartResponse;
|
| 21378 |
kshitij.so |
57 |
import com.spice.profitmandi.dao.model.ProductPojo;
|
| 21738 |
amit.gupta |
58 |
import com.spice.profitmandi.dao.model.UserCart;
|
| 28742 |
tejbeer |
59 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
|
|
60 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelByPassRepository;
|
| 29327 |
tejbeer |
61 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
|
| 23360 |
amit.gupta |
62 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 29327 |
tejbeer |
63 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 28742 |
tejbeer |
64 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 29327 |
tejbeer |
65 |
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
|
| 28742 |
tejbeer |
66 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 29327 |
tejbeer |
67 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
|
|
68 |
import com.spice.profitmandi.dao.repository.dtr.RetailerBlockBrandsRepository;
|
| 21735 |
ashik.ali |
69 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 28742 |
tejbeer |
70 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
| 29327 |
tejbeer |
71 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
|
|
72 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 21643 |
ashik.ali |
73 |
import com.spice.profitmandi.dao.util.ContentPojoPopulator;
|
| 28742 |
tejbeer |
74 |
import com.spice.profitmandi.service.FofoUser;
|
|
|
75 |
import com.spice.profitmandi.service.NotificationService;
|
|
|
76 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
|
|
77 |
import com.spice.profitmandi.service.inventory.ByPassRequestModel;
|
| 29327 |
tejbeer |
78 |
import com.spice.profitmandi.service.inventory.FocusedShortageModel;
|
| 25962 |
amit.gupta |
79 |
import com.spice.profitmandi.service.inventory.ItemBucketService;
|
| 29327 |
tejbeer |
80 |
import com.spice.profitmandi.service.inventory.SaholicInventoryService;
|
|
|
81 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 28742 |
tejbeer |
82 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 29327 |
tejbeer |
83 |
import com.spice.profitmandi.web.controller.checkout.OrderController;
|
| 21378 |
kshitij.so |
84 |
import com.spice.profitmandi.web.res.ValidateCartResponse;
|
|
|
85 |
|
|
|
86 |
import io.swagger.annotations.ApiImplicitParam;
|
|
|
87 |
import io.swagger.annotations.ApiImplicitParams;
|
|
|
88 |
import io.swagger.annotations.ApiOperation;
|
|
|
89 |
|
|
|
90 |
@Controller
|
| 24199 |
amit.gupta |
91 |
@Transactional(rollbackFor = Throwable.class)
|
| 21378 |
kshitij.so |
92 |
public class CartController {
|
|
|
93 |
|
| 24199 |
amit.gupta |
94 |
private static final Logger logger = LogManager.getLogger(CartController.class);
|
|
|
95 |
|
| 21440 |
ashik.ali |
96 |
@Autowired
|
| 22931 |
ashik.ali |
97 |
private ResponseSender<?> responseSender;
|
| 21378 |
kshitij.so |
98 |
|
|
|
99 |
@Autowired
|
| 22931 |
ashik.ali |
100 |
private UserAccountRepository userAccountRepository;
|
| 24199 |
amit.gupta |
101 |
|
| 22173 |
amit.gupta |
102 |
@Autowired
|
| 25962 |
amit.gupta |
103 |
private ItemBucketService itemBucketService;
|
|
|
104 |
|
|
|
105 |
@Autowired
|
| 28653 |
amit.gupta |
106 |
CartService cartService;
|
|
|
107 |
|
|
|
108 |
@Autowired
|
| 22931 |
ashik.ali |
109 |
private ContentPojoPopulator contentPojoPopulator;
|
| 24199 |
amit.gupta |
110 |
|
| 23360 |
amit.gupta |
111 |
@Autowired
|
|
|
112 |
private ItemRepository itemRepository;
|
| 21378 |
kshitij.so |
113 |
|
| 28742 |
tejbeer |
114 |
@Autowired
|
|
|
115 |
private UserRepository userRepository;
|
|
|
116 |
|
|
|
117 |
@Autowired
|
|
|
118 |
private AuthRepository authRepository;
|
|
|
119 |
|
|
|
120 |
@Autowired
|
|
|
121 |
private CsService csService;
|
|
|
122 |
|
|
|
123 |
@Autowired
|
|
|
124 |
private PositionRepository positionRepository;
|
|
|
125 |
|
|
|
126 |
@Autowired
|
|
|
127 |
private FocusedModelByPassRepository focusedModelByPassRepository;
|
|
|
128 |
|
|
|
129 |
@Autowired
|
|
|
130 |
private RetailerService retailerService;
|
|
|
131 |
|
|
|
132 |
@Autowired
|
|
|
133 |
private PartnerInvestmentService partnerInvestmentService;
|
|
|
134 |
|
|
|
135 |
@Autowired
|
|
|
136 |
private FofoUser fofoUser;
|
| 28743 |
tejbeer |
137 |
|
| 28742 |
tejbeer |
138 |
@Autowired
|
| 29327 |
tejbeer |
139 |
private FocusedModelRepository focusedModelRepository;
|
|
|
140 |
|
|
|
141 |
@Autowired
|
|
|
142 |
private PartnerRegionRepository partnerRegionRepository;
|
|
|
143 |
|
|
|
144 |
@Autowired
|
|
|
145 |
private SaholicInventoryService saholicInventoryService;
|
|
|
146 |
|
|
|
147 |
@Autowired
|
|
|
148 |
private TransactionService transactionService;
|
|
|
149 |
|
|
|
150 |
@Autowired
|
|
|
151 |
private FofoStoreRepository fofoStoreRepository;
|
|
|
152 |
|
|
|
153 |
@Autowired
|
|
|
154 |
private RetailerBlockBrandsRepository retailerBlockBrandRepository;
|
|
|
155 |
|
|
|
156 |
@Autowired
|
|
|
157 |
private OrderRepository orderRepository;
|
|
|
158 |
|
|
|
159 |
@Autowired
|
|
|
160 |
private TagListingRepository tagListingRepository;
|
|
|
161 |
|
|
|
162 |
@Autowired
|
| 28742 |
tejbeer |
163 |
private NotificationService notificationService;
|
|
|
164 |
|
| 29327 |
tejbeer |
165 |
@Autowired
|
|
|
166 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
|
|
167 |
|
| 24422 |
amit.gupta |
168 |
public static final Map<String, Integer> MIN_BRAND_QTY_LIMIT = new HashMap<>();
|
|
|
169 |
|
| 29327 |
tejbeer |
170 |
private static final Logger log = LogManager.getLogger(CartController.class);
|
|
|
171 |
|
| 28746 |
tejbeer |
172 |
List<EscalationType> esclationType = Arrays.asList(EscalationType.L3, EscalationType.L4, EscalationType.L2);
|
| 28742 |
tejbeer |
173 |
|
| 29325 |
tejbeer |
174 |
List<String> emails = Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com",
|
|
|
175 |
"niranjan.kala@smartdukaan.com", "sm@smartdukaan.com");
|
| 28742 |
tejbeer |
176 |
|
| 24422 |
amit.gupta |
177 |
static {
|
| 25962 |
amit.gupta |
178 |
// MIN_BRAND_QTY_LIMIT.put("Realme", 10);
|
| 24464 |
amit.gupta |
179 |
MIN_BRAND_QTY_LIMIT.put("Reliance", 5);
|
| 24422 |
amit.gupta |
180 |
}
|
|
|
181 |
|
| 25962 |
amit.gupta |
182 |
@RequestMapping(value = ProfitMandiConstants.URL_CART, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
183 |
@ApiImplicitParams({
|
|
|
184 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
|
|
185 |
@ApiOperation(value = "Add items to cart")
|
|
|
186 |
public ResponseEntity<?> validateCart(HttpServletRequest request,
|
|
|
187 |
@RequestParam(value = "pincode", defaultValue = "110001") String pincode, @RequestParam int bucketId)
|
|
|
188 |
throws Throwable {
|
|
|
189 |
|
|
|
190 |
AddCartRequest cartRequest = new AddCartRequest();
|
| 26607 |
amit.gupta |
191 |
List<CartItem> ci = new ArrayList<>();
|
| 25962 |
amit.gupta |
192 |
itemBucketService.getBucketDetails(bucketId).stream().forEach(x -> {
|
| 28653 |
amit.gupta |
193 |
ci.add(new CartItem(x.getQuantity(), x.getItemId()));
|
| 25962 |
amit.gupta |
194 |
});
|
| 26607 |
amit.gupta |
195 |
cartRequest.setCartItems(ci);
|
| 25962 |
amit.gupta |
196 |
return this.validateCart(request, cartRequest, "110001");
|
|
|
197 |
|
|
|
198 |
}
|
|
|
199 |
|
| 24199 |
amit.gupta |
200 |
@RequestMapping(value = ProfitMandiConstants.URL_CART, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 21378 |
kshitij.so |
201 |
@ApiImplicitParams({
|
| 24199 |
amit.gupta |
202 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 21378 |
kshitij.so |
203 |
@ApiOperation(value = "Add items to cart")
|
| 24199 |
amit.gupta |
204 |
public ResponseEntity<?> validateCart(HttpServletRequest request, @RequestBody AddCartRequest cartRequest,
|
|
|
205 |
@RequestParam(value = "pincode", defaultValue = "110001") String pincode) throws Throwable {
|
| 23273 |
ashik.ali |
206 |
UserAccount userAccount = null;
|
| 21378 |
kshitij.so |
207 |
ValidateCartResponse vc = null;
|
| 24199 |
amit.gupta |
208 |
int userId = (int) request.getAttribute("userId");
|
|
|
209 |
|
| 28653 |
amit.gupta |
210 |
int cartId = userAccountRepository.selectByUserIdType(userId, AccountType.cartId).getAccountKey();
|
| 26607 |
amit.gupta |
211 |
List<CartItem> cartItems = cartRequest.getCartItems();
|
| 28653 |
amit.gupta |
212 |
cartService.addItemsToCart(cartId, cartItems);
|
|
|
213 |
CartResponse cartValidationResponse = cartService.getCartValidation(cartId);
|
|
|
214 |
for (CartItemResponseModel cartItem : cartValidationResponse.getCartItems()) {
|
|
|
215 |
ProductPojo pp = contentPojoPopulator.getShortContent(cartItem.getCatalogItemId());
|
| 29415 |
tejbeer |
216 |
|
| 29416 |
tejbeer |
217 |
log.info("pp {}", pp);
|
| 28742 |
tejbeer |
218 |
if (pp != null) {
|
| 28653 |
amit.gupta |
219 |
cartItem.setImageUrl(pp.getImageUrl());
|
| 29417 |
tejbeer |
220 |
// cartItem.setTitle(pp.getTitle());
|
| 24153 |
amit.gupta |
221 |
}
|
|
|
222 |
}
|
| 28653 |
amit.gupta |
223 |
vc = new ValidateCartResponse(cartValidationResponse, "Success", "Items added to cart successfully");
|
| 23021 |
ashik.ali |
224 |
return responseSender.ok(vc);
|
| 21378 |
kshitij.so |
225 |
}
|
| 21393 |
amit.gupta |
226 |
|
| 24199 |
amit.gupta |
227 |
@RequestMapping(value = ProfitMandiConstants.URL_CART_CHANGE_ADDRESS, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 21393 |
amit.gupta |
228 |
@ApiImplicitParams({
|
| 24199 |
amit.gupta |
229 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
|
|
230 |
|
| 21393 |
amit.gupta |
231 |
@ApiOperation(value = "Change address")
|
| 24199 |
amit.gupta |
232 |
public ResponseEntity<?> changeAddress(HttpServletRequest request,
|
|
|
233 |
@RequestParam(value = "addressId") long addressId) throws Throwable {
|
|
|
234 |
UserCart uc = userAccountRepository.getUserCart((int) request.getAttribute("userId"));
|
| 28653 |
amit.gupta |
235 |
cartService.addAddressToCart(uc.getCartId(), addressId);
|
| 24199 |
amit.gupta |
236 |
return responseSender.ok("Address Changed successfully");
|
|
|
237 |
}
|
| 28742 |
tejbeer |
238 |
|
| 29325 |
tejbeer |
239 |
@RequestMapping(value = "/byPassRequests", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 28742 |
tejbeer |
240 |
@ApiImplicitParams({
|
|
|
241 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
|
|
242 |
|
| 29325 |
tejbeer |
243 |
@ApiOperation(value = "byPassRequests")
|
|
|
244 |
public ResponseEntity<?> byPassRequests(HttpServletRequest request, Model model) throws Exception {
|
| 28742 |
tejbeer |
245 |
|
|
|
246 |
int userId = (int) request.getAttribute("userId");
|
|
|
247 |
|
| 28743 |
tejbeer |
248 |
User user = userRepository.selectById(userId);
|
| 29328 |
tejbeer |
249 |
AuthUser authUser = authRepository.selectByEmailOrMobile(user.getEmailId());
|
| 29325 |
tejbeer |
250 |
|
| 28742 |
tejbeer |
251 |
List<FocusedModelByPassRequest> byPassRequests = null;
|
|
|
252 |
|
|
|
253 |
Set<Integer> authfofoIds = null;
|
| 29325 |
tejbeer |
254 |
boolean actionAccess = false;
|
|
|
255 |
logger.info("authUser" + authUser);
|
| 28742 |
tejbeer |
256 |
|
| 29325 |
tejbeer |
257 |
List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId()).stream()
|
|
|
258 |
.filter(x -> (x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_SALES
|
|
|
259 |
|| x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_RBM))
|
|
|
260 |
.collect(Collectors.toList());
|
| 28742 |
tejbeer |
261 |
|
| 29325 |
tejbeer |
262 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
263 |
|
| 28742 |
tejbeer |
264 |
if (emails.contains(authUser.getEmailId())) {
|
| 29325 |
tejbeer |
265 |
byPassRequests = focusedModelByPassRepository.selectByStatus(ByPassRequestStatus.PENDING);
|
|
|
266 |
actionAccess = true;
|
| 28742 |
tejbeer |
267 |
} else {
|
| 29325 |
tejbeer |
268 |
if (!positions.isEmpty()) {
|
|
|
269 |
for (Position ps : positions) {
|
|
|
270 |
if (ProfitMandiConstants.TICKET_CATEGORY_RBM == ps.getCategoryId()) {
|
|
|
271 |
authfofoIds = storeGuyMap.get(user.getEmailId());
|
|
|
272 |
logger.info("authfofoIdsw" + authfofoIds);
|
|
|
273 |
actionAccess = true;
|
|
|
274 |
break;
|
|
|
275 |
} else if (ProfitMandiConstants.TICKET_CATEGORY_SALES == ps.getCategoryId()) {
|
|
|
276 |
authfofoIds = storeGuyMap.get(user.getEmailId());
|
|
|
277 |
logger.info("authfofoIdsw" + authfofoIds);
|
|
|
278 |
actionAccess = false;
|
|
|
279 |
break;
|
|
|
280 |
}
|
| 28742 |
tejbeer |
281 |
|
|
|
282 |
}
|
|
|
283 |
}
|
|
|
284 |
}
|
|
|
285 |
logger.info("authfofoIds" + authfofoIds);
|
|
|
286 |
if (authfofoIds != null) {
|
|
|
287 |
byPassRequests = focusedModelByPassRepository.selectByStatusAndFofoIds(new ArrayList<>(authfofoIds),
|
|
|
288 |
ByPassRequestStatus.PENDING);
|
|
|
289 |
}
|
| 29327 |
tejbeer |
290 |
|
| 28742 |
tejbeer |
291 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
|
|
292 |
List<ByPassRequestModel> byPassList = new ArrayList<>();
|
|
|
293 |
|
|
|
294 |
for (FocusedModelByPassRequest byPassRequest : byPassRequests) {
|
| 29327 |
tejbeer |
295 |
|
|
|
296 |
List<FocusedShortageModel> fsms = cartService.focusedModelShortageValidation(byPassRequest.getFofoId(),
|
|
|
297 |
new HashMap<>());
|
| 28742 |
tejbeer |
298 |
Map<String, Object> investments = fofoUser.getInvestments(byPassRequest.getFofoId());
|
|
|
299 |
ByPassRequestModel bp = new ByPassRequestModel();
|
|
|
300 |
bp.setPartnerName(customRetailerMap.get(byPassRequest.getFofoId()).getBusinessName());
|
|
|
301 |
bp.setCity(customRetailerMap.get(byPassRequest.getFofoId()).getAddress().getCity());
|
|
|
302 |
bp.setState(customRetailerMap.get(byPassRequest.getFofoId()).getAddress().getState());
|
|
|
303 |
bp.setCode(customRetailerMap.get(byPassRequest.getFofoId()).getCode());
|
|
|
304 |
bp.setStatus(byPassRequest.getStatus());
|
|
|
305 |
bp.setFofoId(byPassRequest.getFofoId());
|
|
|
306 |
bp.setByPassRequestId(byPassRequest.getId());
|
|
|
307 |
bp.setInvestmentOkDays((Long) investments.get("okDays"));
|
| 29327 |
tejbeer |
308 |
bp.setInvestmentShort((PartnerDailyInvestment) investments.get("investment"));
|
| 28742 |
tejbeer |
309 |
bp.setMobileNumber(customRetailerMap.get(byPassRequest.getFofoId()).getMobileNumber());
|
| 29325 |
tejbeer |
310 |
bp.setActionAccess(actionAccess);
|
| 28742 |
tejbeer |
311 |
bp.setCreateTimestamp(byPassRequest.getCreatedTimeStamp());
|
|
|
312 |
bp.setUpdateTimestamp(byPassRequest.getUpdatedTimestamp());
|
| 29327 |
tejbeer |
313 |
bp.setFsms(fsms);
|
| 28742 |
tejbeer |
314 |
byPassList.add(bp);
|
|
|
315 |
|
|
|
316 |
}
|
|
|
317 |
|
|
|
318 |
return responseSender.ok(byPassList);
|
|
|
319 |
}
|
|
|
320 |
|
|
|
321 |
@RequestMapping(value = "/byPassRequestAction", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
322 |
@ApiImplicitParams({
|
|
|
323 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
|
|
324 |
@ApiOperation(value = "Add items to cart")
|
|
|
325 |
public ResponseEntity<?> addAmountToWalletRequestRejected(HttpServletRequest request,
|
|
|
326 |
@RequestParam(name = "id", defaultValue = "0") int id, @RequestParam ByPassRequestStatus status,
|
| 29333 |
tejbeer |
327 |
@RequestParam String reason, Model model) throws Exception {
|
| 29325 |
tejbeer |
328 |
int userId = (int) request.getAttribute("userId");
|
| 28742 |
tejbeer |
329 |
|
| 29325 |
tejbeer |
330 |
User user = userRepository.selectById(userId);
|
|
|
331 |
AuthUser authUser = authRepository.selectByEmailOrMobile(user.getEmailId());
|
|
|
332 |
|
| 28742 |
tejbeer |
333 |
FocusedModelByPassRequest byPassRequest = focusedModelByPassRepository.selectById(id);
|
|
|
334 |
if (status.equals(ByPassRequestStatus.APPROVED)) {
|
|
|
335 |
byPassRequest.setByPass(true);
|
| 29325 |
tejbeer |
336 |
byPassRequest.setAuthId(authUser.getId());
|
| 28742 |
tejbeer |
337 |
byPassRequest.setStatus(ByPassRequestStatus.APPROVED);
|
|
|
338 |
byPassRequest.setUpdatedTimestamp(LocalDateTime.now());
|
| 29333 |
tejbeer |
339 |
byPassRequest.setReason(reason);
|
| 28742 |
tejbeer |
340 |
} else if (status.equals(ByPassRequestStatus.REJECTED)) {
|
|
|
341 |
byPassRequest.setByPass(false);
|
| 29325 |
tejbeer |
342 |
byPassRequest.setAuthId(authUser.getId());
|
| 28742 |
tejbeer |
343 |
byPassRequest.setStatus(ByPassRequestStatus.REJECTED);
|
|
|
344 |
byPassRequest.setUpdatedTimestamp(LocalDateTime.now());
|
| 29333 |
tejbeer |
345 |
byPassRequest.setReason(reason);
|
| 28742 |
tejbeer |
346 |
}
|
|
|
347 |
|
|
|
348 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
|
|
349 |
sendNotificationModel.setCampaignName("Billing Request");
|
|
|
350 |
sendNotificationModel.setTitle("Billing Request");
|
|
|
351 |
sendNotificationModel.setMessage(String.format("Your Billing Request is " + " " + status
|
| 28745 |
tejbeer |
352 |
+ ". Please ensure to order the missing focus models as soon as possible"));
|
| 28742 |
tejbeer |
353 |
sendNotificationModel.setType("url");
|
|
|
354 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
|
|
355 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
|
|
356 |
sendNotificationModel.setMessageType(MessageType.notification);
|
|
|
357 |
sendNotificationModel
|
|
|
358 |
.setUserIds(Arrays.asList(userAccountRepository.selectUserIdByRetailerId(byPassRequest.getFofoId())));
|
|
|
359 |
|
|
|
360 |
notificationService.sendNotification(sendNotificationModel);
|
|
|
361 |
|
|
|
362 |
return responseSender.ok(true);
|
|
|
363 |
}
|
| 21378 |
kshitij.so |
364 |
}
|