WIN-2308041133\Administrator 7 months ago
parent
commit
bca5f2fe78

+ 103 - 0
application/admin/controller/platform/Vuser.php

@@ -0,0 +1,103 @@
+<?php
+
+namespace app\admin\controller\platform;
+
+use app\common\controller\Backend;
+
+/**
+ * 第三方平台列表
+ *
+ */
+class Vuser extends Backend
+{
+
+    protected $relationSearch = true;
+
+
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\common\model\VideoUser();
+        $videolist=[];
+        $platformlist=[];
+        $video=model('videolist')->field('id,name')->select();
+        foreach ($video as $k => $v){
+            $videolist[$v['id']]=$v['name'];
+        }
+        $this->view->assign('videolist', $videolist);
+    }
+
+    /**
+     * 查看
+     */
+    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('user,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");
+
+        }
+        $vid = $this->model->where('id', $ids)->value('vid');
+        $this->view->assign("vid", $vid);
+        return parent::edit($ids);
+    }
+    public function add($vid=0)
+    {
+        if ($this->request->isPost()) {
+            $params = $this->request->post("row/a");
+            $vid = $this->request->post("vid");
+            $uid = $this->request->post("uid");
+            if ($params) {
+                $params['vid'] = $vid;
+                if ($this->model->where('vid', $vid)->where('uid', $uid)->find()){
+                    $this->error('该短剧已拥有记录');
+                }
+                $params['vname'] = model('videolist')->where('id', $params['vid'])->value('name');
+                $result = $this->model->save($params);
+                if ($result === false) {
+                    $this->error($this->model->getError());
+                }
+                $this->success();
+            }else{
+                $this->error();
+            }
+        }
+        return $this->view->fetch();
+    }
+
+}

+ 1 - 1
application/admin/view/platform/record/index.html

@@ -6,7 +6,7 @@
             <div class="tab-pane fade active in" id="one">
                 <div class="widget-body no-padding">
                     <div id="toolbar" class="toolbar">
-                        {:build_toolbar('refresh,add,edit,del')}
+                        {:build_toolbar('refresh,add,edit')}
                         <div class="dropdown btn-group {:$auth->check('platform/record/multi')?'':'hide'}">
                             <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
                             <ul class="dropdown-menu text-left" role="menu">

+ 34 - 0
application/admin/view/platform/vuser/add.html

@@ -0,0 +1,34 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+    {:token()}
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('短剧')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            {:build_select('vid', $videolist, null, ['class'=>'form-control selectpicker', 'data-rule'=>'required', 'field'=>['value'=>'id', 'text'=>'name']])}
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('平台名称')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            {:build_select('platform_id', $platformlist, null, ['class'=>'form-control selectpicker', 'data-rule'=>'required', 'field'=>['value'=>'id', 'text'=>'name']])}
+        </div>
+    </div>
+    <div class="form-group">
+        <label for="c-max" class="control-label col-xs-12 col-sm-2">{:__('每日收益上限')}:</label>
+        <div class="col-xs-12 col-sm-4">
+            <input id="c-max" data-rule="required" class="form-control" name="row[max]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label for="c-min" class="control-label col-xs-12 col-sm-2">{:__('每日收益下限')}:</label>
+        <div class="col-xs-12 col-sm-4">
+            <input id="c-min" data-rule="required" class="form-control" name="row[min]" type="text">
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 50 - 0
application/admin/view/platform/vuser/edit.html

@@ -0,0 +1,50 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+    {:token()}
+    <!-- 短剧下拉框(只读) -->
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('短剧')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <!-- 禁用下拉框 -->
+            {:build_select('vid', $videolist, $vid, [
+            'class' => 'form-control selectpicker',
+            'disabled' => '',  // 禁止用户操作
+            'field' => ['value'=>'id', 'text'=>'name']
+            ])}
+            <!-- 隐藏字段确保表单提交时传递vid值 -->
+            <input type="hidden" name="vid" value="{$vid}">
+        </div>
+    </div>
+
+    <!-- 平台名称下拉框(只读) -->
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('平台名称')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            {:build_select('platform_id', $platformlist, $platform_id, [
+            'class' => 'form-control selectpicker',
+            'disabled' => '',  // 禁止用户操作
+            'field' => ['value'=>'id', 'text'=>'name']
+            ])}
+            <!-- 隐藏字段确保表单提交时传递platform_id值 -->
+            <input type="hidden" name="platform_id" value="{$platform_id}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label for="c-max" class="control-label col-xs-12 col-sm-2">{:__('每日收益上限')}:</label>
+        <div class="col-xs-12 col-sm-4">
+            <input id="c-max" data-rule="required" class="form-control" name="row[max]" type="text" value="{$row.max|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label for="c-min" class="control-label col-xs-12 col-sm-2">{:__('每日收益下限')}:</label>
+        <div class="col-xs-12 col-sm-4">
+            <input id="c-min" data-rule="required" class="form-control" name="row[min]" type="text"  value="{$row.min|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 28 - 0
application/admin/view/platform/vuser/index.html

@@ -0,0 +1,28 @@
+<div class="panel panel-default panel-intro">
+    {:build_heading()}
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        {:build_toolbar('refresh,add,edit,del')}
+                        <div class="dropdown btn-group {:$auth->check('platform/vuser/multi')?'':'hide'}">
+                            <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
+                            <ul class="dropdown-menu text-left" role="menu">
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
+                            </ul>
+                        </div>
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover" 
+                           data-operate-edit="{:$auth->check('platform/vuser/edit')}"
+                           data-operate-del="{:$auth->check('platform/vuser/del')}"
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 1 - 1
application/api/controller/Pay.php

@@ -771,7 +771,7 @@ class Pay extends Api
                 }
                 $after = $video_user['contribution'] + $contribution;
 //                $res = Db::name('video_user')->where('uid', $user['id'])->where('vid', $order['vid'])->update(['sell' => $sell, 'contribution' => $after, 'grade' => $grade]);
-                $res = Db::name('video_user')->where('uid', $user['id'])->where('vid', $order['vid'])->update(['sell' => $sell, 'contribution' => $after, 'grade' => $grade]);
+                $res = Db::name('video_user')->where('uid', $user['id'])->where('vid', $order['vid'])->update(['contribution' => $after]);
                 $res2 = Db::name('user')->where('id', $user['id'])->update(['grade'=>$grade,'sell' => $sell]);
                 $up = [
                     'vid' => $order['vid'],

+ 0 - 4
application/common/model/VideoUser.php

@@ -25,10 +25,6 @@ class VideoUser extends Model
     {
         return $this->belongsTo('Videolist', 'vid', 'id', [], 'LEFT')->setEagerlyType(0);
     }
-    public function platform()
-    {
-        return $this->belongsTo('Platform', 'platform_id', 'id', [], 'LEFT')->setEagerlyType(0);
-    }
     public function user()
     {
         return $this->belongsTo('User', 'uid', 'id', [], 'LEFT')->setEagerlyType(0);

+ 62 - 0
public/assets/js/backend/platform/vuser.js

@@ -0,0 +1,62 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'platform/vuser/index',
+                    add_url: 'platform/vuser/add',
+                    edit_url: 'platform/vuser/edit',
+                    del_url: 'platform/vuser/del',
+                    multi_url: 'platform/vuser/multi',
+                    table: 'video_platform',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                // sortName: 'user.id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id'),align: 'left',align: 'left', sortable: true},
+                        {field: 'vname', title: __('短剧名称'), align: 'left',operate: 'LIKE'},
+                        {field: 'pname', title: __('平台名称'),align: 'left', operate: 'LIKE'},
+                        {field: 'max', title: __('收益上限(每日)'),align: 'left', operate: '='},
+                        {field: 'min', title: __('收益下限(每日)'),align: 'left', operate: '='},
+                        {field: 'createtime', title: __('添加时间'),align: 'left', formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
+                        {field: 'operate', title: __('Operate'),align: 'left', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+        add: function () {
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            Controller.api.bindevent();
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            },
+            // formatter: {
+            //     paytype: function (value) {
+            //         return value==2 ? '<span class="label label-danger">' + __("已支付") + '</span>': '<span class="label label-default">'+ __('未支付')+ '</span>';
+            //     },
+            //     type: function (value) {
+            //         return value==2 ? '<span class="label label-danger">' + __("已使用") + '</span>': '<span class="label label-default">'+ __('未使用')+ '</span>';
+            //     }
+            // }
+        }
+    };
+    return Controller;
+});