title = '商户对账数据'; $this->day = date('Y-m-d'); $query = $this->_query($this->table); $query->equal('mid')->dateBetween('create_at'); $field = '*,(replace(day, "-", "")+0) as day_num'; $order = 'day_num desc,id desc'; $query->field($field); // 列表排序并显示 if (input('output') === 'json') { $result = $query->order($order)->page(true, false); $this->success('获取数据列表成功', $result); } else { $query->order($order)->page(); } } /** * 表单数据处理 * @param array $data * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ protected function _form_filter(&$data) { $this->merchants = $this->app->db->name('MerchantList')->whereRaw('id in(6,42)')->where(['is_deleted' => 0, 'status' => 1])->select()->toArray(); $this->day = date('Y-m-d'); } /** * 列表数据处理 * @param array $data * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ protected function _index_page_filter(array &$data) { $this->merchants = $this->app->db->name('MerchantList')->whereRaw('id in(6,42)')->where(['is_deleted' => 0, 'status' => 1])->select()->toArray(); foreach ($data as $k => $v) { $data[$k]['merchant'] = MerchantService::instance()->getInfo($v['mid']); } } /** * 添加商户 * @auth true * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function add() { $this->_applyFormToken(); $this->_form($this->table, 'form'); } /** * 编辑商户 * @auth true * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function edit() { $this->_applyFormToken(); $this->_form($this->table, 'form'); } }