| Line 2... |
Line 2... |
| 2 |
Created on 29-Mar-2010
|
2 |
Created on 29-Mar-2010
|
| 3 |
|
3 |
|
| 4 |
@author: ashish
|
4 |
@author: ashish
|
| 5 |
'''
|
5 |
'''
|
| 6 |
from string import Template
|
6 |
from string import Template
|
| 7 |
from email.mime.multipart import MIMEMultipart
|
- |
|
| 8 |
from shop2020.thriftpy.utils.ttypes import HelperServiceException, Mail
|
7 |
from shop2020.thriftpy.utils.ttypes import HelperServiceException, Mail
|
| 9 |
from email.mime.base import MIMEBase
|
- |
|
| 10 |
from email import encoders
|
- |
|
| 11 |
from email.mime.text import MIMEText
|
- |
|
| 12 |
import os
|
- |
|
| 13 |
import smtplib
|
- |
|
| 14 |
import time
|
- |
|
| 15 |
from time import strftime
|
- |
|
| 16 |
|
8 |
|
| 17 |
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem,\
|
9 |
from shop2020.model.v1.order.impl.DataService import Transaction, LineItem,\
|
| 18 |
Alerts, Order, BatchNoGenerator
|
10 |
Alerts, Order, BatchNoGenerator
|
| 19 |
from shop2020.thriftpy.model.v1.order.ttypes import Transaction as T_Transaction,\
|
11 |
from shop2020.thriftpy.model.v1.order.ttypes import Transaction as T_Transaction,\
|
| 20 |
TransactionServiceException, TransactionStatus, OrderStatus
|
12 |
TransactionServiceException, TransactionStatus, OrderStatus
|
| 21 |
import datetime
|
13 |
import datetime
|
| 22 |
from elixir import *
|
14 |
from elixir import *
|
| 23 |
from shop2020.utils.Utils import to_py_date, to_java_date
|
15 |
from shop2020.utils.Utils import to_py_date, to_java_date
|
| 24 |
from sqlalchemy.sql.expression import and_
|
16 |
from sqlalchemy.sql.expression import and_, or_
|
| 25 |
from shop2020.model.v1 import order
|
17 |
from shop2020.model.v1 import order
|
| 26 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
18 |
from shop2020.clients.LogisticsClient import LogisticsClient
|
| 27 |
from shop2020.clients.InventoryClient import InventoryClient
|
19 |
from shop2020.clients.InventoryClient import InventoryClient
|
| 28 |
from shop2020.clients.UserClient import UserClient
|
20 |
from shop2020.clients.UserClient import UserClient
|
| 29 |
from shop2020.clients.HelperClient import HelperClient
|
21 |
from shop2020.clients.HelperClient import HelperClient
|
| Line 279... |
Line 271... |
| 279 |
query = query.filter(Order.created_timestamp >from_date)
|
271 |
query = query.filter(Order.created_timestamp >from_date)
|
| 280 |
if to_date:
|
272 |
if to_date:
|
| 281 |
query = query.filter(Order.created_timestamp < to_date)
|
273 |
query = query.filter(Order.created_timestamp < to_date)
|
| 282 |
return query.all()
|
274 |
return query.all()
|
| 283 |
|
275 |
|
| - |
|
276 |
def get_returnable_orders_for_customer(customer_id, limit = None):
|
| - |
|
277 |
if not customer_id:
|
| - |
|
278 |
raise TransactionServiceException(101, "bad customer id")
|
| - |
|
279 |
|
| - |
|
280 |
query = Order.query.filter(Order.customer_id == customer_id)
|
| - |
|
281 |
query = query.filter(Order.status != OrderStatus.PAYMENT_FAILED)
|
| - |
|
282 |
query = query.filter(Order.status != OrderStatus.REJECTED)
|
| - |
|
283 |
query = query.filter(Order.status > OrderStatus.SHIPPED_FROM_WH)
|
| - |
|
284 |
query = query.filter(or_(Order.status < OrderStatus.DELIVERY_SUCCESS, Order.delivery_timestamp < datetime.datetime.now() + datetime.timedelta(hours = 48)))
|
| - |
|
285 |
orders = query.all()
|
| - |
|
286 |
order_ids = [order.id for order in orders]
|
| - |
|
287 |
return order_ids
|
| - |
|
288 |
|
| - |
|
289 |
def get_cancellable_orders_for_customer(customer_id, limit = None):
|
| - |
|
290 |
if not customer_id:
|
| - |
|
291 |
raise TransactionServiceException(101, "bad customer id")
|
| - |
|
292 |
|
| - |
|
293 |
query = Order.query.filter(Order.customer_id == customer_id)
|
| - |
|
294 |
query = query.filter(Order.status != OrderStatus.PAYMENT_FAILED)
|
| - |
|
295 |
query = query.filter(Order.status != OrderStatus.REJECTED)
|
| - |
|
296 |
query = query.filter(Order.status < OrderStatus.BILLED)
|
| - |
|
297 |
orders = query.all()
|
| - |
|
298 |
return [order.id for order in orders]
|
| - |
|
299 |
|
| 284 |
def get_orders_by_billing_date(status, start_billing_date, end_billing_date, warehouse_id):
|
300 |
def get_orders_by_billing_date(status, start_billing_date, end_billing_date, warehouse_id):
|
| 285 |
if not warehouse_id:
|
301 |
if not warehouse_id:
|
| 286 |
raise TransactionServiceException(101, "bad warehouse id")
|
302 |
raise TransactionServiceException(101, "bad warehouse id")
|
| 287 |
|
303 |
|
| 288 |
query = Order.query.filter(Order.warehouse_id == warehouse_id)
|
304 |
query = Order.query.filter(Order.warehouse_id == warehouse_id)
|