- Guides
- /
Frequently Asked Questions FAQs
- /
- Join table Authing in the local user and your business data
¶ How To Join Authing User With Your Business Data?
Update Time: 2024-10-10 07:28:40
If you use Authing, your user information will be stored securely in a database on the Authing cloud, and you do not need to save an additional user information. You need to associate your business data with the Authing user locally, and associate it with the user ID (User ID) and business data. For example, there is an orders table (orders) in your business system, and its own table structure is as follows:
CREATE TABLE `order` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`order_no` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '订单编号',
`order_sn` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '交易号',
`supplier_id` int(11) NOT NULL COMMENT '商户编码',
`supplier_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '商户名称',
`order_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '订单状态 0未付款,1已付款,2已发货,3已签收,-1退货申请,-2退货中,-3已退货,-4取消交易',
`after_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '用户售后状态 0 未发起售后 1 申请售后 -1 售后已取消 2 处理中 200 处理完毕',
`product_count` int(11) NOT NULL DEFAULT '0' COMMENT '商品数量',
`product_amount_total` decimal(12,4) NOT NULL COMMENT '商品总价',
`order_amount_total` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT '实际付款金额',
`logistics_fee` decimal(12,4) NOT NULL COMMENT '运费金额',
`address_id` int(11) NOT NULL COMMENT '收货地址编码',
`pay_channel` tinyint(4) NOT NULL DEFAULT '0' COMMENT '支付渠道 0余额 1微信 2支付宝',
`out_trade_no` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '订单支付单号',
`escrow_trade_no` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '第三方支付流水号',
`pay_time` int(11) NOT NULL DEFAULT '0' COMMENT '付款时间',
`delivery_time` int(11) NOT NULL DEFAULT '0' COMMENT '发货时间',
`order_settlement_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '订单结算状态 0未结算 1已结算',
`order_settlement_time` int(11) NOT NULL DEFAULT '0' COMMENT '订单结算时间',
`is_package` enum('0','1') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '是否是套餐',
`is_integral` enum('0','1') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0' COMMENT '是否是积分产品',
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`deleted_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `order_order_sn_unique` (`order_sn`),
KEY `order_order_sn_member_id_order_status_out_trade_no_index` (`order_sn`,`member_id`,`order_status`,`out_trade_no`(191))
) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
You can create a field owner_id
indicates the ID of the owner of the order:
- The data type is varchar(32);
- The value it stores should be the ID of the Authing user;
ALTER TABLE orders ADD COLUMN `owner_id` varchar(32) NOT NULL COMMENT '订单所有者用户 ID',
If you need to fetch all orders of one user, you can use the following SQL
query:
SELECT * FROM orders WHERE owner_id = '6035120c3xxxxxe890e080db'