12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace app\api\controller\screen;
- use app\api\controller\screen\Index;
- use app\hander\HelpHander;
- use think\Db;
- use think\Exception;
- use think\helper\Time;
- class Mate extends Index
- {
- public function lists(){
- $list = Db::name('todo_mate_item')
- ->alias('tmi')
- ->field('tmi.items_id,mg.title')
- ->join('mate_goods mg','mg.id=tmi.items_id')
- ->where('mg.org_id',$this->orgId)
- ->where('mg.del',0)
- ->order('tmi.id desc')
- ->group('tmi.items_id')
- ->limit(20)
- ->select();
- foreach ($list as $k=>$v){
- $list[$k]['count'] = Db::name('todo_mate_item')
- ->where('items_id',$v['items_id'])
- ->count();
- }
- $list = list_sort_by($list,'count','desc');
- $data = [];
- foreach ($list as $k=>$v){
- $top = 'TOP'.($k+1);
- $data[] = [$top,$v['title'],$v['count']];
- }
- HelpHander::success($data);
- }
- }
|