123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- declare (strict_types=1);
- namespace app\store\controller;
- use app\api\model\PromotionMonitorStatistics as PromotionMonitorStatisticsModel;
- use app\store\model\PromotionMonitor as PromotionMonitorModel;
- /**
- * 推广监控
- *
- * Class PromotionMonitor
- * @package app\store\controller
- */
- class PromotionMonitor extends Controller
- {
- public function list()
- {
- $model = new PromotionMonitorModel;
- $list = $model->getList($this->request->param());
- return $this->renderSuccess(compact('list'));
- }
- /**
- * 刷新数据
- */
- public function refresh()
- {
- $date = date('Y-m-d');
- PromotionMonitorStatisticsModel::addData($date);
- return $this->renderSuccess();
- }
- /**
- * 详情
- * @param int $id
- * @return array
- */
- public function detail(int $id)
- {
- $model = new PromotionMonitorModel;
- $detail = $model->detail($id);
- return $this->renderSuccess(compact('detail'));
- }
- /**
- * 添加
- * @return array|string
- */
- public function add()
- {
- // 新增记录
- $model = new PromotionMonitorModel;
- $post = $this->postForm();
- if ($model->add($post)) {
- return $this->renderSuccess('添加成功');
- }
- return $this->renderError($model->getError() ?: '添加失败');
- }
- /**
- * 编辑
- * @param int $id
- * @return mixed
- */
- public function edit(int $id)
- {
- // 详情
- $model = PromotionMonitorModel::detail($id);
- // 更新记录
- if ($model->edit($this->postForm())) {
- return $this->renderSuccess('更新成功');
- }
- return $this->renderError($model->getError() ?: '更新失败');
- }
- }
|