예제 #1
0
파일: qukuan.py 프로젝트: okada8/python
def qukuan(name, dic_baihu, *args):

    logger = log_user.getlog(Logpath, "qukuan")
    logger1 = log_user.getlog(Logpath1, "qukuan2")
    dic1 = {}
    while True:
        money = input("请输入你要取款的金额: ")
        if money.isdigit():
            now_money = int(dic_baihu[name]["money"]) - int(money)
            if now_money >= 0:
                dic1[name] = {
                    "pwd": dic_baihu[name]["pwd"],
                    "money": now_money,
                    "xyk_y": dic_baihu[name]["xyk_y"],
                    "xyk": dic_baihu[name]["xyk"],
                    "xyk_time": dic_baihu[name]["xyk_time"],
                    "logging_time": dic_baihu[name]["logging_time"]
                }
                dic_baihu.update(dic1)

                jieguo = db_file_write.db_write(dic_baihu)
                if jieguo == True:
                    print("正在取款中......")
                    time.sleep(1)
                    print("正在更新用户信息......")
                    time.sleep(1)
                    print("""
                        -----------------------    
                            取款成功
                            你的名字: %s
                            你的余额: %s
                            信用卡可用额度: %s
                        -----------------------
                            """ % (name, dic_baihu[name]["money"], \
                               dic_baihu[name]["xyk_y"]))
                    time.sleep(2)
                    logger.info("%s取款%s" % (name, money))
                    logger1.info("%s取款%s" % (name, money))
                    break
                else:
                    print("取款失败")
                    logger.error("%s取款%s错误" % (name, money))
            else:
                print("""
                -------------------------------
                        取款失败,您的余额不足!!!
                        你的姓名: %s
                        你的余额: %s
                        信用卡可用额度 : %s
                -------------------------------
                        """ % (name, dic_baihu[name]["money"], \
                            dic_baihu[name]["xyk_y"]))
                logger.error("%s取款%s大于余额" % (name, money))
                time.sleep(2)

        else:
            print("钱是数字")
            logger.error("%s输入错误" % (name))
            continue
예제 #2
0
def app(*args):

    name = args[0]
    logger = log_user.getlog(Logpath, "choice")
    dic={"1":chaxun.chaxun,"2":zhuanzhang.zhuanzhang,\
         "3":qukuan.qukuan,"4":cunkuan.cunkuan,"5":shop_car.shopcar,
         "6":xyk.xyk_ye1}
    while True:
        print("""
---------------------    
    【1】查询
    【2】转账
    【3】取款
    【4】存款
    【5】购物
    【6】信用卡业务
    【7】退出
-----------------------
""")
        choice = input("你的选择: ")
        if choice in dic:
            dic[choice](*args)
            logger.info("%s选择了%s" % (name, dic[choice]))
        else:
            logger.info("%s选择了退出" % (name))
            break
예제 #3
0
def cunkuan(name, dic_baihu, *args):
    logger = log_user.getlog(Logpath, "cunkuan")
    logger1 = log_user.getlog(Logpath1, "cunkuan2")
    dic1 = {}
    while True:
        money = input("请输入您要存入的金额: ")
        if money.isdigit():
            now_money = int(money) + int(dic_baihu[name]["money"])
            dic1[name] = {
                "pwd": dic_baihu[name]["pwd"],
                "money": str(now_money),
                "xyk_y": dic_baihu[name]["xyk_y"],
                "xyk": dic_baihu[name]["xyk"],
                "xyk_time": dic_baihu[name]["xyk_time"],
                "logging_time": dic_baihu[name]["logging_time"]
            }
            dic_baihu.update(dic1)
            jieguo = db_file_write.db_write(dic_baihu)
            if jieguo == True:
                print("正在存款中.....")
                time.sleep(1)
                print("正在更新用户信息.....")
                time.sleep(1)
                print("""
               -----------------------
                   存款成功!!!
                   你的姓名 : %s
                   你的余额: %s
                   信用卡可用额度 : %s
               -----------------------
                   """ % (name, dic_baihu[name]["money"], \
                           dic_baihu[name]["xyk"]))
                time.sleep(2)
                logger1.info("%s存入了%s" % (name, money))
                logger.info("%s存入了%s" % (name, money))
                break
            else:
                print("存款失败")
                logger.error("%s存入%s错误" % (name, money))
        else:
            print("请输入数字")
            logger.error("%s输入错误" % (name))
            continue
예제 #4
0
def chaxun(name, dic_baihu, *args):
    logger = log_user.getlog(Logpath, "chaxun")
    print("正在查询中.....")
    time.sleep(2)
    print("""
 ------------------------   
    你的姓名: %s
    你的余额: %s
    信用卡可用额度: %s
 ------------------------   
    """ %(name,dic_baihu[name]["money"],\
          dic_baihu[name]["xyk_y"]))
    time.sleep(2)
    logger.info("%s查询了余额" % name)
예제 #5
0
def db_write(dic_baihu, *args):
    logger = log_user.getlog(Logpath, "dbwrite")
    with open(settings.db_file_baihu2, "w") as line:
        if not args:
            json.dump(dic_baihu, line)
            logger.info("数据库写入成功")
            return True
        else:
            with open(settings.db_file_baihu2, "a") as f2:
                json.dump(dic_baihu, f2)
            dic_heihu = args[0]
            with open(settings.db_file_heihu2, "w") as line1:
                json.dump(dic_heihu, line1)
            logger.info("数据库写入成功")
            return True
예제 #6
0
def db_read(db_file_baihu,db_file_heihu):
    dic_baihu={}
    dic_heihu={}
    logger=log_user.getlog(Logpath,"db_read")
    logger.info("打开数据库读取白户信息")
    with open(db_file_baihu,encoding="utf-8") as line:
        dic_baihu.update(json.load(line))
    logger.info("打开数据库读取白户信息已完成")
    logger.info("打开数据库读取黑户信息")
    with open(db_file_heihu,encoding="utf-8") as line1:
        if os.path.getsize(db_file_heihu) != 0:
            dic_heihu.update(json.load(line1))
    logger.info("打开数据库读取黑户信息已完成")
    logger.info("进入登录函数")
    user_logging.loging(dic_baihu,dic_heihu)
예제 #7
0
파일: zhuce.py 프로젝트: okada8/python
def user_zhuce(*args):
    logger = log_user.getlog(Logpath, "zhuce")
    name = args[0]
    dic_baihu = args[1]
    dic1 = {}
    tag = True
    while tag:
        pwd = input("请输入登录密码:").strip()
        if pwd.isdigit() and len(pwd) == 6:
            while tag:
                pwd2 = input("请再次输入登录密码:").strip()
                if pwd == pwd2:
                    while tag:
                        money = input("请输入你要存入的余额: ")
                        if not money.isdigit():
                            print("钱是数字")
                            continue
                        else:

                            while tag:
                                xyk = input("你的信用卡额度: ")
                                if not xyk.isdigit():
                                    print("信用卡额度是数字")
                                    continue
                                else:
                                    dic1[name] = {
                                        "pwd": pwd2,
                                        "money": money,
                                        "xyk_y": xyk,
                                        "xyk": xyk,
                                        "xyk_time": "0",
                                        "logging_time": "0"
                                    }
                                    dic_baihu.update(dic1)

                                    jieguo = db_file_write.db_write(dic_baihu)
                                    if jieguo == True:
                                        print("注册成功,需要重新登陆....")
                                        time.sleep(1)
                                        logger.info("%s注册成功" % name)
                                        tag = False
                                        return jieguo
                else:
                    print("两次密码不一致")
                    logger.error("%s密码输入不一致" % name)
                    continue
        else:
            print("请输入6位数密码")
예제 #8
0
def shopcar(name,dic_baihu,*args):

    logger=log_user.getlog(Logpath,"shop_car")
    shope_car1 = {}
    tag = True
    while tag:
        print("""
                    欢迎来到苹果中国
        ---------------------------------------
                  商品列表              单价
                
                1.iphone xs max       10000
                2.iphone xr           9000
                3.iphone x            6000
                4.mac                 12000
            5.结算                         6.退出
        ----------------------------------------
             """)
        choice = int(input("请选择要购买的商品: "))
        time.sleep(1)
        if choice in [1, 2, 3, 4]:
            number = input("请输入你要购买的数量: ")
            time.sleep(1)
            if choice == 1:
                logger.info("%s购买了iphone xs max%s个"%(name,number))
                shope_car1["iphone xs max"] = {"price": 10000, "number": number}
            elif choice == 2:
                logger.info("%s购买了iphone xr%s个" % (name, number))
                shope_car1["iphone xr"] = {"price": 9000, "number": number}
            elif choice == 3:
                logger.info("%s购买了iphone x%s个" % (name, number))
                shope_car1["iphone x"] = {"price": 6000, "number": number}
            elif choice == 4:
                logger.info("%s购买了mac%s个" % (name, number))
                shope_car1["mac"] = {"price": 12000, "number": number}
        else:
            if choice == 5:
                logger.info("%s开始结算" % (name))
                payment.jiesuan(name, dic_baihu, shope_car1)
            elif choice == 6:
                logger.info("%s退出" % (name))
                tag = False

            else:
                logger.error("%s输入错误" % (name))
                print("请输入1-6")
예제 #9
0
def zhuanzhang(name, dic_baihu, dic_heihu):

    logger = log_user.getlog(Logpath, "zhuanzhang")
    logger1 = log_user.getlog(Logpath1, "zhuanzhang2")
    tag = True
    dic1 = {}
    dic2 = {}

    while tag:
        own_name = input("你要转给谁:")
        print("正在查找用户信息......")
        time.sleep(2)
        if own_name in dic_baihu:
            while tag:
                money = input("请输入转多少: ")
                if money.isdigit():
                    now_name_money = int(dic_baihu[name]["money"]) - int(money)
                    now_own_mone = int(
                        dic_baihu[own_name]["money"]) + int(money)
                    if now_name_money > 0:
                        dic1.clear()
                        dic1[name] = {
                            "pwd": dic_baihu[name]["pwd"],
                            "money": str(now_name_money),
                            "xyk_y": dic_baihu[name]["xyk_y"],
                            "xyk": dic_baihu[name]["xyk"],
                            "xyk_time": dic_baihu[name]["xyk_time"],
                            "logging_time": dic_baihu[name]["logging_time"]
                        }
                        dic1[own_name] = {
                            "pwd": dic_baihu[name]["pwd"],
                            "money": str(now_own_mone),
                            "xyk_y": dic_baihu[name]["xyk_y"],
                            "xyk": dic_baihu[name]["xyk"],
                            "xyk_time": dic_baihu[name]["xyk_time"],
                            "logging_time": dic_baihu[name]["logging_time"]
                        }
                        dic_baihu.update(dic1)

                        jieguo = db_file_write.db_write(dic_baihu)
                        if jieguo == True:
                            print("正在查询信息......")
                            time.sleep(1)
                            print("正在转账中........")
                            time.sleep(1)
                            print("正在更新账户信息......")
                            time.sleep(1)
                            print("""
                        ------------------------------       
                                转账成功!!!
                                你的名字: %s
                                你的余额: %s
                                你的信用卡可用额度: %s
                        -------------------------------     
                                """ % (name, dic_baihu[name]["money"], \
                                       dic_baihu[name]["xyk_y"]))
                            time.sleep(2)
                            logger.info("%s给%s转了%s" % (name, own_name, money))
                            logger1.info("%s给%s转了%s" % (name, own_name, money))
                            tag = False
                        else:
                            print("存款错误")
                            logger.error("%s给%s转了%s出现错误" %
                                         (name, own_name, money))
                    else:
                        print("您的余额不足")
                        logger.error("%s余额不足" % (name))
                else:
                    print("钱是数字")
                    logger.error("%s输入错误" % (name))
                    continue

        elif own_name in dic_heihu:

            while tag:
                money = input("请输入转多少: ")
                if money.isdigit():
                    now_name_money = int(dic_baihu[name]["money"]) - int(money)
                    now_own_mone = int(
                        dic_heihu[own_name]["money"]) + int(money)
                    if now_name_money > 0:

                        dic2.clear()
                        dic1.clear()
                        dic1[name] = {
                            "pwd": dic_baihu[name]["pwd"],
                            "money": str(now_name_money),
                            "xyk_y": dic_baihu[name]["xyk_y"],
                            "xyk": dic_baihu[name]["xyk"],
                            "xyk_time": dic_baihu[name]["xyk_time"],
                            "logging_time": dic_baihu[name]["logging_time"]
                        }
                        dic2[own_name] = {
                            "pwd": dic_heihu[own_name]["pwd"],
                            "money": str(now_own_mone),
                            "xyk_y": dic_heihu[own_name]["xyk_y"],
                            "xyk": dic_heihu[own_name]["xyk"],
                            "xyk_time": dic_heihu[own_name]["xyk_time"],
                            "logging_time": dic_heihu[own_name]["logging_time"]
                        }
                        dic_baihu.update(dic1)
                        dic_heihu.update(dic2)

                        jieguo = db_file_write.db_write(dic_baihu, dic_heihu)
                        if jieguo == True:
                            print("正在查询信息......")
                            time.sleep(1)
                            print("正在转账中........")
                            time.sleep(1)
                            print("正在更新账户信息......")
                            time.sleep(1)
                            print("""
                                ------------------------------        
                                        转账成功
                                        你的名字 : %s
                                        你的余额: %s
                                        你的信用卡 : %s
                                ------------------------------        
                                        """ % (name, dic_baihu[name]["money"], \
                                       dic_baihu[name]["xyk_y"]))
                            logger.info("%s给%s转了%s" % (name, own_name, money))
                            logger1.info("%s给%s转了%s" % (name, own_name, money))
                            tag = False
                        else:
                            print("转账错误")
                            logger.error("%s给%s转了%s出现错误" %
                                         (name, own_name, money))
                    else:
                        print("您的余额不足")
                        logger.error("%s余额不足" % (name))
                else:
                    print("钱是数字")
                    logger.error("%s输入错误" % (name))
                    continue
        else:
            print("%s不存在,请重新输入" % own_name)
            time.sleep(2)
            logger.error("%s不存在" % (own_name))
예제 #10
0
파일: payment.py 프로젝트: okada8/python
def jiesuan(name, dic_baihu, shope_car):
    logger = log_user.getlog(Logpath, "payment")
    logger1 = log_user.getlog(Logpath1, "jiesuan")
    tag = True
    l = []
    l1 = []
    dic = {}
    shop_car = {}
    shop_car.update(shope_car)
    sum_money2 = 0
    if len(shop_car) > 1:
        logger.info("%s购物车商品是两种" % name)

        xyk_yue = int(dic_baihu[name]["money"]) + float(
            dic_baihu[name]["xyk_y"])
        user_yue = int(dic_baihu[name]["money"])
        user_xyk = float(dic_baihu[name]["xyk_y"])
        for k, v in shop_car.items():
            l.append(k)
            sum_money1 = int(v["number"]) * int(v["price"])
            sum_money2 += sum_money1

            s = " ".join([
                k,
                str(shop_car[k]["price"]),
                str(shop_car[k]["number"]),
                str(sum_money1)
            ])
            l.append(s)

        for i in range(len(l)):
            if i % 2 != 0:
                l1.append(l[i])

            s4 = "\n".join(l1)

        if sum_money2 > xyk_yue and sum_money2 > user_xyk and \
                sum_money2 > user_yue:
            logger.error("%s信用卡和余额不足以支付" % name)
            print("您的余额和信用卡都不足以支付订单")
            shop_car.clear()
            return
        else:
            print("""
-------------清单---------------------
商品名      单价    数量      总价
%s



                            共计:%s
--------------------------------------
        """ % (s4, sum_money2))
            time.sleep(1)
            while tag:
                print("""
                ------------------------------
                    请选择支付方式
                    1.余额支付
                    2.信用卡支付
                    3.余额加信用卡组合支付
                    4.取消支付(系统会自动清空购物车)
                -------------------------------
                    """)
                choice3 = input("请选择: ")
                if choice3 == "1":
                    if user_yue < sum_money2:
                        logger.error("%s余额不足以支付" % name)
                        print("您目前余额为%s,不能支付请选择其他付款方式" % user_yue)
                        continue
                    else:
                        now_user_yue = user_yue - sum_money2

                        while tag:
                            choice4 = input("确认输入Y/y,退出输入N/n: ")

                            if choice4 in ["y", "Y"]:
                                dic[name] = {
                                    "pwd": dic_baihu[name]["pwd"],
                                    "money": now_user_yue,
                                    "xyk_y": dic_baihu[name]["xyk_y"],
                                    "xyk": dic_baihu[name]["xyk"],
                                    "xyk_time": dic_baihu[name]["xyk_time"],
                                    "logging_time":
                                    dic_baihu[name]["logging_time"]
                                }
                                dic_baihu.update(dic)
                                jieguo = db_file_write.db_write(dic_baihu)
                                print("正在支付中.....")
                                time.sleep(2)
                                if jieguo == True:
                                    logger.info("%s余额支付%s成功" %
                                                (name, sum_money2))
                                    logger1.info("%s余额支付%s成功" %
                                                 (name, sum_money2))
                                    print("支付成功,即将返回上品列表")
                                    tag = False
                                else:
                                    logger.error("%s余额支付失败" % name)
                                    print("支付失败")
                            else:
                                tag = False

                        if user_xyk < sum_money2:
                            print("您目前信用余额为%s,不能支付请选择其他付款方式" % user_xyk)
                            logger.error("%s信用卡余额不足以支付" % name)
                            continue
                        else:
                            now_user_xyk = user_xyk - sum_money2

                            while tag:
                                choice4 = input("确认输入Y/y,退出输入N/n: ")
                                if choice4 in ["y", "Y"]:

                                    dic[name] = {
                                        "pwd":
                                        dic_baihu[name]["pwd"],
                                        "money":
                                        dic_baihu[name]["money"],
                                        "xyk_y":
                                        now_user_xyk,
                                        "xyk":
                                        dic_baihu[name]["xyk"],
                                        "xyk_time":
                                        time.time(),
                                        "logging_time":
                                        dic_baihu[name]["logging_time"]
                                    }
                                    dic_baihu.update(dic)
                                    jieguo = db_file_write.db_write(dic_baihu)
                                    print("正在支付中.....")
                                    time.sleep(2)
                                    if jieguo == True:
                                        logger.info("%s信用卡支付%s成功" %
                                                    (name, sum_money2))
                                        logger1.info("%s信用卡支付%s成功" %
                                                     (name, sum_money2))
                                        print("支付成功,即将返回商品列表")
                                        time.sleep(1)

                                    else:
                                        logger.error("%s信用卡支付失败" % name)
                                        print("支付失败")
                                elif choice4 in ["n", "N"]:
                                    logger.error("%s选择退出" % name)
                                    tag = False
                                else:
                                    logger.error("%s输入错误" % name)
                                    print("输入错误,请重新输入")
                                    continue
                elif choice3 == "2":
                    if user_xyk < sum_money2:
                        print("您目前信用余额为%s,不能支付请选择其他付款方式" % user_xyk)
                        logger.error("%s信用卡余额不足以支付" % name)
                        continue
                    else:
                        now_user_xyk = user_xyk - sum_money2

                        while tag:
                            choice4 = input("确认输入Y/y,退出输入N/n: ")
                            if choice4 in ["y", "Y"]:

                                dic[name] = {
                                    "pwd": dic_baihu[name]["pwd"],
                                    "money": dic_baihu[name]["money"],
                                    "xyk_y": now_user_xyk,
                                    "xyk": dic_baihu[name]["xyk"],
                                    "xyk_time": time.time(),
                                    "logging_time":
                                    dic_baihu[name]["logging_time"]
                                }
                                dic_baihu.update(dic)
                                jieguo = db_file_write.db_write(dic_baihu)
                                print("正在支付中.....")
                                time.sleep(2)
                                if jieguo == True:
                                    logger.info("%s信用卡支付%s成功" %
                                                (name, sum_money2))
                                    logger1.info("%s信用卡支付%s成功" %
                                                 (name, sum_money2))
                                    print("支付成功,即将返回上品列表")
                                    time.sleep(1)
                                    tag = False
                                else:
                                    logger.error("%s信用卡支付失败" % name)
                                    print("支付失败")
                            else:
                                tag = False
                elif choice3 == "3":
                    print("""
                             ------------------------------
                                    您目前余额为:%s
                                    您目前信用卡余额为:%s
                             ------------------------------
                                    """ % (user_yue, user_xyk))
                    while tag:
                        money_y = int(input("请输入你要使用多少余额: "))
                        time.sleep(1)
                        money_x = int(input("请输入你要使用多少信用卡: "))
                        time.sleep(1)
                        user_money_he = money_x + money_y
                        now_user_money = sum_money2 - user_money_he
                        if now_user_money < 0:
                            print("不足以支付,请重新输入要使用的钱数")
                            logger.error("%s信用卡和余额组合不足以支付" % name)
                            continue
                        else:
                            now_user_yue = int(
                                dic_baihu[name]["money"]) - money_y
                            now_user_xyk = float(
                                dic_baihu[name]["xyk_y"]) - money_x

                            while tag:
                                choice4 = input("确认输入Y/y,退出输入N/n: ")
                                if choice4 in ["y", "Y"]:
                                    dic[name] = {
                                        "pwd":
                                        dic_baihu[name]["pwd"],
                                        "money":
                                        now_user_yue,
                                        "xyk_y":
                                        now_user_xyk,
                                        "xyk":
                                        dic_baihu[name]["xyk"],
                                        "xyk_time":
                                        time.time(),
                                        "logging_time":
                                        dic_baihu[name]["logging_time"]
                                    }

                                    dic_baihu.update(dic)
                                    jieguo = db_file_write.db_write(dic_baihu)
                                    print("正在支付中.....")
                                    time.sleep(2)

                                    dic_baihu.update(dic)
                                    if jieguo == True:
                                        print("支付成功,即将返回商品列表")
                                        logger.info("%s组合支付%s成功" %
                                                    (name, sum_money2))
                                        logger1.info("%s组合支付%s成功" %
                                                     (name, sum_money2))
                                        tag = False
                                    else:
                                        logger.error("%s组合支付失败" % name)
                                        print("支付失败")
                                else:
                                    tag = False
                elif choice3 == "4":
                    logger.error("%s选择退出" % name)
                    tag = False
                else:
                    logger.error("%s输入错误" % name)
                    print("输入错误,请重新输入")
                    continue
    else:
        while tag:
            logger.info("%s购物车上品种为1" % (name))
            xyk_yue = int(dic_baihu[name]["money"]) + float(
                dic_baihu[name]["xyk_y"])
            user_yue = int(dic_baihu[name]["money"])
            user_xyk = float(dic_baihu[name]["xyk_y"])
            for i, v in shop_car.items():
                sum_money_shop = int(shop_car[i]["price"]) * \
                                 int(shop_car[i]["number"])

                l.append(i)
                s = " ".join([
                    i,
                    str(shop_car[i]["price"]),
                    str(shop_car[i]["number"]),
                    str(sum_money_shop)
                ])
                l.append(s)
                for i in range(len(l)):
                    if i % 2 != 0:
                        l1.append(l[i])
                    s4 = "\n".join(l1)
                if sum_money_shop > xyk_yue and sum_money_shop > user_xyk and \
                        sum_money_shop > user_yue:
                    logger.error("%s信用卡和余额不足以支付" % name)
                    print("您的余额和信用卡都不足以支付订单")
                    shop_car.clear()
                    return
                else:
                    print("""
    -------------清单---------------------
    商品名      单价    数量      总价
    %s



                                 共计:%s
    --------------------------------------
    """ % (s4, sum_money_shop))
                    time.sleep(1)
                    while tag:
                        print("""
                  ----------------------------------      
                        请选择支付方式
                        1.余额支付
                        2.信用卡支付
                        3.余额加信用卡组合支付
                        4.取消支付(系统会自动清空购物车)
                  -----------------------------------      
                        """)
                        choice3 = input("请选择: ")
                        if choice3 == "1":
                            if user_yue < sum_money_shop:
                                print("您目前余额为%s,不能支付请选择其他付款方式" % user_yue)
                                logger.error("%s余额支付不足" % name)
                                continue
                            else:
                                now_user_yue = user_yue - sum_money_shop
                                while tag:
                                    choice4 = input("确认输入Y/y,退出输入N/n: ")
                                    if choice4 in ["y", "Y"]:
                                        dic[name] = {
                                            "pwd":
                                            dic_baihu[name]["pwd"],
                                            "money":
                                            now_user_yue,
                                            "xyk_y":
                                            dic_baihu[name]["xyk_y"],
                                            "xyk":
                                            dic_baihu[name]["xyk"],
                                            "xyk_time":
                                            dic_baihu[name]["xyk_time"],
                                            "logging_time":
                                            dic_baihu[name]["logging_time"]
                                        }
                                        dic_baihu.update(dic)
                                        jieguo = db_file_write.db_write(
                                            dic_baihu)
                                        print("正在支付中.....")
                                        time.sleep(2)
                                        if jieguo == True:
                                            logger.info("%s余额支付%s成功" %
                                                        (name, sum_money_shop))
                                            logger1.info(
                                                "%s余额支付%s成功" %
                                                (name, sum_money_shop))
                                            print("支付成功,即将返回商品列表")
                                            time.sleep(1)
                                            tag = False
                                        else:
                                            logger.error("%s余额支付失败" % name)
                                            print("支付失败")
                                    elif choice4 in ["n", "N"]:
                                        tag = False
                                    else:
                                        logger.error("%s输入错误" % name)
                                        print("输入错误,请重新输入")
                                        continue
                        elif choice3 == "2":
                            if user_xyk < sum_money_shop:
                                logger.error("%s信用卡余额支付不足" % name)
                                print("您目前信用余额为%s,不能支付请选择其他付款方式" % user_xyk)
                                continue
                            else:
                                now_user_xyk = user_xyk - sum_money_shop

                                while tag:
                                    choice4 = input("确认输入Y/y,退出输入N/n: ")
                                    if choice4 in ["y", "Y"]:
                                        dic[name] = {
                                            "pwd":
                                            dic_baihu[name]["pwd"],
                                            "money":
                                            dic_baihu[name]["money"],
                                            "xyk_y":
                                            now_user_xyk,
                                            "xyk":
                                            dic_baihu[name]["xyk"],
                                            "xyk_time":
                                            time.time(),
                                            "logging_time":
                                            dic_baihu[name]["logging_time"]
                                        }
                                        dic_baihu.update(dic)

                                        jieguo = db_file_write.db_write(
                                            dic_baihu)
                                        print("正在支付中.....")
                                        time.sleep(2)
                                        if jieguo == True:
                                            print("支付成功,即将返回商品列表")
                                            time.sleep(1)
                                            logger.info("%s信用卡支付成功%s" %
                                                        (name, sum_money_shop))
                                            logger1.info(
                                                "%s信用卡支付成功%s" %
                                                (name, sum_money_shop))
                                            tag = False
                                        else:
                                            logger.error("%s信用卡支付失败" % name)
                                            print("支付失败")
                                    elif choice4 in ["n", "N"]:
                                        tag = False
                                    else:
                                        logger.error("%s输入错误" % name)
                                        print("输入错误,请重新输入")
                                        continue
                        elif choice3 == "3":
                            print("""
                        --------------------    
                            余额为:%s
                            信用卡余额为:%s
                        --------------------    
                            """ % (user_yue, user_xyk))
                            while tag:
                                money_y = int(input("请输入你要使用多少余额: "))
                                if money_y > user_yue:
                                    print("您输入的不对!")
                                    continue
                                money_x = int(input("请输入你要使用多少信用卡: "))
                                if money_x < 0:
                                    print("您的信用卡可用额度不足")
                                user_money_he = money_x + money_y
                                now_user_money = sum_money_shop - user_money_he
                                if now_user_money > 0:
                                    logger.error("%s信用卡和余额组合不足以支付" % name)
                                    print("不足以支付,请重新输入要使用的钱数")
                                    continue
                                elif now_user_money == 0:
                                    now_user_yue = int(
                                        dic_baihu[name]["money"]) - money_y
                                    now_user_xyk = float(
                                        dic_baihu[name]["xyk"]) - money_x
                                    while tag:
                                        choice4 = input("确认输入Y/y,退出输入N/n: ")
                                        if choice4 in ["y", "Y"]:
                                            dic[name] = {
                                                "pwd":
                                                dic_baihu[name]["pwd"],
                                                "money":
                                                now_user_yue,
                                                "xyk_y":
                                                now_user_xyk,
                                                "xyk":
                                                dic_baihu[name]["xyk"],
                                                "xyk_time":
                                                time.time(),
                                                "logging_time":
                                                dic_baihu[name]["logging_time"]
                                            }
                                            dic_baihu.update(dic)

                                            jieguo = db_file_write.db_write(
                                                dic_baihu)
                                            print("正在支付中.....")
                                            time.sleep(2)
                                            if jieguo == True:
                                                print("支付成功,即将返回商品列表")
                                                time.sleep(1)
                                                logger.info(
                                                    "%s组合支付%s成功" %
                                                    (name, sum_money_shop))
                                                logger1.info(
                                                    "%s组合支付%s成功" %
                                                    (name, sum_money_shop))
                                                tag = False
                                            else:
                                                logger.error("%s组合支付失败" % name)
                                                print("支付失败")
                                        else:
                                            tag = False
                                else:
                                    print("您输入的金额不对,请重新核对账单后,在支付")
                                    time.sleep(1)
                        elif choice3 == "4":
                            logger.info("%s选择退出" % name)
                            tag = False
                        else:
                            logger.error("%s输入错误" % name)
                            print("输入错误,请重新输入")
                            continue
예제 #11
0
파일: start.py 프로젝트: okada8/python
import sys, os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
sys.path.append(BASE_DIR)
from conf import settings
from db import db_file_read
from lib import log_user
Path1 = os.path.dirname(
    os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
log1 = r"atm_shopcar_payment\log\启动.log"
Logpath = os.path.join(Path1, log1)


def start1():
    db_file_read.db_read(settings.db_file_baihu2, settings.db_file_heihu2)


if __name__ == '__main__':
    logger = log_user.getlog(Logpath, "start")
    logger.info("开始运行程序")
    start1()
else:
    logger = log_user.getlog(Logpath, "start2")
    logger.info("解锁后开始运行程序")
    start1()
예제 #12
0
def loging(*args):
    logger = log_user.getlog(Logpath, "logger")
    count = 0
    dic_baihu = args[0]
    dic_heihu = args[1]
    dic1 = {}
    logger.info("进入登录循环")
    while True:

        print("""
-----------------------------------------        
        欢迎来到建设银行ATM终端
        公安局温馨提示您请关好门
        提示:同账户密码输错三次将会被系统
        锁定5分钟!!!
        
        
1.登录                              2.退出
-----------------------------------------        
        """)
        choice8 = input("请选择:")
        if choice8 == "1":

            user_name = input("你的名字: ").strip()
            if user_name not in dic_heihu and user_name not in dic_baihu:
                print("""
                    你输入的名字不存在
                    1.注册
                    2.退出
                    """)
                choice = input("请选择: ").strip()
                if choice == "1":
                    jieguo = zhuce.user_zhuce(user_name, dic_baihu)
                    if jieguo == True:
                        count = 0
                        continue
                else:
                    break
            if user_name in dic_baihu:
                user_pawd = input("请输入密码: ").strip()
                if count < 2:
                    if user_pawd == dic_baihu[user_name]["pwd"]:
                        print("登录成功")
                        time.sleep(1)
                        logger.info("%s登录成功" % user_name)
                        xuanze.app(user_name, dic_baihu, dic_heihu)
                    else:
                        print("密码错误")
                        logger.error("%s密码错误" % user_name)
                        count += 1
                        continue
                if count >= 2:
                    print("你的账户已经锁定")
                    time.sleep(2)
                    logger.error("%s登录锁定" % user_name)
                    dic1[user_name] = {
                        "pwd": dic_baihu[user_name]["pwd"],
                        "money": dic_baihu[user_name]["money"],
                        "xyk_y": dic_baihu[user_name]["xyk_y"],
                        "xyk": dic_baihu[user_name]["xyk"],
                        "xyk_time": dic_baihu[user_name]["xyk_time"],
                        "logging_time": time.time()
                    }
                    dic_heihu.update(dic1)
                    dic_baihu.pop(user_name)

                    db_file_write.db_write(dic_baihu, dic_heihu)

            else:
                nowtime = time.time()
                if nowtime - float(dic_heihu[user_name]["logging_time"]) > 300:

                    user_pawd = input("请输入密码: ").strip()
                    if count < 2:
                        if user_pawd == dic_heihu[user_name]["pwd"]:

                            dic1.clear()
                            dic1[user_name] = {
                                "pwd": dic_heihu[user_name]["pwd"],
                                "money": dic_heihu[user_name]["money"],
                                "xyk_y": dic_heihu[user_name]["xyk_y"],
                                "xyk": dic_heihu[user_name]["xyk"],
                                "xyk_time": dic_heihu[user_name]["xyk_time"],
                                "logging_time": time.time()
                            }
                            dic_baihu.update(dic1)
                            dic_heihu.pop(user_name)

                            jieguo = db_file_write.db_write(
                                dic_baihu, dic_heihu)
                            if jieguo == True:
                                print("成功解除锁定,需要程序重新启动")
                                logger.info("%s解锁成功" % user_name)
                                exit()
                            else:
                                print("登陆错误")
                        else:
                            print("密码错误")
                            logger.error("%s密码错误" % user_name)
                            count += 1
                            continue
                    else:

                        print("你的账户已经锁定")
                        time.sleep(1)
                        logger.error("%s登录锁定" % user_name)
                        dic1.clear()
                        dic1[user_name] = {
                            "pwd": dic_heihu[user_name]["pwd"],
                            "money": dic_heihu[user_name]["money"],
                            "xyk_y": dic_heihu[user_name]["xyk_y"],
                            "xyk": dic_heihu[user_name]["xyk"],
                            "xyk_time": dic_heihu[user_name]["xyk_time"],
                            "logging_time": time.time()
                        }
                        dic_heihu.update(dic1)

                        db_file_write.db_write(dic_heihu)
                else:
                    print("你的账户距离上次锁定小于300秒,请稍后再试")
                    time.sleep(1)
                    logger.error("%s登录之前就已锁定" % user_name)

        else:
            exit()