<?php
header('Content-Type: application/json; charset=utf-8');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST');

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    http_response_code(405);
    echo json_encode(['success' => false, 'error' => 'Method not allowed']);
    exit;
}

$redirect_url = 'https://example.com'; // Change to your CTA URL

$lots = [
    [
        'lot_no'   => 1,
        'level'    => '上上签',
        'title'    => '紫气东来',
        'poem'     => "紫云高照百福临\n金榜题名喜事频\n春风化雨桃花盛\n福寿双全乐天伦",
        'summary'  => '诸事顺遂，贵人相助，财运亨通，好运连连。宜把握时机，主动出击。',
    ],
    [
        'lot_no'   => 2,
        'level'    => '上上签',
        'title'    => '龙凤呈祥',
        'poem'     => "龙腾四海显神通\n凤舞九天展翅飞\n天赐良缘喜相逢\n福星高照事事成",
        'summary'  => '鸿运当头，万事如意。感情顺利，事业有成，宜积极进取。',
    ],
    [
        'lot_no'   => 3,
        'level'    => '上上签',
        'title'    => '金玉满堂',
        'poem'     => "金光闪闪照前程\n玉树临风气自华\n满载而归财源广\n堂前春色年年新",
        'summary'  => '财运极旺，投资有利，健康平安，家庭和谐美满。',
    ],
    [
        'lot_no'   => 4,
        'level'    => '上签',
        'title'    => '春风得意',
        'poem'     => "春风轻拂柳丝长\n得意之时莫忘形\n意气风发展宏图\n时来运转百事兴",
        'summary'  => '运势渐佳，只需保持耐心，佳音即将传来。',
    ],
    [
        'lot_no'   => 5,
        'level'    => '上签',
        'title'    => '万紫千红',
        'poem'     => "万里晴空迎好运\n紫气祥云绕身旁\n千载难逢好机缘\n红颜相伴享太平",
        'summary'  => '近期运势上扬，适合开展新计划，人际关系顺畅。',
    ],
    [
        'lot_no'   => 6,
        'level'    => '上签',
        'title'    => '步步高升',
        'poem'     => "步履稳健登高处\n步步莲花路路通\n高瞻远瞩谋大事\n升腾云霄展英才",
        'summary'  => '事业顺利，有升迁机会，宜努力把握，贵人临门。',
    ],
    [
        'lot_no'   => 7,
        'level'    => '上签',
        'title'    => '吉星高照',
        'poem'     => "吉祥如意处处逢\n星光灿烂照前程\n高朋满座喜气来\n照耀山河万古长",
        'summary'  => '吉星庇护，小事顺利，大事可期，宜广结善缘。',
    ],
    [
        'lot_no'   => 8,
        'level'    => '上签',
        'title'    => '财源广进',
        'poem'     => "财神驾临送财来\n源源不断滚滚来\n广结善缘福自至\n进退有据显才华",
        'summary'  => '财运不错，适合投资理财，但需量力而为，谨慎行事。',
    ],
    [
        'lot_no'   => 9,
        'level'    => '中签',
        'title'    => '守得云开',
        'poem'     => "守住初心莫动摇\n得失之间看淡然\n云淡风清心自宽\n开怀一笑见阳光",
        'summary'  => '近期平稳，有小波折但无大碍，保持平常心，静待时机。',
    ],
    [
        'lot_no'   => 10,
        'level'    => '中签',
        'title'    => '平安顺遂',
        'poem'     => "平湖秋月映天心\n安居乐业福满门\n顺应天时人和美\n遂心所愿步从容",
        'summary'  => '诸事平顺，健康平安，平稳过渡，无需焦虑。',
    ],
    [
        'lot_no'   => 11,
        'level'    => '中签',
        'title'    => '静待花开',
        'poem'     => "静心修炼待时机\n待得春来百花开\n花好月圆终有日\n开门迎客笑声来",
        'summary'  => '此刻宜静不宜动，蓄势待发，机会即将到来，耐心是关键。',
    ],
    [
        'lot_no'   => 12,
        'level'    => '中签',
        'title'    => '随缘自在',
        'poem'     => "随遇而安心自在\n缘来缘去皆天定\n自强不息勤耕耘\n在世为人当从容",
        'summary'  => '凡事顺其自然，强求无益，随缘便是最大的智慧。',
    ],
    [
        'lot_no'   => 13,
        'level'    => '中签',
        'title'    => '柳暗花明',
        'poem'     => "柳絮飞时春意浓\n暗香浮动月黄昏\n花开花落皆是缘\n明日又是新起点",
        'summary'  => '眼前虽有困难，但转机即将来临，坚持就是胜利。',
    ],
    [
        'lot_no'   => 14,
        'level'    => '下签',
        'title'    => '虚心学习',
        'poem'     => "虚怀若谷纳百川\n心存敬畏学无涯\n学而时习乃大成\n习得真知步步前",
        'summary'  => '近期运势稍弱，宜低调行事，多学习充实自己，蓄积能量。',
    ],
    [
        'lot_no'   => 15,
        'level'    => '下签',
        'title'    => '谨慎前行',
        'poem'     => "谨言慎行守本分\n慎重考虑莫轻动\n前路险峻需警醒\n行稳方能致深远",
        'summary'  => '此时不宜冒进，须谨慎处理各事，凡事三思而后行。',
    ],
];

shuffle($lots);
$lot = $lots[0];
$lot['success']      = true;
$lot['redirect_url'] = $redirect_url;

echo json_encode($lot, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
