RecycleController.php
1.6 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
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/11/12
* Time: 18:21
*/
namespace api\index\controller;
use cmf\controller\RestBaseController;
use think\Db;
/**
* @title 回收分类
* @description
*/
class RecycleController extends RestBaseController
{
/**
* @title 可回收物类型
* @description
* @author GuoSheng
* @url /index/Recycle/index
* @method GET
*
* @return id:可回收物分类ID
* @return recycle_name:类型名称
* @return thumbnail:图片
* @return price:价格
*
*/
public function index(){
$where['delete_time'] = ['eq',0];
$data = Db::name('recycletype')
->where($where)
->field('id,recycle_name,thumbnail,price')
->order('id desc')
->select()
->toArray();
$this->success('SUCCESS',$data);
}
//不可回收物
public function noRecycle()
{
$where['delete_time'] = ['eq',0];
$recycleModel = new NorecycletypeModel();
$data = $recycleModel->selectData($where)->toArray();
$recycleGoodsModel = new NorecyclegoodsModel();
$tiao = [];
$res = $recycleGoodsModel->selectData($tiao)->toArray();
foreach ($data as &$v){
$v['norecyclegoods'] = [];
foreach ($res as $key=>$val){
if($val['recycletype_id'] == $v['id']){
array_push($v['norecyclegoods'],$val);
}
}
}
$this->assign('data',$data);
return $this->fetch();
}
}