WebSettingServiceLogic.php
2.0 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
<?php
namespace App\Http\Logic\Bside\Setting;
use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Domain\DomainInfo;
use App\Models\File\Image;
use App\Models\Project\Project;
use App\Models\WebSetting\WebSettingService;
use Illuminate\Support\Facades\DB;
class WebSettingServiceLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new WebSettingService();
$this->param = $this->requestAll;
}
/**
* @name : (客服设置列表)setting_service_list
* @author :lyh
* @method :post
* @time :2023/5/4 11:23
*/
public function setting_service_list(){
$list = $this->model->list(['project_id'=>$this->user['project_id']],'created_at');
return $this->success($list);
}
/**
* @name : (客服设置)setting_service_save
* @author :lyh
* @method :post
* @time :2023/5/4 11:10
*/
public function setting_service_save(){
DB::connection('custom_mysql')->beginTransaction();
try {
$this->param['data'] = Common::uniqueMultiArray($this->param['data']);
//删除以前的数据
$this->model->del(['project_id'=>$this->user['project_id']]);
$data = [];
foreach ($this->param['data'] as $k => $v){
if(isset($v['values']) && !empty($v['values'])){
$v['project_id'] = $this->user['project_id'];
$v['created_at'] = date('Y-m-d H:i:s');
$v['updated_at'] = date('Y-m-d H:i:s');
$data[] = $v;
}
}
if(!empty($data)){
$this->model->insert($data);
}
DB::connection('custom_mysql')->commit();
}catch (\Exception $e){
DB::connection('custom_mysql')->rollBack();
$this->fail('系统错误,请联系管理员');
}
return $this->success();
}
}