afa 6 luni în urmă
părinte
comite
b4d8028add

+ 52 - 0
application/admin/controller/product/Teacs.php

@@ -0,0 +1,52 @@
+<?php
+
+namespace app\admin\controller\product;
+
+use app\common\controller\Backend;
+
+/**
+ * Teac交易管理
+ *
+ * @icon fa fa-circle-o
+ */
+class Teacs extends Backend
+{
+
+    /**
+     * Teacs模型对象
+     * @var \app\admin\model\product\Teacs
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\common\model\ProductTeac();
+
+    }
+
+
+    public function index()
+    {
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if (false === $this->request->isAjax()) {
+            return $this->view->fetch();
+        }
+        //如果发送的来源是 Selectpage,则转发到 Selectpage
+        if ($this->request->request('keyField')) {
+            return $this->selectpage();
+        }
+        [$where, $sort, $order, $offset, $limit] = $this->buildparams();
+
+        $list = $this->model->with('user')
+            ->where($where)
+            //->where('synthesis_id', '=', $ids)
+            ->order($sort, $order)
+            ->paginate($limit);
+        $result = ['total' => $list->total(), 'rows' => $list->items()];
+        return json($result);
+    }
+
+
+}

+ 52 - 0
application/admin/controller/user/Teacs.php

@@ -0,0 +1,52 @@
+<?php
+
+namespace app\admin\controller\user;
+
+use app\common\controller\Backend;
+
+/**
+ * 用户Teac交易记录管理
+ *
+ * @icon fa fa-circle-o
+ */
+class Teacs extends Backend
+{
+
+    /**
+     * Teacs模型对象
+     * @var \app\admin\model\user\Teacs
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\common\model\UserTeac();
+        $this->assignconfig('ids', $this->request->param('ids'));
+    }
+
+
+
+    public function index()
+    {
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if (false === $this->request->isAjax()) {
+            return $this->view->fetch();
+        }
+        //如果发送的来源是 Selectpage,则转发到 Selectpage
+        if ($this->request->request('keyField')) {
+            return $this->selectpage();
+        }
+        [$where, $sort, $order, $offset, $limit] = $this->buildparams();
+        $ids = $this->request->param('ids');
+        $list = $this->model->with('users')
+            ->where($where)->where('trade_id', '=', $ids)
+            ->order($sort, $order)
+            ->paginate($limit);
+        $result = ['total' => $list->total(), 'rows' => $list->items()];
+        return json($result);
+    }
+   
+
+}

+ 15 - 0
application/admin/lang/zh-cn/product/teacs.php

@@ -0,0 +1,15 @@
+<?php
+
+return [
+    'User_id'     => '求购用户',
+    'Type_id'     => '类型',
+    'Price'       => '价格',
+    'Stock'       => '数量',
+    'Num'         => '已完成数量',
+    'Total_price' => '总价',
+    'Fee'         => '出售服务费',
+    'Status'      => '状态',
+    'Frozen'      => '冻结',
+    'Create_time' => '创建时间',
+    'Update_time' => '更新时间'
+];

+ 14 - 0
application/admin/lang/zh-cn/user/teacs.php

@@ -0,0 +1,14 @@
+<?php
+
+return [
+    'User_id'     => '求购用户',
+    'Trade_id'    => '求购',
+    'Type_id'     => '类型',
+    'Price'       => '出售单价',
+    'Num'         => '出售数量',
+    'Total_price' => '总价',
+    'Fee'         => '服务费',
+    'Status'      => '状态',
+    'Create_time' => '创建时间',
+    'Update_time' => '更新时间'
+];

+ 27 - 0
application/admin/validate/product/Teacs.php

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

+ 27 - 0
application/admin/validate/user/Teacs.php

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

+ 22 - 0
application/admin/view/product/teacs/index.html

@@ -0,0 +1,22 @@
+<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>
+                   
+                        
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+         
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 20 - 0
application/admin/view/user/teacs/index.html

@@ -0,0 +1,20 @@
+<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>
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                  
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 0 - 1
application/api/controller/Teac.php

@@ -185,7 +185,6 @@ class Teac extends Api
     public function getUserTeacList(ProductTeac $productTeac)
     {
         $list = $productTeac::where('user_id', $this->auth->id)
-            
              ->order('create_time desc')
              ->paginate($this->pageSize);
         $this->success('ok', $list);

+ 5 - 0
application/common/model/ProductTeac.php

@@ -62,6 +62,11 @@ class ProductTeac extends Model
       
     }
 
+
+    public function user()
+    {
+        return $this->hasOne('UserModel', 'id', 'user_id', [], 'LEFT')->setEagerlyType(0);
+    }
     
     //用户 user_id
     public function users()

+ 74 - 0
public/assets/js/backend/product/teacs.js

@@ -0,0 +1,74 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'product/teacs/index' + location.search,
+                    table: 'product_teac',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                fixedColumns: true,
+                fixedRightNumber: 1,
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        {field: 'user.address', title: __('User_id')},
+                        { field: 'type_id', title: __('Type_id'), searchList: { "1": __('出售'), "2": __('求购') }, formatter: Table.api.formatter.status },
+                        {field: 'price', title: __('Price'), operate:false},
+                        {field: 'stock', title: __('Stock')},
+                        {field: 'num', title: __('Num')},
+                        {field: 'total_price', title: __('Total_price'), operate:'BETWEEN'},
+                        //{field: 'fee', title: __('Fee'), operate:'BETWEEN'},
+                        {field: 'status', title: __('Status'), searchList: { "1": __('进行中'), "0": __('关闭'), "2": __('已完成') }, formatter: Table.api.formatter.status },
+                        {field: 'frozen', title: __('Frozen'), align: 'left', formatter:function (value, row, index) {
+                            if(row.type_id == 1)  return '<span class="text-success">'+value+' Teac</span>';
+                            return '<span class="text-warning">'+ value+' 茶宝</span>';
+                        }},
+                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'operate', title: __('Operate'),
+                            buttons:[
+                                {
+                                    classname: 'btn btn-xs btn-info btn-dialog',
+                                    name: '交易记录',
+                                    text: __('交易记录'),
+                                    title: __('交易记录'),
+                                    url: 'user/teacs/index',
+                                    extend:'data-area=["90%","85%"]',
+                                    //refresh:true,
+                                },
+                              ],
+                            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;
+});

+ 58 - 0
public/assets/js/backend/user/teacs.js

@@ -0,0 +1,58 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'user/teacs/index' + location.search+'&ids='+Config.ids,
+           
+                    table: 'user_teac',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                fixedColumns: true,
+                fixedRightNumber: 1,
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'id', title: __('Id')},
+                        {field: 'users.address', title: __('User_id')},
+                        {field: 'type_id', title: __('Type_id'), searchList: { "1": __('出售'), "2": __('求购') }, formatter: Table.api.formatter.status },
+                       
+                        {field: 'price', title: __('Price'), operate:'BETWEEN'},
+                        {field: 'num', title: __('Num')},
+                        {field: 'total_price', title: __('Total_price'), operate:'BETWEEN'},
+                        {field: 'fee', title: __('Fee'), operate:'BETWEEN'},
+                      
+                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        
+                       
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            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;
+});