123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?php
- declare (strict_types = 1);
- namespace app\store\controller\card;
- use app\store\controller\Controller;
- use app\store\model\card\RiceCard as RiceCardModel;
- /**
- * 米卡管理控制器
- * Class RiceCard
- * @package app\store\controller\card
- */
- class RiceCard extends Controller
- {
- public function list()
- {
- $model = new RiceCardModel;
- $list = $model->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'));
- }
- }
|