### 交易订单记录表 `payment_order` > merchant_id 关联 [merchant.id](./merchant_struct.md) > > trade_no: 由平台生成的交易单号 > > from_account_no :转出账户,关联银行机构的帐户号 [merchant_account_sys.account_num](./merchant_account_sys.md) > > from_account_id :转出账户id, [merchant_account_sys.id](./merchant_account_sys.md) > > to_account_id :转入账户,关联银行机构的帐户号 [merchant_account_sys.account_num](./merchant_account_sys.md) > > to_account_no :转入账户,关联银行机构的帐户号 [merchant_account_sys.id](./merchant_account_sys.md) > > channel_id: 交易渠道的id: 关联[channel.id](./channel.md) > > exchange_rate : 交易时的汇率 > > from_currency_id :交易来自货币,关联[currency.id](./currency.md) > > to_currency_id :交易的目标货币,关联[currency.id](./currency.md) > > trade_org_id: 交易机构的id',关联[bank.id](./currency.md) > >trade_org_code: 交易机构账户,关联[bank.id](./currency.md) ```mysql CREATE TABLE `payment_order` ( `id` int NOT NULL AUTO_INCREMENT, `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', `deleted_at` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', `merchant_id` int NOT NULL DEFAULT '0' COMMENT '商户ID', `trade_no` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '平台生成的交易单号', `from_account_no` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '来自银行的账户编号', `from_account_id` int DEFAULT '0' COMMENT '来自账户的id', `to_account_id` int DEFAULT '0' COMMENT '转到账户的id', `to_account_no` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '转到银行的账户编号', `channel_id` int DEFAULT NULL COMMENT '交易渠道id', `exchange_rate` decimal(10,10) DEFAULT NULL COMMENT '汇率', `amount` decimal(10,2) NOT NULL COMMENT '交易的金额', `from_currency_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '来自币种', `to_currency_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '目标币种', `transfer_type` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '交易类型(汇兑、结汇、充值)', `transfer_state` tinyint(1) NOT NULL DEFAULT '0' COMMENT '交易状态', `remark` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '备注', `loan_mark` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '借贷标识', `trade_org_id` varchar(64) DEFAULT NULL COMMENT '交易机构的id', `trade_org_code` varchar(64) DEFAULT NULL COMMENT '交易机构代码', `org_trade_no` varchar(64) DEFAULT NULL COMMENT '交易机构的交易单号', `state` tinyint DEFAULT NULL COMMENT '交易状态', PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 ROW_FORMAT=DYNAMIC COMMENT='商户外部账户余额明细记录'; ```