| 3339 |
mandeep.dh |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.serving.controllers;
|
|
|
5 |
|
|
|
6 |
import in.shop2020.crm.Activity;
|
|
|
7 |
import in.shop2020.crm.ActivityType;
|
|
|
8 |
import in.shop2020.crm.Agent;
|
|
|
9 |
import in.shop2020.thrift.clients.HelperClient;
|
|
|
10 |
import in.shop2020.util.CRMConstants;
|
|
|
11 |
import in.shop2020.utils.HelperService.Client;
|
|
|
12 |
|
|
|
13 |
import java.util.List;
|
|
|
14 |
|
|
|
15 |
import org.apache.thrift.TException;
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* @author mandeep
|
|
|
19 |
*
|
|
|
20 |
*/
|
|
|
21 |
public class ActivityController extends BaseController {
|
|
|
22 |
/**
|
|
|
23 |
*
|
|
|
24 |
*/
|
|
|
25 |
private static final long serialVersionUID = 1L;
|
|
|
26 |
private List<Activity> activities;
|
|
|
27 |
private String description;
|
|
|
28 |
private String type;
|
|
|
29 |
private String subject;
|
|
|
30 |
private String body;
|
|
|
31 |
private String userEmailId;
|
|
|
32 |
private String customerMobileNumber;
|
|
|
33 |
private String creatorId;
|
|
|
34 |
|
|
|
35 |
public String index() {
|
|
|
36 |
createServiceClients();
|
|
|
37 |
try {
|
|
|
38 |
if (creatorId != null && !creatorId.isEmpty()) {
|
|
|
39 |
activities = crmServiceClient.getActivitiesByCreator(Long
|
|
|
40 |
.parseLong(creatorId));
|
|
|
41 |
} else {
|
|
|
42 |
activities = crmServiceClient
|
|
|
43 |
.getActivitiesByCreator(crmServiceClient
|
|
|
44 |
.getAgentByEmailId(currentAgentEmailId).getId());
|
|
|
45 |
}
|
|
|
46 |
} catch (TException e) {
|
|
|
47 |
log.error("Error while retrieving activities for "
|
|
|
48 |
+ currentAgentEmailId, e);
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
return INDEX;
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
public String create() throws Exception {
|
|
|
55 |
createServiceClients();
|
|
|
56 |
|
|
|
57 |
Activity activity = new Activity();
|
|
|
58 |
activity.setDescription(description);
|
|
|
59 |
activity.setType(ActivityType.valueOf(type));
|
|
|
60 |
activity.setCreatorId(crmServiceClient.getAgentByEmailId(
|
|
|
61 |
currentAgentEmailId).getId());
|
|
|
62 |
|
|
|
63 |
if (customerMobileNumber != null && !customerMobileNumber.isEmpty()) {
|
|
|
64 |
activity.setCustomerMobileNumber(customerMobileNumber);
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
if (ActivityType.SEND_EMAIL_TO_CUSTOMER.equals(activity.getType())) {
|
|
|
68 |
log.info("Sending mail");
|
|
|
69 |
Client helperClient = new HelperClient().getClient();
|
|
|
70 |
activity.setEmailId(helperClient.saveUserEmailForSending(
|
|
|
71 |
userEmailId, CRMConstants.CRM_EMAIL_SENDOR, subject, body,
|
|
|
72 |
null, CRMConstants.CRM_EMAIL_TYPE));
|
|
|
73 |
|
|
|
74 |
activity.setDescription("Subject: " + subject + "\n\n" + "Body: "
|
|
|
75 |
+ body);
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
crmServiceClient.insertActivity(activity);
|
|
|
79 |
|
|
|
80 |
return index();
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
public ActivityType[] getActivityTypes() {
|
|
|
84 |
return ActivityType.values();
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
public Agent getAgent(long agentId) throws TException {
|
|
|
88 |
return crmServiceClient.getAgent(agentId);
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
public String getDescription() {
|
|
|
92 |
return description;
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
public void setDescription(String description) {
|
|
|
96 |
this.description = description;
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
public String getType() {
|
|
|
100 |
return type;
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
public void setType(String type) {
|
|
|
104 |
this.type = type;
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
public String getSubject() {
|
|
|
108 |
return subject;
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
public void setSubject(String subject) {
|
|
|
112 |
this.subject = subject;
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
public String getBody() {
|
|
|
116 |
return body;
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
public void setBody(String body) {
|
|
|
120 |
this.body = body;
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
public String getUserEmailId() {
|
|
|
124 |
return userEmailId;
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
public void setUserEmailId(String userEmailId) {
|
|
|
128 |
this.userEmailId = userEmailId;
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
public String getCustomerMobileNumber() {
|
|
|
132 |
return customerMobileNumber;
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
public void setCustomerMobileNumber(String customerMobileNumber) {
|
|
|
136 |
this.customerMobileNumber = customerMobileNumber;
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
public List<Activity> getActivities() {
|
|
|
140 |
return activities;
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
public String getCreatorId() {
|
|
|
144 |
return creatorId;
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
public void setCreatorId(String creatorId) {
|
|
|
148 |
this.creatorId = creatorId;
|
|
|
149 |
}
|
|
|
150 |
}
|