OrderController.php
10.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
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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<?php
namespace api\portal\controller;
use think\Controller;
use think\Db;
/**
* @title 后台订单
* @description 后台订单相关接口
*/
class OrderController extends Controller
{
/**
* @title 营销订单
* @description
* @author panhaowen
* @url /portal/Order/marketOrderIndex
* @param name:param type:varchar require:1 desc:搜索参数(order_sn,media,user_login1,status)
* @method POST
*/
public function marketOrderIndex()
{
$param=$this->request->param();
$where=[];
if (!empty($param['order_sn'])){
$where['mo.order_sn']=['like','%'.$param['order_sn'].'%'];
}
if (!empty($param['media'])){
$where['m.media']=['like','%'.$param['media'].'%'];
}
if (!empty($param['user_login1'])){
$where['u1.user_login']=['like','%'.$param['user_login1'].'%'];
}
if (!empty($param['status'])){
$where['mo.status']=$param['status'];
}
$data=Db::name('market_order')
->alias('mo')
->join('user u1','mo.user_id=u1.id')
->join('user u2','mo.admin_id=u2.id')
->join('market_business m','mo.market_business_id=m.id')
->where($where)
->field('mo.*,u1.user_login as user_login1,u2.user_login as user_login2,m.plant,u1.user_type,m.media')
->paginate('10');
$this->success('获取信息成功',$data);
}
/**
* @title 查看营销订单
* @description
* @author panhaowen
* @url /portal/Order/OrderCheck
* @param name:id type:int require:1 desc:订单id
* @method POST
*/
public function OrderCheck()
{
$param=$this->request->param();
$data=Db::name('market_order')->where('id',$param['id'])->find();
$data['more']=cmf_get_file_download_url($data['more']);
$this->success('获取信息成功',$data);
}
/**
* @title 通过营销订单
* @description
* @author panhaowen
* @url /portal/Order/OrderPass
* @param name:id type:int require:1 desc:订单id
* @method POST
*/
public function OrderPass()
{
$param=$this->request->param();
$user=$this->getUser();
$re=Db::name('market_order')->where('id',$param['id'])->update(['status'=>2,'admin_id'=>$user['id']]);
if ($re){
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
/**
* @title 驳回营销订单
* @description
* @author panhaowen
* @url /portal/Order/OrderReturn
* @param name:id type:int require:1 desc:订单id
* @param name:return type:varchar require:1 desc:驳回原因
* @method POST
*/
public function OrderReturn()
{
$param=$this->request->param();
$admin=$this->getUser();
$re=Db::name('market_order')->where('id',$param['id'])->update(['status'=>3,'return'=>$param['return'],'admin_id'=>$admin['id']]);
$order=Db::name('market_order')->where('id',$param['id'])->find();
Db::name('user')->where('id',$order['user_id'])->setInc('money',$order['money']);
$user=Db::name('user')->where('id',$order['user_id'])->find();
Db::name('money_log')->insert(['type'=>4,'create_time'=>time(),'money'=>$order['money'],'remark'=>$param['return'],'now_money'=>$user['money'],'user_id'=>$user['id']]);
if ($re){
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
/**
* @title 驳回营销订单原因
* @description
* @author panhaowen
* @url /portal/Order/OrderReturnDetail
* @param name:id type:int require:1 desc:订单id
* @method POST
*/
public function OrderReturnDetail()
{
$param=$this->request->param();
$data=Db::name('market_order')->where('id',$param['id'])->find();
$this->success('获取数据成功',$data['return']);
}
/**
* @title 发布营销订单
* @description
* @author panhaowen
* @url /portal/Order/OrderShow
* @param name:id type:int require:1 desc:订单id
* @param name:param type:varchar require:1 desc:发布内容(url链接,remark文件)
* @method POST
*/
public function OrderShow()
{
$param=$this->request->param();
$param['status']=4;
$re=Db::name('market_order')->where('id',$param['id'])->update($param);
if ($re){
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
/**
* @title 发布营销订单详情
* @description
* @author panhaowen
* @url /portal/Order/OrderShowDetail
* @param name:id type:int require:1 desc:订单id
* @method POST
*/
public function OrderShowDetail()
{
$param=$this->request->param();
$data=Db::name('market_order')->where('id',$param['id'])->find();
if (empty($data['remark'])){
$this->success('获取数据成功',$data['url']);
}else{
$this->success('获取数据成功',cmf_get_file_download_url($data['remark']));
}
}
/**
* @title 新媒体订单
* @description
* @author panhaowen
* @url /portal/Order/businessOrderIndex
* @param name:param type:varchar require:1 desc:搜索参数(order_sn,name,user_login1,status)
* @method POST
*/
public function businessOrderIndex()
{
$param=$this->request->param();
$where=[];
if (!empty($param['order_sn'])){
$where['bo.order_sn']=['like','%'.$param['order_sn'].'%'];
}
if (!empty($param['name'])){
$where['b.name']=['like','%'.$param['name'].'%'];
}
if (!empty($param['user_login1'])){
$where['u1.user_login']=['like','%'.$param['user_login1'].'%'];
}
if (!empty($param['status'])){
$where['bo.status']=$param['status'];
}
$data=Db::name('business_order')
->alias('bo')
->join('user u1','bo.user_id=u1.id')
->join('user u2','bo.admin_id=u2.id')
->join('business b','bo.business_id=b.id')
->where($where)
->field('bo.*,u1.user_login as user_login1,u2.user_login as user_login2,u1.user_type,b.name')
->paginate('10');
$this->success('获取信息成功',$data);
}
/**
* @title 新媒体订单接收
* @description
* @author panhaowen
* @url /portal/Order/businessOrderPass
* @param name:id type:int require:1 desc:新媒体订单id
* @method POST
*/
public function businessOrderPass()
{
$param=$this->request->param();
$user=$this->getUser();
$re=Db::name('business_order')->where('id',$param['id'])->update(['status'=>2,'admin_id'=>$user['id']]);
if ($re){
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
/**
* @title 新媒体订单驳回
* @description
* @author panhaowen
* @url /portal/Order/businessOrderReturn
* @param name:id type:int require:1 desc:新媒体订单id
* @param name:return type:varchar require:1 desc:驳回原因
* @method POST
*/
public function businessOrderReturn()
{
$param=$this->request->param();
$user=$this->getUser();
$re=Db::name('business_order')->where('id',$param['id'])->update(['status'=>3,'admin_id'=>$user['id'],'return'=>$param['return']]);
$user=Db::name('business_order')->where('id',$param['id'])->find();
Db::name('user')->where('id',$user['id'])->setInc('money',$user['money']);
if ($re){
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
/**
* @title 驳回新媒体订单原因
* @description
* @author panhaowen
* @url /portal/Order/businessOrderReturnDetail
* @param name:id type:int require:1 desc:订单id
* @method POST
*/
public function businessOrderReturnDetail()
{
$param=$this->request->param();
$data=Db::name('business_order')->where('id',$param['id'])->find();
$this->success('获取数据成功',$data['return']);
}
/**
* @title 新媒体订单留言(留言类 )
* @description
* @author panhaowen
* @url /portal/Order/businessOrderLiuyan
* @param name:id type:int require:1 desc:订单id
* @method POST
*/
public function businessOrderLiuyan()
{
$param=$this->request->param();
$data=Db::name('business_order')->where('id',$param['id'])->find();
$this->success('获取数据成功',$data['liuyan']);
}
/**
* @title 完成新媒体订单
* @description
* @author panhaowen
* @url /portal/Order/businessOrderShow
* @param name:id type:int require:1 desc:订单id
* @param name:param type:varchar require:1 desc:发布内容(url链接,remark文件)
* @method POST
*/
public function businessOrderShow()
{
$param=$this->request->param();
$param['status']=4;
$param['end_time']=time();
$re=Db::name('business_order')->where('id',$param['id'])->update($param);
if ($re){
$this->success('操作成功');
}else{
$this->error('操作失败');
}
}
/**
* @title 完成新媒体订单详情
* @description
* @author panhaowen
* @url /portal/Order/businessOrderShowDetail
* @param name:id type:int require:1 desc:订单id
* @method POST
*/
public function businessOrderShowDetail()
{
$param=$this->request->param();
$data=Db::name('business_order')->where('id',$param['id'])->find();
if (empty($data['remark'])){
$this->success('获取数据成功',$data['url']);
}else{
$this->success('获取数据成功',cmf_get_file_download_url($data['remark']));
}
}
}