示例#1
0
def select_party(userid, txtype):
    """
    卡号选择 传入用户id 和交易类型  返回选择的卡号
    :param userid: 
    :param txtype: 
    :return: 
    """
    party_list = dbssc('select card_num from party where userid = %s' %
                       (userid))
    rownum = 0
    rownum_list = []
    for i in party_list:
        print('%s. 卡号[%s]' % (rownum, i))
        rownum_list.append(rownum)
        rownum += 1
    exit_flag = False
    while not exit_flag:
        select_card_num = int(
            input('请输入选择 %s 账户的编号:\n>>' % transaction_type[txtype]))
        if select_card_num in rownum_list:
            exit_flag = True
            select_card = party_list[select_card_num]
        else:
            print('输入账号编码错误')
            log.warn('输入账号编码错误')
    party_id = dbssv('select party_id from party where card_num = %s' %
                     (select_card))
    return party_id
示例#2
0
def frozen_account():
    """
    冻结账户
    :return: 
    """
    frozen_account_dis = ['账户名']
    frozen_account_name = input_handle(frozen_account_dis)[0]
    if frozen_account_name not in dbssc('select username from account'):
        print('账户不存在')
        log.warn('账户 %s 不存在' % frozen_account_name)
    else:
        db('update account set account_status = locked where userid = %d ' %
           (dbssc('select userid from account where username = %s' %
                  (frozen_account_name))[0]))
示例#3
0
def set_limit():
    """
    设置额度
    :return: 
    """
    set_limit_dis = ['账户名', '新的额度是']
    set_limit_name, set_limit_new_amount = input_handle(set_limit_dis)
    if set_limit_name not in dbssc('select username from account'):
        print('账户不存在')
        log.warn('账户 %s 不存在' % set_limit_name)
    else:
        db('update party set card_balance = %d where userid = %d ' %
           (int(set_limit_new_amount),
            dbssc('select userid from account where username = %s' %
                  (set_limit_name))[0]))
示例#4
0
def get_user_info(party_id):
    """
    传入party_id 返回用户名 卡号等信息
    :param party_id: 
    :return: 
    """
    if party_id is not None:
        user_id = dbssv('select userid from party where party_id = %s' %
                        (party_id))
        username = dbssv('select username from account where userid = %s' %
                         (user_id))
        card_num = dbssv('select card_num from party where party_id = %s' %
                         (party_id))
        return username, card_num
    else:
        log.warn('没有交易对手')
示例#5
0
def uinstall_atmdb():
    """
    清理删除atmdb数据库
    :param dbname:
    :return:
    """
    log.info('------------- database %s drop'%dbname)

    if db('show databases') is not None:
        if dbname in db('show databases'):
            db('drop database %s'%dbname)
            log.info('database %s is drop' % dbname)
        else:
            print('database %s does not exist'%dbname)
            log.warn('database %s does not exist'%dbname)
    else:
        log.warn('database %s does not exist' % dbname)
    log.info('------------- database %s drop end' % dbname)
示例#6
0
def auth(user_type):
    login_info_dis = ['用户名', '密码']
    username, password = input_handle(login_info_dis)
    if username in dbssc('select username from account where rule = %s' %
                         (user_type)):
        if password == dbssv(
                'select password from account where username = %s' %
            (username)) and dbssv(
                'select account_status from account where username = %s' %
                (username)) == 'open':
            userdata['auth_status'] = True
            userdata['userid'] = dbssv(
                'select userid from account where username = %s' % (username))
            userdata['user_type'] = user_type
            log.info('用户 %s 认证登陆成功' % (username))
            return True
        elif dbssv('select account_status from account where username = %s' %
                   (username)) == 'locked':
            log.warn('用户 %s 账户锁定 请求认证失败' % (username))
            print('用户 %s 账户锁定 请求认证失败' % (username))
            return False
        else:
            log.warn('用户 %s 密码错误 请求认证失败' % (username))
            print('用户 %s 密码错误 请求认证失败' % (username))
            return False
    else:
        log.warn('用户 %s 不存在 请求认证失败' % (username))
        print('用户 %s 不存在 请求认证失败' % (username))
        return False