| Line 35... |
Line 35... |
| 35 |
import org.apache.http.entity.StringEntity;
|
35 |
import org.apache.http.entity.StringEntity;
|
| 36 |
import org.apache.http.impl.client.CloseableHttpClient;
|
36 |
import org.apache.http.impl.client.CloseableHttpClient;
|
| 37 |
import org.apache.http.impl.client.HttpClients;
|
37 |
import org.apache.http.impl.client.HttpClients;
|
| 38 |
import org.apache.logging.log4j.LogManager;
|
38 |
import org.apache.logging.log4j.LogManager;
|
| 39 |
import org.apache.logging.log4j.Logger;
|
39 |
import org.apache.logging.log4j.Logger;
|
| - |
|
40 |
import org.json.JSONArray;
|
| 40 |
import org.json.JSONObject;
|
41 |
import org.json.JSONObject;
|
| 41 |
import org.springframework.beans.factory.annotation.Autowired;
|
42 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 42 |
import org.springframework.beans.factory.annotation.Qualifier;
|
43 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 43 |
import org.springframework.beans.factory.annotation.Value;
|
44 |
import org.springframework.beans.factory.annotation.Value;
|
| 44 |
import org.springframework.core.io.ByteArrayResource;
|
45 |
import org.springframework.core.io.ByteArrayResource;
|
| Line 149... |
Line 150... |
| 149 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
150 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 150 |
import com.spice.profitmandi.dao.repository.dtr.UserCampaignRepository;
|
151 |
import com.spice.profitmandi.dao.repository.dtr.UserCampaignRepository;
|
| 151 |
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
|
152 |
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
|
| 152 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
153 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 153 |
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
|
154 |
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
|
| - |
|
155 |
import com.spice.profitmandi.dao.repository.fofo.CustomerRepository;
|
| 154 |
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemRepository;
|
156 |
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemRepository;
|
| 155 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
157 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 156 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
158 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| 157 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
159 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
| 158 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
160 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| 159 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
161 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
| 160 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
|
162 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
|
| 161 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
163 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| 162 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderItemRepository;
|
164 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderItemRepository;
|
| 163 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderRepository;
|
165 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderRepository;
|
| - |
|
166 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderService;
|
| 164 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
167 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseRepository;
|
| 165 |
import com.spice.profitmandi.dao.repository.fofo.RazorPayRepository;
|
168 |
import com.spice.profitmandi.dao.repository.fofo.RazorPayRepository;
|
| 166 |
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
|
169 |
import com.spice.profitmandi.dao.repository.fofo.ScanRecordRepository;
|
| 167 |
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
|
170 |
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
|
| 168 |
import com.spice.profitmandi.dao.repository.transaction.HdfcPaymentRepository;
|
171 |
import com.spice.profitmandi.dao.repository.transaction.HdfcPaymentRepository;
|
| Line 171... |
Line 174... |
| 171 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
174 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
| 172 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
175 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;
|
| 173 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
176 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 174 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
177 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 175 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
178 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| - |
|
179 |
import com.spice.profitmandi.service.EmailService;
|
| 176 |
import com.spice.profitmandi.service.NotificationService;
|
180 |
import com.spice.profitmandi.service.NotificationService;
|
| 177 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
181 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 178 |
import com.spice.profitmandi.service.integrations.RazorpayPaymentService;
|
182 |
import com.spice.profitmandi.service.integrations.RazorpayPaymentService;
|
| 179 |
import com.spice.profitmandi.service.integrations.toffee.ToffeeService;
|
183 |
import com.spice.profitmandi.service.integrations.toffee.ToffeeService;
|
| 180 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
184 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| Line 469... |
Line 473... |
| 469 |
|
473 |
|
| 470 |
@Autowired
|
474 |
@Autowired
|
| 471 |
private RazorpayPaymentService razorPaymentService;
|
475 |
private RazorpayPaymentService razorPaymentService;
|
| 472 |
|
476 |
|
| 473 |
@Autowired
|
477 |
@Autowired
|
| - |
|
478 |
private EmailService emailService;
|
| - |
|
479 |
|
| - |
|
480 |
@Autowired
|
| 474 |
private RazorPayRepository razorPayRepository;
|
481 |
private RazorPayRepository razorPayRepository;
|
| 475 |
|
482 |
|
| - |
|
483 |
@Autowired
|
| - |
|
484 |
private PendingOrderService pendingOrderService;
|
| - |
|
485 |
|
| - |
|
486 |
@Autowired
|
| - |
|
487 |
private CustomerRepository customerRepository;
|
| - |
|
488 |
|
| 476 |
private static final Logger LOGGER = LogManager.getLogger(ScheduledTasks.class);
|
489 |
private static final Logger LOGGER = LogManager.getLogger(ScheduledTasks.class);
|
| 477 |
|
490 |
|
| 478 |
private String FCM_URL = "https://fcm.googleapis.com/fcm/send";
|
491 |
private String FCM_URL = "https://fcm.googleapis.com/fcm/send";
|
| 479 |
private String FCM_API_KEY = "AAAASAjNcn4:APA91bG6fWRIgYJI0L9gCjP5ynaXz2hJHYKtD9dfH7Depdv31Nd9APJwhx-OPkAJ1WSz4BGNYG8lHThLFSjDGFxIwUZv241YcAJEGDLgt86mxq9FXJe-yBRu-S0_ZwHqmX-QaVKl5F_A";
|
492 |
private String FCM_API_KEY = "AAAASAjNcn4:APA91bG6fWRIgYJI0L9gCjP5ynaXz2hJHYKtD9dfH7Depdv31Nd9APJwhx-OPkAJ1WSz4BGNYG8lHThLFSjDGFxIwUZv241YcAJEGDLgt86mxq9FXJe-yBRu-S0_ZwHqmX-QaVKl5F_A";
|
| 480 |
|
493 |
|
| Line 1593... |
Line 1606... |
| 1593 |
// this.sendMailOfHtmlFomat("amit.gupta@smartukaan.com", saleReport, cc,
|
1606 |
// this.sendMailOfHtmlFomat("amit.gupta@smartukaan.com", saleReport, cc,
|
| 1594 |
// subject);
|
1607 |
// subject);
|
| 1595 |
this.sendMailOfHtmlFormat("amit.gupta@smartdukaan.com", statewiseSaleReport, cc, "Statewise" + subject);
|
1608 |
this.sendMailOfHtmlFormat("amit.gupta@smartdukaan.com", statewiseSaleReport, cc, "Statewise" + subject);
|
| 1596 |
}
|
1609 |
}
|
| 1597 |
|
1610 |
|
| 1598 |
public void checkRazorPayPaymentStatus() throws IOException, RazorpayException {
|
1611 |
public void checkRazorPayPaymentStatus() throws Exception {
|
| 1599 |
List<PendingOrder> pendingOrder = pendingOrderRepository
|
1612 |
List<PendingOrder> pendingOrder = pendingOrderRepository
|
| 1600 |
.selectAllByStatus(com.spice.profitmandi.dao.enumuration.transaction.OrderStatus.PENDING);
|
1613 |
.selectAllByStatus(com.spice.profitmandi.dao.enumuration.transaction.OrderStatus.PENDING);
|
| 1601 |
|
1614 |
|
| 1602 |
for (PendingOrder po : pendingOrder) {
|
1615 |
for (PendingOrder po : pendingOrder) {
|
| 1603 |
RazorPay razorPay = razorPayRepository.selectByOrdeId(po.getId());
|
1616 |
RazorPay razorPay = razorPayRepository.selectByOrdeId(po.getId());
|
| - |
|
1617 |
List<PendingOrderItem> poItems = pendingOrderItemRepository.selectByOrderId(po.getId());
|
| 1604 |
|
1618 |
|
| 1605 |
LOGGER.info("razorPay" + razorPay);
|
1619 |
LOGGER.info("razorPay" + razorPay);
|
| 1606 |
if (razorPay != null) {
|
1620 |
if (razorPay != null) {
|
| 1607 |
List<Payment> payments = razorPaymentService.fetchOrderForPayment(razorPay.getRazorOrderId());
|
1621 |
List<Payment> payments = razorPaymentService.fetchOrderForPayment(razorPay.getRazorOrderId());
|
| - |
|
1622 |
|
| 1608 |
if (!payments.isEmpty()) {
|
1623 |
if (!payments.isEmpty()) {
|
| - |
|
1624 |
List<String> statusList = new ArrayList<>();
|
| 1609 |
for (Payment payment : payments) {
|
1625 |
for (Payment payment : payments) {
|
| 1610 |
LOGGER.info("payment" + payment);
|
- |
|
| 1611 |
|
1626 |
|
| - |
|
1627 |
JSONObject jsonObj = new JSONObject(payment.toString());
|
| - |
|
1628 |
|
| - |
|
1629 |
String status = jsonObj.getString("status");
|
| - |
|
1630 |
|
| - |
|
1631 |
statusList.add(status);
|
| - |
|
1632 |
|
| - |
|
1633 |
}
|
| - |
|
1634 |
LOGGER.info("statusList" + statusList);
|
| - |
|
1635 |
|
| - |
|
1636 |
if (statusList.contains("authorized") || statusList.contains("captured")) {
|
| - |
|
1637 |
po.setStatus(com.spice.profitmandi.dao.enumuration.transaction.OrderStatus.PROCESSING);
|
| - |
|
1638 |
po.setPaidAmount(po.getTotalAmount());
|
| - |
|
1639 |
for (PendingOrderItem poi : poItems) {
|
| - |
|
1640 |
poi.setStatus(com.spice.profitmandi.dao.enumuration.transaction.OrderStatus.PROCESSING);
|
| - |
|
1641 |
}
|
| - |
|
1642 |
Map<String, Object> emailModel = pendingOrderService.sendCreateOrderMail(po);
|
| - |
|
1643 |
|
| - |
|
1644 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(po.getFofoId());
|
| - |
|
1645 |
Customer customer = customerRepository.selectById(po.getCustomerId());
|
| - |
|
1646 |
String[] customerEmail = null;
|
| - |
|
1647 |
if (customer.getEmailId() != null) {
|
| - |
|
1648 |
customerEmail = new String[] { customer.getEmailId() };
|
| - |
|
1649 |
}
|
| - |
|
1650 |
List<String> bccTo = Arrays.asList("kamini.sharma@smartdukaan.com",
|
| - |
|
1651 |
"tarun.verma@smartdukaan.com", "hemant.kaura@smartdukaan.com",
|
| - |
|
1652 |
"niranjan.kala@smartdukaan.com", "sm@smartdukaan.com", "tejbeer.kaur@shop2020.in",
|
| - |
|
1653 |
customRetailer.getEmail());
|
| - |
|
1654 |
List<String> authUserEmails = csService.getAuthUserByPartnerId(customRetailer.getPartnerId());
|
| - |
|
1655 |
if (authUserEmails != null) {
|
| - |
|
1656 |
authUserEmails = new ArrayList<>();
|
| - |
|
1657 |
}
|
| - |
|
1658 |
authUserEmails.addAll(bccTo);
|
| - |
|
1659 |
|
| - |
|
1660 |
emailService.sendMailWithAttachments("Order Created with SmartDukaan", "order-confirm.vm",
|
| - |
|
1661 |
emailModel, customerEmail, null, authUserEmails.toArray(new String[0]));
|
| - |
|
1662 |
|
| - |
|
1663 |
} else if (statusList.contains("refunded") || statusList.contains("failed")) {
|
| - |
|
1664 |
for (PendingOrderItem poi : poItems) {
|
| - |
|
1665 |
poi.setStatus(com.spice.profitmandi.dao.enumuration.transaction.OrderStatus.FAILED);
|
| - |
|
1666 |
}
|
| - |
|
1667 |
|
| - |
|
1668 |
po.setStatus(com.spice.profitmandi.dao.enumuration.transaction.OrderStatus.FAILED);
|
| 1612 |
}
|
1669 |
}
|
| 1613 |
|
1670 |
|
| 1614 |
}
|
1671 |
}
|
| 1615 |
//LOGGER.info("payment" + payments);
|
1672 |
// LOGGER.info("payment" + payments);
|
| 1616 |
|
1673 |
|
| 1617 |
}
|
1674 |
}
|
| 1618 |
}
|
1675 |
}
|
| 1619 |
}
|
1676 |
}
|
| 1620 |
|
1677 |
|