| Line 58... |
Line 58... |
| 58 |
|
58 |
|
| 59 |
@Controller
|
59 |
@Controller
|
| 60 |
@Transactional(rollbackOn = Throwable.class)
|
60 |
@Transactional(rollbackOn = Throwable.class)
|
| 61 |
public class SDCreditController {
|
61 |
public class SDCreditController {
|
| 62 |
|
62 |
|
| 63 |
@Autowired
|
63 |
@Autowired
|
| 64 |
private RetailerService retailerService;
|
64 |
private RetailerService retailerService;
|
| 65 |
|
65 |
|
| 66 |
@Autowired
|
66 |
@Autowired
|
| 67 |
SDCreditRequirementRepository sdCreditRequirementRepository;
|
67 |
SDCreditRequirementRepository sdCreditRequirementRepository;
|
| 68 |
|
68 |
|
| 69 |
@Autowired
|
69 |
@Autowired
|
| 70 |
SanctionRequestRepository sanctionRequestRepository;
|
70 |
SanctionRequestRepository sanctionRequestRepository;
|
| 71 |
|
71 |
|
| 72 |
@Autowired
|
72 |
@Autowired
|
| 73 |
PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
73 |
PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
| 74 |
|
74 |
|
| 75 |
@Autowired
|
75 |
@Autowired
|
| 76 |
private FofoStoreRepository fofoStoreRepository;
|
76 |
private FofoStoreRepository fofoStoreRepository;
|
| 77 |
|
77 |
|
| 78 |
@Autowired
|
78 |
@Autowired
|
| 79 |
private CreditAccountRepository creditAccountRepository;
|
79 |
private CreditAccountRepository creditAccountRepository;
|
| 80 |
|
80 |
|
| 81 |
@Autowired
|
81 |
@Autowired
|
| 82 |
private SDCreditService sdCreditService;
|
82 |
private SDCreditService sdCreditService;
|
| 83 |
|
83 |
|
| 84 |
@Autowired
|
84 |
@Autowired
|
| 85 |
private CsService1 csService1;
|
85 |
private CsService1 csService1;
|
| 86 |
|
86 |
|
| 87 |
@Autowired
|
87 |
@Autowired
|
| 88 |
private NotificationService notificationService;
|
88 |
private NotificationService notificationService;
|
| 89 |
|
89 |
|
| 90 |
@Autowired
|
90 |
@Autowired
|
| 91 |
private AuthRepository authRepository;
|
91 |
private AuthRepository authRepository;
|
| 92 |
|
92 |
|
| 93 |
@Autowired
|
93 |
@Autowired
|
| 94 |
private UserRepository userRepository;
|
94 |
private UserRepository userRepository;
|
| 95 |
|
95 |
|
| 96 |
@Autowired
|
96 |
@Autowired
|
| 97 |
private CurrentPartnerDailyInvestmentRepository currentPartnerDailyInvestmentRepository;
|
97 |
private CurrentPartnerDailyInvestmentRepository currentPartnerDailyInvestmentRepository;
|
| 98 |
|
98 |
|
| 99 |
@Autowired
|
99 |
@Autowired
|
| 100 |
private UserWalletRepository userWalletRepository;
|
100 |
private UserWalletRepository userWalletRepository;
|
| 101 |
|
101 |
|
| 102 |
@Autowired
|
102 |
@Autowired
|
| 103 |
LoanRepository loanRepository;
|
103 |
LoanRepository loanRepository;
|
| 104 |
|
104 |
|
| 105 |
@Autowired
|
105 |
@Autowired
|
| 106 |
private CookiesProcessor cookiesProcessor;
|
106 |
private CookiesProcessor cookiesProcessor;
|
| 107 |
|
107 |
|
| 108 |
@Autowired
|
108 |
@Autowired
|
| 109 |
private CsService csService;
|
109 |
private CsService csService;
|
| 110 |
|
110 |
|
| 111 |
@Autowired
|
111 |
@Autowired
|
| 112 |
AddressRepository addressRepository;
|
112 |
AddressRepository addressRepository;
|
| 113 |
|
113 |
|
| 114 |
@Autowired
|
114 |
@Autowired
|
| 115 |
OrderRepository orderRepository;
|
115 |
OrderRepository orderRepository;
|
| 116 |
|
116 |
|
| 117 |
@Autowired
|
117 |
@Autowired
|
| 118 |
private LoanStatementRepository loanStatementRepository;
|
118 |
private LoanStatementRepository loanStatementRepository;
|
| 119 |
|
119 |
|
| 120 |
@Autowired
|
120 |
@Autowired
|
| 121 |
private com.spice.profitmandi.dao.repository.user.UserRepository userUserRepository;
|
121 |
private com.spice.profitmandi.dao.repository.user.UserRepository userUserRepository;
|
| 122 |
|
122 |
|
| 123 |
@Autowired
|
123 |
@Autowired
|
| 124 |
private JavaMailSender mailSender;
|
124 |
private JavaMailSender mailSender;
|
| 125 |
|
125 |
|
| 126 |
@Autowired
|
126 |
@Autowired
|
| 127 |
private MVCResponseSender mvcResponseSender;
|
127 |
private MVCResponseSender mvcResponseSender;
|
| 128 |
|
128 |
|
| 129 |
private static final Logger LOGGER = LogManager.getLogger(SDCreditController.class);
|
129 |
private static final Logger LOGGER = LogManager.getLogger(SDCreditController.class);
|
| 130 |
|
130 |
|
| 131 |
@RequestMapping(value = "/getSDCreditReq", method = RequestMethod.GET)
|
131 |
@RequestMapping(value = "/getSDCreditReq", method = RequestMethod.GET)
|
| 132 |
public String getSDCreditReq(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
132 |
public String getSDCreditReq(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| 133 |
|
133 |
|
| 134 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
|
134 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
|
| 135 |
|
135 |
|
| 136 |
Map<Integer, SDCreditRequirement> sdCreditRequirementMap = sdCreditRequirementRepository.selectAll().stream()
|
136 |
Map<Integer, SDCreditRequirement> sdCreditRequirementMap = sdCreditRequirementRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 137 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
- |
|
| 138 |
for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailerMap.entrySet()) {
|
137 |
for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailerMap.entrySet()) {
|
| 139 |
int fofoId = customRetailerEntry.getKey();
|
138 |
int fofoId = customRetailerEntry.getKey();
|
| 140 |
|
139 |
|
| 141 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementMap.get(customRetailerEntry.getKey());
|
140 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementMap.get(customRetailerEntry.getKey());
|
| 142 |
|
141 |
|
| 143 |
if (sdCreditRequirement != null) {
|
142 |
if (sdCreditRequirement != null) {
|
| 144 |
|
143 |
|
| 145 |
BigDecimal utilizedLimit = new BigDecimal(sdCreditService.getUtilizationAmount(fofoId));
|
144 |
BigDecimal utilizedLimit = new BigDecimal(sdCreditService.getUtilizationAmount(fofoId));
|
| 146 |
|
145 |
|
| 147 |
BigDecimal availableLimit = sdCreditRequirement.getLimit().subtract(utilizedLimit);
|
146 |
BigDecimal availableLimit = sdCreditRequirement.getLimit().subtract(utilizedLimit);
|
| 148 |
|
147 |
|
| 149 |
LOGGER.info("utilizedLimit {} ", utilizedLimit);
|
148 |
LOGGER.info("utilizedLimit {} ", utilizedLimit);
|
| 150 |
|
149 |
|
| 151 |
LOGGER.info("availableLimit {} ", availableLimit);
|
150 |
LOGGER.info("availableLimit {} ", availableLimit);
|
| 152 |
|
151 |
|
| 153 |
sdCreditRequirement.setUtilizedAmount(utilizedLimit);
|
152 |
sdCreditRequirement.setUtilizedAmount(utilizedLimit);
|
| 154 |
|
153 |
|
| 155 |
sdCreditRequirement.setUpdateTimestamp(LocalDateTime.now());
|
154 |
sdCreditRequirement.setUpdateTimestamp(LocalDateTime.now());
|
| 156 |
}
|
155 |
}
|
| 157 |
|
156 |
|
| 158 |
}
|
157 |
}
|
| 159 |
|
158 |
|
| 160 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
159 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
| 161 |
model.addAttribute("sdCreditRequirementMap", sdCreditRequirementMap);
|
160 |
model.addAttribute("sdCreditRequirementMap", sdCreditRequirementMap);
|
| 162 |
return "sd-credit";
|
161 |
return "sd-credit";
|
| 163 |
}
|
162 |
}
|
| 164 |
|
163 |
|
| 165 |
@RequestMapping(value = "/creditRequirement", method = RequestMethod.POST)
|
164 |
@RequestMapping(value = "/creditRequirement", method = RequestMethod.POST)
|
| 166 |
public String sdCredit(HttpServletRequest request, @RequestBody SdCreditRequirementModel sdCreditRequirementModel,
|
165 |
public String sdCredit(HttpServletRequest request, @RequestBody SdCreditRequirementModel sdCreditRequirementModel, Model model) throws Exception {
|
| 167 |
Model model) throws Exception {
|
- |
|
| 168 |
|
166 |
|
| 169 |
LOGGER.info("sdCreditRequirementModel {} ", sdCreditRequirementModel);
|
167 |
LOGGER.info("sdCreditRequirementModel {} ", sdCreditRequirementModel);
|
| 170 |
|
168 |
|
| 171 |
int fofoId = sdCreditRequirementModel.getFofoId();
|
169 |
int fofoId = sdCreditRequirementModel.getFofoId();
|
| 172 |
|
170 |
|
| 173 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementRepository
|
171 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementRepository.selectByFofoId(sdCreditRequirementModel.getFofoId());
|
| 174 |
.selectByFofoId(sdCreditRequirementModel.getFofoId());
|
- |
|
| 175 |
|
172 |
|
| 176 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(sdCreditRequirementModel.getFofoId());
|
173 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(sdCreditRequirementModel.getFofoId());
|
| 177 |
sdCreditRequirement.setSecurityCheck(sdCreditRequirementModel.getSecurityCheck());
|
174 |
sdCreditRequirement.setSecurityCheck(sdCreditRequirementModel.getSecurityCheck());
|
| 178 |
// sdCreditRequirement.setSecurityCheck(2);
|
175 |
// sdCreditRequirement.setSecurityCheck(2);
|
| 179 |
|
176 |
|
| 180 |
sdCreditRequirement.setInterestRate(sdCreditRequirementModel.getInterest());
|
177 |
sdCreditRequirement.setInterestRate(sdCreditRequirementModel.getInterest());
|
| 181 |
sdCreditRequirement.setFreeDays(sdCreditRequirementModel.getFreeDays());
|
178 |
sdCreditRequirement.setFreeDays(sdCreditRequirementModel.getFreeDays());
|
| 182 |
sdCreditRequirement.setLimit(sdCreditRequirementModel.getLimit());
|
179 |
sdCreditRequirement.setLimit(sdCreditRequirementModel.getLimit());
|
| 183 |
BigDecimal utilizedLimit = new BigDecimal(sdCreditService.getUtilizationAmount(fofoId));
|
180 |
BigDecimal utilizedLimit = new BigDecimal(sdCreditService.getUtilizationAmount(fofoId));
|
| 184 |
|
181 |
|
| 185 |
BigDecimal availableLimit = sdCreditRequirement.getLimit().subtract(utilizedLimit);
|
182 |
BigDecimal availableLimit = sdCreditRequirement.getLimit().subtract(utilizedLimit);
|
| 186 |
|
183 |
|
| 187 |
LOGGER.info("utilizedLimit {} ", utilizedLimit);
|
184 |
LOGGER.info("utilizedLimit {} ", utilizedLimit);
|
| 188 |
|
185 |
|
| 189 |
LOGGER.info("availableLimit {} ", availableLimit);
|
186 |
LOGGER.info("availableLimit {} ", availableLimit);
|
| 190 |
|
187 |
|
| 191 |
sdCreditRequirement.setUtilizedAmount(utilizedLimit);
|
188 |
sdCreditRequirement.setUtilizedAmount(utilizedLimit);
|
| 192 |
|
189 |
|
| 193 |
sdCreditRequirement.setCreditDays(15);
|
190 |
sdCreditRequirement.setCreditDays(15);
|
| 194 |
sdCreditRequirement.setUpdateTimestamp(LocalDateTime.now());
|
191 |
sdCreditRequirement.setUpdateTimestamp(LocalDateTime.now());
|
| 195 |
|
192 |
|
| 196 |
if (sdCreditRequirement.getSecurityCheck() > 0) {
|
193 |
if (sdCreditRequirement.getSecurityCheck() > 0) {
|
| 197 |
|
194 |
|
| 198 |
CreditAccount creditAccount = creditAccountRepository
|
- |
|
| 199 |
.selectByFofoIdAndGateway(sdCreditRequirementModel.getFofoId(), Gateway.SDDIRECT);
|
195 |
CreditAccount creditAccount = creditAccountRepository.selectByFofoIdAndGateway(sdCreditRequirementModel.getFofoId(), Gateway.SDDIRECT);
|
| 200 |
if (creditAccount == null) {
|
196 |
if (creditAccount == null) {
|
| 201 |
creditAccount = new CreditAccount();
|
197 |
creditAccount = new CreditAccount();
|
| 202 |
creditAccount.setFofoId(sdCreditRequirementModel.getFofoId());
|
198 |
creditAccount.setFofoId(sdCreditRequirementModel.getFofoId());
|
| 203 |
creditAccount.setGateway(Gateway.SDDIRECT);
|
199 |
creditAccount.setGateway(Gateway.SDDIRECT);
|
| 204 |
creditAccount.setCreditStatus(CreditStatus.SANCTIONED);
|
200 |
creditAccount.setCreditStatus(CreditStatus.SANCTIONED);
|
| 205 |
creditAccount.setActive(false);
|
201 |
creditAccount.setActive(false);
|
| 206 |
|
202 |
|
| 207 |
creditAccount.setUpdatedOn(LocalDateTime.now());
|
203 |
creditAccount.setUpdatedOn(LocalDateTime.now());
|
| 208 |
|
204 |
|
| 209 |
creditAccountRepository.persist(creditAccount);
|
205 |
creditAccountRepository.persist(creditAccount);
|
| 210 |
}
|
206 |
}
|
| 211 |
|
207 |
|
| 212 |
creditAccount.setInterestRate(sdCreditRequirement.getInterestRate().floatValue());
|
208 |
creditAccount.setInterestRate(sdCreditRequirement.getInterestRate().floatValue());
|
| 213 |
creditAccount.setSanctionedAmount(sdCreditRequirement.getLimit().floatValue());
|
209 |
creditAccount.setSanctionedAmount(sdCreditRequirement.getLimit().floatValue());
|
| 214 |
creditAccount.setAvailableAmount(availableLimit.floatValue());
|
210 |
creditAccount.setAvailableAmount(availableLimit.floatValue());
|
| 215 |
creditAccount.setFreeDays(sdCreditRequirement.getFreeDays());
|
211 |
creditAccount.setFreeDays(sdCreditRequirement.getFreeDays());
|
| 216 |
creditAccount.setUpdatedOn(LocalDateTime.now());
|
212 |
creditAccount.setUpdatedOn(LocalDateTime.now());
|
| 217 |
|
213 |
|
| 218 |
}
|
214 |
}
|
| 219 |
LOGGER.info("sdCreditRequirement {} ", sdCreditRequirement);
|
215 |
LOGGER.info("sdCreditRequirement {} ", sdCreditRequirement);
|
| 220 |
|
216 |
|
| 221 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(sdCreditRequirementModel.getFofoId());
|
217 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(sdCreditRequirementModel.getFofoId());
|
| 222 |
|
218 |
|
| 223 |
sdCreditRequirement = sdCreditRequirementRepository.selectByFofoId(sdCreditRequirementModel.getFofoId());
|
219 |
sdCreditRequirement = sdCreditRequirementRepository.selectByFofoId(sdCreditRequirementModel.getFofoId());
|
| 224 |
|
220 |
|
| 225 |
Map<Integer, SDCreditRequirement> sdCreditRequirementMap = new HashMap<>();
|
221 |
Map<Integer, SDCreditRequirement> sdCreditRequirementMap = new HashMap<>();
|
| 226 |
sdCreditRequirementMap.put(sdCreditRequirement.getFofoId(), sdCreditRequirement);
|
222 |
sdCreditRequirementMap.put(sdCreditRequirement.getFofoId(), sdCreditRequirement);
|
| 227 |
model.addAttribute("sdCreditRequirementMap", sdCreditRequirementMap);
|
223 |
model.addAttribute("sdCreditRequirementMap", sdCreditRequirementMap);
|
| 228 |
model.addAttribute("customRetailer", customRetailer);
|
224 |
model.addAttribute("customRetailer", customRetailer);
|
| 229 |
|
225 |
|
| 230 |
return "sd-credit-requirement-row";
|
226 |
return "sd-credit-requirement-row";
|
| 231 |
|
227 |
|
| 232 |
}
|
228 |
}
|
| 233 |
|
229 |
|
| 234 |
@RequestMapping(value = "/getSanctionRequest", method = RequestMethod.GET)
|
230 |
@RequestMapping(value = "/getSanctionRequest", method = RequestMethod.GET)
|
| 235 |
public String getSanctionRequest(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
231 |
public String getSanctionRequest(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| 236 |
|
232 |
|
| 237 |
List<SanctionRequest> sanctionRequests = sanctionRequestRepository.selectByDate(LocalDate.now());
|
233 |
List<SanctionRequest> sanctionRequests = sanctionRequestRepository.selectByDate(LocalDate.now());
|
| 238 |
|
234 |
|
| 239 |
List<Integer> authIds = sanctionRequests.stream().map(x -> x.getAuthId()).collect(Collectors.toList());
|
235 |
List<Integer> authIds = sanctionRequests.stream().map(x -> x.getAuthId()).collect(Collectors.toList());
|
| 240 |
Map<Integer, String> authMap = authRepository.selectAllAuthUserByIds(authIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x.getFullName()));
|
236 |
Map<Integer, String> authMap = authRepository.selectAllAuthUserByIds(authIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x.getFullName()));
|
| 241 |
|
237 |
|
| 242 |
if (!sanctionRequests.isEmpty()) {
|
238 |
if (!sanctionRequests.isEmpty()) {
|
| 243 |
|
239 |
|
| 244 |
List<Integer> fofoIds = sanctionRequests.stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
240 |
List<Integer> fofoIds = sanctionRequests.stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
| 245 |
|
241 |
|
| 246 |
Map<Integer, Long> partnerCreditDaysMap = new HashMap<>();
|
242 |
Map<Integer, Long> partnerCreditDaysMap = new HashMap<>();
|
| 247 |
|
243 |
|
| 248 |
Map<Integer, Integer> partnerActiveLoanMap = new HashMap<>();
|
244 |
Map<Integer, Integer> partnerActiveLoanMap = new HashMap<>();
|
| 249 |
|
245 |
|
| 250 |
for (Integer fofoId : fofoIds) {
|
246 |
for (Integer fofoId : fofoIds) {
|
| 251 |
List<Loan> loans = loanRepository.selectActiveLoan(fofoId);
|
247 |
List<Loan> loans = loanRepository.selectActiveLoan(fofoId);
|
| 252 |
|
248 |
|
| 253 |
if (!loans.isEmpty()) {
|
249 |
if (!loans.isEmpty()) {
|
| 254 |
|
250 |
|
| 255 |
partnerActiveLoanMap.put(fofoId, loans.size());
|
251 |
partnerActiveLoanMap.put(fofoId, loans.size());
|
| 256 |
Loan loan = loans.get(loans.size() - 1);
|
252 |
Loan loan = loans.get(loans.size() - 1);
|
| 257 |
|
253 |
|
| 258 |
long daysBetween = Duration.between(loan.getCreatedOn(), LocalDateTime.now()).toDays();
|
254 |
long daysBetween = Duration.between(loan.getCreatedOn(), LocalDateTime.now()).toDays();
|
| 259 |
|
255 |
|
| 260 |
partnerCreditDaysMap.put(fofoId, daysBetween);
|
256 |
partnerCreditDaysMap.put(fofoId, daysBetween);
|
| 261 |
|
257 |
|
| 262 |
}
|
258 |
}
|
| 263 |
model.addAttribute("partnerCreditDaysMap", partnerCreditDaysMap);
|
259 |
model.addAttribute("partnerCreditDaysMap", partnerCreditDaysMap);
|
| 264 |
model.addAttribute("partnerActiveLoanMap", partnerActiveLoanMap);
|
260 |
model.addAttribute("partnerActiveLoanMap", partnerActiveLoanMap);
|
| 265 |
|
261 |
|
| 266 |
}
|
262 |
}
|
| 267 |
|
263 |
|
| 268 |
Map<Integer, SDCreditRequirement> sdCreditRequirementMap = sdCreditRequirementRepository.selectAll()
|
264 |
Map<Integer, SDCreditRequirement> sdCreditRequirementMap = sdCreditRequirementRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 269 |
.stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
- |
|
| 270 |
|
265 |
|
| 271 |
Map<Integer, UserWallet> userWalletMap = userWalletRepository.selectByRetailerIds(new HashSet<>(fofoIds))
|
266 |
Map<Integer, UserWallet> userWalletMap = userWalletRepository.selectByRetailerIds(new HashSet<>(fofoIds)).stream().collect(Collectors.toMap(x -> x.getUserId(), x -> x));
|
| 272 |
.stream().collect(Collectors.toMap(x -> x.getUserId(), x -> x));
|
- |
|
| 273 |
|
267 |
|
| 274 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(fofoIds);
|
268 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(fofoIds);
|
| 275 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = partnerDailyInvestmentRepository
|
269 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = partnerDailyInvestmentRepository.selectAll(fofoIds, LocalDate.now().minusDays(1)).stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 276 |
.selectAll(fofoIds, LocalDate.now().minusDays(1)).stream()
|
- |
|
| 277 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
- |
|
| 278 |
|
270 |
|
| 279 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
271 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
| 280 |
|
272 |
|
| 281 |
model.addAttribute("partnerDailyInvestmentMap", partnerDailyInvestmentMap);
|
273 |
model.addAttribute("partnerDailyInvestmentMap", partnerDailyInvestmentMap);
|
| 282 |
model.addAttribute("sdCreditRequirementMap", sdCreditRequirementMap);
|
274 |
model.addAttribute("sdCreditRequirementMap", sdCreditRequirementMap);
|
| 283 |
|
275 |
|
| 284 |
model.addAttribute("userWalletMap", userWalletMap);
|
276 |
model.addAttribute("userWalletMap", userWalletMap);
|
| 285 |
|
277 |
|
| 286 |
}
|
278 |
}
|
| 287 |
|
279 |
|
| 288 |
model.addAttribute("sanctionRequests", sanctionRequests);
|
280 |
model.addAttribute("sanctionRequests", sanctionRequests);
|
| 289 |
model.addAttribute("authMap", authMap);
|
281 |
model.addAttribute("authMap", authMap);
|
| 290 |
|
282 |
|
| 291 |
model.addAttribute("sanctionStatus", SanctionStatus.values());
|
283 |
model.addAttribute("sanctionStatus", SanctionStatus.values());
|
| 292 |
return "sanction-request";
|
284 |
return "sanction-request";
|
| 293 |
|
285 |
|
| 294 |
}
|
286 |
}
|
| 295 |
|
287 |
|
| 296 |
@RequestMapping(value = "/sanctionRequest", method = RequestMethod.POST)
|
288 |
@RequestMapping(value = "/sanctionRequest", method = RequestMethod.POST)
|
| 297 |
public String sanctionRequest(HttpServletRequest request, @RequestBody SanctionRequestModel sanctionRequestModel,
|
289 |
public String sanctionRequest(HttpServletRequest request, @RequestBody SanctionRequestModel sanctionRequestModel, Model model) throws Exception {
|
| 298 |
Model model) throws Exception {
|
- |
|
| 299 |
|
290 |
|
| 300 |
LOGGER.info("sanctionRequestModel {} ", sanctionRequestModel);
|
291 |
LOGGER.info("sanctionRequestModel {} ", sanctionRequestModel);
|
| 301 |
Map<Integer, SDCreditRequirement> sdCreditRequirementMap = sdCreditRequirementRepository.selectAll().stream()
|
292 |
Map<Integer, SDCreditRequirement> sdCreditRequirementMap = sdCreditRequirementRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 302 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
- |
|
| 303 |
|
293 |
|
| 304 |
SanctionRequest sanctionRequest = sanctionRequestRepository.selectById(sanctionRequestModel.getId());
|
294 |
SanctionRequest sanctionRequest = sanctionRequestRepository.selectById(sanctionRequestModel.getId());
|
| 305 |
List<Integer> fofoIds = sanctionRequestRepository.selectByDate(LocalDate.now()).stream().map(x -> x.getFofoId())
|
- |
|
| 306 |
.collect(Collectors.toList());
|
- |
|
| 307 |
|
295 |
|
| 308 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(fofoIds);
|
296 |
Map<Integer, String> authMap = new HashMap<Integer, String>();
|
| - |
|
297 |
AuthUser authUser = authRepository.selectById(sanctionRequest.getAuthId());
|
| 309 |
|
298 |
|
| 310 |
LOGGER.info("freeDays {} ", sdCreditRequirementMap.get(sanctionRequest.getFofoId()).getFreeDays());
|
299 |
authMap.put(authUser.getId(), authUser.getFullName());
|
| 311 |
|
300 |
|
| 312 |
if (sanctionRequestModel.getStatus().equals(SanctionStatus.APPROVED)) {
|
- |
|
| 313 |
CustomRetailer customRetailer = customRetailerMap.get(sanctionRequest.getFofoId());
|
- |
|
| 314 |
sanctionRequest.setApprovalTimestamp(LocalDateTime.now());
|
301 |
model.addAttribute("authMap", authMap);
|
| 315 |
BigDecimal availableAmount = sdCreditService.getAvailableAmount(sanctionRequest.getFofoId());
|
302 |
List<Integer> fofoIds = sanctionRequestRepository.selectByDate(LocalDate.now()).stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
| 316 |
|
303 |
|
| 317 |
String title = "Sanction Request Approved";
|
- |
|
| 318 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
- |
|
| 319 |
String message = "Congratulations! Your credit limit is increased for today Rs."
|
- |
|
| 320 |
+ sanctionRequest.getApprovalAmount().setScale(2, RoundingMode.HALF_UP)
|
- |
|
| 321 |
+ ". Your total available limit is Rs." + availableAmount.setScale(2, RoundingMode.HALF_UP) + ".";
|
- |
|
| 322 |
notificationService.sendNotification(sanctionRequest.getFofoId(), title, MessageType.notification, title,
|
304 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(fofoIds);
|
| 323 |
message, url);
|
- |
|
| 324 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository
|
- |
|
| 325 |
.selectById(sanctionRequest.getFofoId());
|
- |
|
| 326 |
|
305 |
|
| 327 |
Address address = addressRepository.selectById(user.getAddressId());
|
306 |
LOGGER.info("freeDays {} ", sdCreditRequirementMap.get(sanctionRequest.getFofoId()).getFreeDays());
|
| 328 |
|
307 |
|
| - |
|
308 |
if (sanctionRequestModel.getStatus().equals(SanctionStatus.APPROVED)) {
|
| - |
|
309 |
CustomRetailer customRetailer = customRetailerMap.get(sanctionRequest.getFofoId());
|
| 329 |
notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
310 |
sanctionRequest.setApprovalTimestamp(LocalDateTime.now());
|
| - |
|
311 |
BigDecimal availableAmount = sdCreditService.getAvailableAmount(sanctionRequest.getFofoId());
|
| 330 |
|
312 |
|
| - |
|
313 |
String title = "Sanction Request Approved";
|
| - |
|
314 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
| 331 |
AuthUser authUser = authRepository.selectById(sanctionRequest.getAuthId());
|
315 |
String message = "Congratulations! Your credit limit is increased for today Rs." + sanctionRequest.getApprovalAmount().setScale(2, RoundingMode.HALF_UP) + ". Your total available limit is Rs." + availableAmount.setScale(2, RoundingMode.HALF_UP) + ".";
|
| - |
|
316 |
notificationService.sendNotification(sanctionRequest.getFofoId(), title, MessageType.notification, title, message, url);
|
| - |
|
317 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(sanctionRequest.getFofoId());
|
| 332 |
|
318 |
|
| 333 |
String empMessage = "Congratulations! Your Partner " + customRetailer.getBusinessName()
|
- |
|
| 334 |
+ " credit limit is increased for today Rs."
|
- |
|
| 335 |
+ sanctionRequest.getApprovalAmount().setScale(2, RoundingMode.HALF_UP)
|
- |
|
| 336 |
+ " and total available limit is Rs." + availableAmount.setScale(2, RoundingMode.HALF_UP) + ".";
|
- |
|
| 337 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
- |
|
| 338 |
sendNotificationModel.setCampaignName("Sanction Request");
|
- |
|
| 339 |
sendNotificationModel.setTitle("title");
|
- |
|
| 340 |
sendNotificationModel.setMessage(empMessage);
|
- |
|
| 341 |
sendNotificationModel.setType("url");
|
- |
|
| 342 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/credit");
|
- |
|
| 343 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
- |
|
| 344 |
sendNotificationModel.setMessageType(MessageType.notification);
|
- |
|
| 345 |
sendNotificationModel
|
- |
|
| 346 |
.setUserIds(Arrays.asList(userRepository.selectByEmailId(authUser.getEmailId()).getId()));
|
319 |
Address address = addressRepository.selectById(user.getAddressId());
|
| 347 |
System.out.println(sendNotificationModel);
|
- |
|
| 348 |
notificationService.sendNotification(sendNotificationModel);
|
- |
|
| 349 |
|
320 |
|
| 350 |
notificationService.sendWhatsappMessage(empMessage, title, authUser.getMobileNumber());
|
321 |
notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
| 351 |
|
322 |
|
| 352 |
}
|
323 |
String empMessage = "Congratulations! Your Partner " + customRetailer.getBusinessName() + " credit limit is increased for today Rs." + sanctionRequest.getApprovalAmount().setScale(2, RoundingMode.HALF_UP) + " and total available limit is Rs." + availableAmount.setScale(2, RoundingMode.HALF_UP) + ".";
|
| - |
|
324 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| - |
|
325 |
sendNotificationModel.setCampaignName("Sanction Request");
|
| - |
|
326 |
sendNotificationModel.setTitle("title");
|
| - |
|
327 |
sendNotificationModel.setMessage(empMessage);
|
| - |
|
328 |
sendNotificationModel.setType("url");
|
| - |
|
329 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/credit");
|
| - |
|
330 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(2));
|
| - |
|
331 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| - |
|
332 |
sendNotificationModel.setUserIds(Arrays.asList(userRepository.selectByEmailId(authUser.getEmailId()).getId()));
|
| - |
|
333 |
System.out.println(sendNotificationModel);
|
| - |
|
334 |
notificationService.sendNotification(sendNotificationModel);
|
| 353 |
|
335 |
|
| 354 |
if (sdCreditRequirementMap.get(sanctionRequest.getFofoId()).getFreeDays() >= sanctionRequestModel
|
- |
|
| 355 |
.getFreeDays()) {
|
- |
|
| 356 |
sanctionRequest.setFreeDays(sanctionRequestModel.getFreeDays());
|
336 |
notificationService.sendWhatsappMessage(empMessage, title, authUser.getMobileNumber());
|
| 357 |
} else {
|
- |
|
| 358 |
throw new ProfitMandiBusinessException("Free Days", "Free Days", "Free Days is not more than "
|
- |
|
| 359 |
+ sdCreditRequirementMap.get(sanctionRequest.getFofoId()).getFreeDays() + " days ");
|
- |
|
| 360 |
}
|
- |
|
| 361 |
|
337 |
|
| 362 |
sanctionRequest.setApprovalAmount(sanctionRequestModel.getApprovalAmount());
|
- |
|
| 363 |
sanctionRequest.setStatus(sanctionRequestModel.getStatus());
|
- |
|
| 364 |
sanctionRequest.setStockHold(sanctionRequestModel.isStockHold());
|
- |
|
| - |
|
338 |
}
|
| 365 |
|
339 |
|
| 366 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = partnerDailyInvestmentRepository
|
340 |
if (sdCreditRequirementMap.get(sanctionRequest.getFofoId()).getFreeDays() >= sanctionRequestModel.getFreeDays()) {
|
| 367 |
.selectAll(fofoIds, LocalDate.now().minusDays(1)).stream()
|
341 |
sanctionRequest.setFreeDays(sanctionRequestModel.getFreeDays());
|
| - |
|
342 |
} else {
|
| 368 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
343 |
throw new ProfitMandiBusinessException("Free Days", "Free Days", "Free Days is not more than " + sdCreditRequirementMap.get(sanctionRequest.getFofoId()).getFreeDays() + " days ");
|
| - |
|
344 |
}
|
| 369 |
|
345 |
|
| 370 |
Map<Integer, UserWallet> userWalletMap = userWalletRepository.selectByRetailerIds(new HashSet<>(fofoIds))
|
346 |
sanctionRequest.setApprovalAmount(sanctionRequestModel.getApprovalAmount());
|
| - |
|
347 |
sanctionRequest.setStatus(sanctionRequestModel.getStatus());
|
| 371 |
.stream().collect(Collectors.toMap(x -> x.getUserId(), x -> x));
|
348 |
sanctionRequest.setStockHold(sanctionRequestModel.isStockHold());
|
| 372 |
|
349 |
|
| 373 |
sanctionRequest = sanctionRequestRepository.selectById(sanctionRequestModel.getId());
|
350 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = partnerDailyInvestmentRepository.selectAll(fofoIds, LocalDate.now().minusDays(1)).stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 374 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
- |
|
| 375 |
model.addAttribute("sanctionRequest", sanctionRequest);
|
- |
|
| 376 |
model.addAttribute("partnerDailyInvestmentMap", partnerDailyInvestmentMap);
|
- |
|
| 377 |
model.addAttribute("sdCreditRequirementMap", sdCreditRequirementMap);
|
- |
|
| 378 |
model.addAttribute("userWalletMap", userWalletMap);
|
- |
|
| 379 |
|
351 |
|
| 380 |
model.addAttribute("sanctionStatus", SanctionStatus.values());
|
352 |
Map<Integer, UserWallet> userWalletMap = userWalletRepository.selectByRetailerIds(new HashSet<>(fofoIds)).stream().collect(Collectors.toMap(x -> x.getUserId(), x -> x));
|
| 381 |
|
353 |
|
| - |
|
354 |
sanctionRequest = sanctionRequestRepository.selectById(sanctionRequestModel.getId());
|
| - |
|
355 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
| 382 |
return "sanction-request-row";
|
356 |
model.addAttribute("sanctionRequest", sanctionRequest);
|
| - |
|
357 |
model.addAttribute("partnerDailyInvestmentMap", partnerDailyInvestmentMap);
|
| - |
|
358 |
model.addAttribute("sdCreditRequirementMap", sdCreditRequirementMap);
|
| - |
|
359 |
model.addAttribute("userWalletMap", userWalletMap);
|
| 383 |
|
360 |
|
| 384 |
}
|
- |
|
| - |
|
361 |
model.addAttribute("sanctionStatus", SanctionStatus.values());
|
| 385 |
|
362 |
|
| 386 |
List<String> emails = Arrays.asList("kamini.sharma@smartdukaan.com", "neeraj.gupta@smartdukaan.com",
|
- |
|
| 387 |
"amit.gupta@smartdukaan.com");
|
363 |
return "sanction-request-row";
|
| 388 |
|
364 |
|
| 389 |
@RequestMapping(value = "/getLoans", method = RequestMethod.GET)
|
- |
|
| 390 |
public String getLoans(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
- |
|
| - |
|
365 |
}
|
| 391 |
|
366 |
|
| 392 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
367 |
List<String> emails = Arrays.asList("kamini.sharma@smartdukaan.com", "neeraj.gupta@smartdukaan.com", "amit.gupta@smartdukaan.com");
|
| 393 |
String email = loginDetails.getEmailId();
|
- |
|
| 394 |
|
368 |
|
| 395 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
369 |
@RequestMapping(value = "/getLoans", method = RequestMethod.GET)
|
| 396 |
Set<Integer> fofoIds = csService1.getAuthFofoIds(email, false);
|
370 |
public String getLoans(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| 397 |
|
371 |
|
| 398 |
LOGGER.info("fofoIds" + fofoIds);
|
372 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 399 |
if (fofoIds == null) {
|
373 |
String email = loginDetails.getEmailId();
|
| 400 |
throw new ProfitMandiBusinessException("you are not authorized", "", "you are not authorized" + " " + "");
|
- |
|
| 401 |
}
|
- |
|
| 402 |
|
374 |
|
| 403 |
List<Loan> loans = loanRepository.selectAllLoans(new ArrayList<>(fofoIds));
|
375 |
AuthUser authUser = authRepository.selectByEmailOrMobile(email);
|
| - |
|
376 |
Set<Integer> fofoIds = csService1.getAuthFofoIds(email, false);
|
| 404 |
|
377 |
|
| - |
|
378 |
LOGGER.info("fofoIds" + fofoIds);
|
| - |
|
379 |
if (fofoIds == null) {
|
| 405 |
List<Integer> loanFofoIds = loans.stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
380 |
throw new ProfitMandiBusinessException("you are not authorized", "", "you are not authorized" + " " + "");
|
| - |
|
381 |
}
|
| 406 |
|
382 |
|
| 407 |
List<SDCreditRequirement> sdCreditRequirements = sdCreditRequirementRepository
|
- |
|
| 408 |
.selectByFofoIds(new ArrayList<>(loanFofoIds));
|
383 |
List<Loan> loans = loanRepository.selectAllLoans(new ArrayList<>(fofoIds));
|
| 409 |
|
384 |
|
| 410 |
Map<Integer, Long> loanCountMap = loans.stream()
|
- |
|
| 411 |
.collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.counting()));
|
385 |
List<Integer> loanFofoIds = loans.stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
| 412 |
|
386 |
|
| 413 |
Map<Integer, UserWallet> userWalletMap = userWalletRepository.selectByRetailerIds(fofoIds).stream()
|
387 |
List<SDCreditRequirement> sdCreditRequirements = sdCreditRequirementRepository.selectByFofoIds(new ArrayList<>(loanFofoIds));
|
| 414 |
.collect(Collectors.toMap(x -> x.getUserId(), x -> x));
|
- |
|
| 415 |
Map<Integer, CurrentPartnerDailyInvestment> currentPartnerDailyInvestmentMap = currentPartnerDailyInvestmentRepository
|
- |
|
| 416 |
.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
- |
|
| 417 |
|
388 |
|
| 418 |
model.addAttribute("userWalletMap", userWalletMap);
|
389 |
Map<Integer, Long> loanCountMap = loans.stream().collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.counting()));
|
| 419 |
|
390 |
|
| - |
|
391 |
Map<Integer, UserWallet> userWalletMap = userWalletRepository.selectByRetailerIds(fofoIds).stream().collect(Collectors.toMap(x -> x.getUserId(), x -> x));
|
| 420 |
model.addAttribute("currentPartnerDailyInvestmentMap", currentPartnerDailyInvestmentMap);
|
392 |
Map<Integer, CurrentPartnerDailyInvestment> currentPartnerDailyInvestmentMap = currentPartnerDailyInvestmentRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 421 |
|
393 |
|
| 422 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(new ArrayList<>(fofoIds));
|
- |
|
| 423 |
model.addAttribute("sdCreditRequirements", sdCreditRequirements);
|
- |
|
| 424 |
model.addAttribute("loanCountMap", loanCountMap);
|
- |
|
| 425 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
394 |
model.addAttribute("userWalletMap", userWalletMap);
|
| 426 |
return "loan-summary";
|
- |
|
| 427 |
|
395 |
|
| 428 |
}
|
- |
|
| - |
|
396 |
model.addAttribute("currentPartnerDailyInvestmentMap", currentPartnerDailyInvestmentMap);
|
| 429 |
|
397 |
|
| - |
|
398 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(new ArrayList<>(fofoIds));
|
| 430 |
@RequestMapping(value = "/getLoanSummary", method = RequestMethod.GET)
|
399 |
model.addAttribute("sdCreditRequirements", sdCreditRequirements);
|
| - |
|
400 |
model.addAttribute("loanCountMap", loanCountMap);
|
| 431 |
public String getLoanSummary(HttpServletRequest request, @RequestParam int fofoId, Model model)
|
401 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
| 432 |
throws ProfitMandiBusinessException {
|
402 |
return "loan-summary";
|
| 433 |
|
403 |
|
| 434 |
SDCreditResponseOut sdCreditResponseOut = sdCreditService.sdDirectService(fofoId);
|
- |
|
| 435 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
- |
|
| - |
|
404 |
}
|
| 436 |
|
405 |
|
| 437 |
model.addAttribute("customRetailer", customRetailer);
|
406 |
@RequestMapping(value = "/getLoanSummary", method = RequestMethod.GET)
|
| 438 |
model.addAttribute("loanSummary", sdCreditResponseOut.getLoans());
|
407 |
public String getLoanSummary(HttpServletRequest request, @RequestParam int fofoId, Model model) throws ProfitMandiBusinessException {
|
| 439 |
|
408 |
|
| - |
|
409 |
SDCreditResponseOut sdCreditResponseOut = sdCreditService.sdDirectService(fofoId);
|
| 440 |
return "loan-summary-detail";
|
410 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
| 441 |
|
411 |
|
| 442 |
}
|
- |
|
| - |
|
412 |
model.addAttribute("customRetailer", customRetailer);
|
| - |
|
413 |
model.addAttribute("loanSummary", sdCreditResponseOut.getLoans());
|
| 443 |
|
414 |
|
| 444 |
@RequestMapping(value = "/getSanctionHoldOrder", method = RequestMethod.GET)
|
415 |
return "loan-summary-detail";
|
| 445 |
public String getSanctionHoldOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
- |
|
| 446 |
|
416 |
|
| 447 |
List<Order> allOrders = orderRepository.selectHoldOrder();
|
- |
|
| - |
|
417 |
}
|
| 448 |
|
418 |
|
| 449 |
LOGGER.info("allOrders {}", allOrders);
|
419 |
@RequestMapping(value = "/getSanctionHoldOrder", method = RequestMethod.GET)
|
| - |
|
420 |
public String getSanctionHoldOrder(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| 450 |
|
421 |
|
| 451 |
if (!allOrders.isEmpty()) {
|
- |
|
| 452 |
Map<Integer, Double> transactionAmountMap = allOrders.stream().collect(
|
422 |
List<Order> allOrders = orderRepository.selectHoldOrder();
|
| 453 |
Collectors.groupingBy(Order::getTransactionId, Collectors.summingDouble(x -> x.getTotalAmount())));
|
- |
|
| 454 |
|
423 |
|
| 455 |
Map<Integer, List<Order>> transactionOrdersMap = allOrders.stream()
|
424 |
LOGGER.info("allOrders {}", allOrders);
|
| 456 |
.collect(Collectors.groupingBy(Order::getTransactionId, Collectors.toList()));
|
- |
|
| 457 |
|
425 |
|
| - |
|
426 |
if (!allOrders.isEmpty()) {
|
| 458 |
List<SanctionRequest> sanctionRequests = sanctionRequestRepository
|
427 |
Map<Integer, Double> transactionAmountMap = allOrders.stream().collect(
|
| 459 |
.selectByTransactionId(new ArrayList<>(transactionAmountMap.keySet()));
|
428 |
Collectors.groupingBy(Order::getTransactionId, Collectors.summingDouble(x -> x.getTotalAmount())));
|
| 460 |
|
429 |
|
| 461 |
model.addAttribute("transactionAmountMap", transactionAmountMap);
|
430 |
Map<Integer, List<Order>> transactionOrdersMap = allOrders.stream().collect(Collectors.groupingBy(Order::getTransactionId, Collectors.toList()));
|
| 462 |
|
431 |
|
| 463 |
model.addAttribute("transactionOrdersMap", transactionOrdersMap);
|
432 |
List<SanctionRequest> sanctionRequests = sanctionRequestRepository.selectByTransactionId(new ArrayList<>(transactionAmountMap.keySet()));
|
| 464 |
|
433 |
|
| 465 |
model.addAttribute("sanctionRequests", sanctionRequests);
|
434 |
model.addAttribute("transactionAmountMap", transactionAmountMap);
|
| 466 |
|
435 |
|
| 467 |
Map<Integer, Double> transactionCreditMap = new HashMap<>();
|
- |
|
| 468 |
for (Entry<Integer, List<Order>> transactionOrderEntry : transactionOrdersMap.entrySet()) {
|
436 |
model.addAttribute("transactionOrdersMap", transactionOrdersMap);
|
| 469 |
|
437 |
|
| 470 |
List<Order> orders = transactionOrderEntry.getValue();
|
438 |
model.addAttribute("sanctionRequests", sanctionRequests);
|
| 471 |
|
439 |
|
| 472 |
LocalDateTime createDate = orders.get(0).getCreateTimestamp();
|
440 |
Map<Integer, Double> transactionCreditMap = new HashMap<>();
|
| - |
|
441 |
for (Entry<Integer, List<Order>> transactionOrderEntry : transactionOrdersMap.entrySet()) {
|
| 473 |
|
442 |
|
| 474 |
int fofoId = orders.get(0).getRetailerId();
|
443 |
List<Order> orders = transactionOrderEntry.getValue();
|
| 475 |
|
444 |
|
| 476 |
double loanSettleAmount = loanStatementRepository.selectByDateAndFofoId(createDate, fofoId).stream()
|
- |
|
| 477 |
.filter(x -> x.getAmount().doubleValue() > 0)
|
- |
|
| 478 |
.collect(Collectors.summingDouble(x -> x.getAmount().doubleValue()));
|
445 |
LocalDateTime createDate = orders.get(0).getCreateTimestamp();
|
| 479 |
|
446 |
|
| 480 |
transactionCreditMap.put(transactionOrderEntry.getKey(), loanSettleAmount);
|
447 |
int fofoId = orders.get(0).getRetailerId();
|
| 481 |
|
448 |
|
| 482 |
}
|
- |
|
| - |
|
449 |
double loanSettleAmount = loanStatementRepository.selectByDateAndFofoId(createDate, fofoId).stream().filter(x -> x.getAmount().doubleValue() > 0).collect(Collectors.summingDouble(x -> x.getAmount().doubleValue()));
|
| 483 |
|
450 |
|
| 484 |
model.addAttribute("transactionCreditMap", transactionCreditMap);
|
451 |
transactionCreditMap.put(transactionOrderEntry.getKey(), loanSettleAmount);
|
| 485 |
|
452 |
|
| 486 |
}
|
453 |
}
|
| 487 |
|
454 |
|
| 488 |
return "sanction-order-hold";
|
455 |
model.addAttribute("transactionCreditMap", transactionCreditMap);
|
| 489 |
|
456 |
|
| 490 |
}
|
457 |
}
|
| 491 |
|
458 |
|
| 492 |
@RequestMapping(value = "/unholdOrder", method = RequestMethod.POST)
|
- |
|
| 493 |
public String unholdOrder(HttpServletRequest request, @RequestParam int transactionId, Model model)
|
- |
|
| 494 |
throws Exception {
|
459 |
return "sanction-order-hold";
|
| 495 |
|
460 |
|
| 496 |
List<Order> orders = orderRepository.selectAllByTransactionId(transactionId);
|
- |
|
| - |
|
461 |
}
|
| 497 |
|
462 |
|
| 498 |
LOGGER.info("orders" + orders);
|
463 |
@RequestMapping(value = "/unholdOrder", method = RequestMethod.POST)
|
| - |
|
464 |
public String unholdOrder(HttpServletRequest request, @RequestParam int transactionId, Model model) throws Exception {
|
| 499 |
|
465 |
|
| 500 |
if (!orders.isEmpty()) {
|
- |
|
| 501 |
orders.forEach(x -> x.setShipmentHold(false));
|
466 |
List<Order> orders = orderRepository.selectAllByTransactionId(transactionId);
|
| 502 |
}
|
- |
|
| 503 |
|
467 |
|
| 504 |
double totalAmount = orders.stream().collect(Collectors.summingDouble(x -> x.getTotalAmount()));
|
468 |
LOGGER.info("orders" + orders);
|
| 505 |
|
469 |
|
| - |
|
470 |
if (!orders.isEmpty()) {
|
| - |
|
471 |
orders.forEach(x -> x.setShipmentHold(false));
|
| 506 |
try {
|
472 |
}
|
| 507 |
|
473 |
|
| 508 |
List<String> authUserEmail = csService.getAuthUserIdByPartnerId(orders.get(0).getRetailerId()).stream()
|
- |
|
| 509 |
.map(x -> x.getEmailId()).collect(Collectors.toList());
|
474 |
double totalAmount = orders.stream().collect(Collectors.summingDouble(x -> x.getTotalAmount()));
|
| 510 |
|
475 |
|
| 511 |
authUserEmail.add("vinay.p@smartdukaan.com");
|
476 |
try {
|
| 512 |
authUserEmail.add("shivam.gupta@smartdukaan.com");
|
- |
|
| 513 |
|
477 |
|
| 514 |
String[] emailTo = authUserEmail.toArray(new String[authUserEmail.size()]);
|
478 |
List<String> authUserEmail = csService.getAuthUserIdByPartnerId(orders.get(0).getRetailerId()).stream().map(x -> x.getEmailId()).collect(Collectors.toList());
|
| 515 |
|
479 |
|
| - |
|
480 |
authUserEmail.add("vinay.p@smartdukaan.com");
|
| 516 |
String[] ccTo = { "tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com" };
|
481 |
authUserEmail.add("shivam.gupta@smartdukaan.com");
|
| 517 |
|
482 |
|
| 518 |
String subject = "Dispatched " + (orders.get(0).getRetailerName());
|
483 |
String[] emailTo = authUserEmail.toArray(new String[authUserEmail.size()]);
|
| 519 |
String message = String.format("Dear Team, \n" + "Kindly note the meterial for the "
|
- |
|
| 520 |
+ orders.get(0).getRetailerName() + "of Rs." + totalAmount + " is dispatched.");
|
- |
|
| 521 |
|
484 |
|
| 522 |
LOGGER.info("message" + message);
|
485 |
String[] ccTo = {"tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com"};
|
| 523 |
|
486 |
|
| 524 |
Utils.sendMailWithAttachments(mailSender, emailTo, ccTo, subject, message);
|
487 |
String subject = "Dispatched " + (orders.get(0).getRetailerName());
|
| 525 |
} catch (Exception e) {
|
488 |
String message = String.format("Dear Team, \n" + "Kindly note the meterial for the " + orders.get(0).getRetailerName() + "of Rs." + totalAmount + " is dispatched.");
|
| 526 |
|
489 |
|
| 527 |
e.printStackTrace();
|
490 |
LOGGER.info("message" + message);
|
| 528 |
|
491 |
|
| - |
|
492 |
Utils.sendMailWithAttachments(mailSender, emailTo, ccTo, subject, message);
|
| 529 |
}
|
493 |
} catch (Exception e) {
|
| 530 |
|
494 |
|
| 531 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
495 |
e.printStackTrace();
|
| 532 |
|
496 |
|
| 533 |
return "response";
|
497 |
}
|
| 534 |
|
498 |
|
| - |
|
499 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| - |
|
500 |
|
| - |
|
501 |
return "response";
|
| 535 |
}
|
502 |
|
| - |
|
503 |
}
|
| 536 |
|
504 |
|
| 537 |
}
|
505 |
}
|
| 538 |
|
506 |
|