Subversion Repositories SmartDukaan

Rev

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