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