def user_login(): global current_person print("顾客登录".center(20, "=")) name = input("请输入顾客名称: ") password = input("请输入顾客密码: ") user = User(name, password) user_service = UserService() ret = user_service.login(user) if ret: current_person = user return ret
def user_reg(): print("顾客注册".center(20, "=")) name = input("请输入顾客名称: ") password1 = input("请输入顾客密码: ") password2 = input("请再次输入密码: ") if password2 != password1: return False user = User(name, password1) user_service = UserService() ret = user_service.reg(user) return ret
def return_item(self, order): try: ReturnItemService.__rdao.remove_item(order) sum = reduce(lambda a, b: a + b, map(lambda x: x.price * x.stock, order.items)) # sum=0 for i in order.items: # sum+=i.stock*i.price ReturnItemService.__idao.return_updata_stock(i) user = User(order.user_id, int(sum)) ReturnItemService.__udao.return_update_point(user) return True except: return False
def add(self, order): try: OrderService.__odao.add(order) sum = reduce(lambda a, b: a + b, map(lambda x: x.price * x.stock, order.items)) # sum=0 for i in order.items: # sum+=i.stock*i.price OrderService.__idao.updata_stock(i) user = User(order.user_id, int(sum)) OrderService.__udao.update_point(user) return True except: return False