ReInquiryDetailLog.php 1.6 KB
<?php
/**
 * Created by PhpStorm.
 * User: zhl
 * Date: 2024/10/08
 * Time: 14:10
 */
namespace App\Models\Inquiry;

use Illuminate\Database\Eloquent\Model;

/**
 * 转发详情日志
 * Class ReInquiryDetailLog
 * @package App\Models\Inquiry
 */
class ReInquiryDetailLog extends Model
{
    /**
     * @var string
     */
    protected $table = 'gl_re_inquiry_detail_log';

    /**
     * 任务状态, 0:初始化,1:待处理,2:处理成功,9:处理失败
     */
    const STATUS_INIT = 0;
    const STATUS_PEND = 1;
    const STATUS_SUCCESS = 2;
    const STATUS_FAIL = 9;

    /**
     * 执行类型, 1:访问, 2:询盘
     */
    const TYPE_VISIT = 1;
    const TYPE_INQUIRY = 2;

    /**
     * 状态映射
     * @return array
     */
    public static function statusMap()
    {
        return [
            self::STATUS_INIT => '初始化',
            self::STATUS_PEND => '待处理',
            self::STATUS_SUCCESS => '处理成功',
            self::STATUS_FAIL => '处理失败',
        ];
    }


    /**
     * 创建转发详情日志
     * @param $detail_id
     * @param $type
     * @param $pre
     * @param $url
     * @param $start_at
     * @return ReInquiryDetailLog
     */
    public static function createInquiryLog($detail_id, $type, $pre, $url, $start_at)
    {
        $self = self::where(compact('detail_id', 'type', 'pre'))->first();
        if ($self)
            return $self;
        $self = new self();
        $self->detail_id = $detail_id;
        $self->type = $type;
        $self->pre = $pre;
        $self->url = $url;
        $self->start_at = $start_at;
        $self->save();
        return $self;
    }
}