| Line 1... |
Line 1... |
| 1 |
package in.shop2020.serving.services;
|
1 |
package in.shop2020.serving.services;
|
| 2 |
|
2 |
|
| 3 |
import in.shop2020.logistics.Provider;
|
3 |
import in.shop2020.logistics.Provider;
|
| 4 |
import in.shop2020.model.v1.order.Order;
|
4 |
import in.shop2020.model.v1.order.Order;
|
| - |
|
5 |
import in.shop2020.model.v1.order.OrderStatus;
|
| - |
|
6 |
import in.shop2020.model.v1.order.OrderStatusGroups;
|
| 5 |
import in.shop2020.model.v1.user.Address;
|
7 |
import in.shop2020.model.v1.user.Address;
|
| 6 |
import in.shop2020.model.v1.user.User;
|
8 |
import in.shop2020.model.v1.user.User;
|
| 7 |
import in.shop2020.model.v1.user.UserContextException;
|
9 |
import in.shop2020.model.v1.user.UserContextException;
|
| 8 |
import in.shop2020.serving.utils.FormattingUtils;
|
10 |
import in.shop2020.serving.utils.FormattingUtils;
|
| 9 |
import in.shop2020.serving.utils.Utils;
|
11 |
import in.shop2020.serving.utils.Utils;
|
| Line 166... |
Line 168... |
| 166 |
|
168 |
|
| 167 |
return getHtmlFromVelocity(templateFile, context);
|
169 |
return getHtmlFromVelocity(templateFile, context);
|
| 168 |
}
|
170 |
}
|
| 169 |
|
171 |
|
| 170 |
|
172 |
|
| 171 |
public String getOrderDetailsHtml(long orderId, long userId) {
|
173 |
public String getOrderDetailsHtml(long orderId, UserSessionInfo userinfo) {
|
| - |
|
174 |
long userId = userinfo.getUserId();
|
| 172 |
String htmlString = "";
|
175 |
String htmlString = "";
|
| 173 |
VelocityContext context = new VelocityContext();
|
176 |
VelocityContext context = new VelocityContext();
|
| 174 |
String templateFile = "templates/orderdetails.vm";
|
177 |
String templateFile = "templates/orderdetails.vm";
|
| 175 |
Order order = null;
|
178 |
Order order = null;
|
| 176 |
Date orderedOn = null, deliveryEstimate = null;
|
179 |
Date orderedOn = null, deliveryEstimate = null;
|
| 177 |
Provider provider = null;
|
180 |
Provider provider = null;
|
| 178 |
List<Address> addresses = null;
|
181 |
List<Address> addresses = null;
|
| 179 |
Long defaultAddressId = null;
|
182 |
Long defaultAddressId = null;
|
| - |
|
183 |
boolean initiateOrderCancelation = false;
|
| - |
|
184 |
boolean requestOrderCancelation = false;
|
| - |
|
185 |
OrderStatusGroups Groups = new OrderStatusGroups();
|
| - |
|
186 |
List<OrderStatus> codCancellable = Groups.getCodCancellable();
|
| - |
|
187 |
List<OrderStatus> prepaidCancellableBeforeBilled = Groups.getPrepaidCancellableBeforeBilled();
|
| - |
|
188 |
List<OrderStatus> prepaidCancellableAfterBilled = Groups.getPrepaidCancellableAfterBilled();
|
| 180 |
|
189 |
|
| 181 |
try{
|
190 |
try{
|
| 182 |
TransactionClient transactionServiceClient = new TransactionClient();
|
191 |
TransactionClient transactionServiceClient = new TransactionClient();
|
| 183 |
in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();
|
192 |
in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();
|
| 184 |
order = orderClient.getOrderForCustomer(orderId, userId);
|
193 |
order = orderClient.getOrderForCustomer(orderId, userId);
|
| 185 |
orderedOn = new Date(order.getCreated_timestamp());
|
194 |
orderedOn = new Date(order.getCreated_timestamp());
|
| 186 |
deliveryEstimate = new Date(order.getExpected_delivery_time());
|
195 |
deliveryEstimate = new Date(order.getExpected_delivery_time());
|
| - |
|
196 |
|
| - |
|
197 |
if(order.isCod()){
|
| - |
|
198 |
if(codCancellable.contains(order.getStatus())){
|
| - |
|
199 |
initiateOrderCancelation = true;
|
| - |
|
200 |
}
|
| - |
|
201 |
}
|
| - |
|
202 |
else {
|
| - |
|
203 |
if(prepaidCancellableBeforeBilled.contains(order.getStatus())){
|
| - |
|
204 |
initiateOrderCancelation = true;
|
| - |
|
205 |
}
|
| - |
|
206 |
else if(prepaidCancellableAfterBilled.contains(order.getStatus())){
|
| - |
|
207 |
requestOrderCancelation = true;
|
| - |
|
208 |
}
|
| - |
|
209 |
}
|
| 187 |
|
210 |
|
| 188 |
in.shop2020.model.v1.user.UserContextService.Client userClient = new UserClient().getClient();
|
211 |
in.shop2020.model.v1.user.UserContextService.Client userClient = new UserClient().getClient();
|
| 189 |
addresses = userClient.getAllAddressesForUser(userId);
|
212 |
addresses = userClient.getAllAddressesForUser(userId);
|
| 190 |
defaultAddressId = userClient.getDefaultAddressId(userId);
|
213 |
defaultAddressId = userClient.getDefaultAddressId(userId);
|
| 191 |
logger.info("Found addresses: " + addresses + " for userId: " + userId);
|
214 |
logger.info("Found addresses: " + addresses + " for userId: " + userId);
|
| Line 205... |
Line 228... |
| 205 |
context.put("order", order);
|
228 |
context.put("order", order);
|
| 206 |
context.put("orderedOn", dateformat.format(orderedOn));
|
229 |
context.put("orderedOn", dateformat.format(orderedOn));
|
| 207 |
context.put("deliveryEstimate", dateformat1.format(deliveryEstimate));
|
230 |
context.put("deliveryEstimate", dateformat1.format(deliveryEstimate));
|
| 208 |
context.put("addresses", addresses);
|
231 |
context.put("addresses", addresses);
|
| 209 |
context.put("defaultAddressId", defaultAddressId);
|
232 |
context.put("defaultAddressId", defaultAddressId);
|
| - |
|
233 |
context.put("userinfo", userinfo);
|
| - |
|
234 |
context.put("initiateOrderCancelation", initiateOrderCancelation);
|
| - |
|
235 |
context.put("requestOrderCancelation", requestOrderCancelation);
|
| 210 |
|
236 |
|
| 211 |
if(provider!=null){
|
237 |
if(provider!=null){
|
| 212 |
context.put("providerName", provider.getName());
|
238 |
context.put("providerName", provider.getName());
|
| 213 |
}
|
239 |
}
|
| 214 |
|
240 |
|