MarketController.php
8.5 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<?php
namespace api\portal\controller;
use think\Controller;
use think\Db;
/**
* @title 后台营销业务
* @description 营销业务相关接口
*/
class MarketController extends Controller
{
/**
* @title 添加分类
* @description
* @author panhaowen
* @url /portal/market/marketAdd
* @param name:type type:int require:1 desc:字段类型
* @param name:selected type:varchar require:1 desc:所选字段id(,隔开)
* @param name:name type:varchar require:1 desc:分类名称
* @method POST
*/
public function marketAdd()
{
$param=$this->request->param();
// $param['selected']=json_encode(explode(',',$param['selected']));
$re=Db::name('market')->insert($param);
if ($re){
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
/**
* @title 分类(列表)
* @description
* @author panhaowen
* @url /portal/market/market
* @method POST
*/
public function market()
{
$data=Db::name('market')->select();
$this->success('获取信息成功',$data);
}
/**
* @title 编辑分类
* @description
* @author panhaowen
* @url /portal/market/marketEdit
* @param name:id type:int require:1 desc:分类id
* @method POST
*/
public function marketEdit()
{
$param=$this->request->param();
$data=Db::name('market')->where('id',$param['id'])->find();
$data['selected']=Db::name('classify')->where('id','in',explode(',', $data['selected']))->select();
$type=Db::name('type')->where('id',$data['type'])->find()['classify'];
$data['classify']=Db::name('classify')->where('id','in',explode(',', $type))->select();
$this->success('获取信息成功',$data);
}
/**
* @title 编辑分类提交
* @description
* @author panhaowen
* @url /portal/market/marketEditPost
* @param name:id type:int require:1 desc:分类id
* @param name:selected type:varchar require:1 desc:所选字段id(,隔开)
* @param name:name type:varchar require:1 desc:分类名称
* @method POST
*/
public function marketEditPost()
{
$param=$this->request->param();
$re=Db::name('market')->where('id',$param['id'])->update($param);
if ($re){
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
/**
* @title 删除分类
* @description
* @author panhaowen
* @url /portal/market/marketDelete
* @param name:id type:int require:1 desc:分类id
* @method POST
*/
public function marketDelete()
{
$param=$this->request->param();
$re=Db::name('market')->where('id',$param['id'])->delete();
if ($re){
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
/**
* @title 筛选条件(添加)
* @description
* @author panhaowen
* @url /portal/market/classify
* @method POST
* @param name:type type:int require:1 desc:字段类型
*/
public function classify()
{
$param=$this->request->param();
$classify=Db::name('type')->where('id',$param['type'])->find()['classify'];
$classify=explode(',',$classify);
$data=Db::name('classify')->where('id','in',$classify)->select();
$this->success('获取信息成功',$data);
}
/**
* @title 筛选条件(列表)
* @description
* @author panhaowen
* @url /portal/market/classifyIndex
* @method POST
* @param name:id type:int require:1 desc:分类id
*/
public function classifyIndex()
{
$param=$this->request->param();
$classify=explode(',',Db::name('market')->where('id',$param['id'])->find()['selected']);
$data=Db::name('classify')->where('id','in',$classify)->select()->toArray();
$arr=[];
// $arr['id']=$classify;
foreach ($data as $k=>$v){
$arr[$v['name']]=Db::name('classify_value')->where(['market_id'=>$param['id'],'classify_id'=>$v['id']])->select();
}
$this->success('获取信息成功',$arr);
}
/**
* @title 添加筛选字段
* @description
* @author panhaowen
* @url /portal/market/classifyAdd
* @method POST
* @param name:id type:int require:1 desc:筛选字段id
* @param name:category_id type:int require:1 desc:分类id
* @param name:name type:varchar require:1 desc:筛选名称
*/
public function classifyAdd()
{
$param=$this->request->param();
$re=Db::name('classify_value')->insert(['market_id'=>$param['category_id'],'create_time'=>time(),'classify_id'=>$param['id'],'value'=>$param['name']]);
if ($re){
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
/**
* @title 删除筛选字段
* @description
* @author panhaowen
* @url /portal/market/classifyDelete
* @param name:id type:int require:1 desc:筛选字段值id
* @method POST
*/
public function classifyDelete()
{
$param=$this->request->param();
$re=Db::name('classify_value')->where('id',$param['id'])->delete();
if ($re){
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
/**
* @title 添加营销
* @description
* @author panhaowen
* @url /portal/market/marketBusinessAdd
* @method POST
* @param name:market_id type:int require:1 desc:上级分类id
*/
public function marketBusinessAdd()
{
$param=$this->request->param();
$type=Db::name('market')->where('id',$param['market_id'])->find()['type'];
$classify=Db::name('type')->where('id',$type)->find()['classify'];
$data=Db::name('classify')->where('id','in',explode(',',$classify))->select();
$this->success('获取信息成功',$data);
}
/**
* @title 添加营销提交
* @description 添加营销提交
* @author panhaowen
* @url /portal/market/marketBusinessAddPost
* @method POST
* @param name:market_id type:int require:1 desc:上级分类id
*/
public function marketBusinessAddPost()
{
$param=$this->request->param();
$param['create_time']=time();
$re=Db::name('market_business')->insert($param);
if ($re){
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
/**
* @title 编辑营销
* @description
* @author panhaowen
* @url /portal/market/marketBusinessEdit
* @method POST
* @param name:id type:int require:1 desc:媒体id
*/
public function marketBusinessEdit()
{
$param=$this->request->param();
$data=Db::name('market_business')->where('id',$param['id'])->find();
$this->success('获取信息成功',$data);
}
/**
* @title 编辑营销提交
* @description
* @author panhaowen
* @url /portal/market/marketBusinessEditPost
* @method POST
* @param name:id type:int require:1 desc:媒体id
*/
public function marketBusinessEditPost()
{
$param=$this->request->param();
$re=Db::name('market_business')->where('id',$param['id'])->update($param);
if ($re){
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
/**
* @title 删除营销
* @description
* @author panhaowen
* @url /portal/market/marketBusinessDelete
* @param name:id type:int require:1 desc:媒体id
* @method POST
*/
public function marketBusinessDelete()
{
$param=$this->request->param();
$re=Db::name('market_business')->where('id',$param['id'])->delete();
if ($re){
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
/**
* @title 营销(列表)
* @description
* @author panhaowen
* @url /portal/market/marketBusiness
* @param name:market_id type:int require:1 desc:分类id
* @method POST
*/
public function marketBusiness()
{
$param=$this->request->param();
$data=Db::name('market_business')->where('market_id',$param['market_id'])->paginate(10);
$this->success('获取信息成功',$data);
}
}