class Tom:
    def __init__(self):
        self.db = SimpleMysql(host='127.0.0.1',
                              charset='utf8',
                              db='nissan_group',
                              user='******',
                              passwd='dndcadmin88*..',
                              autocommit=True,
                              keep_alive=False)

    def reg_tid(self, string):
        string = string.strip()
        if not string or (string.isdigit() and len(string) > 16): return None
        found = re.findall(re.compile(r'\d{16}', re.IGNORECASE), string)
        return found and found[-1] or None

    def addAccountPageQuery(self, data):
        try:
            for d in data:
                if d == 'merchant_out_order_no' and data[d]:
                    data['tid'] = self.reg_tid(data[d])

            return self.db.insertOrUpdate(table='alipay_bill',
                                          data=data,
                                          keys=('iw_account_log_id'))
        except Exception as e:
            logging.error(e)
            return 0
Example #2
0
class Tom:
    def __init__(self):
        self.db = SimpleMysql(host='127.0.0.1', charset='utf8', db='nissan_group', user='******', passwd='dndcadmin88*..', autocommit=True, keep_alive=False)

    def reg_tid(self, string):
        string = string.strip()
        if not string or (string.isdigit() and len(string)>16): return None
        found = re.findall(re.compile(r'\d{16}', re.IGNORECASE), string)
        return found and found[-1] or None

    def addAccountPageQuery(self, data):
        try:
            for d in data:
                if d == 'merchant_out_order_no' and data[d]:
                    data['tid'] = self.reg_tid(data[d])

            return self.db.insertOrUpdate(table='alipay_bill', data=data, keys=('iw_account_log_id'))
        except Exception as e:
            logging.error(e)
            return 0