diff --git a/pages/mall/merchant/sql/categories_rows.sql b/pages/mall/merchant/sql/categories_rows.sql deleted file mode 100644 index baa7882a..00000000 --- a/pages/mall/merchant/sql/categories_rows.sql +++ /dev/null @@ -1 +0,0 @@ -INSERT INTO "public"."categories" ("id", "name", "icon", "description", "color", "created_at") VALUES ('allergy', '抗过敏', '🤧', '过敏性疾病用药', '#9C27B0', '2026-01-30 01:48:28.396373+00'), ('child', '儿童用药', '👶', '儿童专用', '#00BCD4', '2026-01-28 09:23:10.344413+00'), ('chronic', '慢性疾病', '🫀', '长期管理', '#795548', '2026-01-28 09:23:10.344413+00'), ('cold', '感冒发烧', '🤧', '解热镇痛', '#2196F3', '2026-01-28 09:23:10.344413+00'), ('cough', '止咳化痰', '😷', '呼吸道疾病用药', '#2196F3', '2026-01-30 01:48:28.396373+00'), ('device', '医疗器械', '🩺', '医疗设备', '#607D8B', '2026-01-28 09:23:10.344413+00'), ('external', '外用药品', '🧴', '外用制剂', '#8BC34A', '2026-01-28 09:23:10.344413+00'), ('health', '健康食品', '🥗', '保健食品', '#FFC107', '2026-01-28 09:23:10.344413+00'), ('pain', '止痛消炎', '💊', '镇痛消炎', '#F44336', '2026-01-28 09:23:10.344413+00'), ('skin', '皮肤用药', '🤕', '皮肤护理', '#9C27B0', '2026-01-28 09:23:10.344413+00'), ('stomach', '肠胃用药', '🤢', '消化系统', '#4CAF50', '2026-01-28 09:23:10.344413+00'), ('vitamin', '维生素', '🍊', '营养补充', '#FF9800', '2026-01-28 09:23:10.344413+00'); \ No newline at end of file diff --git a/pages/mall/merchant/sql/create_ml_brands_and_member_levels.sql b/pages/mall/merchant/sql/create_ml_brands_and_member_levels.sql deleted file mode 100644 index 7a3f1e33..00000000 --- a/pages/mall/merchant/sql/create_ml_brands_and_member_levels.sql +++ /dev/null @@ -1,109 +0,0 @@ --- ===================================================== --- 在 Supabase Studio > SQL Editor 中执行此文件 --- 解决 ml_brands / ml_member_levels 404 问题 --- 字段名严格对齐前端 product-edit.uvue 代码 --- ===================================================== - - --- ===================================================== --- 一、品牌表 ml_brands --- ===================================================== --- 前端 loadBrands() 用到字段:id, name, logo_url, is_active --- 查询条件:is_active = true,排序:name asc - -CREATE TABLE IF NOT EXISTS public.ml_brands ( - id UUID PRIMARY KEY DEFAULT gen_random_uuid(), - name VARCHAR(200) NOT NULL, - logo_url TEXT, - description TEXT, - website VARCHAR(500), - is_active BOOLEAN DEFAULT TRUE, - created_at TIMESTAMPTZ DEFAULT NOW(), - updated_at TIMESTAMPTZ DEFAULT NOW() -); - -COMMENT ON TABLE public.ml_brands IS '品牌表'; - --- RLS 策略:登录用户 / 匿名用户均可读 -ALTER TABLE public.ml_brands ENABLE ROW LEVEL SECURITY; - -DROP POLICY IF EXISTS "ml_brands anon select" ON public.ml_brands; -CREATE POLICY "ml_brands anon select" - ON public.ml_brands FOR SELECT - TO authenticated, anon - USING (true); - --- 初始化测试数据(可按需修改) -INSERT INTO public.ml_brands (name, logo_url, description, is_active) VALUES - ('健民医药', '', '综合医药品牌', true), - ('同仁堂', '', '百年老字号中医药', true), - ('华润医疗', '', '华润集团旗下医疗品牌', true) -ON CONFLICT DO NOTHING; - - --- ===================================================== --- 二、会员等级表 ml_member_levels --- ===================================================== --- 前端 loadMemberLevels() 用到字段: --- id, name, level_rank, discount_rate, is_active --- 查询条件:is_active = true,排序:level_rank asc - -CREATE TABLE IF NOT EXISTS public.ml_member_levels ( - id UUID PRIMARY KEY DEFAULT gen_random_uuid(), - name VARCHAR(100) NOT NULL, - level_rank INTEGER NOT NULL DEFAULT 0, -- 等级排序(越小越低) - discount_rate DECIMAL(5,4) NOT NULL DEFAULT 1.0000, -- 折扣率,0.85 = 85折 - min_amount DECIMAL(10,2) DEFAULT 0, -- 升级所需累计消费金额 - description TEXT, - is_active BOOLEAN DEFAULT TRUE, - created_at TIMESTAMPTZ DEFAULT NOW(), - updated_at TIMESTAMPTZ DEFAULT NOW() -); - -COMMENT ON TABLE public.ml_member_levels IS '会员等级配置表'; -COMMENT ON COLUMN public.ml_member_levels.discount_rate IS '折扣率,0.85 表示 85 折,1.0 表示无折扣'; -COMMENT ON COLUMN public.ml_member_levels.level_rank IS '等级排序值,数值越小等级越低,用于前端排序'; - --- RLS 策略:登录用户 / 匿名用户均可读 -ALTER TABLE public.ml_member_levels ENABLE ROW LEVEL SECURITY; - -DROP POLICY IF EXISTS "ml_member_levels anon select" ON public.ml_member_levels; -CREATE POLICY "ml_member_levels anon select" - ON public.ml_member_levels FOR SELECT - TO authenticated, anon - USING (true); - --- 初始化 5 档会员等级数据 -INSERT INTO public.ml_member_levels (name, level_rank, discount_rate, min_amount, description, is_active) VALUES - ('普通会员', 0, 1.0000, 0, '注册即享', true), - ('铜牌会员', 1, 0.9800, 500, '累计消费满500元', true), - ('银牌会员', 2, 0.9500, 2000, '累计消费满2000元', true), - ('金牌会员', 3, 0.9200, 5000, '累计消费满5000元', true), - ('钻石会员', 4, 0.8800, 10000, '累计消费满10000元',true) -ON CONFLICT DO NOTHING; - - --- ===================================================== --- 三、商品会员价关联表 ml_product_member_prices(如不存在则补建) --- ===================================================== --- 前端 loadMemberPrices() 用到字段:product_id, level_id, member_price - -CREATE TABLE IF NOT EXISTS public.ml_product_member_prices ( - id UUID PRIMARY KEY DEFAULT gen_random_uuid(), - product_id UUID NOT NULL, - level_id UUID NOT NULL REFERENCES public.ml_member_levels(id) ON DELETE CASCADE, - member_price DECIMAL(12,2) NOT NULL CHECK (member_price >= 0), - created_at TIMESTAMPTZ DEFAULT NOW(), - updated_at TIMESTAMPTZ DEFAULT NOW(), - UNIQUE (product_id, level_id) -); - -COMMENT ON TABLE public.ml_product_member_prices IS '商品会员等级专属价格'; - -ALTER TABLE public.ml_product_member_prices ENABLE ROW LEVEL SECURITY; - -DROP POLICY IF EXISTS "ml_product_member_prices anon select" ON public.ml_product_member_prices; -CREATE POLICY "ml_product_member_prices anon select" - ON public.ml_product_member_prices FOR SELECT - TO authenticated, anon - USING (true);