getList($this->request->param()); return $this->renderSuccess(compact('list')); } /** * 米卡下拉列表 * @return array */ public function selectList(){ $param = $this->request->get(); $model = new RiceCardModel; $list = $model->getListAll($param); return $this->renderSuccess(compact('list')); } /** * 米卡-现金卡详情记录 * @param int $id * @return array */ public function cashDetail(int $id) { $model = new RiceCardModel; $detail = $model->getDetail($id); return $this->renderSuccess(compact('detail')); } /** * 添加现金卡 * @return array|string */ public function addCash() { // 新增记录 $model = new RiceCardModel; $post = $this->postForm(); $post['type'] = RiceCardModel::CASH_CARD; if ($model->add($post)) { return $this->renderSuccess('添加成功'); } return $this->renderError($model->getError() ?: '添加失败'); } //添加兑换卡EXCHANGE_CARD public function addExchange(){ $model = new RiceCardModel; $post = $this->postForm(); $post['type'] = RiceCardModel::EXCHANGE_CARD; $post['status'] = 1; if ($model->add($post)) { return $this->renderSuccess('添加成功'); } return $this->renderError($model->getError() ?: '添加失败'); } /** * 添加实体现金卡 * @return array * @author: zjwhust * @Time: 2022/3/9 10:59 */ public function addEntityCash() { // 新增记录 $model = new RiceCardModel; $post = $this->postForm(); $post['type'] = RiceCardModel::CASH_CARD_ENTITY; $post['status'] = 1; if ($model->add($post)) { return $this->renderSuccess('添加成功'); } return $this->renderError($model->getError() ?: '添加失败'); } /** * 编辑兑换卡 * @param int $id * @return mixed */ public function editExchange(int $id) { // 详情 $model = RiceCardModel::detail($id); // 更新记录 if ($model->edit($this->postForm())) { return $this->renderSuccess('更新成功'); } return $this->renderError($model->getError() ?: '更新失败'); } /** * 编辑现金卡 * @param int $id * @return mixed */ public function editCash(int $id) { // 详情 $model = RiceCardModel::detail($id); // 更新记录 if ($model->edit($this->postForm())) { return $this->renderSuccess('更新成功'); } return $this->renderError($model->getError() ?: '更新失败'); } /** * 修改状态(上下架) * @param array $ids id集 * @param bool $state 为true表示上架 * @return array */ public function state(array $ids, bool $state) { $model = new RiceCardModel; if (!$model->setStatus($ids, $state)) { return $this->renderError($model->getError() ?: '操作失败'); } return $this->renderSuccess('操作成功'); } public function simpleList(){ $list = RiceCardModel::getSimpleList(); return $this->renderSuccess(compact('list')); } }