| 2674 |
vikas |
1 |
package in.shop2020.serving.controllers;
|
|
|
2 |
|
| 7572 |
anupam.sin |
3 |
import in.shop2020.model.v1.order.LineItem;
|
| 6153 |
anupam.sin |
4 |
import in.shop2020.model.v1.order.RechargeType;
|
| 3390 |
mandeep.dh |
5 |
import in.shop2020.serving.auth.CRMAuthorizingRealm;
|
| 6153 |
anupam.sin |
6 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 4689 |
anupam.sin |
7 |
import in.shop2020.util.CRMConstants;
|
|
|
8 |
import in.shop2020.util.CRMConstants.CODCancelMatrix;
|
| 7572 |
anupam.sin |
9 |
import in.shop2020.utils.ModelUtils;
|
| 3090 |
mandeep.dh |
10 |
|
|
|
11 |
import java.text.SimpleDateFormat;
|
|
|
12 |
import java.util.Date;
|
| 2674 |
vikas |
13 |
import java.util.Map;
|
|
|
14 |
|
|
|
15 |
import javax.servlet.http.HttpServletRequest;
|
|
|
16 |
import javax.servlet.http.HttpServletResponse;
|
|
|
17 |
import javax.servlet.http.HttpSession;
|
|
|
18 |
|
|
|
19 |
import org.apache.log4j.Logger;
|
| 3090 |
mandeep.dh |
20 |
import org.apache.shiro.SecurityUtils;
|
| 2674 |
vikas |
21 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
|
|
22 |
import org.apache.struts2.interceptor.ServletResponseAware;
|
|
|
23 |
import org.apache.struts2.interceptor.SessionAware;
|
| 3090 |
mandeep.dh |
24 |
import org.apache.thrift.TException;
|
| 2674 |
vikas |
25 |
|
|
|
26 |
import com.opensymphony.xwork2.ValidationAwareSupport;
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
* Base class for all user action handlers i.e. controllers
|
|
|
30 |
*
|
|
|
31 |
* @author Vikas
|
|
|
32 |
*/
|
|
|
33 |
public abstract class BaseController extends ValidationAwareSupport implements
|
|
|
34 |
ServletResponseAware, ServletRequestAware, SessionAware
|
|
|
35 |
{
|
|
|
36 |
private static final long serialVersionUID = 3339523094497219816L;
|
| 3090 |
mandeep.dh |
37 |
protected static Logger log = Logger.getLogger(BaseController.class);
|
|
|
38 |
|
|
|
39 |
protected static final String INPUT = "input";
|
|
|
40 |
protected static final String INDEX = "index";
|
|
|
41 |
protected static final String EDIT_NEW = "editNew";
|
|
|
42 |
protected static final String EDIT = "edit";
|
|
|
43 |
protected static final String SHOW = "show";
|
| 5909 |
amar.kumar |
44 |
protected static final String OPEN = "open";
|
| 3106 |
mandeep.dh |
45 |
protected static final String EXCEPTION = "exception";
|
| 6153 |
anupam.sin |
46 |
|
|
|
47 |
static Map<Long, String> providersMap;
|
| 3090 |
mandeep.dh |
48 |
|
|
|
49 |
protected final SimpleDateFormat SDF = new SimpleDateFormat("dd MMM, yyyy hh:mm a");
|
|
|
50 |
|
| 2674 |
vikas |
51 |
protected HttpServletResponse response;
|
|
|
52 |
protected HttpServletRequest request;
|
|
|
53 |
protected HttpSession session;
|
|
|
54 |
protected Map<String, Object> sessionMap;
|
|
|
55 |
|
| 3090 |
mandeep.dh |
56 |
// Clients used at many places
|
|
|
57 |
protected in.shop2020.model.v1.user.UserContextService.Client userContextServiceClient;
|
|
|
58 |
protected in.shop2020.model.v1.order.TransactionService.Client transactionServiceClient;
|
|
|
59 |
protected in.shop2020.crm.CRMService.Client crmServiceClient;
|
|
|
60 |
|
|
|
61 |
protected String currentAgentEmailId = (String) SecurityUtils.getSubject().getPrincipal();
|
|
|
62 |
|
| 2674 |
vikas |
63 |
public void setServletResponse(HttpServletResponse response) {
|
|
|
64 |
this.response = response;
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
public void setServletRequest(HttpServletRequest request) {
|
|
|
68 |
this.request = request;
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
public void setSession(Map<String, Object> sessionMap) {
|
|
|
72 |
this.session = request.getSession();
|
|
|
73 |
this.sessionMap = sessionMap;
|
|
|
74 |
}
|
| 3090 |
mandeep.dh |
75 |
|
| 6153 |
anupam.sin |
76 |
static {
|
|
|
77 |
TransactionClient tcl;
|
|
|
78 |
try {
|
|
|
79 |
tcl = new TransactionClient();
|
| 6206 |
rajveer |
80 |
providersMap = tcl.getClient().getServiceProviders(RechargeType.MOBILE, false);
|
|
|
81 |
providersMap.putAll(tcl.getClient().getServiceProviders(RechargeType.DTH, false));
|
| 6153 |
anupam.sin |
82 |
} catch (Exception e) {
|
|
|
83 |
log.error("Could not get providers", e);
|
|
|
84 |
}
|
|
|
85 |
}
|
|
|
86 |
|
| 3090 |
mandeep.dh |
87 |
/**
|
|
|
88 |
* Utility method to convert a date to a readable format
|
|
|
89 |
*/
|
| 3106 |
mandeep.dh |
90 |
public String convertDate(Long date) {
|
|
|
91 |
if (date == null || date == 0) {
|
| 3090 |
mandeep.dh |
92 |
return "N/A";
|
|
|
93 |
}
|
|
|
94 |
|
| 4144 |
mandeep.dh |
95 |
return SDF.format(new Date(date));
|
| 3090 |
mandeep.dh |
96 |
}
|
| 3106 |
mandeep.dh |
97 |
|
|
|
98 |
public String getCurrentAgentEmailId() {
|
|
|
99 |
return currentAgentEmailId;
|
|
|
100 |
}
|
| 7572 |
anupam.sin |
101 |
|
|
|
102 |
public String getProductName(LineItem lineItem) {
|
|
|
103 |
String name = ModelUtils.extractProductNameFromLineItem(lineItem);
|
| 3106 |
mandeep.dh |
104 |
|
| 7572 |
anupam.sin |
105 |
if (lineItem.getColor() != null && !lineItem.getColor().isEmpty()) {
|
|
|
106 |
name += "(" + lineItem.getColor() + ")";
|
|
|
107 |
}
|
|
|
108 |
|
|
|
109 |
return name;
|
|
|
110 |
}
|
|
|
111 |
|
| 3090 |
mandeep.dh |
112 |
public String getAgentName() throws TException
|
|
|
113 |
{
|
| 3390 |
mandeep.dh |
114 |
return CRMAuthorizingRealm.getAgent(currentAgentEmailId).getName();
|
| 3090 |
mandeep.dh |
115 |
}
|
|
|
116 |
|
| 3578 |
mandeep.dh |
117 |
public boolean canVerifyCOD() {
|
|
|
118 |
return SecurityUtils.getSubject().hasRole("Outbound");
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
public boolean canViewFailedPayments() {
|
|
|
122 |
return SecurityUtils.getSubject().hasRole("Outbound");
|
|
|
123 |
}
|
|
|
124 |
|
| 4008 |
mandeep.dh |
125 |
public boolean canViewDelayedDeliveries() {
|
|
|
126 |
return SecurityUtils.getSubject().hasRole("Outbound");
|
|
|
127 |
}
|
| 4267 |
anupam.sin |
128 |
|
|
|
129 |
public boolean canViewFlaggedPayments() {
|
| 6507 |
anupam.sin |
130 |
return SecurityUtils.getSubject().hasRole("Outbound");
|
| 4267 |
anupam.sin |
131 |
}
|
| 4490 |
anupam.sin |
132 |
|
|
|
133 |
public boolean canViewDoaRequests() {
|
|
|
134 |
return (SecurityUtils.getSubject().hasRole("Outbound") && SecurityUtils.getSubject().hasRole("TeamLead"));
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
public boolean canViewReturnRequests() {
|
|
|
138 |
return (SecurityUtils.getSubject().hasRole("Outbound") && SecurityUtils.getSubject().hasRole("TeamLead"));
|
|
|
139 |
}
|
| 4751 |
anupam.sin |
140 |
|
| 4793 |
amar.kumar |
141 |
public boolean canManageAgents() {
|
|
|
142 |
return (SecurityUtils.getSubject().hasRole("TeamLead"));
|
|
|
143 |
}
|
|
|
144 |
|
| 4751 |
anupam.sin |
145 |
public boolean canViewOrderCancellation() {
|
| 6507 |
anupam.sin |
146 |
return SecurityUtils.getSubject().hasRole("Outbound");
|
| 4751 |
anupam.sin |
147 |
}
|
| 5884 |
amar.kumar |
148 |
|
|
|
149 |
public boolean canViewStorePickupTickets() {
|
|
|
150 |
return (SecurityUtils.getSubject().hasRole("Outbound"));
|
|
|
151 |
}
|
| 4008 |
mandeep.dh |
152 |
|
| 5909 |
amar.kumar |
153 |
public boolean canViewAllOpenTickets() {
|
|
|
154 |
return (SecurityUtils.getSubject().hasRole("TeamLead")||SecurityUtils.getSubject().hasRole("Outbound"));
|
|
|
155 |
}
|
|
|
156 |
|
| 7372 |
kshitij.so |
157 |
public boolean canViewLowInventoryCancellation() {
|
|
|
158 |
return (SecurityUtils.getSubject().hasRole("TeamLead")||SecurityUtils.getSubject().hasRole("Outbound"));
|
|
|
159 |
}
|
|
|
160 |
|
| 7616 |
manish.sha |
161 |
//Start:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
|
|
|
162 |
public boolean canViewRTORefunds() {
|
|
|
163 |
return (SecurityUtils.getSubject().hasRole("TeamLead")||SecurityUtils.getSubject().hasRole("Outbound"));
|
|
|
164 |
}
|
|
|
165 |
//End:- Added By Manish Sharma for Creating a new Ticket: Category- RTO Refund on 21-Jun-2013
|
|
|
166 |
|
| 11890 |
kshitij.so |
167 |
public boolean canViewBulkOrderEnquiry() {
|
|
|
168 |
return (SecurityUtils.getSubject().hasRole("TeamLead"));
|
|
|
169 |
}
|
|
|
170 |
|
| 14882 |
manish.sha |
171 |
public boolean canViewProfitMandiTicket(){
|
| 15698 |
manish.sha |
172 |
return (SecurityUtils.getSubject().hasRole("TeamLead")||SecurityUtils.getSubject().hasRole("Outbound"));
|
| 14882 |
manish.sha |
173 |
}
|
|
|
174 |
|
| 3106 |
mandeep.dh |
175 |
public String editNew() {
|
|
|
176 |
return EDIT_NEW;
|
| 3090 |
mandeep.dh |
177 |
}
|
|
|
178 |
|
| 3106 |
mandeep.dh |
179 |
public String edit() {
|
|
|
180 |
return EDIT;
|
| 3090 |
mandeep.dh |
181 |
}
|
| 4689 |
anupam.sin |
182 |
|
|
|
183 |
public CODCancelMatrix[] getCODCancelMatrix () {
|
|
|
184 |
return CRMConstants.CODCancelMatrix.values();
|
|
|
185 |
}
|
| 3090 |
mandeep.dh |
186 |
}
|