Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding: utf-8
- # ## Food Delivery System
- # MODULES COMPLETED:
- # MEMBERS:
- # -> Register
- # -> Login
- # -> View Menu
- # -> Add Items To Cart
- # -> Modify Cart
- # -> Add / Manage Address
- # -> Payment Modes (Online / COD)
- # -> Add Balance
- # -> Place Order
- # -> View Order History
- # -> Cancel Order
- # -> Track Order
- # Admin:
- # -> Register
- # -> Login
- # -> View Menu
- # -> Modify Menu
- # -> Add Items To User Cart
- # -> Modify User Cart
- # -> Add / Manage User Address
- # -> Modify Payment Modes (Online / COD)
- # -> Modify Balance
- # -> Place User Order
- # -> View User Order History
- # -> Cancel User Order
- # -> Track User Order
- # 1. Register / Login (Admin & Users)
- # 2.
- # In[51]:
- import time as tm
- import random
- # In[52]:
- # local databases
- # menu = {index : [name, price, prepare time, availability]}
- menu = {1 : ['Shahi Mushroom', 150, 2, "YES"], 2 : ['Kashmiri Aloo', 250, 3, "YES"], 3 : ['Dal Makhani', 200, 2.5, "YES"], 4 : ['Chana Masala', 100, 1.5, "YES"]}
- menuFlag = 5
- # cust = {usrName : [name, username, password, credit]}
- cust = {'test' : ['testUser', 'test', 'test123', 0]}
- #admin
- admin = {'admin' : ['testAdmin', 'admin', 'admin123']}
- # custAddress = {username : [[]]}
- custAdd = {}
- # cust transaction history = {username : [[menuIndex, date, paymentMode, status]]}
- custHist = {}
- #custCart
- custCart = {}
- # In[ ]:
- def adminReg():
- name = input("Admin Registration\n\nEnter Your Name : ")
- usrName = input("Enter Prefered Username : ")
- usrPass = input("Enter Password : ")
- while True:
- if usrName in admin:
- usrName = ("\nSorry! Username not available!\nEnter New Username : ")
- else:
- break
- admin[usrName] = [name, usrName, usrPass]
- print("\nCongratulations! Admin Account has been created!")
- # In[53]:
- def adminLogin():
- usrName = input("\nLog-In To Sikkim Treats Admin Panel\nEnter Username : ")
- usrPass = input("Enter Password : ")
- if usrName in cust:
- if usrPass == admin[usrName][2]:
- print("\nLog-In Successful!")
- adminPortal(usrName)
- else:
- print("\nWrong Password!")
- else:
- print("\nAdmin Not Found!")
- # In[54]:
- def memReg():
- name = input("Registration\n\nEnter Your Name : ")
- usrName = input("Enter Prefered Username : ")
- usrPass = input("Enter Password : ")
- while True:
- if usrName in cust:
- usrName = ("\nSorry! Username not available!\nEnter New Username : ")
- else:
- break
- cust[usrName] = [name, usrName, usrPass, 0]
- custHist[usrName] = []
- custAdd[usrName] = []
- custCart[usrName] = []
- print("\nCongratulations! Account has been created!")
- # In[55]:
- def memLogin():
- usrName = input("\nLog-In To Sikkim Treats\nEnter Username : ")
- usrPass = input("Enter Password : ")
- if usrName in cust:
- if usrPass == cust[usrName][2]:
- print("\nLog-In Successful!")
- userPortal(usrName)
- else:
- print("\nWrong Password!")
- else:
- print("\nUser Not Found!")
- # In[56]:
- def addAddress(usrName):
- try:
- street = input("\nAdd New Address\nEnter Street Name : ")
- landmark = input("Enter Landmark : ")
- pincode = int(input("Enter Pincode : "))
- time = random.randint(1, 3)
- custAdd[usrName].append([street, landmark, pincode, time])
- print("\nNew Address Has Been Added!")
- except:
- print("Enter Valid pincode")
- # In[57]:
- def addMenu():
- try:
- nameRecipe = input("Add Menu\nEnter Recipe Name : ")
- price = int(input("Enter Price : "))
- time = float(input("Enter prepare time : "))
- avail = input("Enter Availability : ")
- menu[menuFlag] = [nameRecipe, price, time, avail]
- menuFlag += 1
- except:
- print("Error In Adding Recipe!")
- # In[58]:
- def addCredit(usrName):
- try:
- print("\nManage Balance\nCurrent Balance : {}" .format(cust[usrName][3]))
- amount = int(input("Enter Amount To Add : "))
- cust[usrName][3] += amount
- print("\n{} Added Successfully!\nNew Balance : {}" .format(amount, cust[usrName][3]))
- except:
- print("\nEnter Valid Amount!")
- # In[59]:
- def viewAddress(usrName):
- try:
- if len(custAdd[usrName]) == 0:
- print("\nNo Address Yet!")
- else:
- flag = 1
- for i in custAdd[usrName]:
- print("\nAddress : {}\nStreet Name : {}\nLandmark : {}\nPincode : {}\nDelivery Time : {} minutes\n" .format(flag, i[0], i[1], i[2], i[3]))
- flag += 1
- except:
- print("\nError In Displaying Address\n")
- # In[60]:
- def viewProfile(usrName):
- try:
- print("\nProfile\nName : {}\nUsername : {}\nPassword : {}\nBalance : {}" .format(cust[usrName][0], cust[usrName][1], cust[usrName][2], cust[usrName][3]))
- except:
- print("\nError in loading Profile!\n")
- # In[61]:
- def viewMenu():
- try:
- print("\n\nMENU\n\nSl.No.\tName\t\t\tPrice\t\tPrepare Time\n")
- for i in menu:
- if(menu[i][3] == "YES"):
- print("\n{}\t{}\t\t₹ {}\t\t{} minutes" .format(i, menu[i][0], menu[i][1], menu[i][2]))
- except:
- print("\nError in loading menu!\n")
- # In[78]:
- def addItems(usrName):
- try:
- viewMenu()
- choice = int(input("\n100 : Back\nEnter Sl. No. To Add Items : "))
- if (choice == 100):
- pass
- else:
- if menu[choice][3] == "YES":
- custCart[usrName].append(choice)
- print("\nItem Has Been Added To Cart!")
- addItems(usrName)
- else:
- print("\nSorry, Item Not Available!")
- except:
- print("\nError in adding items!")
- # In[63]:
- def viewCart(usrName):
- try:
- if len(custCart[usrName]) == 0:
- print("\nCart is empty!")
- else:
- total = 0
- totalWait = 0
- print("\n\nCART\n\nSl.No.\tName\t\t\tPrice\t\tPrepare Time\n")
- for i in custCart[usrName]:
- print("\n{}\t{}\t\t₹ {}\t\t{} minutes" .format(i, menu[i][0], menu[i][1], menu[i][2]))
- total += menu[i][1]
- totalWait += menu[i][2]
- print("\n","-"*65, "\n\t\t\t\t\tWaiting Time : {} minutes\n\n\t\t\t\t\tAmount Payable : ₹ {}" .format(totalWait, total))
- except:
- print("\nError in loading cart!")
- # In[64]:
- def editCart(usrName):
- try:
- if len(custCart[usrName]) == 0:
- print("\nCart is empty!")
- else:
- viewCart(usrName)
- choice = int(input("\nBack : 100\nSl. No. To Remove Items : "))
- if choice == 100:
- pass
- else:
- if choice in custCart[usrName]:
- custCart[usrName].remove(choice)
- print("\nItem Removed Successfully!")
- editCart(usrName)
- else:
- print("\nInvalid Item")
- except:
- print("\nError in cart! Please Try Later!")
- # In[65]:
- def paymentMode(usrName, amount):
- try:
- choice = int(input("\nSelect Payment Mode\n1. Credit\n2. Cash On Delivery\n3. BackChoice : "))
- if choice == 1:
- if cust[usrName][3] >= amount:
- cust[usrName][3] -= amount
- print("\nPayment Successful!\nOrder Confirmed!\n")
- return "Online"
- else:
- print("\nInsufficient Balance!")
- paymentMode(usrName, amount)
- elif choice == 2:
- print("\nPlease pay ₹ {} at time of delivery\nOrder Confirmed!\n" .format(amount))
- return "COD"
- elif choice == 3:
- return False
- else:
- print("\nInvalid Input")
- except:
- print("\nError in payment! Try Again Later!")
- return False
- # In[66]:
- def placeOrder(usrName, method, address):
- try:
- if len(custCart[usrName]) == 0:
- print("\nEmpty Cart!")
- else:
- total = 0
- totalWait = 0
- for i in custCart[usrName]:
- total += menu[i][1]
- totalWait += menu[i][2]
- totalWait += custAdd[usrName][address-1][3]
- order = custCart[usrName].copy()
- temp = []
- temp.append(total)
- temp.append(totalWait)
- temp.append(method)
- temp.append(tm.time())
- custHist[usrName].append([order, temp])
- custCart[usrName] = []
- print("\nOrder Has Been Placed!\n")
- except:
- print("\nError in loading cart!")
- # In[67]:
- def viewOrder(usrName):
- try:
- if (len(custHist[usrName]) == 0):
- print("\nNo Order Has Been Made!")
- else:
- flag = 0
- for i in custHist[usrName]:
- print("\n\nOrder : {}\n\nSl.No.\tName\t\t\tPrice\t\tPrepare Time\n" .format(flag))
- for j in i[0]:
- print("\n{}\t{}\t\t₹ {}\t\t{} minutes" .format(j, menu[j][0], menu[j][1], menu[j][2]))
- if i[1][3] == None:
- status = "Cancelled"
- elif (tm.time() - i[1][3]) < i[1][1]*60:
- status = "Delivery in {0:0.2f} minutes" .format(((i[1][1]*60) - (tm.time()-i[1][3]))/60)
- elif (tm.time() - i[1][3]) >= i[1][1]*60:
- status = "Delivered!"
- else:
- status = "Unknown"
- print("\n", "-"*65, "\nTotal Amount : ₹ {}\nTotal Wait Time : {} minutes\nPayment Mode : {}\nStatus : {}\n" .format(i[1][0], i[1][1], i[1][2], status))
- flag += 1
- except:
- print("\nEror in view order!")
- # In[68]:
- def cancelOrder(usrName):
- try:
- print("\nCANCEL ORDER")
- viewOrder(usrName)
- choice = int(input("\n100 : Back\nEnter Order No. To Cancel : "))
- if choice == 100:
- pass
- elif choice >= len(custHist[usrName]) and choice != 100:
- print("\nInvalid Input!")
- else:
- if custHist[usrName][choice][1][3] == None:
- print("\nOrder Already Has Been Cancelled!")
- elif (tm.time() - custHist[usrName][choice][1][3]) < custHist[usrName][choice][1][1] * 60 :
- custHist[usrName][choice][1][3] = None
- if custHist[usrName][choice][1][2] == "Online":
- cust[usrName][3] += custHist[usrName][choice][1][0]
- print("\nOrder cancelled!\nCredit has been Refunded!")
- else:
- print("\nOrder cancelled!")
- else:
- print("\nOrder has been delivered!")
- except:
- print("\nError in cancel order!")
- # In[69]:
- def trackOrder(usrName):
- try:
- flag = 0
- for i in custHist[usrName]:
- if i[1][3] == None:
- status = "Cancelled"
- elif (tm.time() - i[1][3]) < i[1][1]*60:
- status = "Delivery in {0:0.2f} minutes" .format(((i[1][1]*60) - (tm.time()-i[1][3]))/60)
- print("\n\nTrack Order : {}\n\nSl.No.\tName\t\t\tPrice\t\tPrepare Time\n" .format(flag))
- for j in i[0]:
- print("\n{}\t{}\t\t₹ {}\t\t{} minutes" .format(j, menu[j][0], menu[j][1], menu[j][2]))
- print("\n", "-"*65, "\nTotal Amount : ₹ {}\nTotal Wait Time : {} minutes\nPayment Mode : {}\nStatus : {}\n" .format(i[1][0], i[1][1], i[1][2], status))
- flag += 1
- elif (tm.time() - i[1][3]) >= i[1][1]*60:
- status = "Delivered!"
- else:
- status = "Unknown"
- if (flag == 0):
- print("\nNo Active Order!")
- except:
- print("\nError in tracking order!")
- # In[70]:
- def homepage():
- try:
- while True:
- choice = int(input("\nWELCOME TO SIKKIM TREATS\n\n1. Admin Register \n2. Admin Log-In\n3. User Register\n4. User Log-In\n5. Exit\nChoice : "))
- if choice == 1:
- adminReg()
- elif choice == 2:
- adminLogin()
- elif choice == 3:
- memReg()
- elif choice == 4:
- memLogin()
- elif choice == 5:
- print("\nHave A Good Day!")
- break
- else:
- print("\nInvalid Input!")
- except:
- print("\nError in homepage!")
- # In[71]:
- def userPortal(usrName):
- try:
- while True:
- choice = int(input("\nWELCOME {} TO SIKKIM TREATS\n1. View Profile\n2. View Menu\n3. View Cart\n4. Manage Cart\n5. Place Order\n6. View Orders\n7. Track Order\n8. Cancel Order \n9. Manage Balance\n10. Manage Address\n11. Log Out\nChoice : " .format(cust[usrName][0])))
- if choice == 1:
- viewProfile(usrName)
- elif choice == 2:
- addItems(usrName)
- elif choice == 3:
- viewCart(usrName)
- elif choice == 4:
- editCart(usrName)
- elif choice == 5:
- # calculating cart value
- total = 0
- for i in custCart[usrName]:
- total += menu[i][1]
- mode = paymentMode(usrName, total)
- # selecting address
- viewAddress(usrName)
- address = int(input("\nSelect a address : "))
- if mode == 'Online' or mode == 'COD':
- placeOrder(usrName, mode, address)
- else:
- print("\nOrder Unsuccessful!")
- elif choice == 6:
- viewOrder(usrName)
- elif choice == 7:
- trackOrder(usrName)
- elif choice == 8:
- cancelOrder(usrName)
- elif choice == 9:
- while True:
- bal = int(input("\nManage Balance\n1. Add Credit\n2. View Balance\n3. Back\nChoice : "))
- if bal == 1:
- print("\nManage Balance\nCurrent Balance : {}" .format(cust[usrName][3]))
- elif bal == 2:
- addCredit(usrName)
- elif bal == 3:
- break
- else:
- print("\nInvalid Input")
- elif choice == 10:
- while True:
- add = int(input("\nManage Address\n1. View Address\n2. Add Address\n3. Back\n Choice : "))
- if add == 1:
- viewAddress(usrName)
- elif add == 2:
- addAddress(usrName)
- elif add == 3:
- break
- else:
- print("\nInvalid Input!")
- elif choice == 11:
- print("\nBye!")
- break
- except:
- print("\nError in User Portal")
- # In[72]:
- def adminPortal(adminName):
- try:
- while True:
- choice = int(input("\nWELCOME {} TO SIKKIM TREATS\n1. View User Profile\n2. Manage Menu\n3. View User Cart\n4. Manage User Cart\n5. Place User Order\n6. View User Orders\n7. Track User Order\n8. Cancel User Order \n9. Manage User Balance\n10. Manage User Address\n11. Log Out\nChoice : " .format(admin[adminName][0])))
- if choice == 1:
- usrName = input("\nEnter username to member : ")
- if usrName in cust:
- viewProfile(usrName)
- else:
- print("\nUser Not Found")
- elif choice == 2:
- menuChoice = int(input("\nManage Menu\n1. View Menu\n2. Add Menu\nChoice : "))
- if menuChoice == 1:
- viewMenu()
- elif menuChoice == 2:
- addMenu()
- else:
- print("\nInvalid Input!")
- elif choice == 3:
- usrName = input("\nEnter username to member : ")
- if usrName in cust:
- viewCart(usrName)
- else:
- print("\nUser Not Found")
- elif choice == 4:
- usrName = input("\nEnter username to member : ")
- if usrName in cust:
- editCart(usrName)
- else:
- print("\nUser Not Found")
- elif choice == 5:
- usrName = input("\nEnter username to member : ")
- if usrName in cust:
- # calculating cart value
- total = 0
- for i in custCart[usrName]:
- total += menu[i][1]
- mode = paymentMode(usrName, total)
- # selecting address
- viewAddress(usrName)
- address = int(input("\nSelect a address : "))
- if mode == "Online" or "COD":
- placeOrder(usrName, mode, address)
- else:
- print("\nOrder Unsuccessful!")
- else:
- print("\nUser Not Found")
- elif choice == 6:
- usrName = input("\nEnter username to member : ")
- if usrName in cust:
- viewOrder(usrName)
- else:
- print("\nUser Not Found")
- elif choice == 7:
- usrName = input("\nEnter username to member : ")
- if usrName in cust:
- trackOrder(usrName)
- else:
- print("\nUser Not Found")
- elif choice == 8:
- usrName = input("\nEnter username to member : ")
- if usrName in cust:
- cancelOrder(usrName)
- else:
- print("\nUser Not Found")
- elif choice == 9:
- usrName = input("\nEnter username to member : ")
- if usrName in cust:
- while True:
- bal = int(input("\nManage Balance\n1. Add Credit\n2. View Balance\n3. Back\nChoice : "))
- if bal == 1:
- print("\nManage Balance\nCurrent Balance : {}" .format(cust[usrName][3]))
- elif bal == 2:
- addCredit(usrName)
- elif bal == 3:
- break
- else:
- print("\nInvalid Input")
- else:
- print("\nUser Not Found")
- elif choice == 10:
- usrName = input("\nEnter username to member : ")
- if usrName in cust:
- while True:
- add = int(input("\nManage Address\n1. View Address\n2. Add Address\n3. Back\n Choice : "))
- if add == 1:
- viewAddress(usrName)
- elif add == 2:
- addAddress(usrName)
- elif add == 3:
- break
- else:
- print("\nInvalid Input!")
- else:
- print("\nUser Not Found")
- elif choice == 11:
- print("\nBye!")
- break
- except:
- print("\nError In Admin Panel!")
- # In[80]:
- homepage()
Add Comment
Please, Sign In to add comment