|
|
@@ -0,0 +1,78 @@
|
|
|
+<?php
|
|
|
+namespace app\admin\controller\platform;
|
|
|
+
|
|
|
+use app\common\controller\Backend;
|
|
|
+use app\common\model\Videolist;
|
|
|
+use app\common\model\Platform;
|
|
|
+
|
|
|
+class Income extends Backend
|
|
|
+{
|
|
|
+ protected $model = null;
|
|
|
+
|
|
|
+ public function _initialize()
|
|
|
+ {
|
|
|
+ parent::_initialize();
|
|
|
+ $this->model = new \app\common\model\Income;
|
|
|
+ // 获取短剧和平台数据(用于下拉框)
|
|
|
+ $videolist = Videolist::column('id,title');
|
|
|
+ $platforms = Platform::column('id,name');
|
|
|
+ $this->assign('videolist', $videolist);
|
|
|
+ $this->assign('platforms', $platforms);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 列表页
|
|
|
+ public function index()
|
|
|
+ {
|
|
|
+ $this->request->filter(['strip_tags']);
|
|
|
+ if ($this->request->isAjax()) {
|
|
|
+ list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
|
|
+ $total = $this->model
|
|
|
+ ->with(['videolist', 'platform'])
|
|
|
+ ->where($where)
|
|
|
+ ->order($sort, $order)
|
|
|
+ ->count();
|
|
|
+ $list = $this->model
|
|
|
+ ->with(['videolist', 'platform'])
|
|
|
+ ->where($where)
|
|
|
+ ->order($sort, $order)
|
|
|
+ ->limit($offset, $limit)
|
|
|
+ ->select();
|
|
|
+ $result = ["total" => $total, "rows" => $list];
|
|
|
+ return json($result);
|
|
|
+ }
|
|
|
+ return $this->view->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加
|
|
|
+ public function add()
|
|
|
+ {
|
|
|
+ if ($this->request->isPost()) {
|
|
|
+ $params = $this->request->post("row/a");
|
|
|
+ if ($params) {
|
|
|
+ $result = $this->model->save($params);
|
|
|
+ if ($result) $this->success();
|
|
|
+ $this->error(__('操作失败'));
|
|
|
+ }
|
|
|
+ $this->error(__('参数错误'));
|
|
|
+ }
|
|
|
+ return $this->view->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 编辑
|
|
|
+ public function edit($ids = null)
|
|
|
+ {
|
|
|
+ $row = $this->model->get($ids);
|
|
|
+ if (!$row) $this->error(__('记录不存在'));
|
|
|
+ if ($this->request->isPost()) {
|
|
|
+ $params = $this->request->post("row/a");
|
|
|
+ if ($params) {
|
|
|
+ $result = $row->save($params);
|
|
|
+ if ($result) $this->success();
|
|
|
+ $this->error(__('操作失败'));
|
|
|
+ }
|
|
|
+ $this->error(__('参数错误'));
|
|
|
+ }
|
|
|
+ $this->assign('row', $row);
|
|
|
+ return $this->view->fetch();
|
|
|
+ }
|
|
|
+}
|