def transfer_interface(from_name, to_name, account): from_user_dic = user.select_t(from_name) to_user_dic = user.select_t(to_name) if from_user_dic['account']>=account: from_user_dic['account'] -= account to_user_dic['account'] += account from_user_dic['liushui'].extend(['%s transfer %s yuan to %s' % (from_name, account, to_name)]) to_user_dic['liushui'].extend(['%s accept %s yuan from %s' % (to_name, account, from_name)]) db_hander.update(from_user_dic) db_hander.update(to_user_dic) logger_bank.info('%s 向 %s 转账 %s' % (from_name, to_name, account)) return True else: return False
def zhuanzhang(): print('转账') while True: trans_name = input('输入你的转账用户(q to exit)>>').strip() if trans_name == panduan['name']: print('不能是本人') continue if 'q' == trans_name: break trans_dic = user.select_t(trans_name) if trans_dic: trans_money = input('输入转账金额 >>:').strip() if trans_money.isdigit(): trans_money = int(trans_money) user_balance = bank.get_bank_interface(panduan['name']) if user_balance >= trans_money: bank.transfer_interface(panduan['name'], trans_name, trans_money) break else: print('钱不够') continue else: print('输入数字') continue else: print('账户不存在') continue
def huankuan(): while True: user_dic=user.select_t(panduan['name']) money=input('还多少 速度。。。').strip() if not money.isdigit():continue money=int(money) user_dic['account']+=money user.update_t(user_dic['name'],user_dic['passwd'],user_dic['account']) print('您还了%s $,还剩%s $' %(money,user_dic['account'])) logger_bank.info('%s 还款 %s 元' % (user_dic['name'], user_dic['account'])) break
def register(): while True: name = input('输入你的账号: ').strip() if not name.isalnum():continue user_dic=user.select_t(name) if user_dic: print('账户已存在 ggg') continue else: passwd=input('输入你的账户密码').strip() passwd1=input('确认你输入的账户密码').strip() if passwd==passwd1: user.update_t(name,passwd) print('注册成功') break else: print('密码不一致')
def login(): while True: name = input('输入你的账号: ').strip() if not name.isalnum():continue user_dic=user.select_t(name) # print(user_dic) if user_dic: passwd=input('输入你的账户密码').strip() if passwd==user_dic['passwd']: panduan['name']=name panduan['is_auth']=True print('登陆成功') break else: print('密码错误') continue else: print('账户不存在 ggg') break
def get_bank_interface(name): return user.select_t(name)['account']
def check_record(name): current_user = user.select_t(name) logger_bank.info('%s 查看了银行流水' % name) return current_user['liushui']