| Line 15... |
Line 15... |
| 15 |
import javax.persistence.criteria.CriteriaBuilder;
|
15 |
import javax.persistence.criteria.CriteriaBuilder;
|
| 16 |
import javax.persistence.criteria.CriteriaQuery;
|
16 |
import javax.persistence.criteria.CriteriaQuery;
|
| 17 |
import javax.persistence.criteria.Predicate;
|
17 |
import javax.persistence.criteria.Predicate;
|
| 18 |
import javax.persistence.criteria.Root;
|
18 |
import javax.persistence.criteria.Root;
|
| 19 |
|
19 |
|
| 20 |
import org.apache.commons.collections.ListUtils;
|
- |
|
| 21 |
import org.apache.logging.log4j.LogManager;
|
20 |
import org.apache.logging.log4j.LogManager;
|
| 22 |
import org.apache.logging.log4j.Logger;
|
21 |
import org.apache.logging.log4j.Logger;
|
| 23 |
import org.hibernate.Session;
|
22 |
import org.hibernate.Session;
|
| 24 |
import org.hibernate.SessionFactory;
|
23 |
import org.hibernate.SessionFactory;
|
| 25 |
import org.hibernate.query.Query;
|
24 |
import org.hibernate.query.Query;
|
| 26 |
import org.springframework.beans.factory.annotation.Autowired;
|
25 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 27 |
import org.springframework.beans.factory.annotation.Qualifier;
|
26 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 28 |
import org.springframework.cache.annotation.Cacheable;
|
27 |
import org.springframework.cache.annotation.Cacheable;
|
| 29 |
import org.springframework.stereotype.Component;
|
28 |
import org.springframework.stereotype.Component;
|
| 30 |
|
29 |
|
| 31 |
import com.itextpdf.text.pdf.PdfStructTreeController.returnType;
|
- |
|
| 32 |
import com.mysql.fabric.xmlrpc.base.Array;
|
- |
|
| 33 |
import com.spice.profitmandi.common.enumuration.ItemType;
|
30 |
import com.spice.profitmandi.common.enumuration.ItemType;
|
| 34 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
31 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 35 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
32 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 36 |
import com.spice.profitmandi.common.model.SchemeModel;
|
33 |
import com.spice.profitmandi.common.model.SchemeModel;
|
| 37 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
34 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| Line 41... |
Line 38... |
| 41 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
38 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| 42 |
import com.spice.profitmandi.dao.entity.fofo.ActivatedImei;
|
39 |
import com.spice.profitmandi.dao.entity.fofo.ActivatedImei;
|
| 43 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
40 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
| 44 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
41 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
| 45 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
42 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| 46 |
import com.spice.profitmandi.dao.entity.fofo.PendingOrder;
|
- |
|
| 47 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
43 |
import com.spice.profitmandi.dao.entity.fofo.Purchase;
|
| 48 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
44 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| 49 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
45 |
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
|
| 50 |
import com.spice.profitmandi.dao.entity.fofo.SchemeItem;
|
46 |
import com.spice.profitmandi.dao.entity.fofo.SchemeItem;
|
| 51 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
47 |
import com.spice.profitmandi.dao.entity.transaction.PriceDrop;
|
| Line 490... |
Line 486... |
| 490 |
SchemeInOut schemeInOut = new SchemeInOut();
|
486 |
SchemeInOut schemeInOut = new SchemeInOut();
|
| 491 |
amountToCredit = this.getAmount(inventoryItem, scheme);
|
487 |
amountToCredit = this.getAmount(inventoryItem, scheme);
|
| 492 |
schemeInOut.setSchemeId(scheme.getId());
|
488 |
schemeInOut.setSchemeId(scheme.getId());
|
| 493 |
schemeInOut.setInventoryItemId(inventoryItem.getId());
|
489 |
schemeInOut.setInventoryItemId(inventoryItem.getId());
|
| 494 |
schemeInOut.setAmount(amountToCredit);
|
490 |
schemeInOut.setAmount(amountToCredit);
|
| - |
|
491 |
schemeInOutRepository.persist(schemeInOut);
|
| 495 |
if(scheme.getType().equals(SchemeType.ACTIVATION)) {
|
492 |
if(scheme.getType().equals(SchemeType.ACTIVATION)) {
|
| 496 |
schemeInOut.setStatus(SchemePayoutStatus.PENDING);
|
493 |
schemeInOut.setStatus(SchemePayoutStatus.PENDING);
|
| 497 |
schemeInOut.setStatusDescription("Activation pending for IMEI#" + inventoryItem.getSerialNumber());
|
494 |
schemeInOut.setStatusDescription("Activation pending for IMEI#" + inventoryItem.getSerialNumber());
|
| 498 |
return 0;
|
495 |
return 0;
|
| 499 |
} else if(scheme.getType().equals(SchemeType.INVESTMENT)) {
|
496 |
} else if(scheme.getType().equals(SchemeType.INVESTMENT)) {
|
| Line 503... |
Line 500... |
| 503 |
} else {
|
500 |
} else {
|
| 504 |
schemeInOut.setStatus(SchemePayoutStatus.CREDITED);
|
501 |
schemeInOut.setStatus(SchemePayoutStatus.CREDITED);
|
| 505 |
schemeInOut.setStatusDescription("Credited for sale of IMEI#" + inventoryItem.getSerialNumber());
|
502 |
schemeInOut.setStatusDescription("Credited for sale of IMEI#" + inventoryItem.getSerialNumber());
|
| 506 |
schemeInOut.setCreditTimestamp(LocalDateTime.now());
|
503 |
schemeInOut.setCreditTimestamp(LocalDateTime.now());
|
| 507 |
}
|
504 |
}
|
| 508 |
schemeInOutRepository.persist(schemeInOut);
|
- |
|
| 509 |
}
|
505 |
}
|
| 510 |
return amountToCredit;
|
506 |
return amountToCredit;
|
| 511 |
}
|
507 |
}
|
| 512 |
|
508 |
|
| 513 |
// We are maintaining price drop after grn
|
509 |
// We are maintaining price drop after grn
|