<?php

namespace App\Services\Github;
use App\Services\TomTool\Http;
use App\Models\Blade as ModelBlade;

function xx($x)
{
    return $x;
};

class Blade extends Github{
    
    private function echo($zz){
        return $zz;
    }
    
    private function eval($sEval)
    {
        return eval("return ".$sEval);
    }
    
    private function date($date)
    {
        return date($date);
    }
    
    private function goodToStr($sGood)
    {
        $aGood = json_decode($sGood, true);
        
        $sGoodStr = "";
        $i = 0;
        foreach ($aGood as $row) {
            if ($i !== 0) {
                $sGoodStr .= "

";
            }
            $sGoodStr .= $row;
            $i++;
        }
        
        return $sGoodStr;
    }
    
    public function get($aArticle)
    {

        //// dog自带系列
        $dog_mod = $aArticle["mod"];
        $dog_mod_type = $aArticle["mod_type"];
        $dog_sale_code = $aArticle["sale_code"];
        $dog_sale_rate = $aArticle["sale_rate"];
        $dog_ship_code = $aArticle["ship_code"];
        $dog_fn_www = $aArticle["fn_www"];
        
        //// 组合生成系列
        $ex_feed_v2ray_url = "https://".$aArticle["fn_www"]."/feed/v2ray-".date("Ymd").".txt";
        $ex_feed_clash_url = "https://".$aArticle["fn_www"]."/clash/v2ray-".date("Ymd").".yaml";

        //// ship系列
        $oHttp = new Http();
        $oHttp->sMethod = "get";
        $oHttp->bIsJson = true;
        $sDateNow = date("Y-m-d");
        $sMasterUrl = "https://".env("www_master")."/api/ship/get/".$aArticle["ship_code"]."/github/".$aArticle["user_name"]."-".$aArticle["project_name"];
        $sShip = $oHttp->send($sMasterUrl);
        $aShip = json_decode($sShip, true);
        
        $ship_name = $aShip["name"];
        $ship_www = $aShip["www"];
        $ship_good = $this->goodToStr($aShip["good"]);
        $ship_have_huodong = $aShip["have_huodong"];
        $ship_huodong_str = $aShip["huodong"]["str"] ?? false;
        //// ship系列end
        
        //// rand 系列
        //// good pool系列
        // 随机good，预留
        $oHttp = new Http();
        $oHttp->sMethod = "get";
        $sMasterUrl = "https://".env("www_master")."/api/good/rand/".$dog_ship_code;
        $oHttp->bIsJson = true;
        $sGood = $oHttp->send($sMasterUrl);
        $aGood = json_decode($sGood, true);
        
        $rand_good = $this->goodToStr($aGood["good"]);
        
        
        
        tomd($rand_good, 1);
        
        
        
//        $ship_www =
        
//        $aArticle["ex_ship"] = $aShip;
//        $aArticle["ex_ship_name"] = $aShip["name"];
//        $aArticle["ex_ship_www"] = $aShip["www"];
//        
//        
//        
//        
//        
//        
//        
//        $aArticle["ex_feed_v2ray_url"] = "https://".$aArticle["fn_www"]."/feed/v2ray-".date("Ymd").".txt";
//        $aArticle["ex_feed_clash_url"] = "https://".$aArticle["fn_www"]."/clash/v2ray-".date("Ymd").".yaml";
//
//        $aArticle["ex_ship"] = $aShip;
//        $aArticle["ex_ship_name"] = $aShip["name"];
//        $aArticle["ex_ship_www"] = $aShip["www"];
        
        
        
//        tomd($aArticle);
        
//        $oBlade = ModelBlade::all();
        
//        tomd($oBlade, 1);
        
        
        
        
//        echo eval("");
//        echo 123;
//        exit;
        $zz = "???";
        
        $s = "zabc{$this->date('Y-m-d')}defg";
        
        return $s;
        
        
        
        
        
//        $r = $this->GetShip($aArticle);
        
        tomd($r, 1);
        echo "balzzzzde";
        exit;
    }
    
}
