Subversion Repositories SmartDukaan

Rev

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

Rev 12984 Rev 12992
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
    #Dear Customer, thanks for placing order of Spice Stellar Mi-535 Black and 5 other items amounting Rs. 25000. Check your email for details.
-
 
694
    
693
    smsText = "Dear Customer, Thanks for ordering "
695
    smsText = "Dear Customer, thanks for placing order of "
694
    otgSms = False
-
 
695
    mobileNo = None
696
    mobileNo = None
696
    customerId = 0
697
    customerId = 0
-
 
698
    sendSms = True
-
 
699
    transactionAmount = 0.0
-
 
700
    orderQuantity = 0        
697
    
701
    
698
    subject = source_name + " - Order Details"
702
    subject = source_name + " - Order Details"
699
    orders = transaction.orders
703
    orders = transaction.orders
700
    advance_amount = orders[0].advanceAmount
704
    advance_amount = orders[0].advanceAmount
701
    saddress = ""
705
    saddress = ""
-
 
706
    
-
 
707
    for order in orders:
-
 
708
        if order.pickupStoreId:
-
 
709
            sendSms= False
-
 
710
        transactionAmount = transactionAmount + order.total_amount
-
 
711
        for lineitem in order.lineitems:
-
 
712
            orderQuantity = orderQuantity + lineitem.model_number
-
 
713
    
-
 
714
    oneProduct = str(orders[0].lineitems[0])
-
 
715
    
-
 
716
    smsText = smsText + oneProduct
-
 
717
            
-
 
718
    orderQuantity = orderQuantity - 1
-
 
719
    
-
 
720
    if orderQuantity !=0 and orderQuantity >0:
-
 
721
        smsText = smsText + " and " + str(orderQuantity) + " other items"
-
 
722
    
-
 
723
    smsText = smsText +" amounting Rs. "+transactionAmount+ ". Check your email for details." 
-
 
724
        
702
    bcc = []
725
    bcc = []
703
    if advance_amount  > 0:
726
    if advance_amount  > 0:
704
        store = get_hotspot_store(orders[0].storeId, "")
727
        store = get_hotspot_store(orders[0].storeId, "")
705
        bcc = bcc + store.approvalEmail.split(';')  + [store.email,  "amit.gupta@shop2020.in", "rajneesh.arora@shop2020.in", "amit.sirohi@shop2020.in"]
728
        bcc = bcc + store.approvalEmail.split(';')  + [store.email,  "amit.gupta@shop2020.in", "rajneesh.arora@shop2020.in", "amit.sirohi@shop2020.in"]
706
        saddress += " at our store " + __get_hotspot_store_address_html(store)
729
        saddress += " at our store " + __get_hotspot_store_address_html(store)
707
    otgLink = ""
730
    otgLink = ""
708
    inOrderOtg = "<div>On Time Guarantee<br><span style=color:red>We pay if we delay</span></div>"
731
    inOrderOtg = "<div>On Time Guarantee<br><span style=color:red>We pay if we delay</span></div>"
709
    if len(transaction.orders) == 1:
732
    if len(transaction.orders) == 1:
710
        inOrderOtg = ""
733
        inOrderOtg = ""
711
        if transaction.orders[0].otg :
734
        if transaction.orders[0].otg :
712
            otgSms = True
-
 
713
            subject = "Your Order is confirmed with On Time Guarantee We Pay if we Delay"
735
            subject = "Your Order is confirmed with On Time Guarantee We Pay if we Delay"
714
            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>'
736
            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>'
715
    
737
    
716
    customer_name = "" 
738
    customer_name = "" 
717
    html_header = """
739
    html_header = """
Line 773... Line 795...
773
            attribute.name = "SECRET_CODE"
795
            attribute.name = "SECRET_CODE"
774
            attribute.value = random_text
796
            attribute.value = random_text
775
            session.commit()
797
            session.commit()
776
        
798
        
777
        for lineitem in order.lineitems:
799
        for lineitem in order.lineitems:
778
            smsText = smsText + lineitem.brand + " " + lineitem.model_name + " " + lineitem.model_number + "("+str(lineitem.quantity)+ ")" +". "
-
 
779
            lineitem_total_price = round(lineitem.total_price, 2)
800
            lineitem_total_price = round(lineitem.total_price, 2)
780
            
801
            
781
            html_tr += "<td>" + str(lineitem) + "</td>"
802
            html_tr += "<td>" + str(lineitem) + "</td>"
782
            if order.otg:
803
            if order.otg:
783
                html_tr += "<td align='center'><div>" + store_delivery_date + "</div>" + inOrderOtg + "</td>"
804
                html_tr += "<td align='center'><div>" + store_delivery_date + "</div>" + inOrderOtg + "</td>"
Line 786... Line 807...
786
            html_tr += "<td align='center'>" + ("%.0f" % lineitem.quantity) + "</td>"
807
            html_tr += "<td align='center'>" + ("%.0f" % lineitem.quantity) + "</td>"
787
            html_tr += "<td align='center'> Rs. " + ("%.2f" % lineitem.unit_price) + "</td>"
808
            html_tr += "<td align='center'> Rs. " + ("%.2f" % lineitem.unit_price) + "</td>"
788
            html_tr += "<td align='center'> Rs. " + ("%.2f" % lineitem_total_price) + "</td></tr>"
809
            html_tr += "<td align='center'> Rs. " + ("%.2f" % lineitem_total_price) + "</td></tr>"
789
            total_amount += lineitem_total_price
810
            total_amount += lineitem_total_price
790
            html_table += html_tr
811
            html_table += html_tr
791
        smsText = smsText + "Order Id: "+str(order.id)+" "
-
 
792
        if order.freebieItemId:
812
        if order.freebieItemId:
793
            catalog_client = CatalogClient().get_client()
813
            catalog_client = CatalogClient().get_client()
794
            item = catalog_client.getItem(order.freebieItemId)
814
            item = catalog_client.getItem(order.freebieItemId)
795
            html_table += "<tr><td align='center'></td><td style='font-style:italic;' colspan='5'> Free Item: "+item.brand + " " + item.modelName + " " + item.modelNumber+"</td></tr>"
815
            html_table += "<tr><td align='center'></td><td style='font-style:italic;' colspan='5'> Free Item: "+item.brand + " " + item.modelName + " " + item.modelNumber+"</td></tr>"
796
        if order.insurer:
816
        if order.insurer:
797
            html_table += "<tr><td colspan=6>&nbsp;</td></tr>"
817
            html_table += "<tr><td colspan=6>&nbsp;</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>"
818
            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>"
819
            html_table += "<td align='center'>" + str(order.insuranceAmount) + "</td></tr>"
800
            total_amount += order.insuranceAmount
820
            total_amount += order.insuranceAmount
801
            
821
            
802
    smsText = smsText + "Saholic.com." 
-
 
803
    emi_amount = 0
822
    emi_amount = 0
804
    miscCharges = get_misc_charges(transaction_id)
823
    miscCharges = get_misc_charges(transaction_id)
805
    if miscCharges.get(1):
824
    if miscCharges.get(1):
806
        emi_amount = miscCharges.get(1)
825
        emi_amount = miscCharges.get(1)
807
        
826
        
Line 883... Line 902...
883
    store_delivery_date = sdt.strftime("%A, %d %B %Y")
902
    store_delivery_date = sdt.strftime("%A, %d %B %Y")
884
 
903
 
885
    email_header = Template(html_header).substitute(dict(order_date = formated_order_date, customer_name = customer_name, source_url = source_url, otgLink = otgLink, saddress = saddress))
904
    email_header = Template(html_header).substitute(dict(order_date = formated_order_date, customer_name = customer_name, source_url = source_url, otgLink = otgLink, saddress = saddress))
886
    email_footer = Template(html_footer).substitute(dict(total_amount = "%.2f" % total_amount, emi_amount = "%.2f" % emi_amount, advance_amount = "%.2f" % advance_amount, net_amount = "%.2f" % (total_amount-order.gvAmount), secret_code = random_text, store_address = store_address, store_delivery_date = store_delivery_date, source_url = source_url, source_name = source_name, amount_string = amount_string))
905
    email_footer = Template(html_footer).substitute(dict(total_amount = "%.2f" % total_amount, emi_amount = "%.2f" % emi_amount, advance_amount = "%.2f" % advance_amount, net_amount = "%.2f" % (total_amount-order.gvAmount), secret_code = random_text, store_address = store_address, store_delivery_date = store_delivery_date, source_url = source_url, source_name = source_name, amount_string = amount_string))
887
 
906
 
888
    if otgSms:
-
 
889
        smsText = smsText +" Order comes under On Time Guarantee We Pay if we Delay. T&C Apply"
-
 
890
    
-
 
891
    try:
907
    try:
892
        helper_client = HelperClient().get_client()
908
        helper_client = HelperClient().get_client()
893
        helper_client.saveUserEmailForSending([user_email], "", subject, email_header + html_table + email_footer, str(transaction_id), "TransactionInfo", [], bcc, orders[0].source)
909
        helper_client.saveUserEmailForSending([user_email], "", subject, email_header + html_table + email_footer, str(transaction_id), "TransactionInfo", [], bcc, orders[0].source)
-
 
910
        if sendSms:
894
        send_transaction_sms(customerId, mobileNo, smsText, SmsType.TRANSACTIONAL)
911
            send_transaction_sms(customerId, mobileNo, smsText, SmsType.TRANSACTIONAL)
895
        return True
912
        return True
896
    except Exception as e:
913
    except Exception as e:
897
        print e
914
        print e
898
        return False
915
        return False
899
    
916