| 569 |
rajveer |
1 |
package in.shop2020.serving.controllers;
|
|
|
2 |
|
| 1170 |
varun.gupt |
3 |
import java.text.ParseException;
|
| 569 |
rajveer |
4 |
import java.util.ArrayList;
|
|
|
5 |
import java.util.List;
|
|
|
6 |
|
| 1170 |
varun.gupt |
7 |
import in.shop2020.model.v1.user.UserContextException;
|
|
|
8 |
import in.shop2020.model.v1.user.UserContextService;
|
| 569 |
rajveer |
9 |
import in.shop2020.serving.controllers.BaseController;
|
|
|
10 |
import in.shop2020.thrift.clients.HelperServiceClient;
|
| 1170 |
varun.gupt |
11 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
|
|
12 |
import in.shop2020.serving.utils.UserMessage;
|
| 569 |
rajveer |
13 |
|
| 832 |
rajveer |
14 |
import org.apache.log4j.Logger;
|
| 569 |
rajveer |
15 |
import org.apache.struts2.rest.DefaultHttpHeaders;
|
|
|
16 |
import org.apache.struts2.rest.HttpHeaders;
|
|
|
17 |
|
| 980 |
vikas |
18 |
public class ContactUsController extends BaseController{
|
| 569 |
rajveer |
19 |
|
|
|
20 |
private static final long serialVersionUID = 1L;
|
| 832 |
rajveer |
21 |
private static Logger log = Logger.getLogger(Class.class);
|
| 1170 |
varun.gupt |
22 |
/* private static String customerCareMailId = "help@saholic.com";
|
| 569 |
rajveer |
23 |
private String userMailId;
|
| 1170 |
varun.gupt |
24 |
|
| 894 |
rajveer |
25 |
static {
|
|
|
26 |
try {
|
|
|
27 |
customerCareMailId = ConfigClient.getClient().get("saholic_customer_care_mail");
|
|
|
28 |
} catch (ConfigException e) {
|
|
|
29 |
customerCareMailId = "help@saholic.com";
|
|
|
30 |
e.printStackTrace();
|
|
|
31 |
}
|
|
|
32 |
}
|
| 901 |
rajveer |
33 |
*/
|
| 1170 |
varun.gupt |
34 |
public ContactUsController(){
|
|
|
35 |
super();
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
// GET /Show Form
|
|
|
39 |
public HttpHeaders index() {
|
|
|
40 |
return new DefaultHttpHeaders("index").disableCaching();
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
// POST /Save Communication
|
|
|
44 |
public String create() {
|
|
|
45 |
long communicationType = -1;
|
|
|
46 |
long orderId = -1;
|
|
|
47 |
|
|
|
48 |
try {
|
|
|
49 |
boolean u = userinfo.isLoggedIn();
|
|
|
50 |
long userId = u ? userinfo.getUserId() : 0;
|
|
|
51 |
String email = request.getParameter("email");
|
|
|
52 |
communicationType = Integer.parseInt(request.getParameter("communication_type"));
|
|
|
53 |
orderId = Integer.parseInt(request.getParameter("order_id"));
|
|
|
54 |
String awb = request.getParameter("awb");
|
|
|
55 |
String product = request.getParameter("product");
|
|
|
56 |
String subject = request.getParameter("subject");
|
|
|
57 |
String message = request.getParameter("message");
|
|
|
58 |
|
|
|
59 |
UserContextService.Client userClient = (new UserContextServiceClient()).getClient();
|
|
|
60 |
|
|
|
61 |
if(userClient.saveUserCommunication(userId, email, communicationType, orderId, awb, product, subject, message)) {
|
|
|
62 |
System.out.println("User Communication saved successfully!");
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
} catch(NumberFormatException e) {
|
|
|
66 |
e.printStackTrace();
|
|
|
67 |
} catch (UserContextException e) {
|
|
|
68 |
e.printStackTrace();
|
|
|
69 |
} catch (Exception e) {
|
|
|
70 |
e.printStackTrace();
|
|
|
71 |
} finally {
|
|
|
72 |
|
| 569 |
rajveer |
73 |
}
|
|
|
74 |
|
| 1170 |
varun.gupt |
75 |
/* Mail mail = new Mail();
|
| 569 |
rajveer |
76 |
List<String> mailTo = new ArrayList<String>();
|
|
|
77 |
|
| 627 |
rajveer |
78 |
this.userMailId = request.getParameter("mailFrom");
|
|
|
79 |
String mailSubject = request.getParameter("mailSubject");
|
|
|
80 |
String mailBody = request.getParameter("mailBody");
|
| 569 |
rajveer |
81 |
mailTo.add(customerCareMailId);
|
|
|
82 |
|
|
|
83 |
mail.setSubject(mailSubject);
|
|
|
84 |
mail.setSender(userMailId);
|
|
|
85 |
mail.setTo(mailTo);
|
|
|
86 |
mail.setData(mailBody);
|
|
|
87 |
|
|
|
88 |
HelperServiceClient helperServiceClient;
|
|
|
89 |
try {
|
|
|
90 |
helperServiceClient = new HelperServiceClient();
|
|
|
91 |
helperServiceClient.getClient().sendMail(mail);
|
|
|
92 |
} catch (Exception e) {
|
|
|
93 |
log.error("Helper service not working properly. Error while sending mail to user.");
|
|
|
94 |
e.printStackTrace();
|
| 1170 |
varun.gupt |
95 |
}*/
|
| 569 |
rajveer |
96 |
|
|
|
97 |
return "success";
|
|
|
98 |
}
|
|
|
99 |
|
| 1170 |
varun.gupt |
100 |
public String getSuccessMsg() {
|
|
|
101 |
return UserMessage.USER_COMMUNICATION_SUCCESS;
|
| 569 |
rajveer |
102 |
}
|
|
|
103 |
}
|