| Line 68... |
Line 68... |
| 68 |
TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
|
68 |
TransactionStatus, OrderStatus, DelayReason, ExtraTransactionProcessingType, \
|
| 69 |
HotspotAction, TimeoutSummary, OrderStatusGroups, OrderType, RechargeOrderStatus, \
|
69 |
HotspotAction, TimeoutSummary, OrderStatusGroups, OrderType, RechargeOrderStatus, \
|
| 70 |
RechargeType, RechargeStatistics, DeviceNumberInfo, EmiChargeType, PayMethod, \
|
70 |
RechargeType, RechargeStatistics, DeviceNumberInfo, EmiChargeType, PayMethod, \
|
| 71 |
OrderSource, StorePaymentStatus, ProductCondition, TaxType, \
|
71 |
OrderSource, StorePaymentStatus, ProductCondition, TaxType, \
|
| 72 |
AmazonFCWarehouseLocation
|
72 |
AmazonFCWarehouseLocation
|
| - |
|
73 |
#from shop2020.thriftpy.utils.ttypes import UserSmsInfo, SmsType
|
| 73 |
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType, CouponCategory, \
|
74 |
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType, CouponCategory, \
|
| 74 |
User, Sex
|
75 |
User, Sex
|
| 75 |
from shop2020.thriftpy.payments.ttypes import PaymentException
|
76 |
from shop2020.thriftpy.payments.ttypes import PaymentException
|
| 76 |
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
|
77 |
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
|
| 77 |
WarehouseServiceException
|
78 |
WarehouseServiceException
|
| Line 626... |
Line 627... |
| 626 |
return diff - (non_business_days + sundays)
|
627 |
return diff - (non_business_days + sundays)
|
| 627 |
|
628 |
|
| 628 |
|
629 |
|
| 629 |
def enqueue_transaction_info_email(transaction_id):
|
630 |
def enqueue_transaction_info_email(transaction_id):
|
| 630 |
transaction = get_transaction(transaction_id)
|
631 |
transaction = get_transaction(transaction_id)
|
| - |
|
632 |
'''
|
| - |
|
633 |
smsText = "Thanks for ordering "
|
| - |
|
634 |
otgSms = False
|
| - |
|
635 |
mobileNo = None
|
| - |
|
636 |
customerId = 0
|
| - |
|
637 |
'''
|
| 631 |
subject = source_name + " - Order Details"
|
638 |
subject = source_name + " - Order Details"
|
| 632 |
orders = transaction.orders
|
639 |
orders = transaction.orders
|
| 633 |
advance_amount = orders[0].advanceAmount
|
640 |
advance_amount = orders[0].advanceAmount
|
| 634 |
saddress = ""
|
641 |
saddress = ""
|
| 635 |
bcc = []
|
642 |
bcc = []
|
| Line 640... |
Line 647... |
| 640 |
otgLink = ""
|
647 |
otgLink = ""
|
| 641 |
inOrderOtg = "<div>On Time Guarantee<br><span style=color:red>We pay if we delay</span></div>"
|
648 |
inOrderOtg = "<div>On Time Guarantee<br><span style=color:red>We pay if we delay</span></div>"
|
| 642 |
if len(transaction.orders) == 1:
|
649 |
if len(transaction.orders) == 1:
|
| 643 |
inOrderOtg = ""
|
650 |
inOrderOtg = ""
|
| 644 |
if transaction.orders[0].otg :
|
651 |
if transaction.orders[0].otg :
|
| - |
|
652 |
#otgSms = True
|
| 645 |
subject = "Your Order is confirmed with On Time Guarantee We Pay if we Delay"
|
653 |
subject = "Your Order is confirmed with On Time Guarantee We Pay if we Delay"
|
| 646 |
otgLink = ' Your Order is covered under the <a href="http://www.saholic.com/static/on-time-guarantee">On Time Guarantee, We pay If we Delay.</a>'
|
654 |
otgLink = ' Your Order is covered under the <a href="http://www.saholic.com/static/on-time-guarantee">On Time Guarantee, We pay If we Delay.</a>'
|
| 647 |
|
655 |
|
| 648 |
customer_name = ""
|
656 |
customer_name = ""
|
| 649 |
html_header = """
|
657 |
html_header = """
|
| Line 681... |
Line 689... |
| 681 |
if orders[0].pickupStoreId:
|
689 |
if orders[0].pickupStoreId:
|
| 682 |
random_text = str(randrange(100000, 999999))
|
690 |
random_text = str(randrange(100000, 999999))
|
| 683 |
|
691 |
|
| 684 |
first = True
|
692 |
first = True
|
| 685 |
for order in orders:
|
693 |
for order in orders:
|
| - |
|
694 |
'''mobileNo = order.customer_mobilenumber
|
| - |
|
695 |
customerId = order.customer_id
|
| - |
|
696 |
'''
|
| 686 |
customer_name = order.customer_name
|
697 |
customer_name = order.customer_name
|
| 687 |
order_date = order.created_timestamp
|
698 |
order_date = order.created_timestamp
|
| 688 |
user_email = order.customer_email
|
699 |
user_email = order.customer_email
|
| 689 |
if first:
|
700 |
if first:
|
| 690 |
first = False
|
701 |
first = False
|
| Line 702... |
Line 713... |
| 702 |
attribute.name = "SECRET_CODE"
|
713 |
attribute.name = "SECRET_CODE"
|
| 703 |
attribute.value = random_text
|
714 |
attribute.value = random_text
|
| 704 |
session.commit()
|
715 |
session.commit()
|
| 705 |
|
716 |
|
| 706 |
for lineitem in order.lineitems:
|
717 |
for lineitem in order.lineitems:
|
| - |
|
718 |
#smsText = smsText + lineitem.brand + " " + lineitem.model_name + " " + lineitem.model_number + "("+str(lineitem.quantity)+ ")" +" "
|
| 707 |
lineitem_total_price = round(lineitem.total_price, 2)
|
719 |
lineitem_total_price = round(lineitem.total_price, 2)
|
| 708 |
|
720 |
|
| 709 |
html_tr += "<td>" + str(lineitem) + "</td>"
|
721 |
html_tr += "<td>" + str(lineitem) + "</td>"
|
| 710 |
if order.otg:
|
722 |
if order.otg:
|
| 711 |
html_tr += "<td align='center'><div>" + store_delivery_date + "</div>" + inOrderOtg + "</td>"
|
723 |
html_tr += "<td align='center'><div>" + store_delivery_date + "</div>" + inOrderOtg + "</td>"
|
| Line 714... |
Line 726... |
| 714 |
html_tr += "<td align='center'>" + ("%.0f" % lineitem.quantity) + "</td>"
|
726 |
html_tr += "<td align='center'>" + ("%.0f" % lineitem.quantity) + "</td>"
|
| 715 |
html_tr += "<td align='center'> Rs. " + ("%.2f" % lineitem.unit_price) + "</td>"
|
727 |
html_tr += "<td align='center'> Rs. " + ("%.2f" % lineitem.unit_price) + "</td>"
|
| 716 |
html_tr += "<td align='center'> Rs. " + ("%.2f" % lineitem_total_price) + "</td></tr>"
|
728 |
html_tr += "<td align='center'> Rs. " + ("%.2f" % lineitem_total_price) + "</td></tr>"
|
| 717 |
total_amount += lineitem_total_price
|
729 |
total_amount += lineitem_total_price
|
| 718 |
html_table += html_tr
|
730 |
html_table += html_tr
|
| - |
|
731 |
#smsText = smsText + "Order Id: "+str(order.id)+" "
|
| 719 |
if order.freebieItemId:
|
732 |
if order.freebieItemId:
|
| 720 |
catalog_client = CatalogClient().get_client()
|
733 |
catalog_client = CatalogClient().get_client()
|
| 721 |
item = catalog_client.getItem(order.freebieItemId)
|
734 |
item = catalog_client.getItem(order.freebieItemId)
|
| 722 |
html_table += "<tr><td align='center'></td><td style='font-style:italic;' colspan='5'> Free Item: "+item.brand + " " + item.modelName + " " + item.modelNumber+"</td></tr>"
|
735 |
html_table += "<tr><td align='center'></td><td style='font-style:italic;' colspan='5'> Free Item: "+item.brand + " " + item.modelName + " " + item.modelNumber+"</td></tr>"
|
| 723 |
if order.insurer:
|
736 |
if order.insurer:
|
| 724 |
html_table += "<tr><td colspan=6> </td></tr>"
|
737 |
html_table += "<tr><td colspan=6> </td></tr>"
|
| 725 |
html_table += "<tr><td align='center'></td><td style='font-style:italic;'>Insured Against Theft for 1 Year. <a href='http://www.saholic.com/static/insurance-terms'>Know More</a></td><td align='center'></td><td align='center'></td><td align='center'></td>"
|
738 |
html_table += "<tr><td align='center'></td><td style='font-style:italic;'>Insured Against Theft for 1 Year. <a href='http://www.saholic.com/static/insurance-terms'>Know More</a></td><td align='center'></td><td align='center'></td><td align='center'></td>"
|
| 726 |
html_table += "<td align='center'>" + str(order.insuranceAmount) + "</td></tr>"
|
739 |
html_table += "<td align='center'>" + str(order.insuranceAmount) + "</td></tr>"
|
| 727 |
total_amount += order.insuranceAmount
|
740 |
total_amount += order.insuranceAmount
|
| - |
|
741 |
|
| - |
|
742 |
#smsText = smsText + "Saholic.com"
|
| 728 |
emi_amount = 0
|
743 |
emi_amount = 0
|
| 729 |
miscCharges = get_misc_charges(transaction_id)
|
744 |
miscCharges = get_misc_charges(transaction_id)
|
| 730 |
if miscCharges.get(1):
|
745 |
if miscCharges.get(1):
|
| 731 |
emi_amount = miscCharges.get(1)
|
746 |
emi_amount = miscCharges.get(1)
|
| 732 |
|
747 |
|
| Line 816... |
Line 831... |
| 816 |
|
831 |
|
| 817 |
return True
|
832 |
return True
|
| 818 |
except Exception as e:
|
833 |
except Exception as e:
|
| 819 |
print e
|
834 |
print e
|
| 820 |
return False
|
835 |
return False
|
| - |
|
836 |
'''
|
| - |
|
837 |
if otgSms:
|
| - |
|
838 |
smsText = smsText +" On Time Guarantee We Pay if we Delay. T&C Apply"
|
| - |
|
839 |
|
| - |
|
840 |
try:
|
| - |
|
841 |
helper_client = HelperClient().get_client()
|
| - |
|
842 |
helper_client.saveUserEmailForSending([user_email], "", subject, email_header + html_table + email_footer, str(transaction_id), "TransactionInfo", [], bcc, orders[0].source)
|
| - |
|
843 |
except Exception as e:
|
| - |
|
844 |
print e
|
| - |
|
845 |
try:
|
| - |
|
846 |
send_transaction_sms(customerId, mobileNo, smsText, SmsType.TRANSACTIONAL)
|
| - |
|
847 |
return True
|
| - |
|
848 |
except Exception as e:
|
| - |
|
849 |
print e
|
| - |
|
850 |
print sys.exc_info()[0]
|
| - |
|
851 |
return False
|
| - |
|
852 |
|
| - |
|
853 |
try:
|
| - |
|
854 |
send_transaction_sms(customerId, mobileNo, smsText, SmsType.TRANSACTIONAL)
|
| - |
|
855 |
return True
|
| - |
|
856 |
except Exception as e:
|
| - |
|
857 |
print e
|
| - |
|
858 |
print sys.exc_info()[0]
|
| - |
|
859 |
return True
|
| - |
|
860 |
'''
|
| - |
|
861 |
|
| - |
|
862 |
def send_transaction_sms(customerId, mobileNo, smsText, smsType):
|
| - |
|
863 |
if mobileNo is not None:
|
| - |
|
864 |
helper_client = HelperClient().get_client()
|
| - |
|
865 |
helper_client.saveUserSmsForSending(customerId, mobileNo, smsText, SmsType.TRANSACTIONAL)
|
| - |
|
866 |
userSmsInfo = helper_client.getUserSmsInfo(customerId);
|
| - |
|
867 |
if userSmsInfo and mobileNo == userSmsInfo.mobileNo:
|
| - |
|
868 |
userSmsInfo.dailyCount = userSmsInfo.dailyCount +1
|
| - |
|
869 |
userSmsInfo.weeklyCount = userSmsInfo.weeklyCount +1
|
| - |
|
870 |
helper_client.updateUserSmsInfo(userSmsInfo)
|
| - |
|
871 |
elif userSmsInfo and mobileNo != userSmsInfo.mobileNo:
|
| - |
|
872 |
userSmsInfo.updateTimestamp = to_java_date(datetime.datetime.now())
|
| - |
|
873 |
userSmsInfo.mobileNo = mobileNo
|
| - |
|
874 |
userSmsInfo.dailyCount = 1
|
| - |
|
875 |
userSmsInfo.weeklyCount = 1
|
| - |
|
876 |
helper_client.updateUserSmsInfo(userSmsInfo)
|
| - |
|
877 |
else:
|
| - |
|
878 |
userSmsInfo = UserSmsInfo()
|
| - |
|
879 |
userSmsInfo.userId = customerId
|
| - |
|
880 |
userSmsInfo.mobileNo = mobileNo
|
| - |
|
881 |
userSmsInfo.createdTimestamp = to_java_date(datetime.datetime.now())
|
| - |
|
882 |
userSmsInfo.updateTimestamp = to_java_date(datetime.datetime.now())
|
| - |
|
883 |
helper_client.addUserSmsInfo(userSmsInfo);
|
| 821 |
|
884 |
|
| 822 |
def enqueue_received_at_store_email(order):
|
885 |
def enqueue_received_at_store_email(order):
|
| 823 |
html_header = """
|
886 |
html_header = """
|
| 824 |
<html>
|
887 |
<html>
|
| 825 |
<body>
|
888 |
<body>
|
| Line 1073... |
Line 1136... |
| 1073 |
email_footer = Template(html_footer).substitute(dict(total_amount = "%.2f" % total_amount, source_name = source_name, freebie_text = freebie_text))
|
1136 |
email_footer = Template(html_footer).substitute(dict(total_amount = "%.2f" % total_amount, source_name = source_name, freebie_text = freebie_text))
|
| 1074 |
|
1137 |
|
| 1075 |
try:
|
1138 |
try:
|
| 1076 |
helper_client = HelperClient(host_key = "helper_service_server_host_prod").get_client()
|
1139 |
helper_client = HelperClient(host_key = "helper_service_server_host_prod").get_client()
|
| 1077 |
helper_client.saveUserEmailForSending([user_email], "", subject, email_header + html_table + email_footer, str(order.id), "DeliverySuccess", [], [], order.source)
|
1140 |
helper_client.saveUserEmailForSending([user_email], "", subject, email_header + html_table + email_footer, str(order.id), "DeliverySuccess", [], [], order.source)
|
| - |
|
1141 |
'''
|
| - |
|
1142 |
if order.source == OrderSource.WEBSITE:
|
| - |
|
1143 |
send_transaction_sms(order.customer_id, order.customer_mobilenumber, "Dear "+ order.customer_name +", Your order: " + str(order.id) + " has been delivered now. For any queries please call 0120-2479977." , SmsType.TRANSACTIONAL)
|
| - |
|
1144 |
'''
|
| 1078 |
return True
|
1145 |
return True
|
| 1079 |
except Exception as e:
|
1146 |
except Exception as e:
|
| 1080 |
print e
|
1147 |
print e
|
| 1081 |
return False
|
1148 |
return False
|
| 1082 |
|
1149 |
|
| Line 1476... |
Line 1543... |
| 1476 |
raise TransactionServiceException(110,'Parent order for this is COD and is still undelivered')
|
1543 |
raise TransactionServiceException(110,'Parent order for this is COD and is still undelivered')
|
| 1477 |
# inventoryClient = InventoryClient().get_client()
|
1544 |
# inventoryClient = InventoryClient().get_client()
|
| 1478 |
# if not inventoryClient.isOrderBillable(item_id, order.fulfilmentWarehouseId, sourceId, orderId):
|
1545 |
# if not inventoryClient.isOrderBillable(item_id, order.fulfilmentWarehouseId, sourceId, orderId):
|
| 1479 |
# raise TransactionServiceException(101, "There are other orders to be billed before this order id " + str(orderId))
|
1546 |
# raise TransactionServiceException(101, "There are other orders to be billed before this order id " + str(orderId))
|
| 1480 |
|
1547 |
|
| - |
|
1548 |
singleInvoiceAttr = Attribute.query.filter(Attribute.orderId == order.id).filter(Attribute.name == "Single Invoice").first()
|
| - |
|
1549 |
|
| 1481 |
catalog_client = CatalogClient().get_client()
|
1550 |
catalog_client = CatalogClient().get_client()
|
| 1482 |
item = catalog_client.getItem(item_id)
|
1551 |
item = catalog_client.getItem(item_id)
|
| 1483 |
if order.status == OrderStatus.ACCEPTED:
|
1552 |
if order.status == OrderStatus.ACCEPTED:
|
| 1484 |
order.jacket_number = jacketNumber
|
1553 |
order.jacket_number = jacketNumber
|
| 1485 |
if order.source == 6:
|
1554 |
if order.source == 6:
|
| Line 1487... |
Line 1556... |
| 1487 |
if order.source == 7:
|
1556 |
if order.source == 7:
|
| 1488 |
order.jacket_number = "700"+str(orderId)
|
1557 |
order.jacket_number = "700"+str(orderId)
|
| 1489 |
if order.source == 8:
|
1558 |
if order.source == 8:
|
| 1490 |
order.jacket_number = "800"+str(orderId)
|
1559 |
order.jacket_number = "800"+str(orderId)
|
| 1491 |
if itemNumbers:
|
1560 |
if itemNumbers:
|
| 1492 |
lineitem.item_number = itemNumbers[0]
|
1561 |
lineitem.item_number = itemNumbers[0]
|
| - |
|
1562 |
|
| - |
|
1563 |
if singleInvoiceAttr:
|
| - |
|
1564 |
if singleInvoiceAttr.value == "true":
|
| - |
|
1565 |
if serialNumbers:
|
| - |
|
1566 |
finalSerialNo =''
|
| - |
|
1567 |
for serialNumber in serialNumbers:
|
| - |
|
1568 |
finalSerialNo = finalSerialNo +','+ serialNumber
|
| - |
|
1569 |
|
| - |
|
1570 |
finalSerialNo = finalSerialNo[1:]
|
| - |
|
1571 |
|
| - |
|
1572 |
if lineitem.serial_number is None:
|
| - |
|
1573 |
lineitem.serial_number = finalSerialNo
|
| - |
|
1574 |
else:
|
| - |
|
1575 |
lineitem.serial_number = lineitem.serial_number + ',' + finalSerialNo
|
| - |
|
1576 |
else:
|
| 1493 |
if serialNumbers:
|
1577 |
if serialNumbers:
|
| 1494 |
lineitem.serial_number = serialNumbers[0]
|
1578 |
lineitem.serial_number = serialNumbers[0]
|
| 1495 |
|
1579 |
|
| 1496 |
'''
|
1580 |
'''
|
| 1497 |
if billingType == BillingType.EXTERNAL or billingType == BillingType.OURS_EXTERNAL:
|
1581 |
if billingType == BillingType.EXTERNAL or billingType == BillingType.OURS_EXTERNAL:
|
| 1498 |
if billedOrdersColorMap.has_key(orderId):
|
1582 |
if billedOrdersColorMap.has_key(orderId):
|
| 1499 |
etpColor = billedOrdersColorMap.get(orderId)
|
1583 |
etpColor = billedOrdersColorMap.get(orderId)
|
| Line 1511... |
Line 1595... |
| 1511 |
order.invoice_number = invoice_number
|
1595 |
order.invoice_number = invoice_number
|
| 1512 |
|
1596 |
|
| 1513 |
if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
|
1597 |
if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
|
| 1514 |
if ItemType.SERIALIZED == item.type and not (serialNumbers and serialNumbers[0]):
|
1598 |
if ItemType.SERIALIZED == item.type and not (serialNumbers and serialNumbers[0]):
|
| 1515 |
raise TransactionServiceException(110, "No Serial Number supplied")
|
1599 |
raise TransactionServiceException(110, "No Serial Number supplied")
|
| - |
|
1600 |
if singleInvoiceAttr:
|
| - |
|
1601 |
if singleInvoiceAttr.value == "true":
|
| - |
|
1602 |
if serialNumbers:
|
| - |
|
1603 |
finalSerialNo =''
|
| - |
|
1604 |
for serialNumber in serialNumbers:
|
| - |
|
1605 |
finalSerialNo = finalSerialNo +','+ serialNumber
|
| - |
|
1606 |
|
| - |
|
1607 |
finalSerialNo = finalSerialNo[1:]
|
| - |
|
1608 |
if lineitem.serial_number is None:
|
| - |
|
1609 |
lineitem.serial_number = finalSerialNo
|
| - |
|
1610 |
else:
|
| 1516 |
if serialNumbers:
|
1611 |
if serialNumbers:
|
| 1517 |
lineitem.serial_number = serialNumbers[0]
|
1612 |
lineitem.serial_number = serialNumbers[0]
|
| 1518 |
|
1613 |
|
| 1519 |
|
1614 |
|
| 1520 |
order.status = OrderStatus.BILLED
|
1615 |
order.status = OrderStatus.BILLED
|
| 1521 |
order.statusDescription = "Order Billed"
|
1616 |
order.statusDescription = "Order Billed"
|
| 1522 |
order.billing_timestamp = datetime.datetime.now()
|
1617 |
order.billing_timestamp = datetime.datetime.now()
|
| Line 1646... |
Line 1741... |
| 1646 |
print e.message
|
1741 |
print e.message
|
| 1647 |
raise TransactionServiceException(110,'Error in billing freebie for warehouseId ' + str(freebieWarehouseId))
|
1742 |
raise TransactionServiceException(110,'Error in billing freebie for warehouseId ' + str(freebieWarehouseId))
|
| 1648 |
if order.productCondition != ProductCondition.BAD:
|
1743 |
if order.productCondition != ProductCondition.BAD:
|
| 1649 |
__update_inventory_reservation(order)
|
1744 |
__update_inventory_reservation(order)
|
| 1650 |
order.fulfilmentWarehouseId = warehouse.id
|
1745 |
order.fulfilmentWarehouseId = warehouse.id
|
| - |
|
1746 |
if singleInvoiceAttr:
|
| - |
|
1747 |
if singleInvoiceAttr.value == "true":
|
| - |
|
1748 |
session.commit()
|
| - |
|
1749 |
return True
|
| 1651 |
if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
|
1750 |
if billingType == BillingType.OURS or billingType == BillingType.OURS_EXTERNAL:
|
| 1652 |
order.invoice_number = get_next_invoice_number(order.orderType)
|
1751 |
order.invoice_number = get_next_invoice_number(order.orderType)
|
| 1653 |
session.commit()
|
1752 |
session.commit()
|
| 1654 |
return True
|
1753 |
return True
|
| 1655 |
else:
|
1754 |
else:
|
| Line 4270... |
Line 4369... |
| 4270 |
helperClient = HelperClient(host_key = "helper_service_server_host_prod").get_client()
|
4369 |
helperClient = HelperClient(host_key = "helper_service_server_host_prod").get_client()
|
| 4271 |
try:
|
4370 |
try:
|
| 4272 |
emailSubject = 'Shipping Details for Order ID: ' + str(order.id)
|
4371 |
emailSubject = 'Shipping Details for Order ID: ' + str(order.id)
|
| 4273 |
emailBody = get_shipping_confirmation_email_body(order)
|
4372 |
emailBody = get_shipping_confirmation_email_body(order)
|
| 4274 |
helperClient.saveUserEmailForSending([order.customer_email], None, emailSubject, emailBody, str(order.id), 'ShippingConfirmation', [], [], order.source)
|
4373 |
helperClient.saveUserEmailForSending([order.customer_email], None, emailSubject, emailBody, str(order.id), 'ShippingConfirmation', [], [], order.source)
|
| 4275 |
|
4374 |
'''
|
| - |
|
4375 |
logistics_providers = {1: {'name': 'BlueDart', 'phone': '011-66111234'}, 6: {'name': 'RedExpress', 'phone': '8373915813'}, 3: {'name': 'Delhivery', 'phone' : '0124- 4212200'}, 7: {'name': 'FedEx', 'phone' : '0120-4354176'}}
|
| - |
|
4376 |
provider_name = logistics_providers[order.logistics_provider_id]['name']
|
| - |
|
4377 |
if order.source == OrderSource.WEBSITE :
|
| - |
|
4378 |
send_transaction_sms(order.customer_id, order.customer_mobilenumber, "Dear "+ order.customer_name +", We have shipped your order: " + str(order.id) + " through "+provider_name + " AWB No. " + order.airwaybill_no, SmsType.TRANSACTIONAL)
|
| - |
|
4379 |
'''
|
| 4276 |
except Exception as e:
|
4380 |
except Exception as e:
|
| 4277 |
print e
|
4381 |
print e
|
| 4278 |
|
4382 |
|
| 4279 |
def get_order_distribution_by_status(start_date, end_date):
|
4383 |
def get_order_distribution_by_status(start_date, end_date):
|
| 4280 |
query = session.query(Order.status, func.count(Order.id)).group_by(Order.status)
|
4384 |
query = session.query(Order.status, func.count(Order.id)).group_by(Order.status)
|
| Line 4775... |
Line 4879... |
| 4775 |
FailureReasonMap = {}
|
4879 |
FailureReasonMap = {}
|
| 4776 |
FailureReasonMap["Invalid Amount"] = "the amount you tried seems to be invalid. Please try another amount."
|
4880 |
FailureReasonMap["Invalid Amount"] = "the amount you tried seems to be invalid. Please try another amount."
|
| 4777 |
FailureReasonMap["Customer Exceeded Daily Limit"] = "you have exceeded daily recharge limit for this number. Please try after 12 hours."
|
4881 |
FailureReasonMap["Customer Exceeded Daily Limit"] = "you have exceeded daily recharge limit for this number. Please try after 12 hours."
|
| 4778 |
FailureReasonMap["Invalid Device Number"] = "it seems that your device number is not being recognized by selected operator. Please make sure the number you tried is correct."
|
4882 |
FailureReasonMap["Invalid Device Number"] = "it seems that your device number is not being recognized by selected operator. Please make sure the number you tried is correct."
|
| 4779 |
|
4883 |
|
| - |
|
4884 |
'''
|
| - |
|
4885 |
FailureReasonMapSms = {}
|
| - |
|
4886 |
FailureReasonMapSms["Invalid Amount"] = " invalid amount."
|
| - |
|
4887 |
FailureReasonMapSms["Customer Exceeded Daily Limit"] = " daily limit exceeded. Please try after 12Hrs"
|
| - |
|
4888 |
FailureReasonMapSms["Invalid Device Number"] = " invalid device number."
|
| - |
|
4889 |
'''
|
| 4780 |
failureReason = FailureReasonMap.get(recharge_order.description)
|
4890 |
failureReason = FailureReasonMap.get(recharge_order.description)
|
| - |
|
4891 |
'''
|
| - |
|
4892 |
failureReasonSms = FailureReasonMapSms.get(recharge_order.description)
|
| - |
|
4893 |
|
| - |
|
4894 |
if failureReasonSms is None:
|
| - |
|
4895 |
failureReasonSms = " network failure."
|
| - |
|
4896 |
'''
|
| 4781 |
if failureReason is None:
|
4897 |
if failureReason is None:
|
| 4782 |
failureReason = "of network failure."
|
4898 |
failureReason = "of network failure."
|
| 4783 |
if recharge_order.status == RechargeOrderStatus.RECHARGE_SUCCESSFUL:
|
4899 |
if recharge_order.status == RechargeOrderStatus.RECHARGE_SUCCESSFUL:
|
| 4784 |
status = "Recharge Successful"
|
4900 |
status = "Recharge Successful"
|
| 4785 |
message = ""
|
4901 |
message = ""
|
| Line 4834... |
Line 4950... |
| 4834 |
formated_order_date = dt.strftime("%A, %d. %B %Y %I:%M%p")
|
4950 |
formated_order_date = dt.strftime("%A, %d. %B %Y %I:%M%p")
|
| 4835 |
|
4951 |
|
| 4836 |
email_header = Template(html_header).substitute(dict(order_id = display_order_id, order_date = formated_order_date, email = email, source_url = source_url, order_amount = recharge_order.totalAmount, order_status = status, device_number = deviceNumber, service_provider = providerName, failureReason = failureReason))
|
4952 |
email_header = Template(html_header).substitute(dict(order_id = display_order_id, order_date = formated_order_date, email = email, source_url = source_url, order_amount = recharge_order.totalAmount, order_status = status, device_number = deviceNumber, service_provider = providerName, failureReason = failureReason))
|
| 4837 |
email_footer = Template(html_footer).substitute(dict(source_url = source_url, source_name = source_name))
|
4953 |
email_footer = Template(html_footer).substitute(dict(source_url = source_url, source_name = source_name))
|
| 4838 |
|
4954 |
|
| - |
|
4955 |
'''
|
| - |
|
4956 |
if isinstance(recharge_order, MobileRechargeOrder):
|
| - |
|
4957 |
smsText = ""
|
| - |
|
4958 |
|
| - |
|
4959 |
if status == "Recharge Failed" and recharge_order.description == "Invalid Device Number" :
|
| - |
|
4960 |
print "Do send Sms"
|
| - |
|
4961 |
elif status == "Recharge Failed" and recharge_order.description != "Invalid Device Number" :
|
| - |
|
4962 |
smsText = "Dear Customer, We could not process your recharge due to" + failureReasonSms + " We have credited the amount to your recharge wallet. You can use wallet amount to recharge again. "
|
| - |
|
4963 |
elif status == "Recharge Successful" :
|
| - |
|
4964 |
smsText = "Thanks for recharging your mobile for Rs. "+ str(recharge_order.totalAmount) + " from Saholic.com. Order Id is "+ display_order_id + ". Any Query? please call 0120-2479977"
|
| - |
|
4965 |
elif status == "Recharge Under Process" :
|
| - |
|
4966 |
smsText = "Dear Customer, Your Payment was successful but due to some internal error with the operator's system we are not sure if the recharge was successful. In case your recharge is not processed, we will credit amount to your recharge wallet. You can use wallet amount to recharge again."
|
| - |
|
4967 |
elif status == "Recharge Failed, Amount Refunded" :
|
| - |
|
4968 |
smsText = "Dear Customer, It seems operator could not process your recharge request. We are crediting the refund amount to your recharge wallet. You can use wallet amount to recharge again."
|
| - |
|
4969 |
|
| - |
|
4970 |
try:
|
| - |
|
4971 |
send_transaction_sms(recharge_order.userId, deviceNumber, smsText, SmsType.TRANSACTIONAL)
|
| - |
|
4972 |
except Exception as e:
|
| - |
|
4973 |
print e
|
| - |
|
4974 |
try:
|
| - |
|
4975 |
helper_client = HelperClient().get_client()
|
| - |
|
4976 |
helper_client.saveUserEmailForSending([email], "", source_name + " - Recharge Order Details", email_header + email_footer, str(recharge_order.id), "RechargeInfo", [], [], 1)
|
| - |
|
4977 |
return True
|
| - |
|
4978 |
except Exception as e:
|
| - |
|
4979 |
print e
|
| - |
|
4980 |
return False
|
| - |
|
4981 |
'''
|
| 4839 |
try:
|
4982 |
try:
|
| 4840 |
helper_client = HelperClient().get_client()
|
4983 |
helper_client = HelperClient().get_client()
|
| 4841 |
helper_client.saveUserEmailForSending([email], "", source_name + " - Recharge Order Details", email_header + email_footer, str(recharge_order.id), "RechargeInfo", [], [], 1)
|
4984 |
helper_client.saveUserEmailForSending([email], "", source_name + " - Recharge Order Details", email_header + email_footer, str(recharge_order.id), "RechargeInfo", [], [], 1)
|
| 4842 |
return True
|
4985 |
return True
|
| 4843 |
except Exception as e:
|
4986 |
except Exception as e:
|
| Line 6480... |
Line 6623... |
| 6480 |
s_order = Order.get_by(id=flipkartorder.orderId)
|
6623 |
s_order = Order.get_by(id=flipkartorder.orderId)
|
| 6481 |
if s_order.cod:
|
6624 |
if s_order.cod:
|
| 6482 |
s_order.status = OrderStatus.COD_VERIFICATION_PENDING
|
6625 |
s_order.status = OrderStatus.COD_VERIFICATION_PENDING
|
| 6483 |
else:
|
6626 |
else:
|
| 6484 |
s_order.status = OrderStatus.ACCEPTED
|
6627 |
s_order.status = OrderStatus.ACCEPTED
|
| - |
|
6628 |
s_order.accepted_timetsmap = datetime.datetime.now()
|
| 6485 |
user = None
|
6629 |
user = None
|
| 6486 |
try:
|
6630 |
try:
|
| 6487 |
user_client = UserClient().get_client()
|
6631 |
user_client = UserClient().get_client()
|
| 6488 |
user_to_add = User()
|
6632 |
user_to_add = User()
|
| 6489 |
user_to_add.email = 'FK.'+ str(flipkartorder.orderId) + '@mailinator.com'
|
6633 |
user_to_add.email = 'FK.'+ str(flipkartorder.orderId) + '@mailinator.com'
|
| Line 6970... |
Line 7114... |
| 6970 |
order_ids.append(order.id)
|
7114 |
order_ids.append(order.id)
|
| 6971 |
retFkOrders = FlipkartOrder.query.filter(FlipkartOrder.orderId.in_(tuple(order_ids)))
|
7115 |
retFkOrders = FlipkartOrder.query.filter(FlipkartOrder.orderId.in_(tuple(order_ids)))
|
| 6972 |
if not retFkOrders:
|
7116 |
if not retFkOrders:
|
| 6973 |
retFkOrders = []
|
7117 |
retFkOrders = []
|
| 6974 |
return retFkOrders
|
7118 |
return retFkOrders
|
| - |
|
7119 |
|
| - |
|
7120 |
def add_invoice_details_to_orders(transactionId, customerId):
|
| - |
|
7121 |
orders = Order.query.filter_by(transaction_id=transactionId, customer_id=customerId).all()
|
| - |
|
7122 |
if not orders:
|
| - |
|
7123 |
raise TransactionServiceException(101, "No order for the transaction Unable to Print Invoice")
|
| - |
|
7124 |
else:
|
| - |
|
7125 |
invoiceNo = get_next_invoice_number(orders[0].orderType)
|
| - |
|
7126 |
for order in orders:
|
| - |
|
7127 |
order.invoice_number = invoiceNo
|
| - |
|
7128 |
session.commit()
|
| 6975 |
|
7129 |
|
| 6976 |
if __name__ == '__main__':
|
7130 |
if __name__ == '__main__':
|
| 6977 |
print get_orders_by_mobile_number("9650889334")
|
7131 |
print get_orders_by_mobile_number("9650889334")
|