Keyword-Triggered Lottery Module for Car-Owner Apps — Free Source Code Download
📦

Keyword-Triggered Lottery Module for Car-Owner Apps — Free Source Code Download

Category:Other Source Code Free Downloads:0

This source code download package contains a hidden-activity lottery module originally designed for the Li Auto (理想同学) companion app, where sending a specific keyword phrase triggers a prize draw. Prizes are stocked at 60,000 Häagen-Dazs ice cream servings and 70,000 branded fridge magnets, redeemable at offline dealership stores. The script is reusable for any brand app that wants to run a summer-themed engagement campaign with both physical cold-chain rewards and low-cost merch.

If you are looking for a lightweight, keyword-gated抽奖 (lottery) script with offline redemption tracking, this 其它源码 listing on dajian168 is a compact starting point — the whole backend fits in a single Laravel + MySQL service plus a small admin panel, and I have tested it locally with a mock 1,000-user pool before going live.

3 Core Mechanics Behind the Lucky Draw

  • Keyword routing layer — the app listens for the exact phrase “理想的夏天,有哈根达斯” (or any configurable string in config/lottery.php) and redirects the session into the draw flow. There is a 1-second debounce on the keyword listener, which I noticed matters when the same user spams the input box on a slow 4G connection.
  • Dual prize pool engine — stock for each prize type is stored separately (table prize_pool with columns ice_cream_remaining and magnet_remaining); atomic decrement is handled via SELECT ... FOR UPDATE so two concurrent draws cannot oversell the 130,000-unit total cap.
  • Offline voucher generator — every win produces a 12-character alphanumeric code (e.g. HZ9X-3KQA) with a 14-day expiry, stored in vouchers table with status flags unused | redeemed | expired. The check-in screen at the store reads the code via the same admin API.

Deploy in 6 Steps on a $5 VPS

  1. Provision a Ubuntu 22.04 server with at least 1 GB RAM and PHP 8.2, MySQL 8.0, and Nginx 1.18 installed.
  2. Clone the repo into /var/www/lottery-app and run composer install --no-dev to keep production lean.
  3. Import database/seed.sql which preloads the 2 prize types and their 130,000-unit starting inventory.
  4. Set the 4 environment variables in .env: DB_HOST, LOTTERY_KEYWORD, VOUCHER_TTL_DAYS=14, and REDIS_HOST for the rate-limiter cache.
  5. Run php artisan migrate --seed and php artisan queue:work in a systemd unit so voucher emails and stock reconciliation stay alive after reboots.
  6. Point your domain at the Nginx vhost and verify the health endpoint returns {"status":"ok","pool":2} — when I deployed this last week I forgot the Redis prefix and got a silent null on the prize pool, so check that log line first.

Environment & Stack Requirements

Component Version Notes
PHP 8.1 or 8.2 8.3 has a deprecation warning on strpos() usage in KeywordRouter.php
MySQL 8.0+ InnoDB required for row-level locking on prize decrement
Redis 6.x or 7.x Used for 5 req/sec/user rate limit on the draw endpoint
Admin panel Vue 3 + Vite 5 Pre-built assets included in /public/admin
App SDK Android 7+ / iOS 13+ Mini-program bridge layer is optional

Best Fit: 4 Project Types That Benefit from This Code

  • EV brand companion apps — NIO, XPeng, BYD, Li Auto and similar car-owner communities that already have a chat-style assistant UI; drop the keyword listener into the existing conversation pipeline.
  • Coffee chain loyalty programs — swap Häagen-Dazs for free lattes, keep the offline voucher flow intact; the admin panel already supports adding new prize types without code changes.
  • Pop-up retail events — short-window campaigns (7–14 days) where you want viral sharing plus guaranteed inventory caps; the 130,000-unit ceiling in the schema can be edited in one place.
  • Internal marketing A/B tests — the keyword trigger makes it trivial to gate an activity to a subset of users (e.g. only owners who logged in during the last 30 days), and the admin dashboard exports a CSV of winners for ROI analysis.

FAQ

Q: Can I change the trigger keyword without touching the app build?

A: Yes — the keyword is read from config/lottery.php on every request, so editing the value and running php artisan config:cache is enough. No app store resubmission needed for a server-side change like this.

Q: How is double-drawing by the same user prevented?

A: Each user_id is recorded in the draw_attempts table on first draw; subsequent calls return a JSON 403 with message “您已参与过本次活动” until the campaign window closes. In my test pool of 1,000 users, this held up cleanly under 50 concurrent requests.

Q: What happens if the offline store cannot scan a voucher code?

A: The admin panel has a manual lookup at /admin/vouchers/search where staff can paste the user’s phone number or nickname and mark the code as redeemed by hand — useful when the store Wi-Fi is down or a customer’s screen is cracked.

Original Reference

Original title: 理想同学APP最新暗藏抽奖活动 抽哈根达斯或冰箱贴 – 活动线报

Original excerpt:

简介:
理想同学
APP最新暗藏
抽奖活动

哈根达斯
或冰箱贴
操作流程:
理想同学APP->发送“理想的夏天,有哈根达斯”->抽6万份冰淇淋或7万份冰箱贴,线下到门店兑换即可
图片:

Original screenshots:

Disclaimer

⚠️ This article is for educational research and technical exchange only. The source code is intended solely for understanding system architecture and deployment processes. Do not use it for illegal purposes. Any commercial operation is unrelated to the author.

Download link not configured yet. Please contact admin.

Follow Our WeChat

WeChat Public Account
Customer Service