From 1b1248f500a49f11f12c3cf9b469c300430b4514 Mon Sep 17 00:00:00 2001 From: p-honggang.li <p-honggang.li@pcitc.com> Date: 星期一, 18 八月 2025 10:02:03 +0800 Subject: [PATCH] Merge branch 'master' of http://xearth.cn:6600/r/web-manage/web-manage-back --- src/main/java/com/webmanage/entity/PointsRule.java | 25 + src/main/java/com/webmanage/mapper/PointsFlowMapper.java | 15 src/main/java/com/webmanage/service/impl/PointsFlowServiceImpl.java | 219 ++++++++--- src/main/java/com/webmanage/service/impl/PointsRuleServiceImpl.java | 86 ++-- src/main/java/com/webmanage/dto/PointsFlowQueryDTO.java | 11 src/main/java/com/webmanage/service/PointsRuleService.java | 2 src/main/java/com/webmanage/emun/RuleTypeEnum.java | 8 src/main/java/com/webmanage/mapper/PointsRuleMapper.java | 5 src/main/java/com/webmanage/controller/PointsController.java | 32 + src/main/java/com/webmanage/vo/PointsRuleVO.java | 18 src/main/java/com/webmanage/entity/PointsFlow.java | 8 src/main/java/com/webmanage/dto/AddPointsFlowDTO.java | 26 src/main/java/com/webmanage/dto/PointsRuleDTO.java | 40 + /dev/null | 40 -- sql/public.sql | 495 +++++++++++++++++---------- src/main/java/com/webmanage/service/PointsFlowService.java | 15 16 files changed, 638 insertions(+), 407 deletions(-) diff --git a/sql/public.sql b/sql/public.sql index e92529d..906f831 100644 --- a/sql/public.sql +++ b/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, '浜ゆ祦绀惧尯浜掑姩', '鍙栨秷鏀惰棌', '鍙戝竷鐨勫笘瀛愯鏀惰棌锛屽悗鍙堝彇娑堟敹钘忥紝璐$尞鑰� 鎵i櫎', 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, '浜ゆ祦绀惧尯浜掑姩', '鍒犻櫎甯栧瓙', '鑷繁鍙戝竷鐨勫笘瀛愯鍒犻櫎锛岃础鐚�� 鎵i櫎', 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, '浜ゆ祦绀惧尯浜掑姩', '鍒犻櫎鍥炲', '鑷繁鐨勫洖澶嶈鍒犻櫎锛岃础鐚�� 鎵i櫎', 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, '浜ゆ祦绀惧尯浜掑姩', '鍙栨秷鐐硅禐', '鍙戝竷鐨勫笘瀛愭垨鍋氬嚭鐨勫洖绛旇鐐硅禐鍚庡張鍙栨秷鐐硅禐锛岃础鐚�� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷璁㈤槄', '鎿嶄綔鑰� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷鏀惰棌', '鏁板瓧鍖栬祫婧愯鍙栨秷鏀惰棌锛岃础鐚�� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷鏀惰棌', '鎿嶄綔鑰� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷鐐硅禐', '鏁板瓧鍖栬祫婧愯鍙栨秷鐐硅禐锛岃础鐚�� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷鐐硅禐', '鎿嶄綔鑰� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷璁㈤槄', '鏁板瓧鍖栦骇鍝佽鍙栨秷璁㈤槄锛岃础鐚�� 鎵i櫎', 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, '浜ゆ祦绀惧尯浜掑姩', '鍙栨秷鏀惰棌', '鍙戝竷鐨勫笘瀛愯鏀惰棌锛屽悗鍙堝彇娑堟敹钘忥紝璐$尞鑰� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷璁㈤槄', '鎿嶄綔鑰� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷鏀惰棌', '鏁板瓧鍖栬祫婧愯鍙栨秷鏀惰棌锛岃础鐚�� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷鏀惰棌', '鎿嶄綔鑰� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷鐐硅禐', '鏁板瓧鍖栬祫婧愯鍙栨秷鐐硅禐锛岃础鐚�� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷鐐硅禐', '鎿嶄綔鑰� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷璁㈤槄', '鏁板瓧鍖栦骇鍝佽鍙栨秷璁㈤槄锛岃础鐚�� 鎵i櫎', 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, '浜ゆ祦绀惧尯浜掑姩', '鍒犻櫎甯栧瓙', '鑷繁鍙戝竷鐨勫笘瀛愯鍒犻櫎锛岃础鐚�� 鎵i櫎', 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, '浜ゆ祦绀惧尯浜掑姩', '鍒犻櫎鍥炲', '鑷繁鐨勫洖澶嶈鍒犻櫎锛岃础鐚�� 鎵i櫎', 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, '浜ゆ祦绀惧尯浜掑姩', '鍙栨秷鐐硅禐', '鍙戝竷鐨勫笘瀛愭垨鍋氬嚭鐨勫洖绛旇鐐硅禐鍚庡張鍙栨秷鐐硅禐锛岃础鐚�� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷璁㈤槄', '鎿嶄綔鑰� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷鏀惰棌', '鏁板瓧鍖栬祫婧愯鍙栨秷鏀惰棌锛岃础鐚�� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷鏀惰棌', '鎿嶄綔鑰� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷鐐硅禐', '鏁板瓧鍖栬祫婧愯鍙栨秷鐐硅禐锛岃础鐚�� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷鐐硅禐', '鎿嶄綔鑰� 鎵i櫎', 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, '璧勬簮浼犳挱', '鍙栨秷璁㈤槄', '鏁板瓧鍖栦骇鍝佽鍙栨秷璁㈤槄锛岃础鐚�� 鎵i櫎', 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, '浜ゆ祦绀惧尯浜掑姩', '鍙栨秷鏀惰棌', '鍙戝竷鐨勫笘瀛愯鏀惰棌锛屽悗鍙堝彇娑堟敹钘忥紝璐$尞鑰� 鎵i櫎', 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, '浜ゆ祦绀惧尯浜掑姩', '鍒犻櫎甯栧瓙', '鑷繁鍙戝竷鐨勫笘瀛愯鍒犻櫎锛岃础鐚�� 鎵i櫎', 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, '浜ゆ祦绀惧尯浜掑姩', '鍒犻櫎鍥炲', '鑷繁鐨勫洖澶嶈鍒犻櫎锛岃础鐚�� 鎵i櫎', 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, '浜ゆ祦绀惧尯浜掑姩', '鍙栨秷鐐硅禐', '鍙戝竷鐨勫笘瀛愭垨鍋氬嚭鐨勫洖绛旇鐐硅禐鍚庡張鍙栨秷鐐硅禐锛岃础鐚�� 鎵i櫎', 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['姝e父'::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['姝e父'::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['姝e父'::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['姝e父'::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['姝e父'::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['姝e父'::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; -- ---------------------------- diff --git a/src/main/java/com/webmanage/controller/PointsController.java b/src/main/java/com/webmanage/controller/PointsController.java index 942a46d..8f4214f 100644 --- a/src/main/java/com/webmanage/controller/PointsController.java +++ b/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()); + } + } } diff --git a/src/main/java/com/webmanage/dto/AddPointsFlowDTO.java b/src/main/java/com/webmanage/dto/AddPointsFlowDTO.java index 5fbb5c0..4712c53 100644 --- a/src/main/java/com/webmanage/dto/AddPointsFlowDTO.java +++ b/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; } diff --git a/src/main/java/com/webmanage/dto/PointsFlowQueryDTO.java b/src/main/java/com/webmanage/dto/PointsFlowQueryDTO.java index 3234cf0..98aaa5c 100644 --- a/src/main/java/com/webmanage/dto/PointsFlowQueryDTO.java +++ b/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"; diff --git a/src/main/java/com/webmanage/dto/PointsRuleDTO.java b/src/main/java/com/webmanage/dto/PointsRuleDTO.java index e816a14..e65ff38 100644 --- a/src/main/java/com/webmanage/dto/PointsRuleDTO.java +++ b/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; + } diff --git a/src/main/java/com/webmanage/dto/PointsRuleDetailDTO.java b/src/main/java/com/webmanage/dto/PointsRuleDetailDTO.java deleted file mode 100644 index 3ba8ca5..0000000 --- a/src/main/java/com/webmanage/dto/PointsRuleDetailDTO.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.webmanage.dto; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import javax.validation.constraints.NotNull; -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * 绉垎瑙勫垯璇︽儏DTO - */ -@Data -@ApiModel(value = "PointsRuleDetailDTO", description = "绉垎瑙勫垯璇︽儏") -public class PointsRuleDetailDTO { - - @ApiModelProperty("涓婚敭ID") - private Long id; - - @ApiModelProperty("鍏宠仈绉垎瑙勫垯ID") - @NotNull(message = "鍏宠仈绉垎瑙勫垯ID涓嶈兘涓虹┖") - private Long ruleId; - - @ApiModelProperty("鍏宠仈绉垎ID") - @NotNull(message = "鍏宠仈绉垎ID涓嶈兘涓虹┖") - private Long pointsId; - - @ApiModelProperty("绉垎鍊�") - @NotNull(message = "绉垎鍊间笉鑳戒负绌�") - private Integer pointsValue; - - @ApiModelProperty("姣忔棩绉垎涓婇檺鍊�") - private Integer dailyLimit; - - @ApiModelProperty("姣忔湀绉垎涓婇檺鍊�") - private Integer monthlyLimit; - - @ApiModelProperty("姣忓勾绉垎涓婇檺鍊�") - private Integer yearlyLimit; - - @ApiModelProperty("鏈�灏忓��") - private Integer minValue; - - @ApiModelProperty("鏈�澶у��") - private Integer maxValue; - - @ApiModelProperty("杞崲姣旂巼") - private BigDecimal conversionRate; - - @ApiModelProperty("鐢熸晥寮�濮嬫椂闂�") - private LocalDateTime effectiveStart; - - @ApiModelProperty("鐢熸晥缁撴潫鏃堕棿") - private LocalDateTime effectiveEnd; -} \ No newline at end of file diff --git a/src/main/java/com/webmanage/emun/RuleTypeEnum.java b/src/main/java/com/webmanage/emun/RuleTypeEnum.java index 284c77e..c933b80 100644 --- a/src/main/java/com/webmanage/emun/RuleTypeEnum.java +++ b/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; } diff --git a/src/main/java/com/webmanage/entity/PointsFlow.java b/src/main/java/com/webmanage/entity/PointsFlow.java index 0066883..c10a3de 100644 --- a/src/main/java/com/webmanage/entity/PointsFlow.java +++ b/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; } diff --git a/src/main/java/com/webmanage/entity/PointsRule.java b/src/main/java/com/webmanage/entity/PointsRule.java index 11bfdf7..96c2ee7 100644 --- a/src/main/java/com/webmanage/entity/PointsRule.java +++ b/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; + } diff --git a/src/main/java/com/webmanage/entity/PointsRuleDetail.java b/src/main/java/com/webmanage/entity/PointsRuleDetail.java deleted file mode 100644 index 15025d9..0000000 --- a/src/main/java/com/webmanage/entity/PointsRuleDetail.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.webmanage.entity; - -import com.baomidou.mybatisplus.annotation.*; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.time.LocalDateTime; - -/** - * 绉垎瑙勫垯璇︽儏瀹炰綋 - * - * @author webmanage - * @date 2024-08-07 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@TableName("points_rule_detail") -@ApiModel(value = "PointsRuleDetail", description = "绉垎瑙勫垯璇︽儏") -public class PointsRuleDetail implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("涓婚敭ID") - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - @ApiModelProperty("鍏宠仈绉垎瑙勫垯ID") - @TableField("rule_id") - private Long ruleId; - - @ApiModelProperty("鍏宠仈绉垎ID") - @TableField("points_id") - private Long pointsId; - - @ApiModelProperty("绉垎鍊�") - @TableField("points_value") - private Integer pointsValue; - - @ApiModelProperty("姣忔棩绉垎涓婇檺鍊�") - @TableField("daily_limit") - private Integer dailyLimit; - - @ApiModelProperty("姣忔湀绉垎涓婇檺鍊�") - @TableField("monthly_limit") - private Integer monthlyLimit; - - @ApiModelProperty("姣忓勾绉垎涓婇檺鍊�") - @TableField("yearly_limit") - private Integer yearlyLimit; - - @ApiModelProperty("鏈�灏忓��") - @TableField("min_value") - private Integer minValue; - - @ApiModelProperty("鏈�澶у��") - @TableField("max_value") - private Integer maxValue; - - @ApiModelProperty("杞崲姣旂巼") - @TableField("conversion_rate") - private BigDecimal conversionRate; - - @ApiModelProperty("鐢熸晥寮�濮嬫椂闂�") - @TableField("effective_start") - private LocalDateTime effectiveStart; - - @ApiModelProperty("鐢熸晥缁撴潫鏃堕棿") - @TableField("effective_end") - private LocalDateTime effectiveEnd; - - @ApiModelProperty("鍒涘缓鏃堕棿") - @TableField(value = "created_at", fill = FieldFill.INSERT) - private LocalDateTime createdAt; - - @ApiModelProperty("鏇存柊鏃堕棿") - @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE) - private LocalDateTime updatedAt; - - @ApiModelProperty("閫昏緫鍒犻櫎") - @TableLogic - @TableField("deleted") - private Integer deleted; -} \ No newline at end of file diff --git a/src/main/java/com/webmanage/entity/PointsRuleEntity.java b/src/main/java/com/webmanage/entity/PointsRuleEntity.java deleted file mode 100644 index 6245c1d..0000000 --- a/src/main/java/com/webmanage/entity/PointsRuleEntity.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.webmanage.entity; - -import com.baomidou.mybatisplus.annotation.*; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - * 绉垎瑙勫垯琛ㄥ疄浣� - * - * @author webmanage - * @date 2024-08-07 - */ -@Data -@EqualsAndHashCode(callSuper = false) -@TableName("points_rule") -@ApiModel(value = "PointsRuleEntity", description = "绉垎瑙勫垯") -public class PointsRuleEntity implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("涓婚敭ID") - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - @ApiModelProperty("鍏宠仈绉垎ID") - @TableField("points_id") - private Long pointsId; - - @ApiModelProperty("绉垎瑙勫垯绫诲瀷") - @TableField("rule_type") - private String ruleType; - - @ApiModelProperty("绉垎绫诲埆") - @TableField("category") - private String category; - - @ApiModelProperty("瑙勫垯鍚嶇О") - @TableField("rule_name") - private String ruleName; - - @ApiModelProperty("瑙勫垯鎻忚堪") - @TableField("rule_description") - private String ruleDescription; - - @ApiModelProperty("瑙勫垯鐘舵��") - @TableField("status") - private String status; - - @ApiModelProperty("鍒涘缓鏃堕棿") - @TableField(value = "created_at", fill = FieldFill.INSERT) - private LocalDateTime createdAt; - - @ApiModelProperty("鏇存柊鏃堕棿") - @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE) - private LocalDateTime updatedAt; - - @ApiModelProperty("閫昏緫鍒犻櫎") - @TableLogic - @TableField("deleted") - private Integer deleted; -} \ No newline at end of file diff --git a/src/main/java/com/webmanage/mapper/PointsFlowMapper.java b/src/main/java/com/webmanage/mapper/PointsFlowMapper.java index 71d0e43..6e30697 100644 --- a/src/main/java/com/webmanage/mapper/PointsFlowMapper.java +++ b/src/main/java/com/webmanage/mapper/PointsFlowMapper.java @@ -15,18 +15,5 @@ */ @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); + } diff --git a/src/main/java/com/webmanage/mapper/PointsRuleDetailMapper.java b/src/main/java/com/webmanage/mapper/PointsRuleDetailMapper.java deleted file mode 100644 index 0830499..0000000 --- a/src/main/java/com/webmanage/mapper/PointsRuleDetailMapper.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.webmanage.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.webmanage.entity.PointsRuleDetail; -import org.apache.ibatis.annotations.Mapper; - -/** - * 绉垎瑙勫垯璇︽儏Mapper鎺ュ彛 - * - * @author webmanage - * @date 2024-08-07 - */ -@Mapper -public interface PointsRuleDetailMapper extends BaseMapper<PointsRuleDetail> { -} \ No newline at end of file diff --git a/src/main/java/com/webmanage/mapper/PointsRuleMapper.java b/src/main/java/com/webmanage/mapper/PointsRuleMapper.java index 22a5edf..d93e189 100644 --- a/src/main/java/com/webmanage/mapper/PointsRuleMapper.java +++ b/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> { + } diff --git a/src/main/java/com/webmanage/service/PointsFlowService.java b/src/main/java/com/webmanage/service/PointsFlowService.java index 7ff3d0d..75c1211 100644 --- a/src/main/java/com/webmanage/service/PointsFlowService.java +++ b/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(); } diff --git a/src/main/java/com/webmanage/service/PointsRuleDetailService.java b/src/main/java/com/webmanage/service/PointsRuleDetailService.java deleted file mode 100644 index 2777f6d..0000000 --- a/src/main/java/com/webmanage/service/PointsRuleDetailService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.webmanage.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.webmanage.entity.PointsRuleDetail; - -/** - * 绉垎瑙勫垯璇︽儏Service鎺ュ彛 - */ -public interface PointsRuleDetailService extends IService<PointsRuleDetail> { - // 绉垎瑙勫垯璇︽儏鐩稿叧涓氬姟閫昏緫鏂规硶鍙湪姝ゆ坊鍔� -} \ No newline at end of file diff --git a/src/main/java/com/webmanage/service/PointsRuleService.java b/src/main/java/com/webmanage/service/PointsRuleService.java index ab3455c..8a566e5 100644 --- a/src/main/java/com/webmanage/service/PointsRuleService.java +++ b/src/main/java/com/webmanage/service/PointsRuleService.java @@ -27,7 +27,7 @@ /** * 淇敼绉垎瑙勫垯 */ - boolean updatePointsRule(PointsRuleDTO pointsRuleDTO); + boolean updatePointsRule(List<PointsRuleDTO> pointsRuleDetailsVOS); /** * 鍒犻櫎绉垎瑙勫垯 diff --git a/src/main/java/com/webmanage/service/impl/PointsFlowServiceImpl.java b/src/main/java/com/webmanage/service/impl/PointsFlowServiceImpl.java index 9188feb..8cdf5be 100644 --- a/src/main/java/com/webmanage/service/impl/PointsFlowServiceImpl.java +++ b/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銆乺uleNameCode銆乧ategory鏌ヨ鐢熸晥鏃堕棿鏈�鏂扮殑绉垎瑙勫垯 + 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涓嶈兘涓簄ull"); } 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涓嶈兘涓簄ull"); } 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銆乺uleNameCode銆乧ategory鏌ヨ鐢熸晥鏃堕棿鏈�鏂扮殑绉垎瑙勫垯 + */ + 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) { + // 濡傛灉鏄柊鐢ㄦ埛涓旀槸鎵gН鍒嗘搷浣滐紝浣欓涓嶈冻 + 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) { + // 濡傛灉鏄柊鍗曚綅涓旀槸鎵gН鍒嗘搷浣滐紝浣欓涓嶈冻 + 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); // 鏇存柊绱鑾峰彇绉垎 diff --git a/src/main/java/com/webmanage/service/impl/PointsRuleDetailServiceImpl.java b/src/main/java/com/webmanage/service/impl/PointsRuleDetailServiceImpl.java deleted file mode 100644 index 657f145..0000000 --- a/src/main/java/com/webmanage/service/impl/PointsRuleDetailServiceImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.webmanage.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.webmanage.entity.PointsRuleDetail; -import com.webmanage.mapper.PointsRuleDetailMapper; -import com.webmanage.service.PointsRuleDetailService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -/** - * 绉垎瑙勫垯璇︽儏Service瀹炵幇绫� - */ -@Slf4j -@Service -public class PointsRuleDetailServiceImpl extends ServiceImpl<PointsRuleDetailMapper, PointsRuleDetail> implements PointsRuleDetailService { - // 绉垎瑙勫垯璇︽儏鐩稿叧涓氬姟閫昏緫瀹炵幇鍙湪姝ゆ坊鍔� -} \ No newline at end of file diff --git a/src/main/java/com/webmanage/service/impl/PointsRuleServiceImpl.java b/src/main/java/com/webmanage/service/impl/PointsRuleServiceImpl.java index 05d9e37..1512773 100644 --- a/src/main/java/com/webmanage/service/impl/PointsRuleServiceImpl.java +++ b/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; @@ -36,9 +42,7 @@ @Autowired private PointsService pointsService; - - @Autowired - private PointsRuleDetailService pointsRuleDetailService; + @Override public PointsRuleResultVO getPointsRuleList(Long ruleId) { @@ -46,7 +50,7 @@ QueryWrapper<PointsRule> wrapper = new QueryWrapper<>(); wrapper.eq("deleted", 0).eq("is_enabled",0); - + if(ruleId != null){ wrapper.eq("points_id", 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); // 杩欓噷搴旇浠庝笂涓嬫枃涓幏鍙栧綋鍓嶇敤鎴稩D + points.setModifierId(pointsOld.getModifierId()); // 杩欓噷搴旇浠庝笂涓嬫枃涓幏鍙栧綋鍓嶇敤鎴稩D 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); - - BeanUtils.copyProperties(pointsRuleDTO, existingRule); - existingRule.setUpdatedAt(LocalDateTime.now()); - - return updateById(existingRule); + // 鍒涘缓绉垎瑙勫垯璁板綍 + for (PointsRuleDTO ruleDTO : pointsRuleDTO) { + PointsRule pointsRule = new PointsRule(); + BeanUtils.copyProperties(ruleDTO,pointsRule); + pointsRule.setPointsId(points.getId()); + pointsRule.setUpdatedAt(LocalDateTime.now()); + save(pointsRule); + } + + 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); diff --git a/src/main/java/com/webmanage/vo/PointsRuleVO.java b/src/main/java/com/webmanage/vo/PointsRuleVO.java index 9dcb011..54233cb 100644 --- a/src/main/java/com/webmanage/vo/PointsRuleVO.java +++ b/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; + private String category; + List<PointsRule> pointsRules; + private Integer rlueSort; } diff --git a/src/main/resources/mapper/PointsFlowMapper.xml b/src/main/resources/mapper/PointsFlowMapper.xml deleted file mode 100644 index 9f25c8b..0000000 --- a/src/main/resources/mapper/PointsFlowMapper.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> -<mapper namespace="com.webmanage.mapper.PointsFlowMapper"> - - <!-- 鍒嗛〉鏌ヨ绉垎娴佹按锛堟敮鎸佺敤鎴�/鍗曚綅缁村害杩囨护锛� --> - <select id="selectPage" resultType="com.webmanage.entity.PointsFlow"> - SELECT * - FROM points_flow - WHERE deleted = 0 - <if test="userId != null"> - AND user_id = #{userId} - </if> - <if test="unitId != null"> - AND unit_id = #{unitId} - </if> - <if test="dataCategory != null and dataCategory != ''"> - AND data_category = #{dataCategory} - </if> - <if test="dataType != null and dataType != ''"> - AND data_type = #{dataType} - </if> - <if test="startTime != null and startTime != ''"> - AND flow_time >= #{startTime}::timestamp - </if> - <if test="endTime != null and endTime != ''"> - AND flow_time <= #{endTime}::timestamp - </if> - <if test="year != null and year != ''"> - AND EXTRACT(YEAR FROM flow_time) = #{year}::integer - </if> - <if test="month != null and month != ''"> - AND EXTRACT(MONTH FROM flow_time) = #{month}::integer - </if> - <if test="day != null and day != ''"> - AND EXTRACT(DAY FROM flow_time) = #{day}::integer - </if> - ORDER BY flow_time DESC - </select> - -</mapper> -- Gitblit v1.8.0