예제 #1
0
    def card_pay(self, cost, paytype, sereialno):
        """
        信用卡支付,从信用卡可透支余额中扣费
        :param sereialno: 流水号
        :param cost: 消费金额 float类型
        :param paytype: 消费类型 int类型  ( 1:消费、2:转账、3:提现、4:手续费 ) 对于2,3类型的支付要扣手续费,单记录一条流水单
        :return:
        """
        if paytype == 1:
            payfor = "消费"
        elif paytype == 2:
            payfor = "转账"
        elif paytype == 3:
            payfor = "提现"
        elif paytype == 4:
            payfor = "手续费"
        else:
            payfor = "未知"

        # 支付扣款
        self.credit_balance -= cost

        # 记录消费流水对账单,将发生了费用还没有还款的账单信息写入文件 report_bill 中
        _tmp_bill_record = dict(cardno="{0}".format(self.cardno),
                                starttime=datetime.strftime(
                                    datetime.now(), "%Y-%m-%d %H:%M"),
                                payfor=payfor,
                                cost=cost,
                                serialno=sereialno)
        dbapi.append_db_json(_tmp_bill_record,
                             os.path.join(settings.REPORT_PATH, "report_bill"))

        # 更新信用卡可透支余额信息到数据库 creditcard.db
        self.credit_card[self.cardno]["credit_balance"] = self.credit_balance
        dbapi.write_db_json(self.credit_card, self.__database)
예제 #2
0
    def card_pay(self, cost, paytype, sereialno):
        """
        信用卡支付,从信用卡可透支余额中扣费
        :param sereialno: 流水号
        :param cost: 消费金额 float类型
        :param paytype: 消费类型 int类型  ( 1:消费、2:转账、3:提现、4:手续费 ) 对于2,3类型的支付要扣手续费,单记录一条流水单
        :return:
        """
        if paytype == 1:
            payfor = "消费"
        elif paytype == 2:
            payfor = "转账"
        elif paytype == 3:
            payfor = "提现"
        elif paytype == 4:
            payfor = "手续费"
        else:
            payfor = "未知"

        # 支付扣款
        self.credit_balance -= cost

        # 记录消费流水对账单,将发生了费用还没有还款的账单信息写入文件 report_bill 中
        _tmp_bill_record = dict(cardno="{0}".format(self.cardno),
                                starttime=datetime.strftime(datetime.now(), "%Y-%m-%d %H:%M"),
                                payfor=payfor,
                                cost=cost,
                                serialno=sereialno)
        dbapi.append_db_json(_tmp_bill_record, os.path.join(settings.REPORT_PATH, "report_bill"))

        # 更新信用卡可透支余额信息到数据库 creditcard.db
        self.credit_card[self.cardno]["credit_balance"] = self.credit_balance
        dbapi.write_db_json(self.credit_card, self.__database)
예제 #3
0
 def updata_user(self):
     '''用户数据更新'''
     try:
         dbapi.write_db_json(self.dict_user,self._database)
         return True
     except Exception as e:
         common.write_log("用户登录页面更新用户数据:{0}".format(e))
         return False
예제 #4
0
 def update_card(self):
     password = common.encrypt(self.password)
     self.credit_card[self.cardno]["password"] = password
     self.credit_card[self.cardno]["owner"] = self.owner
     self.credit_card[self.cardno]["credit_total"] = self.credit_total
     self.credit_card[self.cardno]["credit_balance"] = self.credit_balance
     self.credit_card[self.cardno]["frozenstatus"] = self.frozenstatus
     # 写入数据库
     dbapi.write_db_json(self.credit_card, self.__database)
예제 #5
0
 def update_card(self):
     password = common.encrypt(self.password)
     self.credit_card[self.cardno]["password"] = password
     self.credit_card[self.cardno]["owner"] = self.owner
     self.credit_card[self.cardno]["credit_total"] = self.credit_total
     self.credit_card[self.cardno]["credit_balance"] = self.credit_balance
     self.credit_card[self.cardno]["frozenstatus"] = self.frozenstatus
     # 写入数据库
     dbapi.write_db_json(self.credit_card, self.__database)
예제 #6
0
 def create_card(self):
     """
     新发行一张行用卡
     :return:
     """
     password = common.encrypt(self.password)
     self.credit_card[self.cardno] = dict(password=password,
                                          credit_total=self.credit_total,
                                          credit_balance=self.credit_balance,
                                          owner=self.owner,
                                          frozenstatus=self.frozenstatus)
     # 保存到数据库
     dbapi.write_db_json(self.credit_card, self.__database)
예제 #7
0
파일: users.py 프로젝트: 0chk0/python
 def create_user(self):
     """
     新创建一个用户,将用户数据同步写入到数据库文件
     :return:
     """
     self.dict_user[self.username] = dict(password=common.encrypt(self.password),
                                          name=self.name,
                                          mobile=self.mobile,
                                          bindcard=self.bindcard,
                                          role=self.role,
                                          islocked=0,
                                          isdel=0,
                                          )
     dbapi.write_db_json(self.dict_user, self.__database)
예제 #8
0
 def create_user(self):
     """
     新创建一个用户,将用户数据同步写入到数据库文件
     :return:
     """
     self.dict_user[self.username] = dict(password=common.encrypt(self.password),
                                          name=self.name,
                                          mobile=self.mobile,
                                          bindcard=self.bindcard,
                                          role=self.role,
                                          islocked=0,
                                          isdel=0,
                                          )
     dbapi.write_db_json(self.dict_user, self.__database)
예제 #9
0
 def create_card(self):
     """
     新发行一张行用卡
     :return:
     """
     password = common.encrypt(self.password)
     self.credit_card[self.cardno] = dict(
         password=password,
         credit_total=self.credit_total,
         credit_balance=self.credit_balance,
         owner=self.owner,
         frozenstatus=self.frozenstatus)
     # 保存到数据库
     dbapi.write_db_json(self.credit_card, self.__database)
예제 #10
0
파일: users.py 프로젝트: 0chk0/python
 def update_user(self):
     """
     用户数据更新方法,用户修改信息、用户账户锁定、解锁等操作之后更新数据库文件
     :return:
     """
     try:
         '''
         _password = common.encrypt(self.password)
         self.dict_user[self.username]["password"] = _password
         self.dict_user[self.username]["islocked"] = self.islocked
         self.dict_user[self.username]["name"] = self.name
         self.dict_user[self.username]["mobile"] = self.mobile
         self.dict_user[self.username]["bindcard"] = self.bindcard
         self.dict_user[self.username]["isdel"] = self.isdel
         self.dict_user[self.username]["role"] = self.role
         '''
         # 写入数据库文件
         dbapi.write_db_json(self.dict_user, self.__database)
         return True
     except Exception as e:
         common.write_error_log(e)
         return False
예제 #11
0
 def update_user(self):
     """
     用户数据更新方法,用户修改信息、用户账户锁定、解锁等操作之后更新数据库文件
     :return:
     """
     try:
         '''
         _password = common.encrypt(self.password)
         self.dict_user[self.username]["password"] = _password
         self.dict_user[self.username]["islocked"] = self.islocked
         self.dict_user[self.username]["name"] = self.name
         self.dict_user[self.username]["mobile"] = self.mobile
         self.dict_user[self.username]["bindcard"] = self.bindcard
         self.dict_user[self.username]["isdel"] = self.isdel
         self.dict_user[self.username]["role"] = self.role
         '''
         # 写入数据库文件
         dbapi.write_db_json(self.dict_user, self.__database)
         return True
     except Exception as e:
         common.write_log(e)
         return False
예제 #12
0
 def write_user_update_password(self,content):
     '''重置用户密码,更新到用户表'''
     dbapi.write_db_json(content,self._database)
예제 #13
0
 def write_clear_user_token(self,content):
     '''登录成功后保存token到本地,退出成功后清除本地token'''
     dbapi.write_db_json(content,self._database_1)