0% found this document useful (0 votes)
0 views

Computer science

The document outlines proposed enhancements for a customer service application, including password security improvements, two-factor authentication, order tracking, user profile management, and a loyalty program. It also includes source code for various functionalities such as customer account creation, order placement, and subscription management. Additionally, it provides a main function to navigate through the application features.

Uploaded by

haritharajan2407
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Computer science

The document outlines proposed enhancements for a customer service application, including password security improvements, two-factor authentication, order tracking, user profile management, and a loyalty program. It also includes source code for various functionalities such as customer account creation, order placement, and subscription management. Additionally, it provides a main function to navigate through the application features.

Uploaded by

haritharajan2407
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

111111FUTURE ENHANCEMENTS

1. Password Security Improvements


 Implement password hashing (using bcrypt or
hashlib) and add password strength valida on
(e.g., requiring a mix of uppercase, lowercase,
numbers, and special characters).
2. Two-Factor Authen ca on (2FA)
 Add 2FA for customer login to improve security by
requiring a second form of verifica on, such as an
SMS code or email link.
3. Order Tracking and No fica ons
 Implement real- me order tracking and send
SMS/email no fica ons to customers as the order
progresses through different stages.
4. User Profile Management
 Allow customers to upload a profile picture, set
delivery preferences, and manage their contact
informa on.
5. Loyalty Program
 Introduce a loyalty program that rewards
customers with points for every order, which can
be redeemed for discounts or free services.
6. Order Cancella on and Refund Policies
 Allow customers to cancel orders within a specified
me frame and implement a refund policy based
on the cancella on rules.
7. Subscrip on Management
 Enable customers to upgrade or downgrade their
Golden Member subscrip on and manage their
renewal preferences.
8. Admin Dashboard
 Develop an admin panel to manage orders, track
customer ac vity, and generate reports on sales,
cancella ons, and subscrip ons.
9. Mobile App Development
 Build a mobile app for customers to easily manage
their accounts, place orders, and track deliveries
from their smartphones.
10. Integra on with Payment Gateways
 Integrate mul ple payment gateways (e.g., PayPal,
Stripe) to provide secure, convenient, and varied
payment op ons for customers.
SOURCE CODE
import mysql.connector
import random
import me

# Global variable for customer_id


customer_id = None

# Connect to the MySQL database


def get_connec on():
try:
conn = mysql.connector.connect(
host="localhost",
user="root", # Your MySQL username
password="haritha007", # Your MySQL
password
database="CaringCourierDBase" # Your
database name
)
return conn
except mysql.connector.Error as err:
print(f"Error: {err}")
return None

# Create customer account with a normal password


def create_customer():
name = input("Enter your name: ")
email = input("Enter your email: ")

if email_exists(email):
print("Email already exists!")
return None

mobile = input("Enter your mobile number: ")

# No password valida on, just a simple prompt for


password input
password = input("Enter a password: ")

conn = get_connec on()


if conn:
cursor = conn.cursor()
query = "INSERT INTO customers (name, email,
mobile, password) VALUES (%s, %s, %s, %s)"
cursor.execute(query, (name, email, mobile,
password))
conn.commit()
cursor.close()
conn.close()
print("Account created successfully!")
return email
return None

# Check if email already exists


def email_exists(email):
conn = get_connec on()
if conn:
cursor = conn.cursor()
query = "SELECT * FROM customers WHERE email
= %s"
cursor.execute(query, (email,))
result = cursor.fetchone()
cursor.close()
conn.close()
return result is not None
return False

# Customer login
def customer_login():
global customer_id
email = input("Enter your email address: ")
password = input("Enter your password: ")

conn = get_connec on()


if conn:
cursor = conn.cursor()
query = "SELECT * FROM customers WHERE email
= %s AND password = %s"
cursor.execute(query, (email, password))
customer = cursor.fetchone()
if customer:
customer_id = customer[0]
print(f"Login successful! Your customer ID is
{customer_id}.")
cursor.close()
conn.close()
return customer_id
else:
print("Incorrect email or password.")
cursor.close()
conn.close()
return None

# Golden Member Subscrip on


def golden_member_subscrip on():
print("Choose your Golden Member package:")
print("1. Yearly package: ₹1999")
print("2. Monthly package: ₹499")
choice = input("Enter your choice (1/2): ")
if choice == '1':
print("You have selected the Yearly package for
₹1999.")
elif choice == '2':
print("You have selected the Monthly package for
₹499.")
else:
print("Invalid choice, please select either 1 or 2.")

# Place an order and simulate status updates


def place_order(customer_id):
pickup_address = input("Enter the pickup address: ")
delivery_address = input("Enter the delivery address:
")

tracking_id = str(random.randint(1000, 9999))


order_status = "Order Received"

conn = get_connec on()


if conn:
cursor = conn.cursor()
query = "INSERT INTO orders (customer_id,
tracking_id, pickup_address, delivery_address,
order_status) VALUES (%s, %s, %s, %s, %s)"
cursor.execute(query, (customer_id, tracking_id,
pickup_address, delivery_address, order_status))
conn.commit()

order_id = cursor.lastrowid
cursor.execute("INSERT INTO order_tracking
(order_id, tracking_id, status, mestamp) VALUES (%s,
%s, %s, NOW())", (order_id, tracking_id, order_status))
conn.commit()

print(f"Order placed successfully with tracking ID:


{tracking_id}")

cursor.close()
conn.close()

automa c_order_status_update(tracking_id)
return tracking_id
return None
# Automa cally update order status through stages
def automa c_order_status_update(tracking_id):
status_stages = ["Order Received", "Preparing for
Dispatch", "Out for Delivery", "Delivered"]

for stage in status_stages:


print(f"Upda ng status to: {stage}")
update_order_status(tracking_id, stage)
me.sleep(2)

# Update order status in the database


def update_order_status(tracking_id, new_status):
conn = get_connec on()
if conn:
cursor = conn.cursor()

# Update the main order status


query = "UPDATE orders SET order_status = %s
WHERE tracking_id = %s"
cursor.execute(query, (new_status, tracking_id))
conn.commit()

# Check if this tracking_id and order_id


combina on already exists in the order_tracking table
query_check = """
SELECT COUNT(*)
FROM order_tracking
WHERE tracking_id = %s AND order_id = (SELECT
order_id FROM orders WHERE tracking_id = %s)
"""
cursor.execute(query_check, (tracking_id,
tracking_id))
result = cursor.fetchone()

if result[0] == 0: # If the combina on doesn't exist,


insert the new record
# Insert into order_tracking table
query_insert = """
INSERT INTO order_tracking (tracking_id,
order_id, status, mestamp)
SELECT %s, order_id, %s, NOW()
FROM orders
WHERE tracking_id = %s
"""
cursor.execute(query_insert, (tracking_id,
new_status, tracking_id))
conn.commit()

print(f"Order status updated to '{new_status}'


for tracking ID {tracking_id}")
else:
print(f"Order tracking record already exists for
tracking ID {tracking_id}.")

cursor.close()
conn.close()

# View order history


def view_order_history(customer_id):
conn = get_connec on()
if conn:
cursor = conn.cursor()
query = "SELECT tracking_id, order_status FROM
orders WHERE customer_id = %s"
cursor.execute(query, (customer_id,))
orders = cursor.fetchall()

if orders:
print("Your Order History:")
for order in orders:
print(f"Tracking ID: {order[0]}, Status:
{order[1]}")
else:
print("No orders found.")
cursor.close()
conn.close()

# Update account details


def update_account_details():
new_name = input("Enter new name (leave blank to
keep current): ")
new_email = input("Enter new email (leave blank to
keep current): ")
new_mobile = input("Enter new mobile number
(leave blank to keep current): ")

conn = get_connec on()


if conn:
cursor = conn.cursor()

if new_name:
cursor.execute("UPDATE customers SET name =
%s WHERE customer_id = %s", (new_name,
customer_id))
if new_email:
cursor.execute("UPDATE customers SET email =
%s WHERE customer_id = %s", (new_email,
customer_id))
if new_mobile:
cursor.execute("UPDATE customers SET mobile =
%s WHERE customer_id = %s", (new_mobile,
customer_id))

conn.commit()
print("Account details updated successfully.")
cursor.close()
conn.close()

# Cancel an order
def cancel_order():
tracking_id = input("Enter the tracking ID of the
order to cancel: ")

conn = get_connec on()


if conn:
cursor = conn.cursor()
query = "UPDATE orders SET order_status =
'Cancelled' WHERE tracking_id = %s"
cursor.execute(query, (tracking_id,))
conn.commit()

if cursor.rowcount > 0:
print(f"Order with tracking ID {tracking_id} has
been cancelled.")
else:
print(f"No order found with tracking ID
{tracking_id}.")
cursor.close()
conn.close()

# View available packages (can add more details later)


def view_packages():
print("Here are the available packages:")
print("1. Basic Package: ₹199")
print("2. Premium Package: ₹499")
print("3. Golden Member (Yearly): ₹1999")
print("4. Golden Member (Monthly): ₹499")

# Logout from the account


def logout():
global customer_id
customer_id = None
print("You have logged out successfully.")

# Exit the applica on


def exit_program():
print("Exi ng program. Goodbye!")
exit()

# Main func on
def main():
while True:
print("\n1. Create Customer Account")
print("2. Login as Customer")
print("3. Place Order")
print("4. Golden Member Subscrip on")
print("5. View Order History")
print("6. Update Account Details")
print("7. Cancel Order")
print("8. View Packages")
print("9. Logout")
print("10. Exit")

choice = input("Enter your choice: ")


if choice == '1':
create_customer()
elif choice == '2':
customer_login()
elif choice == '3':
if customer_id:
place_order(customer_id)
else:
print("Please log in first.")
elif choice == '4':
golden_member_subscrip on()
elif choice == '5':
if customer_id:
view_order_history(customer_id)
else:
print("Please log in first.")
elif choice == '6':
if customer_id:
update_account_details()
else:
print("Please log in first.")
elif choice == '7':
cancel_order()
elif choice == '8':
view_packages()
elif choice == '9':
logout()
elif choice == '10':
exit_program()
else:
print("Invalid choice. Please try again.")

if __name__ == "__main__":
main()
OUTPUT
BIBLIOGRAPHY
● The Complete Reference Python byMar n C. Brown
from Mc. GrawHill publica ons.

● Computer Science with Python by Sumita Arora from


Dhanpat Rai & Co. publica ons

. ● www.geeksforgeeks.org

● www.python.org

You might also like