Subversion Repositories SmartDukaan

Rev

Rev 5767 | Rev 5778 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5767 Rev 5776
Line 31... Line 31...
31
    TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
31
    TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
32
    HotspotAction, TimeoutSummary, OrderStatusGroups, OrderType
32
    HotspotAction, TimeoutSummary, OrderStatusGroups, OrderType
33
from shop2020.thriftpy.payments.ttypes import PaymentException
33
from shop2020.thriftpy.payments.ttypes import PaymentException
34
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
34
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
35
    WarehouseServiceException
35
    WarehouseServiceException
36
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
36
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part,\
-
 
37
    mail_html
37
from shop2020.utils.Utils import to_py_date, to_java_date
38
from shop2020.utils.Utils import to_py_date, to_java_date
38
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
39
from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
39
from sqlalchemy.sql import func
40
from sqlalchemy.sql import func
40
from sqlalchemy.sql.expression import and_, or_, desc, not_, distinct, select
41
from sqlalchemy.sql.expression import and_, or_, desc, not_, distinct, select
41
from string import Template
42
from string import Template
Line 336... Line 337...
336
    
337
    
337
    return delivery_days
338
    return delivery_days
338
 
339
 
339
def enqueue_transaction_info_email(transaction_id):
340
def enqueue_transaction_info_email(transaction_id):
340
    transaction = get_transaction(transaction_id)
341
    transaction = get_transaction(transaction_id)
341
    
342
    customer_name = "" 
342
    html_header = """
343
    html_header = """
343
<html>
344
<html>
344
<body>
345
<body>
345
<div>
346
<div>
346
    <p>
347
    <p>
347
        Hello,<br /><br />
348
        Hello $customer_name,<br /><br />
348
        Thanks for placing order with us. Following are the details of your order:
349
        Thanks for placing order with us. Following are the details of your order:
349
    </p>
350
    </p>
350
    <div>
351
    <div>
351
        Order Date: $order_date
352
        Order Date: $order_date
352
    </div>
353
    </div>
Line 370... Line 371...
370
 
371
 
371
    orders = transaction.orders
372
    orders = transaction.orders
372
    html_pickup_text = ""
373
    html_pickup_text = ""
373
    random_text = ""
374
    random_text = ""
374
    if orders[0].pickupStoreId:
375
    if orders[0].pickupStoreId:
375
        random_text = str(randrange(100000, 999999))
376
        random_text = str(randrange(100000, 999999)) 
376
        html_pickup_text =  "Secret code for your order is " + random_text + ". Please tell store manager this secret code to get the order. " 
-
 
377
                
377
                
378
    for order in orders:
378
    for order in orders:
-
 
379
        customer_name = order.customer_name
379
        order_date = order.created_timestamp
380
        order_date = order.created_timestamp
380
        user_email = order.customer_email
381
        user_email = order.customer_email
381
        html_tr = "<tr><td align='center'>" + str(order.id) + "</td>"
382
        html_tr = "<tr><td align='center'>" + str(order.id) + "</td>"
382
 
383
 
383
        if order.pickupStoreId:
384
        if order.pickupStoreId:
Line 405... Line 406...
405
            <td> Rs. $total_amount</td>
406
            <td> Rs. $total_amount</td>
406
        </tr>
407
        </tr>
407
        </table>
408
        </table>
408
    </div>
409
    </div>
409
    """
410
    """
-
 
411
    
-
 
412
    store_address = ""
-
 
413
    if orders[0].pickupStoreId:
-
 
414
        store = LogisticsClient().get_client().getPickupStore(orders[0].pickupStoreId)
-
 
415
        store_address = __get_store_address_html(store)
-
 
416
 
-
 
417
        html_pickup_text = html_pickup_text + """
-
 
418
        <h3>Steps to Pickup In Store</h3>
-
 
419
        1) Estimated arrival date of your product(s) is $store_delivery_date at your selected Store.<br>
-
 
420
        2) You will receive a confirmation email from us when your product(s) reaches the store. Once you receive the same, please visit the following store selected by you.<br>
-
 
421
        <br><i>$store_address</i><br>
-
 
422
        """
-
 
423
 
-
 
424
        if orders[0].cod:
-
 
425
            html_pickup_text = html_pickup_text + """
-
 
426
            3) Pay Rs. $total_amount, present a valid Photo Identity Proof* and use your Secret Code <b><i>$secret_code</i></b> to claim your Product(s).<br><br>
-
 
427
            *Valid Photo Identity Proof are Driving License, Passport, PAN Card, Voter ID, Company Issued ID Card, College issued Student ID Card Or any other Government approved Photo Id.<br>
-
 
428
            <br>
-
 
429
            In case you have any questions please visit <a href="www.saholic.com/static/buy-online-pickup-in-store">Details on Pickup in Store</a>. If you still have more questions feel free to contact us 24/7 via <a href="http://www.saholic.com/contact-us">http://www.saholic.com/contact-us</a>
-
 
430
            </br><hr />
-
 
431
            """
-
 
432
        else:
-
 
433
            html_pickup_text = html_pickup_text + """
-
 
434
            3) Present a valid Photo Identity Proof* and use your Secret Code <b><i>$secret_code</i></b> to claim your Product(s).<br><br>
-
 
435
            *Valid Photo Identity Proof are Driving License, Passport, PAN Card, Voter ID, Company Issued ID Card, College issued Student ID Card Or any other Government approved Photo Id.<br>
-
 
436
            <br>
-
 
437
            In case you have any questions please visit <a href="www.saholic.com/static/buy-online-pickup-in-store">Details on Pickup in Store</a>. If you still have more questions feel free to contact us 24/7 via <a href="http://www.saholic.com/contact-us">http://www.saholic.com/contact-us</a>
-
 
438
            </br><hr />
-
 
439
            """
-
 
440
            
410
    html_footer = html_footer + html_pickup_text + """
441
    html_footer = html_footer + html_pickup_text + """
411
    <p>
442
    <p>
412
        Best Wishes,<br />
443
        Best Wishes,<br />
413
        Saholic Team
444
        Saholic Team
414
    </p>
445
    </p>
Line 417... Line 448...
417
</html>
448
</html>
418
    """
449
    """
419
 
450
 
420
    dt = datetime.datetime.strptime(str(order_date), "%Y-%m-%d %H:%M:%S")
451
    dt = datetime.datetime.strptime(str(order_date), "%Y-%m-%d %H:%M:%S")
421
    formated_order_date = dt.strftime("%A, %d. %B %Y %I:%M%p")
452
    formated_order_date = dt.strftime("%A, %d. %B %Y %I:%M%p")
-
 
453
 
-
 
454
    sdt = datetime.datetime.strptime(str(orders[0].expected_delivery_time), "%Y-%m-%d %H:%M:%S")
-
 
455
    store_delivery_date = sdt.strftime("%A, %d %B %Y")
422
    
456
 
423
    email_header = Template(html_header).substitute(dict(order_date = formated_order_date))
457
    email_header = Template(html_header).substitute(dict(order_date = formated_order_date, customer_name = customer_name))
424
    email_footer = Template(html_footer).substitute(dict(total_amount = "%.2f" % total_amount))
458
    email_footer = Template(html_footer).substitute(dict(total_amount = "%.2f" % total_amount, secret_code = random_text, store_address = store_address, store_delivery_date = store_delivery_date))
425
    
459
    
426
    try:
460
    try:
427
        helper_client = HelperClient().get_client()
461
        helper_client = HelperClient().get_client()
428
        helper_client.saveUserEmailForSending(user_email, "", "Saholic - Order Details", email_header + html_table + email_footer, str(transaction_id), "TransactionInfo")
462
        helper_client.saveUserEmailForSending(user_email, "", "Saholic - Order Details", email_header + html_table + email_footer, str(transaction_id), "TransactionInfo")
429
        return True
463
        return True
Line 2012... Line 2046...
2012
    if store.line2:
2046
    if store.line2:
2013
        address = address + store.line2 + "\n"
2047
        address = address + store.line2 + "\n"
2014
    address = address + store.city + "\n"
2048
    address = address + store.city + "\n"
2015
    address = address + store.state + "\n"
2049
    address = address + store.state + "\n"
2016
    address = address + "PIN " + store.pin + "\n"
2050
    address = address + "PIN " + store.pin + "\n"
-
 
2051
    if store.phone:
2017
    address = address + "Phone: " + store.phone
2052
        address = address + "Phone: " + store.phone
-
 
2053
    return address
-
 
2054
 
-
 
2055
def __get_store_address_html(store):
-
 
2056
    address = store.name + "<br>" + store.line1 + "<br>"
-
 
2057
    if store.line2:
-
 
2058
        address = address + store.line2 + "<br>"
-
 
2059
    address = address + store.city + "<br>"
-
 
2060
    address = address + store.state + "<br>"
-
 
2061
    address = address + "PIN " + store.pin + "<br>"
-
 
2062
    if store.phone:
-
 
2063
        address = address + "Phone: " + store.phone
2018
    return address
2064
    return address
2019
 
2065
 
2020
def __generate_return_advice(order, warehouse, provider, filename):
2066
def __generate_return_advice(order, warehouse, provider, filename):
2021
    if warehouse.id == 7:
2067
    if warehouse.id == 7:
2022
        executive = 'Amit Kumar'
2068
        executive = 'Amit Kumar'