shop-back-end/sql/20251124_user_balance.sql

26 lines
1.5 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

CREATE TABLE `user_balance` (
`user_balance_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`corpid` varchar(50) NOT NULL COMMENT '企业微信id',
`openid` varchar(32) DEFAULT NULL COMMENT 'openid',
`ab98_user_id` bigint NOT NULL COMMENT '汇邦云用户ID',
`qy_user_id` bigint DEFAULT NULL COMMENT '企业用户id',
`balance` bigint NOT NULL DEFAULT 0 COMMENT '用户余额(单位:分)',
`use_balance` bigint NOT NULL DEFAULT 0 COMMENT '用户余额(单位:分)',
`balance_limit` bigint NOT NULL DEFAULT 0 COMMENT '用户余额(单位:分)',
`creator_id` bigint NULL DEFAULT 0 COMMENT '创建者ID',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater_id` bigint NULL DEFAULT 0 COMMENT '更新者ID',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '删除标志0存在 1删除',
PRIMARY KEY (`user_balance_id`),
KEY `idx_openid` (`openid`),
KEY `idx_ab98_user_id` (`ab98_user_id`),
KEY `idx_corpid` (`corpid`),
UNIQUE KEY `uk_corpid_user` (`corpid`, `ab98_user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户余额表';
-- 添加 deleted 字段的 ALTER 语句
ALTER TABLE `user_balance` ADD COLUMN `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '删除标志0存在 1删除';
ALTER TABLE `shop_order` ADD COLUMN `ab98_user_id` bigint DEFAULT NULL COMMENT '汇邦云用户ID' AFTER `name`;