Subversion Repositories SmartDukaan

Rev

Rev 34117 | Rev 34133 | Go to most recent revision | 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",
34129 ranu 24
                query = "SELECT uc.agentId, ucd.agent_id as agentEmail,u.name as partnerName, uc.originalOrderId as orderId, uc.mobile as customerNumber, " +
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" +
34111 ranu 33
                        " LEFT JOIN fofo.upsellRazorpayPaymentStatus rp on rp.order_id = uc.originalOrderId" +
34
                        " LEFT JOIN fofo.upsaleAgentCollection ac on ac.order_id = uc.originalOrderId" +
34117 ranu 35
                        " LEFT JOIN dtr.insurance_policy ip on ip.device_invoice_number = fo.invoice_number" +
34111 ranu 36
                        " WHERE uc.create_timestamp >= :startDate and uc.create_timestamp < :endDate",
37
                resultSetMapping = "UpsellingReport"),
38
 
39
})
40
 
41
@SqlResultSetMappings({
42
 
43
        @SqlResultSetMapping(name = "UpsellingReport",
44
                classes = {@ConstructorResult(targetClass = UpsellingReportModel.class,
45
                        columns = {
46
                                @ColumnResult(name = "agentId", type = Integer.class),
47
                                @ColumnResult(name = "agentEmail", type = String.class),
34117 ranu 48
                                @ColumnResult(name = "partnerName", type = String.class),
34111 ranu 49
                                @ColumnResult(name = "orderId", type = Integer.class),
50
                                @ColumnResult(name = "customerNumber ", type = String.class),
51
                                @ColumnResult(name = "callingDate ", type = String.class),
34129 ranu 52
                                @ColumnResult(name = "disposition ", type = String.class),
53
                                @ColumnResult(name = "remark ", type = String.class),
34111 ranu 54
                                @ColumnResult(name = "paymentStatus ", type = String.class),
55
                                @ColumnResult(name = "insuranceStatus ", type = String.class),
56
                                @ColumnResult(name = "soldAmount ", type = Float.class),
57
                                @ColumnResult(name = "invoiceNumber ", type = String.class),
58
                                @ColumnResult(name = "serialNumber ", type = String.class),
59
                        }
60
                )}
61
        )
62
 
63
})
33715 ranu 64
public class UpSaleCall implements Serializable {
65
 
66
 
67
    private static final long serialVersionUID = 1L;
68
    @Id
69
    @Column(name = "id")
70
    @GeneratedValue(strategy = GenerationType.IDENTITY)
71
    private int id;
72
 
73
    @Column(name = "agentId")
74
    private int agentId;
75
 
76
    @Column(name = "originalOrderId")
77
    private int originalOrderId;
78
 
79
    @Column(name = "mobile")
80
    private String mobile;
81
 
82
    @Column(name = "status")
83
    @Enumerated(EnumType.STRING)
84
    private UpSaleCallStatus status;
85
 
86
    @Column(name = "create_timestamp")
87
    private LocalDateTime createdTimestamp = LocalDateTime.now();
88
 
89
    @Column(name = "rescheduled_timestamp")
90
    private LocalDateTime rescheduledTimestamp;
91
 
92
    public int getId() {
93
        return id;
94
    }
95
 
96
    public void setId(int id) {
97
        this.id = id;
98
    }
99
 
100
    public int getAgentId() {
101
        return agentId;
102
    }
103
 
104
    public void setAgentId(int agentId) {
105
        this.agentId = agentId;
106
    }
107
 
108
    public String getMobile() {
109
        return mobile;
110
    }
111
 
112
    public void setMobile(String mobile) {
113
        this.mobile = mobile;
114
    }
115
 
116
    public UpSaleCallStatus getStatus() {
117
        return status;
118
    }
119
 
120
    public void setStatus(UpSaleCallStatus status) {
121
        this.status = status;
122
    }
123
 
124
    public LocalDateTime getCreatedTimestamp() {
125
        return createdTimestamp;
126
    }
127
 
128
    public void setCreatedTimestamp(LocalDateTime createdTimestamp) {
129
        this.createdTimestamp = createdTimestamp;
130
    }
131
 
132
    public int getOriginalOrderId() {
133
        return originalOrderId;
134
    }
135
 
136
    public void setOriginalOrderId(int originalOrderId) {
137
        this.originalOrderId = originalOrderId;
138
    }
139
 
140
    public LocalDateTime getRescheduledTimestamp() {
141
        return rescheduledTimestamp;
142
    }
143
 
144
    public void setRescheduledTimestamp(LocalDateTime rescheduledTimestamp) {
145
        this.rescheduledTimestamp = rescheduledTimestamp;
146
    }
147
 
148
    @Override
149
    public String toString() {
150
        return "UpSaleCall{" +
151
                "id=" + id +
152
                ", agentId=" + agentId +
153
                ", originalOrderId=" + originalOrderId +
154
                ", mobile='" + mobile + '\'' +
155
                ", status=" + status +
156
                ", createdTimestamp=" + createdTimestamp +
157
                ", rescheduledTimestamp=" + rescheduledTimestamp +
158
                '}';
159
    }
160
 
161
 
162
    @Override
163
    public boolean equals(Object o) {
164
        if (this == o) return true;
165
        if (o == null || getClass() != o.getClass()) return false;
166
        UpSaleCall that = (UpSaleCall) o;
167
        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);
168
    }
169
 
170
    @Override
171
    public int hashCode() {
172
        return Objects.hash(id, agentId, originalOrderId, mobile, status, createdTimestamp, rescheduledTimestamp);
173
    }
174
}