<?php
declare(strict_types=1);
namespace app\common;
final class OwnedWeightBoundary
{
    public static function payload(array $data):void{
        $map=json_decode((string)file_get_contents((string)getenv('CATEGORY_RUNTIME').'/private-owned-map.json'),true);
        if(array_keys($data)!==['storeId','staffId','date']||(int)$data['storeId']!==2147001021
            ||(int)$data['staffId']!==(int)($map['staff_id']??0)||(int)$data['staffId']<=0||$data['date']!==date('Y-m-d'))throw new \RuntimeException('Nonowned weight publication');
    }
}
class Serve
{
    public const CAPTURE_MODE='OWN_NUTRITION_TARGET_STAFF_POWER_ONLY_V1';
    public static function push(string $action,array $data=[],int $delay=0):bool{throw new \RuntimeException('Unexpected ordinary queue publisher');}
    public static function pushJump(string $action,array $data=[]):bool{
        if($action!=='staffPower')throw new \RuntimeException('Unexpected weight action');OwnedWeightBoundary::payload($data);
        file_put_contents((string)getenv('CATEGORY_RUNTIME').'/publish-captures.jsonl',json_encode(['action'=>$action,'data'=>$data])."\n",FILE_APPEND|LOCK_EX);return true;
    }
}
class QwRobot
{
    public const CAPTURE_MODE='OWN_NUTRITION_TARGET_JOB_NOTIFY_ONLY_V1';
    public static function pushMsgFormat($data,$title='',$type='msg',$store=0){
        if(!is_array($data)||array_keys($data)!==['staffId','date']||$title!=='推荐能量任务队列消费'||$type!=='msg')throw new \RuntimeException('Unexpected weight robot');
        OwnedWeightBoundary::payload(['storeId'=>$store,'staffId'=>$data['staffId'],'date'=>$data['date']]);
        file_put_contents((string)getenv('CATEGORY_RUNTIME').'/robot-captures.jsonl',json_encode(['store_id'=>(int)$store,'staff_id'=>(int)$data['staffId'],'date'=>$data['date'],'title'=>$title,'type'=>$type])."\n",FILE_APPEND|LOCK_EX);return true;
    }
}
class UserApi {public function run($apiType,$params=[]):array{throw new \RuntimeException('Unexpected weight external user sync');}}
