Subversion Repositories SmartDukaan

Rev

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

Rev 6019 Rev 6029
Line 61... Line 61...
61
sourceId = int(ConfigClient().get_property("sourceid"))
61
sourceId = int(ConfigClient().get_property("sourceid"))
62
mail_user = 'cnc.center@shop2020.in'
62
mail_user = 'cnc.center@shop2020.in'
63
mail_password = '5h0p2o2o'
63
mail_password = '5h0p2o2o'
64
help_user = 'help@shop2020.in'
64
help_user = 'help@shop2020.in'
65
help_password = '5h0p2o2o'
65
help_password = '5h0p2o2o'
-
 
66
source_url = 'www.saholic.com'
-
 
67
source_name = 'Saholic'
66
 
68
 
67
PREPAID_SHIPPING_CUTOFF_TIME = 15
69
PREPAID_SHIPPING_CUTOFF_TIME = 15
68
COD_SHIPPING_CUTOFF_TIME = 12
70
COD_SHIPPING_CUTOFF_TIME = 12
69
 
71
 
70
PAGE_HEIGHT=defaultPageSize[1]
72
PAGE_HEIGHT=defaultPageSize[1]
Line 445... Line 447...
445
            <td colspan=5>Total Amount</td>
447
            <td colspan=5>Total Amount</td>
446
            <td> Rs. $total_amount</td>
448
            <td> Rs. $total_amount</td>
447
        </tr>
449
        </tr>
448
        </table>
450
        </table>
449
    </div>
451
    </div>
450
    <br>Congratulations, your order qualifies for the <b><i>Oh My God Contest</i></b>. Please check the details at <a href="www.saholic.com/static/oh-my-god-contest"> T &amp; C page </a> . We will get in touch with you on the Prize  announcement dates, if you are the Lucky Winner.<br>
452
    <br>Congratulations, your order qualifies for the <b><i>Oh My God Contest</i></b>. Please check the details at <a href="$source_url/static/oh-my-god-contest"> T &amp; C page </a> . We will get in touch with you on the Prize  announcement dates, if you are the Lucky Winner.<br>
451
    """
453
    """
452
    
454
    
453
    store_address = ""
455
    store_address = ""
454
    if orders[0].pickupStoreId:
456
    if orders[0].pickupStoreId:
455
        store = LogisticsClient().get_client().getPickupStore(orders[0].pickupStoreId)
457
        store = LogisticsClient().get_client().getPickupStore(orders[0].pickupStoreId)
Line 464... Line 466...
464
        if orders[0].cod:
466
        if orders[0].cod:
465
            html_pickup_text = html_pickup_text + """
467
            html_pickup_text = html_pickup_text + """
466
            2) 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>
468
            2) 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>
467
            *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>
469
            *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>
468
            <br>
470
            <br>
469
            In case you have any questions please visit <a href="www.saholic.com/static/buy-online-and-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>
471
            In case you have any questions please visit <a href="$source_url/static/buy-online-and-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="$source_url/contact-us">$source_url/contact-us</a>
470
            </br><hr />
472
            </br><hr />
471
            """
473
            """
472
        else:
474
        else:
473
            html_pickup_text = html_pickup_text + """
475
            html_pickup_text = html_pickup_text + """
474
            2) Present a valid Photo Identity Proof* and use your Secret Code <b><i>$secret_code</i></b> to claim your Product(s).<br><br>
476
            2) Present a valid Photo Identity Proof* and use your Secret Code <b><i>$secret_code</i></b> to claim your Product(s).<br><br>
475
            *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>
477
            *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>
476
            <br>
478
            <br>
477
            In case you have any questions please visit <a href="www.saholic.com/static/buy-online-and-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>
479
            In case you have any questions please visit <a href="$source_url/static/buy-online-and-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="$source_url/contact-us">$source_url/contact-us</a>
478
            </br><hr />
480
            </br><hr />
479
            """
481
            """
480
            
482
            
481
    html_footer = html_footer + html_pickup_text + """
483
    html_footer = html_footer + html_pickup_text + """
482
    <p>
484
    <p>
483
        Best Wishes,<br />
485
        Best Wishes,<br />
484
        Saholic Team
486
        $source_name Team
485
    </p>
487
    </p>
486
</div>
488
</div>
487
</body>
489
</body>
488
</html>
490
</html>
489
    """
491
    """
Line 492... Line 494...
492
    formated_order_date = dt.strftime("%A, %d. %B %Y %I:%M%p")
494
    formated_order_date = dt.strftime("%A, %d. %B %Y %I:%M%p")
493
 
495
 
494
    sdt = datetime.datetime.strptime(str(orders[0].expected_delivery_time), "%Y-%m-%d %H:%M:%S")
496
    sdt = datetime.datetime.strptime(str(orders[0].expected_delivery_time), "%Y-%m-%d %H:%M:%S")
495
    store_delivery_date = sdt.strftime("%A, %d %B %Y")
497
    store_delivery_date = sdt.strftime("%A, %d %B %Y")
496
 
498
 
497
    email_header = Template(html_header).substitute(dict(order_date = formated_order_date, customer_name = customer_name))
499
    email_header = Template(html_header).substitute(dict(order_date = formated_order_date, customer_name = customer_name, source_url = source_url))
498
    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))
500
    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, source_url = source_url, source_name = source_name))
499
    
501
    
500
    try:
502
    try:
501
        helper_client = HelperClient().get_client()
503
        helper_client = HelperClient().get_client()
502
        ##FIXME Remove once tesing is done
504
        ##FIXME Remove once tesing is done
503
        if orders[0].pickupStoreId:
505
        if orders[0].pickupStoreId:
504
            helper_client.saveUserEmailForSending([user_email], "", "Saholic - Order Details", email_header + html_table + email_footer, str(transaction_id), "TransactionInfo", [], ["abhishek.mathur@shop2020.in"])
506
            helper_client.saveUserEmailForSending([user_email], "", source_name + " - Order Details", email_header + html_table + email_footer, str(transaction_id), "TransactionInfo", [], ["abhishek.mathur@shop2020.in"])
505
        else:
507
        else:
506
            helper_client.saveUserEmailForSending([user_email], "", "Saholic - Order Details", email_header + html_table + email_footer, str(transaction_id), "TransactionInfo", [], [])
508
            helper_client.saveUserEmailForSending([user_email], "", source_name + " - Order Details", email_header + html_table + email_footer, str(transaction_id), "TransactionInfo", [], [])
507
         
509
         
508
        return True
510
        return True
509
    except Exception as e:
511
    except Exception as e:
510
        print e
512
        print e
511
        return False
513
        return False
Line 581... Line 583...
581
        if order.cod:
583
        if order.cod:
582
            html_pickup_text = html_pickup_text + """
584
            html_pickup_text = html_pickup_text + """
583
            2) Pay Rs. $total_amount, present a valid Photo Identity Proof* and quote your Secret Code <b><i>$secret_code</i></b> to claim your Product.<br><br>
585
            2) Pay Rs. $total_amount, present a valid Photo Identity Proof* and quote your Secret Code <b><i>$secret_code</i></b> to claim your Product.<br><br>
584
            *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>
586
            *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>
585
            <br>
587
            <br>
586
            In case you have any questions please visit <a href="www.saholic.com/static/buy-online-and-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>
588
            In case you have any questions please visit <a href="$source_url/static/buy-online-and-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="$source_url/contact-us">$source_url/contact-us</a>
587
            </br><hr />
589
            </br><hr />
588
            """
590
            """
589
        else:
591
        else:
590
            html_pickup_text = html_pickup_text + """
592
            html_pickup_text = html_pickup_text + """
591
            2) Present a valid Photo Identity Proof* and use your Secret Code <b><i>$secret_code</i></b> to claim your Product(s).<br><br>
593
            2) Present a valid Photo Identity Proof* and use your Secret Code <b><i>$secret_code</i></b> to claim your Product(s).<br><br>
592
            *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>
594
            *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>
593
            <br>
595
            <br>
594
            In case you have any questions please visit <a href="www.saholic.com/static/buy-online-and-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>
596
            In case you have any questions please visit <a href="$source_url/static/buy-online-and-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="$source_url/contact-us">$source_url/contact-us</a>
595
            </br><hr />
597
            </br><hr />
596
            """
598
            """
597
            
599
            
598
        html_footer = html_footer + html_pickup_text + """
600
        html_footer = html_footer + html_pickup_text + """
599
        <p>
601
        <p>
600
            Best Wishes,<br />
602
            Best Wishes,<br />
601
            Saholic Team
603
            $source_name Team
602
        </p>
604
        </p>
603
        </div>
605
        </div>
604
        </body>
606
        </body>
605
        </html>
607
        </html>
606
        """
608
        """
Line 611... Line 613...
611
 
613
 
612
    oetd = datetime.datetime.now() + datetime.timedelta(days=4)
614
    oetd = datetime.datetime.now() + datetime.timedelta(days=4)
613
    formated_order_expiry_date = oetd.strftime("%A, %d %B %Y")
615
    formated_order_expiry_date = oetd.strftime("%A, %d %B %Y")
614
    
616
    
615
 
617
 
616
    email_header = Template(html_header).substitute(dict(order_date = formated_order_date, customer_name = customer_name, order_expiry_date = formated_order_expiry_date))
618
    email_header = Template(html_header).substitute(dict(order_date = formated_order_date, customer_name = customer_name, order_expiry_date = formated_order_expiry_date, source_url = source_url, source_name = source_name))
617
    email_footer = Template(html_footer).substitute(dict(total_amount = "%.2f" % total_amount, secret_code = random_text, store_address = store_address, order_expiry_date = formated_order_expiry_date))
619
    email_footer = Template(html_footer).substitute(dict(total_amount = "%.2f" % total_amount, secret_code = random_text, store_address = store_address, order_expiry_date = formated_order_expiry_date, source_url = source_url, source_name = source_name))
618
    
620
    
619
    try:
621
    try:
620
        helper_client = HelperClient(host_key = "helper_service_server_host_prod").get_client()
622
        helper_client = HelperClient(host_key = "helper_service_server_host_prod").get_client()
621
        ##FIXME Remove once tesing is done
623
        ##FIXME Remove once tesing is done
622
        if order.pickupStoreId:
624
        if order.pickupStoreId:
Line 640... Line 642...
640
    if order.pickupStoreId:
642
    if order.pickupStoreId:
641
        pickup_text = "Pickup Date: " + order.delivery_timestamp.strftime("%A, %d. %B %Y %I:%M%p")
643
        pickup_text = "Pickup Date: " + order.delivery_timestamp.strftime("%A, %d. %B %Y %I:%M%p")
642
        thank_you_html = """
644
        thank_you_html = """
643
        Thank you for shopping with us and picking up your order in Store. Please do join us at our <a href="http://www.facebook.com/mysaholic">Facebook Page</a>, and share your experience with other shoppers.<br><br>
645
        Thank you for shopping with us and picking up your order in Store. Please do join us at our <a href="http://www.facebook.com/mysaholic">Facebook Page</a>, and share your experience with other shoppers.<br><br>
644
    
646
    
645
        Following are the details of your order for which the pickup has happened. If you have not picked up this product please <a href="http://www.saholic.com/contact-us" target="_blank">contact us</a> immediately.<br>
647
        Following are the details of your order for which the pickup has happened. If you have not picked up this product please <a href="$source_url/contact-us" target="_blank">contact us</a> immediately.<br>
646
        """
648
        """
647
    else:
649
    else:
648
        pickup_text = ""
650
        pickup_text = ""
649
        thank_you_html = """
651
        thank_you_html = """
650
        Thank you for shopping with us. Please do join us at our <a href="http://www.facebook.com/mysaholic">Facebook Page</a>, and share your experience with other shoppers. Following are the details of your order.<br>
652
        Thank you for shopping with us. Please do join us at our <a href="http://www.facebook.com/mysaholic">Facebook Page</a>, and share your experience with other shoppers. Following are the details of your order.<br>
Line 696... Line 698...
696
        </tr>
698
        </tr>
697
        </table>
699
        </table>
698
    </div>
700
    </div>
699
    <p>
701
    <p>
700
        Best Wishes,<br />
702
        Best Wishes,<br />
701
        Saholic Team
703
        $source_name Team
702
    </p>
704
    </p>
703
    </div>
705
    </div>
704
    </body>
706
    </body>
705
    </html>
707
    </html>
706
    """
708
    """
Line 708... Line 710...
708
    subject = "Your order for " + str(order.lineitems[0]) + " is now complete"
710
    subject = "Your order for " + str(order.lineitems[0]) + " is now complete"
709
    dt = datetime.datetime.strptime(str(order_date), "%Y-%m-%d %H:%M:%S")
711
    dt = datetime.datetime.strptime(str(order_date), "%Y-%m-%d %H:%M:%S")
710
    formated_order_date = dt.strftime("%A, %d. %B %Y %I:%M%p")
712
    formated_order_date = dt.strftime("%A, %d. %B %Y %I:%M%p")
711
 
713
 
712
    
714
    
713
    email_header = Template(html_header).substitute(dict(order_date = formated_order_date, customer_name = customer_name, pickup_text = pickup_text))
715
    email_header = Template(html_header).substitute(dict(order_date = formated_order_date, customer_name = customer_name, pickup_text = pickup_text, source_url = source_url))
714
    email_footer = Template(html_footer).substitute(dict(total_amount = "%.2f" % total_amount))
716
    email_footer = Template(html_footer).substitute(dict(total_amount = "%.2f" % total_amount, source_name = source_name))
715
    
717
    
716
    try:
718
    try:
717
        helper_client = HelperClient(host_key = "helper_service_server_host_prod").get_client()
719
        helper_client = HelperClient(host_key = "helper_service_server_host_prod").get_client()
718
        ##FIXME Remove once tesing is done
720
        ##FIXME Remove once tesing is done
719
        if order.pickupStoreId:
721
        if order.pickupStoreId:
Line 1187... Line 1189...
1187
    
1189
    
1188
def send_mails_to_bdms(order):
1190
def send_mails_to_bdms(order):
1189
    logistics_client = LogisticsClient().get_client()
1191
    logistics_client = LogisticsClient().get_client()
1190
    store = logistics_client.getPickupStore(order.pickupStoreId)
1192
    store = logistics_client.getPickupStore(order.pickupStoreId)
1191
    provider = logistics_client.getProvider(order.logistics_provider_id)
1193
    provider = logistics_client.getProvider(order.logistics_provider_id)
1192
    subject = "Saholic order " + str(order.id) +" shipped to store" 
1194
    subject = source_name + " order " + str(order.id) +" shipped to store" 
1193
    raw_message = '''
1195
    raw_message = '''
1194
    Dear Sir,
1196
    Dear Sir,
1195
 
1197
 
1196
    Order mentioned below is being shipped to your store. Customer will pick it from your store. 
1198
    Order mentioned below is being shipped to your store. Customer will pick it from your store. 
1197
 
1199
 
Line 1769... Line 1771...
1769
        %(customer_address)s
1771
        %(customer_address)s
1770
 
1772
 
1771
        Do let us know in case of any concerns
1773
        Do let us know in case of any concerns
1772
 
1774
 
1773
        Thanks & Regards
1775
        Thanks & Regards
1774
        Saholic Team
1776
        %(source_name)s Team
1775
        '''
1777
        '''
1776
        message = dedent(raw_message) % {'customer_name' : order.customer_name,
1778
        message = dedent(raw_message) % {'customer_name' : order.customer_name,
1777
                                         'order_id' : order_id,
1779
                                         'order_id' : order_id,
1778
                                         'provider_name' : provider_name,
1780
                                         'provider_name' : provider_name,
1779
                                         'date': today,
1781
                                         'date': today,
1780
                                         'pickup_request_no' : pickup_number,
1782
                                         'pickup_request_no' : pickup_number,
1781
                                         'customer_address' : __get_order_address(order)}
1783
                                         'customer_address' : __get_order_address(order),
-
 
1784
                                         'source_name' : source_name}
1782
        print message
1785
        print message
1783
        __generate_return_advice(order, warehouse, provider, filename)
1786
        __generate_return_advice(order, warehouse, provider, filename)
1784
        mail(help_user, help_password, [to_addr], subject, message, [get_attachment_part(filename)])
1787
        mail(help_user, help_password, [to_addr], subject, message, [get_attachment_part(filename)])
1785
        order.pickupRequestNo = pickup_number
1788
        order.pickupRequestNo = pickup_number
1786
        if order.status == OrderStatus.RET_PICKUP_REQUEST_RAISED:
1789
        if order.status == OrderStatus.RET_PICKUP_REQUEST_RAISED:
Line 3232... Line 3235...
3232
        For scheduling the delivery of your product at some specific timings, we recommend you to contact the helpline for $courier_name with your complete AWB#.
3235
        For scheduling the delivery of your product at some specific timings, we recommend you to contact the helpline for $courier_name with your complete AWB#.
3233
    </p>
3236
    </p>
3234
    <p>$courier_name: $courier_phone</p>
3237
    <p>$courier_name: $courier_phone</p>
3235
    <p>
3238
    <p>
3236
        Warm Regards,<br />
3239
        Warm Regards,<br />
3237
        Saholic Team
3240
        $source_name Team
3238
    </p>
3241
    </p>
3239
</div>
3242
</div>
3240
</body>
3243
</body>
3241
</html>
3244
</html>
3242
    """
3245
    """
Line 3249... Line 3252...
3249
    dt = datetime.datetime.strptime(str(order.shipping_timestamp), "%Y-%m-%d %H:%M:%S")
3252
    dt = datetime.datetime.strptime(str(order.shipping_timestamp), "%Y-%m-%d %H:%M:%S")
3250
    shipping_date = dt.strftime("%A, %d %B %Y %I:%M%p")
3253
    shipping_date = dt.strftime("%A, %d %B %Y %I:%M%p")
3251
    product = "%s %s %s" % (order.lineitems[0].brand, order.lineitems[0].model_name, order.lineitems[0].model_number)
3254
    product = "%s %s %s" % (order.lineitems[0].brand, order.lineitems[0].model_name, order.lineitems[0].model_number)
3252
    new_expected_delivery_timestamp = datetime.datetime.now() + timedelta(adjust_delivery_time(datetime.datetime.now(), (logistics_info.deliveryTime - logistics_info.shippingTime)))
3255
    new_expected_delivery_timestamp = datetime.datetime.now() + timedelta(adjust_delivery_time(datetime.datetime.now(), (logistics_info.deliveryTime - logistics_info.shippingTime)))
3253
    new_expected_delivery_date = new_expected_delivery_timestamp.strftime("%A, %d %B %Y")
3256
    new_expected_delivery_date = new_expected_delivery_timestamp.strftime("%A, %d %B %Y")
3254
    info = dict(order_id = order.id, product_name = product, shipping_datetime = shipping_date, awb = order.airwaybill_no, expected_delivery_date = new_expected_delivery_date, courier_name = provider_name, courier_phone = provider_phone)
3257
    info = dict(order_id = order.id, product_name = product, shipping_datetime = shipping_date, awb = order.airwaybill_no, expected_delivery_date = new_expected_delivery_date, courier_name = provider_name, courier_phone = provider_phone, source_name = source_name)
3255
    return Template(html).substitute(info)
3258
    return Template(html).substitute(info)
3256
 
3259
 
3257
def enqueue_shipping_confirmation_email(order):
3260
def enqueue_shipping_confirmation_email(order):
3258
    # Calling helper service on production
3261
    # Calling helper service on production
3259
    helperClient = HelperClient(host_key = "helper_service_server_host_prod").get_client()
3262
    helperClient = HelperClient(host_key = "helper_service_server_host_prod").get_client()