class Coffee_Class():
def __init__(self):
self.aaa("c:\\data\\kiosk.png")
print('키오스크 시스템을 시작합니다')
self.cafe_dict = {}
self.cafe_dict['주문번호'] = []
self.cafe_dict['주문시간'] = []
self.cafe_dict['커피종류'] = []
self.cafe_dict['주문수량'] = []
self.cafe_dict['결제금액'] = []
self.coffee = ['아메리카노', '카페라떼', '카페모카', '녹차라떼']
self.coffee_iv = [20, 10, 30, 20] # [0] 아메리카노 재고, [1] 카페라떼 재고, [2] 카페모카 재고, [3] 녹차라떼 재고
self.coffee_p = (1500, 2500, 3500, 3500) # [0] 아메리카노 가격, [1] 카페라떼 가격, [2] 카페모카 가격, [3] 녹차라떼 가격
self.ornum = 0 # 주문번호
self.cup = 0
self.password = 1234 # 비밀번호
self.password_in = 0 # 비밀번호 입력 변수
self.sf_coffee_menu = self.coffee.copy()
# 시각화를 위한 함수
def aaa(self, name):
import PIL.Image as pilimg
import numpy as np
import matplotlib.pyplot as plt
im = pilimg.open(name)
pix = np.array(im)
plt.imshow(pix)
plt.axis('off')
plt.show()
# 매출 결산을 위한 함수
def machul_sum(self):
import pandas as pd
from matplotlib import font_manager, rc
import matplotlib.pyplot as plt
import seaborn as sns # seaborn 모듈을 임포트하여 color_palette 메소드를 불러오려함
from datetime import datetime
now = str(datetime.now())
cafe = pd.DataFrame(self.cafe_dict)
cafe.to_csv("c:\\data\\coffee_report_" + now[0:10] +'일_' + now[11:13] + '시_' + now[14:16] + '분_' + now[17:19] + '초' + ".csv", encoding = "ANSI")
print('현재 총 수익 : %d' %cafe['결제금액'].sum())
font_name = font_manager.FontProperties(fname="c:/Windows/Fonts/malgun.ttf").get_name()
rc('font', family=font_name)
result = cafe.groupby('커피종류')['결제금액'].sum().reset_index()
result.columns=['커피종류', '총매출액']
colors_c = sns.color_palette('YlOrBr', len(result)) # color_pallete(팔레트명, 색상개수)
result.plot.pie(y='총매출액', labels=result['커피종류'],autopct='%1.1f%%', colors = colors_c)
plt.legend(loc='best', bbox_to_anchor=(1, 1) )
plt.ylabel('총매출액', labelpad = 40)
plt.savefig("c:\\data\\result_" + now[0:10] +'일_' + now[11:13] + '시_' + now[14:16] + '분_' + now[17:19] + '초' + ".png", dpi = 300)
return cafe
# 데이터를 쌓는 함수
def data_add(self, num):
from datetime import datetime
now = str(datetime.now())
self.cafe_dict['주문번호'].append(self.ornum)
self.cafe_dict['주문시간'].append(now)
self.cafe_dict['커피종류'].append(self.coffee[num-1])
self.cafe_dict['주문수량'].append(self.cup)
self.cafe_dict['결제금액'].append(self.cup*self.coffee_p[num-1])
# 키오스크 주문 메인 함수
def coffee_kiosk(self):
self.aaa("c:\\data\\menu.png")
# 오늘의 추천 음료
from random import shuffle
shuffle(self.sf_coffee_menu)
print('★ 오늘의 추천 음료는 %s ★' %self.sf_coffee_menu[0])
while True:
if self.coffee_iv[0] == 0 and self.coffee_iv[1] == 0 and self.coffee_iv[2] == 0 and self.coffee_iv[3] == 0:
print('\n※ 모든 음료 재고가 소진되었습니다 직원에게 문의해주세요 ※')
break
try:
num = int(input('주문하시겠습니까? 번호를 눌러주세요 : '))
except:
print('오류 : 잘못된 값을 입력하셨습니다.\n처음화면으로 돌아갑니다.')
continue
if num < 5:
if self.coffee_iv[num-1] == 0:
print('※ %s는 솔드아웃 되었습니다 다시 선택해주세요 ※' %self.coffee[num-1])
continue
print('%s를 선택하셨습니다\n' %self.coffee[num-1])
try:
self.cup = int(input('몇 잔 주문하시겠습니까? '))
except:
print('오류 : 잘못된 값을 입력하셨습니다. 숫자로 입력해주세요.\n처음화면으로 돌아갑니다.')
continue
if self.cup > self.coffee_iv[num-1]:
print('죄송합니다. 주문량에 비해 %s 재고가 부족합니다.' %self.coffee[num-1])
print('현재 주문 가능한 수량은 %d개 입니다. 다시 입력해주세요.' %self.coffee_iv[num-1])
self.cup = int(input('몇 잔 주문하시겠습니까? '))
print('결제하실 금액은 %d원입니다' %(self.cup*self.coffee_p[num-1]))
try:
money = int(input('돈을 넣어주세요 :'))
except:
print('오류: 잘못된 값입니다. \n처음화면으로 돌아갑니다.')
continue
if money == self.cup*self.coffee_p[num-1]:
self.ornum += 1
print('\n◎ 주문번호 %d번 : %s %d잔 나왔습니다 ◎' %(self.ornum, self.coffee[num-1], self.cup))
self.coffee_iv[num-1] -= self.cup
elif money > self.cup*self.coffee_p[num-1]:
self.ornum += 1
print('거스름돈은 %d원입니다 \n\n◎ 주문번호 %d번 : %s %d잔 나왔습니다 ◎' %(money - self.coffee_p[num-1]*self.cup, self.ornum, self.coffee[num-1], self.cup))
self.coffee_iv[num-1] -= self.cup
else:
print('%d원이 부족합니다. 잔돈이 반환됩니다 \n처음화면으로 돌아갑니다' %(self.cup*self.coffee_p[num-1] - money))
continue
print('\n쿠폰이 %d개가 발행되었습니다\n20개를 모으면 한 잔 무료!\n' %self.cup)
# 데이터 쌓는 함수
self.data_add(num)
# 관리자 모드
elif num == 5:
try:
self.password_in = int(input('\n관리자 모드를 실행하시겠습니까? 비밀번호를 눌러주세요 : '))
except:
print('오류 : 잘못된 입력입니다. 숫자로 입력해주세요')
continue
if self.password_in == self.password:
print('\n※ 관리자 모드를 실행합니다 ※\n')
break
else:
print('※ 잘못된 비밀번호입니다 처음화면으로 돌아갑니다 ※')
continue
else:
print('※ 잘못된 번호입니다 처음화면으로 돌아갑니다 ※')
continue
return self.machul_sum()