ServiceLogic.php
3.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
namespace App\Http\Logic\Aside\Service;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Service;
use Illuminate\Support\Facades\DB;
class ServiceLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new Service();
$this->param = $this->requestAll;
}
/**
* @remark :企业服务列表
* @name :serviceLists
* @author :lyh
* @method :post
* @time :2023/6/25 14:32
*/
public function serviceLists($map,$page,$row,$order = 'id',$filed = ['*']){
$lists = $this->model->lists($map,$page,$row,$order,$filed);
foreach ($lists as $k => $v){
if(!empty($v['images'])){
$arr = explode(',',$v['images']);
foreach ($arr as $k1 => $v1){
$v['images_link'][$k1] = url('a/image/'.$v1);
}
}
if(!empty($v['android'])){
$v['android_link'] = url('a/image/'.$v['android']);
}
if(!empty($v['ios'])){
$v['ios_link'] = url('a/image/'.$v['android']);
}
$lists[$k] = $v;
}
return $this->success($lists);
}
/**
* @remark :获取详情
* @name :serviceRead
* @author :lyh
* @method :post
* @time :2023/6/25 13:44
*/
public function serviceRead(){
$info = $this->model->read(['id'=>$this->param['id'],'status'=>0]);
var_dump($info);
die();
if(!empty($info['images'])){
$arr = explode(',',$info['images']);
foreach ($arr as $k => $v){
$info['images_link'][$k] = url('a/image/'.$v);
}
}
if(!empty($info['android'])){
$info['android_link'] = url('a/image/'.$v['android']);
}
if(!empty($info['ios'])){
$info['ios_link'] = url('a/image/'.$v['android']);
}
return $this->success($info);
}
/**
* @remark :新增或编辑
* @name :serviceSave
* @author :lyh
* @method :post
* @time :2023/6/25 13:45
*/
public function serviceSave(){
$info = $this->model->read(['id'=>$this->param['id']]);
if($info === false){
$rs = $this->model->add($this->param);
}else{
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
}
if($rs === false){
$this->fail('error');
}
return $this->success();
}
/**
* @remark :指定状态始终为一条数据
* @name :serviceStatus
* @author :lyh
* @method :post
* @time :2023/6/25 14:09
*/
public function serviceStatus(){
DB::beginTransaction();
try {
$this->model->edit(['status'=>1],['id'=>['!=',$this->param['id']]]);
$this->model->edit(['status'=>0],['id'=>$this->param['id']]);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('error');
}
return $this->success();
}
/**
* @remark :删除企业服务信息
* @name :serviceDel
* @author :lyh
* @method :post
* @time :2023/6/25 14:22
*/
public function serviceDel(){
$rs = $this->model->del(['id'=>['in',$this->param['id']]]);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
}