Subversion Repositories SmartDukaan

Rev

Rev 34256 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
30652 amit.gupta 1
package com.spice.profitmandi.dao.entity.fofo;
2
 
3
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
4
 
5
import javax.persistence.*;
6
import java.time.LocalDateTime;
7
import java.util.Objects;
8
 
31008 amit.gupta 9
@Entity
31860 tejbeer 10
@Table(name = "fofo.offer_payout")
31008 amit.gupta 11
@NamedQueries({
31380 amit.gupta 12
        @NamedQuery(name = "OfferPayout.selectPaidOffers", query = "select new com.spice.profitmandi.service.transaction.InventoryMarginModel("
13
                + " o.retailerId, li.sgstRate, li.cgstRate, li.igstRate," +
14
                " cast(case when op.createTimestamp between :startDate and :endDate and op.rejectTimestamp is null then op.amount " +
15
                " 			when op.createTimestamp between :startDate and :endDate and op.rejectTimestamp between :startDate and :endDate then 0" +
16
                "			when op.rejectTimestamp between :startDate and :endDate then -op.amount" +
33459 amit.gupta 17
                "			else 0 end as float),  op.inventoryItemId,  lii.serialNumber, op.description, o.invoiceNumber, " +
36184 amit 18
                " case when op.rejectTimestamp between :startDate and :endDate then op.rejectTimestamp else op.createTimestamp end, ii.hsnCode)  from "
19
                + " OfferPayout op join InventoryItem ii on ii.id=op.inventoryItemId join LineItemImei lii on (op.serialNumber=lii.serialNumber) join LineItem li on li.id=lii.lineItemId "
31380 amit.gupta 20
                + " join Order o on (o.retailerId=op.fofoId and o.billingTimestamp is not null and o.id=li.orderId) "
21
                + " where op.createTimestamp >= :cnDate and ((op.createTimestamp between :startDate and :endDate) or (op.rejectTimestamp between :startDate and :endDate))"
34256 ranu 22
                + " and lii.id=(select max(lii2.id) from LineItemImei lii2 join LineItem li2 on li2.id=lii2.lineItemId join Order o2 on o2.id=li2.orderId where lii2.serialNumber=lii.serialNumber and o2.retailerId=op.fofoId) "
23
                + " AND (:fofoId IS NULL OR o.retailerId = :fofoId)"),
31352 amit.gupta 24
 
34256 ranu 25
 
26
 
31380 amit.gupta 27
        @NamedQuery(name = "OfferPayout.getTotalPayoutsByPartnerPeriod", query = "select new com.spice.profitmandi.common.model.OfferPayoutImeiIncomeModel(" +
28
                " ii.id, ii.serialNumber, " +
29
                " case when (sr.type='PURCHASE' and o.schemeType='SELLIN') then max(sr.createTimestamp) end," +
30
                " case when (sr.type='SALE' and o.schemeType != 'SELLIN') then max(sr.createTimestamp)  end, " +
31
                " case when (sr.type='PURCHASE' and o.schemeType='SELLIN') then sum(op.amount)  else 0 end, " +
32
                " case when (sr.type='SALE' and o.schemeType!='SELLIN') then sum(op.amount) else 0 end, " +
33
                " i.catalogItemId, i.brand, i.modelName, i.modelNumber" +
34
                ") from OfferPayout op join Offer o on o.id=op.offerId join InventoryItem ii on ii.serialNumber=op.serialNumber and op.fofoId=ii.fofoId" +
35
                " join Item i on i.id=ii.itemId join ScanRecord  sr on sr.inventoryItemId=ii.id " +
36
                " and ((sr.type='PURCHASE' and o.schemeType='SELLIN') or (sr.type='SALE' and o.schemeType!='SELLIN'))" +
37
                " where op.rejectTimestamp is null and sr.createTimestamp between :startDate and :endDate" +
38
                " and (:brand is null or i.brand=:brand)" +
39
                " and (:catalogId is null or i.catalogItemId=:catalogId)" +
40
                " and op.fofoId=:fofoId" +
32234 amit.gupta 41
                " group by ii.id, sr.type "),
31352 amit.gupta 42
 
31380 amit.gupta 43
        @NamedQuery(name = "OfferPayout.getTotalPayoutsByImei", query = "select new com.spice.profitmandi.common.model.OfferPayoutImeiIncomeModel(" +
44
                " ii.id, ii.serialNumber, " +
45
                " max(case when (sr.type='PURCHASE' and o.schemeType='SELLIN') then sr.createTimestamp end)," +
46
                " max(case when (sr.type='SALE' and o.schemeType != 'SELLIN') then sr.createTimestamp  end), " +
47
                " sum(case when (sr.type='PURCHASE' and o.schemeType='SELLIN') then op.amount  else 0 end), " +
48
                " sum(case when (sr.type='SALE' and o.schemeType!='SELLIN') then op.amount else 0 end), " +
49
                " i.catalogItemId, i.brand, i.modelName, i.modelNumber" +
50
                ") from OfferPayout op join Offer o on o.id=op.offerId join InventoryItem ii on ii.serialNumber=op.serialNumber and op.fofoId=ii.fofoId" +
51
                " join Item i on i.id=ii.itemId join ScanRecord  sr on sr.inventoryItemId=ii.id " +
52
                " and ((sr.type='PURCHASE' and o.schemeType='SELLIN') or (sr.type='SALE' and o.schemeType!='SELLIN'))" +
53
                " where op.rejectTimestamp is null and ii.serialNumber in :serialNumbers" +
31382 amit.gupta 54
                " group by ii.id ")/*,
31380 amit.gupta 55
        @NamedQuery(name = "OfferPayout.selectMarginsByYearMonth", query = "select com.spice.profitmandi.common.model.MarginModel(" +
56
                " " +
57
                ") from Order ord join    OfferPayout op join Offer on o.id=op.offerId join InventoryItem ii on ii.serialNumber=op.serialNumber and op.fofoId=ii.fofoId" +
58
                " join Item i on i.id=ii.itemId join ScanRecord  sr on sr.inventoryItemId=ii.id " +
59
                " and ((sr.type='PURCHASE' and o.schemeType='SELLIN') or (sr.type='SALE' and o.schemeType!='SELLIN'))" +
60
                " join  " +
61
                " where op.rejectTimestamp is null and ii.serialNumber in :serialNumbers" +
31382 amit.gupta 62
                " group by ii.id ")*/
31008 amit.gupta 63
})
30652 amit.gupta 64
public class OfferPayout {
31380 amit.gupta 65
        @Id
66
        @GeneratedValue(strategy = GenerationType.IDENTITY)
67
        private long id;
68
        @Column(name = "fofo_id", nullable = false)
69
        private long fofoId;
70
        @Column(name = "offer_id", nullable = false)
71
        private long offerId;
72
        @Column(name = "criteria_id", nullable = false)
73
        private long criteriaId;
74
        @Column(name = "slab_amount", nullable = false)
75
        private double slabAmount;
76
        @Column(name = "serial_number", nullable = false)
77
        private String serialNumber;
78
        @Column(name = "amount", nullable = false)
79
        private double amount;
80
        @Column(name = "status", nullable = false)
81
        @Enumerated(EnumType.STRING)
82
        private SchemePayoutStatus status;
83
        @Column(name = "description", nullable = false)
84
        private String description;
85
        @Column(name = "inventory_item_id", nullable = false)
86
        private int inventoryItemId;
87
        @Column(name = "create_timestamp", nullable = false)
88
        private LocalDateTime createTimestamp;
89
        @Column(name = "reject_timestamp")
90
        private LocalDateTime rejectTimestamp;
30652 amit.gupta 91
 
31380 amit.gupta 92
        public OfferPayout() {
30996 amit.gupta 93
 
31380 amit.gupta 94
        }
30996 amit.gupta 95
 
31380 amit.gupta 96
        public OfferPayout(long fofoId, long offerId, long criteriaId, double slabAmount, String serialNumber, double amount, SchemePayoutStatus status, String description, LocalDateTime createTimestamp) {
97
                this.fofoId = fofoId;
98
                this.offerId = offerId;
99
                this.criteriaId = criteriaId;
100
                this.slabAmount = slabAmount;
101
                this.serialNumber = serialNumber;
102
                this.amount = amount;
103
                this.status = status;
104
                this.description = description;
105
                this.createTimestamp = createTimestamp;
106
        }
31008 amit.gupta 107
 
31380 amit.gupta 108
        @Override
109
        public String toString() {
110
                return "OfferPayout{" +
111
                        "id=" + id +
112
                        ", fofoId=" + fofoId +
113
                        ", offerId=" + offerId +
114
                        ", criteriaId=" + criteriaId +
115
                        ", slabAmount=" + slabAmount +
116
                        ", serialNumber='" + serialNumber + '\'' +
117
                        ", amount=" + amount +
118
                        ", status=" + status +
119
                        ", description='" + description + '\'' +
120
                        ", inventoryItemId=" + inventoryItemId +
121
                        ", createTimestamp=" + createTimestamp +
122
                        ", rejectTimestamp=" + rejectTimestamp +
123
                        '}';
124
        }
30996 amit.gupta 125
 
31380 amit.gupta 126
        public int getInventoryItemId() {
127
                return inventoryItemId;
128
        }
31008 amit.gupta 129
 
31380 amit.gupta 130
        public void setInventoryItemId(int inventoryItemId) {
131
                this.inventoryItemId = inventoryItemId;
132
        }
31008 amit.gupta 133
 
31380 amit.gupta 134
        @Override
135
        public boolean equals(Object o) {
136
                if (this == o) return true;
137
                if (o == null || getClass() != o.getClass()) return false;
138
                OfferPayout that = (OfferPayout) o;
139
                return id == that.id && fofoId == that.fofoId && offerId == that.offerId && criteriaId == that.criteriaId && Double.compare(that.slabAmount, slabAmount) == 0 && Double.compare(that.amount, amount) == 0 && inventoryItemId == that.inventoryItemId && Objects.equals(serialNumber, that.serialNumber) && status == that.status && Objects.equals(description, that.description) && Objects.equals(createTimestamp, that.createTimestamp) && Objects.equals(rejectTimestamp, that.rejectTimestamp);
140
        }
31008 amit.gupta 141
 
31380 amit.gupta 142
        @Override
143
        public int hashCode() {
144
                return Objects.hash(id, fofoId, offerId, criteriaId, slabAmount, serialNumber, amount, status, description, inventoryItemId, createTimestamp, rejectTimestamp);
145
        }
31008 amit.gupta 146
 
31380 amit.gupta 147
        public LocalDateTime getCreateTimestamp() {
148
                return createTimestamp;
149
        }
30652 amit.gupta 150
 
31380 amit.gupta 151
        public void setCreateTimestamp(LocalDateTime createTimestamp) {
152
                this.createTimestamp = createTimestamp;
153
        }
30652 amit.gupta 154
 
31380 amit.gupta 155
        public LocalDateTime getRejectTimestamp() {
156
                return rejectTimestamp;
157
        }
30996 amit.gupta 158
 
31380 amit.gupta 159
        public void setRejectTimestamp(LocalDateTime rejectTimestamp) {
160
                this.rejectTimestamp = rejectTimestamp;
161
        }
30996 amit.gupta 162
 
31380 amit.gupta 163
        public long getId() {
164
                return id;
165
        }
30996 amit.gupta 166
 
31380 amit.gupta 167
        public void setId(long id) {
168
                this.id = id;
169
        }
30652 amit.gupta 170
 
31380 amit.gupta 171
        public long getFofoId() {
172
                return fofoId;
173
        }
30652 amit.gupta 174
 
31380 amit.gupta 175
        public void setFofoId(long fofoId) {
176
                this.fofoId = fofoId;
177
        }
30652 amit.gupta 178
 
31380 amit.gupta 179
        public long getOfferId() {
180
                return offerId;
181
        }
30652 amit.gupta 182
 
31380 amit.gupta 183
        public void setOfferId(long offerId) {
184
                this.offerId = offerId;
185
        }
30652 amit.gupta 186
 
31380 amit.gupta 187
        public long getCriteriaId() {
188
                return criteriaId;
189
        }
30652 amit.gupta 190
 
31380 amit.gupta 191
        public void setCriteriaId(long criteriaId) {
192
                this.criteriaId = criteriaId;
193
        }
30652 amit.gupta 194
 
31380 amit.gupta 195
        public double getSlabAmount() {
196
                return slabAmount;
197
        }
30652 amit.gupta 198
 
31380 amit.gupta 199
        public void setSlabAmount(double slabAmount) {
200
                this.slabAmount = slabAmount;
201
        }
30652 amit.gupta 202
 
31380 amit.gupta 203
        public String getSerialNumber() {
204
                return serialNumber;
205
        }
30652 amit.gupta 206
 
31380 amit.gupta 207
        public void setSerialNumber(String serialNumber) {
208
                this.serialNumber = serialNumber;
209
        }
30652 amit.gupta 210
 
31380 amit.gupta 211
        public double getAmount() {
212
                return amount;
213
        }
30652 amit.gupta 214
 
31380 amit.gupta 215
        public void setAmount(double amount) {
216
                this.amount = amount;
217
        }
30652 amit.gupta 218
 
31380 amit.gupta 219
        public SchemePayoutStatus getStatus() {
220
                return status;
221
        }
30652 amit.gupta 222
 
31380 amit.gupta 223
        public void setStatus(SchemePayoutStatus status) {
224
                this.status = status;
225
        }
30652 amit.gupta 226
 
31380 amit.gupta 227
        public String getDescription() {
228
                return description;
229
        }
30652 amit.gupta 230
 
31380 amit.gupta 231
        public void setDescription(String description) {
232
                this.description = description;
233
        }
30652 amit.gupta 234
}