12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace app\admin\controller;
- use app\common\controller\Backend;
- class UserPayRank extends Backend
- {
-
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\UserJewelLog();
- }
-
-
- 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();
- $whereAppend["user_jewel_log.type"] = ["in",[0,2,3,5,6,13]];
- $list = model('UserJewelLog')->alias("user_jewel_log")
- ->field("user_jewel_log.id,sum(user_jewel_log.value) as total_price,user_jewel_log.user_id,user.avatar as `user.avatar`,user.nickname as `user.nickname`,user_jewel_log.createtime")
- ->where($where)
- ->where($whereAppend)
- ->join("hx_user user","user.id = user_jewel_log.user_id")
- ->group("user_jewel_log.user_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();
- }
- }
|