| 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;
|
| 24422 |
amit.gupta |
6 |
import java.util.HashMap;
|
| 21378 |
kshitij.so |
7 |
import java.util.List;
|
| 24422 |
amit.gupta |
8 |
import java.util.Map;
|
| 28742 |
tejbeer |
9 |
import java.util.Set;
|
| 29325 |
tejbeer |
10 |
import java.util.stream.Collectors;
|
| 21378 |
kshitij.so |
11 |
|
|
|
12 |
import javax.servlet.http.HttpServletRequest;
|
|
|
13 |
|
| 34196 |
ranu |
14 |
import com.spice.profitmandi.common.enumuration.SchemeType;
|
|
|
15 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
|
|
16 |
import com.spice.profitmandi.common.model.UserInfo;
|
|
|
17 |
import com.spice.profitmandi.common.web.client.RestClient;
|
|
|
18 |
import com.spice.profitmandi.dao.model.*;
|
|
|
19 |
import com.spice.profitmandi.dao.repository.fofo.FofoOpeningStockRepository;
|
|
|
20 |
import com.spice.profitmandi.service.inventory.*;
|
|
|
21 |
import org.apache.commons.lang3.StringUtils;
|
|
|
22 |
import org.apache.http.conn.HttpHostConnectException;
|
| 23959 |
amit.gupta |
23 |
import org.apache.logging.log4j.LogManager;
|
|
|
24 |
import org.apache.logging.log4j.Logger;
|
| 34196 |
ranu |
25 |
import org.json.JSONArray;
|
| 29503 |
amit.gupta |
26 |
import org.json.JSONObject;
|
| 21378 |
kshitij.so |
27 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
28 |
import org.springframework.http.MediaType;
|
|
|
29 |
import org.springframework.http.ResponseEntity;
|
|
|
30 |
import org.springframework.stereotype.Controller;
|
| 21707 |
amit.gupta |
31 |
import org.springframework.transaction.annotation.Transactional;
|
| 28742 |
tejbeer |
32 |
import org.springframework.ui.Model;
|
| 34196 |
ranu |
33 |
import org.springframework.web.bind.annotation.*;
|
| 21378 |
kshitij.so |
34 |
|
| 28742 |
tejbeer |
35 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
|
|
36 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 21378 |
kshitij.so |
37 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 28742 |
tejbeer |
38 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
| 29503 |
amit.gupta |
39 |
import com.spice.profitmandi.common.services.mandii.MandiiService;
|
| 21741 |
ashik.ali |
40 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 28653 |
amit.gupta |
41 |
import com.spice.profitmandi.dao.cart.CartService;
|
| 28742 |
tejbeer |
42 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
|
|
43 |
import com.spice.profitmandi.dao.entity.catalog.FocusedModelByPassRequest;
|
|
|
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;
|
| 29503 |
amit.gupta |
47 |
import com.spice.profitmandi.dao.entity.fofo.FofoPayment;
|
| 29327 |
tejbeer |
48 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 29503 |
amit.gupta |
49 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| 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;
|
| 29503 |
amit.gupta |
53 |
import com.spice.profitmandi.dao.enumuration.fofo.PaymentStatus;
|
| 28742 |
tejbeer |
54 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
|
|
55 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelByPassRepository;
|
| 29327 |
tejbeer |
56 |
import com.spice.profitmandi.dao.repository.catalog.FocusedModelRepository;
|
| 23360 |
amit.gupta |
57 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 29327 |
tejbeer |
58 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 28742 |
tejbeer |
59 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 29327 |
tejbeer |
60 |
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
|
| 28742 |
tejbeer |
61 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 29327 |
tejbeer |
62 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
|
|
63 |
import com.spice.profitmandi.dao.repository.dtr.RetailerBlockBrandsRepository;
|
| 21735 |
ashik.ali |
64 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 28742 |
tejbeer |
65 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
| 29327 |
tejbeer |
66 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 29503 |
amit.gupta |
67 |
import com.spice.profitmandi.dao.repository.fofo.FofoPaymentRepository;
|
| 29327 |
tejbeer |
68 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 29503 |
amit.gupta |
69 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
| 21643 |
ashik.ali |
70 |
import com.spice.profitmandi.dao.util.ContentPojoPopulator;
|
| 28742 |
tejbeer |
71 |
import com.spice.profitmandi.service.FofoUser;
|
|
|
72 |
import com.spice.profitmandi.service.NotificationService;
|
|
|
73 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 29327 |
tejbeer |
74 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 28742 |
tejbeer |
75 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 29503 |
amit.gupta |
76 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 21378 |
kshitij.so |
77 |
import com.spice.profitmandi.web.res.ValidateCartResponse;
|
|
|
78 |
|
| 29503 |
amit.gupta |
79 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
| 21378 |
kshitij.so |
80 |
import io.swagger.annotations.ApiImplicitParam;
|
|
|
81 |
import io.swagger.annotations.ApiImplicitParams;
|
|
|
82 |
import io.swagger.annotations.ApiOperation;
|
|
|
83 |
|
|
|
84 |
@Controller
|
| 24199 |
amit.gupta |
85 |
@Transactional(rollbackFor = Throwable.class)
|
| 21378 |
kshitij.so |
86 |
public class CartController {
|
|
|
87 |
|
| 24199 |
amit.gupta |
88 |
private static final Logger logger = LogManager.getLogger(CartController.class);
|
|
|
89 |
|
| 21440 |
ashik.ali |
90 |
@Autowired
|
| 22931 |
ashik.ali |
91 |
private ResponseSender<?> responseSender;
|
| 21378 |
kshitij.so |
92 |
|
|
|
93 |
@Autowired
|
| 22931 |
ashik.ali |
94 |
private UserAccountRepository userAccountRepository;
|
| 24199 |
amit.gupta |
95 |
|
| 22173 |
amit.gupta |
96 |
@Autowired
|
| 25962 |
amit.gupta |
97 |
private ItemBucketService itemBucketService;
|
|
|
98 |
|
|
|
99 |
@Autowired
|
| 28653 |
amit.gupta |
100 |
CartService cartService;
|
|
|
101 |
|
|
|
102 |
@Autowired
|
| 22931 |
ashik.ali |
103 |
private ContentPojoPopulator contentPojoPopulator;
|
| 24199 |
amit.gupta |
104 |
|
| 23360 |
amit.gupta |
105 |
@Autowired
|
|
|
106 |
private ItemRepository itemRepository;
|
| 21378 |
kshitij.so |
107 |
|
| 28742 |
tejbeer |
108 |
@Autowired
|
|
|
109 |
private UserRepository userRepository;
|
|
|
110 |
|
|
|
111 |
@Autowired
|
|
|
112 |
private AuthRepository authRepository;
|
|
|
113 |
|
|
|
114 |
@Autowired
|
|
|
115 |
private CsService csService;
|
|
|
116 |
|
|
|
117 |
@Autowired
|
|
|
118 |
private PositionRepository positionRepository;
|
|
|
119 |
|
|
|
120 |
@Autowired
|
|
|
121 |
private FocusedModelByPassRepository focusedModelByPassRepository;
|
| 30989 |
tejbeer |
122 |
|
| 29503 |
amit.gupta |
123 |
@Autowired
|
|
|
124 |
private FofoPaymentRepository fofoPaymentRepository;
|
| 28742 |
tejbeer |
125 |
|
|
|
126 |
@Autowired
|
|
|
127 |
private RetailerService retailerService;
|
|
|
128 |
|
|
|
129 |
@Autowired
|
|
|
130 |
private PartnerInvestmentService partnerInvestmentService;
|
|
|
131 |
|
|
|
132 |
@Autowired
|
|
|
133 |
private FofoUser fofoUser;
|
| 28743 |
tejbeer |
134 |
|
| 28742 |
tejbeer |
135 |
@Autowired
|
| 29327 |
tejbeer |
136 |
private FocusedModelRepository focusedModelRepository;
|
|
|
137 |
|
|
|
138 |
@Autowired
|
|
|
139 |
private PartnerRegionRepository partnerRegionRepository;
|
|
|
140 |
|
|
|
141 |
@Autowired
|
|
|
142 |
private SaholicInventoryService saholicInventoryService;
|
|
|
143 |
|
|
|
144 |
@Autowired
|
|
|
145 |
private TransactionService transactionService;
|
|
|
146 |
|
|
|
147 |
@Autowired
|
|
|
148 |
private FofoStoreRepository fofoStoreRepository;
|
|
|
149 |
|
|
|
150 |
@Autowired
|
|
|
151 |
private RetailerBlockBrandsRepository retailerBlockBrandRepository;
|
|
|
152 |
|
|
|
153 |
@Autowired
|
|
|
154 |
private OrderRepository orderRepository;
|
|
|
155 |
|
|
|
156 |
@Autowired
|
|
|
157 |
private TagListingRepository tagListingRepository;
|
|
|
158 |
|
|
|
159 |
@Autowired
|
| 28742 |
tejbeer |
160 |
private NotificationService notificationService;
|
|
|
161 |
|
| 29327 |
tejbeer |
162 |
@Autowired
|
| 34196 |
ranu |
163 |
private FofoOpeningStockRepository fofoOpeningStockRepository;
|
|
|
164 |
|
|
|
165 |
@Autowired
|
| 29327 |
tejbeer |
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);
|
| 31715 |
tejbeer |
214 |
|
| 33474 |
amit.gupta |
215 |
for (CartItemResponseModel cartItem : cartValidationResponse.getCartItems()) {
|
| 31715 |
tejbeer |
216 |
ProductPojo pp = contentPojoPopulator.getShortContent(cartItem.getCatalogItemId());
|
|
|
217 |
|
|
|
218 |
log.info("pp {}", pp);
|
|
|
219 |
if (pp != null) {
|
|
|
220 |
cartItem.setImageUrl(pp.getImageUrl()); // cartItem.setTitle(pp.getTitle());
|
|
|
221 |
}
|
| 33474 |
amit.gupta |
222 |
}
|
| 31715 |
tejbeer |
223 |
|
| 28653 |
amit.gupta |
224 |
vc = new ValidateCartResponse(cartValidationResponse, "Success", "Items added to cart successfully");
|
| 23021 |
ashik.ali |
225 |
return responseSender.ok(vc);
|
| 21378 |
kshitij.so |
226 |
}
|
| 21393 |
amit.gupta |
227 |
|
| 24199 |
amit.gupta |
228 |
@RequestMapping(value = ProfitMandiConstants.URL_CART_CHANGE_ADDRESS, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 21393 |
amit.gupta |
229 |
@ApiImplicitParams({
|
| 24199 |
amit.gupta |
230 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
|
|
231 |
|
| 21393 |
amit.gupta |
232 |
@ApiOperation(value = "Change address")
|
| 24199 |
amit.gupta |
233 |
public ResponseEntity<?> changeAddress(HttpServletRequest request,
|
|
|
234 |
@RequestParam(value = "addressId") long addressId) throws Throwable {
|
|
|
235 |
UserCart uc = userAccountRepository.getUserCart((int) request.getAttribute("userId"));
|
| 28653 |
amit.gupta |
236 |
cartService.addAddressToCart(uc.getCartId(), addressId);
|
| 24199 |
amit.gupta |
237 |
return responseSender.ok("Address Changed successfully");
|
|
|
238 |
}
|
| 28742 |
tejbeer |
239 |
|
| 29325 |
tejbeer |
240 |
@RequestMapping(value = "/byPassRequests", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
| 28742 |
tejbeer |
241 |
@ApiImplicitParams({
|
|
|
242 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
|
|
243 |
|
| 29325 |
tejbeer |
244 |
@ApiOperation(value = "byPassRequests")
|
| 35435 |
amit |
245 |
@Transactional(readOnly = true)
|
| 29325 |
tejbeer |
246 |
public ResponseEntity<?> byPassRequests(HttpServletRequest request, Model model) throws Exception {
|
| 28742 |
tejbeer |
247 |
|
|
|
248 |
int userId = (int) request.getAttribute("userId");
|
|
|
249 |
|
| 28743 |
tejbeer |
250 |
User user = userRepository.selectById(userId);
|
| 29328 |
tejbeer |
251 |
AuthUser authUser = authRepository.selectByEmailOrMobile(user.getEmailId());
|
| 29325 |
tejbeer |
252 |
|
| 28742 |
tejbeer |
253 |
List<FocusedModelByPassRequest> byPassRequests = null;
|
|
|
254 |
|
|
|
255 |
Set<Integer> authfofoIds = null;
|
| 29325 |
tejbeer |
256 |
boolean actionAccess = false;
|
|
|
257 |
logger.info("authUser" + authUser);
|
| 28742 |
tejbeer |
258 |
|
| 29325 |
tejbeer |
259 |
List<Position> positions = positionRepository.selectPositionByAuthId(authUser.getId()).stream()
|
|
|
260 |
.filter(x -> (x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_SALES
|
|
|
261 |
|| x.getCategoryId() == ProfitMandiConstants.TICKET_CATEGORY_RBM))
|
|
|
262 |
.collect(Collectors.toList());
|
| 28742 |
tejbeer |
263 |
|
| 29325 |
tejbeer |
264 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
|
|
265 |
|
| 28742 |
tejbeer |
266 |
if (emails.contains(authUser.getEmailId())) {
|
| 29325 |
tejbeer |
267 |
byPassRequests = focusedModelByPassRepository.selectByStatus(ByPassRequestStatus.PENDING);
|
|
|
268 |
actionAccess = true;
|
| 28742 |
tejbeer |
269 |
} else {
|
| 29325 |
tejbeer |
270 |
if (!positions.isEmpty()) {
|
|
|
271 |
for (Position ps : positions) {
|
|
|
272 |
if (ProfitMandiConstants.TICKET_CATEGORY_RBM == ps.getCategoryId()) {
|
|
|
273 |
authfofoIds = storeGuyMap.get(user.getEmailId());
|
|
|
274 |
logger.info("authfofoIdsw" + authfofoIds);
|
|
|
275 |
actionAccess = true;
|
|
|
276 |
break;
|
|
|
277 |
} else if (ProfitMandiConstants.TICKET_CATEGORY_SALES == ps.getCategoryId()) {
|
|
|
278 |
authfofoIds = storeGuyMap.get(user.getEmailId());
|
|
|
279 |
logger.info("authfofoIdsw" + authfofoIds);
|
|
|
280 |
actionAccess = false;
|
|
|
281 |
break;
|
|
|
282 |
}
|
| 28742 |
tejbeer |
283 |
|
|
|
284 |
}
|
|
|
285 |
}
|
|
|
286 |
}
|
|
|
287 |
logger.info("authfofoIds" + authfofoIds);
|
|
|
288 |
if (authfofoIds != null) {
|
|
|
289 |
byPassRequests = focusedModelByPassRepository.selectByStatusAndFofoIds(new ArrayList<>(authfofoIds),
|
|
|
290 |
ByPassRequestStatus.PENDING);
|
|
|
291 |
}
|
| 29327 |
tejbeer |
292 |
|
| 28742 |
tejbeer |
293 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
|
|
294 |
List<ByPassRequestModel> byPassList = new ArrayList<>();
|
|
|
295 |
|
|
|
296 |
for (FocusedModelByPassRequest byPassRequest : byPassRequests) {
|
| 29327 |
tejbeer |
297 |
|
|
|
298 |
List<FocusedShortageModel> fsms = cartService.focusedModelShortageValidation(byPassRequest.getFofoId(),
|
|
|
299 |
new HashMap<>());
|
| 28742 |
tejbeer |
300 |
Map<String, Object> investments = fofoUser.getInvestments(byPassRequest.getFofoId());
|
|
|
301 |
ByPassRequestModel bp = new ByPassRequestModel();
|
|
|
302 |
bp.setPartnerName(customRetailerMap.get(byPassRequest.getFofoId()).getBusinessName());
|
|
|
303 |
bp.setCity(customRetailerMap.get(byPassRequest.getFofoId()).getAddress().getCity());
|
|
|
304 |
bp.setState(customRetailerMap.get(byPassRequest.getFofoId()).getAddress().getState());
|
|
|
305 |
bp.setCode(customRetailerMap.get(byPassRequest.getFofoId()).getCode());
|
|
|
306 |
bp.setStatus(byPassRequest.getStatus());
|
|
|
307 |
bp.setFofoId(byPassRequest.getFofoId());
|
|
|
308 |
bp.setByPassRequestId(byPassRequest.getId());
|
|
|
309 |
bp.setInvestmentOkDays((Long) investments.get("okDays"));
|
| 29327 |
tejbeer |
310 |
bp.setInvestmentShort((PartnerDailyInvestment) investments.get("investment"));
|
| 28742 |
tejbeer |
311 |
bp.setMobileNumber(customRetailerMap.get(byPassRequest.getFofoId()).getMobileNumber());
|
| 29325 |
tejbeer |
312 |
bp.setActionAccess(actionAccess);
|
| 28742 |
tejbeer |
313 |
bp.setCreateTimestamp(byPassRequest.getCreatedTimeStamp());
|
|
|
314 |
bp.setUpdateTimestamp(byPassRequest.getUpdatedTimestamp());
|
| 29327 |
tejbeer |
315 |
bp.setFsms(fsms);
|
| 28742 |
tejbeer |
316 |
byPassList.add(bp);
|
|
|
317 |
|
|
|
318 |
}
|
|
|
319 |
|
|
|
320 |
return responseSender.ok(byPassList);
|
|
|
321 |
}
|
|
|
322 |
|
|
|
323 |
@RequestMapping(value = "/byPassRequestAction", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
324 |
@ApiImplicitParams({
|
|
|
325 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
|
|
326 |
@ApiOperation(value = "Add items to cart")
|
|
|
327 |
public ResponseEntity<?> addAmountToWalletRequestRejected(HttpServletRequest request,
|
|
|
328 |
@RequestParam(name = "id", defaultValue = "0") int id, @RequestParam ByPassRequestStatus status,
|
| 29333 |
tejbeer |
329 |
@RequestParam String reason, Model model) throws Exception {
|
| 29325 |
tejbeer |
330 |
int userId = (int) request.getAttribute("userId");
|
| 28742 |
tejbeer |
331 |
|
| 29325 |
tejbeer |
332 |
User user = userRepository.selectById(userId);
|
|
|
333 |
AuthUser authUser = authRepository.selectByEmailOrMobile(user.getEmailId());
|
|
|
334 |
|
| 28742 |
tejbeer |
335 |
FocusedModelByPassRequest byPassRequest = focusedModelByPassRepository.selectById(id);
|
|
|
336 |
if (status.equals(ByPassRequestStatus.APPROVED)) {
|
|
|
337 |
byPassRequest.setByPass(true);
|
| 29325 |
tejbeer |
338 |
byPassRequest.setAuthId(authUser.getId());
|
| 28742 |
tejbeer |
339 |
byPassRequest.setStatus(ByPassRequestStatus.APPROVED);
|
|
|
340 |
byPassRequest.setUpdatedTimestamp(LocalDateTime.now());
|
| 29333 |
tejbeer |
341 |
byPassRequest.setReason(reason);
|
| 28742 |
tejbeer |
342 |
} else if (status.equals(ByPassRequestStatus.REJECTED)) {
|
|
|
343 |
byPassRequest.setByPass(false);
|
| 29325 |
tejbeer |
344 |
byPassRequest.setAuthId(authUser.getId());
|
| 28742 |
tejbeer |
345 |
byPassRequest.setStatus(ByPassRequestStatus.REJECTED);
|
|
|
346 |
byPassRequest.setUpdatedTimestamp(LocalDateTime.now());
|
| 29333 |
tejbeer |
347 |
byPassRequest.setReason(reason);
|
| 28742 |
tejbeer |
348 |
}
|
|
|
349 |
|
| 30989 |
tejbeer |
350 |
String title = "Billing Request";
|
|
|
351 |
|
|
|
352 |
String message = String.format("Your Billing Request is " + status
|
|
|
353 |
+ ". Please ensure to order the missing focus models as soon as possible.");
|
|
|
354 |
|
| 28742 |
tejbeer |
355 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
|
|
356 |
sendNotificationModel.setCampaignName("Billing Request");
|
| 30989 |
tejbeer |
357 |
sendNotificationModel.setTitle(title);
|
|
|
358 |
sendNotificationModel.setMessage(message);
|
| 28742 |
tejbeer |
359 |
sendNotificationModel.setType("url");
|
| 34902 |
vikas |
360 |
sendNotificationModel.setUrl("https://smartdukaan.com/pages/home/notifications");
|
| 28742 |
tejbeer |
361 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
|
|
362 |
sendNotificationModel.setMessageType(MessageType.notification);
|
|
|
363 |
sendNotificationModel
|
|
|
364 |
.setUserIds(Arrays.asList(userAccountRepository.selectUserIdByRetailerId(byPassRequest.getFofoId())));
|
|
|
365 |
|
|
|
366 |
notificationService.sendNotification(sendNotificationModel);
|
|
|
367 |
|
|
|
368 |
return responseSender.ok(true);
|
|
|
369 |
}
|
| 30989 |
tejbeer |
370 |
|
| 29503 |
amit.gupta |
371 |
@Autowired
|
|
|
372 |
WalletService walletService;
|
| 30989 |
tejbeer |
373 |
|
| 29503 |
amit.gupta |
374 |
@Autowired
|
|
|
375 |
MandiiService mandiiService;
|
| 30989 |
tejbeer |
376 |
|
|
|
377 |
@Autowired
|
|
|
378 |
UserWalletHistoryRepository userWalletHistoryRepository;
|
|
|
379 |
|
| 29503 |
amit.gupta |
380 |
@RequestMapping(value = "/cart/payment", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
381 |
public ResponseEntity<?> validateCartPayment(HttpServletRequest request,
|
|
|
382 |
@RequestParam(defaultValue = "0") int paymentId, Model model) throws Exception {
|
|
|
383 |
int userId = (int) request.getAttribute("userId");
|
|
|
384 |
UserCart uc = userAccountRepository.getUserCart(userId);
|
|
|
385 |
|
|
|
386 |
FofoPayment fofoPayment = fofoPaymentRepository.selectById(paymentId);
|
| 30989 |
tejbeer |
387 |
if (fofoPayment == null || fofoPayment.getFofoId() != uc.getUserId()) {
|
| 29503 |
amit.gupta |
388 |
return responseSender.ok(false);
|
|
|
389 |
}
|
|
|
390 |
String gatewayReference = fofoPayment.getGatewayReference();
|
| 30989 |
tejbeer |
391 |
List<UserWalletHistory> historyList = userWalletHistoryRepository
|
|
|
392 |
.selectAllByreferenceIdandreferenceType(paymentId, WalletReferenceType.PAYMENT_GATEWAY);
|
| 29503 |
amit.gupta |
393 |
if (fofoPayment.getStatus().equals(PaymentStatus.INIT) && historyList.size() == 0) {
|
|
|
394 |
String jsonString = mandiiService.getOrderStatus(gatewayReference);
|
|
|
395 |
JSONObject jsonOrder = new JSONObject(jsonString);
|
|
|
396 |
double orderAmount = jsonOrder.getDouble("order_amount");
|
| 29611 |
amit.gupta |
397 |
double capturedAmount = jsonOrder.getDouble("captured_amount");
|
| 29503 |
amit.gupta |
398 |
int merchantOrderId = jsonOrder.getInt("merchant_order_number");
|
| 29594 |
amit.gupta |
399 |
String status = jsonOrder.getString("status");
|
| 30989 |
tejbeer |
400 |
if (merchantOrderId == paymentId && status.equals("SUCCESS") || status.equals("CAPTURED")) {
|
|
|
401 |
if (orderAmount == fofoPayment.getAmount()) {
|
| 29611 |
amit.gupta |
402 |
fofoPayment.setStatus(PaymentStatus.SUCCESS);
|
| 29625 |
amit.gupta |
403 |
fofoPayment.setAmount(capturedAmount);
|
| 30989 |
tejbeer |
404 |
walletService.addAmountToWallet(uc.getUserId(), paymentId, WalletReferenceType.PAYMENT_GATEWAY,
|
|
|
405 |
"Amount added to wallet via SD Credit via Mandii", (float) fofoPayment.getAmount(),
|
|
|
406 |
LocalDateTime.now());
|
|
|
407 |
if (orderAmount == capturedAmount) {
|
| 29611 |
amit.gupta |
408 |
return responseSender.ok(true);
|
| 30989 |
tejbeer |
409 |
}
|
| 29611 |
amit.gupta |
410 |
}
|
| 29503 |
amit.gupta |
411 |
}
|
|
|
412 |
}
|
|
|
413 |
return responseSender.ok(false);
|
|
|
414 |
}
|
| 34196 |
ranu |
415 |
|
|
|
416 |
@RequestMapping(value = "/partner/hidAllocation", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
|
417 |
@ApiImplicitParams({@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header")})
|
| 35435 |
amit |
418 |
@Transactional(readOnly = true)
|
| 34196 |
ranu |
419 |
public ResponseEntity<?> getItemHidAllocation(HttpServletRequest request) throws
|
|
|
420 |
Exception {
|
|
|
421 |
List<HidAllocationModel> hidAllocationModels = new ArrayList<>();
|
|
|
422 |
|
|
|
423 |
int userId = (int) request.getAttribute(ProfitMandiConstants.USER_ID);
|
|
|
424 |
int retailerId = userAccountRepository.selectRetailerIdByUserId(userId);
|
|
|
425 |
|
|
|
426 |
hidAllocationModels = fofoOpeningStockRepository.getPartnerHidAllocation(retailerId);
|
|
|
427 |
|
|
|
428 |
return responseSender.ok(hidAllocationModels);
|
|
|
429 |
}
|
|
|
430 |
|
|
|
431 |
|
| 21378 |
kshitij.so |
432 |
}
|