123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace app\admin\controller;
- use app\common\controller\Backend;
- class UserGiftRank extends Backend
- {
-
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\GiftUserParty;
- }
-
-
- public function index()
- {
-
- $this->relationSearch = true;
-
- $this->request->filter(['strip_tags', 'trim']);
- if ($this->request->isAjax()) {
-
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $list = model('GiftUserParty')->alias("gift_user_party")
- ->field("gift_user_party.id,sum(gift_user_party.value) as total_price,gift_user_party.user_id,user.avatar as `user.avatar`,user.nickname as `user.nickname`,gift_user_party.createtime")
- ->where($where)
- ->join("hx_user user","user.id = gift_user_party.user_id")
- ->group("gift_user_party.user_to_id")
- ->order('total_price',$order)
- ->paginate($limit);
- $totalNo = $list->total() - $offset;
- foreach ($list as $key => &$row) {
- if ($order == 'asc') {
- $row['no'] = $totalNo;
- $totalNo--;
- } else {
- $offset++;
- $row['no'] = $offset;
- }
- }
- $result = array("total" => $list->total(), "rows" => $list->items());
- return json($result);
- }
- return $this->view->fetch();
- }
- }
|