jingcai-php/app/Model/Zq/ZqPredict.php

61 lines
1.4 KiB
PHP
Executable File

<?php
/**
* @createtime 2023/4/26
* @author wild
* @copyright PhpStorm
*/
namespace App\Model\Zq;
use App\Model\BaseModel;
use Illuminate\Support\Arr;
class ZqPredict extends BaseModel
{
protected $casts = [
'spf_pr' => 'array',
'rq_pr' => 'array',
'dx_pr' => 'array',
];
/**
* 格式化成wap页面需要的数据格式
* @return \string[][]
*/
public function formatViewData() {
$result = [
[
'result' => '',
'spf' => '胜平负',
'rq' => '让球胜平负',
],
];
$result[] = [
'result' => '胜',
'spf' => $this->getPercent(Arr::get($this->spf_pr, 'win')),
'rq' => $this->getPercent(Arr::get($this->rq_pr, 'win')),
];
$result[] = [
'result' => '平',
'spf' => $this->getPercent(Arr::get($this->spf_pr, 'draw')),
'rq' => $this->getPercent(Arr::get($this->rq_pr, 'draw')),
];
$result[] = [
'result' => '负',
'spf' => $this->getPercent(Arr::get($this->spf_pr, 'loss')),
'rq' => $this->getPercent(Arr::get($this->rq_pr, 'loss')),
];
return $result;
}
private function getPercent($odd)
{
if (!$odd) {
return '-';
}
return sprintf('%.02f', $odd * 100) . '%';
}
}