| Line 480... |
Line 480... |
| 480 |
return True
|
480 |
return True
|
| 481 |
except Exception as e:
|
481 |
except Exception as e:
|
| 482 |
print e
|
482 |
print e
|
| 483 |
return False
|
483 |
return False
|
| 484 |
|
484 |
|
| - |
|
485 |
def enqueue_received_at_store_email(order):
|
| - |
|
486 |
html_header = """
|
| - |
|
487 |
<html>
|
| - |
|
488 |
<body>
|
| - |
|
489 |
<div>
|
| - |
|
490 |
<p>
|
| - |
|
491 |
Hello $customer_name,<br /><br />
|
| - |
|
492 |
Your Product has reached the Store selected by you and is available for pickup. Please pick up your product on or before $order_expiry_date. Following are the details of your order and steps to pickup the same:
|
| - |
|
493 |
</p>
|
| - |
|
494 |
<div>
|
| - |
|
495 |
Order Date: $order_date
|
| - |
|
496 |
</div>
|
| - |
|
497 |
<div>
|
| - |
|
498 |
<table>
|
| - |
|
499 |
<tr><td colspan="5"><hr /></td></tr>
|
| - |
|
500 |
<tr><td colspan="5" align="left"><b>Order Details</b></td></tr>
|
| - |
|
501 |
<tr><td colspan="5"><hr /></td></tr>
|
| - |
|
502 |
<tr>
|
| - |
|
503 |
<th width="100">Order No.</th>
|
| - |
|
504 |
<th>Product</th>
|
| - |
|
505 |
<th width="100">Quantity</th>
|
| - |
|
506 |
<th width="100">Unit Price</th>
|
| - |
|
507 |
<th width="100">Amount</th>
|
| - |
|
508 |
</tr>
|
| - |
|
509 |
"""
|
| - |
|
510 |
total_amount = 0.0
|
| - |
|
511 |
html_table = ""
|
| - |
|
512 |
|
| - |
|
513 |
html_pickup_text = ""
|
| - |
|
514 |
random_text = __get_secret_code(order.id)
|
| - |
|
515 |
|
| - |
|
516 |
customer_name = order.customer_name
|
| - |
|
517 |
order_date = order.created_timestamp
|
| - |
|
518 |
user_email = order.customer_email
|
| - |
|
519 |
html_tr = "<tr><td align='center'>" + str(order.id) + "</td>"
|
| - |
|
520 |
|
| - |
|
521 |
for lineitem in order.lineitems:
|
| - |
|
522 |
lineitem_total_price = round(lineitem.total_price, 2)
|
| - |
|
523 |
|
| - |
|
524 |
html_tr += "<td>" + str(lineitem) + "</td>"
|
| - |
|
525 |
html_tr += "<td align='center'>" + ("%.0f" % lineitem.quantity) + "</td>"
|
| - |
|
526 |
html_tr += "<td align='center'> Rs. " + ("%.2f" % lineitem.unit_price) + "</td>"
|
| - |
|
527 |
html_tr += "<td align='center'> Rs. " + ("%.2f" % lineitem_total_price) + "</td></tr>"
|
| - |
|
528 |
total_amount += lineitem_total_price
|
| - |
|
529 |
html_table += html_tr
|
| - |
|
530 |
|
| - |
|
531 |
html_footer = """
|
| - |
|
532 |
<tr><td colspan=5> </td></tr>
|
| - |
|
533 |
<tr><td colspan=5><hr /></td></tr>
|
| - |
|
534 |
<tr>
|
| - |
|
535 |
<td colspan=4>Total Amount</td>
|
| - |
|
536 |
<td> Rs. $total_amount</td>
|
| - |
|
537 |
</tr>
|
| - |
|
538 |
</table>
|
| - |
|
539 |
</div>
|
| - |
|
540 |
"""
|
| - |
|
541 |
|
| - |
|
542 |
store_address = ""
|
| - |
|
543 |
if order.pickupStoreId:
|
| - |
|
544 |
store = LogisticsClient().get_client().getPickupStore(order.pickupStoreId)
|
| - |
|
545 |
store_address = __get_store_address_html(store)
|
| - |
|
546 |
|
| - |
|
547 |
html_pickup_text = html_pickup_text + """
|
| - |
|
548 |
<h3>Steps to Pickup In Store</h3>
|
| - |
|
549 |
1) Please visit the following store selected by you on or before $order_expiry_date<br>
|
| - |
|
550 |
<br><i>$store_address</i><br>
|
| - |
|
551 |
"""
|
| - |
|
552 |
|
| - |
|
553 |
if order.cod:
|
| - |
|
554 |
html_pickup_text = html_pickup_text + """
|
| - |
|
555 |
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>
|
| - |
|
556 |
*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>
|
| - |
|
557 |
<br>
|
| - |
|
558 |
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>
|
| - |
|
559 |
</br><hr />
|
| - |
|
560 |
"""
|
| - |
|
561 |
else:
|
| - |
|
562 |
html_pickup_text = html_pickup_text + """
|
| - |
|
563 |
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>
|
| - |
|
564 |
*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>
|
| - |
|
565 |
<br>
|
| - |
|
566 |
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>
|
| - |
|
567 |
</br><hr />
|
| - |
|
568 |
"""
|
| - |
|
569 |
|
| - |
|
570 |
html_footer = html_footer + html_pickup_text + """
|
| - |
|
571 |
<p>
|
| - |
|
572 |
Best Wishes,<br />
|
| - |
|
573 |
Saholic Team
|
| - |
|
574 |
</p>
|
| - |
|
575 |
</div>
|
| - |
|
576 |
</body>
|
| - |
|
577 |
</html>
|
| - |
|
578 |
"""
|
| - |
|
579 |
|
| - |
|
580 |
subject = "Your order for " + str(order.lineitems[0]) + " is ready for Pickup in Store"
|
| - |
|
581 |
dt = datetime.datetime.strptime(str(order_date), "%Y-%m-%d %H:%M:%S")
|
| - |
|
582 |
formated_order_date = dt.strftime("%A, %d. %B %Y %I:%M%p")
|
| - |
|
583 |
|
| - |
|
584 |
oetd = datetime.datetime.now() + datetime.timedelta(days=4)
|
| - |
|
585 |
formated_order_expiry_date = oetd.strftime("%A, %d %B %Y")
|
| - |
|
586 |
|
| - |
|
587 |
|
| - |
|
588 |
email_header = Template(html_header).substitute(dict(order_date = formated_order_date, customer_name = customer_name, order_expiry_date = formated_order_expiry_date))
|
| - |
|
589 |
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))
|
| - |
|
590 |
|
| - |
|
591 |
try:
|
| - |
|
592 |
helper_client = HelperClient().get_client()
|
| - |
|
593 |
helper_client.saveUserEmailForSending(user_email, "", subject, email_header + html_table + email_footer, str(order.id), "ReceivedAtStore")
|
| - |
|
594 |
return True
|
| - |
|
595 |
except Exception as e:
|
| - |
|
596 |
print e
|
| - |
|
597 |
return False
|
| - |
|
598 |
|
| - |
|
599 |
|
| - |
|
600 |
def __get_secret_code(order_id):
|
| - |
|
601 |
existingAttributes = Attribute.query.filter(Attribute.orderId == order_id).all()
|
| - |
|
602 |
if existingAttributes :
|
| - |
|
603 |
for existingAttribute in existingAttributes :
|
| - |
|
604 |
if existingAttribute.name == 'SECRET_CODE':
|
| - |
|
605 |
return existingAttribute.value
|
| - |
|
606 |
return ""
|
| - |
|
607 |
|
| 485 |
def get_order(order_id):
|
608 |
def get_order(order_id):
|
| 486 |
order = Order.get_by(id=order_id)
|
609 |
order = Order.get_by(id=order_id)
|
| 487 |
if not order:
|
610 |
if not order:
|
| 488 |
raise TransactionServiceException(108, "no such order")
|
611 |
raise TransactionServiceException(108, "no such order")
|
| 489 |
|
612 |
|
| Line 1066... |
Line 1189... |
| 1066 |
try:
|
1189 |
try:
|
| 1067 |
enqueue_received_at_store_email(order)
|
1190 |
enqueue_received_at_store_email(order)
|
| 1068 |
except Exception as e:
|
1191 |
except Exception as e:
|
| 1069 |
print e
|
1192 |
print e
|
| 1070 |
|
1193 |
|
| 1071 |
def enqueue_received_at_store_email(order):
|
- |
|
| 1072 |
# Calling helper service on production
|
- |
|
| 1073 |
helperClient = HelperClient(host_key = "helper_service_server_host_prod").get_client()
|
- |
|
| 1074 |
try:
|
- |
|
| 1075 |
emailSubject = 'Order Pickup from Store for Order ID: ' + str(order.id)
|
- |
|
| 1076 |
emailBody = get_received_at_store_email_body(order)
|
- |
|
| 1077 |
helperClient.saveUserEmailForSending(order.customer_email, None, emailSubject, emailBody, '', 'ReceivedAtStore')
|
- |
|
| 1078 |
except Exception as e:
|
- |
|
| 1079 |
print e
|
- |
|
| 1080 |
|
- |
|
| 1081 |
def get_received_at_store_email_body(order):
|
- |
|
| 1082 |
|
- |
|
| 1083 |
html = """
|
- |
|
| 1084 |
<html>
|
- |
|
| 1085 |
<body>
|
- |
|
| 1086 |
<div>
|
- |
|
| 1087 |
<p>Dear Customer,</p>
|
- |
|
| 1088 |
<p>
|
- |
|
| 1089 |
We are pleased to inform that your order: $order_id for your product $product_name has been reached at store.
|
- |
|
| 1090 |
You can pick it from store. Store details are mentioned below:
|
- |
|
| 1091 |
</p>
|
- |
|
| 1092 |
<p>
|
- |
|
| 1093 |
Store Address is:
|
- |
|
| 1094 |
$store_address
|
- |
|
| 1095 |
</p>
|
- |
|
| 1096 |
<p>
|
- |
|
| 1097 |
Warm Regards,<br />
|
- |
|
| 1098 |
Saholic Team
|
- |
|
| 1099 |
</p>
|
- |
|
| 1100 |
</div>
|
- |
|
| 1101 |
</body>
|
- |
|
| 1102 |
</html>
|
- |
|
| 1103 |
"""
|
- |
|
| 1104 |
client = LogisticsClient().get_client()
|
- |
|
| 1105 |
pickupStore = client.getPickupStore(order.pickupStoreId)
|
- |
|
| 1106 |
address = pickupStore.name + "\n" + pickupStore.line1 + "\n"
|
- |
|
| 1107 |
if pickupStore.line2:
|
- |
|
| 1108 |
address = address + pickupStore.line2 + "\n"
|
- |
|
| 1109 |
address = address + pickupStore.city + "\n"
|
- |
|
| 1110 |
address = address + pickupStore.state + "\n"
|
- |
|
| 1111 |
address = address + "PIN " + pickupStore.pin + "\n"
|
- |
|
| 1112 |
address = address + "Phone: " + pickupStore.phone
|
- |
|
| 1113 |
|
- |
|
| 1114 |
product = "%s %s %s %s" % (order.lineitems[0].brand, order.lineitems[0].model_name, order.lineitems[0].model_number, order.lineitems[0].color)
|
- |
|
| 1115 |
info = dict(order_id = order.id, product_name = product, store_address = address)
|
- |
|
| 1116 |
return Template(html).substitute(info)
|
- |
|
| 1117 |
|
1194 |
|
| 1118 |
|
1195 |
|
| 1119 |
def mark_orders_as_rto(provider_id, returned_orders):
|
1196 |
def mark_orders_as_rto(provider_id, returned_orders):
|
| 1120 |
for awb, detail in returned_orders.iteritems():
|
1197 |
for awb, detail in returned_orders.iteritems():
|
| 1121 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).first()
|
1198 |
order = Order.query.filter_by(airwaybill_no=awb, logistics_provider_id = provider_id).first()
|
| Line 2077... |
Line 2154... |
| 2077 |
address = store.name + "\n" + store.line1 + "\n"
|
2154 |
address = store.name + "\n" + store.line1 + "\n"
|
| 2078 |
if store.line2:
|
2155 |
if store.line2:
|
| 2079 |
address = address + store.line2 + "\n"
|
2156 |
address = address + store.line2 + "\n"
|
| 2080 |
address = address + store.city + "\n"
|
2157 |
address = address + store.city + "\n"
|
| 2081 |
address = address + store.state + "\n"
|
2158 |
address = address + store.state + "\n"
|
| 2082 |
address = address + "PIN " + store.pin + "\n"
|
2159 |
address = address + "PIN - " + store.pin + "\n"
|
| 2083 |
if store.phone:
|
2160 |
if store.phone:
|
| 2084 |
address = address + "Phone: " + store.phone
|
2161 |
address = address + "Phone - " + store.phone + "\n"
|
| - |
|
2162 |
address = address + "Store timing - 11AM to 8PM (7 days)\n"
|
| 2085 |
return address
|
2163 |
return address
|
| 2086 |
|
2164 |
|
| 2087 |
def __get_store_address_html(store):
|
2165 |
def __get_store_address_html(store):
|
| 2088 |
address = store.name + "<br>" + store.line1 + "<br>"
|
2166 |
address = store.name + "<br>" + store.line1 + "<br>"
|
| 2089 |
if store.line2:
|
2167 |
if store.line2:
|
| 2090 |
address = address + store.line2 + "<br>"
|
2168 |
address = address + store.line2 + "<br>"
|
| 2091 |
address = address + store.city + "<br>"
|
2169 |
address = address + store.city + "<br>"
|
| 2092 |
address = address + store.state + "<br>"
|
2170 |
address = address + store.state + "<br>"
|
| 2093 |
address = address + "PIN " + store.pin + "<br>"
|
2171 |
address = address + "PIN - " + store.pin + "<br>"
|
| 2094 |
if store.phone:
|
2172 |
if store.phone:
|
| 2095 |
address = address + "Phone: " + store.phone
|
2173 |
address = address + "Phone - " + store.phone + "<br>"
|
| - |
|
2174 |
address = address + "Store timing - 7 days: 11AM to 8PM (7 days)<br>"
|
| 2096 |
return address
|
2175 |
return address
|
| 2097 |
|
2176 |
|
| 2098 |
def __generate_return_advice(order, warehouse, provider, filename):
|
2177 |
def __generate_return_advice(order, warehouse, provider, filename):
|
| 2099 |
if warehouse.id == 7:
|
2178 |
if warehouse.id == 7:
|
| 2100 |
executive = 'Amit Kumar'
|
2179 |
executive = 'Amit Kumar'
|