ReInquiryTask.php
2.6 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
94
95
96
97
98
99
100
101
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2024/9/30
* Time: 14:12
*/
namespace App\Models\Inquiry;
use App\Helper\Arr;
use App\Models\Base;
use Illuminate\Database\Eloquent\Model;
/**
* 广告转询盘任务
* Class ReInquiryTask
* @package App\Models\Inquiry
*/
class ReInquiryTask extends Base
{
/**
* @var string
*/
protected $table = 'gl_re_inquiry_task';
/**
* 任务状态, 1:开启(默认), 0:关闭
*/
const STATUS_OPEN = 1;
const STATUS_CLOSE = 0;
/**
* 创建询盘任务
* @param $id
* @param $title
* @param $industry
* @param $ad_id
* @param $ad_url
* @param $ad_img
* @param $num
* @param int $status
* @return ReInquiryTask
*/
public static function createTask($id, $title, $industry, $ad_id, $ad_url, $ad_img, $num, $status, $is_replace_text, $ai_param, $is_show_fb_source, $second_push_rate)
{
$self = self::where(['id' => $id])->first();
if (empty($self))
$self = new self();
$self->title = $title;
$self->industry = $industry;
$self->ad_id = $ad_id;
$self->ad_url = $ad_url;
$self->ad_img = $ad_img;
$self->num = $num;
$self->status = $status;
$self->is_replace_text = $is_replace_text;
$self->ai_param = $ai_param;
$self->is_show_fb_source = $is_show_fb_source;
$self->second_push_rate = $second_push_rate;
$self->save();
return $self;
}
/**
* @param $value
* @return mixed
*/
public function getTargetAttribute($value)
{
$value = $value ? json_decode($value, true) : [];
foreach ($value as &$item){
$item['url'] = $item['url'] ?? '';
$item['agent'] = $item['agent'] ?? '';
$item['agent_group'] = $item['agent_group'] ?? '';
$item['is_require'] = $item['is_require'] ?? 0;
$item['price'] = $item['price'] ?? 0;
$item['frequency'] = $item['frequency'] ?? '3'; //默认频率3天一次
}
return $value;
}
public function getShopSiteAttribute($value)
{
return $value ? json_decode($value, true) : [];
}
public function getFobProAttribute($value)
{
return $value ? json_decode($value, true) : [];
}
public function setAiParamAttribute($value)
{
$this->attributes['ai_param'] = Arr::a2s($value);
}
public function getAiParamAttribute($value)
{
return Arr::s2a($value) ?: ReInquiryConfig::getDefaultConfigCache(ReInquiryConfig::TYPE_AI_PARAM);
}
}