فهرست منبع

持有产品统计

afa 5 ماه پیش
والد
کامیت
8e9b353113

+ 0 - 1
application/admin/controller/product/Lists.php

@@ -57,7 +57,6 @@ class Lists extends Backend
             ->where($where)
             ->order($sort, $order)
             ->paginate($limit);
-
         $productOrder = new ProductOrder();    
         foreach ($list as &$item) {
             $item['hold_num'] = $productOrder::where('product_id', $item->id)->where('status', 'in',[$productOrder::Paid, $productOrder::Transferred, $productOrder::Freeze])->count();//持有数量

+ 65 - 0
application/admin/controller/product/Orders.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace app\admin\controller\product;
+
+use app\common\controller\Backend;
+
+/**
+ * 订单管理
+ *
+ * @icon fa fa-circle-o
+ */
+class Orders extends Backend
+{
+
+    /**
+     * Orders模型对象
+     * @var \app\admin\model\product\Orders
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\common\model\ProductOrder;
+        $this->assignconfig('ids', $this->request->param('ids'));
+    }
+
+
+    /**
+     * 查看
+     * @return string|Json
+     * @throws \think\Exception
+     * @throws DbException
+     */
+    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();
+        $product_id = $this->request->param('ids');
+        //显示该产品下,每个地址持有数量  用户地址  持有数量
+
+        $list = $this->model->with('users')
+            ->where($where)
+            ->where('product_id', $product_id)->where('product_order.status', 'in', [$this->model::Paid, $this->model::Transferred, $this->model::Freeze])
+            ->field('user_id,  SUM(num) as total_num,users.address')
+            ->group('user_id')
+            ->order($sort, $order)
+            ->paginate($limit);
+   
+ 
+        $result = ['total' => $list->total(), 'rows' => $list->items()];
+        return json($result);
+    }
+
+
+}

+ 63 - 0
application/admin/controller/user/Orders.php

@@ -0,0 +1,63 @@
+<?php
+
+namespace app\admin\controller\user;
+
+use app\common\controller\Backend;
+
+/**
+ * 订单管理
+ *
+ * @icon fa fa-circle-o
+ */
+class Orders extends Backend
+{
+
+    /**
+     * Orders模型对象
+     * @var \app\admin\model\user\Orders
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\common\model\ProductOrder;
+        $this->assignconfig('ids', $this->request->param('ids'));
+    }
+
+
+    /**
+     * 查看
+     * @return string|Json
+     * @throws \think\Exception
+     * @throws DbException
+     */
+    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();
+        $user_id = $this->request->param('ids');
+        //持有产品中每个产品的持有总量
+        $list = $this->model->with('products')
+            ->where($where)
+            ->where('user_id', $user_id)->where('product_order.status', 'in', [$this->model::Paid, $this->model::Transferred, $this->model::Freeze])
+            ->field('user_id,  SUM(num) as total_num,products.zh_name')
+            ->group('product_id')
+            ->order($sort, $order)
+            ->paginate($limit);
+   
+ 
+        $result = ['total' => $list->total(), 'rows' => $list->items()];
+        return json($result);
+    }
+
+}

+ 5 - 3
application/admin/controller/user/User.php

@@ -9,7 +9,7 @@ use app\common\model\LedgerFrozenChangeModel;
 use Exception;
 use fast\GoogleAuthenticator;
 use fast\Asset;
-use fast\Common;
+use app\common\model\ProductOrder;
 use app\common\model\LedgerTeacChangeModel;
 use think\Db;
 use think\exception\DbException;
@@ -63,9 +63,11 @@ class User extends Backend
 
         [$where, $sort, $order, $offset, $limit] = $this->buildparams();
         
-   
-  
         $list = $this->model->with('ledgerWallet')->where($where)->order($sort, $order)->paginate($limit);
+        $productOrder = new ProductOrder();    
+        foreach ($list as &$item) {
+            $item['hold_num'] = $productOrder::where('user_id', $item->id)->where('status', 'in',[$productOrder::Paid, $productOrder::Transferred, $productOrder::Freeze])->count();//持有数量
+        }
         $result = ['total' => $list->total(), 'rows' => $list->items()];
         return json($result);
     }

+ 23 - 0
application/admin/view/product/orders/index.html

@@ -0,0 +1,23 @@
+<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>

+ 22 - 0
application/admin/view/user/orders/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>

+ 4 - 4
public/assets/js/backend/product/lists.js

@@ -67,8 +67,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'area',  ], function
                         { field: 'operate', title: __('Operate'),
                             buttons:[
                                 {
+                                    name: 'areas',
                                     classname: 'btn btn-xs btn-info btn-dialog',
-                                    name: '区域设置',
                                     text: __('区域设置'),
                                     title: __('区域设置'),
                                     url: 'product/areas/index',
@@ -78,12 +78,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'area',  ], function
                                     }
                                     //refresh:true,
                                 },{
+                                    name: 'counts',
                                     classname: 'btn btn-xs btn-danger btn-dialog',
-                                    name: '产品统计',
                                     text: __('产品统计'),
                                     title: __('产品统计'),
-                                    url: 'product/areas/index',
-                                    extend:'data-area=["90%","85%"]',
+                                    url: 'product/orders/index',
+                                    extend:'data-area=["50%","85%"]',
                                 },
                               ],
                             table: table, events: Table.api.events.operate,

+ 46 - 0
public/assets/js/backend/product/orders.js

@@ -0,0 +1,46 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'product/orders/index' + location.search+'&ids='+Config.ids,
+                    table: 'product_order',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+                fixedColumns: false,
+         
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'user_id', title: __('用户Id'), operate: 'LIKE'},
+                        {field: 'users.address', title: __('用户地址'), operate: 'LIKE'},
+                        {field: 'total_num', title: __('持有数量'), operate: false},
+       
+                     
+
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+  
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});

+ 44 - 0
public/assets/js/backend/user/orders.js

@@ -0,0 +1,44 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'user/orders/index' + location.search+'&ids='+Config.ids,
+                    table: 'product_order',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'id',
+                sortName: 'id',
+
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'product_id', title: __('产品Id')},
+                        {field: 'products.zh_name', title: __('产品名称'), operate: 'LIKE'},
+                        {field: 'total_num', title: __('持有数量')},
+                  
+       
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});

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

@@ -42,6 +42,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'ledger_wallet.token', title: '茶宝', operate: false},
                         {field: 'ledger_wallet.teac', title: 'Teac', operate: false},
                         {field: 'team_num', title: __('Team_num'), operate: false},
+                        {field: 'hold_num', title: __('持有产品数量'), operate: false},
                         {field: 'direct_num', title: __('Direct_num'), operate: false},
                         {field: 'effective_time', title: __('Effective_time'), operate: false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'is_login', title: __('登录锁定'), searchList: {"1":__('Yes'),"0":__('No')}, formatter: Table.api.formatter.toggle},
@@ -56,10 +57,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                 text: '资金调整',
                                 title: '资金调整',
                                 classname: 'btn btn-xs btn-info btn-dialog btn-receivable',
-                                icon: 'fa fa-pencil',
                                 url: 'user/user/approve',
                                 extend: 'data-area=\'["50%", "50%"]\'',
-                            },],
+                            },{
+                                name: 'counts',
+                                text: '统计',
+                                title: '统计',
+                                classname: 'btn btn-xs btn-danger btn-dialog',
+                                url: 'user/orders/index',
+                                extend: 'data-area=\'["50%", "85%"]\'',
+                            }],
                             formatter: Table.api.formatter.operate
                         }
                     ]