Subversion Repositories SmartDukaan

Rev

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

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