From fefed50bf97060a82aabd09e090fa08ce532532f Mon Sep 17 00:00:00 2001 From: p-honggang.li <p-honggang.li@pcitc.com> Date: 星期三, 20 八月 2025 10:59:04 +0800 Subject: [PATCH] Merge branch 'master' of http://xearth.cn:6600/r/web-manage/web-manage-back --- src/main/java/com/webmanage/service/OrderInfoService.java | 2 src/main/java/com/webmanage/WebManageApplication.java | 2 src/main/java/com/webmanage/mapper/CartMapper.java | 2 src/main/java/com/webmanage/service/impl/ProductPricingServiceImpl.java | 27 src/main/resources/mapper/CartMapper.xml | 3 src/main/java/com/webmanage/service/impl/CartServiceImpl.java | 165 ++-- sql/public_new.sql | 1575 +++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/webmanage/config/AsyncExecutorProperties.java | 40 + src/main/resources/mapper/ProductPricingMapper.xml | 5 src/main/java/com/webmanage/service/TokenService.java | 22 src/main/java/com/webmanage/config/CartProperties.java | 31 src/main/java/com/webmanage/controller/OrderController.java | 27 src/main/java/com/webmanage/entity/Cart.java | 1 src/main/java/com/webmanage/emun/PriceTypeEnum.java | 20 src/main/java/com/webmanage/service/impl/TokenServiceImpl.java | 45 + src/main/java/com/webmanage/config/RedisConfig.java | 5 src/main/java/com/webmanage/service/impl/CartPersistenceServiceImpl.java | 64 + src/main/java/com/webmanage/service/impl/OrderInfoServiceImpl.java | 4 src/main/java/com/webmanage/entity/ProductPricing.java | 12 src/main/java/com/webmanage/config/AsyncConfig.java | 52 + src/main/java/com/webmanage/vo/CartItemVO.java | 3 src/main/resources/application.yml | 17 src/main/java/com/webmanage/service/CartPersistenceService.java | 11 23 files changed, 2,039 insertions(+), 96 deletions(-) diff --git a/sql/public_new.sql b/sql/public_new.sql new file mode 100644 index 0000000..f2df232 --- /dev/null +++ b/sql/public_new.sql @@ -0,0 +1,1575 @@ +/* + Navicat Premium Data Transfer + + Source Server : pgSQL + Source Server Type : PostgreSQL + Source Server Version : 130000 + Source Host : localhost:5432 + Source Catalog : web_manage + Source Schema : public + + Target Server Type : PostgreSQL + Target Server Version : 130000 + File Encoding : 65001 + + Date: 19/08/2025 18:11:08 +*/ + + +-- ---------------------------- +-- Sequence structure for cart_id_seq +-- ---------------------------- +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 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for order_approval_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."order_approval_id_seq"; +CREATE SEQUENCE "public"."order_approval_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +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 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for order_detail_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."order_detail_id_seq"; +CREATE SEQUENCE "public"."order_detail_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +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 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for points_account_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."points_account_id_seq"; +CREATE SEQUENCE "public"."points_account_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for points_flow_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."points_flow_id_seq"; +CREATE SEQUENCE "public"."points_flow_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for points_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."points_id_seq"; +CREATE SEQUENCE "public"."points_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"; +CREATE SEQUENCE "public"."points_rule_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for points_transaction_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."points_transaction_id_seq"; +CREATE SEQUENCE "public"."points_transaction_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for product_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."product_id_seq"; +CREATE SEQUENCE "public"."product_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +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"; +CREATE SEQUENCE "public"."product_pricing_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +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 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for user_points_id_seq +-- ---------------------------- +DROP SEQUENCE IF EXISTS "public"."user_points_id_seq"; +CREATE SEQUENCE "public"."user_points_id_seq" +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +CACHE 1; + +-- ---------------------------- +-- Sequence structure for users_id_seq +-- ---------------------------- +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 +START 1 +CACHE 1; + +-- ---------------------------- +-- Table structure for cart +-- ---------------------------- +DROP TABLE IF EXISTS "public"."cart"; +CREATE TABLE "public"."cart" ( + "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY ( +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +), + "user_id" int8 NOT NULL, + "unit_id" int8 NOT NULL, + "pricing_id" int8 NOT NULL, + "product_id" int8 NOT NULL, + "product_name" text COLLATE "pg_catalog"."default", + "suite_name" text COLLATE "pg_catalog"."default", + "sales_form" text COLLATE "pg_catalog"."default", + "customer_type" text COLLATE "pg_catalog"."default", + "account_limit" text COLLATE "pg_catalog"."default", + "concurrent_nodes" text COLLATE "pg_catalog"."default", + "price_type" text COLLATE "pg_catalog"."default", + "price_unit" text COLLATE "pg_catalog"."default", + "unit_price" numeric(15,2) NOT NULL, + "quantity" int4 NOT NULL DEFAULT 1, + "duration" int4, + "total_price" numeric(15,2), + "provider_id" int8, + "provider_name" text COLLATE "pg_catalog"."default", + "remarks" text COLLATE "pg_catalog"."default", + "add_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "update_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "deleted" int4 DEFAULT 0 +) +; +COMMENT ON TABLE "public"."cart" IS '璐墿杞﹁〃'; + +-- ---------------------------- +-- Records of cart +-- ---------------------------- + +-- ---------------------------- +-- Table structure for order_approval +-- ---------------------------- +DROP TABLE IF EXISTS "public"."order_approval"; +CREATE TABLE "public"."order_approval" ( + "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY ( +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +), + "order_id" text COLLATE "pg_catalog"."default" NOT NULL, + "approval_step" text COLLATE "pg_catalog"."default" NOT NULL, + "approval_type" text COLLATE "pg_catalog"."default" NOT NULL, + "approval_opinion" text COLLATE "pg_catalog"."default", + "approval_result" text COLLATE "pg_catalog"."default" NOT NULL, + "approver_id" int8 NOT NULL, + "approver_name" text COLLATE "pg_catalog"."default" NOT NULL, + "approver_role" text COLLATE "pg_catalog"."default", + "approval_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "next_approver_id" int8, + "next_approver_name" text COLLATE "pg_catalog"."default", + "workflow_status" text COLLATE "pg_catalog"."default", + "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "deleted" int4 DEFAULT 0 +) +; +COMMENT ON TABLE "public"."order_approval" IS '璁㈠崟瀹℃牳琛�'; + +-- ---------------------------- +-- Records of order_approval +-- ---------------------------- + +-- ---------------------------- +-- Table structure for order_attachment +-- ---------------------------- +DROP TABLE IF EXISTS "public"."order_attachment"; +CREATE TABLE "public"."order_attachment" ( + "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY ( +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +), + "order_id" text COLLATE "pg_catalog"."default" NOT NULL, + "file_name" text COLLATE "pg_catalog"."default" NOT NULL, + "original_name" text COLLATE "pg_catalog"."default", + "file_type" text COLLATE "pg_catalog"."default" NOT NULL, + "file_size" int8 NOT NULL, + "file_url" text COLLATE "pg_catalog"."default" NOT NULL, + "file_path" text COLLATE "pg_catalog"."default", + "bucket_name" text COLLATE "pg_catalog"."default", + "object_name" text COLLATE "pg_catalog"."default", + "upload_user_id" int8, + "upload_user_name" text COLLATE "pg_catalog"."default", + "attachment_type" text COLLATE "pg_catalog"."default", + "description" text COLLATE "pg_catalog"."default", + "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "deleted" int4 DEFAULT 0 +) +; +COMMENT ON TABLE "public"."order_attachment" IS '璁㈠崟闄勪欢琛�'; + +-- ---------------------------- +-- Records of order_attachment +-- ---------------------------- + +-- ---------------------------- +-- Table structure for order_detail +-- ---------------------------- +DROP TABLE IF EXISTS "public"."order_detail"; +CREATE TABLE "public"."order_detail" ( + "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY ( +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +), + "order_id" text COLLATE "pg_catalog"."default" NOT NULL, + "pricing_id" int8 NOT NULL, + "product_id" int8 NOT NULL, + "suite_name" text COLLATE "pg_catalog"."default" NOT NULL, + "sales_form" text COLLATE "pg_catalog"."default" NOT NULL, + "customer_type" text COLLATE "pg_catalog"."default" NOT NULL, + "account_limit" text COLLATE "pg_catalog"."default", + "concurrent_nodes" text COLLATE "pg_catalog"."default", + "price_type" text COLLATE "pg_catalog"."default" NOT NULL, + "price_unit" text COLLATE "pg_catalog"."default" NOT NULL, + "unit_price" numeric(15,2) NOT NULL, + "quantity" int4 NOT NULL, + "duration" int4, + "total_price" numeric(15,2) NOT NULL, + "provider_id" int8 NOT NULL, + "provider_name" text COLLATE "pg_catalog"."default", + "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "remarks" text COLLATE "pg_catalog"."default", + "deleted" int4 DEFAULT 0 +) +; +COMMENT ON TABLE "public"."order_detail" IS '璁㈠崟璇︽儏琛�'; + +-- ---------------------------- +-- Records of order_detail +-- ---------------------------- +INSERT INTO "public"."order_detail" OVERRIDING SYSTEM VALUE VALUES (1, '202508191718590806528000', 5, 1, '浼佷笟绉佹湁SaaS鐗堣鍙�', '绉佹湁澧為噺鍖�', '涓汉', '2', '3', '绉垎', '濂�/骞�', 200.00, 1, 1, 200.00, 3, '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', '2025-08-19 17:18:59.649', '2025-08-19 17:18:59.649', '', 0); +INSERT INTO "public"."order_detail" OVERRIDING SYSTEM VALUE VALUES (2, '202508191718590806528000', 4, 1, '浼佷笟绉佹湁SaaS鐗堣鍙�', '绉熻祦', '涓汉', '1', '1', '绉垎', '濂�/骞�', 200.00, 1, 1, 200.00, 3, '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', '2025-08-19 17:18:59.66', '2025-08-19 17:18:59.66', '', 0); +INSERT INTO "public"."order_detail" OVERRIDING SYSTEM VALUE VALUES (3, '202508191718590806528000', 9, 1, '浼佷笟绉佹湁SaaS鐗堢敤鎴峰閲忓寘', '绉佹湁澧為噺鍖�', '椤圭洰閮�', '1', '1', '鍏嶈垂', '骞�', 0.00, 1, 1, 0.00, 3, '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', '2025-08-19 17:18:59.664', '2025-08-19 17:18:59.664', '', 0); +INSERT INTO "public"."order_detail" OVERRIDING SYSTEM VALUE VALUES (4, '202508191730018270442496', 2, 1, '涓撲笟鐗�', '绉熻祦', '浼佷笟', '涓嶉檺', '涓嶉檺', '绉垎', '濂�/骞�', 500.00, 1, 1, 500.00, 3, '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', '2025-08-19 17:30:01.814', '2025-08-19 17:30:01.814', '', 0); +INSERT INTO "public"."order_detail" OVERRIDING SYSTEM VALUE VALUES (5, '202508191732232175500288', 1, 1, '鍩虹鐗�', '涔版柇', '浼佷笟', '涓嶉檺', '涓嶉檺', '绉垎', '濂�', 1000.00, 1, 1, 1000.00, 3, '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', '2025-08-19 17:32:23.412', '2025-08-19 17:32:23.412', '', 0); +INSERT INTO "public"."order_detail" OVERRIDING SYSTEM VALUE VALUES (6, '202508191735337897883648', 9, 1, '浼佷笟绉佹湁SaaS鐗堢敤鎴峰閲忓寘', '绉佹湁澧為噺鍖�', '椤圭洰閮�', '1', '1', '鍏嶈垂', '骞�', 0.00, 1, 1, 0.00, 3, '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', '2025-08-19 17:35:33.127', '2025-08-19 17:35:33.127', '', 0); +INSERT INTO "public"."order_detail" OVERRIDING SYSTEM VALUE VALUES (7, '202508191745527049352192', 5, 1, '浼佷笟绉佹湁SaaS鐗堣鍙�', '绉佹湁澧為噺鍖�', '涓汉', '2', '3', '绉垎', '濂�/骞�', 200.00, 1, 1, 200.00, 3, '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', '2025-08-19 17:45:52.815', '2025-08-19 17:45:52.815', '', 0); +INSERT INTO "public"."order_detail" OVERRIDING SYSTEM VALUE VALUES (8, '202508191752392071676928', 9, 1, '浼佷笟绉佹湁SaaS鐗堢敤鎴峰閲忓寘', '绉佹湁澧為噺鍖�', '椤圭洰閮�', '1', '1', '鍏嶈垂', '骞�', 0.00, 1, 1, 0.00, 3, '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', '2025-08-19 17:52:39.325', '2025-08-19 17:52:39.325', '', 0); +INSERT INTO "public"."order_detail" OVERRIDING SYSTEM VALUE VALUES (9, '202508191809061614843904', 4, 1, '浼佷笟绉佹湁SaaS鐗堣鍙�', '绉熻祦', '涓汉', '1', '1', '绉垎', '濂�/骞�', 200.00, 1, 1, 200.00, 3, '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', '2025-08-19 18:09:06.269', '2025-08-19 18:09:06.269', '', 0); +INSERT INTO "public"."order_detail" OVERRIDING SYSTEM VALUE VALUES (10, '202508191809061614843904', 9, 1, '浼佷笟绉佹湁SaaS鐗堢敤鎴峰閲忓寘', '绉佹湁澧為噺鍖�', '椤圭洰閮�', '1', '1', '鍏嶈垂', '骞�', 0.00, 1, 1, 0.00, 3, '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', '2025-08-19 18:09:06.275', '2025-08-19 18:09:06.275', '', 0); + +-- ---------------------------- +-- Table structure for order_evaluation +-- ---------------------------- +DROP TABLE IF EXISTS "public"."order_evaluation"; +CREATE TABLE "public"."order_evaluation" ( + "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY ( +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +), + "order_id" text COLLATE "pg_catalog"."default" NOT NULL, + "evaluator_id" int8 NOT NULL, + "evaluator_name" text COLLATE "pg_catalog"."default" NOT NULL, + "evaluator_type" text COLLATE "pg_catalog"."default" NOT NULL, + "content" text COLLATE "pg_catalog"."default" NOT NULL, + "rating" int4 NOT NULL, + "service_rating" int4, + "quality_rating" int4, + "delivery_rating" int4, + "is_anonymous" bool DEFAULT false, + "reply_content" text COLLATE "pg_catalog"."default", + "reply_user_id" int8, + "reply_time" timestamp(6), + "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "deleted" int4 DEFAULT 0 +) +; +COMMENT ON TABLE "public"."order_evaluation" IS '璁㈠崟璇勪环琛�'; + +-- ---------------------------- +-- Records of order_evaluation +-- ---------------------------- + +-- ---------------------------- +-- Table structure for order_info +-- ---------------------------- +DROP TABLE IF EXISTS "public"."order_info"; +CREATE TABLE "public"."order_info" ( + "order_id" text COLLATE "pg_catalog"."default" NOT NULL, + "product_id" int8 NOT NULL, + "user_id" int8 NOT NULL, + "unit_id" int8, + "product_name" text COLLATE "pg_catalog"."default" NOT NULL, + "provider_name" text COLLATE "pg_catalog"."default" NOT NULL, + "provider_id" int8 NOT NULL, + "apply_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "order_status" text COLLATE "pg_catalog"."default" NOT NULL DEFAULT '寰呭鎵�'::text, + "total_amount" numeric(15,2) NOT NULL, + "payment_type" text COLLATE "pg_catalog"."default", + "payment_status" text COLLATE "pg_catalog"."default" DEFAULT '鏈敮浠�'::text, + "workflow_id" text COLLATE "pg_catalog"."default", + "current_step" text COLLATE "pg_catalog"."default", + "approval_flow" text COLLATE "pg_catalog"."default", + "buyer_remarks" text COLLATE "pg_catalog"."default", + "seller_remarks" text COLLATE "pg_catalog"."default", + "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "deleted" int4 DEFAULT 0 +) +; +COMMENT ON TABLE "public"."order_info" IS '璁㈠崟琛�'; + +-- ---------------------------- +-- Records of order_info +-- ---------------------------- +INSERT INTO "public"."order_info" VALUES ('202508191718590806528000', 1, 1, 1, '涓氦鏂硅繙鏅鸿兘瀹炴祴瀹為噺绠$悊绯荤粺', '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', 3, '2025-08-19 17:18:59.608', '寰呭鎵�', 400.00, '绉垎', '鏈敮浠�', NULL, NULL, NULL, '', NULL, '2025-08-19 17:18:59.608', '2025-08-19 17:18:59.608', 0); +INSERT INTO "public"."order_info" VALUES ('202508191730018270442496', 1, 1, 1, '涓氦鏂硅繙鏅鸿兘瀹炴祴瀹為噺绠$悊绯荤粺', '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', 3, '2025-08-19 17:30:01.807', '寰呭鎵�', 500.00, '绉垎', '鏈敮浠�', NULL, NULL, NULL, '', NULL, '2025-08-19 17:30:01.807', '2025-08-19 17:30:01.807', 0); +INSERT INTO "public"."order_info" VALUES ('202508191732232175500288', 1, 1, 1, '涓氦鏂硅繙鏅鸿兘瀹炴祴瀹為噺绠$悊绯荤粺', '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', 3, '2025-08-19 17:32:23.405', '寰呭鎵�', 1000.00, '绉垎', '鏈敮浠�', NULL, NULL, NULL, '', NULL, '2025-08-19 17:32:23.405', '2025-08-19 17:32:23.405', 0); +INSERT INTO "public"."order_info" VALUES ('202508191735337897883648', 1, 1, 1, '涓氦鏂硅繙鏅鸿兘瀹炴祴瀹為噺绠$悊绯荤粺', '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', 3, '2025-08-19 17:35:33.12', '寰呭鎵�', 0.00, '绉垎', '鏈敮浠�', NULL, NULL, NULL, '', NULL, '2025-08-19 17:35:33.12', '2025-08-19 17:35:33.12', 0); +INSERT INTO "public"."order_info" VALUES ('202508191745527049352192', 1, 1, 1, '涓氦鏂硅繙鏅鸿兘瀹炴祴瀹為噺绠$悊绯荤粺', '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', 3, '2025-08-19 17:45:52.806', '寰呭鎵�', 200.00, '绉垎', '鏈敮浠�', NULL, NULL, NULL, '', NULL, '2025-08-19 17:45:52.807', '2025-08-19 17:45:52.807', 0); +INSERT INTO "public"."order_info" VALUES ('202508191752392071676928', 1, 1, 1, '涓氦鏂硅繙鏅鸿兘瀹炴祴瀹為噺绠$悊绯荤粺', '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', 3, '2025-08-19 17:52:39.316', '寰呭鎵�', 0.00, '绉垎', '鏈敮浠�', NULL, NULL, NULL, '', NULL, '2025-08-19 17:52:39.316', '2025-08-19 17:52:39.316', 0); +INSERT INTO "public"."order_info" VALUES ('202508191809061614843904', 1, 1, 1, '涓氦鏂硅繙鏅鸿兘瀹炴祴瀹為噺绠$悊绯荤粺', '涓氦寤虹瓚闆嗗洟绗竴宸ョ▼鏈夐檺鍏徃', 3, '2025-08-19 18:09:06.259', '寰呭鎵�', 200.00, '绉垎', '鏈敮浠�', NULL, NULL, NULL, '', NULL, '2025-08-19 18:09:06.259', '2025-08-19 18:09:06.259', 0); + +-- ---------------------------- +-- Table structure for points +-- ---------------------------- +DROP TABLE IF EXISTS "public"."points"; +CREATE TABLE "public"."points" ( + "id" int8 NOT NULL DEFAULT nextval('points_id_seq'::regclass), + "points_name" varchar COLLATE "pg_catalog"."default" NOT NULL, + "effective_start" timestamp(0) NOT NULL, + "modifier_id" int8 NOT NULL, + "modifier_name" varchar COLLATE "pg_catalog"."default" NOT NULL, + "version" numeric(2,1) NOT NULL, + "description" text COLLATE "pg_catalog"."default", + "status" int2, + "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "deleted" int2 DEFAULT 0 +) +; +COMMENT ON COLUMN "public"."points"."points_name" IS '绉垎鍚嶇О'; +COMMENT ON COLUMN "public"."points"."effective_start" IS '鐢熸晥寮�濮嬫椂闂�'; +COMMENT ON COLUMN "public"."points"."modifier_id" IS '淇敼浜篒D'; +COMMENT ON COLUMN "public"."points"."modifier_name" IS '淇敼浜哄鍚�'; +COMMENT ON COLUMN "public"."points"."version" IS '鐗堟湰鍙�'; +COMMENT ON COLUMN "public"."points"."description" IS '绉垎鎻忚堪'; +COMMENT ON COLUMN "public"."points"."status" IS '鐘舵��(0鍚敤1绂佺敤)'; +COMMENT ON COLUMN "public"."points"."created_at" IS '鍒涘缓鏃堕棿'; +COMMENT ON COLUMN "public"."points"."updated_at" IS '鏇存柊鏃堕棿'; +COMMENT ON COLUMN "public"."points"."deleted" IS '閫昏緫鍒犻櫎(1鍒犻櫎)'; +COMMENT ON TABLE "public"."points" IS '绉垎涓昏〃'; + +-- ---------------------------- +-- 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 +-- ---------------------------- +DROP TABLE IF EXISTS "public"."points_account"; +CREATE TABLE "public"."points_account" ( + "id" int8 NOT NULL DEFAULT nextval('points_account_id_seq'::regclass), + "user_id" int8 NOT NULL, + "points_balance" int4 NOT NULL DEFAULT 0, + "total_earned" int4 NOT NULL DEFAULT 0, + "total_consumed" int4 NOT NULL DEFAULT 0, + "account_type" text COLLATE "pg_catalog"."default" NOT NULL, + "account_status" text COLLATE "pg_catalog"."default" DEFAULT '姝e父'::text, + "last_transaction_time" timestamptz(6), + "created_at" timestamptz(6) DEFAULT CURRENT_TIMESTAMP, + "updated_at" timestamptz(6) DEFAULT CURRENT_TIMESTAMP, + "deleted" int2 DEFAULT 0 +) +; +COMMENT ON COLUMN "public"."points_account"."user_id" IS '鐢ㄦ埛ID'; +COMMENT ON COLUMN "public"."points_account"."points_balance" IS '绉垎浣欓'; +COMMENT ON COLUMN "public"."points_account"."total_earned" IS '绱鑾峰彇绉垎'; +COMMENT ON COLUMN "public"."points_account"."total_consumed" IS '绱娑堣�楃Н鍒�'; +COMMENT ON COLUMN "public"."points_account"."account_type" IS '璐︽埛绫诲瀷'; +COMMENT ON COLUMN "public"."points_account"."account_status" IS '璐︽埛鐘舵��'; +COMMENT ON COLUMN "public"."points_account"."last_transaction_time" IS '鏈�鍚庝氦鏄撴椂闂�'; +COMMENT ON COLUMN "public"."points_account"."created_at" IS '鍒涘缓鏃堕棿'; +COMMENT ON COLUMN "public"."points_account"."updated_at" IS '鏇存柊鏃堕棿'; +COMMENT ON COLUMN "public"."points_account"."deleted" IS '閫昏緫鍒犻櫎'; +COMMENT ON TABLE "public"."points_account" IS '绉垎璐︽埛琛�'; + +-- ---------------------------- +-- Records of points_account +-- ---------------------------- + +-- ---------------------------- +-- Table structure for points_flow +-- ---------------------------- +DROP TABLE IF EXISTS "public"."points_flow"; +CREATE TABLE "public"."points_flow" ( + "id" int8 NOT NULL DEFAULT nextval('points_flow_id_seq'::regclass), + "user_id" int8, + "unit_id" int8, + "data_category" varchar(100) COLLATE "pg_catalog"."default" NOT NULL, + "data_type" int2 NOT NULL, + "name" text COLLATE "pg_catalog"."default" NOT NULL, + "points" int4 NOT NULL, + "flow_time" timestamp(6) NOT NULL, + "create_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "update_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "deleted" int4 DEFAULT 0, + "rule_id" int4 +) +; +COMMENT ON COLUMN "public"."points_flow"."user_id" IS '鐢ㄦ埛ID'; +COMMENT ON COLUMN "public"."points_flow"."unit_id" IS '鍗曚綅ID'; +COMMENT ON COLUMN "public"."points_flow"."data_category" IS '鏁版嵁绫荤洰'; +COMMENT ON COLUMN "public"."points_flow"."data_type" IS '鏁版嵁绫诲瀷'; +COMMENT ON COLUMN "public"."points_flow"."name" IS '鍚嶇О/鎻忚堪'; +COMMENT ON COLUMN "public"."points_flow"."points" IS '绉垎鍊�'; +COMMENT ON COLUMN "public"."points_flow"."flow_time" IS '娴佹按鏃堕棿'; +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, '璧勬簮璐$尞', 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 +-- ---------------------------- +DROP TABLE IF EXISTS "public"."points_rule"; +CREATE TABLE "public"."points_rule" ( + "id" int8 NOT NULL DEFAULT nextval('points_rule_id_seq'::regclass), + "points_id" int8 NOT NULL, + "rule_type" int2 NOT NULL, + "category" varchar COLLATE "pg_catalog"."default" NOT NULL, + "rule_name" varchar COLLATE "pg_catalog"."default" NOT NULL, + "rule_description" varchar COLLATE "pg_catalog"."default", + "is_enabled" int2 DEFAULT 0, + "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "deleted" int2 DEFAULT 0, + "points_winner" int2, + "is_limit" int2, + "rule_order" int2, + "points_value" int2, + "daily_limit" int2, + "rule_name_code" varchar(255) COLLATE "pg_catalog"."default" NOT NULL +) +; +COMMENT ON COLUMN "public"."points_rule"."points_id" IS '鍏宠仈绉垎ID'; +COMMENT ON COLUMN "public"."points_rule"."rule_type" IS '绉垎瑙勫垯绫诲瀷(0鑾峰彇1娑堣��)'; +COMMENT ON COLUMN "public"."points_rule"."category" IS '绉垎绫诲埆'; +COMMENT ON COLUMN "public"."points_rule"."rule_name" IS '瑙勫垯鍚嶇О'; +COMMENT ON COLUMN "public"."points_rule"."rule_description" IS '瑙勫垯鎻忚堪'; +COMMENT ON COLUMN "public"."points_rule"."is_enabled" IS '瑙勫垯鐘舵��(0鍚姩1绂佺敤)'; +COMMENT ON COLUMN "public"."points_rule"."created_at" IS '鍒涘缓鏃堕棿'; +COMMENT ON COLUMN "public"."points_rule"."updated_at" IS '鏇存柊鏃堕棿'; +COMMENT ON COLUMN "public"."points_rule"."deleted" IS '閫昏緫鍒犻櫎'; +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 (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 +-- ---------------------------- +DROP TABLE IF EXISTS "public"."points_transaction"; +CREATE TABLE "public"."points_transaction" ( + "id" int8 NOT NULL DEFAULT nextval('points_transaction_id_seq'::regclass), + "data_category" text COLLATE "pg_catalog"."default" NOT NULL, + "transaction_name" text COLLATE "pg_catalog"."default" NOT NULL, + "transaction_time" timestamptz(6) DEFAULT CURRENT_TIMESTAMP, + "points_change" int4 NOT NULL, + "rule_type" text COLLATE "pg_catalog"."default" NOT NULL, + "user_id" int8, + "unit_id" int8, + "user_type" text COLLATE "pg_catalog"."default" NOT NULL, + "rule_id" int8, + "detail_id" int8, + "created_at" timestamptz(6) DEFAULT CURRENT_TIMESTAMP, + "deleted" int2 DEFAULT 0 +) +; +COMMENT ON COLUMN "public"."points_transaction"."data_category" IS '鏁版嵁绫荤洰'; +COMMENT ON COLUMN "public"."points_transaction"."transaction_name" IS '鍚嶇О'; +COMMENT ON COLUMN "public"."points_transaction"."transaction_time" IS '鏃堕棿'; +COMMENT ON COLUMN "public"."points_transaction"."points_change" IS '绉垎鍙樺姩鍊�'; +COMMENT ON COLUMN "public"."points_transaction"."rule_type" IS '绉垎瑙勫垯绫诲瀷'; +COMMENT ON COLUMN "public"."points_transaction"."user_id" IS '鐢ㄦ埛ID'; +COMMENT ON COLUMN "public"."points_transaction"."unit_id" IS '浼佷笟ID'; +COMMENT ON COLUMN "public"."points_transaction"."user_type" IS '鐢ㄦ埛绫诲瀷'; +COMMENT ON COLUMN "public"."points_transaction"."rule_id" IS '鍏宠仈瑙勫垯ID'; +COMMENT ON COLUMN "public"."points_transaction"."detail_id" IS '鍏宠仈瑙勫垯璇︽儏ID'; +COMMENT ON COLUMN "public"."points_transaction"."created_at" IS '鍒涘缓鏃堕棿'; +COMMENT ON COLUMN "public"."points_transaction"."deleted" IS '閫昏緫鍒犻櫎'; +COMMENT ON TABLE "public"."points_transaction" IS '绉垎娴佹按琛�'; + +-- ---------------------------- +-- Records of points_transaction +-- ---------------------------- + +-- ---------------------------- +-- Table structure for product +-- ---------------------------- +DROP TABLE IF EXISTS "public"."product"; +CREATE TABLE "public"."product" ( + "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY ( +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +), + "product_name" text COLLATE "pg_catalog"."default" NOT NULL, + "product_code" text COLLATE "pg_catalog"."default" NOT NULL, + "product_type" text COLLATE "pg_catalog"."default", + "category" text COLLATE "pg_catalog"."default", + "description" text COLLATE "pg_catalog"."default", + "provider_id" int8 NOT NULL, + "provider_name" text COLLATE "pg_catalog"."default" NOT NULL, + "provider_type" text COLLATE "pg_catalog"."default", + "status" text COLLATE "pg_catalog"."default" DEFAULT '涓婃灦'::text, + "audit_status" text COLLATE "pg_catalog"."default" DEFAULT '寰呭鏍�'::text, + "tags" text COLLATE "pg_catalog"."default", + "cover_image" text COLLATE "pg_catalog"."default", + "demo_url" text COLLATE "pg_catalog"."default", + "doc_url" text COLLATE "pg_catalog"."default", + "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "created_by" int8, + "updated_by" int8, + "deleted" int4 DEFAULT 0, + "submitUnit" varchar(255) COLLATE "pg_catalog"."default", + "industry" varchar(255) COLLATE "pg_catalog"."default", + "projectUnit" varchar(255) COLLATE "pg_catalog"."default", + "industryStage" varchar(255) COLLATE "pg_catalog"."default" +) +; +COMMENT ON TABLE "public"."product" IS '浜у搧琛�'; + +-- ---------------------------- +-- Records of product +-- ---------------------------- +INSERT INTO "public"."product" OVERRIDING SYSTEM VALUE VALUES (2, '娴嬭瘯浜у搧2', 'TEST_PRODUCT_002', '纭欢/浼犳劅', '鎶�鏈湇鍔�', '杩欐槸鍙︿竴涓祴璇曚骇鍝�', 3, '娴嬭瘯鎻愪緵鑰�', NULL, '涓婃灦', '瀹℃牳閫氳繃', NULL, NULL, NULL, NULL, '2025-08-13 14:50:16.574223', '2025-08-13 14:50:16.574223', NULL, NULL, 0, '涓氦涓�鍏眬', '浜ら�氬熀纭�璁炬柦', '鏌愰珮閫熷叕璺伐绋�', '搴旂敤闃舵'); +INSERT INTO "public"."product" OVERRIDING SYSTEM VALUE VALUES (1, '鏁板瓧鍖栦骇鍝丅', 'TEST_PRODUCT_001', '纭欢/浼犳劅', '浼佷笟绠$悊', '鏈骇鍝佸畾浣嶄负浠ュ缓璁炬湡BIM鏁板瓧璧勪骇浣滀负鏁板瓧搴曠洏锛岀粨鍚堥」鐩繍钀ョ淮淇濋渶姹傜殑瀹炴椂鎬с�佷氦浜掓�с�佷究鎹锋�х殑涓夌淮鍙鍖栬繍缁寸鐞嗙郴缁熴�傜郴缁熸彁渚涢」鐩暟瀛楀寲銆佹櫤鑳藉寲杩愮淮绠$悊鍔熻兘锛岃兘澶熻В鍐冲缓绛戣繍琛岀淮鎶ょ鐞嗕腑鐨勫疄闄呴棶棰橈紝瀹炵幇淇℃伅蹇�熸暣鍚堜笌鏌ヨ銆佷俊鎭湁鏁堝叡浜笌浼犻�掞紝鎻愬崌椤圭洰缁煎悎绠$悊涓庣淮鎶ゆ按骞炽��', 3, '寮犱笁', NULL, '涓婃灦', '瀹℃牳閫氳繃', NULL, NULL, NULL, NULL, '2025-08-13 14:50:16.574223', '2025-08-13 14:50:16.574223', NULL, NULL, 0, '涓氦浜岃埅灞�', '甯傛斂宸ョ▼', '鏅烘収绠″粖椤圭洰', '鐮斿彂闃舵'); + +-- ---------------------------- +-- Table structure for product_pricing +-- ---------------------------- +DROP TABLE IF EXISTS "public"."product_pricing"; +CREATE TABLE "public"."product_pricing" ( + "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY ( +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +), + "suite_name" text COLLATE "pg_catalog"."default" NOT NULL, + "sales_form" text COLLATE "pg_catalog"."default" NOT NULL, + "customer_type" text COLLATE "pg_catalog"."default" NOT NULL, + "account_limit" text COLLATE "pg_catalog"."default" DEFAULT '涓嶉檺'::text, + "concurrent_nodes" text COLLATE "pg_catalog"."default" DEFAULT '涓嶉檺'::text, + "price_type" text COLLATE "pg_catalog"."default" NOT NULL, + "price_unit" text COLLATE "pg_catalog"."default" NOT NULL, + "points_price" numeric(15,2), + "is_active" bool DEFAULT true, + "product_id" int8 NOT NULL, + "product_name" text COLLATE "pg_catalog"."default", + "provider_id" int8, + "provider_name" text COLLATE "pg_catalog"."default", + "description" text COLLATE "pg_catalog"."default", + "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "created_by" int8, + "updated_by" int8, + "deleted" int4 DEFAULT 0, + "currency_price" numeric(15,2) +) +; +COMMENT ON COLUMN "public"."product_pricing"."suite_name" IS '浜у搧濂椾欢鍚嶇О'; +COMMENT ON COLUMN "public"."product_pricing"."sales_form" IS '閿�鍞舰寮�'; +COMMENT ON COLUMN "public"."product_pricing"."points_price" IS '绉垎浠锋牸'; +COMMENT ON COLUMN "public"."product_pricing"."currency_price" IS '璐у竵浠锋牸'; +COMMENT ON TABLE "public"."product_pricing" IS '浜у搧瀹氫环琛�'; + +-- ---------------------------- +-- Records of product_pricing +-- ---------------------------- +INSERT INTO "public"."product_pricing" OVERRIDING SYSTEM VALUE VALUES (1, '鍩虹鐗�', '涔版柇', '浼佷笟', '涓嶉檺', '涓嶉檺', '绉垎', '濂�', 1000.00, 't', 1, '娴嬭瘯浜у搧1', 3, '娴嬭瘯鎻愪緵鑰�', NULL, '2025-08-13 14:50:16.574223', '2025-08-13 14:50:16.574223', NULL, NULL, 0, NULL); +INSERT INTO "public"."product_pricing" OVERRIDING SYSTEM VALUE VALUES (2, '涓撲笟鐗�', '绉熻祦', '浼佷笟', '涓嶉檺', '涓嶉檺', '绉垎', '濂�/骞�', 500.00, 't', 1, '娴嬭瘯浜у搧1', 3, '娴嬭瘯鎻愪緵鑰�', NULL, '2025-08-13 14:50:16.574223', '2025-08-13 14:50:16.574223', NULL, NULL, 0, NULL); +INSERT INTO "public"."product_pricing" OVERRIDING SYSTEM VALUE VALUES (3, '浼佷笟鐗�', '涔版柇', '浼佷笟', '涓嶉檺', '涓嶉檺', '璐у竵', '濂�', 10000.00, 't', 2, '娴嬭瘯浜у搧2', 3, '娴嬭瘯鎻愪緵鑰�', NULL, '2025-08-13 14:50:16.574223', '2025-08-13 14:50:16.574223', NULL, NULL, 0, NULL); +INSERT INTO "public"."product_pricing" OVERRIDING SYSTEM VALUE VALUES (4, '浼佷笟绉佹湁SaaS鐗堣鍙�', '绉熻祦', '涓汉', '1', '1', '绉垎,璐у竵', '濂�/骞�', 200.00, 't', 1, '鏁板瓧鍖栦骇鍝丄', NULL, NULL, '', '2025-08-18 16:53:39.407', '2025-08-18 16:53:39.407', NULL, NULL, 0, 100.00); +INSERT INTO "public"."product_pricing" OVERRIDING SYSTEM VALUE VALUES (6, '浼佷笟绉佹湁SaaS鐗堢敤鎴峰閲忓寘', '绉熻祦', '涓汉', '2', '2', '璐у竵', '濂�/骞�', 200.00, 't', 1, '鏁板瓧鍖栦骇鍝丄', NULL, NULL, '', '2025-08-18 17:13:29.332', '2025-08-18 17:13:29.332', NULL, NULL, 0, 100.00); +INSERT INTO "public"."product_pricing" OVERRIDING SYSTEM VALUE VALUES (9, '浼佷笟绉佹湁SaaS鐗堢敤鎴峰閲忓寘', '绉佹湁澧炲寘閲�', '椤圭洰閮�', '1', '1', '鍏嶈垂', '骞�', NULL, 't', 1, '鏁板瓧鍖栦骇鍝丄', NULL, NULL, '', '2025-08-19 17:17:41.644', '2025-08-19 17:17:41.644', NULL, NULL, 0, NULL); +INSERT INTO "public"."product_pricing" OVERRIDING SYSTEM VALUE VALUES (5, '浼佷笟绉佹湁SaaS鐗堣鍙�', '绉佹湁澧炲寘閲�', '涓汉', '2', '3', '绉垎,璐у竵', '濂�/骞�', 200.00, 'f', 1, '鏁板瓧鍖栦骇鍝丄', NULL, NULL, '', '2025-08-18 16:53:57.726', '2025-08-19 17:54:06.25', NULL, NULL, 1, 100.00); + +-- ---------------------------- +-- Table structure for unit +-- ---------------------------- +DROP TABLE IF EXISTS "public"."unit"; +CREATE TABLE "public"."unit" ( + "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY ( +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +), + "unit_name" text COLLATE "pg_catalog"."default" NOT NULL, + "unit_code" text COLLATE "pg_catalog"."default", + "unit_type" text COLLATE "pg_catalog"."default", + "industry" text COLLATE "pg_catalog"."default", + "address" text COLLATE "pg_catalog"."default", + "contact_person" text COLLATE "pg_catalog"."default", + "contact_phone" text COLLATE "pg_catalog"."default", + "contact_email" text COLLATE "pg_catalog"."default", + "business_license" text COLLATE "pg_catalog"."default", + "legal_person" text COLLATE "pg_catalog"."default", + "registered_capital" numeric(15,2), + "establishment_date" date, + "status" text COLLATE "pg_catalog"."default" DEFAULT '姝e父'::text, + "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "deleted" int4 DEFAULT 0 +) +; +COMMENT ON TABLE "public"."unit" IS '鍗曚綅琛�'; + +-- ---------------------------- +-- Records of unit +-- ---------------------------- +INSERT INTO "public"."unit" OVERRIDING SYSTEM VALUE VALUES (1, '娴嬭瘯浼佷笟', 'TEST_ENTERPRISE', '浼佷笟', '淇℃伅鎶�鏈�', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '姝e父', '2025-08-13 14:50:16.574223', '2025-08-13 14:50:16.574223', 0); +INSERT INTO "public"."unit" OVERRIDING SYSTEM VALUE VALUES (2, '娴嬭瘯鍗曚綅', 'TEST_UNIT', '浜嬩笟鍗曚綅', '鏁欒偛', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '姝e父', '2025-08-13 14:50:16.574223', '2025-08-13 14:50:16.574223', 0); + +-- ---------------------------- +-- Table structure for user_points +-- ---------------------------- +DROP TABLE IF EXISTS "public"."user_points"; +CREATE TABLE "public"."user_points" ( + "id" int8 NOT NULL DEFAULT nextval('user_points_id_seq'::regclass), + "user_id" int8 NOT NULL, + "unit_id" int8, + "balance" int4 NOT NULL DEFAULT 0, + "total_earned" int4 NOT NULL DEFAULT 0, + "total_consumed" int4 NOT NULL DEFAULT 0, + "total_converted" int4 NOT NULL DEFAULT 0, + "create_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "update_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "deleted" int4 DEFAULT 0 +) +; +COMMENT ON COLUMN "public"."user_points"."user_id" IS '鐢ㄦ埛ID'; +COMMENT ON COLUMN "public"."user_points"."unit_id" IS '鍗曚綅ID'; +COMMENT ON COLUMN "public"."user_points"."balance" IS '绉垎浣欓'; +COMMENT ON COLUMN "public"."user_points"."total_earned" IS '绱鑾峰彇绉垎'; +COMMENT ON COLUMN "public"."user_points"."total_consumed" IS '绱娑堣�楃Н鍒�'; +COMMENT ON COLUMN "public"."user_points"."total_converted" IS '绱杞崲绉垎'; +COMMENT ON COLUMN "public"."user_points"."create_time" IS '鍒涘缓鏃堕棿'; +COMMENT ON COLUMN "public"."user_points"."update_time" IS '鏇存柊鏃堕棿'; +COMMENT ON COLUMN "public"."user_points"."deleted" IS '閫昏緫鍒犻櫎锛�1-宸插垹闄わ紝0-鏈垹闄�'; +COMMENT ON TABLE "public"."user_points" IS '鐢ㄦ埛绉垎琛�'; + +-- ---------------------------- +-- Records of user_points +-- ---------------------------- +INSERT INTO "public"."user_points" VALUES (1, 1, 1, 20000, 10000, 200, 0, '2025-08-07 11:48:21.574933', '2025-08-07 11:48:21.574933', 0); + +-- ---------------------------- +-- Table structure for users +-- ---------------------------- +DROP TABLE IF EXISTS "public"."users"; +CREATE TABLE "public"."users" ( + "id" int8 NOT NULL GENERATED ALWAYS AS IDENTITY ( +INCREMENT 1 +MINVALUE 1 +MAXVALUE 9223372036854775807 +START 1 +), + "username" text COLLATE "pg_catalog"."default" NOT NULL, + "real_name" text COLLATE "pg_catalog"."default", + "email" text COLLATE "pg_catalog"."default", + "phone" text COLLATE "pg_catalog"."default", + "avatar" text COLLATE "pg_catalog"."default", + "user_type" text COLLATE "pg_catalog"."default" DEFAULT '涓汉鐢ㄦ埛'::text, + "unit_id" int8, + "unit_name" text COLLATE "pg_catalog"."default", + "status" text COLLATE "pg_catalog"."default" DEFAULT '姝e父'::text, + "last_login_time" timestamp(6), + "created_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "updated_at" timestamp(6) DEFAULT CURRENT_TIMESTAMP, + "deleted" int4 DEFAULT 0 +) +; +COMMENT ON TABLE "public"."users" IS '鐢ㄦ埛琛�'; + +-- ---------------------------- +-- Records of users +-- ---------------------------- +INSERT INTO "public"."users" OVERRIDING SYSTEM VALUE VALUES (1, 'admin', '绯荤粺绠$悊鍛�', NULL, NULL, NULL, '涓汉鐢ㄦ埛', NULL, NULL, '姝e父', NULL, '2025-08-13 14:50:16.574223', '2025-08-13 14:50:16.574223', 0); +INSERT INTO "public"."users" OVERRIDING SYSTEM VALUE VALUES (2, 'test_user', '娴嬭瘯鐢ㄦ埛', NULL, NULL, NULL, '涓汉鐢ㄦ埛', 1, NULL, '姝e父', NULL, '2025-08-13 14:50:16.574223', '2025-08-13 14:50:16.574223', 0); +INSERT INTO "public"."users" OVERRIDING SYSTEM VALUE VALUES (3, 'test_provider', '娴嬭瘯鎻愪緵鑰�', NULL, NULL, NULL, '鍗曚綅鐢ㄦ埛', 1, NULL, '姝e父', NULL, '2025-08-13 14:50:16.574223', '2025-08-13 14:50:16.574223', 0); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."cart_id_seq" +OWNED BY "public"."cart"."id"; +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"', 15, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."order_approval_id_seq" +OWNED BY "public"."order_approval"."id"; +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"', 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"', 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"', 11, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."order_evaluation_id_seq" +OWNED BY "public"."order_evaluation"."id"; +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"', 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"', 19, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."points_id_seq" +OWNED BY "public"."points"."id"; +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"', 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"', 3, false); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."product_id_seq" +OWNED BY "public"."product"."id"; +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"', 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"', 10, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."unit_id_seq" +OWNED BY "public"."unit"."id"; +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"', 3, true); + +-- ---------------------------- +-- Alter sequences owned by +-- ---------------------------- +ALTER SEQUENCE "public"."users_id_seq" +OWNED BY "public"."users"."id"; +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 +-- ---------------------------- +CREATE INDEX "idx_cart_add_time" ON "public"."cart" USING btree ( + "add_time" "pg_catalog"."timestamp_ops" ASC NULLS LAST, + "deleted" "pg_catalog"."int4_ops" ASC NULLS LAST +); +CREATE INDEX "idx_cart_pricing" ON "public"."cart" USING btree ( + "pricing_id" "pg_catalog"."int8_ops" ASC NULLS LAST, + "deleted" "pg_catalog"."int4_ops" ASC NULLS LAST +); +CREATE INDEX "idx_cart_product" ON "public"."cart" USING btree ( + "product_id" "pg_catalog"."int8_ops" ASC NULLS LAST, + "deleted" "pg_catalog"."int4_ops" ASC NULLS LAST +); +CREATE INDEX "idx_cart_provider" ON "public"."cart" USING btree ( + "provider_id" "pg_catalog"."int8_ops" ASC NULLS LAST, + "deleted" "pg_catalog"."int4_ops" ASC NULLS LAST +); +CREATE INDEX "idx_cart_user_unit" ON "public"."cart" USING btree ( + "user_id" "pg_catalog"."int8_ops" ASC NULLS LAST, + "unit_id" "pg_catalog"."int8_ops" ASC NULLS LAST, + "deleted" "pg_catalog"."int4_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Uniques structure for table cart +-- ---------------------------- +ALTER TABLE "public"."cart" ADD CONSTRAINT "cart_user_id_unit_id_pricing_id_deleted_key" UNIQUE ("user_id", "unit_id", "pricing_id", "deleted"); + +-- ---------------------------- +-- Checks structure for table cart +-- ---------------------------- +ALTER TABLE "public"."cart" ADD CONSTRAINT "cart_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1])); + +-- ---------------------------- +-- Primary Key structure for table cart +-- ---------------------------- +ALTER TABLE "public"."cart" ADD CONSTRAINT "cart_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Indexes structure for table order_approval +-- ---------------------------- +CREATE INDEX "idx_order_approval_approver_id" ON "public"."order_approval" USING btree ( + "approver_id" "pg_catalog"."int8_ops" ASC NULLS LAST +); +CREATE INDEX "idx_order_approval_order_id" ON "public"."order_approval" USING btree ( + "order_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Checks structure for table order_approval +-- ---------------------------- +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 +-- ---------------------------- +ALTER TABLE "public"."order_approval" ADD CONSTRAINT "order_approval_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Indexes structure for table order_attachment +-- ---------------------------- +CREATE INDEX "idx_order_attachment_order_id" ON "public"."order_attachment" USING btree ( + "order_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- 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])); + +-- ---------------------------- +-- Primary Key structure for table order_attachment +-- ---------------------------- +ALTER TABLE "public"."order_attachment" ADD CONSTRAINT "order_attachment_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Indexes structure for table order_detail +-- ---------------------------- +CREATE INDEX "idx_order_detail_order_id" ON "public"."order_detail" USING btree ( + "order_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Checks structure for table order_detail +-- ---------------------------- +ALTER TABLE "public"."order_detail" ADD CONSTRAINT "order_detail_deleted_check" CHECK (deleted = ANY (ARRAY[0, 1])); + +-- ---------------------------- +-- Primary Key structure for table order_detail +-- ---------------------------- +ALTER TABLE "public"."order_detail" ADD CONSTRAINT "order_detail_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Indexes structure for table order_evaluation +-- ---------------------------- +CREATE INDEX "idx_order_evaluation_evaluator_id" ON "public"."order_evaluation" USING btree ( + "evaluator_id" "pg_catalog"."int8_ops" ASC NULLS LAST +); +CREATE INDEX "idx_order_evaluation_order_id" ON "public"."order_evaluation" USING btree ( + "order_id" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Checks structure for table order_evaluation +-- ---------------------------- +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 +-- ---------------------------- +ALTER TABLE "public"."order_evaluation" ADD CONSTRAINT "order_evaluation_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Indexes structure for table order_info +-- ---------------------------- +CREATE INDEX "idx_order_info_apply_time" ON "public"."order_info" USING btree ( + "apply_time" "pg_catalog"."timestamp_ops" ASC NULLS LAST +); +CREATE INDEX "idx_order_info_provider_id" ON "public"."order_info" USING btree ( + "provider_id" "pg_catalog"."int8_ops" ASC NULLS LAST +); +CREATE INDEX "idx_order_info_status" ON "public"."order_info" USING btree ( + "order_status" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST +); +CREATE INDEX "idx_order_info_user_id" ON "public"."order_info" USING btree ( + "user_id" "pg_catalog"."int8_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Checks structure for table order_info +-- ---------------------------- +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 +-- ---------------------------- +ALTER TABLE "public"."order_info" ADD CONSTRAINT "order_info_pkey" PRIMARY KEY ("order_id"); + +-- ---------------------------- +-- Checks structure for table points +-- ---------------------------- +ALTER TABLE "public"."points" ADD CONSTRAINT "chk_deleted" CHECK (deleted = ANY (ARRAY[0, 1])); + +-- ---------------------------- +-- Primary Key structure for table points +-- ---------------------------- +ALTER TABLE "public"."points" ADD CONSTRAINT "points_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Indexes structure for table points_account +-- ---------------------------- +CREATE INDEX "idx_account_user" ON "public"."points_account" USING btree ( + "user_id" "pg_catalog"."int8_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- 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])); + +-- ---------------------------- +-- Primary Key structure for table points_account +-- ---------------------------- +ALTER TABLE "public"."points_account" ADD CONSTRAINT "points_account_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Indexes structure for table points_flow +-- ---------------------------- +CREATE INDEX "idx_points_flow_data_category" ON "public"."points_flow" USING btree ( + "data_category" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST +); +CREATE INDEX "idx_points_flow_flow_time" ON "public"."points_flow" USING btree ( + "flow_time" "pg_catalog"."timestamp_ops" ASC NULLS LAST +); +CREATE INDEX "idx_points_flow_unit_id" ON "public"."points_flow" USING btree ( + "unit_id" "pg_catalog"."int8_ops" ASC NULLS LAST +); +CREATE INDEX "idx_points_flow_user_id" ON "public"."points_flow" USING btree ( + "user_id" "pg_catalog"."int8_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Primary Key structure for table points_flow +-- ---------------------------- +ALTER TABLE "public"."points_flow" ADD CONSTRAINT "points_flow_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Indexes structure for table points_rule +-- ---------------------------- +CREATE INDEX "idx_points_rule_points" ON "public"."points_rule" USING btree ( + "points_id" "pg_catalog"."int8_ops" ASC NULLS LAST +); +CREATE INDEX "idx_points_rule_points_id" ON "public"."points_rule" USING btree ( + "points_id" "pg_catalog"."int8_ops" ASC NULLS LAST +); +CREATE INDEX "idx_points_rule_type" ON "public"."points_rule" USING btree ( + "rule_type" "pg_catalog"."int2_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- 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])); + +-- ---------------------------- +-- 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_transaction +-- ---------------------------- +CREATE INDEX "idx_transaction_time" ON "public"."points_transaction" USING btree ( + "transaction_time" "pg_catalog"."timestamptz_ops" ASC NULLS LAST +); +CREATE INDEX "idx_transaction_user" ON "public"."points_transaction" USING btree ( + "user_id" "pg_catalog"."int8_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- 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])); + +-- ---------------------------- +-- Primary Key structure for table points_transaction +-- ---------------------------- +ALTER TABLE "public"."points_transaction" ADD CONSTRAINT "points_transaction_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Indexes structure for table product +-- ---------------------------- +CREATE INDEX "idx_product_provider_id" ON "public"."product" USING btree ( + "provider_id" "pg_catalog"."int8_ops" ASC NULLS LAST +); +CREATE INDEX "idx_product_status" ON "public"."product" USING btree ( + "status" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Uniques structure for table product +-- ---------------------------- +ALTER TABLE "public"."product" ADD CONSTRAINT "product_product_code_key" UNIQUE ("product_code"); + +-- ---------------------------- +-- Checks structure for table product +-- ---------------------------- +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 +-- ---------------------------- +ALTER TABLE "public"."product" ADD CONSTRAINT "product_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Indexes structure for table product_pricing +-- ---------------------------- +CREATE INDEX "idx_product_pricing_product_id" ON "public"."product_pricing" USING btree ( + "product_id" "pg_catalog"."int8_ops" ASC NULLS LAST +); +CREATE INDEX "idx_product_pricing_status" ON "public"."product_pricing" USING btree ( + "is_active" "pg_catalog"."bool_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Checks structure for table product_pricing +-- ---------------------------- +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])); + +-- ---------------------------- +-- Primary Key structure for table product_pricing +-- ---------------------------- +ALTER TABLE "public"."product_pricing" ADD CONSTRAINT "product_pricing_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Uniques structure for table unit +-- ---------------------------- +ALTER TABLE "public"."unit" ADD CONSTRAINT "unit_unit_code_key" UNIQUE ("unit_code"); + +-- ---------------------------- +-- 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])); + +-- ---------------------------- +-- Primary Key structure for table unit +-- ---------------------------- +ALTER TABLE "public"."unit" ADD CONSTRAINT "unit_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Indexes structure for table user_points +-- ---------------------------- +CREATE INDEX "idx_user_points_unit_id" ON "public"."user_points" USING btree ( + "unit_id" "pg_catalog"."int8_ops" ASC NULLS LAST +); +CREATE INDEX "idx_user_points_user_id" ON "public"."user_points" USING btree ( + "user_id" "pg_catalog"."int8_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Primary Key structure for table user_points +-- ---------------------------- +ALTER TABLE "public"."user_points" ADD CONSTRAINT "user_points_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Indexes structure for table users +-- ---------------------------- +CREATE INDEX "idx_users_status" ON "public"."users" USING btree ( + "status" COLLATE "pg_catalog"."default" "pg_catalog"."text_ops" ASC NULLS LAST +); +CREATE INDEX "idx_users_unit_id" ON "public"."users" USING btree ( + "unit_id" "pg_catalog"."int8_ops" ASC NULLS LAST +); + +-- ---------------------------- +-- Uniques structure for table users +-- ---------------------------- +ALTER TABLE "public"."users" ADD CONSTRAINT "users_username_key" UNIQUE ("username"); + +-- ---------------------------- +-- 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])); + +-- ---------------------------- +-- Primary Key structure for table users +-- ---------------------------- +ALTER TABLE "public"."users" ADD CONSTRAINT "users_pkey" PRIMARY KEY ("id"); + +-- ---------------------------- +-- Foreign Keys structure for table cart +-- ---------------------------- +ALTER TABLE "public"."cart" ADD CONSTRAINT "cart_pricing_id_fkey" FOREIGN KEY ("pricing_id") REFERENCES "public"."product_pricing" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."cart" ADD CONSTRAINT "cart_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "public"."product" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."cart" ADD CONSTRAINT "cart_provider_id_fkey" FOREIGN KEY ("provider_id") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."cart" ADD CONSTRAINT "cart_unit_id_fkey" FOREIGN KEY ("unit_id") REFERENCES "public"."unit" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."cart" ADD CONSTRAINT "cart_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; + +-- ---------------------------- +-- Foreign Keys structure for table order_approval +-- ---------------------------- +ALTER TABLE "public"."order_approval" ADD CONSTRAINT "order_approval_approver_id_fkey" FOREIGN KEY ("approver_id") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."order_approval" ADD CONSTRAINT "order_approval_next_approver_id_fkey" FOREIGN KEY ("next_approver_id") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."order_approval" ADD CONSTRAINT "order_approval_order_id_fkey" FOREIGN KEY ("order_id") REFERENCES "public"."order_info" ("order_id") ON DELETE NO ACTION ON UPDATE NO ACTION; + +-- ---------------------------- +-- Foreign Keys structure for table order_attachment +-- ---------------------------- +ALTER TABLE "public"."order_attachment" ADD CONSTRAINT "order_attachment_order_id_fkey" FOREIGN KEY ("order_id") REFERENCES "public"."order_info" ("order_id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."order_attachment" ADD CONSTRAINT "order_attachment_upload_user_id_fkey" FOREIGN KEY ("upload_user_id") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; + +-- ---------------------------- +-- Foreign Keys structure for table order_detail +-- ---------------------------- +ALTER TABLE "public"."order_detail" ADD CONSTRAINT "order_detail_order_id_fkey" FOREIGN KEY ("order_id") REFERENCES "public"."order_info" ("order_id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."order_detail" ADD CONSTRAINT "order_detail_pricing_id_fkey" FOREIGN KEY ("pricing_id") REFERENCES "public"."product_pricing" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."order_detail" ADD CONSTRAINT "order_detail_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "public"."product" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."order_detail" ADD CONSTRAINT "order_detail_provider_id_fkey" FOREIGN KEY ("provider_id") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; + +-- ---------------------------- +-- Foreign Keys structure for table order_evaluation +-- ---------------------------- +ALTER TABLE "public"."order_evaluation" ADD CONSTRAINT "order_evaluation_evaluator_id_fkey" FOREIGN KEY ("evaluator_id") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."order_evaluation" ADD CONSTRAINT "order_evaluation_order_id_fkey" FOREIGN KEY ("order_id") REFERENCES "public"."order_info" ("order_id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."order_evaluation" ADD CONSTRAINT "order_evaluation_reply_user_id_fkey" FOREIGN KEY ("reply_user_id") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; + +-- ---------------------------- +-- Foreign Keys structure for table order_info +-- ---------------------------- +ALTER TABLE "public"."order_info" ADD CONSTRAINT "order_info_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "public"."product" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."order_info" ADD CONSTRAINT "order_info_provider_id_fkey" FOREIGN KEY ("provider_id") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."order_info" ADD CONSTRAINT "order_info_unit_id_fkey" FOREIGN KEY ("unit_id") REFERENCES "public"."unit" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."order_info" ADD CONSTRAINT "order_info_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; + +-- ---------------------------- +-- Foreign Keys structure for table points_rule +-- ---------------------------- +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_transaction +-- ---------------------------- +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; + +-- ---------------------------- +-- Foreign Keys structure for table product +-- ---------------------------- +ALTER TABLE "public"."product" ADD CONSTRAINT "product_created_by_fkey" FOREIGN KEY ("created_by") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."product" ADD CONSTRAINT "product_provider_id_fkey" FOREIGN KEY ("provider_id") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."product" ADD CONSTRAINT "product_updated_by_fkey" FOREIGN KEY ("updated_by") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; + +-- ---------------------------- +-- Foreign Keys structure for table product_pricing +-- ---------------------------- +ALTER TABLE "public"."product_pricing" ADD CONSTRAINT "product_pricing_created_by_fkey" FOREIGN KEY ("created_by") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."product_pricing" ADD CONSTRAINT "product_pricing_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "public"."product" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."product_pricing" ADD CONSTRAINT "product_pricing_provider_id_fkey" FOREIGN KEY ("provider_id") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; +ALTER TABLE "public"."product_pricing" ADD CONSTRAINT "product_pricing_updated_by_fkey" FOREIGN KEY ("updated_by") REFERENCES "public"."users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; + +-- ---------------------------- +-- Foreign Keys structure for table users +-- ---------------------------- +ALTER TABLE "public"."users" ADD CONSTRAINT "users_unit_id_fkey" FOREIGN KEY ("unit_id") REFERENCES "public"."unit" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION; diff --git a/src/main/java/com/webmanage/WebManageApplication.java b/src/main/java/com/webmanage/WebManageApplication.java index 4af56a8..e54698e 100644 --- a/src/main/java/com/webmanage/WebManageApplication.java +++ b/src/main/java/com/webmanage/WebManageApplication.java @@ -1,6 +1,7 @@ package com.webmanage; import org.mybatis.spring.annotation.MapperScan; +import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -11,6 +12,7 @@ * @date 2024-08-07 */ @SpringBootApplication +@EnableAsync @MapperScan("com.webmanage.mapper") public class WebManageApplication { diff --git a/src/main/java/com/webmanage/config/AsyncConfig.java b/src/main/java/com/webmanage/config/AsyncConfig.java new file mode 100644 index 0000000..d712fac --- /dev/null +++ b/src/main/java/com/webmanage/config/AsyncConfig.java @@ -0,0 +1,52 @@ +package com.webmanage.config; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.AsyncConfigurer; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +import javax.annotation.Resource; +import java.lang.reflect.Method; +import java.util.concurrent.Executor; +import java.util.concurrent.ThreadPoolExecutor; + +@Configuration +public class AsyncConfig implements AsyncConfigurer { + + private static final Logger log = LoggerFactory.getLogger(AsyncConfig.class); + + @Resource + private AsyncExecutorProperties properties; + + @Override + @Bean("asyncExecutor") + public Executor getAsyncExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(properties.getCorePoolSize()); + executor.setMaxPoolSize(properties.getMaxPoolSize()); + executor.setQueueCapacity(properties.getQueueCapacity()); + executor.setKeepAliveSeconds(properties.getKeepAliveSeconds()); + executor.setThreadNamePrefix(properties.getThreadNamePrefix()); + executor.setWaitForTasksToCompleteOnShutdown(properties.isWaitForTasksToCompleteOnShutdown()); + executor.setAwaitTerminationSeconds(properties.getAwaitTerminationSeconds()); + // 楗卞拰绛栫暐锛氳皟鐢ㄦ柟绾跨▼鎵ц锛岄伩鍏嶄换鍔¤涓㈠純 + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); + executor.initialize(); + return executor; + } + + @Override + public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { + return new AsyncUncaughtExceptionHandler() { + @Override + public void handleUncaughtException(Throwable ex, Method method, Object... params) { + log.error("寮傛浠诲姟鎵ц寮傚父, method={}, params={}", method, params, ex); + } + }; + } +} + + diff --git a/src/main/java/com/webmanage/config/AsyncExecutorProperties.java b/src/main/java/com/webmanage/config/AsyncExecutorProperties.java new file mode 100644 index 0000000..4b06d45 --- /dev/null +++ b/src/main/java/com/webmanage/config/AsyncExecutorProperties.java @@ -0,0 +1,40 @@ +package com.webmanage.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties(prefix = "async.executor") +public class AsyncExecutorProperties { + /** 鏍稿績绾跨▼鏁� */ + private int corePoolSize = 4; + /** 鏈�澶х嚎绋嬫暟 */ + private int maxPoolSize = 8; + /** 闃熷垪瀹归噺 */ + private int queueCapacity = 200; + /** 绾跨▼瀛樻椿鏃堕棿锛堢锛� */ + private int keepAliveSeconds = 60; + /** 绾跨▼鍚嶅墠缂� */ + private String threadNamePrefix = "async-exec-"; + /** 鍏抽棴鏃舵槸鍚︾瓑寰呬换鍔″畬鎴� */ + private boolean waitForTasksToCompleteOnShutdown = true; + /** 鍏抽棴鏃舵渶澶х瓑寰呯鏁� */ + private int awaitTerminationSeconds = 30; + + public int getCorePoolSize() { return corePoolSize; } + public void setCorePoolSize(int corePoolSize) { this.corePoolSize = corePoolSize; } + public int getMaxPoolSize() { return maxPoolSize; } + public void setMaxPoolSize(int maxPoolSize) { this.maxPoolSize = maxPoolSize; } + public int getQueueCapacity() { return queueCapacity; } + public void setQueueCapacity(int queueCapacity) { this.queueCapacity = queueCapacity; } + public int getKeepAliveSeconds() { return keepAliveSeconds; } + public void setKeepAliveSeconds(int keepAliveSeconds) { this.keepAliveSeconds = keepAliveSeconds; } + public String getThreadNamePrefix() { return threadNamePrefix; } + public void setThreadNamePrefix(String threadNamePrefix) { this.threadNamePrefix = threadNamePrefix; } + public boolean isWaitForTasksToCompleteOnShutdown() { return waitForTasksToCompleteOnShutdown; } + public void setWaitForTasksToCompleteOnShutdown(boolean waitForTasksToCompleteOnShutdown) { this.waitForTasksToCompleteOnShutdown = waitForTasksToCompleteOnShutdown; } + public int getAwaitTerminationSeconds() { return awaitTerminationSeconds; } + public void setAwaitTerminationSeconds(int awaitTerminationSeconds) { this.awaitTerminationSeconds = awaitTerminationSeconds; } +} + + diff --git a/src/main/java/com/webmanage/config/CartProperties.java b/src/main/java/com/webmanage/config/CartProperties.java new file mode 100644 index 0000000..d4fd690 --- /dev/null +++ b/src/main/java/com/webmanage/config/CartProperties.java @@ -0,0 +1,31 @@ +package com.webmanage.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Component +@ConfigurationProperties(prefix = "cart") +public class CartProperties { + /** Redis缂撳瓨杩囨湡澶╂暟 */ + private Integer expireDays = 30; + /** 鏄惁鍚敤鏁版嵁搴撴寔涔呭寲 */ + private Boolean enablePersistence = true; + /** 鏄惁鍚敤涓�鑷存�ф鏌� */ + private Boolean enableConsistencyCheck = true; + /** 鍚屾绛栫暐锛歳ealtime|batch|manual */ + private String syncStrategy = "realtime"; + + public Integer getExpireDays() { return expireDays; } + public void setExpireDays(Integer expireDays) { this.expireDays = expireDays; } + + public Boolean getEnablePersistence() { return enablePersistence; } + public void setEnablePersistence(Boolean enablePersistence) { this.enablePersistence = enablePersistence; } + + public Boolean getEnableConsistencyCheck() { return enableConsistencyCheck; } + public void setEnableConsistencyCheck(Boolean enableConsistencyCheck) { this.enableConsistencyCheck = enableConsistencyCheck; } + + public String getSyncStrategy() { return syncStrategy; } + public void setSyncStrategy(String syncStrategy) { this.syncStrategy = syncStrategy; } +} + + diff --git a/src/main/java/com/webmanage/config/RedisConfig.java b/src/main/java/com/webmanage/config/RedisConfig.java index 65383b7..803da7b 100644 --- a/src/main/java/com/webmanage/config/RedisConfig.java +++ b/src/main/java/com/webmanage/config/RedisConfig.java @@ -3,7 +3,9 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.RedisConnectionFactory; @@ -27,6 +29,9 @@ ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL); + objectMapper.registerModule(new JavaTimeModule()); + // 绂佺敤鏃ユ湡鏃堕棿浣滀负鏃堕棿鎴� + objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); jackson2JsonRedisSerializer.setObjectMapper(objectMapper); // 浣跨敤StringRedisSerializer鏉ュ簭鍒楀寲鍜屽弽搴忓垪鍖杛edis鐨刱ey鍊� diff --git a/src/main/java/com/webmanage/controller/OrderController.java b/src/main/java/com/webmanage/controller/OrderController.java index 6680838..d2d30e7 100644 --- a/src/main/java/com/webmanage/controller/OrderController.java +++ b/src/main/java/com/webmanage/controller/OrderController.java @@ -3,7 +3,9 @@ import com.webmanage.common.Result; import com.webmanage.dto.CreateOrderDTO; import com.webmanage.dto.OrderQueryDTO; +import com.webmanage.entity.OrderInfo; import com.webmanage.service.OrderInfoService; +import com.webmanage.service.TokenService; import com.webmanage.service.OrderNoService; import com.webmanage.vo.OrderDetailVO; import io.swagger.annotations.Api; @@ -29,6 +31,7 @@ public class OrderController { @Resource private OrderInfoService orderInfoService; @Resource private OrderNoService orderNoService; + @Resource private TokenService tokenService; @PostMapping("/buyer/page") @ApiOperation("鍒嗛〉鏌ヨ涔板璁㈠崟鍒楄〃") @@ -38,17 +41,33 @@ } @PostMapping("/create") - @ApiOperation("鍒涘缓璁㈠崟锛堝寘鍚鍗曡鎯咃級") - public Result<Object> createOrder(@Valid @RequestBody CreateOrderDTO createOrderDTO) { + @ApiOperation("鍒涘缓璁㈠崟锛堝寘鍚鍗曡鎯咃級锛岄渶鍦� Header 鎼哄甫 Idempotency-Token 闃查噸澶嶆彁浜�") + public Result<OrderInfo> createOrder(@RequestHeader(value = "Idempotency-Token", required = false) String token, + @Valid @RequestBody CreateOrderDTO createOrderDTO) { try { - String orderId = orderInfoService.createOrder(createOrderDTO); - return Result.success(orderId); + if (!tokenService.verifyAndConsume(token)) { + return Result.error("璇锋眰鏃犳晥鎴栭噸澶嶆彁浜わ紝璇峰埛鏂伴〉闈㈠悗閲嶈瘯"); + } + OrderInfo orderInfo = orderInfoService.createOrder(createOrderDTO); + return Result.success(orderInfo); } catch (Exception e) { log.error("鍒涘缓璁㈠崟澶辫触", e); return Result.error("鍒涘缓璁㈠崟澶辫触锛�" + e.getMessage()); } } + @GetMapping("/idempotency/token") + @ApiOperation("鑾峰彇涓�娆℃�ч槻閲嶅鎻愪氦 Token") + public Result<Object> getIdempotencyToken(@RequestParam(required = false) Long userId) { + try { + String token = tokenService.generateToken(userId); + return Result.success("token鐢熸垚",token); + } catch (Exception e) { + log.error("鐢熸垚闃查噸澶嶆彁浜� Token 澶辫触", e); + return Result.error("鐢熸垚闃查噸澶嶆彁浜� Token 澶辫触锛�" + e.getMessage()); + } + } + @GetMapping("/no/new") @ApiOperation("鐢熸垚鍞竴璁㈠崟鍙�") public Result<Object> generateOrderNo() { diff --git a/src/main/java/com/webmanage/emun/PriceTypeEnum.java b/src/main/java/com/webmanage/emun/PriceTypeEnum.java new file mode 100644 index 0000000..5a5c607 --- /dev/null +++ b/src/main/java/com/webmanage/emun/PriceTypeEnum.java @@ -0,0 +1,20 @@ +package com.webmanage.emun; + +/** + * @ClassName PriceTypeEnum + * @Description TODO + * @Author wangxudong + * @Date 2025/8/18 17:39 + * @Version 1.0 + **/ +public enum PriceTypeEnum { + POINTS("绉垎"),CURRENCY("璐у竵"),AGREEMENT("鍗忚"),FREE("鍏嶈垂"); + private String name; + PriceTypeEnum(String name) { + this.name = name; + } + + public String getName() { + return name; + } +} diff --git a/src/main/java/com/webmanage/entity/Cart.java b/src/main/java/com/webmanage/entity/Cart.java index 2504dd7..5b5c741 100644 --- a/src/main/java/com/webmanage/entity/Cart.java +++ b/src/main/java/com/webmanage/entity/Cart.java @@ -106,7 +106,6 @@ private LocalDateTime updateTime; @ApiModelProperty("閫昏緫鍒犻櫎锛�1-宸插垹闄わ紝0-鏈垹闄�") - @TableLogic @TableField("deleted") private Integer deleted; } diff --git a/src/main/java/com/webmanage/entity/ProductPricing.java b/src/main/java/com/webmanage/entity/ProductPricing.java index 7c61271..fee2c84 100644 --- a/src/main/java/com/webmanage/entity/ProductPricing.java +++ b/src/main/java/com/webmanage/entity/ProductPricing.java @@ -70,10 +70,16 @@ private String priceUnit; /** - * 浠锋牸鍊� + * 璐у竵浠锋牸鍊� */ - @TableField("price") - private BigDecimal price; + @TableField("currency_price") + private BigDecimal currencyPrice; + + /** + * 绉垎浠峰�� + */ + @TableField("points_price") + private BigDecimal pointsPrice; /** * 鍚敤鐘舵�� diff --git a/src/main/java/com/webmanage/mapper/CartMapper.java b/src/main/java/com/webmanage/mapper/CartMapper.java index 76abe93..5cc4d07 100644 --- a/src/main/java/com/webmanage/mapper/CartMapper.java +++ b/src/main/java/com/webmanage/mapper/CartMapper.java @@ -32,4 +32,6 @@ * 鏍规嵁鐢ㄦ埛ID鍜屽崟浣岻D璁$畻璐墿杞︽�婚噾棰� */ java.math.BigDecimal sumTotalAmountByUserIdAndUnitId(@Param("userId") Long userId, @Param("unitId") Long unitId); + + Integer deleteByCustomerCondition(@Param("id") Long id); } diff --git a/src/main/java/com/webmanage/service/CartPersistenceService.java b/src/main/java/com/webmanage/service/CartPersistenceService.java new file mode 100644 index 0000000..bd7cb3d --- /dev/null +++ b/src/main/java/com/webmanage/service/CartPersistenceService.java @@ -0,0 +1,11 @@ +package com.webmanage.service; + +import com.webmanage.vo.CartItemVO; + +public interface CartPersistenceService { + void saveOrUpdate(Long userId, Long unitId, CartItemVO item); + void remove(Long userId, Long unitId, Long pricingId); + void clear(Long userId, Long unitId); +} + + diff --git a/src/main/java/com/webmanage/service/OrderInfoService.java b/src/main/java/com/webmanage/service/OrderInfoService.java index 8e85fc7..d50282a 100644 --- a/src/main/java/com/webmanage/service/OrderInfoService.java +++ b/src/main/java/com/webmanage/service/OrderInfoService.java @@ -35,7 +35,7 @@ /** * 鍒涘缓璁㈠崟锛堝寘鍚鍗曞ご涓庢槑缁嗘彃鍏ワ級锛岃繑鍥炶鍗曠紪鍙� */ - String createOrder(CreateOrderDTO createOrderDTO); + OrderInfo createOrder(CreateOrderDTO createOrderDTO); /** * 涓婁紶璁㈠崟闄勪欢 diff --git a/src/main/java/com/webmanage/service/TokenService.java b/src/main/java/com/webmanage/service/TokenService.java new file mode 100644 index 0000000..3312ff8 --- /dev/null +++ b/src/main/java/com/webmanage/service/TokenService.java @@ -0,0 +1,22 @@ +package com.webmanage.service; + +/** + * 闃查噸澶嶆彁浜� Token 鏈嶅姟 + */ +public interface TokenService { + /** + * 鐢熸垚涓�娆℃�ч槻閲嶅鎻愪氦 Token锛堥粯璁ゆ湁鏁堟湡鐭椂闂达級 + * @param userId 鍙�夌殑鐢ㄦ埛ID锛屼粎鐢ㄤ簬杩借釜 + * @return token 瀛楃涓� + */ + String generateToken(Long userId); + + /** + * 鏍¢獙骞舵秷璐� Token锛堜竴娆℃�э級銆傛垚鍔熻繑鍥� true锛屽け璐�/涓嶅瓨鍦�/杩囨湡杩斿洖 false銆� + * @param token header 涓紶閫掔殑 token + * @return 鏍¢獙骞跺垹闄ゆ垚鍔熻繑鍥� true锛屽惁鍒� false + */ + boolean verifyAndConsume(String token); +} + + diff --git a/src/main/java/com/webmanage/service/impl/CartPersistenceServiceImpl.java b/src/main/java/com/webmanage/service/impl/CartPersistenceServiceImpl.java new file mode 100644 index 0000000..cdbe2c2 --- /dev/null +++ b/src/main/java/com/webmanage/service/impl/CartPersistenceServiceImpl.java @@ -0,0 +1,64 @@ +package com.webmanage.service.impl; + +import com.webmanage.entity.Cart; +import com.webmanage.mapper.CartMapper; +import com.webmanage.service.CartPersistenceService; +import com.webmanage.vo.CartItemVO; +import org.springframework.beans.BeanUtils; +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.AsyncConfigurer; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.time.LocalDateTime; + +@Service +public class CartPersistenceServiceImpl implements CartPersistenceService { + + @Resource + private CartMapper cartMapper; + + @Override + @Async("asyncExecutor") + public void saveOrUpdate(Long userId, Long unitId, CartItemVO item) { + try { + Cart cart = new Cart(); + BeanUtils.copyProperties(item, cart); + cart.setUserId(userId); + cart.setUnitId(unitId); + cart.setUpdateTime(LocalDateTime.now()); + Cart existing = cartMapper.selectByUserIdUnitIdAndPricingId(userId, unitId, item.getPricingId()); + if (existing != null) { + cart.setId(existing.getId()); + cartMapper.updateById(cart); + } else { + cart.setAddTime(LocalDateTime.now()); + cartMapper.insert(cart); + } + } catch (Exception ignored) {} + } + + @Override + @Async("asyncExecutor") + public void remove(Long userId, Long unitId, Long pricingId) { + try { + Cart existing = cartMapper.selectByUserIdUnitIdAndPricingId(userId, unitId, pricingId); + if (existing != null) { + cartMapper.deleteById(existing.getId()); + } + } catch (Exception ignored) {} + } + + @Override + @Async("asyncExecutor") + public void clear(Long userId, Long unitId) { + try { + java.util.List<Cart> cartItems = cartMapper.selectByUserIdAndUnitId(userId, unitId); + for (Cart item : cartItems) { + cartMapper.deleteById(item.getId()); + } + } catch (Exception ignored) {} + } +} + + diff --git a/src/main/java/com/webmanage/service/impl/CartServiceImpl.java b/src/main/java/com/webmanage/service/impl/CartServiceImpl.java index 304a9fe..7072069 100644 --- a/src/main/java/com/webmanage/service/impl/CartServiceImpl.java +++ b/src/main/java/com/webmanage/service/impl/CartServiceImpl.java @@ -7,11 +7,14 @@ import com.webmanage.mapper.CartMapper; import com.webmanage.mapper.ProductPricingMapper; import com.webmanage.service.CartService; +import com.webmanage.service.CartPersistenceService; import com.webmanage.vo.CartItemVO; import com.webmanage.vo.CartVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; +import com.webmanage.config.CartProperties; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.format.datetime.DateFormatter; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; @@ -39,11 +42,17 @@ @Resource private ProductPricingMapper productPricingMapper; + @Resource + private CartPersistenceService cartPersistenceService; + + @Resource + private CartProperties cartProperties; + // Redis key鍓嶇紑 private static final String CART_KEY_PREFIX = "cart:"; private static final String CART_ITEM_KEY_PREFIX = "cart_item:"; private static final int CART_EXPIRE_DAYS = 30; // 璐墿杞﹁繃鏈熸椂闂�30澶� - + @Override @Transactional(rollbackFor = Exception.class) public boolean addToCart(Long userId, Long unitId, CartItemDTO cartItemDTO) { @@ -53,11 +62,11 @@ if (pricing == null) { throw new BusinessException("鍟嗗搧瀹氫环涓嶅瓨鍦�"); } - + // 鏋勫缓璐墿杞ey String cartKey = buildCartKey(userId, unitId); String cartItemKey = buildCartItemKey(userId, unitId, cartItemDTO.getPricingId()); - + // 妫�鏌ュ晢鍝佹槸鍚﹀凡鍦ㄨ喘鐗╄溅涓� CartItemVO existingItem = (CartItemVO) redisTemplate.opsForValue().get(cartItemKey); if (existingItem != null) { @@ -76,19 +85,21 @@ existingItem.setTotalPrice(existingItem.getUnitPrice().multiply(BigDecimal.valueOf(existingItem.getQuantity()))); } } - + // 淇濆瓨鍒癛edis - redisTemplate.opsForValue().set(cartItemKey, existingItem, CART_EXPIRE_DAYS, TimeUnit.DAYS); - + redisTemplate.opsForValue().set(cartItemKey, existingItem, (cartProperties.getExpireDays() != null ? cartProperties.getExpireDays() : CART_EXPIRE_DAYS), TimeUnit.DAYS); + // 鏇存柊璐墿杞﹀晢鍝佸垪琛� updateCartItemList(userId, unitId, cartItemDTO.getPricingId(), true); - + // 璁剧疆璐墿杞﹁繃鏈熸椂闂� - redisTemplate.expire(cartKey, CART_EXPIRE_DAYS, TimeUnit.DAYS); - - // 鍚屾鍒版暟鎹簱 - syncCartItemToDatabase(userId, unitId, existingItem); - + redisTemplate.expire(cartKey, (cartProperties.getExpireDays() != null ? cartProperties.getExpireDays() : CART_EXPIRE_DAYS), TimeUnit.DAYS); + + // 寮傛鎸佷箙鍖栧埌鏁版嵁搴擄紙鏍规嵁閰嶇疆锛� + if (Boolean.TRUE.equals(cartProperties.getEnablePersistence()) && "realtime".equalsIgnoreCase(cartProperties.getSyncStrategy())) { + cartPersistenceService.saveOrUpdate(userId, unitId, existingItem); + } + log.info("鐢ㄦ埛{}鎴愬姛娣诲姞鍟嗗搧{}鍒拌喘鐗╄溅", userId, cartItemDTO.getProductName()); return true; } catch (Exception e) { @@ -96,22 +107,24 @@ throw new BusinessException("娣诲姞鍟嗗搧鍒拌喘鐗╄溅澶辫触锛�" + e.getMessage()); } } - + @Override @Transactional(rollbackFor = Exception.class) public boolean removeFromCart(Long userId, Long unitId, Long pricingId) { try { String cartItemKey = buildCartItemKey(userId, unitId, pricingId); - + // 浠嶳edis涓垹闄ゅ晢鍝侀」 Boolean removed = redisTemplate.delete(cartItemKey); if (Boolean.TRUE.equals(removed)) { // 鏇存柊璐墿杞﹀晢鍝佸垪琛� updateCartItemList(userId, unitId, pricingId, false); - - // 浠庢暟鎹簱涓垹闄� - removeCartItemFromDatabase(userId, unitId, pricingId); - + + // 寮傛浠庢暟鎹簱涓垹闄わ紙鏍规嵁閰嶇疆锛� + if (Boolean.TRUE.equals(cartProperties.getEnablePersistence()) && "realtime".equalsIgnoreCase(cartProperties.getSyncStrategy())) { + cartPersistenceService.remove(userId, unitId, pricingId); + } + log.info("鐢ㄦ埛{}鎴愬姛浠庤喘鐗╄溅绉婚櫎鍟嗗搧{}", userId, pricingId); return true; } @@ -121,7 +134,7 @@ throw new BusinessException("浠庤喘鐗╄溅绉婚櫎鍟嗗搧澶辫触锛�" + e.getMessage()); } } - + @Override @Transactional(rollbackFor = Exception.class) public boolean updateCartItemQuantity(Long userId, Long unitId, Long pricingId, Integer quantity) { @@ -129,23 +142,25 @@ if (quantity <= 0) { return removeFromCart(userId, unitId, pricingId); } - + String cartItemKey = buildCartItemKey(userId, unitId, pricingId); CartItemVO cartItem = (CartItemVO) redisTemplate.opsForValue().get(cartItemKey); if (cartItem == null) { throw new BusinessException("璐墿杞﹀晢鍝佷笉瀛樺湪"); } - + cartItem.setQuantity(quantity); cartItem.setTotalPrice(cartItem.getUnitPrice().multiply(BigDecimal.valueOf(quantity))); cartItem.setUpdateTime(LocalDateTime.now()); - + // 鏇存柊鍒癛edis - redisTemplate.opsForValue().set(cartItemKey, cartItem, CART_EXPIRE_DAYS, TimeUnit.DAYS); - - // 鍚屾鍒版暟鎹簱 - syncCartItemToDatabase(userId, unitId, cartItem); - + redisTemplate.opsForValue().set(cartItemKey, cartItem, (cartProperties.getExpireDays() != null ? cartProperties.getExpireDays() : CART_EXPIRE_DAYS), TimeUnit.DAYS); + + // 寮傛鎸佷箙鍖栧埌鏁版嵁搴擄紙鏍规嵁閰嶇疆锛� + if (Boolean.TRUE.equals(cartProperties.getEnablePersistence()) && "realtime".equalsIgnoreCase(cartProperties.getSyncStrategy())) { + cartPersistenceService.saveOrUpdate(userId, unitId, cartItem); + } + log.info("鐢ㄦ埛{}鎴愬姛鏇存柊璐墿杞﹀晢鍝亄}鏁伴噺涓簕}", userId, pricingId, quantity); return true; } catch (Exception e) { @@ -153,26 +168,28 @@ throw new BusinessException("鏇存柊璐墿杞﹀晢鍝佹暟閲忓け璐ワ細" + e.getMessage()); } } - + @Override @Transactional(rollbackFor = Exception.class) public boolean clearCart(Long userId, Long unitId) { try { String cartKey = buildCartKey(userId, unitId); List<Long> pricingIds = getCartItemPricingIds(userId, unitId); - + // 鍒犻櫎鎵�鏈夊晢鍝侀」 for (Long pricingId : pricingIds) { String cartItemKey = buildCartItemKey(userId, unitId, pricingId); redisTemplate.delete(cartItemKey); } - + // 鍒犻櫎璐墿杞﹀垪琛� redisTemplate.delete(cartKey); - - // 娓呯┖鏁版嵁搴撲腑鐨勮喘鐗╄溅鏁版嵁 - clearCartFromDatabase(userId, unitId); - + + // 寮傛娓呯┖鏁版嵁搴撲腑鐨勮喘鐗╄溅鏁版嵁锛堟牴鎹厤缃級 + if (Boolean.TRUE.equals(cartProperties.getEnablePersistence()) && "realtime".equalsIgnoreCase(cartProperties.getSyncStrategy())) { + cartPersistenceService.clear(userId, unitId); + } + log.info("鐢ㄦ埛{}鎴愬姛娓呯┖璐墿杞�", userId); return true; } catch (Exception e) { @@ -180,34 +197,34 @@ throw new BusinessException("娓呯┖璐墿杞﹀け璐ワ細" + e.getMessage()); } } - + @Override public CartVO getCart(Long userId, Long unitId) { try { CartVO cartVO = new CartVO(); cartVO.setUserId(userId); cartVO.setUnitId(unitId); - + List<CartItemVO> items = getCartItems(userId, unitId); cartVO.setItems(items); - + // 璁$畻鎬绘暟閲忓拰鎬婚噾棰� int totalQuantity = items.stream().mapToInt(item -> item.getQuantity()).sum(); BigDecimal totalAmount = items.stream() .map(item -> item.getTotalPrice()) .reduce(BigDecimal.ZERO, BigDecimal::add); - + cartVO.setTotalQuantity(totalQuantity); cartVO.setTotalAmount(totalAmount); cartVO.setLastUpdateTime(LocalDateTime.now()); - + return cartVO; } catch (Exception e) { log.error("鑾峰彇璐墿杞︿俊鎭け璐�", e); throw new BusinessException("鑾峰彇璐墿杞︿俊鎭け璐ワ細" + e.getMessage()); } } - + @Override public List<CartItemVO> getCartItems(Long userId, Long unitId) { try { @@ -216,7 +233,7 @@ if (items != null && !items.isEmpty()) { return items; } - + // Redis涓病鏈夋暟鎹紝浠庢暟鎹簱鍔犺浇 log.info("Redis涓棤璐墿杞︽暟鎹紝浠庢暟鎹簱鍔犺浇鐢ㄦ埛{}鐨勮喘鐗╄溅", userId); return loadCartFromDatabase(userId, unitId) ? getCartItemsFromRedis(userId, unitId) : new ArrayList<>(); @@ -226,13 +243,13 @@ return getCartItemsFromDatabase(userId, unitId); } } - + @Override public boolean checkCartItemStock(Long userId, Long unitId, Long pricingId) { // TODO: 瀹炵幇搴撳瓨妫�鏌ラ�昏緫 return true; } - + @Override @Transactional(rollbackFor = Exception.class) public boolean batchRemoveFromCart(Long userId, Long unitId, List<Long> pricingIds) { @@ -240,18 +257,18 @@ if (CollectionUtils.isEmpty(pricingIds)) { return true; } - + for (Long pricingId : pricingIds) { removeFromCart(userId, unitId, pricingId); } - + return true; } catch (Exception e) { log.error("鎵归噺鍒犻櫎璐墿杞﹀晢鍝佸け璐�", e); throw new BusinessException("鎵归噺鍒犻櫎璐墿杞﹀晢鍝佸け璐ワ細" + e.getMessage()); } } - + @Override public Integer getCartItemCount(Long userId, Long unitId) { try { @@ -261,7 +278,7 @@ if (pricingIds != null) { return pricingIds.size(); } - + // 浠庢暟鎹簱鑾峰彇 return cartMapper.countByUserIdAndUnitId(userId, unitId); } catch (Exception e) { @@ -269,7 +286,7 @@ return 0; } } - + @Override public boolean loadCartFromDatabase(Long userId, Long unitId) { try { @@ -277,22 +294,22 @@ if (CollectionUtils.isEmpty(cartItems)) { return false; } - + String cartKey = buildCartKey(userId, unitId); List<Long> pricingIds = new ArrayList<>(); - + for (Cart cartItem : cartItems) { CartItemVO itemVO = convertCartToCartItemVO(cartItem); String cartItemKey = buildCartItemKey(userId, unitId, cartItem.getPricingId()); - + // 淇濆瓨鍒癛edis redisTemplate.opsForValue().set(cartItemKey, itemVO, CART_EXPIRE_DAYS, TimeUnit.DAYS); pricingIds.add(cartItem.getPricingId()); } - + // 淇濆瓨璐墿杞﹀垪琛ㄥ埌Redis redisTemplate.opsForValue().set(cartKey, pricingIds, CART_EXPIRE_DAYS, TimeUnit.DAYS); - + log.info("鎴愬姛浠庢暟鎹簱鍔犺浇鐢ㄦ埛{}鐨勮喘鐗╄溅鏁版嵁鍒癛edis", userId); return true; } catch (Exception e) { @@ -300,7 +317,7 @@ return false; } } - + @Override public boolean syncCartToDatabase(Long userId, Long unitId) { try { @@ -308,15 +325,15 @@ if (CollectionUtils.isEmpty(redisItems)) { return true; } - + // 娓呯┖鏁版嵁搴撲腑鐨勮喘鐗╄溅鏁版嵁 clearCartFromDatabase(userId, unitId); - + // 鍚屾Redis鏁版嵁鍒版暟鎹簱 for (CartItemVO item : redisItems) { syncCartItemToDatabase(userId, unitId, item); } - + log.info("鎴愬姛鍚屾Redis璐墿杞︽暟鎹埌鏁版嵁搴擄紝鐢ㄦ埛{}", userId); return true; } catch (Exception e) { @@ -324,18 +341,18 @@ return false; } } - + @Override public boolean checkCartConsistency(Long userId, Long unitId) { try { List<CartItemVO> redisItems = getCartItemsFromRedis(userId, unitId); List<Cart> dbItems = cartMapper.selectByUserIdAndUnitId(userId, unitId); - + if (redisItems.size() != dbItems.size()) { log.warn("璐墿杞︽暟鎹笉涓�鑷达細Redis鏁伴噺{}锛屾暟鎹簱鏁伴噺{}", redisItems.size(), dbItems.size()); return false; } - + // 妫�鏌ユ瘡涓晢鍝侀」鏄惁涓�鑷� for (CartItemVO redisItem : redisItems) { boolean found = false; @@ -351,56 +368,56 @@ return false; } } - + return true; } catch (Exception e) { log.error("妫�鏌ヨ喘鐗╄溅鏁版嵁涓�鑷存�уけ璐�", e); return false; } } - + // ==================== 绉佹湁鏂规硶 ==================== - + private String buildCartKey(Long userId, Long unitId) { return CART_KEY_PREFIX + userId + ":" + unitId; } - + private String buildCartItemKey(Long userId, Long unitId, Long pricingId) { return CART_ITEM_KEY_PREFIX + userId + ":" + unitId + ":" + pricingId; } - + private void updateCartItemList(Long userId, Long unitId, Long pricingId, boolean add) { String cartKey = buildCartKey(userId, unitId); List<Long> pricingIds = (List<Long>) redisTemplate.opsForValue().get(cartKey); - + if (pricingIds == null) { pricingIds = new ArrayList<>(); } - + if (add && !pricingIds.contains(pricingId)) { pricingIds.add(pricingId); } else if (!add) { pricingIds.remove(pricingId); } - + redisTemplate.opsForValue().set(cartKey, pricingIds, CART_EXPIRE_DAYS, TimeUnit.DAYS); } - + private List<Long> getCartItemPricingIds(Long userId, Long unitId) { String cartKey = buildCartKey(userId, unitId); List<Long> pricingIds = (List<Long>) redisTemplate.opsForValue().get(cartKey); return pricingIds != null ? pricingIds : new ArrayList<>(); } - + private List<CartItemVO> getCartItemsFromRedis(Long userId, Long unitId) { try { String cartKey = buildCartKey(userId, unitId); List<Long> pricingIds = (List<Long>) redisTemplate.opsForValue().get(cartKey); - + if (CollectionUtils.isEmpty(pricingIds)) { return new ArrayList<>(); } - + List<CartItemVO> items = new ArrayList<>(); for (Long pricingId : pricingIds) { String cartItemKey = buildCartItemKey(userId, unitId, pricingId); @@ -409,7 +426,7 @@ items.add(item); } } - + return items; } catch (Exception e) { log.error("浠嶳edis鑾峰彇璐墿杞﹀晢鍝佸垪琛ㄥけ璐�", e); @@ -467,7 +484,7 @@ try { Cart existingCart = cartMapper.selectByUserIdUnitIdAndPricingId(userId, unitId, pricingId); if (existingCart != null) { - cartMapper.deleteById(existingCart.getId()); + cartMapper.deleteByCustomerCondition(existingCart.getId()); } } catch (Exception e) { log.error("浠庢暟鎹簱鍒犻櫎璐墿杞﹀晢鍝佸け璐�", e); diff --git a/src/main/java/com/webmanage/service/impl/OrderInfoServiceImpl.java b/src/main/java/com/webmanage/service/impl/OrderInfoServiceImpl.java index 92a9b54..c981a09 100644 --- a/src/main/java/com/webmanage/service/impl/OrderInfoServiceImpl.java +++ b/src/main/java/com/webmanage/service/impl/OrderInfoServiceImpl.java @@ -190,7 +190,7 @@ @Override @Transactional(rollbackFor = Exception.class) - public String createOrder(CreateOrderDTO createOrderDTO) { + public OrderInfo createOrder(CreateOrderDTO createOrderDTO) { if (createOrderDTO == null || CollectionUtils.isEmpty(createOrderDTO.getItems())) { throw new BusinessException("璁㈠崟淇℃伅涓嶅畬鏁�"); } @@ -258,7 +258,7 @@ orderDetailMapper.insert(detail); } - return orderId; + return orderInfo; } @Override diff --git a/src/main/java/com/webmanage/service/impl/ProductPricingServiceImpl.java b/src/main/java/com/webmanage/service/impl/ProductPricingServiceImpl.java index f14987b..0d59412 100644 --- a/src/main/java/com/webmanage/service/impl/ProductPricingServiceImpl.java +++ b/src/main/java/com/webmanage/service/impl/ProductPricingServiceImpl.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.webmanage.common.BusinessException; +import com.webmanage.emun.PriceTypeEnum; import com.webmanage.entity.ProductPricing; import com.webmanage.mapper.ProductPricingMapper; import com.webmanage.service.ProductPricingService; @@ -47,8 +48,17 @@ if (!StringUtils.hasText(productPricing.getPriceType())) { throw new BusinessException("浠锋牸璁剧疆涓嶈兘涓虹┖"); } - if (productPricing.getPrice() == null || productPricing.getPrice().doubleValue() < 0) { - throw new BusinessException("浠锋牸鍊间笉鑳戒负绌轰笖涓嶈兘涓鸿礋鏁�"); + if (productPricing.getPriceType().indexOf(PriceTypeEnum.POINTS.getName()) > -1 + && productPricing.getPointsPrice() == null || + productPricing.getPriceType().indexOf(PriceTypeEnum.POINTS.getName()) > -1 + &&productPricing.getPointsPrice().doubleValue() < 0) { + throw new BusinessException("绉垎浠锋牸鍊间笉鑳戒负绌轰笖涓嶈兘涓鸿礋鏁�"); + } + if (productPricing.getPriceType().indexOf(PriceTypeEnum.CURRENCY.getName()) > -1 + && productPricing.getCurrencyPrice()== null || + productPricing.getPriceType().indexOf(PriceTypeEnum.CURRENCY.getName()) > -1 + && productPricing.getCurrencyPrice().doubleValue() < 0){ + throw new BusinessException("璐у竵浠锋牸鍊间笉鑳戒负绌轰笖涓嶈兘涓鸿礋鏁�"); } if (productPricing.getProductId() == null) { throw new BusinessException("浜у搧ID涓嶈兘涓虹┖"); @@ -96,8 +106,17 @@ if (!StringUtils.hasText(productPricing.getPriceType())) { throw new BusinessException("浠锋牸璁剧疆涓嶈兘涓虹┖"); } - if (productPricing.getPrice() == null || productPricing.getPrice().doubleValue() < 0) { - throw new BusinessException("浠锋牸鍊间笉鑳戒负绌轰笖涓嶈兘涓鸿礋鏁�"); + if (productPricing.getPriceType().indexOf(PriceTypeEnum.POINTS.getName()) > -1 + && productPricing.getPointsPrice() == null || + productPricing.getPriceType().indexOf(PriceTypeEnum.POINTS.getName()) > -1 + &&productPricing.getPointsPrice().doubleValue() < 0) { + throw new BusinessException("绉垎浠锋牸鍊间笉鑳戒负绌轰笖涓嶈兘涓鸿礋鏁�"); + } + if (productPricing.getPriceType().indexOf(PriceTypeEnum.CURRENCY.getName()) > -1 + && productPricing.getCurrencyPrice()== null || + productPricing.getPriceType().indexOf(PriceTypeEnum.CURRENCY.getName()) > -1 + && productPricing.getCurrencyPrice().doubleValue() < 0) { + throw new BusinessException("璐у竵浠锋牸鍊间笉鑳戒负绌轰笖涓嶈兘涓鸿礋鏁�"); } boolean result = updateById(productPricing); diff --git a/src/main/java/com/webmanage/service/impl/TokenServiceImpl.java b/src/main/java/com/webmanage/service/impl/TokenServiceImpl.java new file mode 100644 index 0000000..964e8b4 --- /dev/null +++ b/src/main/java/com/webmanage/service/impl/TokenServiceImpl.java @@ -0,0 +1,45 @@ +package com.webmanage.service.impl; + +import com.webmanage.service.TokenService; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.UUID; +import java.util.concurrent.TimeUnit; + +@Service +public class TokenServiceImpl implements TokenService { + + private static final String IDEMPOTENCY_TOKEN_PREFIX = "idempotency:token:"; + private static final long DEFAULT_EXPIRE_SECONDS = 60 * 5; // 5鍒嗛挓 + + @Resource + private RedisTemplate<String, Object> redisTemplate; + + @Override + public String generateToken(Long userId) { + String token = UUID.randomUUID().toString().replace("-", ""); + String key = IDEMPOTENCY_TOKEN_PREFIX + token; + // 鍊间笉閲嶈锛岃缃竴涓爣璁板嵆鍙� + redisTemplate.opsForValue().set(key, userId == null ? 0L : userId, DEFAULT_EXPIRE_SECONDS, TimeUnit.SECONDS); + return token; + } + + @Override + public boolean verifyAndConsume(String token) { + if (token == null || token.isEmpty()) { + return false; + } + String key = IDEMPOTENCY_TOKEN_PREFIX + token; + Boolean existed = redisTemplate.hasKey(key); + if (Boolean.TRUE.equals(existed)) { + // 娑堣垂鍚庡垹闄わ紝纭繚涓�娆℃�� + redisTemplate.delete(key); + return true; + } + return false; + } +} + + diff --git a/src/main/java/com/webmanage/vo/CartItemVO.java b/src/main/java/com/webmanage/vo/CartItemVO.java index b41078d..ab0275a 100644 --- a/src/main/java/com/webmanage/vo/CartItemVO.java +++ b/src/main/java/com/webmanage/vo/CartItemVO.java @@ -1,5 +1,6 @@ package com.webmanage.vo; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -66,8 +67,10 @@ private String remarks; @ApiModelProperty("娣诲姞鏃堕棿") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime addTime; @ApiModelProperty("鏈�鍚庢洿鏂版椂闂�") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime updateTime; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 3e402c4..52bb679 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -7,11 +7,12 @@ application: name: web-manage-back profiles: - active: test + active: dev jackson: date-format: yyyy-MM-dd HH:mm:ss time-zone: GMT+8 - + serialization: + write-dates-as-timestamps: false #mcv閰嶇疆 mvc: pathmatch: @@ -29,9 +30,6 @@ # 涓婚敭绫诲瀷 id-type: auto # 閫昏緫鍒犻櫎閰嶇疆 - logic-delete-field: deleted - logic-delete-value: 1 - logic-not-delete-value: 0 mapper-locations: classpath*:/mapper/**/*.xml # 鏃ュ織閰嶇疆 @@ -63,3 +61,12 @@ enable-consistency-check: true # 鍚屾绛栫暐锛歳ealtime锛堝疄鏃跺悓姝ワ級銆乥atch锛堟壒閲忓悓姝ワ級銆乵anual锛堟墜鍔ㄥ悓姝ワ級 sync-strategy: realtime + async: + executor: + core-pool-size: 4 + max-pool-size: 16 + queue-capacity: 500 + keep-alive-seconds: 60 + thread-name-prefix: async-cart- + wait-for-tasks-to-complete-on-shutdown: true + await-termination-seconds: 30 diff --git a/src/main/resources/mapper/CartMapper.xml b/src/main/resources/mapper/CartMapper.xml index 086a599..3d56c30 100644 --- a/src/main/resources/mapper/CartMapper.xml +++ b/src/main/resources/mapper/CartMapper.xml @@ -69,5 +69,8 @@ AND user_id = #{userId} AND unit_id = #{unitId} </select> + <delete id="deleteByCustomerCondition"> + delete from cart where id = #{id} + </delete> </mapper> diff --git a/src/main/resources/mapper/ProductPricingMapper.xml b/src/main/resources/mapper/ProductPricingMapper.xml index a9966a7..1d5398f 100644 --- a/src/main/resources/mapper/ProductPricingMapper.xml +++ b/src/main/resources/mapper/ProductPricingMapper.xml @@ -12,7 +12,8 @@ <result column="concurrent_nodes" property="concurrentNodes" jdbcType="VARCHAR"/> <result column="price_type" property="priceType" jdbcType="VARCHAR"/> <result column="price_unit" property="priceUnit" jdbcType="VARCHAR"/> - <result column="price" property="price" jdbcType="NUMERIC"/> + <result column="points_price" property="pointsPrice" jdbcType="DECIMAL"/> + <result column="currency_price" property="currencyPrice" jdbcType="DECIMAL"/> <result column="is_active" property="isActive" jdbcType="BOOLEAN"/> <result column="product_id" property="productId" jdbcType="BIGINT"/> <result column="product_name" property="productName" jdbcType="VARCHAR"/> @@ -29,7 +30,7 @@ <!-- 鍩虹瀛楁 --> <sql id="Base_Column_List"> id, suite_name, sales_form, customer_type, account_limit, concurrent_nodes, - price_type, price_unit, price, is_active, product_id, product_name, provider_id, + price_type, price_unit, points_price,currency_price, is_active, product_id, product_name, provider_id, provider_name, description, created_at, updated_at, created_by, updated_by, deleted </sql> -- Gitblit v1.8.0