| Line 12... |
Line 12... |
| 12 |
import in.shop2020.model.v1.order.OrderStatus;
|
12 |
import in.shop2020.model.v1.order.OrderStatus;
|
| 13 |
import in.shop2020.model.v1.order.TransactionService.Client;
|
13 |
import in.shop2020.model.v1.order.TransactionService.Client;
|
| 14 |
import in.shop2020.thrift.clients.CatalogClient;
|
14 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 15 |
import in.shop2020.thrift.clients.InventoryClient;
|
15 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 16 |
import in.shop2020.thrift.clients.TransactionClient;
|
16 |
import in.shop2020.thrift.clients.TransactionClient;
|
| - |
|
17 |
import in.shop2020.thrift.clients.LogisticsClient;
|
| 17 |
|
18 |
|
| 18 |
import java.io.ByteArrayOutputStream;
|
19 |
import java.io.ByteArrayOutputStream;
|
| 19 |
import java.io.File;
|
20 |
import java.io.File;
|
| 20 |
import java.io.FileNotFoundException;
|
21 |
import java.io.FileNotFoundException;
|
| 21 |
import java.io.FileOutputStream;
|
22 |
import java.io.FileOutputStream;
|
| Line 206... |
Line 207... |
| 206 |
*/
|
207 |
*/
|
| 207 |
public static Order getOrderFromThriftOrder(in.shop2020.model.v1.order.Order t_order) {
|
208 |
public static Order getOrderFromThriftOrder(in.shop2020.model.v1.order.Order t_order) {
|
| 208 |
LineItem lineItem = t_order.getLineitems().get(0);
|
209 |
LineItem lineItem = t_order.getLineitems().get(0);
|
| 209 |
String pickFromWarehouse = null;
|
210 |
String pickFromWarehouse = null;
|
| 210 |
Item item = null;
|
211 |
Item item = null;
|
| - |
|
212 |
|
| - |
|
213 |
Map<Long, Map<String, String>> acceptTogetherOrdersMap = null;
|
| - |
|
214 |
Map<Long, Map<String, String>> billTogetherOrdersMap = null;
|
| 211 |
|
215 |
|
| 212 |
try {
|
216 |
try {
|
| 213 |
in.shop2020.model.v1.catalog.CatalogService.Client client = new CatalogClient().getClient();
|
217 |
in.shop2020.model.v1.catalog.CatalogService.Client client = new CatalogClient().getClient();
|
| 214 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
218 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
| 215 |
item = client.getItem(lineItem.getItem_id());
|
219 |
item = client.getItem(lineItem.getItem_id());
|
| Line 217... |
Line 221... |
| 217 |
.get(t_order.getFulfilmentWarehouseId());
|
221 |
.get(t_order.getFulfilmentWarehouseId());
|
| 218 |
|
222 |
|
| 219 |
if (pickFromWarehouse == null) {
|
223 |
if (pickFromWarehouse == null) {
|
| 220 |
Warehouse warehouse = inventoryClient.getWarehouse(t_order.getFulfilmentWarehouseId());
|
224 |
Warehouse warehouse = inventoryClient.getWarehouse(t_order.getFulfilmentWarehouseId());
|
| 221 |
pickFromWarehouse = inventoryClient.getWarehouses(null, InventoryType.GOOD, warehouse.getVendor().getId(), t_order.getWarehouse_id(), 0).get(0).getDisplayName();
|
225 |
pickFromWarehouse = inventoryClient.getWarehouses(null, InventoryType.GOOD, warehouse.getVendor().getId(), t_order.getWarehouse_id(), 0).get(0).getDisplayName();
|
| - |
|
226 |
}
|
| - |
|
227 |
if(!t_order.isSetAccepted_timestamp()){
|
| - |
|
228 |
acceptTogetherOrdersMap = new HashMap<Long, Map<String, String>>();
|
| - |
|
229 |
Map<String, String> orderValuesMap = new HashMap<String, String>();
|
| - |
|
230 |
orderValuesMap.put("ProductName", getItemDisplayName(lineItem));
|
| - |
|
231 |
orderValuesMap.put("Quantity", lineItem.getQuantity()+"");
|
| - |
|
232 |
acceptTogetherOrdersMap.put(t_order.getId(), orderValuesMap);
|
| - |
|
233 |
List<in.shop2020.model.v1.order.Order> taOrders = new TransactionClient().getClient().getOrdersForTransaction(t_order.getTransactionId(), t_order.getCustomer_id());
|
| - |
|
234 |
in.shop2020.logistics.Provider provider = new LogisticsClient().getClient().getProvider(t_order.getLogistics_provider_id());
|
| - |
|
235 |
for(in.shop2020.model.v1.order.Order taOrder : taOrders){
|
| - |
|
236 |
LineItem lineItem1 = taOrder.getLineitems().get(0);
|
| - |
|
237 |
if(t_order.getId()==taOrder.getId()){
|
| - |
|
238 |
continue;
|
| - |
|
239 |
}else{
|
| - |
|
240 |
orderValuesMap = new HashMap<String, String>();
|
| - |
|
241 |
if(provider.isGroupShipmentAllowed() && !taOrder.isSetAccepted_timestamp() && t_order.getStatus()==taOrder.getStatus() && taOrder.getLogistics_provider_id()==t_order.getLogistics_provider_id() && taOrder.isLogisticsCod()==t_order.isLogisticsCod() && taOrder.getWarehouse_id() == t_order.getWarehouse_id() && taOrder.getOrderType() == t_order.getOrderType()){
|
| - |
|
242 |
orderValuesMap.put("ProductName", getItemDisplayName(lineItem1));
|
| - |
|
243 |
orderValuesMap.put("Quantity", lineItem1.getQuantity()+"");
|
| - |
|
244 |
}
|
| - |
|
245 |
if(orderValuesMap!=null && orderValuesMap.size()>0){
|
| - |
|
246 |
acceptTogetherOrdersMap.put(taOrder.getId(), orderValuesMap);
|
| - |
|
247 |
}
|
| - |
|
248 |
}
|
| - |
|
249 |
}
|
| - |
|
250 |
}
|
| - |
|
251 |
|
| - |
|
252 |
if(t_order.isSetLogisticsTransactionId()){
|
| - |
|
253 |
billTogetherOrdersMap = new HashMap<Long, Map<String, String>>();
|
| - |
|
254 |
Map<String, String> orderValuesMap = new HashMap<String, String>();
|
| - |
|
255 |
orderValuesMap.put("ProductName", getItemDisplayName(lineItem));
|
| - |
|
256 |
orderValuesMap.put("Quantity", lineItem.getQuantity()+"");
|
| - |
|
257 |
if(ItemType.SERIALIZED==item.getType()){
|
| - |
|
258 |
orderValuesMap.put("IsSerialized", "true");
|
| - |
|
259 |
}else{
|
| - |
|
260 |
orderValuesMap.put("IsSerialized", "false");
|
| - |
|
261 |
}
|
| - |
|
262 |
if(t_order.isSetFreebieItemId() && t_order.getFreebieItemId()!=0){
|
| - |
|
263 |
orderValuesMap.put("IsFreebie", "true");
|
| - |
|
264 |
} else {
|
| - |
|
265 |
orderValuesMap.put("IsFreebie", "false");
|
| - |
|
266 |
}
|
| - |
|
267 |
billTogetherOrdersMap.put(t_order.getId(), orderValuesMap);
|
| - |
|
268 |
Map<Long, Item> orderItemMap = new HashMap<Long, Item>();
|
| - |
|
269 |
List<in.shop2020.model.v1.order.Order> taOrders = new TransactionClient().getClient().getGroupOrdersByLogisticsTxnId(t_order.getLogisticsTransactionId());
|
| - |
|
270 |
for(in.shop2020.model.v1.order.Order ord1: taOrders){
|
| - |
|
271 |
if(ord1.getId()== t_order.getId()){
|
| - |
|
272 |
orderItemMap.put(ord1.getId(), item);
|
| - |
|
273 |
} else {
|
| - |
|
274 |
if(!client.isAlive()){
|
| - |
|
275 |
client = new CatalogClient().getClient();
|
| - |
|
276 |
}
|
| - |
|
277 |
Item it = client.getItem(ord1.getLineitems().get(0).getItem_id());
|
| - |
|
278 |
orderItemMap.put(ord1.getId(), it);
|
| - |
|
279 |
}
|
| - |
|
280 |
}
|
| - |
|
281 |
|
| - |
|
282 |
for(in.shop2020.model.v1.order.Order taOrder: taOrders){
|
| - |
|
283 |
if(taOrder.getId()==t_order.getId()){
|
| - |
|
284 |
continue;
|
| - |
|
285 |
} else {
|
| - |
|
286 |
orderValuesMap = new HashMap<String, String>();
|
| - |
|
287 |
Item orderItem = orderItemMap.get(taOrder.getId());
|
| - |
|
288 |
orderValuesMap.put("ProductName", getProductName(orderItem));
|
| - |
|
289 |
orderValuesMap.put("Quantity", taOrder.getLineitems().get(0).getQuantity()+"");
|
| - |
|
290 |
if(ItemType.SERIALIZED==item.getType()){
|
| - |
|
291 |
orderValuesMap.put("IsSerialized", "true");
|
| - |
|
292 |
}else{
|
| - |
|
293 |
orderValuesMap.put("IsSerialized", "false");
|
| - |
|
294 |
}
|
| - |
|
295 |
if(taOrder.isSetFreebieItemId() && taOrder.getFreebieItemId()!=0){
|
| - |
|
296 |
orderValuesMap.put("IsFreebie", "true");
|
| - |
|
297 |
} else {
|
| - |
|
298 |
orderValuesMap.put("IsFreebie", "false");
|
| - |
|
299 |
}
|
| - |
|
300 |
billTogetherOrdersMap.put(taOrder.getId(), orderValuesMap);
|
| - |
|
301 |
}
|
| - |
|
302 |
}
|
| - |
|
303 |
}
|
| - |
|
304 |
else{
|
| - |
|
305 |
billTogetherOrdersMap = new HashMap<Long, Map<String, String>>();
|
| - |
|
306 |
Map<String, String> orderValuesMap = new HashMap<String, String>();
|
| - |
|
307 |
orderValuesMap.put("ProductName", getItemDisplayName(lineItem));
|
| - |
|
308 |
orderValuesMap.put("Quantity", lineItem.getQuantity()+"");
|
| - |
|
309 |
if(ItemType.SERIALIZED==item.getType()){
|
| - |
|
310 |
orderValuesMap.put("IsSerialized", "true");
|
| - |
|
311 |
}else{
|
| - |
|
312 |
orderValuesMap.put("IsSerialized", "false");
|
| - |
|
313 |
}
|
| - |
|
314 |
if(t_order.isSetFreebieItemId() && t_order.getFreebieItemId()!=0){
|
| - |
|
315 |
orderValuesMap.put("IsFreebie", "true");
|
| - |
|
316 |
} else {
|
| - |
|
317 |
orderValuesMap.put("IsFreebie", "false");
|
| - |
|
318 |
}
|
| - |
|
319 |
billTogetherOrdersMap.put(t_order.getId(), orderValuesMap);
|
| 222 |
}
|
320 |
}
|
| 223 |
}
|
321 |
}
|
| 224 |
catch (Exception e) {
|
322 |
catch (Exception e) {
|
| 225 |
logger.error("Error looking up warehouse: " + t_order.getVendorId(), e);
|
323 |
logger.error("Error looking up warehouse: " + t_order.getVendorId(), e);
|
| 226 |
}
|
324 |
}
|
| Line 280... |
Line 378... |
| 280 |
t_order.getFulfilmentWarehouseId(),
|
378 |
t_order.getFulfilmentWarehouseId(),
|
| 281 |
t_order.getWarehouse_id(),
|
379 |
t_order.getWarehouse_id(),
|
| 282 |
t_order.getPickupStoreId(),
|
380 |
t_order.getPickupStoreId(),
|
| 283 |
t_order.getFreebieItemId(),
|
381 |
t_order.getFreebieItemId(),
|
| 284 |
osource,
|
382 |
osource,
|
| 285 |
new Long(t_order.getProductCondition().getValue()));
|
383 |
new Long(t_order.getProductCondition().getValue()),
|
| - |
|
384 |
t_order.getTransactionId());
|
| - |
|
385 |
if(acceptTogetherOrdersMap!=null && acceptTogetherOrdersMap.size()>0){
|
| - |
|
386 |
order.setAcceptTogetherOrdersMap(acceptTogetherOrdersMap);
|
| - |
|
387 |
}
|
| - |
|
388 |
if(billTogetherOrdersMap!=null && billTogetherOrdersMap.size()>0){
|
| - |
|
389 |
order.setBillTogetherOrdersMap(billTogetherOrdersMap);
|
| - |
|
390 |
}
|
| - |
|
391 |
if(t_order.isSetLogisticsTransactionId()){
|
| - |
|
392 |
order.setLogisticsTransactionId(t_order.getLogisticsTransactionId());
|
| - |
|
393 |
}
|
| 286 |
return order;
|
394 |
return order;
|
| 287 |
}
|
395 |
}
|
| 288 |
|
396 |
|
| 289 |
/**
|
397 |
/**
|
| 290 |
* Queries the transction server to get the list of all return orders that
|
398 |
* Queries the transction server to get the list of all return orders that
|
| Line 480... |
Line 588... |
| 480 |
default:
|
588 |
default:
|
| 481 |
break;
|
589 |
break;
|
| 482 |
}
|
590 |
}
|
| 483 |
return statuses;
|
591 |
return statuses;
|
| 484 |
}
|
592 |
}
|
| - |
|
593 |
|
| - |
|
594 |
public static List<Long> getEligibleOrdersToBeAccepted(Order order){
|
| - |
|
595 |
List<Long> orders = new ArrayList<Long>();
|
| - |
|
596 |
try {
|
| - |
|
597 |
|
| - |
|
598 |
TransactionClient client = new TransactionClient();
|
| - |
|
599 |
Client c = client.getClient();
|
| - |
|
600 |
|
| - |
|
601 |
in.shop2020.model.v1.order.Order thriftOrder = c.getOrder(order.getOrderId());
|
| - |
|
602 |
long provider_id = thriftOrder.getLogistics_provider_id();
|
| - |
|
603 |
boolean cod = thriftOrder.isLogisticsCod();
|
| - |
|
604 |
|
| - |
|
605 |
List<in.shop2020.model.v1.order.Order> torders = c.getOrdersForTransaction(thriftOrder.getTransactionId(), thriftOrder.getCustomer_id());
|
| - |
|
606 |
for(in.shop2020.model.v1.order.Order torder: torders){
|
| - |
|
607 |
if(torder.getLogistics_provider_id() == provider_id && torder.isLogisticsCod() == cod){
|
| - |
|
608 |
orders.add(torder.getId());
|
| - |
|
609 |
}
|
| - |
|
610 |
}
|
| - |
|
611 |
|
| - |
|
612 |
}catch(Exception e){
|
| - |
|
613 |
e.printStackTrace();
|
| - |
|
614 |
}
|
| - |
|
615 |
return orders;
|
| - |
|
616 |
}
|
| - |
|
617 |
|
| - |
|
618 |
public static String getItemDisplayName(LineItem lineitem){
|
| - |
|
619 |
StringBuffer itemName = new StringBuffer();
|
| - |
|
620 |
if (lineitem.getBrand() != null)
|
| - |
|
621 |
itemName.append(lineitem.getBrand() + " ");
|
| - |
|
622 |
if (lineitem.getModel_name() != null)
|
| - |
|
623 |
itemName.append(lineitem.getModel_name() + " ");
|
| - |
|
624 |
if (lineitem.getModel_number() != null)
|
| - |
|
625 |
itemName.append(lineitem.getModel_number() + " ");
|
| - |
|
626 |
if (lineitem.getColor() != null
|
| - |
|
627 |
&& !lineitem.getColor().trim().equals("NA"))
|
| - |
|
628 |
itemName.append("(" + lineitem.getColor() + ")");
|
| - |
|
629 |
|
| - |
|
630 |
return itemName.toString();
|
| - |
|
631 |
}
|
| - |
|
632 |
|
| - |
|
633 |
public static String getProductName(in.shop2020.model.v1.catalog.Item item){
|
| - |
|
634 |
StringBuffer itemName = new StringBuffer();
|
| - |
|
635 |
if (item.getBrand() != null)
|
| - |
|
636 |
itemName.append(item.getBrand() + " ");
|
| - |
|
637 |
if (item.getModelName() != null)
|
| - |
|
638 |
itemName.append(item.getModelName() + " ");
|
| - |
|
639 |
if (item.getModelNumber() != null)
|
| - |
|
640 |
itemName.append(item.getModelNumber() + " ");
|
| - |
|
641 |
if (item.getColor() != null
|
| - |
|
642 |
&& !item.getColor().trim().equals("NA"))
|
| - |
|
643 |
itemName.append("(" + item.getColor() + ")");
|
| - |
|
644 |
|
| - |
|
645 |
return itemName.toString();
|
| - |
|
646 |
}
|
| 485 |
}
|
647 |
}
|