WebSettingFromLogic.php
2.4 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
<?php
namespace App\Http\Logic\Bside\Setting;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\WebSetting\WebSettingForm;
use App\Models\WebSetting\WebSettingFormBack;
class WebSettingFromLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new WebSettingForm();
$this->param = $this->requestAll;
}
/**
* @name :(获取表单设置详情)setting_from_info
* @author :lyh
* @method :post
* @time :2023/5/4 13:43
*/
public function setting_from_info(){
$info = $this->model->list(['project_id'=>$this->user['project_id']],'created_at');
if($info === false){
$this->fail('当前数据不存在,或者已被删除');
}
return $this->success($info);
}
/**
* @name :(表单设置)setting_from_save
* @param :(is_required是否必填,name名称)
* @author :lyh
* @method :post
* @time :2023/5/4 10:39
*/
public function setting_from_save(){
try {
//删除以前的数据
$this->model->del(['project_id'=>$this->user['project_id']]);
foreach ($this->param['data'] as $k => $v){
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$v['project_id'] = $this->user['project_id'];
$this->param['data'][$k] = $v;
}
//新增
$this->model->insert($this->param['data']);
}catch (\Exception $e){
$this->fail('error');
}
return $this->success();
}
/**
* 保存询盘请求返回信息
* @param $message
* @param $url
* @return WebSettingFormBack|mixed
*/
public function fromBackMsgSet($message, $url)
{
$project_id = $this->user['project_id'];
$info = WebSettingFormBack::saveBack($project_id, $message, $url);
return $info;
}
/**
* 获取询盘请求返回信息
* @return mixed
*/
public function fromBackMsgGet()
{
$project_id = $this->user['project_id'];
$info = WebSettingFormBack::getBack($project_id);
$result = [
'message' => $info->message ?? '',
'url' => $info->url ?? '',
'other' => $info->other ?? ''
];
return $result;
}
}