0
0

Mate.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\api\controller\screen;
  3. use app\api\controller\screen\Index;
  4. use app\hander\HelpHander;
  5. use think\Db;
  6. use think\Exception;
  7. use think\helper\Time;
  8. class Mate extends Index
  9. {
  10. public function lists(){
  11. $list = Db::name('todo_mate_item')
  12. ->alias('tmi')
  13. ->field('tmi.items_id,mg.title')
  14. ->join('mate_goods mg','mg.id=tmi.items_id')
  15. ->where('mg.org_id',$this->orgId)
  16. ->where('mg.del',0)
  17. ->order('tmi.id desc')
  18. ->group('tmi.items_id')
  19. ->limit(20)
  20. ->select();
  21. foreach ($list as $k=>$v){
  22. $list[$k]['count'] = Db::name('todo_mate_item')
  23. ->where('items_id',$v['items_id'])
  24. ->count();
  25. }
  26. $list = list_sort_by($list,'count','desc');
  27. $data = [];
  28. foreach ($list as $k=>$v){
  29. $top = 'TOP'.($k+1);
  30. $data[] = [$top,$v['title'],$v['count']];
  31. }
  32. HelpHander::success($data);
  33. }
  34. }