InquiryRelayDetailLog.php 1.6 KB
<?php
/**
 * Created by PhpStorm.
 * User: zhl
 * Date: 2024/10/08
 * Time: 14:10
 */

namespace App\Models\Inquiry;

use App\Models\Base;

/**
 * 转发详情日志
 * Class ReInquiryDetailLog
 * @package App\Models\Inquiry
 */
class InquiryRelayDetailLog extends Base
{
    /**
     * @var string
     */
    protected $table = 'gl_inquiry_relay_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
     */
    public static function createInquiryLog($detail_id, $type, $pre, $url, $start_at)
    {
        $self = self::where(compact('detail_id', 'type', 'pre'))->first();
        if (!$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();
        }
    }
}