Add SNS Marketing Campaign feature

- Add cash_cc_balance to User model (withdrawable CC)
- Create SnsShareSubmission model for SNS share verification
- Add marketing campaign settings to SystemSettings
- Add reward_type to ReferralReward model
- Create /api/sns-share endpoints for submission and verification
- Add referral signup reward logic (10CC on signup)
- Create /sns-share user page for SNS sharing
- Create /admin/sns-shares management page
- Add marketing settings UI to admin settings page
- Add SNS Shares menu to admin sidebar

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
AutonetSellCar Deploy
2026-01-03 18:21:17 +09:00
parent 718c5b0474
commit 7c943d8553
17 changed files with 1414 additions and 6 deletions

View File

@@ -0,0 +1,45 @@
-- Marketing Campaign Migration V1
-- Apply to staging/production PostgreSQL databases
--
-- Instructions:
-- 1. Connect to staging: psql -U autonet -d autonet_staging
-- 2. Run: \i /path/to/marketing_campaign_v1.sql
--
-- 1. Add cash_cc_balance to users table
ALTER TABLE users ADD COLUMN IF NOT EXISTS cash_cc_balance FLOAT DEFAULT 0.0;
-- 2. Create sns_share_submissions table
CREATE TABLE IF NOT EXISTS sns_share_submissions (
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(id),
car_id INTEGER NOT NULL REFERENCES cars(id),
platform VARCHAR(20) NOT NULL,
sns_url VARCHAR(500) NOT NULL,
status VARCHAR(20) DEFAULT 'pending',
rejected_reason TEXT,
reward_cc FLOAT DEFAULT 3.0,
rewarded_at TIMESTAMP WITH TIME ZONE,
submitted_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
verified_at TIMESTAMP WITH TIME ZONE,
verified_by INTEGER REFERENCES users(id)
);
CREATE INDEX IF NOT EXISTS ix_sns_share_submissions_user_id ON sns_share_submissions(user_id);
CREATE INDEX IF NOT EXISTS ix_sns_share_submissions_status ON sns_share_submissions(status);
-- 3. Add marketing settings to system_settings table
ALTER TABLE system_settings ADD COLUMN IF NOT EXISTS marketing_enabled BOOLEAN DEFAULT FALSE;
ALTER TABLE system_settings ADD COLUMN IF NOT EXISTS marketing_start_date TIMESTAMP WITH TIME ZONE;
ALTER TABLE system_settings ADD COLUMN IF NOT EXISTS marketing_end_date TIMESTAMP WITH TIME ZONE;
ALTER TABLE system_settings ADD COLUMN IF NOT EXISTS sns_share_reward_cc FLOAT DEFAULT 3.0;
ALTER TABLE system_settings ADD COLUMN IF NOT EXISTS referral_signup_reward_cc FLOAT DEFAULT 10.0;
ALTER TABLE system_settings ADD COLUMN IF NOT EXISTS event_cc_validity_months INTEGER DEFAULT 6;
ALTER TABLE system_settings ADD COLUMN IF NOT EXISTS withdrawal_enabled BOOLEAN DEFAULT TRUE;
ALTER TABLE system_settings ADD COLUMN IF NOT EXISTS min_withdrawal_usd FLOAT DEFAULT 10.0;
-- 4. Add reward_type to referral_rewards table
ALTER TABLE referral_rewards ADD COLUMN IF NOT EXISTS reward_type VARCHAR(20) DEFAULT 'payment';
-- Done
SELECT 'Marketing Campaign V1 migration completed!' AS status;