Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
33715 ranu 1
package com.spice.profitmandi.dao.entity.fofo;
2
 
3
import com.spice.profitmandi.dao.enumuration.transaction.UpSaleCallStatus;
34111 ranu 4
import com.spice.profitmandi.dao.model.UpsellingReportModel;
33715 ranu 5
 
6
import javax.persistence.*;
7
import java.io.Serializable;
8
import java.time.LocalDateTime;
9
import java.util.Objects;
10
 
11
/**
12
 * @author ranu
13
 */
14
@Entity
15
@Table(name = "fofo.upSaleCall")
16
@NamedQueries({
17
        @NamedQuery(name = "upSaleCall.checkNumberIsExist", query = "SELECT COUNT(u) FROM UpSaleCall u WHERE u.mobile = :mobile AND u.originalOrderId = :orderId"),
18
        @NamedQuery(name = "upSaleCall.checkOrderIsExist", query = "SELECT COUNT(u) FROM UpSaleCall u WHERE u.originalOrderId = :orderId"),
19
})
34111 ranu 20
 
21
 
22
@NamedNativeQueries({
23
        @NamedNativeQuery(name = "Upsell.UpsellingReport",
34134 ranu 24
                query = "SELECT uc.agentId, ucd.agent_id as agentEmail,u.name as partnerName,ua.phone as partnerMobile, ua.state, uc.originalOrderId as orderId, uc.mobile as customerNumber, " +
34129 ranu 25
                        "ucd.created_timestamp as callingDate, coalesce(ucd.disposition,'-') as disposition,coalesce(ucd.remark,'-') as remark," +
26
                        " coalesce(rp.payment_status, 'Not Found') as paymentStatus, " +
27
                        "(CASE WHEN ac.create_timestamp IS NOT NULL THEN 'Created' ELSE 'Not Created' END) AS insuranceStatus, " +
28
                        "coalesce(ip.sale_amount,0) as soldAmount, coalesce(ip.invoice_number,'Not Found') as invoiceNumber, coalesce(ip.serial_number,'Not Found') as serialNumber" +
34111 ranu 29
                        " FROM fofo.upSaleCall uc" +
30
                        " JOIN fofo.upsell_call_details ucd on uc.id = ucd.upsale_call_id" +
34117 ranu 31
                        " JOIN fofo.fofo_order fo on fo.id = uc.originalOrderId" +
32
                        " JOIN user.user u on u.id = fo.fofo_id" +
34134 ranu 33
                        " JOIN user.address ua on ua.id = u.default_address_id" +
34111 ranu 34
                        " LEFT JOIN fofo.upsellRazorpayPaymentStatus rp on rp.order_id = uc.originalOrderId" +
35
                        " LEFT JOIN fofo.upsaleAgentCollection ac on ac.order_id = uc.originalOrderId" +
34117 ranu 36
                        " LEFT JOIN dtr.insurance_policy ip on ip.device_invoice_number = fo.invoice_number" +
34111 ranu 37
                        " WHERE uc.create_timestamp >= :startDate and uc.create_timestamp < :endDate",
38
                resultSetMapping = "UpsellingReport"),
39
 
40
})
41
 
42
@SqlResultSetMappings({
43
 
44
        @SqlResultSetMapping(name = "UpsellingReport",
45
                classes = {@ConstructorResult(targetClass = UpsellingReportModel.class,
46
                        columns = {
47
                                @ColumnResult(name = "agentId", type = Integer.class),
48
                                @ColumnResult(name = "agentEmail", type = String.class),
34117 ranu 49
                                @ColumnResult(name = "partnerName", type = String.class),
34133 ranu 50
                                @ColumnResult(name = "partnerMobile", type = String.class),
34134 ranu 51
                                @ColumnResult(name = "state", type = String.class),
34111 ranu 52
                                @ColumnResult(name = "orderId", type = Integer.class),
53
                                @ColumnResult(name = "customerNumber ", type = String.class),
54
                                @ColumnResult(name = "callingDate ", type = String.class),
34129 ranu 55
                                @ColumnResult(name = "disposition ", type = String.class),
56
                                @ColumnResult(name = "remark ", type = String.class),
34111 ranu 57
                                @ColumnResult(name = "paymentStatus ", type = String.class),
58
                                @ColumnResult(name = "insuranceStatus ", type = String.class),
59
                                @ColumnResult(name = "soldAmount ", type = Float.class),
60
                                @ColumnResult(name = "invoiceNumber ", type = String.class),
61
                                @ColumnResult(name = "serialNumber ", type = String.class),
62
                        }
63
                )}
64
        )
65
 
66
})
33715 ranu 67
public class UpSaleCall implements Serializable {
68
 
69
 
70
    private static final long serialVersionUID = 1L;
71
    @Id
72
    @Column(name = "id")
73
    @GeneratedValue(strategy = GenerationType.IDENTITY)
74
    private int id;
75
 
76
    @Column(name = "agentId")
77
    private int agentId;
78
 
79
    @Column(name = "originalOrderId")
80
    private int originalOrderId;
81
 
82
    @Column(name = "mobile")
83
    private String mobile;
84
 
85
    @Column(name = "status")
86
    @Enumerated(EnumType.STRING)
87
    private UpSaleCallStatus status;
88
 
89
    @Column(name = "create_timestamp")
90
    private LocalDateTime createdTimestamp = LocalDateTime.now();
91
 
92
    @Column(name = "rescheduled_timestamp")
93
    private LocalDateTime rescheduledTimestamp;
94
 
95
    public int getId() {
96
        return id;
97
    }
98
 
99
    public void setId(int id) {
100
        this.id = id;
101
    }
102
 
103
    public int getAgentId() {
104
        return agentId;
105
    }
106
 
107
    public void setAgentId(int agentId) {
108
        this.agentId = agentId;
109
    }
110
 
111
    public String getMobile() {
112
        return mobile;
113
    }
114
 
115
    public void setMobile(String mobile) {
116
        this.mobile = mobile;
117
    }
118
 
119
    public UpSaleCallStatus getStatus() {
120
        return status;
121
    }
122
 
123
    public void setStatus(UpSaleCallStatus status) {
124
        this.status = status;
125
    }
126
 
127
    public LocalDateTime getCreatedTimestamp() {
128
        return createdTimestamp;
129
    }
130
 
131
    public void setCreatedTimestamp(LocalDateTime createdTimestamp) {
132
        this.createdTimestamp = createdTimestamp;
133
    }
134
 
135
    public int getOriginalOrderId() {
136
        return originalOrderId;
137
    }
138
 
139
    public void setOriginalOrderId(int originalOrderId) {
140
        this.originalOrderId = originalOrderId;
141
    }
142
 
143
    public LocalDateTime getRescheduledTimestamp() {
144
        return rescheduledTimestamp;
145
    }
146
 
147
    public void setRescheduledTimestamp(LocalDateTime rescheduledTimestamp) {
148
        this.rescheduledTimestamp = rescheduledTimestamp;
149
    }
150
 
151
    @Override
152
    public String toString() {
153
        return "UpSaleCall{" +
154
                "id=" + id +
155
                ", agentId=" + agentId +
156
                ", originalOrderId=" + originalOrderId +
157
                ", mobile='" + mobile + '\'' +
158
                ", status=" + status +
159
                ", createdTimestamp=" + createdTimestamp +
160
                ", rescheduledTimestamp=" + rescheduledTimestamp +
161
                '}';
162
    }
163
 
164
 
165
    @Override
166
    public boolean equals(Object o) {
167
        if (this == o) return true;
168
        if (o == null || getClass() != o.getClass()) return false;
169
        UpSaleCall that = (UpSaleCall) o;
170
        return id == that.id && agentId == that.agentId && originalOrderId == that.originalOrderId && Objects.equals(mobile, that.mobile) && status == that.status && Objects.equals(createdTimestamp, that.createdTimestamp) && Objects.equals(rescheduledTimestamp, that.rescheduledTimestamp);
171
    }
172
 
173
    @Override
174
    public int hashCode() {
175
        return Objects.hash(id, agentId, originalOrderId, mobile, status, createdTimestamp, rescheduledTimestamp);
176
    }
177
}