| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.io.ByteArrayInputStream;
|
| - |
|
4 |
import java.io.ByteArrayOutputStream;
|
| - |
|
5 |
import java.io.InputStream;
|
| - |
|
6 |
import java.text.MessageFormat;
|
| - |
|
7 |
import java.time.LocalDate;
|
| - |
|
8 |
import java.time.LocalDateTime;
|
| - |
|
9 |
import java.time.ZoneId;
|
| - |
|
10 |
import java.util.ArrayList;
|
| - |
|
11 |
import java.util.Arrays;
|
| - |
|
12 |
import java.util.Collections;
|
| - |
|
13 |
import java.util.Date;
|
| - |
|
14 |
import java.util.HashMap;
|
| - |
|
15 |
import java.util.List;
|
| - |
|
16 |
import java.util.Map;
|
| - |
|
17 |
import java.util.Set;
|
| - |
|
18 |
import java.util.stream.Collectors;
|
| - |
|
19 |
|
| - |
|
20 |
import javax.mail.internet.InternetAddress;
|
| - |
|
21 |
import javax.mail.internet.MimeMessage;
|
| - |
|
22 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
23 |
import javax.swing.SortOrder;
|
| - |
|
24 |
import javax.transaction.Transactional;
|
| - |
|
25 |
|
| - |
|
26 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
27 |
import org.apache.logging.log4j.Logger;
|
| - |
|
28 |
import org.apache.poi.ss.usermodel.Cell;
|
| - |
|
29 |
import org.apache.poi.ss.usermodel.CellStyle;
|
| - |
|
30 |
import org.apache.poi.ss.usermodel.CreationHelper;
|
| - |
|
31 |
import org.apache.poi.ss.usermodel.Sheet;
|
| - |
|
32 |
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
| - |
|
33 |
import org.json.JSONObject;
|
| - |
|
34 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
35 |
import org.springframework.core.io.InputStreamResource;
|
| - |
|
36 |
import org.springframework.http.HttpHeaders;
|
| - |
|
37 |
import org.springframework.http.HttpStatus;
|
| - |
|
38 |
import org.springframework.http.ResponseEntity;
|
| - |
|
39 |
import org.springframework.mail.javamail.JavaMailSender;
|
| - |
|
40 |
import org.springframework.mail.javamail.MimeMessageHelper;
|
| - |
|
41 |
import org.springframework.stereotype.Controller;
|
| - |
|
42 |
import org.springframework.ui.Model;
|
| - |
|
43 |
import org.springframework.web.bind.annotation.PostMapping;
|
| - |
|
44 |
import org.springframework.web.bind.annotation.RequestBody;
|
| - |
|
45 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| - |
|
46 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| - |
|
47 |
import org.springframework.web.bind.annotation.RequestParam;
|
| - |
|
48 |
import org.springframework.web.bind.annotation.RequestPart;
|
| - |
|
49 |
import org.springframework.web.multipart.MultipartFile;
|
| - |
|
50 |
|
| - |
|
51 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
52 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 4 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
53 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 5 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
54 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 6 |
import com.spice.profitmandi.common.model.UnsettledPaymentModel;
|
55 |
import com.spice.profitmandi.common.model.UnsettledPaymentModel;
|
| 7 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
56 |
import com.spice.profitmandi.common.util.ExcelUtils;
|
| 8 |
import com.spice.profitmandi.common.util.FileUtil;
|
57 |
import com.spice.profitmandi.common.util.FileUtil;
|
| - |
|
58 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 9 |
import com.spice.profitmandi.common.util.StringUtils;
|
59 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 10 |
import com.spice.profitmandi.common.util.WalletHistoryModel;
|
60 |
import com.spice.profitmandi.common.util.WalletHistoryModel;
|
| 11 |
import com.spice.profitmandi.dao.entity.dtr.CreditAccount;
|
61 |
import com.spice.profitmandi.dao.entity.dtr.CreditAccount;
|
| 12 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
62 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| - |
|
63 |
import com.spice.profitmandi.dao.entity.transaction.AddWalletRequest;
|
| - |
|
64 |
import com.spice.profitmandi.dao.entity.transaction.ManualPaymentType;
|
| - |
|
65 |
import com.spice.profitmandi.dao.entity.transaction.UnsettledPayment;
|
| 13 |
import com.spice.profitmandi.dao.entity.transaction.*;
|
66 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| - |
|
67 |
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
|
| 14 |
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
|
68 |
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
|
| 15 |
import com.spice.profitmandi.dao.enumuration.transaction.TransactionType;
|
69 |
import com.spice.profitmandi.dao.enumuration.transaction.TransactionType;
|
| 16 |
import com.spice.profitmandi.dao.repository.catalog.AddWalletRequestRepository;
|
70 |
import com.spice.profitmandi.dao.repository.catalog.AddWalletRequestRepository;
|
| 17 |
import com.spice.profitmandi.dao.repository.catalog.ManualPaymentRequestRepository;
|
71 |
import com.spice.profitmandi.dao.repository.catalog.ManualPaymentRequestRepository;
|
| 18 |
import com.spice.profitmandi.dao.repository.catalog.UnsettledPaymentsRepository;
|
72 |
import com.spice.profitmandi.dao.repository.catalog.UnsettledPaymentsRepository;
|
| Line 21... |
Line 75... |
| 21 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
75 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 22 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
76 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 23 |
import com.spice.profitmandi.dao.repository.transaction.StatementDetailModel;
|
77 |
import com.spice.profitmandi.dao.repository.transaction.StatementDetailModel;
|
| 24 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
78 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
| 25 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
79 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| - |
|
80 |
import com.spice.profitmandi.service.NotificationService;
|
| 26 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
81 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 27 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
82 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 28 |
import com.spice.profitmandi.service.user.RetailerService;
|
83 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 29 |
import com.spice.profitmandi.service.wallet.WalletService;
|
84 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 30 |
import com.spice.profitmandi.web.model.LoginDetails;
|
85 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 31 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
86 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 32 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
87 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 33 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
- |
|
| 34 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 35 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 36 |
import org.apache.poi.ss.usermodel.Cell;
|
- |
|
| 37 |
import org.apache.poi.ss.usermodel.CellStyle;
|
- |
|
| 38 |
import org.apache.poi.ss.usermodel.CreationHelper;
|
- |
|
| 39 |
import org.apache.poi.ss.usermodel.Sheet;
|
- |
|
| 40 |
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
- |
|
| 41 |
import org.json.JSONObject;
|
- |
|
| 42 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 43 |
import org.springframework.core.io.InputStreamResource;
|
- |
|
| 44 |
import org.springframework.http.HttpHeaders;
|
- |
|
| 45 |
import org.springframework.http.HttpStatus;
|
- |
|
| 46 |
import org.springframework.http.ResponseEntity;
|
- |
|
| 47 |
import org.springframework.mail.javamail.JavaMailSender;
|
- |
|
| 48 |
import org.springframework.mail.javamail.MimeMessageHelper;
|
- |
|
| 49 |
import org.springframework.stereotype.Controller;
|
- |
|
| 50 |
import org.springframework.ui.Model;
|
- |
|
| 51 |
import org.springframework.web.bind.annotation.*;
|
- |
|
| 52 |
import org.springframework.web.multipart.MultipartFile;
|
- |
|
| 53 |
|
88 |
|
| 54 |
import javax.mail.internet.InternetAddress;
|
89 |
import in.shop2020.model.v1.order.WalletReferenceType;
|
| 55 |
import javax.mail.internet.MimeMessage;
|
- |
|
| 56 |
import javax.servlet.http.HttpServletRequest;
|
- |
|
| 57 |
import javax.swing.*;
|
- |
|
| 58 |
import javax.transaction.Transactional;
|
- |
|
| 59 |
import java.io.ByteArrayInputStream;
|
- |
|
| 60 |
import java.io.ByteArrayOutputStream;
|
- |
|
| 61 |
import java.io.InputStream;
|
- |
|
| 62 |
import java.text.MessageFormat;
|
- |
|
| 63 |
import java.time.LocalDate;
|
- |
|
| 64 |
import java.time.LocalDateTime;
|
- |
|
| 65 |
import java.time.ZoneId;
|
- |
|
| 66 |
import java.util.*;
|
- |
|
| 67 |
import java.util.stream.Collectors;
|
- |
|
| 68 |
|
90 |
|
| 69 |
@Controller
|
91 |
@Controller
|
| 70 |
@Transactional(rollbackOn = Throwable.class)
|
92 |
@Transactional(rollbackOn = Throwable.class)
|
| 71 |
public class WalletController {
|
93 |
public class WalletController {
|
| 72 |
|
94 |
|
| Line 153... |
Line 175... |
| 153 |
@Autowired
|
175 |
@Autowired
|
| 154 |
AddWalletRequestRepository addWalletRequestRepository;
|
176 |
AddWalletRequestRepository addWalletRequestRepository;
|
| 155 |
|
177 |
|
| 156 |
@Autowired
|
178 |
@Autowired
|
| 157 |
private CreditAccountRepository creditAccountRepository;
|
179 |
private CreditAccountRepository creditAccountRepository;
|
| - |
|
180 |
|
| - |
|
181 |
@Autowired
|
| - |
|
182 |
private NotificationService notificationService;
|
| 158 |
private static final Logger LOGGER = LogManager.getLogger(WalletController.class);
|
183 |
private static final Logger LOGGER = LogManager.getLogger(WalletController.class);
|
| 159 |
|
184 |
|
| 160 |
@PostMapping(value = "/wallet/upload")
|
185 |
@PostMapping(value = "/wallet/upload")
|
| 161 |
public String uploadWalletBulk(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model)
|
186 |
public String uploadWalletBulk(HttpServletRequest request, @RequestPart("file") MultipartFile file, Model model)
|
| 162 |
throws Exception {
|
187 |
throws Exception {
|
| Line 975... |
Line 1000... |
| 975 |
return "response";
|
1000 |
return "response";
|
| 976 |
}
|
1001 |
}
|
| 977 |
|
1002 |
|
| 978 |
@RequestMapping(value = "/walletUpdate", method = RequestMethod.POST)
|
1003 |
@RequestMapping(value = "/walletUpdate", method = RequestMethod.POST)
|
| 979 |
public String walletUpdate(HttpServletRequest request,
|
1004 |
public String walletUpdate(HttpServletRequest request,
|
| 980 |
@RequestParam(name = "reference", defaultValue = "0") int reference, @RequestParam int referenceTypeValue,
|
1005 |
@RequestParam(name = "reference", defaultValue = "0") int reference, @RequestParam int referenceTypeValue,
|
| 981 |
@RequestParam TransactionType transactiontype, @RequestParam int amount, @RequestParam String description,
|
1006 |
@RequestParam TransactionType transactiontype, @RequestParam int amount, @RequestParam String description,
|
| 982 |
@RequestParam int retailerId, Model model, @RequestParam LocalDateTime businessTimestamp) throws Exception {
|
1007 |
@RequestParam int retailerId, Model model, @RequestParam LocalDateTime businessTimestamp) throws Exception {
|
| 983 |
WalletReferenceType referenceType = WalletReferenceType.findByValue(referenceTypeValue);
|
1008 |
WalletReferenceType referenceType = WalletReferenceType.findByValue(referenceTypeValue);
|
| 984 |
if (reference == 0 && referenceType.getValue() >= WalletReferenceType.INCENTIVES.getValue()) {
|
1009 |
if (reference == 0 && referenceType.getValue() >= WalletReferenceType.INCENTIVES.getValue()) {
|
| 985 |
LOGGER.error("referenceType: " + referenceType);
|
1010 |
LOGGER.error("referenceType: " + referenceType);
|
| 986 |
ManualPaymentType paymentType = manualPaymentRequestRepository.selectByReferenceType(referenceType);
|
1011 |
ManualPaymentType paymentType = manualPaymentRequestRepository.selectByReferenceType(referenceType);
|
| 987 |
|
1012 |
|
| Line 1076... |
Line 1101... |
| 1076 |
|
1101 |
|
| 1077 |
creditAccount.setActive(true);
|
1102 |
creditAccount.setActive(true);
|
| 1078 |
|
1103 |
|
| 1079 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailers();
|
1104 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailers();
|
| 1080 |
|
1105 |
|
| - |
|
1106 |
String title = "Loan Approved";
|
| - |
|
1107 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
| - |
|
1108 |
String message = "Congratulations! Your Credit is approved Rs."
|
| - |
|
1109 |
+ FormattingUtils.formatDecimal(creditAccount.getSanctionedAmount());
|
| - |
|
1110 |
notificationService.sendNotification(creditAccount.getFofoId(), "Loan", MessageType.notification, title,
|
| - |
|
1111 |
message, url);
|
| - |
|
1112 |
|
| 1081 |
model.addAttribute("creditAccount", creditAccount);
|
1113 |
model.addAttribute("creditAccount", creditAccount);
|
| 1082 |
model.addAttribute("customRetailers", customRetailers);
|
1114 |
model.addAttribute("customRetailers", customRetailers);
|
| 1083 |
return "partner-credit-detail-row";
|
1115 |
return "partner-credit-detail-row";
|
| 1084 |
}
|
1116 |
}
|
| 1085 |
|
1117 |
|