/*
 Navicat Premium Data Transfer

 Source Server         : pgSQL
 Source Server Type    : PostgreSQL
 Source Server Version : 130000
 Source Host           : localhost:5432
 Source Catalog        : web_manage
 Source Schema         : public

 Target Server Type    : PostgreSQL
 Target Server Version : 130000
 File Encoding         : 65001

 Date: 28/08/2025 08:22:54
*/


-- ----------------------------
-- Table structure for tb_cart
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_cart";
CREATE TABLE "public"."tb_cart" (
  "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 25
),
  "user_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "unit_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "pricing_id" int8 NOT NULL,
  "product_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "product_name" text COLLATE "pg_catalog"."default",
  "suite_name" text COLLATE "pg_catalog"."default",
  "sales_form" text COLLATE "pg_catalog"."default",
  "customer_type" text COLLATE "pg_catalog"."default",
  "account_limit" text COLLATE "pg_catalog"."default",
  "concurrent_nodes" text COLLATE "pg_catalog"."default",
  "price_type" text COLLATE "pg_catalog"."default",
  "price_unit" text COLLATE "pg_catalog"."default",
  "unit_price" numeric(15,2) NOT NULL,
  "quantity" int4 NOT NULL DEFAULT 1,
  "duration" int4,
  "total_price" numeric(15,2),
  "provider_id" int8,
  "provider_name" text COLLATE "pg_catalog"."default",
  "remarks" text COLLATE "pg_catalog"."default",
  "add_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "update_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "deleted" int4 DEFAULT 0
)
;
COMMENT ON TABLE "public"."tb_cart" IS '购物车表';

-- ----------------------------
-- Records of tb_cart
-- ----------------------------
INSERT INTO "public"."tb_cart" OVERRIDING SYSTEM VALUE VALUES (24, '1', '1', 1, '7439040f-cf34-4e8a-a3da-0b7990f79e4d', '钢筋数字化生产加工', '基础版', '买断', '企业', '不限', '不限', '积分', '套', 1000.00, 2, 1, 2000.00, NULL, NULL, NULL, '2025-08-27 18:45:19', '2025-08-27 18:47:01.852', 0);

-- ----------------------------
-- Table structure for tb_order_approval
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_order_approval";
CREATE TABLE "public"."tb_order_approval" (
  "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
),
  "order_id" text COLLATE "pg_catalog"."default" NOT NULL,
  "approval_step" text COLLATE "pg_catalog"."default" NOT NULL,
  "approval_type" text COLLATE "pg_catalog"."default" NOT NULL,
  "approval_opinion" text COLLATE "pg_catalog"."default",
  "approval_result" text COLLATE "pg_catalog"."default" NOT NULL,
  "approver_id" int8 NOT NULL,
  "approver_name" text COLLATE "pg_catalog"."default" NOT NULL,
  "approver_role" text COLLATE "pg_catalog"."default",
  "approval_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "next_approver_id" int8,
  "next_approver_name" text COLLATE "pg_catalog"."default",
  "workflow_status" text COLLATE "pg_catalog"."default",
  "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "deleted" int4 DEFAULT 0
)
;
COMMENT ON TABLE "public"."tb_order_approval" IS '订单审核表';

-- ----------------------------
-- Records of tb_order_approval
-- ----------------------------

-- ----------------------------
-- Table structure for tb_order_attachment
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_order_attachment";
CREATE TABLE "public"."tb_order_attachment" (
  "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
),
  "order_id" text COLLATE "pg_catalog"."default" NOT NULL,
  "file_name" text COLLATE "pg_catalog"."default" NOT NULL,
  "original_name" text COLLATE "pg_catalog"."default",
  "file_type" text COLLATE "pg_catalog"."default" NOT NULL,
  "file_size" int8 NOT NULL,
  "file_url" text COLLATE "pg_catalog"."default" NOT NULL,
  "file_path" text COLLATE "pg_catalog"."default",
  "bucket_name" text COLLATE "pg_catalog"."default",
  "object_name" text COLLATE "pg_catalog"."default",
  "upload_user_id" int8,
  "upload_user_name" text COLLATE "pg_catalog"."default",
  "attachment_type" text COLLATE "pg_catalog"."default",
  "description" text COLLATE "pg_catalog"."default",
  "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "deleted" int4 DEFAULT 0
)
;
COMMENT ON TABLE "public"."tb_order_attachment" IS '订单附件表';

-- ----------------------------
-- Records of tb_order_attachment
-- ----------------------------

-- ----------------------------
-- Table structure for tb_order_detail
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_order_detail";
CREATE TABLE "public"."tb_order_detail" (
  "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 16
),
  "order_id" text COLLATE "pg_catalog"."default" NOT NULL,
  "pricing_id" int8 NOT NULL,
  "product_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "suite_name" text COLLATE "pg_catalog"."default" NOT NULL,
  "sales_form" text COLLATE "pg_catalog"."default" NOT NULL,
  "customer_type" text COLLATE "pg_catalog"."default" NOT NULL,
  "account_limit" text COLLATE "pg_catalog"."default",
  "concurrent_nodes" text COLLATE "pg_catalog"."default",
  "price_type" text COLLATE "pg_catalog"."default" NOT NULL,
  "price_unit" text COLLATE "pg_catalog"."default" NOT NULL,
  "unit_price" numeric(15,2) NOT NULL,
  "quantity" int4 NOT NULL,
  "duration" int4,
  "total_price" numeric(15,2) NOT NULL,
  "provider_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "provider_name" text COLLATE "pg_catalog"."default",
  "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "remarks" text COLLATE "pg_catalog"."default",
  "deleted" int4 DEFAULT 0
)
;
COMMENT ON TABLE "public"."tb_order_detail" IS '订单详情表';

-- ----------------------------
-- Records of tb_order_detail
-- ----------------------------
INSERT INTO "public"."tb_order_detail" OVERRIDING SYSTEM VALUE VALUES (1, '202508191718590806528000', 5, '1', '企业私有SaaS版许可', '私有增量包', '个人', '2', '3', '积分', '套/年', 200.00, 1, 1, 200.00, '3', '中交建筑集团第一工程有限公司', '2025-08-19 17:18:59.649', '2025-08-19 17:18:59.649', '', 0);
INSERT INTO "public"."tb_order_detail" OVERRIDING SYSTEM VALUE VALUES (2, '202508191718590806528000', 4, '1', '企业私有SaaS版许可', '租赁', '个人', '1', '1', '积分', '套/年', 200.00, 1, 1, 200.00, '3', '中交建筑集团第一工程有限公司', '2025-08-19 17:18:59.66', '2025-08-19 17:18:59.66', '', 0);
INSERT INTO "public"."tb_order_detail" OVERRIDING SYSTEM VALUE VALUES (3, '202508191718590806528000', 9, '1', '企业私有SaaS版用户增量包', '私有增量包', '项目部', '1', '1', '免费', '年', 0.00, 1, 1, 0.00, '3', '中交建筑集团第一工程有限公司', '2025-08-19 17:18:59.664', '2025-08-19 17:18:59.664', '', 0);
INSERT INTO "public"."tb_order_detail" OVERRIDING SYSTEM VALUE VALUES (4, '202508191730018270442496', 2, '1', '专业版', '租赁', '企业', '不限', '不限', '积分', '套/年', 500.00, 1, 1, 500.00, '3', '中交建筑集团第一工程有限公司', '2025-08-19 17:30:01.814', '2025-08-19 17:30:01.814', '', 0);
INSERT INTO "public"."tb_order_detail" OVERRIDING SYSTEM VALUE VALUES (5, '202508191732232175500288', 1, '1', '基础版', '买断', '企业', '不限', '不限', '积分', '套', 1000.00, 1, 1, 1000.00, '3', '中交建筑集团第一工程有限公司', '2025-08-19 17:32:23.412', '2025-08-19 17:32:23.412', '', 0);
INSERT INTO "public"."tb_order_detail" OVERRIDING SYSTEM VALUE VALUES (6, '202508191735337897883648', 9, '1', '企业私有SaaS版用户增量包', '私有增量包', '项目部', '1', '1', '免费', '年', 0.00, 1, 1, 0.00, '3', '中交建筑集团第一工程有限公司', '2025-08-19 17:35:33.127', '2025-08-19 17:35:33.127', '', 0);
INSERT INTO "public"."tb_order_detail" OVERRIDING SYSTEM VALUE VALUES (7, '202508191745527049352192', 5, '1', '企业私有SaaS版许可', '私有增量包', '个人', '2', '3', '积分', '套/年', 200.00, 1, 1, 200.00, '3', '中交建筑集团第一工程有限公司', '2025-08-19 17:45:52.815', '2025-08-19 17:45:52.815', '', 0);
INSERT INTO "public"."tb_order_detail" OVERRIDING SYSTEM VALUE VALUES (8, '202508191752392071676928', 9, '1', '企业私有SaaS版用户增量包', '私有增量包', '项目部', '1', '1', '免费', '年', 0.00, 1, 1, 0.00, '3', '中交建筑集团第一工程有限公司', '2025-08-19 17:52:39.325', '2025-08-19 17:52:39.325', '', 0);
INSERT INTO "public"."tb_order_detail" OVERRIDING SYSTEM VALUE VALUES (9, '202508191809061614843904', 4, '1', '企业私有SaaS版许可', '租赁', '个人', '1', '1', '积分', '套/年', 200.00, 1, 1, 200.00, '3', '中交建筑集团第一工程有限公司', '2025-08-19 18:09:06.269', '2025-08-19 18:09:06.269', '', 0);
INSERT INTO "public"."tb_order_detail" OVERRIDING SYSTEM VALUE VALUES (10, '202508191809061614843904', 9, '1', '企业私有SaaS版用户增量包', '私有增量包', '项目部', '1', '1', '免费', '年', 0.00, 1, 1, 0.00, '3', '中交建筑集团第一工程有限公司', '2025-08-19 18:09:06.275', '2025-08-19 18:09:06.275', '', 0);
INSERT INTO "public"."tb_order_detail" OVERRIDING SYSTEM VALUE VALUES (11, '202508221423519599931392', 4, '1', '企业私有SaaS版许可', '租赁', '个人', '1', '1', '积分', '套/年', 200.00, 1, 1, 200.00, '3', '中交建筑集团第一工程有限公司', '2025-08-22 14:23:51.376', '2025-08-22 14:23:51.376', '', 0);
INSERT INTO "public"."tb_order_detail" OVERRIDING SYSTEM VALUE VALUES (12, '202508221423519599931392', 10, '1', '企业私有SaaS版许可', '租赁', '个人', '1', '2', '积分', '套/年', 100.00, 1, 1, 100.00, '3', '中交建筑集团第一工程有限公司', '2025-08-22 14:23:51.385', '2025-08-22 14:23:51.386', '', 0);
INSERT INTO "public"."tb_order_detail" OVERRIDING SYSTEM VALUE VALUES (13, '202508261002538948777984', 2, '1', '专业版', '租赁', '企业', '不限', '不限', '积分', '套/年', 500.00, 1, 1, 500.00, '3', '中交建筑集团第一工程有限公司', '2025-08-26 10:02:53.913', '2025-08-26 10:02:53.913', '', 0);
INSERT INTO "public"."tb_order_detail" OVERRIDING SYSTEM VALUE VALUES (14, '202508272131080287679488', 10, '7439040f-cf34-4e8a-a3da-0b7990f79e4d', '企业私有SaaS版许可', '租赁', '个人', '1', '2', '积分', '套/年', 100.00, 2, 1, 200.00, '1', '中交第二航务工程局有限公司', '2025-08-27 21:31:09.024', '2025-08-27 21:31:09.024', '', 0);
INSERT INTO "public"."tb_order_detail" OVERRIDING SYSTEM VALUE VALUES (15, '202508272131080287679488', 4, '7439040f-cf34-4e8a-a3da-0b7990f79e4d', '企业私有SaaS版许可', '租赁', '个人', '1', '1', '积分', '套/年', 200.00, 2, 1, 400.00, '1', '中交第二航务工程局有限公司', '2025-08-27 21:31:09.295', '2025-08-27 21:31:09.295', '', 0);

-- ----------------------------
-- Table structure for tb_order_evaluation
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_order_evaluation";
CREATE TABLE "public"."tb_order_evaluation" (
  "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
),
  "order_id" text COLLATE "pg_catalog"."default" NOT NULL,
  "evaluator_id" int8 NOT NULL,
  "evaluator_name" text COLLATE "pg_catalog"."default" NOT NULL,
  "evaluator_type" text COLLATE "pg_catalog"."default" NOT NULL,
  "content" text COLLATE "pg_catalog"."default" NOT NULL,
  "rating" int4 NOT NULL,
  "service_rating" int4,
  "quality_rating" int4,
  "delivery_rating" int4,
  "is_anonymous" bool DEFAULT false,
  "reply_content" text COLLATE "pg_catalog"."default",
  "reply_user_id" int8,
  "reply_time" timestamp(6),
  "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "deleted" int4 DEFAULT 0
)
;
COMMENT ON TABLE "public"."tb_order_evaluation" IS '订单评价表';

-- ----------------------------
-- Records of tb_order_evaluation
-- ----------------------------

-- ----------------------------
-- Table structure for tb_order_info
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_order_info";
CREATE TABLE "public"."tb_order_info" (
  "order_id" text COLLATE "pg_catalog"."default" NOT NULL,
  "product_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "user_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "unit_id" varchar(64) COLLATE "pg_catalog"."default",
  "product_name" text COLLATE "pg_catalog"."default" NOT NULL,
  "provider_name" text COLLATE "pg_catalog"."default" NOT NULL,
  "provider_id" varchar(64) COLLATE "pg_catalog"."default",
  "apply_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "order_status" text COLLATE "pg_catalog"."default" NOT NULL DEFAULT '待审批'::text,
  "total_amount" numeric(15,2) NOT NULL,
  "payment_type" text COLLATE "pg_catalog"."default",
  "payment_status" text COLLATE "pg_catalog"."default" DEFAULT '未支付'::text,
  "workflow_id" text COLLATE "pg_catalog"."default",
  "current_step" text COLLATE "pg_catalog"."default",
  "approval_flow" text COLLATE "pg_catalog"."default",
  "buyer_remarks" text COLLATE "pg_catalog"."default",
  "seller_remarks" text COLLATE "pg_catalog"."default",
  "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "deleted" int4 DEFAULT 0
)
;
COMMENT ON TABLE "public"."tb_order_info" IS '订单表';

-- ----------------------------
-- Records of tb_order_info
-- ----------------------------
INSERT INTO "public"."tb_order_info" VALUES ('202508191718590806528000', '1', '1', '1', '中交方远智能实测实量管理系统', '中交建筑集团第一工程有限公司', '3', '2025-08-19 17:18:59.608', '待审批', 400.00, '积分', '未支付', NULL, NULL, NULL, '', NULL, '2025-08-19 17:18:59.608', '2025-08-19 17:18:59.608', 0);
INSERT INTO "public"."tb_order_info" VALUES ('202508191730018270442496', '1', '1', '1', '中交方远智能实测实量管理系统', '中交建筑集团第一工程有限公司', '3', '2025-08-19 17:30:01.807', '待审批', 500.00, '积分', '未支付', NULL, NULL, NULL, '', NULL, '2025-08-19 17:30:01.807', '2025-08-19 17:30:01.807', 0);
INSERT INTO "public"."tb_order_info" VALUES ('202508191732232175500288', '1', '1', '1', '中交方远智能实测实量管理系统', '中交建筑集团第一工程有限公司', '3', '2025-08-19 17:32:23.405', '待审批', 1000.00, '积分', '未支付', NULL, NULL, NULL, '', NULL, '2025-08-19 17:32:23.405', '2025-08-19 17:32:23.405', 0);
INSERT INTO "public"."tb_order_info" VALUES ('202508191735337897883648', '1', '1', '1', '中交方远智能实测实量管理系统', '中交建筑集团第一工程有限公司', '3', '2025-08-19 17:35:33.12', '待审批', 0.00, '积分', '未支付', NULL, NULL, NULL, '', NULL, '2025-08-19 17:35:33.12', '2025-08-19 17:35:33.12', 0);
INSERT INTO "public"."tb_order_info" VALUES ('202508191745527049352192', '1', '1', '1', '中交方远智能实测实量管理系统', '中交建筑集团第一工程有限公司', '3', '2025-08-19 17:45:52.806', '待审批', 200.00, '积分', '未支付', NULL, NULL, NULL, '', NULL, '2025-08-19 17:45:52.807', '2025-08-19 17:45:52.807', 0);
INSERT INTO "public"."tb_order_info" VALUES ('202508191752392071676928', '1', '1', '1', '中交方远智能实测实量管理系统', '中交建筑集团第一工程有限公司', '3', '2025-08-19 17:52:39.316', '待审批', 0.00, '积分', '未支付', NULL, NULL, NULL, '', NULL, '2025-08-19 17:52:39.316', '2025-08-19 17:52:39.316', 0);
INSERT INTO "public"."tb_order_info" VALUES ('202508191809061614843904', '1', '1', '1', '中交方远智能实测实量管理系统', '中交建筑集团第一工程有限公司', '3', '2025-08-19 18:09:06.259', '待审批', 200.00, '积分', '未支付', NULL, NULL, NULL, '', NULL, '2025-08-19 18:09:06.259', '2025-08-19 18:09:06.259', 0);
INSERT INTO "public"."tb_order_info" VALUES ('202508221423519599931392', '1', '1', '1', '中交方远智能实测实量管理系统', '中交建筑集团第一工程有限公司', '3', '2025-08-22 14:23:51.357', '待审批', 300.00, '积分', '未支付', NULL, NULL, NULL, '', NULL, '2025-08-22 14:23:51.357', '2025-08-22 14:23:51.357', 0);
INSERT INTO "public"."tb_order_info" VALUES ('202508261002538948777984', '1', '1', '1', '中交方远智能实测实量管理系统', '中交建筑集团第一工程有限公司', '3', '2025-08-26 10:02:53.904', '待授权', 500.00, '积分', '未支付', NULL, NULL, NULL, '', NULL, '2025-08-26 10:02:53.904', '2025-08-26 10:02:53.904', 0);
INSERT INTO "public"."tb_order_info" VALUES ('202508272131080287679488', '7439040f-cf34-4e8a-a3da-0b7990f79e4d', '2', '', '钢筋数字化生产加工', '中交第二航务工程局有限公司', '2', '2025-08-27 21:31:08.83', '待授权', 600.00, '积分', '未支付', 'f43f7af4-095b-11f0-bea3-fa163eb62b1f', NULL, NULL, '', NULL, '2025-08-27 21:31:08.83', '2025-08-27 21:31:08.831', 0);

-- ----------------------------
-- Table structure for tb_points
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_points";
CREATE TABLE "public"."tb_points" (
  "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
      INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 7
),
  "points_name" varchar COLLATE "pg_catalog"."default" NOT NULL,
  "effective_start" timestamp(0) NOT NULL,
  "modifier_id" int8 NOT NULL,
  "modifier_name" varchar COLLATE "pg_catalog"."default" NOT NULL,
  "version" numeric(2,1) NOT NULL,
  "description" text COLLATE "pg_catalog"."default",
  "status" int2,
  "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "deleted" int2 DEFAULT 0
)
;
COMMENT ON COLUMN "public"."tb_points"."points_name" IS '积分名称';
COMMENT ON COLUMN "public"."tb_points"."effective_start" IS '生效开始时间';
COMMENT ON COLUMN "public"."tb_points"."modifier_id" IS '修改人ID';
COMMENT ON COLUMN "public"."tb_points"."modifier_name" IS '修改人姓名';
COMMENT ON COLUMN "public"."tb_points"."version" IS '版本号';
COMMENT ON COLUMN "public"."tb_points"."description" IS '积分描述';
COMMENT ON COLUMN "public"."tb_points"."status" IS '状态(0启用1禁用)';
COMMENT ON COLUMN "public"."tb_points"."created_at" IS '创建时间';
COMMENT ON COLUMN "public"."tb_points"."updated_at" IS '更新时间';
COMMENT ON COLUMN "public"."tb_points"."deleted" IS '逻辑删除(1删除)';
COMMENT ON TABLE "public"."tb_points" IS '积分主表';

-- ----------------------------
-- Records of tb_points
-- ----------------------------
INSERT INTO "public"."tb_points" OVERRIDING SYSTEM VALUE VALUES (1, '积分运行规则', '2025-08-14 00:00:00', 1, '管理员', 1.0, NULL, 0, '2025-08-14 11:01:32.086436', '2025-08-14 11:01:32.086436', 0);
INSERT INTO "public"."tb_points" OVERRIDING SYSTEM VALUE VALUES (6, '积分运行规则', '2025-08-15 01:04:45', 1, 'admin', 1.1, NULL, 0, '2025-08-15 01:04:44.998', '2025-08-15 01:04:45', 0);

-- ----------------------------
-- Table structure for tb_points_account
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_points_account";
CREATE TABLE "public"."tb_points_account" (
  "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
      INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
),
  "user_id" int8 NOT NULL,
  "points_balance" int4 NOT NULL DEFAULT 0,
  "total_earned" int4 NOT NULL DEFAULT 0,
  "total_consumed" int4 NOT NULL DEFAULT 0,
  "account_type" text COLLATE "pg_catalog"."default" NOT NULL,
  "account_status" text COLLATE "pg_catalog"."default" DEFAULT '正常'::text,
  "last_transaction_time" timestamptz(6),
  "created_at" timestamptz(6) DEFAULT CURRENT_TIMESTAMP,
  "updated_at" timestamptz(6) DEFAULT CURRENT_TIMESTAMP,
  "deleted" int2 DEFAULT 0
)
;
COMMENT ON COLUMN "public"."tb_points_account"."user_id" IS '用户ID';
COMMENT ON COLUMN "public"."tb_points_account"."points_balance" IS '积分余额';
COMMENT ON COLUMN "public"."tb_points_account"."total_earned" IS '累计获取积分';
COMMENT ON COLUMN "public"."tb_points_account"."total_consumed" IS '累计消耗积分';
COMMENT ON COLUMN "public"."tb_points_account"."account_type" IS '账户类型';
COMMENT ON COLUMN "public"."tb_points_account"."account_status" IS '账户状态';
COMMENT ON COLUMN "public"."tb_points_account"."last_transaction_time" IS '最后交易时间';
COMMENT ON COLUMN "public"."tb_points_account"."created_at" IS '创建时间';
COMMENT ON COLUMN "public"."tb_points_account"."updated_at" IS '更新时间';
COMMENT ON COLUMN "public"."tb_points_account"."deleted" IS '逻辑删除';
COMMENT ON TABLE "public"."tb_points_account" IS '积分账户表';

-- ----------------------------
-- Records of tb_points_account
-- ----------------------------

-- ----------------------------
-- Table structure for tb_points_flow
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_points_flow";
CREATE TABLE "public"."tb_points_flow" (
  "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
      INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 18
),
  "user_id" varchar(64) COLLATE "pg_catalog"."default",
  "unit_id" varchar(64) COLLATE "pg_catalog"."default",
  "data_category" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
  "data_type" int2 NOT NULL,
  "name" text COLLATE "pg_catalog"."default" NOT NULL,
  "points" int4 NOT NULL,
  "flow_time" timestamp(6) NOT NULL,
  "create_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "update_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "deleted" int4 DEFAULT 0,
  "rule_id" int4
)
;
COMMENT ON COLUMN "public"."tb_points_flow"."user_id" IS '用户ID';
COMMENT ON COLUMN "public"."tb_points_flow"."unit_id" IS '单位ID';
COMMENT ON COLUMN "public"."tb_points_flow"."data_category" IS '数据类目';
COMMENT ON COLUMN "public"."tb_points_flow"."data_type" IS '数据类型';
COMMENT ON COLUMN "public"."tb_points_flow"."name" IS '名称/描述';
COMMENT ON COLUMN "public"."tb_points_flow"."points" IS '积分值';
COMMENT ON COLUMN "public"."tb_points_flow"."flow_time" IS '流水时间';
COMMENT ON COLUMN "public"."tb_points_flow"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."tb_points_flow"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."tb_points_flow"."deleted" IS '逻辑删除：1-已删除，0-未删除';
COMMENT ON COLUMN "public"."tb_points_flow"."rule_id" IS '规则ID';
COMMENT ON TABLE "public"."tb_points_flow" IS '积分流水表';

-- ----------------------------
-- Records of tb_points_flow
-- ----------------------------
INSERT INTO "public"."tb_points_flow" OVERRIDING SYSTEM VALUE VALUES (1, '1', '1', '资源贡献', 0, '用户每日首次登录', 1, '2025-05-18 16:00:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0, NULL);
INSERT INTO "public"."tb_points_flow" OVERRIDING SYSTEM VALUE VALUES (3, '1', '1', '资源贡献', 0, '用户每日首次登录', 1, '2025-05-16 14:00:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0, NULL);
INSERT INTO "public"."tb_points_flow" OVERRIDING SYSTEM VALUE VALUES (2, '1', '1', '交流社区互动', 0, '交流社区发布评论"基建行业如何利用AI技术提高效率"', 1, '2025-05-17 15:00:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0, NULL);
INSERT INTO "public"."tb_points_flow" OVERRIDING SYSTEM VALUE VALUES (4, '1', '1', '交流社区互动', 1, '交流社区删除提问"基建项目如何应用数字孪生技术?"', -1, '2025-05-15 13:00:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0, NULL);
INSERT INTO "public"."tb_points_flow" OVERRIDING SYSTEM VALUE VALUES (8, '1', '1', '交流社区互动', 0, '交流社区发布提问"基建项目如何应用数字孪生技术?"', 1, '2025-05-02 09:10:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0, NULL);
INSERT INTO "public"."tb_points_flow" OVERRIDING SYSTEM VALUE VALUES (17, '1', '1', '其他', 0, '积分奖励', 100, '2025-08-08 18:34:36', '2025-08-08 18:34:39', '2025-08-08 18:34:41', 0, NULL);
INSERT INTO "public"."tb_points_flow" OVERRIDING SYSTEM VALUE VALUES (10, '1', '1', '其他', 0, '初始化积分', 100, '2025-05-01 09:01:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0, NULL);
INSERT INTO "public"."tb_points_flow" OVERRIDING SYSTEM VALUE VALUES (7, '1', '1', '其他', 0, '积分奖励', 100, '2025-05-04 10:00:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0, NULL);
INSERT INTO "public"."tb_points_flow" OVERRIDING SYSTEM VALUE VALUES (6, '1', '1', '资源传播', 0, '用户每日首次登录', 1, '2025-05-05 11:00:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0, NULL);
INSERT INTO "public"."tb_points_flow" OVERRIDING SYSTEM VALUE VALUES (9, '1', '1', '资源传播', 0, '用户每日首次登录', 1, '2025-05-02 09:02:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0, NULL);
INSERT INTO "public"."tb_points_flow" OVERRIDING SYSTEM VALUE VALUES (5, '1', '1', '资源传播', 0, '单位积分转入', 1000, '2025-05-06 12:00:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0, NULL);

-- ----------------------------
-- Table structure for tb_points_rule
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_points_rule";
CREATE TABLE "public"."tb_points_rule" (
  "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
      INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 85
),
  "points_id" int8 NOT NULL,
  "rule_type" int2 NOT NULL,
  "category" varchar COLLATE "pg_catalog"."default" NOT NULL,
  "rule_name" varchar COLLATE "pg_catalog"."default" NOT NULL,
  "rule_description" varchar COLLATE "pg_catalog"."default",
  "is_enabled" int2 DEFAULT 0,
  "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "deleted" int2 DEFAULT 0,
  "points_winner" int2,
  "is_limit" int2,
  "rule_order" int2,
  "points_value" int2,
  "daily_limit" int2,
  "rule_name_code" varchar(255) COLLATE "pg_catalog"."default" NOT NULL
)
;
COMMENT ON COLUMN "public"."tb_points_rule"."points_id" IS '关联积分ID';
COMMENT ON COLUMN "public"."tb_points_rule"."rule_type" IS '积分规则类型(0获取1消耗)';
COMMENT ON COLUMN "public"."tb_points_rule"."category" IS '积分类别';
COMMENT ON COLUMN "public"."tb_points_rule"."rule_name" IS '规则名称';
COMMENT ON COLUMN "public"."tb_points_rule"."rule_description" IS '规则描述';
COMMENT ON COLUMN "public"."tb_points_rule"."is_enabled" IS '规则状态(0启动1禁用)';
COMMENT ON COLUMN "public"."tb_points_rule"."created_at" IS '创建时间';
COMMENT ON COLUMN "public"."tb_points_rule"."updated_at" IS '更新时间';
COMMENT ON COLUMN "public"."tb_points_rule"."deleted" IS '逻辑删除';
COMMENT ON COLUMN "public"."tb_points_rule"."points_winner" IS '积分获得者（0贡献者1用户）';
COMMENT ON COLUMN "public"."tb_points_rule"."is_limit" IS '积分是否有上限(0没有1有)';
COMMENT ON COLUMN "public"."tb_points_rule"."rule_order" IS '排序规则';
COMMENT ON COLUMN "public"."tb_points_rule"."points_value" IS '积分值';
COMMENT ON COLUMN "public"."tb_points_rule"."daily_limit" IS '积分日上限';
COMMENT ON COLUMN "public"."tb_points_rule"."rule_name_code" IS '规则名称编码';
COMMENT ON TABLE "public"."tb_points_rule" IS '积分规则表';

-- ----------------------------
-- Records of tb_points_rule
-- ----------------------------
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (17, 1, 0, '资源交易', '数字化产品接入', '每成功接入1次，贡献者 获', 0, '2025-08-14 15:07:54.738396', '2025-08-14 15:07:54.738396', 0, 0, 0, 3, NULL, NULL, 'digital_product_access');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (18, 1, 0, '资源交易', '数字化产品交易', '每成功交易1次，贡献者 获', 0, '2025-08-14 15:07:54.739469', '2025-08-14 15:07:54.739469', 0, 0, 0, 3, NULL, NULL, 'digital_product_transaction');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (34, 1, 0, '交流社区互动', '回复帖子', '每回复1次帖子，贡献者 获', 0, '2025-08-14 15:08:19.324645', '2025-08-14 15:08:19.324645', 0, 0, 1, 4, NULL, NULL, 'post_reply');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (35, 1, 0, '交流社区互动', '帖子点赞', '发布的帖子或做出的回答每被点赞一次，贡献者 获', 0, '2025-08-14 15:08:19.325826', '2025-08-14 15:08:19.325826', 0, 0, 0, 4, NULL, NULL, 'post_like');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (36, 1, 0, '交流社区互动', '帖子收藏', '发布的帖子每被收藏一次，贡献者 获', 0, '2025-08-14 15:08:19.326955', '2025-08-14 15:08:19.326955', 0, 0, 0, 4, NULL, NULL, 'post_collect');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (52, 1, 1, '交流社区互动', '取消收藏', '发布的帖子被收藏，后又取消收藏，贡献者 扣除', 0, '2025-08-14 15:15:13.333528', '2025-08-14 15:15:13.333528', 0, 0, 0, 4, NULL, NULL, 'collect_cancel');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (2, 1, 0, '资源贡献', '新增数字化标杆', '每成功上架1个标杆，贡献者 获', 0, '2025-08-14 14:24:00.753678', '2025-08-14 14:24:00.753678', 0, 0, 0, 1, NULL, NULL, 'new_digital_benchmark');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (4, 1, 0, '资源贡献', '新增数字化产品', '每成功上架1个产品，贡献者 获', 0, '2025-08-14 14:44:37.128422', '2025-08-14 14:44:37.128422', 0, 0, 0, 1, NULL, NULL, 'new_digital_product');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (3, 1, 0, '资源贡献', '新增数字化知识', '每成功上架1个知识，贡献者 获', 0, '2025-08-14 14:44:37.124901', '2025-08-14 14:44:37.124901', 0, 0, 0, 1, NULL, NULL, 'new_digital_knowledge');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (11, 1, 0, '资源传播', '评价数字化资源', '每被评价1次，贡献者 获', 0, '2025-08-14 15:07:54.732016', '2025-08-14 15:07:54.732016', 0, 0, 1, 2, NULL, NULL, 'resource_review');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (12, 1, 0, '资源传播', '评价数字化资源', '评价者 获', 0, '2025-08-14 15:07:54.733588', '2025-08-14 15:07:54.733588', 0, 1, 1, 2, NULL, NULL, 'resource_review');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (15, 1, 0, '资源传播', '订阅数字化资源', '每被订阅1次，贡献者 获', 0, '2025-08-14 15:07:54.736641', '2025-08-14 15:07:54.736641', 0, 0, 0, 2, NULL, NULL, 'resource_subscribe');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (16, 1, 0, '资源传播', '订阅数字化资源', '订阅者 获', 0, '2025-08-14 15:07:54.737529', '2025-08-14 15:07:54.737529', 0, 1, 0, 2, NULL, NULL, 'resource_subscribe');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (20, 1, 0, '资源传播', '浏览数字化资源', '浏览者', 0, '2025-08-14 15:08:19.309681', '2025-08-14 15:08:19.309681', 0, 1, 1, 2, NULL, NULL, 'resource_view');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (21, 1, 0, '资源传播', '收藏数字化资源', '每被收藏1次，贡献者 获', 0, '2025-08-14 15:08:19.311096', '2025-08-14 15:08:19.311096', 0, 0, 1, 2, NULL, NULL, 'resource_collect');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (42, 1, 1, '资源传播', '取消订阅', '操作者 扣除', 0, '2025-08-14 15:12:29.49397', '2025-08-14 15:12:29.49397', 0, 1, 0, 2, NULL, NULL, 'subscribe_cancel');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (43, 1, 1, '资源传播', '取消收藏', '数字化资源被取消收藏，贡献者 扣除', 0, '2025-08-14 15:15:13.324114', '2025-08-14 15:15:13.324114', 0, 0, 0, 2, NULL, NULL, 'collect_cancel');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (44, 1, 1, '资源传播', '取消收藏', '操作者 扣除', 0, '2025-08-14 15:15:13.325517', '2025-08-14 15:15:13.325517', 0, 1, 0, 2, NULL, NULL, 'collect_cancel');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (22, 1, 0, '资源传播', '收藏数字化资源', '收藏者 获', 0, '2025-08-14 15:08:19.312482', '2025-08-14 15:08:19.312482', 0, 1, 1, 2, NULL, NULL, 'resource_collect');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (23, 1, 0, '资源传播', '点赞数字化资源', '每被点赞1次，贡献者 获', 0, '2025-08-14 15:08:19.313654', '2025-08-14 15:08:19.313654', 0, 0, 1, 2, NULL, NULL, 'resource_like');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (24, 1, 0, '资源传播', '点赞数字化资源', '点赞者 获', 0, '2025-08-14 15:08:19.314647', '2025-08-14 15:08:19.314647', 0, 1, 1, 2, NULL, NULL, 'resource_like');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (28, 1, 0, '资源传播', '试用数字化资源', '试用者 获', 0, '2025-08-14 15:08:19.318477', '2025-08-14 15:08:19.318477', 0, 1, 0, 2, NULL, NULL, 'resource_trial');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (39, 1, 1, '资源传播', '取消点赞', '数字化资源被取消点赞，贡献者 扣除', 0, '2025-08-14 15:12:29.490075', '2025-08-14 15:12:29.490075', 0, 0, 0, 2, NULL, NULL, 'like_cancel');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (40, 1, 1, '资源传播', '取消点赞', '操作者 扣除', 0, '2025-08-14 15:12:29.49113', '2025-08-14 15:12:29.49113', 0, 1, 0, 2, NULL, NULL, 'like_cancel');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (41, 1, 1, '资源传播', '取消订阅', '数字化产品被取消订阅，贡献者 扣除', 0, '2025-08-14 15:12:29.492296', '2025-08-14 15:12:29.492296', 0, 0, 0, 2, NULL, NULL, 'subscribe_cancel');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (49, 1, 1, '交流社区互动', '删除帖子', '自己发布的帖子被删除，贡献者 扣除', 0, '2025-08-14 15:15:13.330326', '2025-08-14 15:15:13.330326', 0, 0, 0, 4, NULL, NULL, 'post_delete');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (50, 1, 1, '交流社区互动', '删除回复', '自己的回复被删除，贡献者 扣除', 0, '2025-08-14 15:15:13.331467', '2025-08-14 15:15:13.331467', 0, 0, 0, 4, NULL, NULL, 'reply_delete');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (51, 1, 1, '交流社区互动', '取消点赞', '发布的帖子或做出的回答被点赞后又取消点赞，贡献者 扣除', 0, '2025-08-14 15:15:13.332602', '2025-08-14 15:15:13.332602', 0, 0, 0, 4, NULL, NULL, 'like_cancel');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (33, 1, 0, '交流社区互动', '发布帖子', '每成功发布1次，贡献者 获', 0, '2025-08-14 15:08:19.323293', '2025-08-14 15:08:19.323293', 0, 0, 1, 4, NULL, NULL, 'post_create');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (13, 1, 0, '资源传播', '试用数字化资源', '每被试用1次，贡献者 获', 0, '2025-08-14 15:07:54.734444', '2025-08-14 15:07:54.734444', 0, 0, 0, 2, NULL, NULL, 'resource_trial');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (19, 1, 0, '资源传播', '浏览数字化资源', '每被浏览1次，贡献者', 0, '2025-08-14 15:08:19.308203', '2025-08-14 15:08:19.308203', 0, 0, 1, 2, NULL, NULL, 'resource_view');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (54, 6, 0, '资源贡献', '新增数字化标杆', '每成功上架1个标杆，贡献者 获', 0, '2025-08-15 01:04:45.022', '2025-08-15 01:04:45.016', 0, 0, 0, 1, 1, NULL, 'new_digital_benchmark');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (55, 6, 0, '资源贡献', '新增数字化产品', '每成功上架1个产品，贡献者 获', 0, '2025-08-15 01:04:45.146', '2025-08-15 01:04:45.146', 0, 0, 0, 1, 1, NULL, 'new_digital_product');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (56, 6, 0, '资源贡献', '新增数字化知识', '每成功上架1个知识，贡献者 获', 0, '2025-08-15 01:04:45.149', '2025-08-15 01:04:45.148', 0, 0, 0, 1, 1, NULL, 'new_digital_knowledge');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (57, 6, 0, '资源传播', '评价数字化资源', '每被评价1次，贡献者 获', 0, '2025-08-15 01:04:45.153', '2025-08-15 01:04:45.153', 0, 0, 1, 2, 1, 10, 'resource_review');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (58, 6, 0, '资源传播', '评价数字化资源', '评价者 获', 0, '2025-08-15 01:04:45.161', '2025-08-15 01:04:45.159', 0, 1, 1, 2, 1, 10, 'resource_review');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (59, 6, 0, '资源传播', '订阅数字化资源', '每被订阅1次，贡献者 获', 0, '2025-08-15 01:04:45.167', '2025-08-15 01:04:45.164', 0, 0, 0, 2, 1, NULL, 'resource_subscribe');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (60, 6, 0, '资源传播', '订阅数字化资源', '订阅者 获', 0, '2025-08-15 01:04:45.171', '2025-08-15 01:04:45.17', 0, 1, 0, 2, 1, NULL, 'resource_subscribe');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (61, 6, 0, '资源传播', '浏览数字化资源', '浏览者', 0, '2025-08-15 01:04:45.176', '2025-08-15 01:04:45.174', 0, 1, 1, 2, 1, 10, 'resource_view');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (62, 6, 0, '资源传播', '收藏数字化资源', '每被收藏1次，贡献者 获', 0, '2025-08-15 01:04:45.181', '2025-08-15 01:04:45.18', 0, 0, 1, 2, 1, 10, 'resource_collect');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (63, 6, 0, '资源传播', '收藏数字化资源', '收藏者 获', 0, '2025-08-15 01:04:45.184', '2025-08-15 01:04:45.184', 0, 1, 1, 2, 1, 10, 'resource_collect');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (64, 6, 0, '资源传播', '点赞数字化资源', '每被点赞1次，贡献者 获', 0, '2025-08-15 01:04:45.187', '2025-08-15 01:04:45.187', 0, 0, 1, 2, 1, 10, 'resource_like');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (65, 6, 0, '资源传播', '点赞数字化资源', '点赞者 获', 0, '2025-08-15 01:04:45.191', '2025-08-15 01:04:45.19', 0, 1, 1, 2, 1, 10, 'resource_like');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (66, 6, 0, '资源传播', '试用数字化资源', '试用者 获', 0, '2025-08-15 01:04:45.196', '2025-08-15 01:04:45.195', 0, 1, 0, 2, 1, NULL, 'resource_trial');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (67, 6, 0, '资源传播', '试用数字化资源', '每被试用1次，贡献者 获', 0, '2025-08-15 01:04:45.199', '2025-08-15 01:04:45.199', 0, 0, 0, 2, 1, NULL, 'resource_trial');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (68, 6, 0, '资源传播', '浏览数字化资源', '每被浏览1次，贡献者', 0, '2025-08-15 01:04:45.207', '2025-08-15 01:04:45.205', 0, 0, 1, 2, 1, 10, 'resource_view');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (69, 6, 0, '资源交易', '数字化产品接入', '每成功接入1次，贡献者 获', 0, '2025-08-15 01:04:45.218', '2025-08-15 01:04:45.216', 0, 0, 0, 3, 1, NULL, 'digital_product_access');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (70, 6, 0, '资源交易', '数字化产品交易', '每成功交易1次，贡献者 获', 0, '2025-08-15 01:04:45.222', '2025-08-15 01:04:45.221', 0, 0, 0, 3, 1, NULL, 'digital_product_transaction');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (71, 6, 0, '交流社区互动', '回复帖子', '每回复1次帖子，贡献者 获', 0, '2025-08-15 01:04:45.225', '2025-08-15 01:04:45.224', 0, 0, 1, 4, 1, 10, 'post_reply');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (72, 6, 0, '交流社区互动', '帖子点赞', '发布的帖子或做出的回答每被点赞一次，贡献者 获', 0, '2025-08-15 01:04:45.23', '2025-08-15 01:04:45.23', 0, 0, 0, 4, 1, NULL, 'post_like');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (73, 6, 0, '交流社区互动', '帖子收藏', '发布的帖子每被收藏一次，贡献者 获', 0, '2025-08-15 01:04:45.246', '2025-08-15 01:04:45.245', 0, 0, 0, 4, 1, NULL, 'post_collect');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (74, 6, 0, '交流社区互动', '发布帖子', '每成功发布1次，贡献者 获', 0, '2025-08-15 01:04:45.247', '2025-08-15 01:04:45.247', 0, 0, 1, 4, 1, 10, 'post_create');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (75, 6, 1, '资源传播', '取消订阅', '操作者 扣除', 0, '2025-08-15 01:04:45.248', '2025-08-15 01:04:45.248', 0, 1, 0, 2, 1, NULL, 'subscribe_cancel');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (76, 6, 1, '资源传播', '取消收藏', '数字化资源被取消收藏，贡献者 扣除', 0, '2025-08-15 01:04:45.261', '2025-08-15 01:04:45.261', 0, 0, 0, 2, 1, NULL, 'collect_cancel');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (77, 6, 1, '资源传播', '取消收藏', '操作者 扣除', 0, '2025-08-15 01:04:45.263', '2025-08-15 01:04:45.262', 0, 1, 0, 2, 1, NULL, 'collect_cancel');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (78, 6, 1, '资源传播', '取消点赞', '数字化资源被取消点赞，贡献者 扣除', 0, '2025-08-15 01:04:45.264', '2025-08-15 01:04:45.264', 0, 0, 0, 2, 1, NULL, 'like_cancel');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (79, 6, 1, '资源传播', '取消点赞', '操作者 扣除', 0, '2025-08-15 01:04:45.266', '2025-08-15 01:04:45.265', 0, 1, 0, 2, 1, NULL, 'like_cancel');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (80, 6, 1, '资源传播', '取消订阅', '数字化产品被取消订阅，贡献者 扣除', 0, '2025-08-15 01:04:45.267', '2025-08-15 01:04:45.267', 0, 0, 0, 2, 1, NULL, 'subscribe_cancel');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (81, 6, 1, '交流社区互动', '取消收藏', '发布的帖子被收藏，后又取消收藏，贡献者 扣除', 0, '2025-08-15 01:04:45.268', '2025-08-15 01:04:45.268', 0, 0, 0, 4, 1, NULL, 'collect_cancel');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (82, 6, 1, '交流社区互动', '删除帖子', '自己发布的帖子被删除，贡献者 扣除', 0, '2025-08-15 01:04:45.27', '2025-08-15 01:04:45.27', 0, 0, 0, 4, 1, NULL, 'post_delete');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (83, 6, 1, '交流社区互动', '删除回复', '自己的回复被删除，贡献者 扣除', 0, '2025-08-15 01:04:45.271', '2025-08-15 01:04:45.271', 0, 0, 0, 4, 1, NULL, 'reply_delete');
INSERT INTO "public"."tb_points_rule" OVERRIDING SYSTEM VALUE VALUES (84, 6, 1, '交流社区互动', '取消点赞', '发布的帖子或做出的回答被点赞后又取消点赞，贡献者 扣除', 0, '2025-08-15 01:04:45.273', '2025-08-15 01:04:45.273', 0, 0, 0, 4, 1, NULL, 'like_cancel');

-- ----------------------------
-- Table structure for tb_points_transaction
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_points_transaction";
CREATE TABLE "public"."tb_points_transaction" (
  "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
      INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
),
  "data_category" text COLLATE "pg_catalog"."default" NOT NULL,
  "transaction_name" text COLLATE "pg_catalog"."default" NOT NULL,
  "transaction_time" timestamptz(6) DEFAULT CURRENT_TIMESTAMP,
  "points_change" int4 NOT NULL,
  "rule_type" text COLLATE "pg_catalog"."default" NOT NULL,
  "user_id" int8,
  "unit_id" int8,
  "user_type" text COLLATE "pg_catalog"."default" NOT NULL,
  "rule_id" int8,
  "detail_id" int8,
  "created_at" timestamptz(6) DEFAULT CURRENT_TIMESTAMP,
  "deleted" int2 DEFAULT 0
)
;
COMMENT ON COLUMN "public"."tb_points_transaction"."data_category" IS '数据类目';
COMMENT ON COLUMN "public"."tb_points_transaction"."transaction_name" IS '名称';
COMMENT ON COLUMN "public"."tb_points_transaction"."transaction_time" IS '时间';
COMMENT ON COLUMN "public"."tb_points_transaction"."points_change" IS '积分变动值';
COMMENT ON COLUMN "public"."tb_points_transaction"."rule_type" IS '积分规则类型';
COMMENT ON COLUMN "public"."tb_points_transaction"."user_id" IS '用户ID';
COMMENT ON COLUMN "public"."tb_points_transaction"."unit_id" IS '企业ID';
COMMENT ON COLUMN "public"."tb_points_transaction"."user_type" IS '用户类型';
COMMENT ON COLUMN "public"."tb_points_transaction"."rule_id" IS '关联规则ID';
COMMENT ON COLUMN "public"."tb_points_transaction"."detail_id" IS '关联规则详情ID';
COMMENT ON COLUMN "public"."tb_points_transaction"."created_at" IS '创建时间';
COMMENT ON COLUMN "public"."tb_points_transaction"."deleted" IS '逻辑删除';
COMMENT ON TABLE "public"."tb_points_transaction" IS '积分流水表';

-- ----------------------------
-- Records of tb_points_transaction
-- ----------------------------
-- ----------------------------
-- Table structure for tb_product_pricing
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_product_pricing";
CREATE TABLE "public"."tb_product_pricing" (
  "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 12
),
  "suite_name" text COLLATE "pg_catalog"."default" NOT NULL,
  "sales_form" text COLLATE "pg_catalog"."default" NOT NULL,
  "customer_type" text COLLATE "pg_catalog"."default" NOT NULL,
  "account_limit" text COLLATE "pg_catalog"."default" DEFAULT '不限'::text,
  "concurrent_nodes" text COLLATE "pg_catalog"."default" DEFAULT '不限'::text,
  "price_type" text COLLATE "pg_catalog"."default" NOT NULL,
  "price_unit" text COLLATE "pg_catalog"."default" NOT NULL,
  "points_price" numeric(15,2),
  "is_active" bool DEFAULT true,
  "product_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "product_name" text COLLATE "pg_catalog"."default",
  "provider_id" varchar(64) COLLATE "pg_catalog"."default",
  "provider_name" text COLLATE "pg_catalog"."default",
  "description" text COLLATE "pg_catalog"."default",
  "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "created_by" int8,
  "updated_by" int8,
  "deleted" int4 DEFAULT 0,
  "currency_price" numeric(15,2)
)
;
COMMENT ON COLUMN "public"."tb_product_pricing"."suite_name" IS '产品套件名称';
COMMENT ON COLUMN "public"."tb_product_pricing"."sales_form" IS '销售形式';
COMMENT ON COLUMN "public"."tb_product_pricing"."points_price" IS '积分价格';
COMMENT ON COLUMN "public"."tb_product_pricing"."currency_price" IS '货币价格';
COMMENT ON TABLE "public"."tb_product_pricing" IS '产品定价表';

-- ----------------------------
-- Records of tb_product_pricing
-- ----------------------------
INSERT INTO "public"."tb_product_pricing" OVERRIDING SYSTEM VALUE VALUES (3, '企业版', '买断', '企业', '不限', '不限', '货币', '套', 10000.00, 't', '2', '测试产品2', '3', '测试提供者', NULL, '2025-08-13 14:50:16.574223', '2025-08-13 14:50:16.574223', NULL, NULL, 0, NULL);
INSERT INTO "public"."tb_product_pricing" OVERRIDING SYSTEM VALUE VALUES (1, '基础版', '买断', '企业', '不限', '不限', '积分', '套', 1000.00, 't', '7439040f-cf34-4e8a-a3da-0b7990f79e4d', '测试产品1', '3', '测试提供者', NULL, '2025-08-13 14:50:16.574223', '2025-08-13 14:50:16.574223', NULL, NULL, 0, NULL);
INSERT INTO "public"."tb_product_pricing" OVERRIDING SYSTEM VALUE VALUES (2, '专业版', '租赁', '企业', '不限', '不限', '积分', '套/年', 500.00, 't', '7439040f-cf34-4e8a-a3da-0b7990f79e4d', '测试产品1', '3', '测试提供者', NULL, '2025-08-13 14:50:16.574223', '2025-08-13 14:50:16.574223', NULL, NULL, 0, NULL);
INSERT INTO "public"."tb_product_pricing" OVERRIDING SYSTEM VALUE VALUES (4, '企业私有SaaS版许可', '租赁', '个人', '1', '1', '积分,货币', '套/年', 200.00, 't', '7439040f-cf34-4e8a-a3da-0b7990f79e4d', '数字化产品A', NULL, NULL, '', '2025-08-18 16:53:39.407', '2025-08-18 16:53:39.407', NULL, NULL, 0, 100.00);
INSERT INTO "public"."tb_product_pricing" OVERRIDING SYSTEM VALUE VALUES (6, '企业私有SaaS版用户增量包', '租赁', '个人', '2', '2', '货币', '套/年', 200.00, 't', '7439040f-cf34-4e8a-a3da-0b7990f79e4d', '数字化产品A', NULL, NULL, '', '2025-08-18 17:13:29.332', '2025-08-18 17:13:29.332', NULL, NULL, 0, 100.00);
INSERT INTO "public"."tb_product_pricing" OVERRIDING SYSTEM VALUE VALUES (9, '企业私有SaaS版用户增量包', '私有增包量', '项目部', '1', '1', '免费', '年', NULL, 't', '7439040f-cf34-4e8a-a3da-0b7990f79e4d', '数字化产品A', NULL, NULL, '', '2025-08-19 17:17:41.644', '2025-08-19 17:17:41.644', NULL, NULL, 0, NULL);
INSERT INTO "public"."tb_product_pricing" OVERRIDING SYSTEM VALUE VALUES (5, '企业私有SaaS版许可', '私有增包量', '个人', '2', '3', '积分,货币', '套/年', 200.00, 'f', '7439040f-cf34-4e8a-a3da-0b7990f79e4d', '数字化产品A', NULL, NULL, '', '2025-08-18 16:53:57.726', '2025-08-19 17:54:06.25', NULL, NULL, 1, 100.00);
INSERT INTO "public"."tb_product_pricing" OVERRIDING SYSTEM VALUE VALUES (10, '企业私有SaaS版许可', '租赁', '个人', '1', '2', '积分,货币,协议', '套/年', 100.00, 't', '7439040f-cf34-4e8a-a3da-0b7990f79e4d', '数字化产品A', NULL, NULL, '', '2025-08-22 14:21:52.591', '2025-08-22 14:22:20.653', NULL, NULL, 0, 100.00);
INSERT INTO "public"."tb_product_pricing" OVERRIDING SYSTEM VALUE VALUES (11, 'web软件', '租赁', '个人', '1', '不限', '免费', '年', 0.00, 't', '7439040f-cf34-4e8a-a3da-0b7990f79e4d', '钢筋数字化生产加工', NULL, NULL, '', '2025-08-27 16:03:36.041', '2025-08-27 16:04:06.647', NULL, NULL, 0, 0.00);

-- ----------------------------
-- Table structure for tb_user_points
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_user_points";
CREATE TABLE "public"."tb_user_points" (
  "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY (
      INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 2
),
  "user_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
  "unit_id" varchar(64) COLLATE "pg_catalog"."default",
  "balance" int4 NOT NULL DEFAULT 0,
  "total_earned" int4 NOT NULL DEFAULT 0,
  "total_consumed" int4 NOT NULL DEFAULT 0,
  "total_converted" int4 NOT NULL DEFAULT 0,
  "create_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "update_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
  "deleted" int4 DEFAULT 0
)
;
COMMENT ON COLUMN "public"."tb_user_points"."user_id" IS '用户ID';
COMMENT ON COLUMN "public"."tb_user_points"."unit_id" IS '单位ID';
COMMENT ON COLUMN "public"."tb_user_points"."balance" IS '积分余额';
COMMENT ON COLUMN "public"."tb_user_points"."total_earned" IS '累计获取积分';
COMMENT ON COLUMN "public"."tb_user_points"."total_consumed" IS '累计消耗积分';
COMMENT ON COLUMN "public"."tb_user_points"."total_converted" IS '累计转换积分';
COMMENT ON COLUMN "public"."tb_user_points"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."tb_user_points"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."tb_user_points"."deleted" IS '逻辑删除：1-已删除，0-未删除';
COMMENT ON TABLE "public"."tb_user_points" IS '用户积分表';

-- ----------------------------
-- Records of tb_user_points
-- ----------------------------
INSERT INTO "public"."tb_user_points" OVERRIDING SYSTEM VALUE VALUES (1, '1', '1', 20000, 10000, 200, 0, '2025-08-07 11:48:21.574933', '2025-08-07 11:48:21.574933', 0);


-- ----------------------------
-- Indexes structure for table tb_cart
-- ----------------------------
CREATE INDEX "idx_cart_add_time" ON "public"."tb_cart" USING btree (
  "add_time" "pg_catalog"."timestamp_ops" ASC NULLS LAST,
  "deleted" "pg_catalog"."int4_ops" ASC NULLS LAST
);
CREATE INDEX "idx_cart_pricing" ON "public"."tb_cart" USING btree (
  "pricing_id" "pg_catalog"."int8_ops" ASC NULLS LAST,
  "deleted" "pg_catalog"."int4_ops" ASC NULLS LAST
);
CREATE INDEX "idx_cart_product" ON "public"."tb_cart" USING btree (
  "product_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "deleted" "pg_catalog"."int4_ops" ASC NULLS LAST
);
CREATE INDEX "idx_cart_provider" ON "public"."tb_cart" USING btree (
  "provider_id" "pg_catalog"."int8_ops" ASC NULLS LAST,
  "deleted" "pg_catalog"."int4_ops" ASC NULLS LAST
);
CREATE INDEX "idx_cart_user_unit" ON "public"."tb_cart" USING btree (
  "user_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "unit_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST,
  "deleted" "pg_catalog"."int4_ops" ASC NULLS LAST
);

-- ----------------------------
-- Uniques structure for table tb_cart
-- ----------------------------
ALTER TABLE "public"."tb_cart" ADD CONSTRAINT "cart_user_id_unit_id_pricing_id_deleted_key" UNIQUE ("user_id", "unit_id", "pricing_id", "deleted");

-- ----------------------------
-- Checks structure for table tb_cart
-- ----------------------------
ALTER TABLE "public"."tb_cart" ADD CONSTRAINT "cart_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));

-- ----------------------------
-- Primary Key structure for table tb_cart
-- ----------------------------
ALTER TABLE "public"."tb_cart" ADD CONSTRAINT "cart_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- Indexes structure for table tb_order_approval
-- ----------------------------
CREATE INDEX "idx_order_approval_approver_id" ON "public"."tb_order_approval" USING btree (
  "approver_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "idx_order_approval_order_id" ON "public"."tb_order_approval" USING btree (
  "order_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Checks structure for table tb_order_approval
-- ----------------------------
ALTER TABLE "public"."tb_order_approval" ADD CONSTRAINT "order_approval_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));
ALTER TABLE "public"."tb_order_approval" ADD CONSTRAINT "order_approval_approval_type_check" CHECK (approval_type = ANY (ARRAY['审批'::text, '授权'::text]));
ALTER TABLE "public"."tb_order_approval" ADD CONSTRAINT "order_approval_approval_result_check" CHECK (approval_result = ANY (ARRAY['通过'::text, '驳回'::text, '待处理'::text]));

-- ----------------------------
-- Primary Key structure for table tb_order_approval
-- ----------------------------
ALTER TABLE "public"."tb_order_approval" ADD CONSTRAINT "order_approval_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- Indexes structure for table tb_order_attachment
-- ----------------------------
CREATE INDEX "idx_order_attachment_order_id" ON "public"."tb_order_attachment" USING btree (
  "order_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Checks structure for table tb_order_attachment
-- ----------------------------
ALTER TABLE "public"."tb_order_attachment" ADD CONSTRAINT "order_attachment_attachment_type_check" CHECK (attachment_type = ANY (ARRAY['合同'::text, '发票'::text, '其他'::text]));
ALTER TABLE "public"."tb_order_attachment" ADD CONSTRAINT "order_attachment_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));

-- ----------------------------
-- Primary Key structure for table tb_order_attachment
-- ----------------------------
ALTER TABLE "public"."tb_order_attachment" ADD CONSTRAINT "order_attachment_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- Indexes structure for table tb_order_detail
-- ----------------------------
CREATE INDEX "idx_order_detail_order_id" ON "public"."tb_order_detail" USING btree (
  "order_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Checks structure for table tb_order_detail
-- ----------------------------
ALTER TABLE "public"."tb_order_detail" ADD CONSTRAINT "order_detail_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));

-- ----------------------------
-- Primary Key structure for table tb_order_detail
-- ----------------------------
ALTER TABLE "public"."tb_order_detail" ADD CONSTRAINT "order_detail_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- Indexes structure for table tb_order_evaluation
-- ----------------------------
CREATE INDEX "idx_order_evaluation_evaluator_id" ON "public"."tb_order_evaluation" USING btree (
  "evaluator_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "idx_order_evaluation_order_id" ON "public"."tb_order_evaluation" USING btree (
  "order_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Checks structure for table tb_order_evaluation
-- ----------------------------
ALTER TABLE "public"."tb_order_evaluation" ADD CONSTRAINT "order_evaluation_service_rating_check" CHECK (service_rating >= 1 AND service_rating <= 5);
ALTER TABLE "public"."tb_order_evaluation" ADD CONSTRAINT "order_evaluation_quality_rating_check" CHECK (quality_rating >= 1 AND quality_rating <= 5);
ALTER TABLE "public"."tb_order_evaluation" ADD CONSTRAINT "order_evaluation_delivery_rating_check" CHECK (delivery_rating >= 1 AND delivery_rating <= 5);
ALTER TABLE "public"."tb_order_evaluation" ADD CONSTRAINT "order_evaluation_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));
ALTER TABLE "public"."tb_order_evaluation" ADD CONSTRAINT "order_evaluation_evaluator_type_check" CHECK (evaluator_type = ANY (ARRAY['买家'::text, '卖家'::text]));
ALTER TABLE "public"."tb_order_evaluation" ADD CONSTRAINT "order_evaluation_rating_check" CHECK (rating >= 1 AND rating <= 5);

-- ----------------------------
-- Primary Key structure for table tb_order_evaluation
-- ----------------------------
ALTER TABLE "public"."tb_order_evaluation" ADD CONSTRAINT "order_evaluation_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- Indexes structure for table tb_order_info
-- ----------------------------
CREATE INDEX "idx_order_info_apply_time" ON "public"."tb_order_info" USING btree (
  "apply_time" "pg_catalog"."timestamp_ops" ASC NULLS LAST
);
CREATE INDEX "idx_order_info_provider_id" ON "public"."tb_order_info" USING btree (
  "provider_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_order_info_status" ON "public"."tb_order_info" USING btree (
  "order_status" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_order_info_user_id" ON "public"."tb_order_info" USING btree (
  "user_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Checks structure for table tb_order_info
-- ----------------------------
ALTER TABLE "public"."tb_order_info" ADD CONSTRAINT "order_info_payment_type_check" CHECK (payment_type = ANY (ARRAY['积分'::text, '货币'::text, '协议'::text]));
ALTER TABLE "public"."tb_order_info" ADD CONSTRAINT "order_info_payment_status_check" CHECK (payment_status = ANY (ARRAY['未支付'::text, '已支付'::text, '支付失败'::text, '已退款'::text]));
ALTER TABLE "public"."tb_order_info" ADD CONSTRAINT "order_info_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));
ALTER TABLE "public"."tb_order_info" ADD CONSTRAINT "order_info_order_status_check" CHECK (order_status = ANY (ARRAY['待审批'::text, '待审批授权'::text, '待授权'::text, '待上传文件'::text, '待交易确认'::text, '已完成'::text, '已取消'::text, '已驳回'::text]));

-- ----------------------------
-- Primary Key structure for table tb_order_info
-- ----------------------------
ALTER TABLE "public"."tb_order_info" ADD CONSTRAINT "order_info_pkey" PRIMARY KEY ("order_id");

-- ----------------------------
-- Checks structure for table tb_points
-- ----------------------------
ALTER TABLE "public"."tb_points" ADD CONSTRAINT "chk_deleted" CHECK (deleted = ANY (ARRAY[0, 1]));

-- ----------------------------
-- Primary Key structure for table tb_points
-- ----------------------------
ALTER TABLE "public"."tb_points" ADD CONSTRAINT "points_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- Indexes structure for table tb_points_account
-- ----------------------------
CREATE INDEX "idx_account_user" ON "public"."tb_points_account" USING btree (
  "user_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);

-- ----------------------------
-- Checks structure for table tb_points_account
-- ----------------------------
ALTER TABLE "public"."tb_points_account" ADD CONSTRAINT "chk_account_type" CHECK (account_type = ANY (ARRAY['个人积分'::text, '单位积分'::text]));
ALTER TABLE "public"."tb_points_account" ADD CONSTRAINT "chk_account_status" CHECK (account_status = ANY (ARRAY['正常'::text, '冻结'::text, '注销'::text]));
ALTER TABLE "public"."tb_points_account" ADD CONSTRAINT "chk_account_deleted" CHECK (deleted = ANY (ARRAY[0, 1]));

-- ----------------------------
-- Primary Key structure for table tb_points_account
-- ----------------------------
ALTER TABLE "public"."tb_points_account" ADD CONSTRAINT "points_account_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- Indexes structure for table tb_points_flow
-- ----------------------------
CREATE INDEX "idx_points_flow_data_category" ON "public"."tb_points_flow" USING btree (
  "data_category" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_points_flow_flow_time" ON "public"."tb_points_flow" USING btree (
  "flow_time" "pg_catalog"."timestamp_ops" ASC NULLS LAST
);
CREATE INDEX "idx_points_flow_unit_id" ON "public"."tb_points_flow" USING btree (
  "unit_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_points_flow_user_id" ON "public"."tb_points_flow" USING btree (
  "user_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table tb_points_flow
-- ----------------------------
ALTER TABLE "public"."tb_points_flow" ADD CONSTRAINT "points_flow_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- Indexes structure for table tb_points_rule
-- ----------------------------
CREATE INDEX "idx_points_rule_points" ON "public"."tb_points_rule" USING btree (
  "points_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "idx_points_rule_points_id" ON "public"."tb_points_rule" USING btree (
  "points_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "idx_points_rule_type" ON "public"."tb_points_rule" USING btree (
  "rule_type" "pg_catalog"."int2_ops" ASC NULLS LAST
);

-- ----------------------------
-- Checks structure for table tb_points_rule
-- ----------------------------
ALTER TABLE "public"."tb_points_rule" ADD CONSTRAINT "chk_rule_deleted" CHECK (deleted = ANY (ARRAY[0, 1]));
ALTER TABLE "public"."tb_points_rule" ADD CONSTRAINT "chk_category" CHECK (category::text = ANY (ARRAY['资源贡献'::text, '资源传播'::text, '资源交易'::text, '交流社区互动'::text]));

-- ----------------------------
-- Primary Key structure for table tb_points_rule
-- ----------------------------
ALTER TABLE "public"."tb_points_rule" ADD CONSTRAINT "points_rule_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- Indexes structure for table tb_points_transaction
-- ----------------------------
CREATE INDEX "idx_transaction_time" ON "public"."tb_points_transaction" USING btree (
  "transaction_time" "pg_catalog"."timestamptz_ops" ASC NULLS LAST
);
CREATE INDEX "idx_transaction_user" ON "public"."tb_points_transaction" USING btree (
  "user_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);

-- ----------------------------
-- Checks structure for table tb_points_transaction
-- ----------------------------
ALTER TABLE "public"."tb_points_transaction" ADD CONSTRAINT "chk_data_category" CHECK (data_category = ANY (ARRAY['用户参与'::text, '其他'::text]));
ALTER TABLE "public"."tb_points_transaction" ADD CONSTRAINT "chk_trans_rule_type" CHECK (rule_type = ANY (ARRAY['获取'::text, '消耗'::text]));
ALTER TABLE "public"."tb_points_transaction" ADD CONSTRAINT "chk_user_type" CHECK (user_type = ANY (ARRAY['单位用户'::text, '个人用户'::text]));
ALTER TABLE "public"."tb_points_transaction" ADD CONSTRAINT "chk_trans_deleted" CHECK (deleted = ANY (ARRAY[0, 1]));

-- ----------------------------
-- Primary Key structure for table tb_points_transaction
-- ----------------------------
ALTER TABLE "public"."tb_points_transaction" ADD CONSTRAINT "points_transaction_pkey" PRIMARY KEY ("id");


-- ----------------------------
-- Indexes structure for table tb_product_pricing
-- ----------------------------
CREATE INDEX "idx_product_pricing_product_id" ON "public"."tb_product_pricing" USING btree (
  "product_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_product_pricing_status" ON "public"."tb_product_pricing" USING btree (
  "is_active" "pg_catalog"."bool_ops" ASC NULLS LAST
);

-- ----------------------------
-- Checks structure for table tb_product_pricing
-- ----------------------------
ALTER TABLE "public"."tb_product_pricing" ADD CONSTRAINT "product_pricing_customer_type_check" CHECK (customer_type = ANY (ARRAY['企业'::text, '个人'::text, '项目部'::text]));
ALTER TABLE "public"."tb_product_pricing" ADD CONSTRAINT "product_pricing_price_unit_check" CHECK (price_unit = ANY (ARRAY['套'::text, '套/年'::text, '年'::text, '个'::text, '次'::text]));
ALTER TABLE "public"."tb_product_pricing" ADD CONSTRAINT "product_pricing_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));
ALTER TABLE "public"."tb_product_pricing" ADD CONSTRAINT "product_pricing_sales_form_check" CHECK (sales_form = ANY (ARRAY['买断'::text, '租赁'::text, '私有增包量'::text, '公有增包量'::text, 'OTA服务'::text, '资源包'::text, '个人'::text]));

-- ----------------------------
-- Primary Key structure for table tb_product_pricing
-- ----------------------------
ALTER TABLE "public"."tb_product_pricing" ADD CONSTRAINT "product_pricing_pkey" PRIMARY KEY ("id");

-- ----------------------------
-- Indexes structure for table tb_user_points
-- ----------------------------
CREATE INDEX "idx_user_points_unit_id" ON "public"."tb_user_points" USING btree (
  "unit_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);
CREATE INDEX "idx_user_points_user_id" ON "public"."tb_user_points" USING btree (
  "user_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table tb_user_points
-- ----------------------------
ALTER TABLE "public"."tb_user_points" ADD CONSTRAINT "user_points_pkey" PRIMARY KEY ("id");


-- ----------------------------
-- Foreign Keys structure for table tb_cart
-- ----------------------------
ALTER TABLE "public"."tb_cart" ADD CONSTRAINT "cart_pricing_id_fkey" FOREIGN KEY ("pricing_id") REFERENCES "public"."tb_product_pricing" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table tb_order_approval
-- ----------------------------
ALTER TABLE "public"."tb_order_approval" ADD CONSTRAINT "order_approval_order_id_fkey" FOREIGN KEY ("order_id") REFERENCES "public"."tb_order_info" ("order_id") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table tb_order_attachment
-- ----------------------------
ALTER TABLE "public"."tb_order_attachment" ADD CONSTRAINT "order_attachment_order_id_fkey" FOREIGN KEY ("order_id") REFERENCES "public"."tb_order_info" ("order_id") ON DELETE NO ACTION ON UPDATE NO ACTION;
-- ----------------------------
-- Foreign Keys structure for table tb_order_detail
-- ----------------------------
ALTER TABLE "public"."tb_order_detail" ADD CONSTRAINT "order_detail_order_id_fkey" FOREIGN KEY ("order_id") REFERENCES "public"."tb_order_info" ("order_id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "public"."tb_order_detail" ADD CONSTRAINT "order_detail_pricing_id_fkey" FOREIGN KEY ("pricing_id") REFERENCES "public"."tb_product_pricing" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table tb_order_evaluation
-- ----------------------------
ALTER TABLE "public"."tb_order_evaluation" ADD CONSTRAINT "order_evaluation_order_id_fkey" FOREIGN KEY ("order_id") REFERENCES "public"."tb_order_info" ("order_id") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table tb_points_rule
-- ----------------------------
ALTER TABLE "public"."tb_points_rule" ADD CONSTRAINT "fk_points" FOREIGN KEY ("points_id") REFERENCES "public"."tb_points" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

-- ----------------------------
-- Foreign Keys structure for table tb_points_transaction
-- ----------------------------
ALTER TABLE "public"."tb_points_transaction" ADD CONSTRAINT "fk_rule_id" FOREIGN KEY ("rule_id") REFERENCES "public"."tb_points_rule" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

