| Line 4... |
Line 4... |
| 4 |
@author: Chandranshu
|
4 |
@author: Chandranshu
|
| 5 |
'''
|
5 |
'''
|
| 6 |
|
6 |
|
| 7 |
from datetime import date, timedelta
|
7 |
from datetime import date, timedelta
|
| 8 |
from elixir import *
|
8 |
from elixir import *
|
| - |
|
9 |
from random import randrange
|
| 9 |
from reportlab.lib.units import inch
|
10 |
from reportlab.lib.units import inch
|
| 10 |
from reportlab.pdfgen.canvas import Canvas
|
11 |
from reportlab.pdfgen.canvas import Canvas
|
| 11 |
from reportlab.rl_config import defaultPageSize
|
12 |
from reportlab.rl_config import defaultPageSize
|
| - |
|
13 |
from shop2020.clients.AlertClient import AlertClient
|
| 12 |
from shop2020.clients.CatalogClient import CatalogClient
|
14 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 13 |
from shop2020.clients.HelperClient import HelperClient
|
15 |
from shop2020.clients.HelperClient import HelperClient
|
| 14 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
16 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
| 15 |
from shop2020.clients.PaymentClient import PaymentClient
|
17 |
from shop2020.clients.PaymentClient import PaymentClient
|
| 16 |
from shop2020.clients.UserClient import UserClient
|
18 |
from shop2020.clients.UserClient import UserClient
|
| Line 18... |
Line 20... |
| 18 |
from shop2020.model.v1 import order
|
20 |
from shop2020.model.v1 import order
|
| 19 |
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
|
21 |
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem, \
|
| 20 |
Order, BatchNoGenerator, InvoiceIDGenerator, TransactionRequiringExtraProcessing, \
|
22 |
Order, BatchNoGenerator, InvoiceIDGenerator, TransactionRequiringExtraProcessing, \
|
| 21 |
OrderInventory, Alert, PaymentSettlement, EBSSettlementSummary, \
|
23 |
OrderInventory, Alert, PaymentSettlement, EBSSettlementSummary, \
|
| 22 |
CodVerificationAgent, Attribute, RechargeVoucherTracker
|
24 |
CodVerificationAgent, Attribute, RechargeVoucherTracker
|
| 23 |
|
- |
|
| 24 |
from shop2020.model.v1.order.impl.model.ReturnOrder import ReturnOrder
|
25 |
from shop2020.model.v1.order.impl.model.ReturnOrder import ReturnOrder
|
| 25 |
from shop2020.thriftpy.generic.ttypes import ExceptionType
|
- |
|
| 26 |
from shop2020.thriftpy.alert.ttypes import MonitoredEntity, EntityType
|
26 |
from shop2020.thriftpy.alert.ttypes import MonitoredEntity, EntityType
|
| - |
|
27 |
from shop2020.thriftpy.generic.ttypes import ExceptionType
|
| 27 |
from shop2020.thriftpy.logistics.ttypes import DeliveryType, PickUpType
|
28 |
from shop2020.thriftpy.logistics.ttypes import DeliveryType, PickUpType
|
| 28 |
from shop2020.thriftpy.model.v1.catalog.ttypes import BillingType, \
|
29 |
from shop2020.thriftpy.model.v1.catalog.ttypes import BillingType, \
|
| 29 |
InventoryServiceException, WarehouseType, ItemType, InventoryType
|
30 |
InventoryServiceException, WarehouseType, ItemType, InventoryType
|
| 30 |
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
|
31 |
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
|
| 31 |
TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
|
32 |
TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
|
| 32 |
HotspotAction, TimeoutSummary, OrderStatusGroups, OrderType
|
33 |
HotspotAction, TimeoutSummary, OrderStatusGroups, OrderType
|
| - |
|
34 |
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType
|
| 33 |
from shop2020.thriftpy.payments.ttypes import PaymentException
|
35 |
from shop2020.thriftpy.payments.ttypes import PaymentException
|
| 34 |
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
|
36 |
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
|
| 35 |
WarehouseServiceException
|
37 |
WarehouseServiceException
|
| 36 |
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
|
38 |
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
|
| 37 |
from shop2020.utils.Utils import to_py_date, to_java_date
|
39 |
from shop2020.utils.Utils import to_py_date, to_java_date
|
| Line 44... |
Line 46... |
| 44 |
import logging
|
46 |
import logging
|
| 45 |
import os
|
47 |
import os
|
| 46 |
import sys
|
48 |
import sys
|
| 47 |
import time
|
49 |
import time
|
| 48 |
import traceback
|
50 |
import traceback
|
| 49 |
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType
|
- |
|
| 50 |
from random import randrange
|
- |
|
| 51 |
from shop2020.clients.AlertClient import AlertClient
|
- |
|
| - |
|
51 |
|
| 52 |
logging.basicConfig(level=logging.DEBUG)
|
52 |
logging.basicConfig(level=logging.DEBUG)
|
| 53 |
|
53 |
|
| 54 |
|
54 |
|
| 55 |
PREPAID_SHIPPING_CUTOFF_TIME = 15
|
55 |
PREPAID_SHIPPING_CUTOFF_TIME = 15
|
| 56 |
COD_SHIPPING_CUTOFF_TIME = 12
|
56 |
COD_SHIPPING_CUTOFF_TIME = 12
|
| Line 1983... |
Line 1983... |
| 1983 |
litem.dealText = line_item.dealText
|
1983 |
litem.dealText = line_item.dealText
|
| 1984 |
litem.order = new_order
|
1984 |
litem.order = new_order
|
| 1985 |
|
1985 |
|
| 1986 |
logistics_client = LogisticsClient().get_client()
|
1986 |
logistics_client = LogisticsClient().get_client()
|
| 1987 |
item_id = new_order.lineitems[0].item_id
|
1987 |
item_id = new_order.lineitems[0].item_id
|
| 1988 |
logistics_info = logistics_client.getLogisticsInfo(new_order.customer_pincode, item_id, is_cod) #TODO: We should be able to pass another flag to suggest ignoring the inventory situation.
|
1988 |
logistics_info = logistics_client.getLogisticsInfo(new_order.customer_pincode, item_id, is_cod, PickUpType.COURIER) #TODO: We should be able to pass another flag to suggest ignoring the inventory situation.
|
| 1989 |
logistics_info.deliveryTime = adjust_delivery_time(current_time, logistics_info.deliveryTime)
|
1989 |
logistics_info.deliveryTime = adjust_delivery_time(current_time, logistics_info.deliveryTime)
|
| 1990 |
new_order.warehouse_id = logistics_info.warehouseId
|
1990 |
new_order.warehouse_id = logistics_info.warehouseId
|
| 1991 |
new_order.fulfilmentWarehouseId = logistics_info.fulfilmentWarehouseId
|
1991 |
new_order.fulfilmentWarehouseId = logistics_info.fulfilmentWarehouseId
|
| 1992 |
new_order.logistics_provider_id = logistics_info.providerId
|
1992 |
new_order.logistics_provider_id = logistics_info.providerId
|
| 1993 |
new_order.airwaybill_no = logistics_info.airway_billno
|
1993 |
new_order.airwaybill_no = logistics_info.airway_billno
|
| Line 2366... |
Line 2366... |
| 2366 |
if order.cod:
|
2366 |
if order.cod:
|
| 2367 |
if not logistics_info.codAllowed:
|
2367 |
if not logistics_info.codAllowed:
|
| 2368 |
raise TransactionServiceException(2, 'COD service not available')
|
2368 |
raise TransactionServiceException(2, 'COD service not available')
|
| 2369 |
|
2369 |
|
| 2370 |
if logistics_info.providerId != order.logistics_provider_id:
|
2370 |
if logistics_info.providerId != order.logistics_provider_id:
|
| 2371 |
logistics_info = logistics_client.getLogisticsInfo(address.pin, order.lineitems[0].item_id, type)
|
2371 |
logistics_info = logistics_client.getLogisticsInfo(address.pin, order.lineitems[0].item_id, type, PickUpType.COURIER)
|
| 2372 |
order.tracking_id = logistics_info.airway_billno
|
2372 |
order.tracking_id = logistics_info.airway_billno
|
| 2373 |
order.airwaybill_no = logistics_info.airway_billno
|
2373 |
order.airwaybill_no = logistics_info.airway_billno
|
| 2374 |
order.logistics_provider_id = logistics_info.providerId
|
2374 |
order.logistics_provider_id = logistics_info.providerId
|
| 2375 |
|
2375 |
|
| 2376 |
current_time = datetime.datetime.now()
|
2376 |
current_time = datetime.datetime.now()
|