model = new \app\admin\model\Purchasemonthexport; } public function index() { $this->relationSearch = false; $this->request->filter(['strip_tags', 'trim']); if ($this->request->isAjax()) { list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $list = $this->model ->where($where) ->order($sort ?: 'id', $order ?: 'desc') ->paginate($limit); foreach ($list as $row) { $ct = (int)($row['createtime'] ?? 0); $row->createtime_text = $ct > 0 ? date('Y-m-d H:i:s', $ct) : ''; $row->total_amount_text = number_format((float)($row['total_amount'] ?? 0), 2, '.', ','); } return json(['total' => $list->total(), 'rows' => $list->items()]); } return $this->view->fetch(); } }