This commit is contained in:
2026-02-04 17:35:46 +08:00
parent 7344aaae77
commit 0ee4577b31
82 changed files with 20458 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
-- Create Refund Table
CREATE TABLE public.ml_refunds (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
refund_no VARCHAR(50) UNIQUE NOT NULL,
user_id UUID NOT NULL REFERENCES public.ak_users(id),
order_id UUID NOT NULL REFERENCES public.ml_orders(id),
refund_type INTEGER NOT NULL, -- 1: Money Only, 2: Return & Refund
refund_reason VARCHAR(200) NOT NULL,
refund_amount DECIMAL(12,2) NOT NULL,
description TEXT,
images JSONB DEFAULT '[]',
status INTEGER DEFAULT 1, -- 1: Pending, 2: Approved, 3: Rejected, 4: Completed, 5: Cancelled
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
COMMENT ON TABLE public.ml_refunds IS '售后退款申请表';
-- Add RLS Policies (Optional but good practice)
ALTER TABLE public.ml_refunds ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Users can view their own refunds"
ON public.ml_refunds FOR SELECT
USING (auth.uid() = user_id);
CREATE POLICY "Users can insert their own refunds"
ON public.ml_refunds FOR INSERT
WITH CHECK (auth.uid() = user_id);