Subversion Repositories SmartDukaan

Rev

Rev 34572 | Rev 34575 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34572 Rev 34573
Line 164... Line 164...
164
                }
164
                }
165
                totalPayableAmount += cartItem.getSellingPrice() * cartItem.getQuantity();
165
                totalPayableAmount += cartItem.getSellingPrice() * cartItem.getQuantity();
166
                cartItems.add(cartItem);
166
                cartItems.add(cartItem);
167
            }
167
            }
168
            Bid bid = null;
168
            Bid bid = null;
-
 
169
            ProfitMandiConstants.BID_ENUM finalBidStatus = ProfitMandiConstants.BID_ENUM.CLOSED;
169
            if (type.equals(ProfitMandiConstants.PO_TYPE.AUTO)) {
170
            if (type.equals(ProfitMandiConstants.PO_TYPE.AUTO)) {
170
                bid = bidRepository.selectById(fofoBulkOrderModels.get(0).getRowIndex());
171
                bid = bidRepository.selectById(fofoBulkOrderModels.get(0).getRowIndex());
171
            }
172
            }
172
            LOGGER.info("totalAmount of item " + totalPayableAmount);
173
            LOGGER.info("totalAmount of item " + totalPayableAmount);
173
            double walletAmount = walletService.getWalletAmount(fofoId);
174
            double walletAmount = walletService.getWalletAmount(fofoId);
Line 180... Line 181...
180
                if (type.equals(ProfitMandiConstants.PO_TYPE.MANUAL)) {
181
                if (type.equals(ProfitMandiConstants.PO_TYPE.MANUAL)) {
181
                    throw new ProfitMandiBusinessException("Skipping order due to insufficient balance for id - ", fofoId, " ,Check wallet Balance once");
182
                    throw new ProfitMandiBusinessException("Skipping order due to insufficient balance for id - ", fofoId, " ,Check wallet Balance once");
182
                } else {
183
                } else {
183
                    if (scheduleType.equals(ProfitMandiConstants.BID_CRON_ENUM.TODAY)) {
184
                    if (scheduleType.equals(ProfitMandiConstants.BID_CRON_ENUM.TODAY)) {
184
                        bidService.sendMailToRBM(netAmountInHand, totalPayableAmount, fofoId);
185
                        bidService.sendMailToRBM(netAmountInHand, totalPayableAmount, fofoId);
185
                        bid.setStatus(ProfitMandiConstants.BID_ENUM.PROCESSING);
186
                        finalBidStatus = ProfitMandiConstants.BID_ENUM.PROCESSING;
186
                        LOGGER.info("Skipping order due to insufficient balance for id - "+ fofoId+ " Sending mail to RBM");
187
                        LOGGER.info("Skipping order due to insufficient balance for id - "+ fofoId+ " Sending mail to RBM");
187
                        //throw new ProfitMandiBusinessException("Skipping order due to insufficient balance for id - ", fofoId, " ,Sending mail to RBM");
188
                        //throw new ProfitMandiBusinessException("Skipping order due to insufficient balance for id - ", fofoId, " ,Sending mail to RBM");
188
                    } else {
189
                    } else {
189
                        bidService.cancelYesterdayProcessBid(bid);
190
                        bidService.cancelYesterdayProcessBid(bid);
190
                        LOGGER.info("Skipping order due to insufficient balance for id - "+ fofoId+ " Cancelling the BID");
191
                        LOGGER.info("Skipping order due to insufficient balance for id - "+ fofoId+ " Cancelling the BID");
-
 
192
                        finalBidStatus = ProfitMandiConstants.BID_ENUM.CANCELLED;
191
                        //throw new ProfitMandiBusinessException("Skipping order due to insufficient balance for id - ", fofoId, " ,Cancelling the BID");
193
                        //throw new ProfitMandiBusinessException("Skipping order due to insufficient balance for id - ", fofoId, " ,Cancelling the BID");
192
                    }
194
                    }
193
                }
195
                }
194
            }
196
            }
195
            UserCart userCart = cartService.setCartItems(fofoId, cartItems);
197
            UserCart userCart = cartService.setCartItems(fofoId, cartItems);
Line 203... Line 205...
203
                    loanId = loan.getId();
205
                    loanId = loan.getId();
204
                }
206
                }
205
            } catch (Exception exception){
207
            } catch (Exception exception){
206
                if (type.equals(ProfitMandiConstants.PO_TYPE.AUTO)) {
208
                if (type.equals(ProfitMandiConstants.PO_TYPE.AUTO)) {
207
                    bidService.sendMailToRBM(netAmountInHand, totalPayableAmount, fofoId);
209
                    bidService.sendMailToRBM(netAmountInHand, totalPayableAmount, fofoId);
208
                    bid.setStatus(ProfitMandiConstants.BID_ENUM.PROCESSING);
210
                    finalBidStatus = ProfitMandiConstants.BID_ENUM.PROCESSING;
209
                    LOGGER.info("Skipping order due to insufficient balance for id - "+ fofoId+ " Cancelling the BID");
211
                    LOGGER.info("Skipping order due to insufficient balance for id - "+ fofoId+ " Cancelling the BID");
210
                    //throw new ProfitMandiBusinessException("Skipping order unable to create load for id - ", fofoId, " ,Sending mail to RBM");
212
                    //throw new ProfitMandiBusinessException("Skipping order unable to create load for id - ", fofoId, " ,Sending mail to RBM");
211
                }
213
                }
212
            }
214
            }
213
 
215
 
-
 
216
            if (finalBidStatus.equals(ProfitMandiConstants.BID_ENUM.CLOSED)) {
-
 
217
 
214
            int transactionId = transactionService.createTransactionInternally(userCart, totalPayableAmount, 0);
218
                int transactionId = transactionService.createTransactionInternally(userCart, totalPayableAmount, 0);
215
            //Set here created by
219
                //Set here created by
216
            Transaction transaction = transactionRepository.selectById(transactionId);
220
                Transaction transaction = transactionRepository.selectById(transactionId);
217
            transaction.setCreatedBy(creatorId);
221
                transaction.setCreatedBy(creatorId);
218
            LOGGER.info("transaction  created by {}", transaction.getCreatedBy());
222
                LOGGER.info("transaction  created by {}", transaction.getCreatedBy());
219
            commonPaymentService.payThroughWallet(transactionId);
223
                commonPaymentService.payThroughWallet(transactionId);
220
            if (type.equals(ProfitMandiConstants.PO_TYPE.AUTO)) {
224
                if (type.equals(ProfitMandiConstants.PO_TYPE.AUTO)) {
221
                bid.setStatus(ProfitMandiConstants.BID_ENUM.CLOSED);
225
                    bid.setStatus(finalBidStatus);
222
            }
226
                }
223
            if (approvalRequired) {
227
                if (approvalRequired) {
224
                this.createApproval(transactionId);
228
                    this.createApproval(transactionId);
225
                if (loanId > 0) {
229
                    if (loanId > 0) {
226
                    LoanTransaction loanTransaction = new LoanTransaction();
230
                        LoanTransaction loanTransaction = new LoanTransaction();
227
                    loanTransaction.setLoanId(loanId);
231
                        loanTransaction.setLoanId(loanId);
228
                    loanTransaction.setTransactionId(transactionId);
232
                        loanTransaction.setTransactionId(transactionId);
229
                    loanTransactionRepository.persist(loanTransaction);
233
                        loanTransactionRepository.persist(loanTransaction);
-
 
234
                    }
-
 
235
                } else {
-
 
236
                    transactionService.processTransaction(transactionId, loanId);
230
                }
237
                }
231
            } else {
-
 
232
                transactionService.processTransaction(transactionId,loanId);
-
 
233
            }
238
            }
234
 
239
 
235
        }
240
        }
236
    }
241
    }
237
 
242
 
Line 292... Line 297...
292
            AuthUser authUser = authRepository.selectById(transaction.getCreatedBy());
297
            AuthUser authUser = authRepository.selectById(transaction.getCreatedBy());
293
            TransactionApprovalModel transactionApprovalModel = new TransactionApprovalModel();
298
            TransactionApprovalModel transactionApprovalModel = new TransactionApprovalModel();
294
            String retailerName = " ";
299
            String retailerName = " ";
295
            retailerName = orderList.get(0).getRetailerName();
300
            retailerName = orderList.get(0).getRetailerName();
296
            transactionApprovalModel.setRetailerName(retailerName);
301
            transactionApprovalModel.setRetailerName(retailerName);
-
 
302
            if (authUser == null) {
-
 
303
                transactionApprovalModel.setCreatedBy(retailerName);
-
 
304
            } else {
297
            transactionApprovalModel.setCreatedBy(authUser.getFullName());
305
                transactionApprovalModel.setCreatedBy(authUser.getFullName());
-
 
306
            }
298
            transactionApprovalModel.setCreatedOn(transaction.getCreateTimestamp());
307
            transactionApprovalModel.setCreatedOn(transaction.getCreateTimestamp());
299
            transactionApprovalModel.setTransactionId(transactionApproval.getId());
308
            transactionApprovalModel.setTransactionId(transactionApproval.getId());
300
            transactionApprovalModel.setLineItemModels(lineItemModelList);
309
            transactionApprovalModel.setLineItemModels(lineItemModelList);
301
            approvalModelList.add(transactionApprovalModel);
310
            approvalModelList.add(transactionApprovalModel);
302
 
311