| 21716 |
ashik.ali |
1 |
package com.spice.profitmandi.dao.entity.transaction;
|
| 21552 |
ashik.ali |
2 |
|
| 29990 |
amit.gupta |
3 |
import javax.persistence.*;
|
| 21552 |
ashik.ali |
4 |
|
|
|
5 |
@Entity
|
| 28521 |
amit.gupta |
6 |
@Table(name = "transaction.userwallet", schema = "transaction")
|
|
|
7 |
@NamedQueries({
|
| 29990 |
amit.gupta |
8 |
@NamedQuery(name = "UserWallet.getSummary", query = "select new com.spice.profitmandi.dao.model.AccountStatementModel(uwh.referenceType, sum(case when uwh.amount>0 then amount else 0 end), sum(case when uwh.amount<0 then -amount else 0 end))\tfrom UserWalletHistory uwh where uwh.walletId=:walletId \tand uwh.timestamp between :startDate and :endDate group by uwh.referenceType"),
|
| 31242 |
amit.gupta |
9 |
@NamedQuery(name = "UserWallet.getStatewiseCollections", query = "SELECT new com.spice.profitmandi.dao.model.WarehouseWalletAmountModel(fs.warehouseId, sum(uwh.amount), uwh.referenceType) FROM FofoStore fs"
|
| 30077 |
tejbeer |
10 |
+ " join UserWallet uw on uw.userId = fs.id " + "join UserWalletHistory uwh on uwh.walletId = uw.id "
|
|
|
11 |
+ "where uwh.referenceType in ('ADVANCE_AMOUNT', 'AUTOMATED_ADVANCE', 'PAYMENT_GATEWAY') "
|
| 31309 |
amit.gupta |
12 |
+ "and uwh.timestamp between :startDate and :endDate and fs.internal=false group by fs.warehouseId, uwh.referenceType"),
|
| 30077 |
tejbeer |
13 |
|
| 30087 |
tejbeer |
14 |
@NamedQuery(name = "UserWallet.getPartnerWiseTargetCollections", query = "SELECT new com.spice.profitmandi.dao.model.PartnerCollectionPlanModel(fs.id,case when pcp.collectionPlan is not null then cast(pcp.collectionPlan As long) else 0 end,"
|
| 30330 |
tejbeer |
15 |
+ " sum(cast(uwh.amount AS int)),pcp.authId,pcp.createTimestamp, pcp.commitedTimestamp) FROM FofoStore fs"
|
| 30087 |
tejbeer |
16 |
+ " left join UserWallet uw on uw.userId = fs.id "
|
|
|
17 |
+ " left join UserWalletHistory uwh on (uwh.walletId = uw.id and"
|
|
|
18 |
+ " uwh.referenceType in ('ADVANCE_AMOUNT', 'AUTOMATED_ADVANCE', 'PAYMENT_GATEWAY')"
|
| 30137 |
tejbeer |
19 |
+ " and uwh.timestamp >= :startDate )"
|
|
|
20 |
+ " left join PartnerCollectionPlan pcp on (pcp.fofoId = fs.id and pcp.commitedTimestamp >= :startDate"
|
| 30330 |
tejbeer |
21 |
+ " and pcp.active = 1)" + " where fs.id in :fofoIds and fs.internal=0 group by fs.id"),
|
|
|
22 |
|
|
|
23 |
@NamedQuery(name = "UserWallet.getPartnerWiseCollectionAchievement", query = "SELECT new com.spice.profitmandi.dao.model.PartnerCollectionAchievementModel(fs.id,"
|
|
|
24 |
+ " sum(cast(uwh.amount AS int))) FROM FofoStore fs" + " left join UserWallet uw on uw.userId = fs.id "
|
|
|
25 |
+ " left join UserWalletHistory uwh on (uwh.walletId = uw.id and"
|
|
|
26 |
+ " uwh.referenceType in ('ADVANCE_AMOUNT', 'AUTOMATED_ADVANCE', 'PAYMENT_GATEWAY')"
|
|
|
27 |
+ " and uwh.timestamp >= :startDate )"
|
|
|
28 |
+ " where fs.id in :fofoIds and fs.internal=0 group by fs.id"), })
|
|
|
29 |
|
| 28521 |
amit.gupta |
30 |
public class UserWallet {
|
|
|
31 |
|
| 21552 |
ashik.ali |
32 |
@Id
|
| 28521 |
amit.gupta |
33 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
| 21552 |
ashik.ali |
34 |
private int id;
|
|
|
35 |
private int userId;
|
|
|
36 |
private int amount;
|
| 28521 |
amit.gupta |
37 |
|
| 22550 |
ashik.ali |
38 |
@Column(name = "refundable_amount")
|
|
|
39 |
private int refundableAmount;
|
| 28521 |
amit.gupta |
40 |
|
| 21552 |
ashik.ali |
41 |
public int getId() {
|
|
|
42 |
return id;
|
|
|
43 |
}
|
| 28521 |
amit.gupta |
44 |
|
| 21552 |
ashik.ali |
45 |
public void setId(int id) {
|
|
|
46 |
this.id = id;
|
|
|
47 |
}
|
| 28521 |
amit.gupta |
48 |
|
| 21552 |
ashik.ali |
49 |
public int getUserId() {
|
|
|
50 |
return userId;
|
|
|
51 |
}
|
| 25546 |
amit.gupta |
52 |
|
| 21552 |
ashik.ali |
53 |
public void setUserId(int userId) {
|
|
|
54 |
this.userId = userId;
|
|
|
55 |
}
|
| 28521 |
amit.gupta |
56 |
|
| 21552 |
ashik.ali |
57 |
public int getAmount() {
|
| 25546 |
amit.gupta |
58 |
return amount;
|
| 21552 |
ashik.ali |
59 |
}
|
| 28521 |
amit.gupta |
60 |
|
| 21552 |
ashik.ali |
61 |
public void setAmount(int amount) {
|
|
|
62 |
this.amount = amount;
|
|
|
63 |
}
|
| 28521 |
amit.gupta |
64 |
|
| 22550 |
ashik.ali |
65 |
public int getRefundableAmount() {
|
|
|
66 |
return refundableAmount;
|
| 21552 |
ashik.ali |
67 |
}
|
| 28521 |
amit.gupta |
68 |
|
| 22550 |
ashik.ali |
69 |
public void setRefundableAmount(int refundableAmount) {
|
|
|
70 |
this.refundableAmount = refundableAmount;
|
| 21552 |
ashik.ali |
71 |
}
|
| 28521 |
amit.gupta |
72 |
|
| 21602 |
ashik.ali |
73 |
@Override
|
| 21924 |
ashik.ali |
74 |
public int hashCode() {
|
|
|
75 |
final int prime = 31;
|
|
|
76 |
int result = 1;
|
|
|
77 |
result = prime * result + id;
|
|
|
78 |
return result;
|
|
|
79 |
}
|
| 28521 |
amit.gupta |
80 |
|
| 21924 |
ashik.ali |
81 |
@Override
|
|
|
82 |
public boolean equals(Object obj) {
|
|
|
83 |
if (this == obj)
|
|
|
84 |
return true;
|
|
|
85 |
if (obj == null)
|
|
|
86 |
return false;
|
|
|
87 |
if (getClass() != obj.getClass())
|
|
|
88 |
return false;
|
|
|
89 |
UserWallet other = (UserWallet) obj;
|
|
|
90 |
if (id != other.id)
|
|
|
91 |
return false;
|
|
|
92 |
return true;
|
|
|
93 |
}
|
| 28521 |
amit.gupta |
94 |
|
| 21924 |
ashik.ali |
95 |
@Override
|
| 21602 |
ashik.ali |
96 |
public String toString() {
|
| 22550 |
ashik.ali |
97 |
return "UserWallet [id=" + id + ", userId=" + userId + ", amount=" + amount + ", refundableAmount="
|
|
|
98 |
+ refundableAmount + "]";
|
| 21602 |
ashik.ali |
99 |
}
|
| 28521 |
amit.gupta |
100 |
|
| 22653 |
ashik.ali |
101 |
}
|