Subversion Repositories SmartDukaan

Rev

Rev 31242 | Rev 31860 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.dao.entity.transaction;

import javax.persistence.*;

@Entity
@Table(name = "transaction.userwallet", schema = "transaction")
@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"),

                @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"),

                @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"), })

public class UserWallet {

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private int id;
        private int userId;
        private int amount;

        @Column(name = "refundable_amount")
        private int refundableAmount;

        public int getId() {
                return id;
        }

        public void setId(int id) {
                this.id = id;
        }

        public int getUserId() {
                return userId;
        }

        public void setUserId(int userId) {
                this.userId = userId;
        }

        public int getAmount() {
                return amount;
        }

        public void setAmount(int amount) {
                this.amount = amount;
        }

        public int getRefundableAmount() {
                return refundableAmount;
        }

        public void setRefundableAmount(int refundableAmount) {
                this.refundableAmount = refundableAmount;
        }

        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
                result = prime * result + id;
                return result;
        }

        @Override
        public boolean equals(Object obj) {
                if (this == obj)
                        return true;
                if (obj == null)
                        return false;
                if (getClass() != obj.getClass())
                        return false;
                UserWallet other = (UserWallet) obj;
                if (id != other.id)
                        return false;
                return true;
        }

        @Override
        public String toString() {
                return "UserWallet [id=" + id + ", userId=" + userId + ", amount=" + amount + ", refundableAmount="
                                + refundableAmount + "]";
        }

}