2
0

feat: 余额计费

This commit is contained in:
caiyuchao
2025-01-07 10:30:41 +08:00
parent e8a0ad3356
commit 9b902bfd84
20 changed files with 589 additions and 26 deletions

View File

@@ -29,19 +29,21 @@ CREATE TABLE `u_account` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户ID',
`balance` decimal(18, 4) NULL DEFAULT NULL COMMENT '余额',
`balance_used` decimal(18, 4) NULL DEFAULT NULL COMMENT '余额已使用',
`package_id` bigint(20) NULL DEFAULT NULL COMMENT '套餐ID',
`start_time` datetime NULL DEFAULT NULL COMMENT '开始时间',
`end_time` datetime NULL DEFAULT NULL COMMENT '结束时间',
`traffic` bigint(20) NULL DEFAULT NULL COMMENT '流量',
`traffic_used` bigint(20) NULL DEFAULT NULL COMMENT '流量已使用',
`duration` bigint(20) NULL DEFAULT NULL COMMENT '时长',
`duration_used` bigint(20) NULL DEFAULT NULL COMMENT '时长已使用',
`client_num` int(11) NULL DEFAULT NULL COMMENT '在线设备数',
`client_num_used` int(11) NULL DEFAULT NULL COMMENT '在线设备数已使用',
`expired_time` datetime NULL DEFAULT NULL COMMENT '失效时间',
`package_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '套餐名称',
`period_num` int(11) NULL DEFAULT NULL COMMENT '有效期数',
`period_type` tinyint(4) NULL DEFAULT NULL COMMENT '有效期类型',
`price` decimal(18, 4) NULL DEFAULT NULL COMMENT '价格',
`traffic` bigint(20) NULL DEFAULT NULL COMMENT '流量',
`duration` bigint(20) NULL DEFAULT NULL COMMENT '时长',
`client_num` int(11) NULL DEFAULT NULL COMMENT '在线设备数',
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
`rate_limit_enable` tinyint(1) NULL DEFAULT 0 COMMENT '带宽是否限制',
`traffic_enable` tinyint(1) NULL DEFAULT 0 COMMENT '流量是否限制',
@@ -92,22 +94,37 @@ CREATE TABLE `u_balance` (
-- ----------------------------
DROP TABLE IF EXISTS `u_bill`;
CREATE TABLE `u_bill` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Bill ID',
`user_id` bigint(20) NULL DEFAULT NULL COMMENT 'User ID link to u_user',
`fee` double NULL DEFAULT NULL,
`billing_begin` datetime NULL DEFAULT NULL,
`billing_end` datetime NULL DEFAULT NULL,
`status` enum('unpaid','paid') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT 'unpaid',
`create_by` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT 'create name ',
`create_time` datetime NULL DEFAULT NULL COMMENT 'create time',
PRIMARY KEY (`id`) USING BTREE,
INDEX `fk_user_id`(`user_id`) USING BTREE,
CONSTRAINT `u_bill_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `u_user` (`user_id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户平台_用户信息表' ROW_FORMAT = DYNAMIC;
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户ID',
`cdr_history_id` bigint(20) NULL DEFAULT NULL COMMENT '话单记录ID',
`type` tinyint(4) NULL DEFAULT NULL COMMENT '类型',
`amount` decimal(18, 4) NULL DEFAULT NULL COMMENT '金额',
`status` tinyint(4) NULL DEFAULT NULL COMMENT '状态',
`del_flag` tinyint(1) NULL DEFAULT 0 COMMENT '删除标志0存在 1删除',
`create_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1876451063420497923 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户平台-账单表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of u_bill
-- Table structure for u_bill_rule
-- ----------------------------
DROP TABLE IF EXISTS `u_bill_rule`;
CREATE TABLE `u_bill_rule` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`price` decimal(18, 4) NULL DEFAULT NULL COMMENT '价格',
`traffic` bigint(20) NULL DEFAULT NULL COMMENT '流量',
`unit` tinyint(4) NULL DEFAULT NULL COMMENT '单位',
`enable` tinyint(1) NULL DEFAULT NULL COMMENT '是否启用',
`del_flag` tinyint(1) NULL DEFAULT 0 COMMENT '删除标志0存在 1删除',
`create_by` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
`update_by` bigint(20) NULL DEFAULT NULL COMMENT '更新人',
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户平台-计费规则表' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for u_cdr