Subversion Repositories SmartDukaan

Rev

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

Rev 13449 Rev 13455
Line 941... Line 941...
941
    try:
941
    try:
942
        helper_client = HelperClient().get_client()
942
        helper_client = HelperClient().get_client()
943
        helper_client.saveUserEmailForSending([user_email], "", subject, email_header + html_table + email_footer, str(transaction_id), "TransactionInfo", [], bcc, orders[0].source)
943
        helper_client.saveUserEmailForSending([user_email], "", subject, email_header + html_table + email_footer, str(transaction_id), "TransactionInfo", [], bcc, orders[0].source)
944
        
944
        
945
        if sendSms:
945
        if sendSms:
946
            send_transaction_sms(customerId, mobileNo, smsText, SmsType.TRANSACTIONAL)
946
            send_transaction_sms(customerId, mobileNo, smsText, SmsType.TRANSACTIONAL, False)
947
        
947
        
948
        return True
948
        return True
949
    except Exception as e:
949
    except Exception as e:
950
        print e
950
        print e
951
        return False
951
        return False
952
    
952
    
953
def send_transaction_sms(customerId, mobileNo, smsText, smsType):
953
def send_transaction_sms(customerId, mobileNo, smsText, smsType, useKey):
-
 
954
    if useKey:
-
 
955
        if mobileNo is not None:
-
 
956
            helper_client = HelperClient(host_key = "helper_service_server_host_prod").get_client()
-
 
957
            helper_client.saveUserSmsForSending(customerId, mobileNo, smsText, SmsType.TRANSACTIONAL)
-
 
958
            userSmsInfo = helper_client.getUserSmsInfo(customerId);
-
 
959
            if customerId == userSmsInfo.userId and mobileNo == userSmsInfo.mobileNo:
-
 
960
                userSmsInfo.dailyCount = userSmsInfo.dailyCount +1
-
 
961
                userSmsInfo.weeklyCount = userSmsInfo.weeklyCount +1
-
 
962
                helper_client.updateUserSmsInfo(userSmsInfo)
-
 
963
            elif customerId == userSmsInfo.userId and mobileNo != userSmsInfo.mobileNo:
-
 
964
                userSmsInfo.updateTimestamp = to_java_date(datetime.datetime.now())
-
 
965
                userSmsInfo.mobileNo = mobileNo
-
 
966
                userSmsInfo.dailyCount = 1
-
 
967
                userSmsInfo.weeklyCount = 1
-
 
968
                helper_client.updateUserSmsInfo(userSmsInfo)
-
 
969
            else:
-
 
970
                userSmsInfo = UserSmsInfo()
-
 
971
                userSmsInfo.userId = customerId
-
 
972
                userSmsInfo.mobileNo = mobileNo
-
 
973
                userSmsInfo.createdTimestamp = to_java_date(datetime.datetime.now())
-
 
974
                userSmsInfo.updateTimestamp = to_java_date(datetime.datetime.now())
-
 
975
                helper_client.addUserSmsInfo(userSmsInfo);
-
 
976
    else:
954
    if mobileNo is not None:
977
        if mobileNo is not None:
955
            helper_client = HelperClient().get_client()
978
            helper_client = HelperClient().get_client()
956
            helper_client.saveUserSmsForSending(customerId, mobileNo, smsText, SmsType.TRANSACTIONAL)
979
            helper_client.saveUserSmsForSending(customerId, mobileNo, smsText, SmsType.TRANSACTIONAL)
957
            userSmsInfo = helper_client.getUserSmsInfo(customerId);
980
            userSmsInfo = helper_client.getUserSmsInfo(customerId);
958
            if customerId == userSmsInfo.userId and mobileNo == userSmsInfo.mobileNo:
981
            if customerId == userSmsInfo.userId and mobileNo == userSmsInfo.mobileNo:
959
                userSmsInfo.dailyCount = userSmsInfo.dailyCount +1
982
                userSmsInfo.dailyCount = userSmsInfo.dailyCount +1
Line 4807... Line 4830...
4807
    helperClient.saveUserEmailForSending([order.customer_email], None, emailSubject, emailBody, logisticsTxnId, 'ShippingConfirmation', [], [], order.source)
4830
    helperClient.saveUserEmailForSending([order.customer_email], None, emailSubject, emailBody, logisticsTxnId, 'ShippingConfirmation', [], [], order.source)
4808
    
4831
    
4809
    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'}}
4832
    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'}}
4810
    provider_name = logistics_providers[order.logistics_provider_id]['name']
4833
    provider_name = logistics_providers[order.logistics_provider_id]['name']
4811
    if order.source == OrderSource.WEBSITE :
4834
    if order.source == OrderSource.WEBSITE :
4812
        send_transaction_sms(order.customer_id, order.customer_mobilenumber, "Dear Customer, We have shipped your order: " + logisticsTxnId + " through "+provider_name + " AWB No. " + order.airwaybill_no, SmsType.TRANSACTIONAL)    
4835
        send_transaction_sms(order.customer_id, order.customer_mobilenumber, "Dear Customer, We have shipped your order: " + logisticsTxnId + " through "+provider_name + " AWB No. " + order.airwaybill_no, SmsType.TRANSACTIONAL, True)    
4813
    
4836
    
4814
    
4837
    
4815
def get_order_distribution_by_status(start_date, end_date):
4838
def get_order_distribution_by_status(start_date, end_date):
4816
    query = session.query(Order.status, func.count(Order.id)).group_by(Order.status)
4839
    query = session.query(Order.status, func.count(Order.id)).group_by(Order.status)
4817
    query = query.filter(Order.created_timestamp >= start_date)
4840
    query = query.filter(Order.created_timestamp >= start_date)
Line 5454... Line 5477...
5454
        elif status == "Recharge Failed, Amount Refunded" :
5477
        elif status == "Recharge Failed, Amount Refunded" :
5455
            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."
5478
            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."
5456
        
5479
        
5457
        if smsText is not None and len(smsText)>0 and recharge_order.status!=RechargeOrderStatus.RECHARGE_UNKNOWN:
5480
        if smsText is not None and len(smsText)>0 and recharge_order.status!=RechargeOrderStatus.RECHARGE_UNKNOWN:
5458
            try:
5481
            try:
5459
                send_transaction_sms(recharge_order.userId, deviceNumber, smsText, SmsType.TRANSACTIONAL)
5482
                send_transaction_sms(recharge_order.userId, deviceNumber, smsText, SmsType.TRANSACTIONAL, False)
5460
            except Exception as e:
5483
            except Exception as e:
5461
                print e
5484
                print e
5462
                pass
5485
                pass
5463
        
5486
        
5464
    if recharge_order.status == RechargeOrderStatus.RECHARGE_UNKNOWN:
5487
    if recharge_order.status == RechargeOrderStatus.RECHARGE_UNKNOWN: