| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?php
- namespace app\admin\controller\platform;
- use app\common\controller\Backend;
- /**
- * 第三方平台列表
- *
- */
- class Vplatform extends Backend
- {
- protected $relationSearch = true;
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- // $this->model = new \app\admin\model\third\Platform;
- $this->model = new \app\common\model\VideoPlatform;
- // $this->model = model('platform');
- $videolist=[];
- $platformlist=[];
- $video=model('videolist')->field('id,name')->select();
- foreach ($video as $k => $v){
- $videolist[$v['id']]=$v['name'];
- }
- $platform=model('platform')->field('id,name')->select();
- foreach ($platform as $k => $v){
- $platformlist[$v['id']]=$v['name'];
- }
- $this->view->assign('videolist', $videolist);
- $this->view->assign('platformlist', $platformlist);
- }
- /**
- * 查看
- */
- public function index()
- {
- //设置过滤方法
- $this->request->filter(['strip_tags']);
- if ($this->request->isAjax()) {
- //如果发送的来源是Selectpage,则转发到Selectpage
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $total = $this->model
- ->where($where)
- ->order($sort, $order)
- ->count();
- $list = $this->model
- ->where($where)
- ->with('platform,videolist')
- ->order($sort, $order)
- ->limit($offset, $limit)
- ->select();
- $result = array("total" => $total, "rows" => $list);
- return json($result);
- }
- return $this->view->fetch();
- }
- /**
- * 编辑
- */
- public function edit($ids = NULL)
- {
- $row = $this->model->get($ids);
- if (!$row){
- $this->error(__('No Results were found'));
- }
- if ($this->request->isPost()) {
- $params = $this->request->post("row/a");
- // if($params['max']<$params['min']){
- // $this->error('最大值不能小于最小值');
- // }
- if ($params['dividend']<0){
- $this->error('分红金额不能小于0');
- }
- }
- $vid = $this->model->where('id', $ids)->value('vid');
- $platform_id = $this->model->where('id', $ids)->value('platform_id');
- $this->view->assign("vid", $vid);
- $this->view->assign("platform_id", $platform_id);
- return parent::edit($ids);
- }
- public function add($vid=0,$platform_id=0)
- {
- if ($this->request->isPost()) {
- $params = $this->request->post("row/a");
- $vid = $this->request->post("vid");
- $platform_id = $this->request->post("platform_id");
- if ($params) {
- $params['vid'] = $vid;
- $params['platform_id'] = $platform_id;
- if ($this->model->where('vid', $vid)->where('platform_id', $platform_id)->find()){
- $this->error('该平台收益已设置');
- }
- // if($params['max']<$params['min']){
- // $this->error('最大值不能小于最小值');
- // }
- if ($params['dividend']<0){
- $this->error('分红金额不能小于0');
- }
- $params['vname'] = model('videolist')->where('id', $params['vid'])->value('name');
- $params['pname'] = model('platform')->where('id', $params['platform_id'])->value('name');
- $result = $this->model->save($params);
- if ($result === false) {
- $this->error($this->model->getError());
- }
- $this->success();
- }else{
- $this->error();
- }
- }
- return $this->view->fetch();
- }
- }
|