49 lines
1.3 KiB
PHP
Raw Normal View History

<?php
// +----------------------------------------------------------------------
// | 作者:修缘 联系QQ278896498 QQ群1054861244
// | 声明:未经作者许可,禁止倒卖等商业运营,违者必究
// | 另接php业务网站制作、代理后台、gm后台、支付对接等
// +----------------------------------------------------------------------
// | 创建时间: 2022/1/6 10:53
// +----------------------------------------------------------------------
namespace app\common\model;
use think\facade\Config;
use think\model\concern\SoftDelete;
class CdkCode extends Model
{
public $softDelete = false;
protected $autoWriteTimestamp = true;
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $insert = ['status' => 0];
protected $searchField = ['cdk_code', 'item_name'];
protected $whereField = ['type', 'status'];
protected $timeField = ['create_time', 'update_time'];
public static function get_production_cdk(int $cdk_num)
{
$arr = [];
while (count($arr) < $cdk_num) {
$str = get_rand_str(Config::get('game.cdk.length')); //产生随机数
if (!in_array($str, $arr)) { //判断$arr中是否有$a,有则返回true,否则false
$arr[] = $str;
}
}
return $arr;
}
}