<?php
if ( ! defined( 'ABSPATH' ) ) exit;

// 注意这里的类名，要和主文件里 YFJ_Module_ + ucfirst('bazi_cesuan') 对应
class YFJ_Module_Zhanbu_xingzuo extends YFJ_Base_Module {

    public function __construct() {
        $this->module_id = 'zhanbu_xingzuo';             // 1. 修改模块 ID
        $this->shortcode = 'yfj_zhanbu_xingzuo';         // 2. 修改短代码
        $this->api_endpoint = '/v1/Zhanbu/yunshi';       // 3. 配置对应的真实 API 接口

        // 🚀 新增：声明本模块支持英文能力
        $this->supported_langs = ['zh-cn', 'zh-tw', 'en-us'];

        parent::__construct();
    }

    /**
     * 【星座运势专属：结合当天的瞬态缓存策略】
     * 解决跨天缓存失效问题
     */
    protected function fetch_api_data($api_url, $payload) {
        // 1. 获取请求类型和星座ID
        $type = $payload['type'] ?? '0'; // 0: 星座, 1: 生肖
        $yunshi_id = $payload['title_yunshi'] ?? '';

        if ($yunshi_id === '') {
            return parent::fetch_api_data($api_url, $payload);
        }

        // 2. 获取当前的本地年月日 (使用 WP 函数防时区错乱)
        $today = current_time('Ymd');

        // 3. 生成带日期的 Cache Key (例: yfj_xz_20260503_t0_id3)
        // 跨过零点后，$today 发生改变，自动生成全新的 Key
        $cache_key = 'yfj_xz_' . $today . '_t' . $type . '_id' . $yunshi_id;

        // 4. 读取本地瞬态缓存
        $cached_body = get_transient($cache_key);

        if (false !== $cached_body) {
            // 命中当天的缓存，直接返回
            return $cached_body;
        }

        // 5. 未命中（或者是新的一天首次请求），请求服务器
        $body = parent::fetch_api_data($api_url, $payload);

        // 6. 校验通过，写入缓存
        // 依然可以保持 3 小时的刷新频率（防备接口白天更新内容），同时靠 Key 保证零点强制刷新
        if ($body && isset($body['errcode']) && $body['errcode'] == 0) {
            set_transient($cache_key, $body, 3 * HOUR_IN_SECONDS);
        }

        return $body;
    }

    /**
     * 专属数据拦截与加工引擎 (重写基类方法)
     * 在这里可以对 API 返回的原始数据进行格式化、过滤或追加二次计算的自定义数据。
     */
    protected function process_api_data($raw_data) {
        // 1. 确保数据是数组格式，防止报错
        if (is_array($raw_data)) {
            //如果 API 没返回格局，给个默认的兜底值
            if (!isset($raw_data['base_info']['zhengge'])) {
                $raw_data['base_info']['zhengge'] = '未入格';
            }
        }

        //将处理后的数据返回给 views/result.php 进行渲染
        return $raw_data;
    }

    /**
     * 沙盒模式下的模拟数据
     */
    protected function get_demo_data($post_data) {
        //获取当前后台设置的语言
        $lang = get_option('yfj_language', 'zh-cn');

        // 1. 把你的完整 JSON 粘贴到单引号里面（要考虑到zh-cn 和 zh-tw）
        $demo_json_zh_cn = '{"errcode":0,"errmsg":"请求成功","notice":"本次测算结果仅供娱乐使用，请勿用于封建迷信和违法用途。","data":{"运势类型":"巨蟹座","今日运势":{"速配星座":"摩羯座","提防星座":"白羊座","幸运颜色":"白色","幸运数字":"57","幸运宝石":"蓝猫眼石","综合分数":"84","爱情分数":"80","事业分数":"82","心情分数":"81","交际分数":"83","财富分数":"79","健康分数":"85","今明运势":"今日的运势预示着，你将迎来充满积极能量与机遇的一天。你的决心与毅力将是取得成功的核心要素，无论是在职业生涯还是个人生活中。与他人合作、分享想法将为你带来更多好运，所以不要犹豫，积极主动地与他人建立联系。今日是充满机遇与积极氛围的一天，充分利用这些机会，你将取得令人满意的成绩。","爱情运势":"今日的爱情运势鼓励，处于长期稳定关系中的你，与伴侣共同精心规划未来的发展蓝图，携手努力实现共同的目标。在这个过程中，相互支持、彼此珍惜，是保持关系稳固的核心要素。通过共同度过丰富多彩的美好时光，不断加深感情的深度，你们的爱情将坚如磐石，抵御生活中的一切风雨。","事业运势":"今日的事业运势机遇与挑战交织。虽可能遭遇难题，但积极的行动与坚定的决心，助你克服困难，收获职场成功。与同事、合作伙伴紧密协作，共同朝着目标奋进，推动项目顺利进展。把握今日机遇，奋力追求更大成就。","财富运势":"今日的财富运势积极向前，充满希望。你可能迎来令人振奋的财务消息或宝贵机遇，收获意外之财。当下是进行长期投资规划的好时机，但仍需保持谨慎理性，充分利用这些机遇，确保财务稳健发展。始终坚守财务目标，稳步迈向更加富裕的未来。","健康运势":"今日的健康运势提示你，要密切关注自己的身体信号。当身体发出疲惫或不适的信号时，及时停下手中的事务，给自己留出休息与放松的时间，缓解潜在的压力。坚持良好的饮食习惯，为身体提供稳定的营养支持；适度锻炼，激发身体的活力。此外，心理健康同样不容忽视，注重心理压力的管理，通过冥想、阅读等方式放松身心。全方位照顾好自己，为维持全面的健康状态不懈努力。"},"明日运势":{"速配星座":"水瓶座","提防星座":"金牛座","幸运颜色":"紫色","幸运数字":"58","幸运宝石":"紫水晶","综合分数":"85","爱情分数":"81","事业分数":"83","心情分数":"82","交际分数":"84","财富分数":"80","健康分数":"86","今明运势":"今日的运势表明，你即将踏入满是正向蜕变与契机的时段。你的创造力与决心将处于巅峰状态，有望在个人生活中取得显著的进步。这将充分展现你的能力，为未来的晋升奠定坚实基础。今日将是充满希望与机遇的一天，积极有效地利用它，你将收获令人满意的成果。","爱情运势":"今日的爱情运势显示，你与伴侣之间的情感将愈发醇厚深沉。共同参与一场刺激的冒险活动，或是度过一个宁静的周末午后，这些浪漫时刻都将如同璀璨星辰，点缀在你们的爱情天空，进一步增进彼此间的亲密感。单身的你，或许会在一次偶然的社交互动中，遇到那个吸引你目光的人，勇敢地敞开心扉，迎接新感情的到来。","事业运势":"今日的事业运势波澜不惊，平稳有序。工作环境宁静平和，无明显起伏。保持专注与稳健工作态度，延续高效工作节奏，助力职场平稳运行。今日适合巩固现有工作，规划未来职业发展路径。","财富运势":"今日的财富运势平稳如昔。财务状况相对宁静，无明显波动。坚守财务规划和预算，继续保持稳健消费习惯。长期投资策略和储蓄计划将助力财富逐步增长。保持冷静理性，财务状况将持续稳定在稳健轨道上。","健康运势":"今日的健康运势鼓励你用心关注身体的需求。选择适度的运动项目，如打羽毛球、跳健身操等，让身体在运动中焕发生机；搭配健康饮食，为身体提供充足的能量与营养，保持体力与精力的充沛。同时，敏锐察觉身体的任何不适或症状，一旦发现异常，及时寻求专业医疗建议。心理健康同样重要，尝试通过冥想、听音乐等放松练习，为心灵减压。全面呵护身体与心灵，推动整体健康水平的提升。"},"本周运势":{"速配星座":"狮子座","提防星座":"天蝎座","幸运颜色":"深绿色","幸运数字":"40","幸运宝石":"红宝石","综合分数":"87","爱情分数":"83","事业分数":"85","心情分数":"84","交际分数":"86","财富分数":"82","健康分数":"88","本周运势":"本周运势好坏交织。工作中，项目在关键时刻出现资源短缺的问题，需要努力协调解决，但也因此锻炼了自己的应变能力。个人生活里，与家人因观念问题产生分歧，经过沟通后相互理解。财务上，购物时冲动消费，需要控制自己的消费欲望。健康上，注意饮食清淡，预防上火。","爱情运势":"本周爱情运势充满挑战。单身的你，在追求爱情的过程中，可能会遇到一些竞争对手。但这也是一个展现自己优势和魅力的机会，通过提升自己，真诚地对待心仪对象，你有可能赢得对方的心。有伴侣的人，可能会因为工作压力大，导致忽略了爱人的感受。此时，需要及时调整自己的状态，抽出时间陪伴对方，表达自己的爱意，弥补对爱人的疏忽，让感情重回正轨。","事业运势":"本周事业运势呈上升趋势，如旭日东升。职场人士在工作中积极主动，勇于承担责任，完成了一项又一项重要任务，得到领导的赏识和提拔，实现了职业晋升。企业在与供应商的合作中，通过良好的沟通和协商，争取到了更优惠的采购价格和更有利的合作条件，降低了企业的运营成本，提高了企业的竞争力。","财富运势":"本周财富运势谨慎为宜，财务风险需时刻警惕。工作中可能会遇到一些竞争压力，导致收入增长受限，要努力提升自身竞争力。投资领域，市场不稳定因素较多，股票、基金等产品风险较高，建议减少投资比例。生活中，要严格控制开支，避免借贷消费，以防陷入财务困境。","健康运势":"本周健康运势平稳向好，身体恢复能力增强。若之前有运动损伤或疾病，这段时间恢复速度加快。按照医生建议或康复计划，积极进行康复训练，促进身体恢复。饮食上，增加富含胶原蛋白的食物摄入，如猪蹄、鱼皮，有助于伤口愈合与组织修复。"},"本月运势":{"速配星座":"白羊座","提防星座":"巨蟹座","幸运颜色":"深蓝色","幸运数字":"30","幸运宝石":"红宝石","综合分数":"87","爱情分数":"83","事业分数":"85","心情分数":"84","交际分数":"86","财富分数":"82","健康分数":"88","本月运势":"本月学业上，你对知识的理解更加深入，能够举一反三，解决难题。家庭氛围温馨，家人为你提供良好的学习环境。身体状况不错，能保持良好的学习状态。月中后，可能会遇到一些学习上的竞争对手，激发你的斗志。社交方面，与同学交流学习经验，共同进步。本月持续努力，学业成绩会有显著提升。","爱情运势":"本月爱情运势有积极变化。有伴侣的人会发现彼此之间的关系更加亲密无间，能够分享彼此内心深处的想法和感受，感情进一步升华。单身者在参加社交聚会时，可能会遇到一个特别的人，对方的出现让你眼前一亮。要勇敢地表达自己的好感，积极与对方发展关系。","事业运势":"本月事业运势稳步提升。您在工作中表现出色，能够高效地完成各项任务，为公司创造了良好的经济效益。同时，您还积极参与公司的团队建设和文化活动，增强了团队的凝聚力和向心力。在这个过程中，您不仅提升了自己的工作能力，还赢得了同事和领导的尊重和信任。持续保持这种良好的状态，事业将不断迈向新的高度。","财富运势":"本月财富运势较为平淡，收入没有明显增长，支出也相对稳定。在这种情况下，可对家庭资产进行一次全面盘点，包括现金、存款、房产、车辆、投资产品等。分析各项资产的占比是否合理，是否存在资产闲置或浪费的情况。例如，对于闲置的房产，可以考虑出租以增加收入；对于收益较低的投资产品，可以进行调整优化。通过资产盘点和优化，挖掘潜在的财富增长空间，在平淡的财富运势中，为未来的财富增长做好准备，提升整体财务状况。","健康运势":"本月健康运势呈上升趋势，身体状态逐渐改善，精力也越来越充沛。这是一个适合进行健康挑战的月份，比如尝试连续一周每天早起进行晨练，或者坚持一个月不吃垃圾食品。通过这些挑战，进一步强化健康意识，养成更健康的生活习惯。在运动方面，逐渐增加运动的难度和强度，挑战自己的体能极限。饮食上，学习营养搭配知识，为自己制定更科学的饮食计划，让健康运势持续上升，收获更健康的身体。"},"本年运势":{"速配星座":"双子座","提防星座":"处女座","幸运颜色":"橄榄绿","幸运数字":"50","幸运宝石":"蛋白石","综合分数":"77","爱情分数":"98","事业分数":"75","心情分数":"99","交际分数":"76","财富分数":"97","健康分数":"78","本年运势":"本年度首季，运势平稳中略带上升趋势，事业和生活都朝着好的方向发展。进入第二季度，运势进一步上扬，发展速度加快，诸多新的可能性涌现。第三季度是运势爆发期，成功与机遇相伴，而到了第四季度，要警惕潜在风险，提前做好应对预案，确保本年度顺利收尾，不留遗憾。","爱情运势":"这一年，有对象的人爱情运势会有一些起伏。在事业忙碌期，可能会忽略对方的感受，导致感情出现一些小危机。但只要及时调整状态，抽出时间陪伴对方，关心对方的需求，就能化解危机，让感情重回正轨。可以利用周末的时间一起去看电影、逛街，享受二人世界。单身人士在本年可能会在工作场合遇到心仪的对象。与同事长时间的合作和交流，可能会让你发现对方身上的闪光点，从而产生爱慕之情。在工作中积极表现自己，展现自己的专业能力和责任心，同时注意与同事保持良好的沟通和合作关系，为爱情的发展创造机会。","事业运势":"这一年，事业运势迎来丰收期。过去几年的辛勤努力和积累在本年得到了全面的回报。你负责的多个项目都取得了圆满成功，为公司创造了显著的经济效益。你的专业能力和领导才华得到了充分的展现，在公司内部树立了良好的口碑。公司为了表彰你的突出贡献，给予你丰厚的物质奖励和晋升机会。同时，你还受到了行业内其他企业的关注和邀请，为自己的职业发展赢得了更多的选择空间。在丰收的喜悦中，你不忘继续努力，为公司的未来发展制定更加宏伟的计划，比如带领团队连续完成多个大型项目，为公司带来了双倍的利润增长。","财富运势":"这一年，财富运势整体平稳，但在平稳中暗藏机遇。年初，财务状况稳定，没有明显的收入波动或支出压力。在日常工作中，要留意行业动态和市场变化，积极寻找潜在的财富增长点。例如，发现公司业务拓展需要新的技术支持，而你恰好掌握相关技术，通过主动参与项目，不仅能提升自己在公司的价值，还有可能获得额外的奖励或分成。在投资理财方面，选择一些稳健型的理财产品，如银行理财产品、优质企业债券等，确保资金在安全的前提下实现一定增值，比如投资年化收益率为 4% 左右的银行理财产品。","健康运势":"这一年，健康运势先平稳后出现小波动。在年初到年中的时间段，身体和心理状态相对稳定，能正常开展各项活动。但进入下半年，可能会因为季节变化、工作压力增大等因素，出现一些小的健康波动，如秋季容易出现皮肤干燥、呼吸道不适等问题。针对这些情况，要提前做好预防措施。在季节交替前，提前调整饮食，增加滋阴润燥的食物摄入，如银耳、百合等。同时，根据天气变化及时增减衣物，注意保暖。对于工作压力，学会合理分配任务，避免过度劳累。当身体出现不适时，及时采取应对措施，如使用保湿护肤品缓解皮肤干燥，通过多喝水、多休息缓解呼吸道不适，确保健康运势在波动中能够迅速恢复平稳。"}}}';
        $demo_json_zh_tw = '{"errcode":0,"errmsg":"请求成功","notice":"本次测算结果仅供娱乐使用，请勿用于封建迷信和违法用途。","data":{"运势类型":"巨蟹座","今日运势":{"速配星座":"摩羯座","提防星座":"白羊座","幸运颜色":"白色","幸运数字":"57","幸运宝石":"藍貓眼石","综合分数":"84","爱情分数":"80","事业分数":"82","心情分数":"81","交际分数":"83","财富分数":"79","健康分数":"85","今明运势":"今日的運勢預示著，你將迎來充滿積極能量與機遇的一天。你的決心與毅力將是取得成功的核心要素，無論是在職業生涯還是個人生活中。與他人合作、分享想法將為你帶來更多好運，所以不要猶豫，積極主動地與他人建立聯系。今日是充滿機遇與積極氛圍的一天，充分利用這些機會，你將取得令人滿意的成績。","爱情运势":"今日的愛情運勢鼓勵，處於長期穩定關系中的你，與伴侶共同精心規劃未來的發展藍圖，攜手努力實現共同的目標。在這個過程中，相互支持、彼此珍惜，是保持關系穩固的核心要素。通過共同度過豐富多彩的美好時光，不斷加深感情的深度，你們的愛情將堅如磐石，抵禦生活中的一切風雨。","事业运势":"今日的事業運勢機遇與挑戰交織。雖可能遭遇難題，但積極的行動與堅定的決心，助你克服困難，收獲職場成功。與同事、合作夥伴緊密協作，共同朝著目標奮進，推動項目順利進展。把握今日機遇，奮力追求更大成就。","财富运势":"今日的財富運勢積極向前，充滿希望。你可能迎來令人振奮的財務消息或寶貴機遇，收獲意外之財。當下是進行長期投資規劃的好時機，但仍需保持謹慎理性，充分利用這些機遇，確保財務穩健發展。始終堅守財務目標，穩步邁向更加富裕的未來。","健康运势":"今日的健康運勢提示你，要密切關註自己的身體信號。當身體發出疲憊或不適的信號時，及時停下手中的事務，給自己留出休息與放松的時間，緩解潛在的壓力。堅持良好的飲食習慣，為身體提供穩定的營養支持；適度鍛煉，激發身體的活力。此外，心理健康同樣不容忽視，註重心理壓力的管理，通過冥想、閱讀等方式放松身心。全方位照顧好自己，為維持全面的健康狀態不懈努力。"},"明日运势":{"速配星座":"水瓶座","提防星座":"金牛座","幸运颜色":"紫色","幸运数字":"58","幸运宝石":"紫水晶","综合分数":"85","爱情分数":"81","事业分数":"83","心情分数":"82","交际分数":"84","财富分数":"80","健康分数":"86","今明运势":"今日的運勢表明，你即將踏入滿是正向蛻變與契機的時段。你的創造力與決心將處於巔峰狀態，有望在個人生活中取得顯著的進步。這將充分展現你的能力，為未來的晉升奠定堅實基礎。今日將是充滿希望與機遇的一天，積極有效地利用它，你將收獲令人滿意的成果。","爱情运势":"今日的愛情運勢顯示，你與伴侶之間的情感將愈發醇厚深沈。共同參與一場刺激的冒險活動，或是度過一個寧靜的周末午後，這些浪漫時刻都將如同璀璨星辰，點綴在你們的愛情天空，進一步增進彼此間的親密感。單身的你，或許會在一次偶然的社交互動中，遇到那個吸引你目光的人，勇敢地敞開心扉，迎接新感情的到來。","事业运势":"今日的事業運勢波瀾不驚，平穩有序。工作環境寧靜平和，無明顯起伏。保持專註與穩健工作態度，延續高效工作節奏，助力職場平穩運行。今日適合鞏固現有工作，規劃未來職業發展路徑。","财富运势":"今日的財富運勢平穩如昔。財務狀況相對寧靜，無明顯波動。堅守財務規劃和預算，繼續保持穩健消費習慣。長期投資策略和儲蓄計劃將助力財富逐步增長。保持冷靜理性，財務狀況將持續穩定在穩健軌道上。","健康运势":"今日的健康運勢鼓勵你用心關註身體的需求。選擇適度的運動項目，如打羽毛球、跳健身操等，讓身體在運動中煥發生機；搭配健康飲食，為身體提供充足的能量與營養，保持體力與精力的充沛。同時，敏銳察覺身體的任何不適或癥狀，一旦發現異常，及時尋求專業醫療建議。心理健康同樣重要，嘗試通過冥想、聽音樂等放松練習，為心靈減壓。全面呵護身體與心靈，推動整體健康水平的提升。"},"本周运势":{"速配星座":"獅子座","提防星座":"天蠍座","幸运颜色":"深綠色","幸运数字":"40","幸运宝石":"紅寶石","综合分数":"87","爱情分数":"83","事业分数":"85","心情分数":"84","交际分数":"86","财富分数":"82","健康分数":"88","本周运势":"本周運勢好壞交織。工作中，項目在關鍵時刻出現資源短缺的問題，需要努力協調解決，但也因此鍛煉了自己的應變能力。個人生活裏，與家人因觀念問題產生分歧，經過溝通後相互理解。財務上，購物時沖動消費，需要控製自己的消費欲望。健康上，註意飲食清淡，預防上火。","爱情运势":"本周愛情運勢充滿挑戰。單身的你，在追求愛情的過程中，可能會遇到一些競爭對手。但這也是一個展現自己優勢和魅力的機會，通過提升自己，真誠地對待心儀對象，你有可能贏得對方的心。有伴侶的人，可能會因為工作壓力大，導致忽略了愛人的感受。此時，需要及時調整自己的狀態，抽出時間陪伴對方，表達自己的愛意，彌補對愛人的疏忽，讓感情重回正軌。","事业运势":"本周事業運勢呈上升趨勢，如旭日東升。職場人士在工作中積極主動，勇於承擔責任，完成了一項又一項重要任務，得到領導的賞識和提拔，實現了職業晉升。企業在與供應商的合作中，通過良好的溝通和協商，爭取到了更優惠的采購價格和更有利的合作條件，降低了企業的運營成本，提高了企業的競爭力。","财富运势":"本周財富運勢謹慎為宜，財務風險需時刻警惕。工作中可能會遇到一些競爭壓力，導致收入增長受限，要努力提升自身競爭力。投資領域，市場不穩定因素較多，股票、基金等產品風險較高，建議減少投資比例。生活中，要嚴格控製開支，避免借貸消費，以防陷入財務困境。","健康运势":"本周健康運勢平穩向好，身體恢復能力增強。若之前有運動損傷或疾病，這段時間恢復速度加快。按照醫生建議或康復計劃，積極進行康復訓練，促進身體恢復。飲食上，增加富含膠原蛋白的食物攝入，如豬蹄、魚皮，有助於傷口愈合與組織修復。"},"本月运势":{"速配星座":"白羊座","提防星座":"巨蟹座","幸运颜色":"深藍色","幸运数字":"30","幸运宝石":"紅寶石","综合分数":"87","爱情分数":"83","事业分数":"85","心情分数":"84","交际分数":"86","财富分数":"82","健康分数":"88","本月运势":"本月學業上，你對知識的理解更加深入，能夠舉一反三，解決難題。家庭氛圍溫馨，家人為你提供良好的學習環境。身體狀況不錯，能保持良好的學習狀態。月中後，可能會遇到一些學習上的競爭對手，激發你的鬥誌。社交方面，與同學交流學習經驗，共同進步。本月持續努力，學業成績會有顯著提升。","爱情运势":"本月愛情運勢有積極變化。有伴侶的人會發現彼此之間的關系更加親密無間，能夠分享彼此內心深處的想法和感受，感情進一步升華。單身者在參加社交聚會時，可能會遇到一個特別的人，對方的出現讓你眼前一亮。要勇敢地表達自己的好感，積極與對方發展關系。","事业运势":"本月事業運勢穩步提升。您在工作中表現出色，能夠高效地完成各項任務，為公司創造了良好的經濟效益。同時，您還積極參與公司的團隊建設和文化活動，增強了團隊的凝聚力和向心力。在這個過程中，您不僅提升了自己的工作能力，還贏得了同事和領導的尊重和信任。持續保持這種良好的狀態，事業將不斷邁向新的高度。","财富运势":"本月財富運勢較為平淡，收入沒有明顯增長，支出也相對穩定。在這種情況下，可對家庭資產進行一次全面盤點，包括現金、存款、房產、車輛、投資產品等。分析各項資產的占比是否合理，是否存在資產閑置或浪費的情況。例如，對於閑置的房產，可以考慮出租以增加收入；對於收益較低的投資產品，可以進行調整優化。通過資產盤點和優化，挖掘潛在的財富增長空間，在平淡的財富運勢中，為未來的財富增長做好準備，提升整體財務狀況。","健康运势":"本月健康運勢呈上升趨勢，身體狀態逐漸改善，精力也越來越充沛。這是一個適合進行健康挑戰的月份，比如嘗試連續一周每天早起進行晨練，或者堅持一個月不吃垃圾食品。通過這些挑戰，進一步強化健康意識，養成更健康的生活習慣。在運動方面，逐漸增加運動的難度和強度，挑戰自己的體能極限。飲食上，學習營養搭配知識，為自己製定更科學的飲食計劃，讓健康運勢持續上升，收獲更健康的身體。"},"本年运势":{"速配星座":"雙子座","提防星座":"處女座","幸运颜色":"橄欖綠","幸运数字":"50","幸运宝石":"蛋白石","综合分数":"77","爱情分数":"98","事业分数":"75","心情分数":"99","交际分数":"76","财富分数":"97","健康分数":"78","本年运势":"本年度首季，運勢平穩中略帶上升趨勢，事業和生活都朝著好的方向發展。進入第二季度，運勢進一步上揚，發展速度加快，諸多新的可能性湧現。第三季度是運勢爆發期，成功與機遇相伴，而到了第四季度，要警惕潛在風險，提前做好應對預案，確保本年度順利收尾，不留遺憾。","爱情运势":"這一年，有對象的人愛情運勢會有一些起伏。在事業忙碌期，可能會忽略對方的感受，導致感情出現一些小危機。但只要及時調整狀態，抽出時間陪伴對方，關心對方的需求，就能化解危機，讓感情重回正軌。可以利用周末的時間一起去看電影、逛街，享受二人世界。單身人士在本年可能會在工作場合遇到心儀的對象。與同事長時間的合作和交流，可能會讓你發現對方身上的閃光點，從而產生愛慕之情。在工作中積極表現自己，展現自己的專業能力和責任心，同時註意與同事保持良好的溝通和合作關系，為愛情的發展創造機會。","事业运势":"這一年，事業運勢迎來豐收期。過去幾年的辛勤努力和積累在本年得到了全面的回報。你負責的多個項目都取得了圓滿成功，為公司創造了顯著的經濟效益。你的專業能力和領導才華得到了充分的展現，在公司內部樹立了良好的口碑。公司為了表彰你的突出貢獻，給予你豐厚的物質獎勵和晉升機會。同時，你還受到了行業內其他企業的關註和邀請，為自己的職業發展贏得了更多的選擇空間。在豐收的喜悅中，你不忘繼續努力，為公司的未來發展製定更加宏偉的計劃，比如帶領團隊連續完成多個大型項目，為公司帶來了雙倍的利潤增長。","财富运势":"這一年，財富運勢整體平穩，但在平穩中暗藏機遇。年初，財務狀況穩定，沒有明顯的收入波動或支出壓力。在日常工作中，要留意行業動態和市場變化，積極尋找潛在的財富增長點。例如，發現公司業務拓展需要新的技術支持，而你恰好掌握相關技術，通過主動參與項目，不僅能提升自己在公司的價值，還有可能獲得額外的獎勵或分成。在投資理財方面，選擇一些穩健型的理財產品，如銀行理財產品、優質企業債券等，確保資金在安全的前提下實現一定增值，比如投資年化收益率為 4% 左右的銀行理財產品。","健康运势":"這一年，健康運勢先平穩後出現小波動。在年初到年中的時間段，身體和心理狀態相對穩定，能正常開展各項活動。但進入下半年，可能會因為季節變化、工作壓力增大等因素，出現一些小的健康波動，如秋季容易出現皮膚幹燥、呼吸道不適等問題。針對這些情況，要提前做好預防措施。在季節交替前，提前調整飲食，增加滋陰潤燥的食物攝入，如銀耳、百合等。同時，根據天氣變化及時增減衣物，註意保暖。對於工作壓力，學會合理分配任務，避免過度勞累。當身體出現不適時，及時采取應對措施，如使用保濕護膚品緩解皮膚幹燥，通過多喝水、多休息緩解呼吸道不適，確保健康運勢在波動中能夠迅速恢復平穩。"}}}';
        $demo_json_en_us = '{"errcode":0,"errmsg":"请求成功","notice":"本次测算结果仅供娱乐使用，请勿用于封建迷信和违法用途。","data":{"运势类型":"Aries","今日运势":{"速配星座":"Leo","提防星座":"Scorpio","幸运颜色":"Purple","幸运数字":"46","幸运宝石":"Chalcedony","综合分数":"78","爱情分数":"99","事业分数":"76","心情分数":"75","交际分数":"77","财富分数":"98","健康分数":"79","今明运势":"Today\'s fortune indicates that you will have a period full of warmth and love. In your family, the care and love of your family members will make you feel extremely happy. Among your friends and colleagues, you will also feel a strong sense of friendship. This is a good time to spread love and warmth. You can take the initiative to care about others and help those in need, allowing love and warmth to spread among people.","爱情运势":"For couples deeply in love, today\'s love fortune prompts you to try new challenges. Sign up for a marathon together. In the long race, encourage each other and move forward hand in hand, overcoming difficulties together. When you cross the finish line, you will not only reap the joy of success but also further sublimate your love.","事业运势":"Today\'s career fortune has a promising prospect, with new opportunities and challenges coming one after another. You have obtained the opportunity to participate in an industry seminar, which is an excellent platform to show your professional ability and expand your network. At the seminar, you will communicate and learn from industry elites from different companies and understand the latest industry trends and development trends. At the same time, you also need to share your research results and practical experience at the seminar, which is both a challenge and an opportunity for you to improve yourself. Seize this opportunity, actively participate, and open up a broader space for your career development.","财富运势":"Today\'s wealth fortune fluctuates again and is full of variables. Your financial situation is easily interfered with by the outside world, and you may face some situations of tight funds. Pay special attention to the rationality of your expenses, avoid unnecessary waste, deal with debt issues in a timely manner, and avoid overdue payments. In terms of investment, wait and see for the time being and wait for a more suitable opportunity. As long as you stick to financial discipline and respond actively, you will be able to get through this period of fluctuations.","健康运势":"Today\'s health fortune encourages you to actively participate in social activities. Good interpersonal relationships have a positive impact on physical and mental health. Maintaining close communication and interaction with family and friends, and sharing the joys and sorrows in life, can obtain emotional support and comfort. Participate in social gatherings, interest groups, volunteer activities, etc., meet new friends, expand your social circle, and enrich your life experience. In social interactions, learn to listen to and understand others, improve your interpersonal skills, make yourself feel accepted and cared for, and thus enhance your psychological well-being and sense of belonging, and promote physical and mental health."},"明日运势":{"速配星座":"Virgo","提防星座":"Sagittarius","幸运颜色":"Gray","幸运数字":"47","幸运宝石":"Blue Cat\'s Eye","综合分数":"79","爱情分数":"75","事业分数":"77","心情分数":"76","交际分数":"78","财富分数":"99","健康分数":"80","今明运势":"Today\'s fortune foretells that you will have a period full of opportunities and development. In terms of career development, there may be some new projects or opportunities emerging, which will bring new growth points to your career. In your personal life, there may also be some new changes and developments, such as moving to a new place or changing jobs. Although these changes may bring some challenges, they are also full of opportunities. Face these changes actively and seize the opportunities, and you will be able to realize your life value.","爱情运势":"Today\'s love fortune reminds you that if you are married, there will be a deep spiritual dialogue between you and your partner. Share the pressure at work recently, the troubles in life, and the concerns about the future. In the process of listening to and comforting each other, you will feel each other\'s support and companionship, and the marriage relationship will be more indestructible.","事业运势":"Today\'s career fortune is full of thorns and challenges. The market competition is becoming increasingly fierce, and the company is facing great pressure. The department you are in also needs to make some adjustments and changes. In this process, you may face problems such as adjustments to your work content and changes in your position. But you should maintain a positive attitude, take the initiative to adapt to the changes, and continuously improve your abilities to meet the new work requirements. Through hard work, you can not only gain a firm foothold in the changes but also create more development opportunities for yourself.","财富运势":"Today\'s wealth fortune may fall into a difficult situation and face challenges. Your financial situation is greatly affected by external factors, and you may need to deal with some sudden financial situations. At this time, you need to strictly control your expenses, give priority to the expenses of daily necessities, and resolutely avoid high-risk investments. Through reasonable financial planning and actively seeking ways to increase income and reduce expenditure, gradually improve your financial situation.","健康运势":"Today\'s health fortune emphasizes the balance of the body\'s endocrine system. The endocrine system regulates various physiological functions of the body, and endocrine disorders may lead to a series of health problems. Maintain a regular daily routine, and the stability of the biological clock is helpful for the normal operation of the endocrine system. Have a reasonable diet, avoid excessive dieting or overeating, and maintain the body\'s nutritional balance. Exercise moderately. Exercise can promote metabolism and regulate the endocrine system. At the same time, learn to deal with stress. Long-term mental stress will affect the endocrine system. Relieve stress through methods such as meditation, yoga, and traveling, maintain the harmony and stability of the body and mind, and maintain endocrine balance."},"本周运势":{"速配星座":"Aries","提防星座":"Cancer","幸运颜色":"Dark Blue","幸运数字":"30","幸运宝石":"Ruby","综合分数":"92","爱情分数":"88","事业分数":"90","心情分数":"89","交际分数":"91","财富分数":"87","健康分数":"93","本周运势":"This week\'s fortune is like a gurgling stream, stable and continuously moving forward. At work, the tasks you are responsible for are steadily advancing, and you communicate smoothly with your colleagues, and the team atmosphere is harmonious. In life, you used your spare time to learn new skills, such as painting, which has enriched your spiritual life. The financial situation is stable. Your salary arrives on time, and your daily expenses are reasonable. In terms of health, by insisting on taking a walk after meals, you have promoted digestion, and you are in good physical condition.","爱情运势":"This week\'s love fortune is like the warm sun in spring, warm and comfortable. Single people will get to know an opposite-sex person with a cheerful personality and a bright smile in the outdoor picnic activity organized by friends. You play games and share food together, and are gradually attracted by each other\'s charm in a relaxed and happy atmosphere. After the activity, you start to date frequently and love grows strongly in the warm sunshine. For those who have a partner, you and your significant other can visit both sides\' parents together. In the warm atmosphere of the family, you will be more clear about each other\'s plans for the future, and your relationship will become more stable in the interaction with your family.","事业运势":"This week\'s career fortune develops steadily, like a solid train moving forward continuously on the track. Administrative personnel show excellent organizational skills and communication skills when coordinating various affairs within the company, ensuring the smooth daily operation of the company and receiving unanimous praise from all departments. Sales personnel have made a major breakthrough in customer expansion, successfully winning several major customers for long-term cooperation. Their performance has soared, and they not only received generous commissions but also set an example within the company, inspiring other colleagues to be proactive.","财富运势":"This week\'s wealth fortune is generally optimistic, and there are opportunities for both regular and windfall income. Actively expanding your business at work, you are expected to obtain new cooperation projects, bringing substantial income. In terms of windfall income, participating in low-risk investment projects recommended by friends may bring returns beyond expectations. However, you need to reasonably plan your wealth, avoid excessive profligacy due to the increase in wealth, and balance savings and investment well.","健康运势":"This week\'s health fortune fluctuates greatly, and the stomach may be more sensitive, prone to problems such as indigestion and bloating. You should strictly control your diet, avoid eating raw, cold, greasy, and spicy foods, and mainly eat light and easily digestible foods, such as millet porridge and noodles. At the same time, pay attention to the regularity of your diet, eat regularly and in moderation, and avoid overeating to give the stomach enough time to rest and digest."},"本月运势":{"速配星座":"Sagittarius","提防星座":"Pisces","幸运颜色":"Olive Green","幸运数字":"38","幸运宝石":"Green Phantom","综合分数":"95","爱情分数":"91","事业分数":"93","心情分数":"92","交际分数":"94","财富分数":"90","健康分数":"96","本月运势":"This month, there will be many positive changes in your fortune. In your career and studies, opportunities and challenges coexist. As long as you keep working hard, success will come. In terms of interpersonal relationships, family and social life will be more harmonious, and there will be opportunities to resolve the previous conflicts. In terms of health, a positive lifestyle helps maintain physical balance. There may be some obstacles in the second half of the month, but your firm determination will help you overcome them. In general, this month you need to respond flexibly to various situations and maintain a positive attitude. In this way, you can overcome difficulties and move towards success.","爱情运势":"This month, the love fortune is full of positive changes. If you already have a partner, the relationship will become closer and more stable. You can share wonderful moments together, communicate more smoothly, and the relationship will become deeper. Single people have the opportunity to meet someone special. They may meet their crush in social situations. Be brave enough to pursue your relationship goals, and luck will favor you this month. No matter what your relationship status is, this month is full of warmth and romance. Seize the opportunity and enjoy the beauty of love.","事业运势":"This month, the career fortune is in an explosive period. You are full of vitality at work, with frequent creative ideas, and you are ready to break through yourself. There is a high probability that new projects or business opportunities will emerge, allowing you to fully demonstrate your talents and achieve outstanding results. Don\'t be afraid to try new methods and step into new fields. Move forward boldly, because behind risks often come generous rewards. Cooperate closely with colleagues and partners, and strive together to achieve the goals. With everyone\'s concerted efforts, the team will make a major breakthrough, and your career will reach a new height.","财富运势":"This month, the wealth fortune is uneventful, and there will be no major ups and downs. Your financial situation is relatively stable. There is neither a sudden large sum of income nor a huge and troublesome expenditure. During this time, you might as well sort out your existing financial plan, carefully review every expenditure, and see which areas can be optimized. At the same time, you can also think ahead about future savings and investment directions. Although the current wealth fortune is plain, it is precisely suitable to use this stable period to lay a solid foundation for your future financial goals. Maintain prudence and rationality, take every step steadily, and make preparations for wealth growth.","健康运势":"This month, the health fortune is good, and both your physical and mental states are relatively stable without major health problems. This is a good time to continue your healthy habits and maintain a positive lifestyle. Persist in regular exercise, ensure a balanced diet, and get enough sleep to keep you in a good health state. At the same time, also pay attention to your emotional health and maintain an optimistic attitude. With the good health fortune this month, you can boldly pursue your health goals and enjoy life to the fullest. Take good care of your body and mind to keep this good health state for a long time."},"本年运势":{"速配星座":"Sagittarius","提防星座":"Pisces","幸运颜色":"Rose Red","幸运数字":"56","幸运宝石":"Chalcedony","综合分数":"83","爱情分数":"79","事业分数":"81","心情分数":"80","交际分数":"82","财富分数":"78","健康分数":"84","本年运势":"This year, the main tone of life is plain, and there will not be too many major ups and downs, and the days are relatively stable. But plainness does not mean there are no hidden concerns, especially health problems need to be paid attention to. This year, if you want to maintain good health, regular physical examinations, a balanced diet, and moderate exercise are essential. Although the career and finance are relatively stable, it also reminds us that good health is the foundation for enjoying a stable life.","爱情运势":"This year, the love fortune will experience some minor conflicts in the first half of the year. Couples are prone to friction and misunderstandings, but there is no need to worry too much, because a positive change will come in the second half of the year. In the process of running-in and communication, both parties can understand each other more deeply, solve problems, and thus make the relationship deeper. The second half of the year can be regarded as a turning point in the relationship. Both parties will reconcile, the relationship will be stronger, and the mutual understanding and trust will be further enhanced. During this period, you may experience many wonderful moments together and also jointly plan for the future. For example, plan a long-distance trip and imagine what the future life will be like.","事业运势":"This year, the career fortune is stable and steady. You will encounter some challenges in your daily work, but there are no dramatic changes with big ups and downs. Your career will develop on a stable track. The work may continue to be busy, but there will not be too many unexpected situations. This year, you can continuously accumulate experience and improve your professional skills. There may be a small promotion or salary increase. Although it will not bring earth-shaking changes, it is still a tangible progress. You get along well with your colleagues and superiors, and the cooperation atmosphere is good. There are no major conflicts, and everyone works together to promote the work.","财富运势":"This year, the fortune in wealth will usher in a period of explosive growth, and there is an opportunity to quickly accumulate wealth and assets, but you need to manage it carefully to ensure long-term financial stability. During this period, there may be various opportunities, such as high-return investments, career promotion, or other financial gains. This is a moment full of opportunities, but you should not take risks or squander because of the rapid growth of wealth. You need to formulate a financial plan and diversify your investments to ensure the sustainable growth of wealth. For example, diversify your investments in different fields such as stocks, funds, and bonds.","健康运势":"This year, the health fortune is quite good. You can maintain your current good health condition, with no major problems in both your body and mind, and you won\'t encounter significant health problems or challenges. Under such favorable fortune, you can continue to adhere to a healthy lifestyle. For example, maintain a balanced diet and intake various nutrients; take moderate exercise to enhance physical fitness; ensure sufficient rest to allow your body to recover fully. In addition, mental health should not be overlooked. Maintaining a positive attitude and effectively managing stress can improve your overall well-being and quality of life, making you full of vitality this year."}}}';

        if ($lang == 'zh-cn') {
            $demo_json = $demo_json_zh_cn;
        } elseif ($lang == 'zh-tw') {
            $demo_json = $demo_json_zh_tw;
        } else {
            $demo_json = $demo_json_en_us;
        }

        // 2. 解析为 PHP 数组
        $demo_array_json = json_decode($demo_json, true);

        // 3. 【核心提取】剥离外层的 errcode 状态，只提取 data 节点内容
        $data = $demo_array_json['data'] ?? [];

        // 5. 返回处理好的干净数据给 process_api_data
        return $data;
    }
}