25 lines
528 B
PHP
25 lines
528 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace app\common\service;
|
||
|
|
|
||
|
|
use app\admin\model\split\Link;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 分流链接随机打乱配置读取
|
||
|
|
*/
|
||
|
|
class SplitNumberWeighService
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* 链接是否开启随机打乱(新号码按随机插入顺序写入,跳转按 id 顺序轮转)
|
||
|
|
*/
|
||
|
|
public static function isRandomShuffleEnabled(int $linkId): bool
|
||
|
|
{
|
||
|
|
if ($linkId <= 0) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
return (int) Link::where('id', $linkId)->value('random_shuffle') === 1;
|
||
|
|
}
|
||
|
|
}
|