InquiryRelayDetail.php
2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2024/9/30
* Time: 14:56
*/
namespace App\Models\Inquiry;
use App\Models\Base;
/**
* 询盘转发详情
* Class ReInquiryDetail
* @package App\Models\Inquiry
*/
class InquiryRelayDetail extends Base
{
/**
* @var string
*/
protected $table = 'gl_inquiry_relay_detail';
/**
* 任务状态, 0:待处理,1:处理中,2:待转发,3:转发成功,9:转发失败
*/
const STATUS_INIT = 0;
const STATUS_PEND = 1;
const STATUS_SUCCESS = 2;
const STATUS_SEND = 3;
const STATUS_FAIL = 9;
/**
* 状态映射
* @return array
*/
public static function statusMap()
{
return [
self::STATUS_INIT => '待处理',
self::STATUS_PEND => '处理中',
self::STATUS_SUCCESS => '待转发',
self::STATUS_SEND => '转发成功',
self::STATUS_FAIL => '转发失败',
];
}
/**
* 创建询盘转发详情待处理任务
* @param $form_id
* @param $website
* @param $country
* @param $ip
* @param $name
* @param $email
* @param $phone
* @param $message
* @param $is_v6
* @param $urls
* @param $start_at
* @param int $status
*/
public static function createInquiry($form_id, $website, $country, $ip, $name, $email, $phone, $message, $is_v6, $urls, $start_at, $status = self::STATUS_INIT)
{
$self = self::where(compact('form_id', 'website'))->first();
if(!$self){
$self = new self();
$self->form_id = $form_id;
$self->website = $website;
$self->country = $country;
$self->ip = $ip;
$self->name = $name;
$self->email = $email;
$self->phone = $phone;
$self->message = $message;
$self->is_v6 = $is_v6;
$self->urls = $urls;
$self->start_at = $start_at;
$self->status = $status;
$self->save();
}
}
/**
* 转发日志详情
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function detailLog()
{
return $this->hasMany(InquiryRelayDetailLog::class, 'detail_id', 'id');
}
}