示例#1
0
    def __send_money_sub1(cls, user):
        # TODO 금액입력형식 / 계좌번호 입력형식

        money_amount = input()
        if money_amount:
            if prd.dataConfirm(money_amount):
                money_amount = int(prd.dataToBasicType(money_amount))
            else:
                print('잘못된 형식입니다\n아무키나 입력하세요')
                input()
                return
        else:
            print('잘못된 형식입니다\n  아무키나 입력하세요')
            input()
            return
        accounts_sender = reader.read_all_accounts_in_deposit()
        balance = accounts_sender[user.deposits]['balance']

        super().request_keyin('계좌번호')
        account_receiver = input()
        confirm = bd.dataConfirm(account_receiver)
        if confirm:
            account_receiver = bd.dataToBasicType(account_receiver)
            print(f'\n입금액 : {money_amount} 원')
            print(f'계좌번호 : {account_receiver}')
            super().confirm_check('이체')
            keyin_result = keyin.type_in_yes_or_no()
            if keyin_result == 'y' or keyin_result == 'yes':
                pass
            else:
                print('취소하였습니다')
                input()
                return
        else:
            print('잘못된 계좌번호입니다.  아무키나 입력하세요')
            input()
            return

        user_receiver = reader.read_one_users(account_receiver)

        if money_amount < balance:
            writer.withdraw_money(user.deposits, money_amount)
            writer.put_money_in_deposit(user_receiver['accounts'][0],
                                        money_amount)
            writer.make_history(user.deposits, user_receiver['accounts'][0],
                                money_amount, 'Deposits_send')
            cls.send_money_result(user, money_amount)
        else:
            print('''잔액이 부족합니다 아무키나 입력하세요''')
            input()
    def getData(self, account):
        userData = fr.read_one_users(account)
        result = ""
        if userData == False:
            return result
        else:
            id = int(account[:4])
            if 0 <= id < 1000:
                # 관리자
                admin = 0
                name = userData['name']
                pw = userData['pw']
                date = userData['sign_up_date']
                result = {
                    'id': account,
                    'name': name,
                    'sign_up_date': date,
                    'user_class': admin,
                    'Deposits': id,
                    'Savings': 0
                }
                return result
            elif 1000 <= id < 5000:
                # 일반 사용자
                admin = 1
                name = userData['name']
                pw = userData['pw']
                date = userData['sign_up_date']
                depositAccount = userData['accounts'][0]
                try :
                    savingsAccount = userData['accounts'][1]
                except IndexError:
                    savingsAccount = ""
                result = {
                    'id': account,
                    'name': name,
                    'sign_up_date': date,

                    'user_class': admin,
                    'Deposits': depositAccount,
                    'Savings': savingsAccount
                }
                return result
 def loginCheck(self, id, pw):
     userData = fr.read_one_users(id)
     if userData['pw'] == pw:
         return True
     else:
         return False