KeywordVideoTaskLog.php 1.2 KB
<?php
/**
 * @remark :
 * @name   :KeywordVideoTask.php
 * @author :lyh
 * @method :post
 * @time   :2024/2/26 9:33
 */

namespace App\Models\Com;

use App\Models\Base;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Cache;

class KeywordVideoTaskLog extends Base
{
    const STATUS_INIT = 0;
    const STATUS_RUNNING = 1;
    const STATUS_FINISH = 2;
    const STATUS_ERROR = 3;

    protected $table = 'gl_keyword_video_task_log';

    /**
     * 获取当月视频生成数量
     * FIXME 混剪视频订阅计划 50000/m
     * @return mixed
     */
    public static function getMonthVideoNum()
    {
        $key = 'video_keyword_number_month';
        $num =  Cache::get($key, function () use ($key) {
            $this_day = date('d');
            if($this_day >= 13) {
                $start_date = Carbon::now()->day(13)->format('Y-m-d 00:00:00');
            } else {
                $start_date = Carbon::now()->subMonth()->day(13)->format('Y-m-d 00:00:00');
            }
            $num = self::where('created_at', '>', $start_date)->count();
            Cache::put($key, $num, 3600);
            return $num;
        });
        return $num;
    }
}