Browse Source

用户打招呼

lizhen_gitee 8 months ago
parent
commit
7eaabd12b5

+ 75 - 0
application/admin/controller/Usergreetcontent.php

@@ -0,0 +1,75 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\common\controller\Backend;
+
+/**
+ * 用户打招呼设置
+ *
+ * @icon fa fa-circle-o
+ */
+class Usergreetcontent extends Backend
+{
+    
+    /**
+     * Usergreetcontent模型对象
+     * @var \app\admin\model\Usergreetcontent
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\Usergreetcontent;
+        $this->view->assign("typeList", $this->model->getTypeList());
+        $this->view->assign("isDefaultList", $this->model->getIsDefaultList());
+    }
+
+    public function import()
+    {
+        parent::import();
+    }
+
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+    
+
+    /**
+     * 查看
+     */
+    public function index()
+    {
+        //当前是否为关联查询
+        $this->relationSearch = true;
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax()) {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField')) {
+                return $this->selectpage();
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+
+            $list = $this->model
+                    ->with(['user'])
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->paginate($limit);
+
+            foreach ($list as $row) {
+                
+                $row->getRelation('user')->visible(['username','nickname']);
+            }
+
+            $result = array("total" => $list->total(), "rows" => $list->items());
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+
+}

+ 19 - 0
application/admin/lang/zh-cn/usergreetcontent.php

@@ -0,0 +1,19 @@
+<?php
+
+return [
+    'Id'            => 'ID',
+    'User_id'       => '用户ID',
+    'Type'          => '类型',
+    'Type 0'        => '文字',
+    'Type 1'        => '语音',
+    'Type 2'        => '相册',
+    'Title'         => '标题',
+    'Content'       => '内容',
+    'Duration'      => '时长',
+    'Is_default'    => '是否默认使用',
+    'Is_default 0'  => '否',
+    'Is_default 1'  => '是',
+    'Createtime'    => '创建时间',
+    'User.username' => '用户名',
+    'User.nickname' => '昵称'
+];

+ 67 - 0
application/admin/model/Usergreetcontent.php

@@ -0,0 +1,67 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class Usergreetcontent extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'user_greet_content';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+        'type_text',
+        'is_default_text'
+    ];
+    
+
+    
+    public function getTypeList()
+    {
+        return ['0' => __('Type 0'), '1' => __('Type 1'), '2' => __('Type 2')];
+    }
+
+    public function getIsDefaultList()
+    {
+        return ['0' => __('Is_default 0'), '1' => __('Is_default 1')];
+    }
+
+
+    public function getTypeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
+        $list = $this->getTypeList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+
+    public function getIsDefaultTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['is_default']) ? $data['is_default'] : '');
+        $list = $this->getIsDefaultList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+
+
+
+    public function user()
+    {
+        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
+}

+ 27 - 0
application/admin/validate/Usergreetcontent.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace app\admin\validate;
+
+use think\Validate;
+
+class Usergreetcontent extends Validate
+{
+    /**
+     * 验证规则
+     */
+    protected $rule = [
+    ];
+    /**
+     * 提示消息
+     */
+    protected $message = [
+    ];
+    /**
+     * 验证场景
+     */
+    protected $scene = [
+        'add'  => [],
+        'edit' => [],
+    ];
+    
+}

+ 58 - 0
application/admin/view/usergreetcontent/add.html

@@ -0,0 +1,58 @@
+<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
+                {foreach name="typeList" item="vo"}
+                    <option value="{$key}" {in name="key" value="0"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-content" data-rule="required" class="form-control" name="row[content]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Duration')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-duration" data-rule="required" class="form-control" name="row[duration]" type="number" value="0">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Is_default')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-is_default" data-rule="required" class="form-control selectpicker" name="row[is_default]">
+                {foreach name="isDefaultList" item="vo"}
+                    <option value="{$key}" {in name="key" value="0"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </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>

+ 58 - 0
application/admin/view/usergreetcontent/edit.html

@@ -0,0 +1,58 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
+                {foreach name="typeList" item="vo"}
+                    <option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Content')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-content" data-rule="required" class="form-control" name="row[content]" type="text" value="{$row.content|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Duration')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-duration" data-rule="required" class="form-control" name="row[duration]" type="number" value="{$row.duration|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Is_default')}:</label>
+        <div class="col-xs-12 col-sm-8">
+                        
+            <select  id="c-is_default" data-rule="required" class="form-control selectpicker" name="row[is_default]">
+                {foreach name="isDefaultList" item="vo"}
+                    <option value="{$key}" {in name="key" value="$row.is_default"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </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>

+ 35 - 0
application/admin/view/usergreetcontent/index.html

@@ -0,0 +1,35 @@
+<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">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+                        <!--<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('usergreetcontent/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('usergreetcontent/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('usergreetcontent/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('usergreetcontent/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
+
+                        <div class="dropdown btn-group {:$auth->check('usergreetcontent/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 table-nowrap"
+                           data-operate-edit="{:$auth->check('usergreetcontent/edit')}" 
+                           data-operate-del="{:$auth->check('usergreetcontent/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 5 - 0
application/api/controller/Gift.php

@@ -70,6 +70,11 @@ class Gift extends Api
         {
             $this->error("不存在的用户");
         }
+        if($touserinfo['is_kefu'] == 1){
+            $this->error('不可以给客服送礼物');
+        }
+
+
         $money = 0.00;
         Db::startTrans();
         //需要走计费的规则:男的 || 女的 需要收费的

+ 3 - 2
public/assets/js/backend/user/user.js

@@ -36,6 +36,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     [
                         {checkbox: true},
                         {field: 'id', title: __('Id')},
+                        {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
+                        {field: 'bio', title: __('Bio'), operate: 'LIKE'},
+
                         // {field: 'gh_id', title: __('Gh_id')},
                         // {field: 'gonghui.name', title: __('Gonghui.name'), operate: false},
 
@@ -48,14 +51,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'username', title: __('Username'), operate: 'LIKE'},
                         {field: 'intro_uid', title: __('Intro_uid')},
                         {field: 'introcode', title: __('Introcode'), operate: 'LIKE'},
-                        {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
                         {field: 'real_status', title: __('Real_status'), searchList: {"-1":__('Real_status -1'),"0":__('Real_status 0'),"1":__('Real_status 1'),"2":__('Real_status 2')}, formatter: Table.api.formatter.status},
                         {field: 'gender', title: __('Gender'), searchList: {"1":__('Gender 1'),"0":__('Gender 0'),"-1":__('Gender -1')}, formatter: Table.api.formatter.normal},
                         {field: 'is_cost', title: __('Is_cost'), searchList: Config.isCostList, formatter: Table.api.formatter.normal},
                         //{field: 'height', title: __('Height'), operate: 'LIKE'},
                         //{field: 'weight', title: __('Weight'), operate: 'LIKE'},
                         //{field: 'birthday', title: __('Birthday')},
-                        //{field: 'bio', title: __('Bio'), operate: 'LIKE'},
                         //{field: 'audio_bio', title: __('Audio_bio'), operate: 'LIKE'},
                         {field: 'idcard_status', title: __('Idcard_status'), searchList: {"-1":__('Idcard_status -1'),"0":__('Idcard_status 0'),"1":__('Idcard_status 1'),"2":__('Idcard_status 2')}, formatter: Table.api.formatter.status},
                         //{field: 'successions', title: __('Successions')},

+ 77 - 0
public/assets/js/backend/usergreetcontent.js

@@ -0,0 +1,77 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'usergreetcontent/index' + location.search,
+                    add_url: 'usergreetcontent/add',
+//                    edit_url: 'usergreetcontent/edit',
+                    del_url: 'usergreetcontent/del',
+                    multi_url: 'usergreetcontent/multi',
+                    import_url: 'usergreetcontent/import',
+                    table: 'user_greet_content',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        {field: 'user_id', title: __('User_id')},
+                        {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
+                        {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
+                        {field: 'type', title: __('Type'), searchList: {"0":__('Type 0'),"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
+                        {field: 'title', title: __('Title'), operate: 'LIKE'},
+                        {field: 'content', title: __('Content'), operate: 'LIKE',events: Table.api.events.image,formatter: function (value,row,index){
+                            if (row.type == 0){
+                                return value;
+                            }
+                            if (row.type == 1){
+                                return Table.api.formatter.audio(value,row,index);
+                            }
+                            if (row.type == 2){
+                                return Table.api.formatter.image(value,row,index);
+                            }
+                            if (row.type == 'images'){
+                                return Table.api.formatter.images(value,row,index);
+                            }
+                            if (row.type == 'video'){
+                                return Table.api.formatter.video(value,row,index);
+                            }
+                            return '';
+                        }},
+                        {field: 'duration', title: __('Duration')},
+                        {field: 'is_default', title: __('Is_default'), searchList: {"0":__('Is_default 0'),"1":__('Is_default 1')}, formatter: Table.api.formatter.normal},
+                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+
+                        {field: 'operate', title: __('Operate'), 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]"));
+            }
+        }
+    };
+    return Controller;
+});

+ 16 - 0
public/assets/js/require-table.js

@@ -640,6 +640,22 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
                     var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
                     return '<a href="javascript:"><img class="' + classname + '" src="' + Fast.api.cdnurl(value) + '" /></a>';
                 },
+                video: function (value, row, index) {
+                    value = value == null || value.length === 0 ? '' : value.toString();
+
+                    if(!value){
+                        return '';
+                    }
+                    return '<video width="100" height="100" controls><source src="'+ Fast.api.cdnurl(value) +'" type="video/mp4"></video>';
+                },
+                audio: function (value, row, index) {
+                    value = value == null || value.length === 0 ? '' : value.toString();
+
+                    if(!value){
+                        return '';
+                    }
+                    return '<audio controls><source src="'+ Fast.api.cdnurl(value) +'" type="audio/mpeg"></audio>';
+                },
                 images: function (value, row, index) {
                     value = value == null || value.length === 0 ? '' : value.toString();
                     var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';