大发体育娱乐在线-大发体育娱乐官方网站-大发体育娱乐登录网址
做最好的网站

仅供参考

来源:http://www.dfwstonefabricators.com 作者:编程应用 人气:109 发布时间:2019-09-22
摘要:bin目录:程序运行入口 ATM_start.py: 1 #!/usr/bin/python 2 # -*- coding: utf-8 -*- 3 # 模拟ATM电子银行+登录账户权限控制+管理员管理模块 4 # 本程序可以在windows下运行基于python2.7.8版本开发 5 # 管理
  • bin目录:程序运行入口

ATM_start.py:

 1 #!/usr/bin/python 2 # -*- coding: utf-8 -*- 3 # 模拟ATM电子银行+登录账户权限控制+管理员管理模块 4 # 本程序可以在windows下运行基于python2.7.8版本开发 5 # 管理员账号:admin   密码:123123 6 # python04_homework 7 # __author__:Mr.chen 8 # 程序启动入口 9 10 import sys11 sys.path.append('..')12 from src import user_business13 14 15 16 user_business.Main()
  • crontab目录:按期职务触发入口

Auto_mission.py

1 #!/usr/bin/python2 # -*- coding: utf-8 -*-3 # 计划任务定时触发启动文件4 5 import sys6 sys.path.append('..')7 from lib import common8 9 common.Traverse_folder()
  • lib目录:公共类文件

common.py

  1 #!/usr/bin/python  2 # -*- coding: utf-8 -*-  3 # 公共方法层  4   5 import os,time,random,pickle  6   7 DIR = os.path.dirname(__file__)  8 DIR = DIR.replace('lib','db/')  9  10  11 TAG = True      #循环控制标志 12  13  14 def Exit(): 15     ''' 16     系统退出 17     :return:None 18     ''' 19     print ('程序退出!') 20     exit() 21  22  23 def MD5: 24     ''' 25     加密函数 26     :param firstsite: 密码字符串 27     :return: 加密字符串 28     ''' 29     import hashlib 30     return hashlib.md5.hexdigest() 31  32  33 def Verification_input(): 34     ''' 35     登录验证码校验 36     :return: True 37     ''' 38     while TAG: 39         re = Verification_Code() 40         code = raw_input('请输入括号里的验证码,不区分大小写:'.format 41         if code.strip != re.lower(): 42             print('您输入的验证码有误,请重新输入!') 43         else: 44             return True 45  46  47 def Verification_Code(): 48     ''' 49     生成随机的6位验证码:大小写字母数字的组合 50     :return: 验证码 51     ''' 52     code = '' 53     b = random.randrange(0, 5) 54     c = random.randrange(0, 5) 55     for i in range(6): 56         if i == b: 57             a = random.randrange(1, 9) 58             code = code + str 59         else: 60             a = random.randrange(65, 90) 61             if i == c: 62                 code = code + chr.lower() 63             else: 64                 code = code + chr 65     return code 66  67  68  69 def pwd_money_check: 70     ''' 71     用户银行卡密码登录验证 72     :return: True or False 73     ''' 74     while TAG: 75         pwd = raw_input('请输入6位银行卡密码:') 76         if pwd.isdigit() and len == 6: 77             pwd_money = log_info_specific_read(user, 'pwd_money') 78             if pwd_money == False: 79                 print ('用户日志不存在!') 80                 return False 81             else: 82                 if MD5 == pwd_money: 83                     print ('密码验证成功!') 84                     return True 85                 else: 86                     return False 87         else: 88             print ('您的输入有误!') 89  90  91 ###########################前台请求输入方法组################################################################## 92  93 def name_login_input(): 94     ''' 95     键盘输入登录名 96     :return:新用户名 97     ''' 98     while TAG: 99         name_login = raw_input('请输入登陆用户的用户名:')100         if name_login == 'n':101             return102         elif os.path.exists('db/'+name_login+'_log'):103             print('你输入的用户名已存在,请重新输入!')104         elif len(name_login) != len(name_login.strip or len(name_login.strip) != 1:105             print('登录名不能为空,且不能有空格,请重新输入!')106         else:107             return name_login108 109 110 def pwd_login_input():111     '''112     键盘输入登录密码113     :return:新登录密码114     '''115     while TAG:116         pwd_login = raw_input('请输入登陆密码:')117         if pwd_login == 'n':118             return119         elif len(pwd_login) < 8:120             print('您输入的密码不能小于8位数(8位以上字母数字+至少一位大写字母组合),请重新输入!')121         elif len(pwd_login.strip) != 1:122             print('您输入的密码不能有空格,密码也不能为空,请重新输入!')123         elif pwd_login.isdigit():124             print('密码不能全为数字(8位以上字母数字+至少一位大写字母组合),请重新输入!')125         elif pwd_login.lower() == pwd_login:126             print('请至少保留一位的大写字母(8位以上字母数字+至少一位大写字母组合),请重新输入!')127         else:128             pwd_login = MD5(pwd_login)129             return pwd_login130 131 132 def account_input():133     '''134     键盘输入银行卡号135     :return: 新银行卡号136     '''137     while TAG:138         account = raw_input('请输入银行卡号:')139         if account.strip() == '':140             account = 'empty'141             return account142         elif account == 'n':143             return144         elif len(account.strip < 16:145             print('银行卡号是不能小于16位的纯数字,请重新输入!')146         elif account.isdigit() != True:147             print('银行卡号是不能小于16位的纯数字,请重新输入!')148         else:149             return account150 151 152 def pwd_money_input():153     '''154     键盘输入银行卡密码155     :return: 新银行卡密码156     '''157     while TAG:158         pwd_money = raw_input('请输入银行卡的6位数字取款密码:')159         if pwd_money == 'n':160             return161         elif len(pwd_money.strip != 6:162             print('取款密码只能是6位纯数字,请重新输入!')163         elif pwd_money.strip().isdigit() != True:164             print('取款密码只能是6位纯数字,请重新输入!')165         else:166             pwd_money = MD5(pwd_money)167             return pwd_money168 169 170 171 172 ##################################数据读取写入方法组####################################################################173 174 175 def log_info_read:176     '''177     指定用户日志文件全部读取178     :param user:用户名179     :return:dict字典180             如果无文件返回False181     '''182     if os.path.exists(DIR+user+'_log'):183         with open(DIR+user+'_log','r') as f:184             dict = pickle.load185             return dict186     else:187         return False188 189 190 def log_info_specific_read(user,text):191     '''192     指定用户日志文件指定内容读取193     :param user: 用户名194     :param text: 预读取的字段名195     :return: 指定的字段内容196             如果无文件返回False197     '''198     if os.path.exists(DIR+user+'_log'):199         with open(DIR+user+'_log','r') as f:200             dict = pickle.load201             re = dict[text]202             return re203     else:204         return False205 206 207 def log_info_write(user,dict = None):208     '''209     指定用户日志文件全部写入210     :param user:用户名211     :param dict: 日志字典212     :return: True or False213     '''214     #if os.path.exists(user+'_log'):215     #print (DIR+user+'_log')216     with open(DIR+user+'_log','w') as f:217         pickle.dump218         return True219 220 221 def log_info_specific_write(user,dict):222     '''223     指定用户日志文件指定内容写入224     :param user: 用户名225     :param dict: 预修改的字典内容226     :return: True or False227     '''228     dictt = log_info_read229     if dictt == False:230         print ('用户日志文件不存在!')231         return  False232     dictt[dict.keys()[0]] = dict[dict.keys()[0]]233     re = log_info_write(user,dictt)234     if re == True:235         return True236     else:237         return False238 239 240 def log_info_billing_write(user,text):241     '''242     指定用户日志文件流水数据写入243     :param user: 用户名244     :param text: 用户流水数据245     :return: True or False246     '''247 248     dict = log_info_read249     if dict == False:250         print ('用户日志文件不存在!')251         return False252     dict['Not_out_billing'].append253     re = log_info_write(user, dict)254     if re == True:255         return True256     else:257         return False258 259 260 ###############################windows计划任务执行方法组#######################################################261 262 263 def Autopay:264     '''265     自动还款模块266     :param user: 用户267     :return: True or False268     '''269     dict = log_info_read270     tm = time.localtime()271     tm_text = str(tm.tm_year) + '-' + str(tm.tm_mon) + '-' + str(tm.tm_mday) + ' ' + str(tm.tm_hour) + ':' + str(tm.tm_min)272     if time.localtime().tm_mday == int(dict['Repayment_date']) and dict['Debt_Bill_amount'] != '0':273         if int(dict['cash']) >= int(dict['Debt_Bill_amount']):274             print ('用户{0}日期吻合触发自动还款!'.format275             dict['cash'] = str(int(dict['cash']) - int(dict['Debt_Bill_amount']))276             dict['Actual_overdraft'] = str(int(dict['Actual_overdraft'])-int(dict['Debt_Bill_amount']))277             text = '{0}:触发“自动还款”操作,还款成功,还款总额为:{1},电子现金余额为{2},总透支金额为{3}'.format(tm_text,dict['Debt_Bill_amount'],dict['cash'],dict['Actual_overdraft'])278             # log_info_billing_write(user,'{0}:触发“自动还款”操作,还款成功,还款总额为:{1},电子现金余额为{2},总透支金额为{3}'.format(tm_text,dict['Debt_Bill_amount'],dict['cash'],dict['Actual_overdraft']))279             dict['Not_out_billing'].append280             dict['Debt_Bill_amount'] = '0'281             log_info_write(user, dict)282             print ('用户{0}自动还款成功!'.format283             return True284         else:285             print ('用户{0}自动还款失败!电子现金账户余额不足!请存够钱再行尝试'.format286             log_info_billing_write(user,'{0}:触发“自动还款”操作,还款失败,失败原因:电子现金余额不足。还款总额为:{1},电子现金余额为{2},总透支金额为{3}'.format(tm_text,dict['Debt_Bill_amount'],dict['cash'],dict['Actual_overdraft']))287             return False288     else:289         return290 291 292 def AutoBilling:293     '''294     账单自动生成模块295     :param user: 用户296     :return:True or False297     '''298     dict = log_info_read299     time_year = time.localtime().tm_year300     time_mon = time.localtime().tm_mon301     time_mday = time.localtime().tm_mday302     date = str(time_year)+'-'+str303 304     text = '''305                             亲爱的{0},您的{1}年{2}月账单如下:306 307                           账单总金额为:{3},最后还款日为下月{4}日308                             请您按时还款,谢谢您的使用,再见!'''.format(user,str(time_year),str,dict['Actual_overdraft'],dict['Repayment_date'])309     if date not in dict['Debt_record']:310         dict['Debt_record'][date] = text311         dict['Debt_Bill_amount'] = dict['Actual_overdraft']312     if date not in dict['Has_been_out_billing']:313         dict['Has_been_out_billing'][date] = dict['Not_out_billing']314         dict['Not_out_billing'] = []315     log_info_write(user,dict)316 317 318 319 320 def Traverse_folder():321     '''322     根据条件遍历某文件夹里的全部文件内容,323     找出符合条件的文件后调用自动执行模块324     (需windows计划任务触发)325     :return:None326     '''327     list = os.listdir328     time_year = time.localtime().tm_year329     time_mon = time.localtime().tm_mon330     time_mday = time.localtime().tm_mday331     for i in list:332         if i == '__init__.py' or i == '__init__.pyc':333             continue334         else:335             name = i.strip().split('_')[0]336             dict = log_info_read337             if dict['billing_day'] == str(time_mday):338                 AutoBilling339             if dict['Repayment_date'] == str(time_mday):340                 Autopay341 342 343 def test():344     '''345     自动还款测试函数346     :return:None347     '''348     dict = log_info_read('chensiqi')349     dict['Debt_Bill_amount'] = '4000'350     dict['cash'] = '5000'351     dict['Actual_overdraft'] = '5000'352     dict ['Repayment_date'] = '6'353     log_info_write('chensiqi',dict)354     print (dict['Not_out_billing'])
  • src目录:业务逻辑文件

user_business.py

  1 #!/usr/bin/python  2 # -*- coding: utf-8 -*-  3 # 用户业务层  4   5 import os,random,time,sys  6 sys.path.append('..')  7 from src import admin_business  8 from lib import common  9  10  11 DIR = os.path.dirname(__file__) 12 DIR = DIR.replace('src','db/') 13  14  15 LOGINING = []      #用户时时登录列表 16 ERROR = []      #账户临时锁定字典 17 TAG = True      #循环控制标志 18  19  20  21 def login_status: 22     ''' 23     装饰器用于用户登录状态验证 24     :param func: 对象 25     :return: 对象 26     ''' 27     def inner(): 28         if LOGINING == []: 29             log = '用户状态未登录...' 30         else: 31             log = '{0}登录中...'.format(LOGINING[0]) 32         func 33     return inner 34  35  36 def Permission_checking: 37     ''' 38     装饰器用于用户功能权限验证 39     :param func:对象 40     :return:对象 41     ''' 42     def inner(): 43         if LOGINING == []: 44             print ('您尚未登录,请登录后再来!') 45             return 46         func() 47     return inner 48  49  50 def Account_checking: 51     ''' 52     装饰器对用户是否创建银行卡及银行卡状态进行验证 53     :param func: 对象 54     :return: 对象 55     ''' 56     def inner(): 57         re = common.log_info_specific_read(LOGINING[0],'account') 58         ree = common.log_info_specific_read(LOGINING[0],'status') 59         reee = common.log_info_specific_read(LOGINING[0],'pwd_money') 60         if re == 'empty': 61             print ('您尚未关联银行卡,请关联后再来!') 62             return 63         elif ree == '1': 64             print ('您的银行卡已经被管理员冻结!请解冻后再来') 65             return 66         elif reee == 'empty': 67             print ('您的银行卡密码还未设定,请设定后再来!') 68             return 69         func() 70     return inner 71  72  73 @login_status 74 def User_Manage(log = None): 75     ''' 76     用户管理界面,用户登录及注册 77     :param log: 用户登录状态标志 78     :return: None 79     ''' 80     while TAG: 81         text = ''' 82                           欢迎光临用户管理模块     {0} 83  84                              1,用户登录 85                              2,用户注册 86                              3,返回菜单    '''.format 87  88         print  89         choose = raw_input('请输入索引进行选择:') 90         if choose == '1': 91             Login() 92         elif choose == '2': 93             User_registration() 94         elif choose == '3': 95             return 96         else: 97             print ('您的输入有误,请重新输入!') 98  99 100 def Login():101     '''102     用户登录功能模块103     :return: None104     '''105     global ERROR106     num = 0107     while TAG:108         user = raw_input('请输入用户名:')109         pwd = raw_input('请输入密码:')110         ree = Login_check111         if ree == True:112             print ('用户名和密码校验成功!')113             break114         elif ree == '1':115             print('没有这个用户名,请注册后再来!')116             return117         elif num == 2:118             print ('您已经连续输错3次,账号已经锁定!')119             ERROR.append120             return121         elif ree == '2':122             print ('密码输入错误,请重新输入!')123             num += 1124             continue125         elif ree == '3':126             print('这个账号已经被锁定!')127             return128     common.Verification_input()129     LOGINING.insert130     Main()131 132 133 134 def Login_check:135     '''136     用户登录验证功能模块:137     :param user: 用户名138     :param pwd: 登录密码139     :return: 1:用户名不存在140              2:用户名密码不匹配141              3:用户名存在于锁定列表中142              True:登录信息正确143     '''144     if user == 'admin' and pwd == '123123':145         LOGINING.insert(0,'admin')146         admin_business.admin_manage('admin')147     re = common.log_info_read148     if user in ERROR:149         return '3'150     elif os.path.exists(DIR+user+'_log') == False:151         return '1'152     elif re['pwd_login'] != common.MD5:153         return '2'154     else:155         return True156 157 158 def User_registration():159     '''160     用户注册功能模块161     :return: None162     '''163     while TAG:164         name_login = common.name_login_input()     #得到新用户名165         if name_login == None:166             return167         pwd_login = common.pwd_login_input()        #得到新登录密码168         if pwd_login == None:169             return170         account = common.account_input()            #得到新银行卡号171         if account == None:172             return173         if account != 'empty':174             pwd_money = common.pwd_money_input()    #得到新取款密码175             if pwd_money == None:176                 return177         else:178             pwd_money = 'empty'179         common.Verification_input()                 #进行验证码验证180         while TAG:181             information = '''182                     您要注册的信息如下:183 184                     登录用户名:{0}185                     登录的密码:{1}186                     银行卡账号:{2}187                     银行取款码:{3}    '''.format(name_login,pwd_login,account,pwd_money)188             print (information)189             decide = raw_input('注册信息是否确认?:')190             if decide == 'y':191                 tm = time.localtime()192                 tm_text = str(tm.tm_year) +'-'+ str(tm.tm_mon) +'-'+ str(tm.tm_mday) +' '+ str(tm.tm_hour) +':'+ str(tm.tm_min)193                 #user_information = '{0}|{1}|{2}|{3}|{4}|15000|活跃|10000'.format(name_login,pwd_login,account,pwd_money,tm_text)194                 dict_info = {'name_login':name_login,       #用户名195                              'pwd_login':pwd_login,         #登录密码196                              'account':account,             #银行卡号197                              'pwd_money':pwd_money,         #银行卡密码198                              'tm_text':tm_text,             #注册时间199                              'billing_day':'15',            #账单日200                              'Repayment_date':'1',          #还款日201                              'status':'0',                  #账户状态(0:活跃  1:冻结)202                              'cash':'0',                    #现金电子余额203                              'Actual_overdraft':'0',        #总透支金额204                              'Overdraft_limit':'15000',     #透支额度上限205                              'Debt_Bill_amount':'0',        #账单欠账金额记录206                              'Debt_record':{},              #已出账单历史记录207                              'Has_been_out_billing':{},     #已出账单流水历史记录208                              'Not_out_billing':[]           #未出账单流水记录209                               }210                 common.log_info_write(name_login,dict_info)211                 print ('注册成功!')212                 LOGINING.insert(0,name_login)213                 User_Manage()214                 Main()215             elif decide == 'n':216                 break217             else:218                 print ('您的输入有误,请重新输入!')219 220 221 222 #def Log_Pretreatment(firstsite)223 224 225 226 @login_status227 def Main(log = None):228     '''229     用户功能选择界面230     :param log: 用户登录状态标志231     :return: None232     '''233     while TAG:234         text = '''235                              欢迎光临ATM电子银行         {0}236 237                                1,用户管理238                                2,个人信息239                                3,存款取款240                                4,时时转账241                                5,还款设置242                                6,查询账单243                                7,退出系统     '''.format244         print 245         Choose = {'1': User_Manage,246                 '2': User_information,247                 '3': User_Save_Money,248                 '4': User_Transfer_Money,249                 '5': User_Pay_back_Money,250                 '6': Select_Billing,251                 '7': common.Exit252                 }253         choose = raw_input('请输入索引进行选择:')254         # print 255         if choose in Choose:256             Choose[choose]()257         else:258             print ('您输入有误,请重新输入!')259 260 261 262 @Permission_checking263 def User_information():264     '''265     个人信息查询模块266     :return:267     '''268     while TAG:269         dict = common.log_info_read(LOGINING[0])270         if dict['status'] == '0':271             lab = '正常'272         else:273             lab = '冻结'274         if dict['account'] == 'empty':275             labb = '未绑定'276         else:277             labb = dict['account']278         text = '''279                          您的个人注册信息如下:280 281                             登录名:{0}282                             银行卡号:{1}283                             注册时间:{2}284                             账单日:{3}285                             还款日:{4}286                             银行卡状态:{5}287                             电子现金余额:{6}288                             银行卡已透支额度:{7}289                             银行卡透支额度上限:{8}290                             '''.format(dict['name_login'],labb,dict['tm_text'],dict['billing_day'],291                                    dict['Repayment_date'],lab,dict['cash'],292                                    dict['Actual_overdraft'],dict['Overdraft_limit'])293         print294         print ('''295                            您可以进行如下操作:296                             1,修改登录密码297                             2,绑定银行卡298                             3,修改银行卡密码299                             4,返回菜单300               ''')301         while TAG:302             decide = raw_input('你想做点什么?')303             if decide == '1':304                 pwd_login = common.pwd_login_input()305                 if pwd_login == None:306                     return307                 else:308                     dict['pwd_login'] = pwd_login309                     common.log_info_write(LOGINING[0],dict)310                     print('登录密码修改成功')311                     break312             elif decide == '2':313                 if dict['account'] != 'empty':314                     print ('您已经绑定过银行卡了!不能再次绑定!')315                     break316                 else:317                     account = common.account_input()318                     if account == None:319                         return320                     else:321                         dict['account'] = account322                         common.log_info_write(LOGINING[0], dict)323                         print ('银行卡绑定成功!')324                         break325             elif decide == '3':326                 if dict['account'] == 'empty':327                     print ('您尚未绑定银行卡,请绑定后再来!')328                     break329                 else:330                     pwd_money = common.pwd_money_input()331                     if pwd_money == None:332                         return333                     else:334                         dict['pwd_money'] = pwd_money335                         common.log_info_write(LOGINING[0], dict)336                         print ('银行卡密码修改成功!')337                         break338             elif decide == '4':339                 return340             else:341                 print ('您的输入有误!')342 343 344 345 346 @Permission_checking347 @Account_checking348 @login_status349 def User_Save_Money(log = None):350     '''351     用户存款取款模块352     :return:True or False353     '''354     while TAG:355         cash = common.log_info_specific_read(LOGINING[0],'cash')356         Actual_overdraft = common.log_info_specific_read(LOGINING[0],'Actual_overdraft')357         Overdraft_limit = common.log_info_specific_read(LOGINING[0],'Overdraft_limit')358         tm = time.localtime()359         tm_text = str(tm.tm_year) + '-' + str(tm.tm_mon) + '-' + str(tm.tm_mday) + ' ' + str(tm.tm_hour) + ':' + str(tm.tm_min)360 361         text = '''362                     自助存取款功能界面      {0}363 364                        1,取款365                        2,存款366                        3,返回     '''.format367         print 368         print ('您的电子账户现金为{0}元,透支额度上限为{1}元,已经透支的额度为{2}元'.format(cash, Overdraft_limit, Actual_overdraft))369         choose = raw_input('请问你想做点什么?:')370         if choose == '1':371             while TAG:372                 money = raw_input('请输入你想提取的金额:')373                 re = common.pwd_money_check(LOGINING[0])374                 if re == False:375                     print ('密码校验错误!')376                     break377                 elif money.isdigit():378                     if int >= int:379                         cash = str-int380                         common.log_info_specific_write(LOGINING[0],{'cash':cash})381                         #common.log_info_specific_write(LOGINING[0], {'billing': cash})382                         common.log_info_billing_write(LOGINING[0],'{0}:您进行了“提款”操作,提款金额为{1},现金余额为{2},总透支金额为{3}'383                                                       .format(tm_text,money,cash,Actual_overdraft))384                         break385                     else:386                         a = int(Actual_overdraft)+int-int387                         if a <= int(Overdraft_limit):388                             Actual_overdraft = str389                             common.log_info_specific_write(LOGINING[0], {'cash': '0'})390                             common.log_info_specific_write(LOGINING[0], {'Actual_overdraft': Actual_overdraft})391                             common.log_info_billing_write(LOGINING[0], '{0}:您进行了“提款”操作,提款金额为{1},电子现金余额为{2},总透支金额为{3}'392                                                           .format(tm_text,money,'0',Actual_overdraft))393                             break394                         else:395                             a = str(int(Overdraft_limit) - int(Actual_overdraft))396                             print ('您想提取的金额已超透支额度上限,您最多还能提取{0}元'.format397                             break398                 else:399                     print ('您的输入有误!')400         elif choose == '2':401             while TAG:402                 money = raw_input("请输入你想存入的金额:")403                 re = common.pwd_money_check(LOGINING[0])404                 if re == False:405                     print ('密码校验错误!')406                     break407                 elif money.isdigit():408                     cash = str+int409                     common.log_info_specific_write(LOGINING[0], {'cash': cash})410                     common.log_info_billing_write(LOGINING[0], '{0}:您进行了“存款”操作,存款金额为{1},电子现金余额为{2},总透支额度为{3}'411                                                   .format(tm_text, money, cash,Actual_overdraft))412                     break413                 else:414                     print ('您的输入有误!')415 416         elif choose == '3':417             return418         else:419             print ('您的输入有误!')420 421 422 423 @Permission_checking424 @Account_checking425 @login_status426 def User_Transfer_Money(log = None):427     '''428     用户时时转账模块429     :return:430     '''431     while TAG:432         dictt = common.log_info_read(LOGINING[0])433         tm = time.localtime()434         tm_text = str(tm.tm_year) + '-' + str(tm.tm_mon) + '-' + str(tm.tm_mday) + ' ' + str(tm.tm_hour) + ':' + str(tm.tm_min)435         text = '''436                    时时转账功能界面           {0}437                     1,时时转账438                     2,返回菜单439                                 '''.format440         print 441         while TAG:442             decide = raw_input('请问你想做点什么?')443             if decide == '1':444                 name = raw_input('请输入你想转账的人的用户名:')445                 if os.path.exists(DIR +name+'_log') == False:446                     print ('没有这个用户存在!请重新输入!')447                     break448                 elif common.log_info_specific_read(name, 'account') == 'empty':449                     print ('对方没有关联银行卡!')450                     break451                 else:452                     card = raw_input('请输入你想要转账的对方的银行卡号:')453                     account = common.log_info_specific_read(name, 'account')454                     if card == account:455                         print ('银行卡号验证成功!')456                         money = raw_input('请输入你想要转账的金额:')457                         re = common.pwd_money_check(LOGINING[0])458                         if re == False:459                             print ('密码校验错误!')460                             break461                         elif int(dictt['cash']) < int:462                             print ('您没有足够的现金转账!')463                             break464                         elif money.isdigit():465                             dict = common.log_info_read466                             dict['cash'] = str(int(dict['cash'])+int467                             common.log_info_write(name,dict)468                             text = '{0}:银行卡为{1}的用户 向您转账{2}元,电子现金账户余额为{3},总透支额度为{4}'469                                 .format(tm_text,dictt['account'],money,dict['cash'],dict['Actual_overdraft'])470                             common.log_info_billing_write(name,text)471                             dictt['cash'] = str(int(dictt['cash'])-int472                             common.log_info_write(LOGINING[0], dictt)473                             text = '{0}:您进行了“转账”操作,转账金额为{1},对方银行卡号为{2},电子现金余额为{3},总透支额度为{4}'474                                 .format(tm_text,money,dict['account'],dictt['cash'],dictt['Actual_overdraft'])475                             common.log_info_billing_write(LOGINING[0], text)476                             print ('转账成功!')477                     else:478                         print ('您的银行卡号输入错误!')479                         break480             elif decide == '2':481                 return482             else:483                 print ('您的输入有误!')484 485 486 @Permission_checking487 @Account_checking488 def User_Pay_back_Money():489      '''490      用户定期还款设置模块491      :return:492      '''493      dict = common.log_info_read(LOGINING[0])494      print ('您目前的自动还款设置为每月的{0}日还款').format(dict['Repayment_date'])495      while TAG:496         decide = raw_input('你想重新设置自动还款日吗?:')497         if decide == 'y':498             day = raw_input('请输入您想设置的日期:')499             if day.isdigit() and int <= 10:500                 dict['Repayment_date'] = day501                 common.log_info_write(LOGINING[0],dict)502                 print ('自动还款日期修改成功!')503                 return504             else:505                 print ('您的输入有误!')506         elif decide == 'n':507             return508         else:509             print ('您的输入有误!')510 511 512 @Permission_checking513 @Account_checking514 @login_status515 def Select_Billing(log = None):516     '''517     用户账单查询模块518     :return:519     '''520 521     dictt = {}522     while TAG:523         num = 0524         dict = common.log_info_read(LOGINING[0])525         tm = time.localtime()526         tm_text = str(tm.tm_year) + '-' + str(tm.tm_mon) + '-' + str(tm.tm_mday) + ' ' + str(tm.tm_hour) + ':' + str(tm.tm_min)527 528         text = '''529                       账单功能如下:           {0}530                     1,账单查询531                     2,未出账单流水记录查询532                     3,返回菜单533                                   '''.format534         print 535         while TAG:536             choose = raw_input('请输入索引进行选择:')537             if choose == '1':538                 num = 0539                 if len(dict['Debt_record'].keys != 0:540                     for i in dict['Debt_record'].keys():541                         num += 1542                         dictt[str] = i543                         print ('{0},{1}账单'.format,i))544                     while TAG:545                         choose = raw_input('请输入你的选择:')546                         if choose in dictt:547                             print (dict['Debt_record'][dictt[choose]])548                             print ('{0}月账单流水信息如下:'.format(dictt[choose]))549                             for i in dict['Has_been_out_billing'][dictt[choose]]:550                                 print 551                             break552                         else:553                             print ('你的输入有误!')554                 else:555                     print ('目前您没有任何账单生成!')556                     break557             elif choose == '2':558                 print ('未出账单流水记录如下:')559                 for line in dict['Not_out_billing']:560                     print 561                 break562             elif choose == '3':563                 return564             else:565                 print ('您的输入有误!')

admin_business.py

  1 #!/usr/bin/python  2 # -*- coding: utf-8 -*-  3 # 管理员业务层  4   5   6 from lib import common  7 import user_business  8 import os  9 DIR = os.path.dirname(__file__) 10 DIR = DIR.replace('src','db/') 11  12  13 LOGINING = []      #用户时时登录列表 14 TAG = True      #循环控制标志 15  16  17 def admin_manage(log = None): 18     ''' 19     管理员操作界面,只有管理员能进 20     :param log: 用户登录状态标志 21     :return: None 22     ''' 23     while TAG: 24         text = ''' 25                           欢迎光临管理员操作界面        {0} 26  27                              1,添加用户银行卡号 28                              2,指定用户透支额度 29                              3,冻结用户银行卡号 30                              4,系统退出             '''.format 31         print  32         while TAG: 33             choose = raw_input('管理员你好,你想做点什么?:') 34             if choose in {'1','2','3','4'}: 35                 if choose == '1': 36                     admin_add_bankcard() 37                     break 38                 elif choose == '2': 39                     admin_Overdraft_limit() 40                     break 41                 elif choose == '3': 42                     admin_Freeze_bankcard() 43                     break 44                 elif choose == '4': 45                     common.Exit() 46             else: 47                 print ('您的输入有误!') 48  49  50 def admin_add_bankcard(): 51     ''' 52     给没有关联银行卡的用户关联银行卡号 53     :return:None 54     ''' 55     dict = {} 56     print ('尚未建立银行卡关联信息的账户如下:n') 57     list = os.listdir 58     num = 0 59     for i in list: 60         if i == '__init__.py' or i == '__init__.pyc': 61             continue 62         else: 63             re_dict = common.log_info_read.split('_')[0]) 64             if re_dict['account'] == 'empty': 65                 num += 1 66                 print ('{0} 登录名称:{1}  n'.format(num,re_dict['name_login'])) 67                 dict[str] = re_dict['name_login'] 68     while TAG: 69         choose = raw_input('输入索引选择你想添加银行卡的用户(n = 返回上级菜单):') 70         if choose == 'n': 71             return 72         elif choose in dict: 73             account = common.account_input() 74             re_dict = common.log_info_read(dict[choose]) 75             re_dict['account'] = account 76             common.log_info_write(dict[choose],re_dict) 77             print ('用户{0}的银行卡关联成功'.format(dict[choose])) 78         else: 79             print('您输入的信息有误!') 80  81  82  83 def admin_Overdraft_limit(): 84     ''' 85     修改用户银行卡的透支额度 86     :return:None 87     ''' 88     dict = {} 89     print ('所有用户额度信息如下:n') 90     list = os.listdir 91     num = 0 92     for i in list: 93         if i == '__init__.py' or i == '__init__.pyc': 94             continue 95         else: 96             re_dict = common.log_info_read.split('_')[0]) 97             num += 1 98             print ('{0} 登录名称:{1}  透支额度为:{2}  n'.format(num, re_dict['name_login'],re_dict['Overdraft_limit'])) 99             dict[str] = re_dict['name_login']100     while TAG:101         choose = raw_input('输入索引选择你想修改额度的账户(n = 返回上级菜单):')102         if choose == 'n':103             return104         elif choose in dict:105             Quota = raw_input('你想把额度改成多少?:')106             re_dict = common.log_info_read(dict[choose])107             re_dict['Overdraft_limit'] = Quota108             common.log_info_write(dict[choose], re_dict)109             print ('用户{0}的额度修改成功!'.format(dict[choose]))110         else:111             print('您输入的信息有误!')112 113 114 115 def admin_Freeze_bankcard():116     '''117     冻结or解冻用户的银行卡号118     :return:None119     '''120     dict = {}121     print ('所有已关联银行卡的用户的银行卡状态信息如下:n')122     list = os.listdir123     num = 0124     for i in list:125         if i == '__init__.py' or i == '__init__.pyc':126             continue127         else:128             re_dict = common.log_info_read.split('_')[0])129             if re_dict['account'] != 'empty':130                 num += 1131                 if re_dict['status'] == '0':132                     lab = '活跃'133                 else:134                     lab = '冻结'135                 print ('{0} 登录名称:{1}  账户状态:{2} n'.format(num, re_dict['name_login'],lab))136                 dict[str] = re_dict['name_login']137     while TAG:138         choose = raw_input('输入索引选择用户来改变他的银行卡状态(活跃-->冻结-->活跃)(n = 返回上级菜单):')139         if choose == 'n':140             return141         elif choose in dict:142             re_dict = common.log_info_read(dict[choose])143             if  re_dict['status'] == '0':144                 labb = '冻结'145                 labbb = '1'146             else:147                 labb = '活跃'148                 labbb = '0'149             decide = raw_input('你确定要将用户{0}的银行卡的状态改成{1}吗?:'.format(dict[choose],labb))150             if decide == 'n':151                 return152             re_dict['status'] = labbb153             common.log_info_write(dict[choose], re_dict)154             print('用户{0}的银行卡的状态信息已经改变!'.format(dict[choose]))155         else:156             print('您输入的信息有误!')

本文由大发体育娱乐在线发布于编程应用,转载请注明出处:仅供参考

关键词:

上一篇:直播疑难杂症排查

下一篇:没有了

频道精选

最火资讯