class BankCardInfo(BaseModel, TimeColumnMixin): __tablename__ = "bankcard_info" id = orm.Column(orm.Integer, primary_key=True) accountid = orm.Column(orm.Integer) bank_name = orm.Column(orm.String(128)) # 银行名 subbank_name = orm.Column(orm.String(128)) # 分行名 card_name = orm.Column(orm.String(32)) # 开户人 card_number = orm.Column(orm.String(32)) # 银行卡号 card_type = orm.Column(orm.SMALLINT) is_deleted = orm.Column(orm.SMALLINT) extend = orm.Column(orm.TEXT)
class PollingCustID(BaseModel): """ 用于扫码付轮询 """ __tablename__ = 'polling_custid' id = orm.Column(orm.Integer, primary_key=True) appid = orm.Column(orm.Integer) custid = orm.Column(orm.String(30)) pay_type = orm.Column(orm.Integer) real_pay = orm.Column(orm.Integer) valid = orm.Column(orm.Integer) banklinknumber = orm.Column(orm.String(30)) paymenttype = orm.Column(orm.String(30)) mch_name = orm.Column(orm.String(30)) father_mch_name = orm.Column(orm.String(30)) service_rate = orm.Column(orm.Integer)
class Account(UserMixin, BaseModel): __tablename__ = 'accounts' id = orm.Column(orm.Integer, primary_key=True) phone = orm.Column(orm.String(24), unique=True, index=True) passwd_hash = orm.Column(orm.String(128)) name = orm.Column(orm.String(30)) balance = orm.Column(orm.Float) # 服务费 Decimal(10, 5) def __init__(self): self.added_IDS = [] @property def password(self): raise AttributeError('password is not readale') @password.setter def password(self, password): self.passwd_hash = bcrypt.generate_password_hash(password) def verify_passwd(self, passwd): return bcrypt.check_password_hash(self.passwd_hash, passwd)
class JinjianRecord(BaseModel, TimeColumnMixin): __tablename__ = 'jinjian_record' id = orm.Column(orm.BigInteger, primary_key=True) accountid = orm.Column(orm.Integer) real_pay = orm.Column(orm.Integer) jinjian_data = orm.Column(orm.TEXT) resp_data = orm.Column(orm.TEXT) appmanageid = orm.Column(orm.Integer) status = orm.Column(orm.Integer, default=0) mch_name = orm.Column(orm.String(30)) custid = orm.Column(orm.String(30)) banklinknumber = orm.Column(orm.String(30)) # 客达用 paymenttype = orm.Column(orm.String(30)) # D0, D1, T1 @property def jinjian_info(self): return json.loads(self.jinjian_data) @jinjian_info.setter def jinjian_info(self, info_dct): self.jinjian_data = json.dumps(info_dct)
class Appid(BaseModel, TimeColumnMixin): __tablename__ = "account_appid" id = orm.Column(orm.Integer, primary_key=True) accountid = orm.Column(orm.Integer) appid = orm.Column(orm.String(30)) appkey = orm.Column(orm.String(30)) custid = orm.Column(orm.String(30)) pay_type = orm.Column(orm.Integer) real_pay = orm.Column(orm.Integer) valid = orm.Column(orm.Boolean) sceneInfo = orm.Column(orm.TEXT) # H5支付需要 extend = orm.Column(orm.TEXT) fee_rate = orm.Column(orm.Integer) # 手续费,万分率,60表示 千分之6 banklinknumber = orm.Column(orm.String(30)) # 浦发或招行的银行卡,客达用 paymenttype = orm.Column(orm.String(30)) # 客达用, D0或D1 mch_name = orm.Column(orm.String(30)) polling = orm.Column(orm.Boolean, default=False) # 是否为轮询appid service_rate = orm.Column(orm.Integer) # 服务费,万分率 recharge_total = orm.Column(orm.Float, default=0) # 充值总额 Decimal(20, 5) withdraw_total = orm.Column(orm.Float, default=0) # 提现总额 Decimal(20, 5) fee_total = orm.Column(orm.Float, default=0) # 实时更新每笔充值的手续费 daifu_total = orm.Column(orm.Float, default=0) # 代付总额 Decimal(20, 5) service_fee_total = orm.Column(orm.Float, default=0) # 服务费总额 Decmal(20, 5) def get_balance(self): return float(self.recharge_total - self.withdraw_total - self.fee_total - self.service_fee_total - self.daifu_total)
class AppManage(BaseModel, TimeColumnMixin): __tablename__ = "appid_manage" id = orm.Column(orm.Integer, primary_key=True) accountid = orm.Column(orm.Integer) appid = orm.Column(orm.String(30)) appname = orm.Column(orm.String(60)) app_type = orm.Column(orm.Integer) pay_type = orm.Column(orm.String(30)) valid = orm.Column(orm.SMALLINT) paymenttype = orm.Column(orm.String(30)) mch_name = orm.Column(orm.String(30)) mch_short_name = orm.Column(orm.String(30)) mch_number = orm.Column(orm.BigInteger) # 商户编号 balance_type = orm.Column(orm.Integer) # 结算方式,1-对公,2-对私 balance_name = orm.Column(orm.String(30)) # 结算户名 userid_card = orm.Column(orm.BigInteger) # 提现人身份证 bank_city = orm.Column(orm.String(30)) # 开户城市 bank_name = orm.Column(orm.String(30)) # 银行名 card_number = orm.Column(orm.BigInteger) # 结算银行卡号码 card_name = orm.Column(orm.String(30)) # 支付联行号银行名 bank_no = orm.Column(orm.BigInteger) # 支行联行号 industry_no = orm.Column(orm.BigInteger) # 行业编号 extend = orm.Column(orm.TEXT)
class WithdrawRecord(BaseModel, TimeColumnMixin): __tablename__ = 'withdraw_record' id = orm.Column(orm.BigInteger, primary_key=True) mchid = orm.Column(orm.Integer, default=None, nullable=True) # 商户号 appid = orm.Column(orm.String(30)) withdraw_type = orm.Column(orm.Integer) order_code = orm.Column(orm.String(30)) amount = orm.Column(orm.Float) # 提现金额 fee = orm.Column(orm.Float) # 手续费 status = orm.Column(orm.Integer) real_pay = orm.Column(orm.Integer) channel = orm.Column(orm.String(30)) to_account = orm.Column(orm.String(30)) bank_name = orm.Column(orm.String(30)) acc_name = orm.Column(orm.String(30)) trans_time = orm.Column(orm.String(30)) # 杉德代付商户上送时间 extend = orm.Column(orm.TEXT)
class PayRecord(BaseModel, TimeColumnMixin): __tablename__ = 'pay_record' id = orm.Column(orm.BigInteger, primary_key=True) orderid = orm.Column(orm.String(60)) # 订单号(商户传来的订单号) mchid = orm.Column(orm.Integer, default=None, nullable=True) # 商户号 appid = orm.Column(orm.String(30)) # 给商户分配的appid originid = orm.Column(orm.String(30)) # 上游订单号 pay_type = orm.Column(orm.Integer) pay_status = orm.Column(orm.Integer) notify_status = orm.Column(orm.Integer, default=NOTIFY_STATUS.READY) # 回调下游商户的状态 amount = orm.Column(orm.Float) description = orm.Column(orm.String(100)) notify_url = orm.Column(orm.String(200), default=None, nullable=True) fee = orm.Column(orm.Float, default=0) # 手续费, Decimal(10, 5) extend = orm.Column(orm.TEXT) real_pay = orm.Column(orm.Integer) real_custid = orm.Column(orm.String(30)) # 轮询时标记真实custid pay_time = orm.Column(orm.DateTime, default=None) # 支付时间-收到上游回调的时间 service_fee = orm.Column(orm.Float)
class DaifuRecord(BaseModel, TimeColumnMixin): __tablename__ = 'daifu_record' id = orm.Column(orm.BigInteger, primary_key=True) mchid = orm.Column(orm.Integer, default=None, nullable=True) # 商户号 daifu_type = orm.Column(orm.Integer) amount = orm.Column(orm.Float) # 提现金额 fee = orm.Column(orm.Float) # 手续费 status = orm.Column(orm.Integer) bank_name = orm.Column(orm.String(30)) bank_city = orm.Column(orm.String(30)) bank_account_name = orm.Column(orm.String(30)) bank_account_no = orm.Column(orm.String(30)) bank = orm.Column(orm.String(30)) bank_province = orm.Column(orm.String(30)) card_type = orm.Column(orm.Integer) extend = orm.Column(orm.TEXT) def as_dict(self): return { column.name: getattr(self, column.name) for column in self.__table__.columns }
class AppidChannel(BaseModel): __tablename__ = 'appid_channel' id = orm.Column(orm.Integer, primary_key=True) appid = orm.Column(orm.String(30)) real_pay = orm.Column(orm.Integer)
class JinjianAppid(BaseModel): __tablename__ = 'jinjian_appid' accountid = orm.Column(orm.Integer) appid = orm.Column(orm.String(30), primary_key=True) # 主键自增 appkey = orm.Column(orm.String(30))
class Bill(BaseModel): __tablename__ = 'bills' id = orm.Column(orm.Integer, primary_key=True) access_number = orm.Column(orm.String(32)) pay_type = orm.Column(orm.String(8)) trade_type = orm.Column(orm.String(1)) access_seq = orm.Column(orm.String(32)) access_submit_date = orm.Column(orm.DateTime) ## yyyyMMdd trade_amount = orm.Column(orm.String(32)) poundage = orm.Column(orm.String(32)) currency_type = orm.Column(orm.String(8)) channel_number = orm.Column(orm.String(32)) card_code = orm.Column(orm.String(32)) account = orm.Column(orm.String(32)) protocol = orm.Column(orm.String(32)) platform_seq = orm.Column(orm.String(32)) platform_trade_date = orm.Column(orm.DateTime) trade_status = orm.Column(orm.String(1)) bank_merchant_number = orm.Column(orm.String(32)) channel_flag = orm.Column(orm.String(32)) exchange_rate = orm.Column(orm.String(8)) settling_amount = orm.Column(orm.String(32)) settling_currency_type = orm.Column(orm.String(8)) account_id = orm.Column(orm.Integer, orm.ForeignKey('accounts.id')) def fill(self, array): self.access_number = array[0] self.pay_type = array[1] self.trade_type = array[2] self.access_seq = array[3] self.access_submit_date = datetime.strptime(array[14] + array[15], '%Y%m%d%H%M%S') self.trade_amount = array[6] self.poundage = array[7] self.currency_type = array[8] self.channel_number = array[9] self.card_code = array[10] self.account = array[11] self.protocol = array[12] self.platform_seq = array[13] self.platform_trade_date = datetime.strptime(array[14] + array[15], '%Y%m%d%H%M%S') self.trade_status = array[16] self.bank_merchant_number = array[17] self.channel_flag = array[18] self.exchange_rate = array[19] self.settling_amount = array[20] self.settling_currency_type = array[21] def to_dict(self): data = {c.name: getattr(self, c.name) for c in self.__table__.columns} data['access_submit_date'] = datetime.strftime( data['access_submit_date'], '%Y-%m-%d %H:%M:%S') data['platform_trade_date'] = datetime.strftime( data['platform_trade_date'], '%Y-%m-%d %H:%M:%S') return data def __repr__(self): return "Bill:\n%s" % json.dumps( self.to_dict(), indent=2, ensure_ascii=False)