| 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.utils.ttypes import UserSmsInfo, SmsType
|
| 74 |
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType, CouponCategory, \
|
74 |
from shop2020.thriftpy.model.v1.user.ttypes import VoucherType, CouponCategory, \
|
| 75 |
User, Sex
|
75 |
User, Sex
|
| 76 |
from shop2020.thriftpy.payments.ttypes import PaymentException
|
76 |
from shop2020.thriftpy.payments.ttypes import PaymentException
|
| 77 |
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
|
77 |
from shop2020.thriftpy.warehouse.ttypes import ScanType, \
|
| 78 |
WarehouseServiceException
|
78 |
WarehouseServiceException
|
| Line 688... |
Line 688... |
| 688 |
|
688 |
|
| 689 |
|
689 |
|
| 690 |
def enqueue_transaction_info_email(transaction_id):
|
690 |
def enqueue_transaction_info_email(transaction_id):
|
| 691 |
transaction = get_transaction(transaction_id)
|
691 |
transaction = get_transaction(transaction_id)
|
| 692 |
'''
|
692 |
'''
|
| 693 |
smsText = "Thanks for ordering "
|
693 |
smsText = "Dear Customer, Thanks for ordering "
|
| 694 |
otgSms = False
|
694 |
otgSms = False
|
| 695 |
mobileNo = None
|
695 |
mobileNo = None
|
| 696 |
customerId = 0
|
696 |
customerId = 0
|
| 697 |
'''
|
697 |
'''
|
| 698 |
subject = source_name + " - Order Details"
|
698 |
subject = source_name + " - Order Details"
|
| Line 773... |
Line 773... |
| 773 |
attribute.name = "SECRET_CODE"
|
773 |
attribute.name = "SECRET_CODE"
|
| 774 |
attribute.value = random_text
|
774 |
attribute.value = random_text
|
| 775 |
session.commit()
|
775 |
session.commit()
|
| 776 |
|
776 |
|
| 777 |
for lineitem in order.lineitems:
|
777 |
for lineitem in order.lineitems:
|
| 778 |
#smsText = smsText + lineitem.brand + " " + lineitem.model_name + " " + lineitem.model_number + "("+str(lineitem.quantity)+ ")" +" "
|
778 |
#smsText = smsText + lineitem.brand + " " + lineitem.model_name + " " + lineitem.model_number + "("+str(lineitem.quantity)+ ")" +". "
|
| 779 |
lineitem_total_price = round(lineitem.total_price, 2)
|
779 |
lineitem_total_price = round(lineitem.total_price, 2)
|
| 780 |
|
780 |
|
| 781 |
html_tr += "<td>" + str(lineitem) + "</td>"
|
781 |
html_tr += "<td>" + str(lineitem) + "</td>"
|
| 782 |
if order.otg:
|
782 |
if order.otg:
|
| 783 |
html_tr += "<td align='center'><div>" + store_delivery_date + "</div>" + inOrderOtg + "</td>"
|
783 |
html_tr += "<td align='center'><div>" + store_delivery_date + "</div>" + inOrderOtg + "</td>"
|
| Line 797... |
Line 797... |
| 797 |
html_table += "<tr><td colspan=6> </td></tr>"
|
797 |
html_table += "<tr><td colspan=6> </td></tr>"
|
| 798 |
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>"
|
798 |
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>"
|
| 799 |
html_table += "<td align='center'>" + str(order.insuranceAmount) + "</td></tr>"
|
799 |
html_table += "<td align='center'>" + str(order.insuranceAmount) + "</td></tr>"
|
| 800 |
total_amount += order.insuranceAmount
|
800 |
total_amount += order.insuranceAmount
|
| 801 |
|
801 |
|
| 802 |
#smsText = smsText + "Saholic.com"
|
802 |
#smsText = smsText + "Saholic.com."
|
| 803 |
emi_amount = 0
|
803 |
emi_amount = 0
|
| 804 |
miscCharges = get_misc_charges(transaction_id)
|
804 |
miscCharges = get_misc_charges(transaction_id)
|
| 805 |
if miscCharges.get(1):
|
805 |
if miscCharges.get(1):
|
| 806 |
emi_amount = miscCharges.get(1)
|
806 |
emi_amount = miscCharges.get(1)
|
| 807 |
|
807 |
|
| Line 893... |
Line 893... |
| 893 |
except Exception as e:
|
893 |
except Exception as e:
|
| 894 |
print e
|
894 |
print e
|
| 895 |
return False
|
895 |
return False
|
| 896 |
'''
|
896 |
'''
|
| 897 |
if otgSms:
|
897 |
if otgSms:
|
| 898 |
smsText = smsText +" On Time Guarantee We Pay if we Delay. T&C Apply"
|
898 |
smsText = smsText +" Order comes under On Time Guarantee We Pay if we Delay. T&C Apply"
|
| 899 |
|
899 |
|
| 900 |
try:
|
900 |
try:
|
| 901 |
helper_client = HelperClient().get_client()
|
901 |
helper_client = HelperClient().get_client()
|
| 902 |
helper_client.saveUserEmailForSending([user_email], "", subject, email_header + html_table + email_footer, str(transaction_id), "TransactionInfo", [], bcc, orders[0].source)
|
902 |
helper_client.saveUserEmailForSending([user_email], "", subject, email_header + html_table + email_footer, str(transaction_id), "TransactionInfo", [], bcc, orders[0].source)
|
| 903 |
except Exception as e:
|
903 |
except Exception as e:
|
| Line 1198... |
Line 1198... |
| 1198 |
try:
|
1198 |
try:
|
| 1199 |
helper_client = HelperClient(host_key = "helper_service_server_host_prod").get_client()
|
1199 |
helper_client = HelperClient(host_key = "helper_service_server_host_prod").get_client()
|
| 1200 |
helper_client.saveUserEmailForSending([user_email], "", subject, email_header + html_table + email_footer, str(order.id), "DeliverySuccess", [], [], order.source)
|
1200 |
helper_client.saveUserEmailForSending([user_email], "", subject, email_header + html_table + email_footer, str(order.id), "DeliverySuccess", [], [], order.source)
|
| 1201 |
'''
|
1201 |
'''
|
| 1202 |
if order.source == OrderSource.WEBSITE:
|
1202 |
if order.source == OrderSource.WEBSITE:
|
| 1203 |
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)
|
1203 |
send_transaction_sms(order.customer_id, order.customer_mobilenumber, "Dear Customer, Your order: " + str(order.id) + " has been delivered now. For any queries please call 0120-2479977." , SmsType.TRANSACTIONAL)
|
| 1204 |
'''
|
1204 |
'''
|
| 1205 |
return True
|
1205 |
return True
|
| 1206 |
except Exception as e:
|
1206 |
except Exception as e:
|
| 1207 |
print e
|
1207 |
print e
|
| 1208 |
return False
|
1208 |
return False
|
| Line 4460... |
Line 4460... |
| 4460 |
helperClient.saveUserEmailForSending([order.customer_email], None, emailSubject, emailBody, str(order.id), 'ShippingConfirmation', [], [], order.source)
|
4460 |
helperClient.saveUserEmailForSending([order.customer_email], None, emailSubject, emailBody, str(order.id), 'ShippingConfirmation', [], [], order.source)
|
| 4461 |
'''
|
4461 |
'''
|
| 4462 |
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'}}
|
4462 |
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'}}
|
| 4463 |
provider_name = logistics_providers[order.logistics_provider_id]['name']
|
4463 |
provider_name = logistics_providers[order.logistics_provider_id]['name']
|
| 4464 |
if order.source == OrderSource.WEBSITE :
|
4464 |
if order.source == OrderSource.WEBSITE :
|
| 4465 |
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)
|
4465 |
send_transaction_sms(order.customer_id, order.customer_mobilenumber, "Dear Customer, We have shipped your order: " + str(order.id) + " through "+provider_name + " AWB No. " + order.airwaybill_no, SmsType.TRANSACTIONAL)
|
| 4466 |
'''
|
4466 |
'''
|
| 4467 |
except Exception as e:
|
4467 |
except Exception as e:
|
| 4468 |
print e
|
4468 |
print e
|
| 4469 |
|
4469 |
|
| 4470 |
def get_order_distribution_by_status(start_date, end_date):
|
4470 |
def get_order_distribution_by_status(start_date, end_date):
|
| Line 4966... |
Line 4966... |
| 4966 |
FailureReasonMap = {}
|
4966 |
FailureReasonMap = {}
|
| 4967 |
FailureReasonMap["Invalid Amount"] = "the amount you tried seems to be invalid. Please try another amount."
|
4967 |
FailureReasonMap["Invalid Amount"] = "the amount you tried seems to be invalid. Please try another amount."
|
| 4968 |
FailureReasonMap["Customer Exceeded Daily Limit"] = "you have exceeded daily recharge limit for this number. Please try after 12 hours."
|
4968 |
FailureReasonMap["Customer Exceeded Daily Limit"] = "you have exceeded daily recharge limit for this number. Please try after 12 hours."
|
| 4969 |
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."
|
4969 |
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."
|
| 4970 |
|
4970 |
|
| 4971 |
'''
|
4971 |
|
| 4972 |
FailureReasonMapSms = {}
|
4972 |
FailureReasonMapSms = {}
|
| 4973 |
FailureReasonMapSms["Invalid Amount"] = " invalid amount."
|
4973 |
FailureReasonMapSms["Invalid Amount"] = " invalid amount."
|
| 4974 |
FailureReasonMapSms["Customer Exceeded Daily Limit"] = " daily limit exceeded. Please try after 12Hrs"
|
4974 |
FailureReasonMapSms["Customer Exceeded Daily Limit"] = " daily limit exceeded. Please try after 12Hrs."
|
| 4975 |
FailureReasonMapSms["Invalid Device Number"] = " invalid device number."
|
4975 |
FailureReasonMapSms["Invalid Device Number"] = " invalid device number."
|
| 4976 |
'''
|
4976 |
|
| 4977 |
failureReason = FailureReasonMap.get(recharge_order.description)
|
4977 |
failureReason = FailureReasonMap.get(recharge_order.description)
|
| 4978 |
'''
|
4978 |
|
| 4979 |
failureReasonSms = FailureReasonMapSms.get(recharge_order.description)
|
4979 |
failureReasonSms = FailureReasonMapSms.get(recharge_order.description)
|
| 4980 |
|
4980 |
|
| 4981 |
if failureReasonSms is None:
|
4981 |
if failureReasonSms is None:
|
| 4982 |
failureReasonSms = " network failure."
|
4982 |
failureReasonSms = " network failure."
|
| 4983 |
'''
|
4983 |
|
| 4984 |
if failureReason is None:
|
4984 |
if failureReason is None:
|
| 4985 |
failureReason = "of network failure."
|
4985 |
failureReason = "of network failure."
|
| 4986 |
if recharge_order.status == RechargeOrderStatus.RECHARGE_SUCCESSFUL:
|
4986 |
if recharge_order.status == RechargeOrderStatus.RECHARGE_SUCCESSFUL:
|
| 4987 |
status = "Recharge Successful"
|
4987 |
status = "Recharge Successful"
|
| 4988 |
message = ""
|
4988 |
message = ""
|
| Line 5037... |
Line 5037... |
| 5037 |
formated_order_date = dt.strftime("%A, %d. %B %Y %I:%M%p")
|
5037 |
formated_order_date = dt.strftime("%A, %d. %B %Y %I:%M%p")
|
| 5038 |
|
5038 |
|
| 5039 |
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))
|
5039 |
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))
|
| 5040 |
email_footer = Template(html_footer).substitute(dict(source_url = source_url, source_name = source_name))
|
5040 |
email_footer = Template(html_footer).substitute(dict(source_url = source_url, source_name = source_name))
|
| 5041 |
|
5041 |
|
| 5042 |
'''
|
5042 |
|
| 5043 |
if isinstance(recharge_order, MobileRechargeOrder):
|
5043 |
if isinstance(recharge_order, MobileRechargeOrder):
|
| 5044 |
smsText = ""
|
5044 |
smsText = ""
|
| 5045 |
|
5045 |
|
| 5046 |
if status == "Recharge Failed" and recharge_order.description == "Invalid Device Number" :
|
5046 |
if status == "Recharge Failed" and recharge_order.description == "Invalid Device Number" :
|
| 5047 |
print "Do send Sms"
|
5047 |
print "Do send Sms"
|
| - |
|
5048 |
'''
|
| - |
|
5049 |
try:
|
| - |
|
5050 |
helper_client = HelperClient().get_client()
|
| - |
|
5051 |
helper_client.saveUserEmailForSending([email], "", source_name + " - Recharge Order Details", email_header + email_footer, str(recharge_order.id), "RechargeInfo", [], [], 1)
|
| - |
|
5052 |
except Exception as e:
|
| - |
|
5053 |
print e
|
| - |
|
5054 |
'''
|
| 5048 |
elif status == "Recharge Failed" and recharge_order.description != "Invalid Device Number" :
|
5055 |
elif status == "Recharge Failed" and recharge_order.description != "Invalid Device Number" :
|
| 5049 |
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. "
|
5056 |
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. "
|
| 5050 |
elif status == "Recharge Successful" :
|
5057 |
elif status == "Recharge Successful" :
|
| 5051 |
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"
|
5058 |
smsText = "Dear Customer, 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"
|
| 5052 |
elif status == "Recharge Under Process" :
|
5059 |
elif status == "Recharge Under Process" :
|
| 5053 |
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."
|
5060 |
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."
|
| - |
|
5061 |
#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.
|
| 5054 |
elif status == "Recharge Failed, Amount Refunded" :
|
5062 |
elif status == "Recharge Failed, Amount Refunded" :
|
| 5055 |
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."
|
5063 |
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."
|
| 5056 |
|
5064 |
|
| 5057 |
try:
|
5065 |
try:
|
| 5058 |
send_transaction_sms(recharge_order.userId, deviceNumber, smsText, SmsType.TRANSACTIONAL)
|
5066 |
send_transaction_sms(recharge_order.userId, deviceNumber, smsText, SmsType.TRANSACTIONAL)
|
| 5059 |
except Exception as e:
|
5067 |
except Exception as e:
|
| 5060 |
print e
|
5068 |
print e
|
| 5061 |
try:
|
5069 |
pass
|
| 5062 |
helper_client = HelperClient().get_client()
|
- |
|
| 5063 |
helper_client.saveUserEmailForSending([email], "", source_name + " - Recharge Order Details", email_header + email_footer, str(recharge_order.id), "RechargeInfo", [], [], 1)
|
- |
|
| 5064 |
return True
|
- |
|
| 5065 |
except Exception as e:
|
- |
|
| 5066 |
print e
|
- |
|
| 5067 |
return False
|
- |
|
| 5068 |
'''
|
5070 |
|
| 5069 |
try:
|
5071 |
try:
|
| 5070 |
helper_client = HelperClient().get_client()
|
5072 |
helper_client = HelperClient().get_client()
|
| 5071 |
helper_client.saveUserEmailForSending([email], "", source_name + " - Recharge Order Details", email_header + email_footer, str(recharge_order.id), "RechargeInfo", [], [], 1)
|
5073 |
helper_client.saveUserEmailForSending([email], "", source_name + " - Recharge Order Details", email_header + email_footer, str(recharge_order.id), "RechargeInfo", [], [], 1)
|
| 5072 |
return True
|
5074 |
return True
|
| 5073 |
except Exception as e:
|
5075 |
except Exception as e:
|