Пример #1
0
 def transfer(self, u, inu):
     sql = "select * from 开户 where account=%s  "
     data = select(sql, u.getAccount())
     if len(data) != 0:
         sq2 = "select * from 开户 where account=%s  "
         data1 = select(sq2, inu)
         if len(data1) != 0:
             sql3 = "select account from 开户 where account=%s and mima=%s"
             data = select(sql3, [u.getAccount(), u.getPassword()])
             if len(data) != 0:
                 sql4 = "select * from 开户 where account = %s and money>=%s"
                 data = select(sql4, [u.getAccount(), u.getMoney()])
                 if len(data) != 0:
                     sql5 = "update 开户 set money=money-%s where account = %s "
                     update(sql5, [u.getMoney(), u.getAccount()])
                     sql6 = "update 开户 set money=money+%s where account = %s "
                     update(sql6, [u.getMoney(), inu])
                     return 0
                 else:
                     return 3
             else:
                 return 2
         else:
             return 1
     else:
         return 1
Пример #2
0
def query():
    account = input("请输入账号:")
    sql01 = "SELECT * FROM user_data WHERE account = %s"
    param01 = [account]
    data01 = select(sql01, param01)
    if len(data01) != 0:
        print("账户存在!!")
        password = input("请输入密码:")
        sql02 = "SELECT passwords FROM user_data WHERE account = %s"
        param02 = [account]
        data02 = select(sql02, param02)
        if data02[0][0] == password:
            print("密码正确!!")
            info = '''
                                 ------------个人信息----------------
                                 账号:%s,
                                 用户名:%s,
                                 取款密码:%s,
                                 地址信息:
                                     国家:%s,
                                     省份:%s,
                                     街道:%s,
                                     门牌号:%s,
                                 余额:%s,
                                 开户行:%s
                                 -----------------------------------
                             '''
            print(info % (data01[0][0], data01[0][1], data01[0][2],
                          data01[0][3], data01[0][4], data01[0][5],
                          data01[0][6], data01[0][7], data01[0][8]))
        else:
            print("密码错误!!")
    else:
        print("账号不存在!!")
Пример #3
0
  def bank_getmoney (slef,account,password,gmoney):
     # 账号是否存在
      sql="select 账号 from users where 账号 =%s"
      param=[account]
      user=select(sql,param)
      if len(user)>0:
 # 密码是否正确
         sql="select 账号 from users where 账号 =%s and  密码 = %s"
         param=[account,password]
         user=select(sql,param)
         if len(user)>0:
             #正常取钱
             sql="select 账号 from users where 余额>=%s and  账号 =%s"
             param = [gmoney, account]
             user=select(sql,param)
             if len(user) >0:
                sql="update users set 余额=余额-%s where 账号 =%s"
                param=[gmoney,account]
                update(sql,param)
                return 0
             else:
                  return 3
         else:
             return 2
      else:
         return 1
Пример #4
0
 def bank_transfer(self,account1, account2, password, money):
    # 两个账号是不是存在
    sql = "select 账号 from users where 账号=%s or 账号=%s"
    param = [account1, account2]
    user = select(sql, param)
    if len(user) == 2:
        # 转出账号密码是不是存在
        sql = "select * from users where 密码=%s and 账号=%s"
        param = [password, account1]
        user = select(sql, param)
        if len(user) > 0:
            # 转出金额是不是足够
            sql = "select 账号 from users where 余额>=%s and 账号=%s"
            param = [money, account1]
            user = select(sql, param)
            if len(user) > 0:
                # 正常转出
                sql = "update  users set 余额=余额- %s where 账号= %s "
                param = [money, account1]
                update(sql, param)
                # 调用update方法
                sql = "update  users set 余额=余额+ %s where 账号= %s "
                param = [money, account2]
                update(sql, param)
                return 0
            else:
                return 3
        else:
            return 2
    else:
        return 1
Пример #5
0
def bank_query(account, password):
    sql = "select account from user where account = %s"
    param = [account]
    data = select(sql, param)
    if len(data) == 0:
        print("该用户不存在!!!")
    sql1 = "select password from user where account = %s"
    data = select(sql1, param)
    if data[0][0] != password:
        print("密码输入错误!!!")

    # 正常查询
    print("查询成功!")
    sql2 = "select * from user where account = %s"
    data = select(sql2, param)
    print(data)
    info = '''
                ------------个人账户信息----------------
                账号:%s,
                用户名:%s,
                取款密码:%s,
                地址信息:
                    国家:%s,
                    省份:%s,
                    街道:%s,
                    门牌号:%s,
                余额:%s,
                开户行:%s
                -----------------------------------
            '''
    print(info % (data[0][0], data[0][1], data[0][2], data[0][3], data[0][4],
                  data[0][5], data[0][6], data[0][7], data[0][8]))
Пример #6
0
def bank_transfer_accounts(account, accounts, password, money):
    sql = "select account from user where account=%s"
    sq = "select account from user where account=%s"
    param = [account]
    par = [accounts]
    data = select(sql, param)
    d = select(sq, par)
    if len(data) == 0 and len(d) == 0:
        return 1
    sql1 = "select password from user where account = %s"
    param1 = [account]
    data = select(sql1, param1)
    if data[0][0] != password:
        return 2
    sql2 = "select money from user where account = %s"
    data = select(sql2, param1)
    if data[0][0] < money:
        return 3
    # 正常转账
    sql3 = "update user set money=money-%s where account = %s"
    parma3 = [money, account]
    update(sql3, parma3)
    sql4 = "update user set money=money+%s where account = %s"
    parma4 = [money, accounts]
    update(sql4, parma4)
    return 0
Пример #7
0
def bank_takeMoney(account,password,money):
    sql1 = "select * from bank where username=%s"
    user = select(sql1, account)

    if len(user) != 0:
        sql2 = "select password from bank where username=%s"
        password1= select(sql2, account)
        if password1[0][0]==password:
            sql3="select money from  bank where username=%s"
            money1=select(sql3,account)
            if money1[0][0]>=money:
                sql4="update bank set money=money-%s where username =%s"
                parm=[money,account]
                update(sql4,parm)
                print("取了",money,"元")
            else:
                print("取钱失败请充钱")
                return 3

        else:
            print("密码错误")
            return 1
    else:
        print("用户名不存在")
        return 2
Пример #8
0
def withdraw_money():
    account = input("请输入用户账号:")
    sql = "SELECT account FROM user_data where account = %s"
    param = [account]
    data01 = select(sql, param)
    if len(data01) != 0:
        print("用户存在")
        password = input("请输入密码:")
        sql1 = "SELECT passwords FROM user_data where account = %s"
        param1 = [account]
        data02 = select(sql1, param1)
        if data02[0][0] == password:
            print("密码正确!")
            money = int(input("请输入取钱金额:"))
            sql2 = "SELECT money FROM user_data where account = %s"
            param2 = [account]
            data03 = select(sql2, param2)
            if money <= data03[0][0]:
                sql2 = "UPDATE user_data set money = money -%s where account = %s"
                param3 = [money, account]
                update(sql2, param3)
                print("取钱成功!!")
            else:
                print("余额不足!!")
        else:
            print("密码错误!!")
    else:
        print("账户不存在!!")
Пример #9
0
def bank_addUser(account, username, password, country, province, street, door):
    # 判断是否已满

    sql = "select * from users"
    data = select(sql, [])
    print(data)
    if len(data) >= 100:
        return 3

    # 判断是否存在
    sql = "select * from users where id = %s"
    data = select(sql, account)

    if len(data) != 0:
        return 2

    #正常开户

    sql = "insert into users value(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
    param = [
        account, username, password, country, province, street, door, 0,
        bank_name
    ]
    update(sql, param)
    return 1
Пример #10
0
def money_transfer(outuser, takeinuser, password, outmoney):

    sql = "select * from users where id=%s "
    data = select(sql, outuser)
    sql5 = "select * from users where id=%s"
    data1 = select(sql5, takeinuser)
    if len(data) != 0 and len(data1) != 0:
        sql1 = "select * from users where id=%s and upassword=%s"
        data = select(sql1, [outuser, password])
        if len(data) != 0:
            sql2 = "select * from users where id=%s and money>=%s"
            data = select(sql2, [outuser, outmoney])
            if len(data) != 0:
                sql3 = "update users set money=money-%s where id=%s"
                update(sql3, [outmoney, outuser])
                sql4 = "update users set money=money+%s where id=%s"
                update(sql4, [outmoney, takeinuser])

                return 0
            else:
                return 3
        else:
            return 2
    else:
        return 1
Пример #11
0
def bankadd(account, username, password, country, province, street, door):
    sql1 = "select * from user where account = %s"
    param1 = [account]
    data1 = select(sql1, param1)
    if len(data1) > 0:
        return "2"
    sql = "select count(*) from user"  # (5)
    param = []
    data = select(sql, param)
    if data[0][0] >= 100:
        return "3"
    sql2 = " insert into user values(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
    param2 = [
        account, username, password, country, province, street, door, 0,
        bank_name
    ]
    update(sql2, param2)
    # bank[account] = {
    #     "username": username,  # 从useradd的account获取的随机数
    #     "password": password,
    #     "country": country,
    #     "province": province,
    #     "street": street,
    #     "door": door,
    #     "bank_name": bank_name,
    #     "money": 0
    # }
    return "1"
Пример #12
0
def qu():
    zh = input("请输入您的账号:")
    sql = "select * from blank where account = %s"
    param = [zh]
    data = select(sql, param)
    if len(data) != 0:
        print("账户存在!")
        password = input("请输入您的密码:")
        sql1 = "SELECT passwords FROM blank WHERE account =  %s"
        data1 = select(sql1, param)
        print(data1[0][0])
        if data1[0][0] == password:
            quqian = int(input("请输入取钱金额:"))
            sql3 = "SELECT money FROM blank WHERE account =  %s"
            data3 = select(sql3, param)
            print(data3)
            if quqian <= data3[0][0]:
                sql2 = "update blank set money = money - %s where account = %s"
                param1 = [quqian, zh]
                update(sql2, param1)
                print("取钱成功!!")
            else:
                print("取钱失败,金额不足!")

        else:
            print("请输入正确的密码!!!")
            return 2
    else:
        print("请输入用户账号不存在!!!")
        return 1
Пример #13
0
def cha():
    cxzh = input("请输入要查询的账号:")
    sql = "select * from blank where account = %s"
    param = [cxzh]
    data = select(sql, param)
    print(data)
    if len(data) != 0:
        cxmm = input("请输入要查询账号的密码:")
        sql1 = "SELECT * FROM blank WHERE account = %s and passwords = %s"
        param1 = [cxzh, cxmm]
        data1 = select(sql1, param1)
        print(data1[0][0])
        if data1[0][2] == cxmm:
            info = '''
                        ------------个人信息----------------
                        账号:%s,
                        用户名:%s,
                        取款密码:%s,
                        地址信息:
                            国家:%s,
                            省份:%s,
                            街道:%s,
                            门牌号:%s,
                        余额:%s,
                        开户行:%s
                        -----------------------------------
                    '''
            print(info % (data1[0][0], data1[0][1], data1[0][2], data1[0][3],
                          data1[0][4], data1[0][5], data1[0][6], data1[0][7],
                          bank_name))
        else:
            print("您输入的密码不正确,请重新输入!!")

    else:
        print("该用户不存在,请重新输入!!")
Пример #14
0
def bank_moneytransfer (account1,account2,password,moneytransfer):
    sql = "select * from 开户 where account = %s"
    date = select(sql,account1)

    if len(date) != 0:
        sql2 = "select * from 开户 where account = %s"
        date1 = select(sql2,account2)

        if len(date1) !=0:
            sql3 = "select * from 开户 where account = %s and mima = %s"
            date2 = select(sql3,[account1,password])

            if len(date2) !=0:
                sql4 = "select * from 开户 where account= %s and money >=%s"
                date3 = select(sql4,[account1,moneytransfer])

                if len(date3)!=0:
                    sql5 = "update 开户 set money = money - %s where account = %s"
                    update(sql5,[moneytransfer,account1])
                    sql6 = "update 开户 set money = money +%s where account = %s"
                    update(sql6,[moneytransfer,account2])
                    return 0
                else:
                    return 3
            else:
                return 2
        else:
            return 1
Пример #15
0
def bank_wda(account, password, wdamoney):

    sql = "select count(*) from users where users.account = %s"
    data = select(sql, account)

    if data[0][0] == 0:
        return 1
    if data[0][0] == 1:
        sql = "select count(*) from users where users.account= %s and users.password=%s"
        param = [account, password]
        data = select(sql, param)
        if data[0][0] == 1:
            sql2 = "select * from users where users.account= %s"
            param2 = [account]
            data2 = select(sql2, param2)
            datanum = data2[0][7]
            if datanum >= wdamoney:
                sql = "update users set users.money =users.money -%s where users.money>=%s"
                param = (wdamoney, wdamoney)
                update(sql, param)
                return 0
            else:
                return 3
        else:
            return 2
Пример #16
0
 def transfer(self,u,user):
     #判断账号是否存在
     sql = "select * from user where account = %s"
     data = select(sql,u.getId())
     sql = "select * from user where account = %s"
     data1 = select(sql, user)
     if len(data)!=0 and len(data1)!=0:
         #判断密码
         sql = "select * from user where account = %s and password = %s"
         data = select(sql,[u.getId(),u.getPassword()])
         if len(data)!=0:
             #判断余额
             sql = "select * from user where account = %s and balance >= %s"
             data = select(sql,[u.getId(),u.getBalance()])
             if len(data)!=0:
                 sql = "update user set balance = balance -%s where account = %s"
                 updata(sql,[u.getBalance(),u.getId()])
                 sql = "update user set balance = balance + %s where account = %s"
                 updata(sql,[u.getBalance(),user])
                 return 0
             else:
                 return 3
         else:
             return 2
     else:
         return 1
Пример #17
0
 def query(self,u):
     #判断账号是否存在
     sql = "select * from user where account = %s"
     data = select(sql,u.getId())
     if len(data)!=0:
         #判断密码
         sql = "select * from user where account = %s and password = %s"
         data = select(sql,[u.getId(),u.getPassword()])
         if len(data)!=0:
             sql = "select * from user where account = %s"
             data = select(sql,u.getId())
             info = '''
             
             ----------个人信息----------
             账号:%s
             姓名:%s
             密码:%s
             地址:
                 国家:%s
                 省份:%s
                 街道:%s
                 门牌号:%s
             余额:%s
             注册时间:%s
             开户行:%s
             ---------------------------
             '''
             print(info % (data[0][0],data[0][1],data[0][2],data[0][3],data[0][4],data[0][5],data[0][6],data[0][7],data[0][8],data[0][9],))
             return 0
         else:
             return 2
     else:
         return 1
Пример #18
0
def bank_quqian(take_user, take_password, take_money):
    #判断 用户存在
    sql = "select account from bank where account = %s;"
    parame = [take_user]
    users = select(sql, parame)
    if len(users) != 0:
        # 判断 密码正确
        users = ()
        sql = "select account from bank where account = %s and password = %s;"
        parame = [take_user, take_password]
        users = select(sql, parame)
        if len(users) != 0:
            #判断 余额足够
            users = ()
            sql = "select account from bank where account = %s and password = %s and (money-'%s') >= 0;"
            parame = [take_user, take_password, take_money]
            users = select(sql, parame)
            if len(users) != 0:
                #满足 扣钱
                users = ()
                sql = "update bank set money = money - %s where account = %s "
                parame = [take_money, take_user]
                update(sql, parame)
                return 0  #成功 返回值0
            else:
                return 3  #钱不够返回3
        else:
            return 2  #用户密码不正确返回2
    else:
        return 1  #返回1
Пример #19
0
def bank_zhuanzhang(send_user, send_userPw, send_to, send_money):
    sql = "select account from bank where account = %s or account = %s"
    parame = [send_user, send_to]
    users = select(sql, parame)
    if len(users) == 2:
        users = ()
        sql = "select account from bank where account = %s and password = %s"
        parame = [send_user, send_userPw]
        users = select(sql, parame)
        if len(users) == 1:
            users = ()
            sql = "select account from bank where account = %s and password = %s and money >= %s"
            parame = [send_user, send_userPw, send_money]
            users = select(sql, parame)
            if len(users) == 1:
                sql = "update bank set money = (money - %s) where account = %s ;"
                parame = [send_money, send_user]
                update(sql, parame)
                sql = "update bank set money = (money + %s) where account = %s ;"
                parame = [send_money, send_to]
                update(sql, parame)
                return 0
            else:
                return 3
        else:
            return 2
    else:
        return 1
Пример #20
0
def bank_ransferA(chu_account, ru_account, password, chu_money):
    sql8 = "select count(account) from bank where bank.account = %s or bank.account = %s"
    param8 = [chu_account, ru_account]
    data8 = select(sql8, param8)

    if data8[0][0] == 2:
        sql9 = "select count(account) from bank where bank.account = %s and bank.password = %s"
        param9 = [chu_account, password]
        data9 = select(sql9, param9)
        if data9[0][0] == 1:
            sqldx1 = "select * from bank where bank.account = %s"
            paramdx1 = [chu_account]
            datadx = select(sqldx1, paramdx1)
            num1 = datadx[0][7]
            if num1 >= chu_money:
                sql10 = "update bank set bank.money = bank.money - %s where bank.account = %s"
                param10 = [chu_money, chu_account]
                update(sql10, param10)
                sql11 = "update bank set bank.money = bank.money + %s where bank.account = %s"
                param11 = [chu_money, ru_account]
                update(sql11, param11)
                return 0
            else:
                return 3
        else:
            return 2
    else:
        return 1
Пример #21
0
def bank_addUser(account, username, password, country, province, street, door):
    #查询数据库中是否存在账号

    sql = "select count(*) from bank"
    data = select(sql, [])  # ((72),(),())
    print(data)
    # 判断是否已满
    if data[0][0] >= 100:
        return 3

    sql1 = "select * from bank where account = %s"
    data1 = select(sql1, account)
    # 判断是否存在
    if len(data1) != 0:
        return 2

    # 准备一条sql语句
    sql2 = "insert into bank  values(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
    param2 = [
        account, username, password, country, province, street, door, 0,
        bank_name
    ]
    # 让控制台执行sql
    update(sql2, param2)
    return 1
Пример #22
0
def bank_withdraw(account, password, withdraw_money):
    #数据库

    sql5 = "select count(*) from bank where bank.account = %s"
    param5 = [account]
    data5 = select(sql5, param5)

    if data5[0][0] == 1:  #存在
        sql6 = "select count(*) from bank where bank.account = %s and bank.password = %s"
        param6 = [account, password]
        data6 = select(sql6, param6)

        if data6[0][0] == 1:
            sqldx = "select * from bank where bank.account = %s"
            paramdx = [account]
            datadx = select(sqldx, paramdx)
            num = datadx[0][7]
            if num >= withdraw_money:
                sql7 = "update bank set bank.money =bank.money - %s where bank.money >= %s"
                param7 = [withdraw_money, withdraw_money]
                data7 = update(sql7, param7)
                return 0
            else:
                return 3
        else:
            return 2
    else:
        return 1
Пример #23
0
    def method(self, u, ad):
        #判断是否数据库已满

        sql = "select * from user"
        data = select(sql, [])
        if len(data) >= 100:
            return 3
        #判断用户存不存在
        sql = "select * from user where account = %s"
        data = select(sql, u.getId())
        if len(data) != 0:
            return 2
        #正常开户
        print(u.getId())
        sql = "insert into user value(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        param = [
            u.getId(),
            u.getName(),
            u.getPassword(),
            ad.getCountry(),
            ad.getProvince(),
            ad.getStreet(),
            ad.getDoor(),
            u.getBalance(),
            u.getTime(),
            u.getBank()
        ]
        updata(sql, param)
        return 1
Пример #24
0
def transfer_accounts(za, zb, zc, zd):  # 转账
    sql1 = "select * from user where account = %s"
    param1 = [za]
    data1 = select(sql1, param1)
    if za != zb:
        if len(data1[0]) > 0:
            sql2 = "select * from user where account = %s"
            param2 = [zb]
            data2 = select(sql2, param2)
            if len(data2[0]) > 0:
                if zc == data1[0][2]:
                    if data1[0][7] >= zd:
                        sql2 = "update user  set  money = money - %s where account=%s"
                        param = [int(zd), za]
                        update(sql2, param)
                        sql2 = "update user  set  money = money + %s where account=%s"
                        param = [int(zd), zb]
                        update(sql2, param)
                    else:
                        return "3"
                else:
                    return "2"
            else:
                return "1"
        else:
            return "1"
    elif za == zb:
        print("转出账号不能和转入账号相同")
Пример #25
0
def bank_tran(account1, account2, password, money):
    sql = "select count(*) from users where users.account= %s or users.account =%s"
    param = [account1, account2]
    data = select(sql, param)
    if data[0][0] == 2:
        sql = "select count(*) from users where users.account= %s and users.password=%s"
        param = [account1, password]
        data = select(sql, param)
        if data[0][0] == 1:
            sql = "select * from users where users.account= %s"
            param = [account1]
            data = select(sql, param)
            num = data[0][7]
            if num >= money:
                sql = "update users set users.money =users.money - %s where users.account=%s"
                param1 = [money, account1]
                update(sql, param1)
                sql1 = "update users set users.money =users.money + %s where users.account=%s"
                param2 = [money, account2]
                update(sql1, param2)
            else:
                return 3
        if data[0][0] == 0:
            return 2
    else:
        return 1
Пример #26
0
def bank_query(account,password):
    sql = "select * from 开户 where account = %s"
    date = select(sql,account)
    if date!=0:
        sql2 = "select account from 开户 where mima = %s"
        date1 = select(sql2,password)
        if date1!=0:
            return 1
        else:
            return 2
    else:
        return 3
Пример #27
0
 def inquriy(self, u):
     sql = "select * from 开户 where account=%s  "
     data = select(sql, u.getAccount())
     if len(data) != 0:
         sql2 = "select account from 开户 where mima=%s"
         data = select(sql2, u.getPassword())
         if len(data) != 0:
             return 0
         else:
             return 2
     else:
         return 1
Пример #28
0
def bank_query(account, password):
    sql = "select count(*) from users where users.account= %s"
    data = select(sql, account)
    if data[0][0] == 1:
        sql = "select count(*) from users where users.account= %s and users.password=%s"
        param = [account, password]
        data = select(sql, param)
        if data[0][0] == 1:
            return 2
        if data[0][0] == 0:
            return 1
    if data[0][0] == 0:
        return 0
Пример #29
0
def bank_outmoney(account,account1,password,money):
    sql1 = "select * from bank where username=%s"
    user = select(sql1, account)
    sql1 = "select * from bank where username=%s"
    user1 = select(sql1, account1)
    if len(user) != 0 and len(user1)!=0:
        sql2 = "select password from bank where username=%s"
        password1 = select(sql2, account)
        if password1[0][0] == password:
            sql3 = "select money from  bank where username=%s"
            money1 = select(sql3, account)
            if money1[0][0]-money>=0:
                sql4="update bank set money=money-%s where username=%s"
                parm=[money,account]
                select(sql4,parm)
                sql5="update bank set money=money+%s where username=%s"
                parm1=[money,account1]
                select(sql5,parm1)
                print("转账成功")
            else:
                print("转账失败,请充钱")
                return 3
        else:
            print("密码错误")
            return 2

    else:
        print("没有该用户")
        return 1
Пример #30
0
def bank_addUser(account,username,password,country,province,street,door):

    sql= "select count(*) from 开户"
    date = select(sql,[])
    if date[0][0]>=100:
        return 3
    sql1 = "select * from 开户 where account = %s"
    date1 = select(sql1,account)
    if len(date1)!=0:
        return 2
    sql2 = "insert into 开户 values(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
    param2 = [account,username,password,country,province,street,door,0,bank_name]
    update(sql2,param2)
    return 1