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