p-honggang.li
2025-08-18 1b1248f500a49f11f12c3cf9b469c300430b4514
Merge branch 'master' of http://xearth.cn:6600/r/web-manage/web-manage-back

 Conflicts:
 src/main/java/com/webmanage/vo/PointsRuleVO.java
7个文件已删除
15个文件已修改
1285 ■■■■ 已修改文件
sql/public.sql 495 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/controller/PointsController.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/dto/AddPointsFlowDTO.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/dto/PointsFlowQueryDTO.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/dto/PointsRuleDTO.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/dto/PointsRuleDetailDTO.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/emun/RuleTypeEnum.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/entity/PointsFlow.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/entity/PointsRule.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/entity/PointsRuleDetail.java 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/entity/PointsRuleEntity.java 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/mapper/PointsFlowMapper.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/mapper/PointsRuleDetailMapper.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/mapper/PointsRuleMapper.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/service/PointsFlowService.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/service/PointsRuleDetailService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/service/PointsRuleService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/service/impl/PointsFlowServiceImpl.java 219 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/service/impl/PointsRuleDetailServiceImpl.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/service/impl/PointsRuleServiceImpl.java 78 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/webmanage/vo/PointsRuleVO.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/PointsFlowMapper.xml 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sql/public.sql
@@ -1,18 +1,18 @@
/*
 Navicat Premium Data Transfer
 Source Server         : local
 Source Server         : pgSQL
 Source Server Type    : PostgreSQL
 Source Server Version : 110005
 Source Server Version : 130000
 Source Host           : localhost:5432
 Source Catalog        : web_manage
 Source Schema         : public
 Target Server Type    : PostgreSQL
 Target Server Version : 110005
 Target Server Version : 130000
 File Encoding         : 65001
 Date: 14/08/2025 19:19:38
 Date: 15/08/2025 19:07:13
*/
@@ -21,6 +21,17 @@
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."cart_id_seq";
CREATE SEQUENCE "public"."cart_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for cart_id_seq1
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."cart_id_seq1";
CREATE SEQUENCE "public"."cart_id_seq1"
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
@@ -39,10 +50,32 @@
CACHE 1;
-- ----------------------------
-- Sequence structure for order_approval_id_seq1
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."order_approval_id_seq1";
CREATE SEQUENCE "public"."order_approval_id_seq1"
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for order_attachment_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."order_attachment_id_seq";
CREATE SEQUENCE "public"."order_attachment_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for order_attachment_id_seq1
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."order_attachment_id_seq1";
CREATE SEQUENCE "public"."order_attachment_id_seq1"
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
@@ -61,10 +94,32 @@
CACHE 1;
-- ----------------------------
-- Sequence structure for order_detail_id_seq1
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."order_detail_id_seq1";
CREATE SEQUENCE "public"."order_detail_id_seq1"
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for order_evaluation_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."order_evaluation_id_seq";
CREATE SEQUENCE "public"."order_evaluation_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for order_evaluation_id_seq1
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."order_evaluation_id_seq1";
CREATE SEQUENCE "public"."order_evaluation_id_seq1"
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
@@ -105,17 +160,6 @@
CACHE 1;
-- ----------------------------
-- Sequence structure for points_rule_detail_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."points_rule_detail_id_seq";
CREATE SEQUENCE "public"."points_rule_detail_id_seq"
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for points_rule_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."points_rule_id_seq";
@@ -149,6 +193,17 @@
CACHE 1;
-- ----------------------------
-- Sequence structure for product_id_seq1
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."product_id_seq1";
CREATE SEQUENCE "public"."product_id_seq1"
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for product_pricing_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."product_pricing_id_seq";
@@ -160,10 +215,32 @@
CACHE 1;
-- ----------------------------
-- Sequence structure for product_pricing_id_seq1
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."product_pricing_id_seq1";
CREATE SEQUENCE "public"."product_pricing_id_seq1"
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for unit_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."unit_id_seq";
CREATE SEQUENCE "public"."unit_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for unit_id_seq1
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."unit_id_seq1";
CREATE SEQUENCE "public"."unit_id_seq1"
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
@@ -186,6 +263,17 @@
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."users_id_seq";
CREATE SEQUENCE "public"."users_id_seq" 
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for users_id_seq1
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."users_id_seq1";
CREATE SEQUENCE "public"."users_id_seq1"
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
@@ -443,6 +531,7 @@
-- Records of points
-- ----------------------------
INSERT INTO "public"."points" 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"."points" 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 points_account
@@ -487,13 +576,14 @@
  "user_id" int8,
  "unit_id" int8,
  "data_category" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
  "data_type" varchar(50) 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
  "deleted" int4 DEFAULT 0,
  "rule_id" int4
)
;
COMMENT ON COLUMN "public"."points_flow"."user_id" IS '用户ID';
@@ -506,22 +596,23 @@
COMMENT ON COLUMN "public"."points_flow"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."points_flow"."update_time" IS '更新时间';
COMMENT ON COLUMN "public"."points_flow"."deleted" IS '逻辑删除:1-已删除,0-未删除';
COMMENT ON COLUMN "public"."points_flow"."rule_id" IS '规则ID';
COMMENT ON TABLE "public"."points_flow" IS '积分流水表';
-- ----------------------------
-- Records of points_flow
-- ----------------------------
INSERT INTO "public"."points_flow" VALUES (1, 1, 1, 'user_participation', 'earned', '用户每日首次登录', 1, '2025-05-18 16:00:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0);
INSERT INTO "public"."points_flow" VALUES (2, 1, 1, 'user_participation', 'earned', '交流社区发布评论"基建行业如何利用AI技术提高效率"', 1, '2025-05-17 15:00:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0);
INSERT INTO "public"."points_flow" VALUES (3, 1, 1, 'user_participation', 'earned', '用户每日首次登录', 1, '2025-05-16 14:00:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0);
INSERT INTO "public"."points_flow" VALUES (4, 1, 1, 'user_participation', 'consumed', '交流社区删除提问"基建项目如何应用数字孪生技术?"', -1, '2025-05-15 13:00:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0);
INSERT INTO "public"."points_flow" VALUES (5, 1, 1, 'points_conversion', 'earned', '单位积分转入', 1000, '2025-05-06 12:00:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0);
INSERT INTO "public"."points_flow" VALUES (6, 1, 1, 'user_participation', 'earned', '用户每日首次登录', 1, '2025-05-05 11:00:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0);
INSERT INTO "public"."points_flow" VALUES (7, 1, 1, 'other', 'earned', '积分奖励', 100, '2025-05-04 10:00:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0);
INSERT INTO "public"."points_flow" VALUES (8, 1, 1, 'user_participation', 'earned', '交流社区发布提问"基建项目如何应用数字孪生技术?"', 1, '2025-05-02 09:10:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0);
INSERT INTO "public"."points_flow" VALUES (9, 1, 1, 'user_participation', 'earned', '用户每日首次登录', 1, '2025-05-02 09:02:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0);
INSERT INTO "public"."points_flow" VALUES (10, 1, 1, 'other', 'earned', '初始化积分', 100, '2025-05-01 09:01:00', '2025-08-07 11:48:21.579058', '2025-08-07 11:48:21.579058', 0);
INSERT INTO "public"."points_flow" VALUES (17, 1, 1, 'other', 'earned', '积分奖励', 100, '2025-08-08 18:34:36', '2025-08-08 18:34:39', '2025-08-08 18:34:41', 0);
INSERT INTO "public"."points_flow" 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"."points_flow" 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"."points_flow" 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"."points_flow" 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"."points_flow" 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"."points_flow" 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"."points_flow" 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"."points_flow" 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"."points_flow" 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"."points_flow" 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"."points_flow" 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 points_rule
@@ -540,7 +631,10 @@
  "deleted" int2 DEFAULT 0,
  "points_winner" int2,
  "is_limit" int2,
  "rule_order" 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"."points_rule"."points_id" IS '关联积分ID';
@@ -555,80 +649,76 @@
COMMENT ON COLUMN "public"."points_rule"."points_winner" IS '积分获得者(0贡献者1用户)';
COMMENT ON COLUMN "public"."points_rule"."is_limit" IS '积分是否有上限(0没有1有)';
COMMENT ON COLUMN "public"."points_rule"."rule_order" IS '排序规则';
COMMENT ON COLUMN "public"."points_rule"."points_value" IS '积分值';
COMMENT ON COLUMN "public"."points_rule"."daily_limit" IS '积分日上限';
COMMENT ON COLUMN "public"."points_rule"."rule_name_code" IS '规则名称编码';
COMMENT ON TABLE "public"."points_rule" IS '积分规则表';
-- ----------------------------
-- Records of points_rule
-- ----------------------------
INSERT INTO "public"."points_rule" VALUES (2, 1, 0, '资源贡献', '新增数字化标杆', '每成功上架1个标杆,贡献者 获', 0, '2025-08-14 14:24:00.753678', '2025-08-14 14:24:00.753678', 0, 0, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (4, 1, 0, '资源贡献', '新增数字化产品', '每成功上架1个产品,贡献者 获', 0, '2025-08-14 14:44:37.128422', '2025-08-14 14:44:37.128422', 0, 0, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (34, 1, 0, '交流社区互动', '回复帖子', '每回复1次帖子,贡献者 获', 0, '2025-08-14 15:08:19.324645', '2025-08-14 15:08:19.324645', 0, 0, 1, NULL);
INSERT INTO "public"."points_rule" VALUES (35, 1, 0, '交流社区互动', '帖子点赞', '发布的帖子或做出的回答每被点赞一次,贡献者 获', 0, '2025-08-14 15:08:19.325826', '2025-08-14 15:08:19.325826', 0, 0, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (3, 1, 0, '资源贡献', '新增数字化知识', '每成功上架1个知识,贡献者 获', 0, '2025-08-14 14:44:37.124901', '2025-08-14 14:44:37.124901', 0, 0, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (36, 1, 0, '交流社区互动', '帖子收藏', '发布的帖子每被收藏一次,贡献者 获', 0, '2025-08-14 15:08:19.326955', '2025-08-14 15:08:19.326955', 0, 0, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (52, 1, 1, '交流社区互动', '取消收藏', '发布的帖子被收藏,后又取消收藏,贡献者 扣除', 0, '2025-08-14 15:15:13.333528', '2025-08-14 15:15:13.333528', 0, 0, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (49, 1, 1, '交流社区互动', '删除帖子', '自己发布的帖子被删除,贡献者 扣除', 0, '2025-08-14 15:15:13.330326', '2025-08-14 15:15:13.330326', 0, 0, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (50, 1, 1, '交流社区互动', '删除回复', '自己的回复被删除,贡献者 扣除', 0, '2025-08-14 15:15:13.331467', '2025-08-14 15:15:13.331467', 0, 0, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (11, 1, 0, '资源传播', '评价数字化资源', '每被评价1次,贡献者 获', 0, '2025-08-14 15:07:54.732016', '2025-08-14 15:07:54.732016', 0, 0, 1, NULL);
INSERT INTO "public"."points_rule" VALUES (12, 1, 0, '资源传播', '评价数字化资源', '评价者 获', 0, '2025-08-14 15:07:54.733588', '2025-08-14 15:07:54.733588', 0, 1, 1, NULL);
INSERT INTO "public"."points_rule" VALUES (51, 1, 1, '交流社区互动', '取消点赞', '发布的帖子或做出的回答被点赞后又取消点赞,贡献者 扣除', 0, '2025-08-14 15:15:13.332602', '2025-08-14 15:15:13.332602', 0, 0, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (15, 1, 0, '资源传播', '订阅数字化资源', '每被订阅1次,贡献者 获', 0, '2025-08-14 15:07:54.736641', '2025-08-14 15:07:54.736641', 0, 0, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (16, 1, 0, '资源传播', '订阅数字化资源', '订阅者 获', 0, '2025-08-14 15:07:54.737529', '2025-08-14 15:07:54.737529', 0, 1, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (17, 1, 0, '资源交易', '数字化产品接入', '每成功接入1次,贡献者 获', 0, '2025-08-14 15:07:54.738396', '2025-08-14 15:07:54.738396', 0, 0, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (18, 1, 0, '资源交易', '数字化产品交易', '每成功交易1次,贡献者 获', 0, '2025-08-14 15:07:54.739469', '2025-08-14 15:07:54.739469', 0, 0, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (20, 1, 0, '资源传播', '浏览数字化资源', '浏览者', 0, '2025-08-14 15:08:19.309681', '2025-08-14 15:08:19.309681', 0, 1, 1, NULL);
INSERT INTO "public"."points_rule" VALUES (21, 1, 0, '资源传播', '收藏数字化资源', '每被收藏1次,贡献者 获', 0, '2025-08-14 15:08:19.311096', '2025-08-14 15:08:19.311096', 0, 0, 1, NULL);
INSERT INTO "public"."points_rule" VALUES (33, 1, 0, '交流社区互动', '发布帖子', '每成功发布1次,贡献者 获', 0, '2025-08-14 15:08:19.323293', '2025-08-14 15:08:19.323293', 0, 0, 1, NULL);
INSERT INTO "public"."points_rule" VALUES (42, 1, 1, '资源传播', '取消订阅', '操作者 扣除', 0, '2025-08-14 15:12:29.49397', '2025-08-14 15:12:29.49397', 0, 1, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (43, 1, 1, '资源传播', '取消收藏', '数字化资源被取消收藏,贡献者 扣除', 0, '2025-08-14 15:15:13.324114', '2025-08-14 15:15:13.324114', 0, 0, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (44, 1, 1, '资源传播', '取消收藏', '操作者 扣除', 0, '2025-08-14 15:15:13.325517', '2025-08-14 15:15:13.325517', 0, 1, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (22, 1, 0, '资源传播', '收藏数字化资源', '收藏者 获', 0, '2025-08-14 15:08:19.312482', '2025-08-14 15:08:19.312482', 0, 1, 1, NULL);
INSERT INTO "public"."points_rule" VALUES (23, 1, 0, '资源传播', '点赞数字化资源', '每被点赞1次,贡献者 获', 0, '2025-08-14 15:08:19.313654', '2025-08-14 15:08:19.313654', 0, 0, 1, NULL);
INSERT INTO "public"."points_rule" VALUES (24, 1, 0, '资源传播', '点赞数字化资源', '点赞者 获', 0, '2025-08-14 15:08:19.314647', '2025-08-14 15:08:19.314647', 0, 1, 1, NULL);
INSERT INTO "public"."points_rule" VALUES (28, 1, 0, '资源传播', '试用数字化资源', '试用者 获', 0, '2025-08-14 15:08:19.318477', '2025-08-14 15:08:19.318477', 0, 1, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (39, 1, 1, '资源传播', '取消点赞', '数字化资源被取消点赞,贡献者 扣除', 0, '2025-08-14 15:12:29.490075', '2025-08-14 15:12:29.490075', 0, 0, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (40, 1, 1, '资源传播', '取消点赞', '操作者 扣除', 0, '2025-08-14 15:12:29.49113', '2025-08-14 15:12:29.49113', 0, 1, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (41, 1, 1, '资源传播', '取消订阅', '数字化产品被取消订阅,贡献者 扣除', 0, '2025-08-14 15:12:29.492296', '2025-08-14 15:12:29.492296', 0, 0, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (13, 1, 0, '资源传播', '试用数字化资源', '每被试用1次,贡献者 获', 0, '2025-08-14 15:07:54.734444', '2025-08-14 15:07:54.734444', 0, 0, 0, NULL);
INSERT INTO "public"."points_rule" VALUES (19, 1, 0, '资源传播', '浏览数字化资源', '每被浏览1次,贡献者', 0, '2025-08-14 15:08:19.308203', '2025-08-14 15:08:19.308203', 0, 0, 1, NULL);
-- ----------------------------
-- Table structure for points_rule_detail
-- ----------------------------
DROP TABLE IF EXISTS "public"."points_rule_detail";
CREATE TABLE "public"."points_rule_detail" (
  "id" int8 NOT NULL DEFAULT nextval('points_rule_detail_id_seq'::regclass),
  "rule_id" int8 NOT NULL,
  "points_id" int8 NOT NULL,
  "points_value" int4 NOT NULL,
  "daily_limit" int4,
  "monthly_limit" int4,
  "yearly_limit" int4,
  "min_value" int4 DEFAULT 0,
  "max_value" int4,
  "conversion_rate" numeric(10,4) DEFAULT 1.0,
  "created_at" timestamptz(6) DEFAULT CURRENT_TIMESTAMP,
  "updated_at" timestamptz(6) DEFAULT CURRENT_TIMESTAMP,
  "deleted" int2 DEFAULT 0
)
;
COMMENT ON COLUMN "public"."points_rule_detail"."rule_id" IS '关联积分规则ID';
COMMENT ON COLUMN "public"."points_rule_detail"."points_id" IS '关联积分ID';
COMMENT ON COLUMN "public"."points_rule_detail"."points_value" IS '积分值';
COMMENT ON COLUMN "public"."points_rule_detail"."daily_limit" IS '每日积分上限值';
COMMENT ON COLUMN "public"."points_rule_detail"."monthly_limit" IS '每月积分上限值';
COMMENT ON COLUMN "public"."points_rule_detail"."yearly_limit" IS '每年积分上限值';
COMMENT ON COLUMN "public"."points_rule_detail"."min_value" IS '最小值';
COMMENT ON COLUMN "public"."points_rule_detail"."max_value" IS '最大值';
COMMENT ON COLUMN "public"."points_rule_detail"."conversion_rate" IS '转换比率';
COMMENT ON COLUMN "public"."points_rule_detail"."created_at" IS '创建时间';
COMMENT ON COLUMN "public"."points_rule_detail"."updated_at" IS '更新时间';
COMMENT ON COLUMN "public"."points_rule_detail"."deleted" IS '逻辑删除';
COMMENT ON TABLE "public"."points_rule_detail" IS '积分规则详情表';
-- ----------------------------
-- Records of points_rule_detail
-- ----------------------------
INSERT INTO "public"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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"."points_rule" 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 points_transaction
@@ -861,112 +951,168 @@
-- ----------------------------
ALTER SEQUENCE "public"."cart_id_seq"
OWNED BY "public"."cart"."id";
SELECT setval('"public"."cart_id_seq"', 2, false);
SELECT setval('"public"."cart_id_seq"', 3, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."cart_id_seq1"
OWNED BY "public"."cart"."id";
SELECT setval('"public"."cart_id_seq1"', 2, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."order_approval_id_seq"
OWNED BY "public"."order_approval"."id";
SELECT setval('"public"."order_approval_id_seq"', 2, false);
SELECT setval('"public"."order_approval_id_seq"', 3, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."order_approval_id_seq1"
OWNED BY "public"."order_approval"."id";
SELECT setval('"public"."order_approval_id_seq1"', 2, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."order_attachment_id_seq"
OWNED BY "public"."order_attachment"."id";
SELECT setval('"public"."order_attachment_id_seq"', 2, false);
SELECT setval('"public"."order_attachment_id_seq"', 3, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."order_attachment_id_seq1"
OWNED BY "public"."order_attachment"."id";
SELECT setval('"public"."order_attachment_id_seq1"', 2, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."order_detail_id_seq"
OWNED BY "public"."order_detail"."id";
SELECT setval('"public"."order_detail_id_seq"', 2, false);
SELECT setval('"public"."order_detail_id_seq"', 3, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."order_detail_id_seq1"
OWNED BY "public"."order_detail"."id";
SELECT setval('"public"."order_detail_id_seq1"', 2, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."order_evaluation_id_seq"
OWNED BY "public"."order_evaluation"."id";
SELECT setval('"public"."order_evaluation_id_seq"', 2, false);
SELECT setval('"public"."order_evaluation_id_seq"', 3, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."order_evaluation_id_seq1"
OWNED BY "public"."order_evaluation"."id";
SELECT setval('"public"."order_evaluation_id_seq1"', 2, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."points_account_id_seq"
OWNED BY "public"."points_account"."id";
SELECT setval('"public"."points_account_id_seq"', 2, false);
SELECT setval('"public"."points_account_id_seq"', 3, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."points_flow_id_seq"
OWNED BY "public"."points_flow"."id";
SELECT setval('"public"."points_flow_id_seq"', 18, true);
SELECT setval('"public"."points_flow_id_seq"', 19, true);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."points_id_seq"
OWNED BY "public"."points"."id";
SELECT setval('"public"."points_id_seq"', 2, true);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."points_rule_detail_id_seq"
OWNED BY "public"."points_rule_detail"."id";
SELECT setval('"public"."points_rule_detail_id_seq"', 2, false);
SELECT setval('"public"."points_id_seq"', 7, true);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."points_rule_id_seq"
OWNED BY "public"."points_rule"."id";
SELECT setval('"public"."points_rule_id_seq"', 53, true);
SELECT setval('"public"."points_rule_id_seq"', 85, true);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."points_transaction_id_seq"
OWNED BY "public"."points_transaction"."id";
SELECT setval('"public"."points_transaction_id_seq"', 2, false);
SELECT setval('"public"."points_transaction_id_seq"', 3, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."product_id_seq"
OWNED BY "public"."product"."id";
SELECT setval('"public"."product_id_seq"', 3, true);
SELECT setval('"public"."product_id_seq"', 4, true);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."product_id_seq1"
OWNED BY "public"."product"."id";
SELECT setval('"public"."product_id_seq1"', 2, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."product_pricing_id_seq"
OWNED BY "public"."product_pricing"."id";
SELECT setval('"public"."product_pricing_id_seq"', 4, true);
SELECT setval('"public"."product_pricing_id_seq"', 5, true);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."product_pricing_id_seq1"
OWNED BY "public"."product_pricing"."id";
SELECT setval('"public"."product_pricing_id_seq1"', 2, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."unit_id_seq"
OWNED BY "public"."unit"."id";
SELECT setval('"public"."unit_id_seq"', 3, true);
SELECT setval('"public"."unit_id_seq"', 4, true);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."unit_id_seq1"
OWNED BY "public"."unit"."id";
SELECT setval('"public"."unit_id_seq1"', 2, false);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."user_points_id_seq"
OWNED BY "public"."user_points"."id";
SELECT setval('"public"."user_points_id_seq"', 2, true);
SELECT setval('"public"."user_points_id_seq"', 3, true);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."users_id_seq"
OWNED BY "public"."users"."id";
SELECT setval('"public"."users_id_seq"', 4, true);
SELECT setval('"public"."users_id_seq"', 5, true);
-- ----------------------------
-- Alter sequences owned by
-- ----------------------------
ALTER SEQUENCE "public"."users_id_seq1"
OWNED BY "public"."users"."id";
SELECT setval('"public"."users_id_seq1"', 2, false);
-- ----------------------------
-- Indexes structure for table cart
@@ -1001,7 +1147,7 @@
-- ----------------------------
-- Checks structure for table cart
-- ----------------------------
ALTER TABLE "public"."cart" ADD CONSTRAINT "cart_deleted_check" CHECK ((deleted = ANY (ARRAY[0, 1])));
ALTER TABLE "public"."cart" ADD CONSTRAINT "cart_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));
-- ----------------------------
-- Primary Key structure for table cart
@@ -1021,9 +1167,9 @@
-- ----------------------------
-- Checks structure for table order_approval
-- ----------------------------
ALTER TABLE "public"."order_approval" ADD CONSTRAINT "order_approval_approval_result_check" CHECK ((approval_result = ANY (ARRAY['通过'::text, '驳回'::text, '待处理'::text])));
ALTER TABLE "public"."order_approval" ADD CONSTRAINT "order_approval_deleted_check" CHECK ((deleted = ANY (ARRAY[0, 1])));
ALTER TABLE "public"."order_approval" ADD CONSTRAINT "order_approval_approval_type_check" CHECK ((approval_type = ANY (ARRAY['审批'::text, '授权'::text])));
ALTER TABLE "public"."order_approval" ADD CONSTRAINT "order_approval_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));
ALTER TABLE "public"."order_approval" ADD CONSTRAINT "order_approval_approval_type_check" CHECK (approval_type = ANY (ARRAY['审批'::text, '授权'::text]));
ALTER TABLE "public"."order_approval" ADD CONSTRAINT "order_approval_approval_result_check" CHECK (approval_result = ANY (ARRAY['通过'::text, '驳回'::text, '待处理'::text]));
-- ----------------------------
-- Primary Key structure for table order_approval
@@ -1040,8 +1186,8 @@
-- ----------------------------
-- Checks structure for table order_attachment
-- ----------------------------
ALTER TABLE "public"."order_attachment" ADD CONSTRAINT "order_attachment_attachment_type_check" CHECK ((attachment_type = ANY (ARRAY['合同'::text, '发票'::text, '其他'::text])));
ALTER TABLE "public"."order_attachment" ADD CONSTRAINT "order_attachment_deleted_check" CHECK ((deleted = ANY (ARRAY[0, 1])));
ALTER TABLE "public"."order_attachment" ADD CONSTRAINT "order_attachment_attachment_type_check" CHECK (attachment_type = ANY (ARRAY['合同'::text, '发票'::text, '其他'::text]));
ALTER TABLE "public"."order_attachment" ADD CONSTRAINT "order_attachment_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));
-- ----------------------------
-- Primary Key structure for table order_attachment
@@ -1058,7 +1204,7 @@
-- ----------------------------
-- Checks structure for table order_detail
-- ----------------------------
ALTER TABLE "public"."order_detail" ADD CONSTRAINT "order_detail_deleted_check" CHECK ((deleted = ANY (ARRAY[0, 1])));
ALTER TABLE "public"."order_detail" ADD CONSTRAINT "order_detail_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));
-- ----------------------------
-- Primary Key structure for table order_detail
@@ -1078,12 +1224,12 @@
-- ----------------------------
-- Checks structure for table order_evaluation
-- ----------------------------
ALTER TABLE "public"."order_evaluation" ADD CONSTRAINT "order_evaluation_rating_check" CHECK (((rating >= 1) AND (rating <= 5)));
ALTER TABLE "public"."order_evaluation" ADD CONSTRAINT "order_evaluation_service_rating_check" CHECK (((service_rating >= 1) AND (service_rating <= 5)));
ALTER TABLE "public"."order_evaluation" ADD CONSTRAINT "order_evaluation_quality_rating_check" CHECK (((quality_rating >= 1) AND (quality_rating <= 5)));
ALTER TABLE "public"."order_evaluation" ADD CONSTRAINT "order_evaluation_delivery_rating_check" CHECK (((delivery_rating >= 1) AND (delivery_rating <= 5)));
ALTER TABLE "public"."order_evaluation" ADD CONSTRAINT "order_evaluation_deleted_check" CHECK ((deleted = ANY (ARRAY[0, 1])));
ALTER TABLE "public"."order_evaluation" ADD CONSTRAINT "order_evaluation_evaluator_type_check" CHECK ((evaluator_type = ANY (ARRAY['买家'::text, '卖家'::text])));
ALTER TABLE "public"."order_evaluation" ADD CONSTRAINT "order_evaluation_service_rating_check" CHECK (service_rating >= 1 AND service_rating <= 5);
ALTER TABLE "public"."order_evaluation" ADD CONSTRAINT "order_evaluation_quality_rating_check" CHECK (quality_rating >= 1 AND quality_rating <= 5);
ALTER TABLE "public"."order_evaluation" ADD CONSTRAINT "order_evaluation_delivery_rating_check" CHECK (delivery_rating >= 1 AND delivery_rating <= 5);
ALTER TABLE "public"."order_evaluation" ADD CONSTRAINT "order_evaluation_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));
ALTER TABLE "public"."order_evaluation" ADD CONSTRAINT "order_evaluation_evaluator_type_check" CHECK (evaluator_type = ANY (ARRAY['买家'::text, '卖家'::text]));
ALTER TABLE "public"."order_evaluation" ADD CONSTRAINT "order_evaluation_rating_check" CHECK (rating >= 1 AND rating <= 5);
-- ----------------------------
-- Primary Key structure for table order_evaluation
@@ -1109,10 +1255,10 @@
-- ----------------------------
-- Checks structure for table order_info
-- ----------------------------
ALTER TABLE "public"."order_info" ADD CONSTRAINT "order_info_payment_type_check" CHECK ((payment_type = ANY (ARRAY['积分'::text, '货币'::text, '协议'::text])));
ALTER TABLE "public"."order_info" ADD CONSTRAINT "order_info_payment_status_check" CHECK ((payment_status = ANY (ARRAY['未支付'::text, '已支付'::text, '支付失败'::text, '已退款'::text])));
ALTER TABLE "public"."order_info" ADD CONSTRAINT "order_info_deleted_check" CHECK ((deleted = ANY (ARRAY[0, 1])));
ALTER TABLE "public"."order_info" ADD CONSTRAINT "order_info_order_status_check" CHECK ((order_status = ANY (ARRAY['待审批'::text, '待审批授权'::text, '待授权'::text, '待上传文件'::text, '待交易确认'::text, '已完成'::text, '已取消'::text, '已驳回'::text])));
ALTER TABLE "public"."order_info" ADD CONSTRAINT "order_info_payment_status_check" CHECK (payment_status = ANY (ARRAY['未支付'::text, '已支付'::text, '支付失败'::text, '已退款'::text]));
ALTER TABLE "public"."order_info" ADD CONSTRAINT "order_info_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));
ALTER TABLE "public"."order_info" ADD CONSTRAINT "order_info_order_status_check" CHECK (order_status = ANY (ARRAY['待审批'::text, '待审批授权'::text, '待授权'::text, '待上传文件'::text, '待交易确认'::text, '已完成'::text, '已取消'::text, '已驳回'::text]));
ALTER TABLE "public"."order_info" ADD CONSTRAINT "order_info_payment_type_check" CHECK (payment_type = ANY (ARRAY['积分'::text, '货币'::text, '协议'::text]));
-- ----------------------------
-- Primary Key structure for table order_info
@@ -1122,7 +1268,7 @@
-- ----------------------------
-- Checks structure for table points
-- ----------------------------
ALTER TABLE "public"."points" ADD CONSTRAINT "chk_deleted" CHECK ((deleted = ANY (ARRAY[0, 1])));
ALTER TABLE "public"."points" ADD CONSTRAINT "chk_deleted" CHECK (deleted = ANY (ARRAY[0, 1]));
-- ----------------------------
-- Primary Key structure for table points
@@ -1139,9 +1285,9 @@
-- ----------------------------
-- Checks structure for table points_account
-- ----------------------------
ALTER TABLE "public"."points_account" ADD CONSTRAINT "chk_account_type" CHECK ((account_type = ANY (ARRAY['个人积分'::text, '单位积分'::text])));
ALTER TABLE "public"."points_account" ADD CONSTRAINT "chk_account_status" CHECK ((account_status = ANY (ARRAY['正常'::text, '冻结'::text, '注销'::text])));
ALTER TABLE "public"."points_account" ADD CONSTRAINT "chk_account_deleted" CHECK ((deleted = ANY (ARRAY[0, 1])));
ALTER TABLE "public"."points_account" ADD CONSTRAINT "chk_account_type" CHECK (account_type = ANY (ARRAY['个人积分'::text, '单位积分'::text]));
ALTER TABLE "public"."points_account" ADD CONSTRAINT "chk_account_status" CHECK (account_status = ANY (ARRAY['正常'::text, '冻结'::text, '注销'::text]));
ALTER TABLE "public"."points_account" ADD CONSTRAINT "chk_account_deleted" CHECK (deleted = ANY (ARRAY[0, 1]));
-- ----------------------------
-- Primary Key structure for table points_account
@@ -1185,33 +1331,13 @@
-- ----------------------------
-- Checks structure for table points_rule
-- ----------------------------
ALTER TABLE "public"."points_rule" ADD CONSTRAINT "chk_rule_deleted" CHECK ((deleted = ANY (ARRAY[0, 1])));
ALTER TABLE "public"."points_rule" ADD CONSTRAINT "chk_category" CHECK (((category)::text = ANY (ARRAY['资源贡献'::text, '资源传播'::text, '资源交易'::text, '交流社区互动'::text])));
ALTER TABLE "public"."points_rule" ADD CONSTRAINT "chk_rule_deleted" CHECK (deleted = ANY (ARRAY[0, 1]));
ALTER TABLE "public"."points_rule" ADD CONSTRAINT "chk_category" CHECK (category::text = ANY (ARRAY['资源贡献'::text, '资源传播'::text, '资源交易'::text, '交流社区互动'::text]));
-- ----------------------------
-- Primary Key structure for table points_rule
-- ----------------------------
ALTER TABLE "public"."points_rule" ADD CONSTRAINT "points_rule_pkey" PRIMARY KEY ("id");
-- ----------------------------
-- Indexes structure for table points_rule_detail
-- ----------------------------
CREATE INDEX "idx_points_detail_rule" ON "public"."points_rule_detail" USING btree (
  "rule_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE INDEX "idx_points_rule_detail_rule_id" ON "public"."points_rule_detail" USING btree (
  "rule_id" "pg_catalog"."int8_ops" ASC NULLS LAST
);
-- ----------------------------
-- Checks structure for table points_rule_detail
-- ----------------------------
ALTER TABLE "public"."points_rule_detail" ADD CONSTRAINT "chk_detail_deleted" CHECK ((deleted = ANY (ARRAY[0, 1])));
-- ----------------------------
-- Primary Key structure for table points_rule_detail
-- ----------------------------
ALTER TABLE "public"."points_rule_detail" ADD CONSTRAINT "points_rule_detail_pkey" PRIMARY KEY ("id");
-- ----------------------------
-- Indexes structure for table points_transaction
@@ -1226,10 +1352,10 @@
-- ----------------------------
-- Checks structure for table points_transaction
-- ----------------------------
ALTER TABLE "public"."points_transaction" ADD CONSTRAINT "chk_data_category" CHECK ((data_category = ANY (ARRAY['用户参与'::text, '其他'::text])));
ALTER TABLE "public"."points_transaction" ADD CONSTRAINT "chk_trans_rule_type" CHECK ((rule_type = ANY (ARRAY['获取'::text, '消耗'::text])));
ALTER TABLE "public"."points_transaction" ADD CONSTRAINT "chk_user_type" CHECK ((user_type = ANY (ARRAY['单位用户'::text, '个人用户'::text])));
ALTER TABLE "public"."points_transaction" ADD CONSTRAINT "chk_trans_deleted" CHECK ((deleted = ANY (ARRAY[0, 1])));
ALTER TABLE "public"."points_transaction" ADD CONSTRAINT "chk_data_category" CHECK (data_category = ANY (ARRAY['用户参与'::text, '其他'::text]));
ALTER TABLE "public"."points_transaction" ADD CONSTRAINT "chk_trans_rule_type" CHECK (rule_type = ANY (ARRAY['获取'::text, '消耗'::text]));
ALTER TABLE "public"."points_transaction" ADD CONSTRAINT "chk_user_type" CHECK (user_type = ANY (ARRAY['单位用户'::text, '个人用户'::text]));
ALTER TABLE "public"."points_transaction" ADD CONSTRAINT "chk_trans_deleted" CHECK (deleted = ANY (ARRAY[0, 1]));
-- ----------------------------
-- Primary Key structure for table points_transaction
@@ -1254,10 +1380,10 @@
-- ----------------------------
-- Checks structure for table product
-- ----------------------------
ALTER TABLE "public"."product" ADD CONSTRAINT "product_provider_type_check" CHECK ((provider_type = ANY (ARRAY['企业'::text, '个人'::text])));
ALTER TABLE "public"."product" ADD CONSTRAINT "product_status_check" CHECK ((status = ANY (ARRAY['上架'::text, '下架'::text, '审核中'::text, '已下架'::text])));
ALTER TABLE "public"."product" ADD CONSTRAINT "product_audit_status_check" CHECK ((audit_status = ANY (ARRAY['待审核'::text, '审核通过'::text, '审核驳回'::text])));
ALTER TABLE "public"."product" ADD CONSTRAINT "product_deleted_check" CHECK ((deleted = ANY (ARRAY[0, 1])));
ALTER TABLE "public"."product" ADD CONSTRAINT "product_status_check" CHECK (status = ANY (ARRAY['上架'::text, '下架'::text, '审核中'::text, '已下架'::text]));
ALTER TABLE "public"."product" ADD CONSTRAINT "product_audit_status_check" CHECK (audit_status = ANY (ARRAY['待审核'::text, '审核通过'::text, '审核驳回'::text]));
ALTER TABLE "public"."product" ADD CONSTRAINT "product_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));
ALTER TABLE "public"."product" ADD CONSTRAINT "product_provider_type_check" CHECK (provider_type = ANY (ARRAY['企业'::text, '个人'::text]));
-- ----------------------------
-- Primary Key structure for table product
@@ -1277,11 +1403,11 @@
-- ----------------------------
-- Checks structure for table product_pricing
-- ----------------------------
ALTER TABLE "public"."product_pricing" ADD CONSTRAINT "product_pricing_customer_type_check" CHECK ((customer_type = ANY (ARRAY['企业'::text, '个人'::text, '项目部'::text])));
ALTER TABLE "public"."product_pricing" ADD CONSTRAINT "product_pricing_price_type_check" CHECK ((price_type = ANY (ARRAY['积分'::text, '协议'::text, '货币'::text, '免费'::text])));
ALTER TABLE "public"."product_pricing" ADD CONSTRAINT "product_pricing_price_unit_check" CHECK ((price_unit = ANY (ARRAY['套'::text, '套/年'::text, '年'::text, '个'::text, '次'::text])));
ALTER TABLE "public"."product_pricing" ADD CONSTRAINT "product_pricing_deleted_check" CHECK ((deleted = ANY (ARRAY[0, 1])));
ALTER TABLE "public"."product_pricing" ADD CONSTRAINT "product_pricing_sales_form_check" CHECK ((sales_form = ANY (ARRAY['买断'::text, '租赁'::text, '私有增包量'::text, '公有增包量'::text, 'OTA服务'::text, '资源包'::text, '个人'::text])));
ALTER TABLE "public"."product_pricing" ADD CONSTRAINT "product_pricing_customer_type_check" CHECK (customer_type = ANY (ARRAY['企业'::text, '个人'::text, '项目部'::text]));
ALTER TABLE "public"."product_pricing" ADD CONSTRAINT "product_pricing_price_unit_check" CHECK (price_unit = ANY (ARRAY['套'::text, '套/年'::text, '年'::text, '个'::text, '次'::text]));
ALTER TABLE "public"."product_pricing" ADD CONSTRAINT "product_pricing_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));
ALTER TABLE "public"."product_pricing" ADD CONSTRAINT "product_pricing_sales_form_check" CHECK (sales_form = ANY (ARRAY['买断'::text, '租赁'::text, '私有增包量'::text, '公有增包量'::text, 'OTA服务'::text, '资源包'::text, '个人'::text]));
ALTER TABLE "public"."product_pricing" ADD CONSTRAINT "product_pricing_price_type_check" CHECK (price_type = ANY (ARRAY['积分'::text, '协议'::text, '货币'::text, '免费'::text]));
-- ----------------------------
-- Primary Key structure for table product_pricing
@@ -1296,8 +1422,8 @@
-- ----------------------------
-- Checks structure for table unit
-- ----------------------------
ALTER TABLE "public"."unit" ADD CONSTRAINT "unit_status_check" CHECK ((status = ANY (ARRAY['正常'::text, '冻结'::text, '注销'::text])));
ALTER TABLE "public"."unit" ADD CONSTRAINT "unit_deleted_check" CHECK ((deleted = ANY (ARRAY[0, 1])));
ALTER TABLE "public"."unit" ADD CONSTRAINT "unit_status_check" CHECK (status = ANY (ARRAY['正常'::text, '冻结'::text, '注销'::text]));
ALTER TABLE "public"."unit" ADD CONSTRAINT "unit_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));
-- ----------------------------
-- Primary Key structure for table unit
@@ -1337,9 +1463,9 @@
-- ----------------------------
-- Checks structure for table users
-- ----------------------------
ALTER TABLE "public"."users" ADD CONSTRAINT "users_user_type_check" CHECK ((user_type = ANY (ARRAY['个人用户'::text, '单位用户'::text])));
ALTER TABLE "public"."users" ADD CONSTRAINT "users_status_check" CHECK ((status = ANY (ARRAY['正常'::text, '冻结'::text, '注销'::text])));
ALTER TABLE "public"."users" ADD CONSTRAINT "users_deleted_check" CHECK ((deleted = ANY (ARRAY[0, 1])));
ALTER TABLE "public"."users" ADD CONSTRAINT "users_user_type_check" CHECK (user_type = ANY (ARRAY['个人用户'::text, '单位用户'::text]));
ALTER TABLE "public"."users" ADD CONSTRAINT "users_status_check" CHECK (status = ANY (ARRAY['正常'::text, '冻结'::text, '注销'::text]));
ALTER TABLE "public"."users" ADD CONSTRAINT "users_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1]));
-- ----------------------------
-- Primary Key structure for table users
@@ -1397,15 +1523,8 @@
ALTER TABLE "public"."points_rule" ADD CONSTRAINT "fk_points" FOREIGN KEY ("points_id") REFERENCES "public"."points" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
-- ----------------------------
-- Foreign Keys structure for table points_rule_detail
-- ----------------------------
ALTER TABLE "public"."points_rule_detail" ADD CONSTRAINT "fk_detail_points" FOREIGN KEY ("points_id") REFERENCES "public"."points" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "public"."points_rule_detail" ADD CONSTRAINT "fk_rule" FOREIGN KEY ("rule_id") REFERENCES "public"."points_rule" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
-- ----------------------------
-- Foreign Keys structure for table points_transaction
-- ----------------------------
ALTER TABLE "public"."points_transaction" ADD CONSTRAINT "fk_detail_id" FOREIGN KEY ("detail_id") REFERENCES "public"."points_rule_detail" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "public"."points_transaction" ADD CONSTRAINT "fk_rule_id" FOREIGN KEY ("rule_id") REFERENCES "public"."points_rule" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION;
-- ----------------------------
src/main/java/com/webmanage/controller/PointsController.java
@@ -2,12 +2,10 @@
import com.webmanage.common.PageResult;
import com.webmanage.common.Result;
import com.webmanage.dto.AddPointsFlowDTO;
import com.webmanage.dto.PointsFlowQueryDTO;
import com.webmanage.dto.PointsMainQueryDTO;
import com.webmanage.dto.PointsRuleDTO;
import com.webmanage.dto.*;
import com.webmanage.entity.Points;
import com.webmanage.entity.PointsRule;
import com.webmanage.entity.UserPoints;
import com.webmanage.service.PointsFlowService;
import com.webmanage.service.PointsRuleService;
import com.webmanage.service.PointsService;
@@ -91,7 +89,7 @@
    @PostMapping("/rule/update")
    @ApiOperation("修改积分规则")
    public Result<Object> updatePointsRule(@Valid @RequestBody PointsRuleDTO pointsRuleDTO) {
    public Result<Object> updatePointsRule(@Valid @RequestBody List<PointsRuleDTO> pointsRuleDTO) {
        try {
            boolean result = pointsRuleService.updatePointsRule(pointsRuleDTO);
            if (result) {
@@ -252,10 +250,10 @@
    @GetMapping("/total/user/{userId}")
    @ApiOperation("获取用户积分统计")
    public Result<Object> getUserPointsTotal(@ApiParam("用户ID") @PathVariable Long userId) {
    public Result<UserPoints> getUserPointsTotal(@ApiParam("用户ID") @PathVariable Long userId) {
        try {
            Integer total = pointsFlowService.getUserPointsTotal(userId);
            return Result.success(total);
            UserPoints userPoints = pointsFlowService.getUserPointsTotal(userId);
            return Result.success(userPoints);
        } catch (Exception e) {
            log.error("获取用户积分统计失败", e);
            return Result.error("获取用户积分统计失败:" + e.getMessage());
@@ -264,13 +262,27 @@
    @GetMapping("/total/unit/{unitId}")
    @ApiOperation("获取单位积分统计")
    public Result<Object> getUnitPointsTotal(@ApiParam("单位ID") @PathVariable Long unitId) {
    public Result<UserPoints> getUnitPointsTotal(@ApiParam("单位ID") @PathVariable Long unitId) {
        try {
            Integer total = pointsFlowService.getUnitPointsTotal(unitId);
            UserPoints total = pointsFlowService.getUnitPointsTotal(unitId);
            return Result.success(total);
        } catch (Exception e) {
            log.error("获取单位积分统计失败", e);
            return Result.error("获取单位积分统计失败:" + e.getMessage());
        }
    }
    // ==================== 积分流水数据类目 ====================
    @GetMapping("/flow/categories")
    @ApiOperation("获取积分流水数据类目列表")
    public Result<Object> getPointsFlowCategories() {
        try {
            List<String> categories = pointsFlowService.getPointsFlowCategories();
            return Result.success(categories);
        } catch (Exception e) {
            log.error("获取积分流水数据类目失败", e);
            return Result.error("获取积分流水数据类目失败:" + e.getMessage());
        }
    }
}
src/main/java/com/webmanage/dto/AddPointsFlowDTO.java
@@ -22,20 +22,28 @@
    @NotNull(message = "单位ID不能为空")
    private Long unitId;
    @ApiModelProperty("规则类型(获得/消费)")
    @NotBlank(message = "规则类型不能为空")
    private String ruleType;
    @ApiModelProperty("规则类型(0获得/1消费)")
    @NotNull(message = "规则类型不能为空")
    private Integer ruleType;
    @ApiModelProperty("规则名称")
    @NotBlank(message = "规则名称不能为空")
    private String ruleName;
    @ApiModelProperty("积分规则类别(资源贡献、资源传播、资源交易、交流社区互动)")
    @NotBlank(message = "规则类别不能为空")
    private String category;
    @ApiModelProperty("积分规则类别(资源贡献、资源传播、资源交易、交流社区互动)")
    @NotBlank(message = "积分规则编码")
    private String ruleNameCode;
    @ApiModelProperty("数据类目)")
    @NotBlank(message = "数据类目不能为空")
    private String dataCategoty;
    @ApiModelProperty("关联订单ID")
    private String orderId;
    @ApiModelProperty("积分流水描述")
    private String description;
    @ApiModelProperty("触发次数(默认为1)")
    private Integer count = 1;
    @ApiModelProperty("流水描述(可选,不填则使用规则描述)")
    private String description;
}
src/main/java/com/webmanage/dto/PointsFlowQueryDTO.java
@@ -25,20 +25,23 @@
    @ApiModelProperty("单位ID")
    private Long unitId;
    @ApiModelProperty("流水类型(获得/消费)")
    private String flowType;
    @ApiModelProperty("流水类型(0获得1/消费)")
    private Integer dataType;
    @ApiModelProperty("积分来源")
    private String pointsSource;
    @ApiModelProperty("数据类目")
    private String dataCategory;
    @ApiModelProperty("关联订单ID")
    private String orderId;
    @ApiModelProperty("开始时间")
    private LocalDateTime startTime;
    private LocalDateTime flowStartTime;
    @ApiModelProperty("结束时间")
    private LocalDateTime endTime;
    private LocalDateTime flowEndTime;
    @ApiModelProperty("排序字段")
    private String orderBy = "created_at";
src/main/java/com/webmanage/dto/PointsRuleDTO.java
@@ -1,5 +1,6 @@
package com.webmanage.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -16,39 +17,44 @@
public class PointsRuleDTO {
    @ApiModelProperty("主键ID")
    private Long id;
    private Long pointsId;
    @ApiModelProperty("规则名称")
    @NotBlank(message = "规则名称不能为空")
    private String ruleName;
    @ApiModelProperty("规则编码")
    @NotBlank(message = "规则编码不能为空")
    private String ruleNameCode;
    @ApiModelProperty("规则类型(获得/消费)")
    @NotBlank(message = "规则类型不能为空")
    private String ruleType;
    @NotNull(message = "规则类型不能为空")
    private Integer ruleType;
    @ApiModelProperty("规则类别")
    private String category;
    @ApiModelProperty("积分值")
    @NotNull(message = "积分值不能为空")
    private Integer pointsValue;
    @ApiModelProperty("触发条件")
    @NotBlank(message = "触发条件不能为空")
    private String triggerCondition;
    @ApiModelProperty("触发金额")
    private BigDecimal triggerAmount;
    @ApiModelProperty("规则描述")
    private String description;
    private String ruleDescription;
    @ApiModelProperty("是否启用")
    private Boolean isEnabled = true;
    @ApiModelProperty("优先级")
    private Integer priority = 1;
    @ApiModelProperty("每日上限")
    private Integer dailyLimit;
    @ApiModelProperty("有效期开始时间")
    private String validStartTime;
    @ApiModelProperty("积分拥有者(0贡献值1用户)")
    private Integer pointsWinner;
    @ApiModelProperty("有效期结束时间")
    private String validEndTime;
    @ApiModelProperty("积分是否有上限(0有1没有)")
    private Integer isLimit;
    @ApiModelProperty("排序")
    private Integer ruleOrder;
}
src/main/java/com/webmanage/dto/PointsRuleDetailDTO.java
File was deleted
src/main/java/com/webmanage/emun/RuleTypeEnum.java
@@ -9,16 +9,16 @@
 */
public enum RuleTypeEnum {
    GET(0L,"获取"),CONSUME(1L,"消费");
    private Long code;
    GET(0,"获取"),CONSUME(1,"消费");
    private Integer code;
    private String name;
    RuleTypeEnum(Long code, String name) {
    RuleTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }
    public Long getCode() {
    public Integer getCode() {
        return code;
    }
src/main/java/com/webmanage/entity/PointsFlow.java
@@ -48,7 +48,7 @@
     * 数据类型
     */
    @TableField("data_type")
    private String dataType;
    private Integer dataType;
    /**
     * 名称/描述
@@ -86,4 +86,10 @@
    @TableLogic
    @TableField("deleted")
    private Integer deleted;
    /**
     * 规则ID
     */
    @TableField("rule_id")
    private Long rlueId;
}
src/main/java/com/webmanage/entity/PointsRule.java
@@ -28,9 +28,13 @@
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    @ApiModelProperty("points_id")
    @TableField("points_id")
    private Long pointsId;
    @ApiModelProperty("规则类型(0获得/1消费)")
    @TableField("rule_type")
    private Long ruleType;
    private Integer ruleType;
    @ApiModelProperty("规则类别")
    @TableField("category")
@@ -40,13 +44,17 @@
    @TableField("rule_name")
    private String ruleName;
    @ApiModelProperty("规则编码")
    @TableField("rule_name_code")
    private String ruleNameCode;
    @ApiModelProperty("规则描述")
    @TableField("rule_description")
    private String ruleDescription;
    @ApiModelProperty("是否启用")
    @TableField("is_enabled")
    private Boolean isEnabled;
    private Integer isEnabled;
    @ApiModelProperty("创建时间")
    @TableField(value = "created_at", fill = FieldFill.INSERT)
@@ -69,4 +77,17 @@
    @ApiModelProperty("积分是否有上限(0有1没有)")
    @TableField("is_limit")
    private Integer isLimit;
    @ApiModelProperty("排序")
    @TableField("rule_order")
    private Integer ruleOrder;
    @ApiModelProperty("积分值")
    @TableField("points_value")
    private Integer pointsValue;
    @ApiModelProperty("每日上限")
    @TableField("daily_limit")
    private Integer dailyLimit;
}
src/main/java/com/webmanage/entity/PointsRuleDetail.java
File was deleted
src/main/java/com/webmanage/entity/PointsRuleEntity.java
File was deleted
src/main/java/com/webmanage/mapper/PointsFlowMapper.java
@@ -16,17 +16,4 @@
@Mapper
public interface PointsFlowMapper extends BaseMapper<PointsFlow> {
    
    /**
     * 分页查询积分流水
     */
    IPage<PointsFlow> selectPage(Page<PointsFlow> page,
                                @Param("userId") Long userId,
                                @Param("unitId") Long unitId,
                                @Param("dataCategory") String dataCategory,
                                @Param("dataType") String dataType,
                                @Param("startTime") String startTime,
                                @Param("endTime") String endTime,
                                @Param("year") String year,
                                @Param("month") String month,
                                @Param("day") String day);
}
src/main/java/com/webmanage/mapper/PointsRuleDetailMapper.java
File was deleted
src/main/java/com/webmanage/mapper/PointsRuleMapper.java
@@ -3,6 +3,10 @@
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.webmanage.entity.PointsRule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
 * 积分规则Mapper接口
@@ -12,4 +16,5 @@
 */
@Mapper
public interface PointsRuleMapper extends BaseMapper<PointsRule> {
}
src/main/java/com/webmanage/service/PointsFlowService.java
@@ -5,6 +5,7 @@
import com.webmanage.dto.AddPointsFlowDTO;
import com.webmanage.dto.PointsFlowQueryDTO;
import com.webmanage.entity.PointsFlow;
import com.webmanage.entity.UserPoints;
import java.util.List;
@@ -33,11 +34,6 @@
     */
    List<PointsFlow> getPointsFlowByUnitId(Long unitId);
    /**
     * 记录积分流水
     */
    boolean recordPointsFlow(Long userId, Long unitId, String flowType, String pointsSource,
                           Integer pointsValue, String orderId, String description);
    /**
     * 新增积分流水(根据规则自动计算)
@@ -47,10 +43,15 @@
    /**
     * 获取用户积分统计
     */
    Integer getUserPointsTotal(Long userId);
    UserPoints getUserPointsTotal(Long userId);
    /**
     * 获取单位积分统计
     */
    Integer getUnitPointsTotal(Long unitId);
    UserPoints getUnitPointsTotal(Long unitId);
    /**
     * 获取积分流水数据类目列表
     */
    List<String> getPointsFlowCategories();
}
src/main/java/com/webmanage/service/PointsRuleDetailService.java
File was deleted
src/main/java/com/webmanage/service/PointsRuleService.java
@@ -27,7 +27,7 @@
    /**
     * 修改积分规则
     */
    boolean updatePointsRule(PointsRuleDTO pointsRuleDTO);
    boolean updatePointsRule(List<PointsRuleDTO> pointsRuleDetailsVOS);
    /**
     * 删除积分规则
src/main/java/com/webmanage/service/impl/PointsFlowServiceImpl.java
@@ -8,6 +8,7 @@
import com.webmanage.common.PageResult;
import com.webmanage.dto.AddPointsFlowDTO;
import com.webmanage.dto.PointsFlowQueryDTO;
import com.webmanage.emun.RuleTypeEnum;
import com.webmanage.entity.PointsFlow;
import com.webmanage.entity.PointsRule;
import com.webmanage.entity.UserPoints;
@@ -24,6 +25,7 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
/**
 * 积分流水Service实现类
@@ -47,8 +49,7 @@
        Page<PointsFlow> page = new Page<>(queryDTO.getPageNum(), queryDTO.getPageSize());
        
        QueryWrapper<PointsFlow> wrapper = new QueryWrapper<>();
        wrapper.eq("deleted", 0)
               .eq("user_id", queryDTO.getUserId());
        wrapper.eq("user_id", queryDTO.getUserId());
        
        buildQueryWrapper(wrapper, queryDTO);
        
@@ -72,8 +73,7 @@
        Page<PointsFlow> page = new Page<>(queryDTO.getPageNum(), queryDTO.getPageSize());
        
        QueryWrapper<PointsFlow> wrapper = new QueryWrapper<>();
        wrapper.eq("deleted", 0)
               .eq("unit_id", queryDTO.getUnitId());
        wrapper.eq("unit_id", queryDTO.getUnitId());
        
        buildQueryWrapper(wrapper, queryDTO);
        
@@ -118,36 +118,6 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean recordPointsFlow(Long userId, Long unitId, String flowType, String pointsSource,
                                  Integer pointsValue, String orderId, String description) {
        if (userId == null || unitId == null || !StringUtils.hasText(flowType) ||
            !StringUtils.hasText(pointsSource) || pointsValue == null) {
            throw new BusinessException("参数不完整");
        }
        // 创建积分流水记录
        PointsFlow pointsFlow = new PointsFlow();
        pointsFlow.setUserId(userId);
        pointsFlow.setUnitId(unitId);
        pointsFlow.setDataType(flowType);
        pointsFlow.setDataCategory(pointsSource);
        pointsFlow.setPoints(pointsValue);
        pointsFlow.setName(description);
        pointsFlow.setFlowTime(LocalDateTime.now());
        boolean saved = save(pointsFlow);
        if (!saved) {
            throw new BusinessException("保存积分流水失败");
        }
        // 更新用户积分
        updateUserPoints(userId, unitId, pointsValue);
        return true;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean addPointsFlowByRule(AddPointsFlowDTO addPointsFlowDTO) {
        if (addPointsFlowDTO == null) {
            throw new BusinessException("参数不能为空");
@@ -155,14 +125,15 @@
        Long userId = addPointsFlowDTO.getUserId();
        Long unitId = addPointsFlowDTO.getUnitId();
        String ruleType = addPointsFlowDTO.getRuleType();
        String ruleName = addPointsFlowDTO.getRuleName();
        Integer ruleType = addPointsFlowDTO.getRuleType();
        String category = addPointsFlowDTO.getCategory();
        String ruleNameCode = addPointsFlowDTO.getRuleNameCode();
        Integer count = addPointsFlowDTO.getCount() != null ? addPointsFlowDTO.getCount() : 1;
        // 查询积分规则
        PointsRule pointsRule = pointsRuleService.getRuleByTriggerCondition(ruleName);
        // 根据ruleType、ruleNameCode、category查询生效时间最新的积分规则
        PointsRule pointsRule = getLatestEffectiveRule(ruleType, ruleNameCode, category);
        if (pointsRule == null) {
            throw new BusinessException("积分规则不存在或未启用: " + ruleName);
            throw new BusinessException("积分规则不存在或未启用: ruleType=" + ruleType + ", ruleNameCode=" + ruleNameCode + ", category=" + category);
        }
        // 验证规则类型是否匹配
@@ -171,17 +142,22 @@
        }
        // 计算积分值
        Integer basePoints = 0; //pointsRule.getPointsValue() != null ? pointsRule.getPointsValue() : 0;
        Integer basePoints = pointsRule.getPointsValue() != null ? pointsRule.getPointsValue() : 0;
        Integer totalPoints = basePoints * count;
        // 如果是消费类型,积分为负数
        if ("消费".equals(ruleType)) {
        if (ruleType == RuleTypeEnum.CONSUME.getCode()) { // 1表示消费类型
            totalPoints = -totalPoints;
        }
        // 检查每日积分上限
        if (basePoints > 0) {
            checkDailyLimit(userId, unitId, ruleName, totalPoints, 0);
        if (pointsRule.getIsLimit() != null && pointsRule.getIsLimit() == 0) { // 0表示有每日上限
            checkDailyLimitByRule(userId, unitId, pointsRule, totalPoints);
        }
        // 如果是扣积分操作,先检查余额是否足够
        if (totalPoints < 0) {
            checkBalanceSufficient(userId, unitId, Math.abs(totalPoints));
        }
        // 创建积分流水记录
@@ -189,10 +165,11 @@
        pointsFlow.setUserId(userId);
        pointsFlow.setUnitId(unitId);
        pointsFlow.setDataType(ruleType);
        pointsFlow.setDataCategory(ruleName);
        pointsFlow.setDataCategory(addPointsFlowDTO.getCategory());
        pointsFlow.setPoints(totalPoints);
        pointsFlow.setName(addPointsFlowDTO.getDescription() != null ? addPointsFlowDTO.getDescription() : pointsRule.getRuleDescription());
        pointsFlow.setFlowTime(LocalDateTime.now());
        pointsFlow.setRlueId(pointsRule.getId());
        boolean saved = save(pointsFlow);
        if (!saved) {
@@ -200,15 +177,15 @@
        }
        // 更新用户积分账户
        updateUserPointsByRule(userId, unitId, totalPoints, ruleType);
        updateUserPointsByRule(userId, unitId, totalPoints);
        return true;
    }
    @Override
    public Integer getUserPointsTotal(Long userId) {
    public UserPoints getUserPointsTotal(Long userId) {
        if (userId == null) {
            return 0;
            throw new BusinessException("用户ID不能为null");
        }
        
        QueryWrapper<UserPoints> wrapper = new QueryWrapper<>();
@@ -216,13 +193,13 @@
               .eq("user_id", userId);
        
        UserPoints userPoints = userPointsMapper.selectOne(wrapper);
        return userPoints != null ? userPoints.getBalance() : 0;
        return userPoints ;
    }
    @Override
    public Integer getUnitPointsTotal(Long unitId) {
    public UserPoints getUnitPointsTotal(Long unitId) {
        if (unitId == null) {
            return 0;
            throw new BusinessException("用户ID不能为null");
        }
        
        QueryWrapper<UserPoints> wrapper = new QueryWrapper<>();
@@ -230,15 +207,37 @@
               .eq("unit_id", unitId);
        
        UserPoints userPoints = userPointsMapper.selectOne(wrapper);
        return userPoints != null ? userPoints.getBalance() : 0;
        return userPoints;
    }
    @Override
    public List<String> getPointsFlowCategories() {
        QueryWrapper<PointsFlow> wrapper = new QueryWrapper<>();
        wrapper.select("DISTINCT data_category")
               .isNotNull("data_category")
               .ne("data_category", "")
               .ne("data_category", "null")
               .eq("deleted", 0)
               .orderByAsc("data_category");
        List<PointsFlow> flows = list(wrapper);
        return flows.stream()
                .map(PointsFlow::getDataCategory)
                .filter(category -> category != null && !category.trim().isEmpty())
                .distinct()
                .sorted()
                .collect(Collectors.toList());
    }
    /**
     * 构建查询条件
     */
    private void buildQueryWrapper(QueryWrapper<PointsFlow> wrapper, PointsFlowQueryDTO queryDTO) {
        if (StringUtils.hasText(queryDTO.getFlowType())) {
            wrapper.eq("flow_type", queryDTO.getFlowType());
        if(StringUtils.hasText(queryDTO.getDataCategory())){
            wrapper.eq("data_category", queryDTO.getDataCategory());
        }
        if (queryDTO.getDataType()!=null) {
            wrapper.eq("data_type", queryDTO.getDataType());
        }
        if (StringUtils.hasText(queryDTO.getPointsSource())) {
            wrapper.eq("points_source", queryDTO.getPointsSource());
@@ -246,18 +245,100 @@
        if (StringUtils.hasText(queryDTO.getOrderId())) {
            wrapper.eq("order_id", queryDTO.getOrderId());
        }
        if (queryDTO.getStartTime() != null) {
            wrapper.ge("flow_time", queryDTO.getStartTime());
        if (queryDTO.getFlowEndTime() != null) {
            wrapper.ge("flow_time", queryDTO.getFlowStartTime());
        }
        if (queryDTO.getEndTime() != null) {
            wrapper.le("flow_time", queryDTO.getEndTime());
        if (queryDTO.getFlowEndTime() != null) {
            wrapper.le("flow_time", queryDTO.getFlowEndTime());
        }
        
        wrapper.orderByDesc("flow_time");
    }
    /**
     * 检查每日积分上限
     * 根据ruleType、ruleNameCode、category查询生效时间最新的积分规则
     */
    private PointsRule getLatestEffectiveRule(Integer ruleType, String ruleNameCode, String category) {
        QueryWrapper<PointsRule> wrapper = new QueryWrapper<>();
        wrapper.eq("deleted", 0)
               .eq("is_enabled", 0) // 0表示启用
               .eq("rule_type", ruleType)
               .eq("rule_name_code", ruleNameCode)
               .eq("category", category)
               .orderByDesc("created_at") // 按创建时间倒序,获取最新的规则
               .last("LIMIT 1");
        return pointsRuleService.getOne(wrapper);
    }
    /**
     * 检查每日积分上限(基于规则)
     */
    private void checkDailyLimitByRule(Long userId, Long unitId, PointsRule pointsRule, Integer currentPoints) {
        // 获取今日开始和结束时间
        LocalDate today = LocalDate.now();
        LocalDateTime startOfDay = today.atStartOfDay();
        LocalDateTime endOfDay = today.atTime(23, 59, 59);
        // 查询今日该规则的积分流水
        QueryWrapper<PointsFlow> wrapper = new QueryWrapper<>();
        wrapper.eq("deleted", 0)
               .eq("user_id", userId)
               .eq("unit_id", unitId)
//               .eq("data_category", pointsRule.getRuleName())
                .eq("rule_id",pointsRule.getId())
               .ge("flow_time", startOfDay)
               .le("flow_time", endOfDay);
        List<PointsFlow> todayFlows = list(wrapper);
        // 计算今日累计积分
        int todayTotal = todayFlows.stream()
                .mapToInt(flow -> flow.getPoints() != null ? flow.getPoints() : 0)
                .sum();
        // 获取规则的每日积分上限
        Integer dailyLimit = pointsRule.getDailyLimit();
        if (dailyLimit != null && dailyLimit > 0) {
            // 如果今日累计积分超过每日上限,则抛出异常
            if (Math.abs(todayTotal) >= dailyLimit) {
                throw new BusinessException("今日该规则积分已达上限: " + dailyLimit);
            }
            // 如果加上当前积分会超过每日上限,则抛出异常
            if (Math.abs(todayTotal + currentPoints) > dailyLimit) {
                throw new BusinessException("本次积分操作将超过每日上限: " + dailyLimit + ",当前已累计: " + Math.abs(todayTotal));
            }
        }
    }
    /**
     * 检查积分余额是否足够
     */
    private void checkBalanceSufficient(Long userId, Long unitId, Integer requiredPoints) {
        // 检查个人积分余额
        QueryWrapper<UserPoints> userWrapper = new QueryWrapper<>();
        userWrapper.eq("deleted", 0)
                  .eq("user_id", userId);
        UserPoints userPoints = userPointsMapper.selectOne(userWrapper);
        if (userPoints == null || userPoints.getBalance() < requiredPoints) {
            throw new BusinessException("个人积分余额不足,当前余额: " + (userPoints != null ? userPoints.getBalance() : 0) + ",需要扣除: " + requiredPoints);
        }
        // 检查单位积分余额
        QueryWrapper<UserPoints> unitWrapper = new QueryWrapper<>();
        unitWrapper.eq("deleted", 0)
                  .eq("unit_id", unitId);
        UserPoints unitPoints = userPointsMapper.selectOne(unitWrapper);
        if (unitPoints == null || unitPoints.getBalance() < requiredPoints) {
            throw new BusinessException("单位积分余额不足,当前余额: " + (unitPoints != null ? unitPoints.getBalance() : 0) + ",需要扣除: " + requiredPoints);
        }
    }
    /**
     * 检查每日积分上限(旧方法,保留兼容性)
     */
    private void checkDailyLimit(Long userId, Long unitId, String ruleName, Integer currentPoints, Integer priority) {
        // 获取今日开始和结束时间
@@ -331,7 +412,7 @@
    /**
     * 根据规则更新用户积分账户
     */
    private void updateUserPointsByRule(Long userId, Long unitId, Integer pointsValue, String ruleType) {
    private void updateUserPointsByRule(Long userId, Long unitId, Integer pointsValue) {
        // 更新个人积分账户
        QueryWrapper<UserPoints> userWrapper = new QueryWrapper<>();
        userWrapper.eq("deleted", 0)
@@ -339,6 +420,11 @@
        
        UserPoints userPoints = userPointsMapper.selectOne(userWrapper);
        if (userPoints == null) {
            // 如果是新用户且是扣积分操作,余额不足
            if (pointsValue < 0) {
                throw new BusinessException("积分余额不足,无法扣除积分");
            }
            userPoints = new UserPoints();
            userPoints.setUserId(userId);
            userPoints.setUnitId(unitId);
@@ -347,6 +433,11 @@
            userPoints.setTotalConsumed(pointsValue < 0 ? Math.abs(pointsValue) : 0);
            userPointsMapper.insert(userPoints);
        } else {
            // 检查扣积分时余额是否足够
            if (pointsValue < 0 && userPoints.getBalance() + pointsValue < 0) {
                throw new BusinessException("积分余额不足,当前余额: " + userPoints.getBalance() + ",需要扣除: " + Math.abs(pointsValue));
            }
            userPoints.setBalance(userPoints.getBalance() + pointsValue);
            
            // 更新累计获取积分
@@ -372,6 +463,11 @@
        
        UserPoints unitPoints = userPointsMapper.selectOne(unitWrapper);
        if (unitPoints == null) {
            // 如果是新单位且是扣积分操作,余额不足
            if (pointsValue < 0) {
                throw new BusinessException("单位积分余额不足,无法扣除积分");
            }
            unitPoints = new UserPoints();
            unitPoints.setUserId(userId);
            unitPoints.setUnitId(unitId);
@@ -380,6 +476,11 @@
            unitPoints.setTotalConsumed(pointsValue < 0 ? Math.abs(pointsValue) : 0);
            userPointsMapper.insert(unitPoints);
        } else {
            // 检查扣积分时余额是否足够
            if (pointsValue < 0 && unitPoints.getBalance() + pointsValue < 0) {
                throw new BusinessException("单位积分余额不足,当前余额: " + unitPoints.getBalance() + ",需要扣除: " + Math.abs(pointsValue));
            }
            unitPoints.setBalance(unitPoints.getBalance() + pointsValue);
            
            // 更新累计获取积分
src/main/java/com/webmanage/service/impl/PointsRuleDetailServiceImpl.java
File was deleted
src/main/java/com/webmanage/service/impl/PointsRuleServiceImpl.java
@@ -5,24 +5,30 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.webmanage.common.BusinessException;
import com.webmanage.dto.PointsRuleDTO;
import com.webmanage.emun.RuleTypeEnum;
import com.webmanage.entity.Points;
import com.webmanage.entity.PointsRule;
import com.webmanage.entity.PointsRuleDetail;
import com.webmanage.mapper.PointsRuleMapper;
import com.webmanage.service.PointsRuleService;
import com.webmanage.service.PointsService;
import com.webmanage.service.PointsRuleDetailService;
import com.webmanage.vo.PointsRuleResultVO;
import com.webmanage.vo.PointsRuleVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.beans.Transient;
import java.text.DateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -37,8 +43,6 @@
    @Autowired
    private PointsService pointsService;
    
    @Autowired
    private PointsRuleDetailService pointsRuleDetailService;
    @Override
    public PointsRuleResultVO getPointsRuleList(Long ruleId) {
@@ -54,7 +58,7 @@
        List<PointsRule> list = list(wrapper);
        PointsRuleResultVO pointsRuleResultVO = new PointsRuleResultVO();
        if (!CollectionUtil.isEmpty(list)) {
            Map<Long, List<PointsRule>> collect = list.stream().collect(Collectors.groupingBy(PointsRule::getRuleType));
            Map<Integer, List<PointsRule>> collect = list.stream().collect(Collectors.groupingBy(PointsRule::getRuleType));
            Map<String, List<PointsRule>> getRules = collect.get(RuleTypeEnum.GET.getCode()).stream().collect(Collectors.groupingBy(PointsRule::getCategory));
            Map<String, List<PointsRule>> consumeRules = collect.get(RuleTypeEnum.CONSUME.getCode()).stream().collect(Collectors.groupingBy(PointsRule::getCategory));
@@ -62,6 +66,7 @@
            List<PointsRuleVO> consumePointsRuleVOList = new ArrayList<>();
            getRules.forEach((k,v)->{
                PointsRuleVO pointsRuleVO = new PointsRuleVO();
                pointsRuleVO.setRlueSort(v.get(0).getRuleOrder());
                pointsRuleVO.setCategory(k);
                pointsRuleVO.setPointsRules(v);
                getPointsRuleVOList.add(pointsRuleVO);
@@ -69,11 +74,14 @@
            });
            consumeRules.forEach((k,v)->{
                PointsRuleVO pointsRuleVO = new PointsRuleVO();
                pointsRuleVO.setRlueSort(v.get(0).getRuleOrder());
                pointsRuleVO.setCategory(k);
                pointsRuleVO.setPointsRules(v);
                consumePointsRuleVOList.add(pointsRuleVO);
            });
            getPointsRuleVOList.sort(Comparator.comparing(PointsRuleVO::getRlueSort));
            consumePointsRuleVOList.sort(Comparator.comparing(PointsRuleVO::getRlueSort));
            pointsRuleResultVO.setGetPointsRuleList(getPointsRuleVOList);
            pointsRuleResultVO.setConsumePointsRuleList(consumePointsRuleVOList);
        }
@@ -99,48 +107,42 @@
    }
    @Override
    public boolean updatePointsRule(PointsRuleDTO pointsRuleDTO) {
        if (pointsRuleDTO.getId() == null) {
            throw new BusinessException("规则ID不能为空");
    @Transactional(rollbackFor = Exception.class)
    public boolean updatePointsRule(List<PointsRuleDTO> pointsRuleDTO) {
        if (CollectionUtils.isEmpty(pointsRuleDTO)){
            return false;
        }
        
        PointsRule existingRule = getById(pointsRuleDTO.getId());
        if (existingRule == null) {
            throw new BusinessException("积分规则不存在");
        }
        // 验证规则名称是否重复(排除自身)
        QueryWrapper<PointsRule> wrapper = new QueryWrapper<>();
        wrapper.eq("rule_name", pointsRuleDTO.getRuleName())
               .eq("deleted", 0)
               .ne("id", pointsRuleDTO.getId());
        if (count(wrapper) > 0) {
            throw new BusinessException("规则名称已存在");
        }
        // 查询规则名称
         Points pointsOld = pointsService.query().eq("id", pointsRuleDTO.get(0).getPointsId())
                 .eq("deleted", 0).one();
        // 查询当天是否有版本更新记录
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("YYYY-MM-DD HH:mm:ss");
        LocalDateTime nowDatetime = LocalDateTime.now();
        LocalDateTime localDateTimeStart = nowDatetime.toLocalDate().atStartOfDay();
        LocalDateTime localDateTimeEnd = nowDatetime.toLocalDate().atStartOfDay();
        // dateTimeFormatter.format(localDateTimeStart), dateTimeFormatter.format(localDateTimeEnd)
        Long counts = pointsService.query().between("created_at", localDateTimeStart, localDateTimeEnd).count();
        // 创建新的积分主表记录
        Points points = new Points();
        points.setPointsName(pointsRuleDTO.getRuleName() + "_" + System.currentTimeMillis());
        points.setPointsName(pointsOld.getPointsName());
        points.setEffectiveStart(LocalDateTime.now());
        points.setModifierId(1L); // 这里应该从上下文中获取当前用户ID
        points.setModifierId(pointsOld.getModifierId()); // 这里应该从上下文中获取当前用户ID
        points.setModifierName("admin"); // 这里应该从上下文中获取当前用户名
        points.setVersion(1.0f);
        points.setVersion(counts>0 ? pointsOld.getVersion() + 0.1f: 1.0f);
        points.setStatus(0);
        pointsService.save(points);
        
        // 创建积分规则详情记录
        PointsRuleDetail pointsRuleDetail = new PointsRuleDetail();
        pointsRuleDetail.setRuleId(pointsRuleDTO.getId());
        pointsRuleDetail.setPointsId(points.getId());
        pointsRuleDetail.setPointsValue(pointsRuleDTO.getPointsValue());
        pointsRuleDetail.setEffectiveStart(LocalDateTime.now());
        pointsRuleDetailService.save(pointsRuleDetail);
        // 创建积分规则记录
        for (PointsRuleDTO ruleDTO : pointsRuleDTO) {
            PointsRule pointsRule = new PointsRule();
            BeanUtils.copyProperties(ruleDTO,pointsRule);
            pointsRule.setPointsId(points.getId());
            pointsRule.setUpdatedAt(LocalDateTime.now());
            save(pointsRule);
        }
        
        BeanUtils.copyProperties(pointsRuleDTO, existingRule);
        existingRule.setUpdatedAt(LocalDateTime.now());
        return updateById(existingRule);
        return true;
    }
    @Override
@@ -168,7 +170,7 @@
            throw new BusinessException("积分规则不存在");
        }
        
        pointsRule.setIsEnabled(isEnabled);
        pointsRule.setIsEnabled(isEnabled ? 0: 1);
        pointsRule.setUpdatedAt(LocalDateTime.now());
        
        return updateById(pointsRule);
src/main/java/com/webmanage/vo/PointsRuleVO.java
@@ -6,15 +6,15 @@
import java.util.List;
/**
 * @author c.y.b
 * @Title:
 * @Package
 * @Description:
 * @date 2025/8/1413:56
 */
 * @ClassName PointsRuleVO
 * @Description TODO
 * @Author wangxudong
 * @Date 2025/8/14 21:05
 * @Version 1.0
 **/
@Data
public class PointsRuleVO {
   private String category;
   private List<PointsRule> pointsRules;
    List<PointsRule> pointsRules;
    private Integer rlueSort;
}
src/main/resources/mapper/PointsFlowMapper.xml
File was deleted