فهرست منبع

用户积分流水

lizhen_gitee 1 سال پیش
والد
کامیت
8150907601

+ 1 - 1
application/admin/command/Crud.php

@@ -103,7 +103,7 @@ class Crud extends Command
         'user',
         'user_group',
         'user_rule',
-        'user_score_log',
+//        'user_score_log',
         'user_token',
     ];
 

+ 30 - 20
application/admin/controller/Userscorelog.php

@@ -32,29 +32,39 @@ class Userscorelog extends Backend
      */
     public function index()
     {
+        //当前是否为关联查询
+        $this->relationSearch = true;
         //设置过滤方法
         $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();
-        }
-        list($where, $sort, $order, $offset, $limit) = $this->buildparams();
-        $list = $this->model
-            ->where($where)
-            ->order($sort, $order)
-            ->paginate($limit);
-
-        $wallet_logtype = config('wallet.logtype');
-        $lists = collection($list->items())->toArray();
-        foreach ($lists as &$row) {
-            $row['log_type_text'] = isset($wallet_logtype[$row['log_type']]) ? $wallet_logtype[$row['log_type']] : '';
-        }
+        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);
 
-        $result = ['total' => $list->total(), 'rows' => $lists];
-        return json($result);
+            foreach ($list as $row) {
+                
+                $row->getRelation('user')->visible(['username','nickname','mobile']);
+            }
+
+            $wallet_logtype = config('wallet.logtype');
+            $lists = collection($list->items())->toArray();
+            foreach ($lists as &$row) {
+                $row['log_type_text'] = isset($wallet_logtype[$row['log_type']]) ? $wallet_logtype[$row['log_type']] : '';
+            }
+
+            $result = array("total" => $list->total(), "rows" => $lists);
+
+            return json($result);
+        }
+        return $this->view->fetch();
     }
 
 }

+ 15 - 12
application/admin/lang/zh-cn/userscorelog.php

@@ -1,16 +1,19 @@
 <?php
 
 return [
-    'Id'           => 'ID',
-    'User_id'      => '用户ID',
-    'Log_type'     => '日志类型',
-    'Before'       => '之前余额',
-    'Change_value' => '变动金额',
-    'Remain'       => '剩余金额',
-    'Table'        => '数据来源',
-    'Table_id'     => '数据来源ID',
-    'Table_uid'    => '数据贡献用户ID',
-    'Remark'       => '备注',
-    'Createtime'   => '创建时间',
-    'Updatetime'   => '更新时间'
+    'Id'            => 'ID',
+    'User_id'       => '用户ID',
+    'Log_type'      => '日志类型',
+    'Before'        => '之前余额',
+    'Change_value'  => '变动金额',
+    'Remain'        => '剩余金额',
+    'Table'         => '数据来源',
+    'Table_id'      => '数据来源ID',
+    'Table_uid'     => '数据贡献用户ID',
+    'Remark'        => '备注',
+    'Createtime'    => '创建时间',
+    'Updatetime'    => '更新时间',
+    'User.username' => '用户名',
+    'User.nickname' => '昵称',
+    'User.mobile'   => '手机号'
 ];

+ 4 - 0
application/admin/model/Userscorelog.php

@@ -37,4 +37,8 @@ class Userscorelog extends Model
 
 
 
+    public function user()
+    {
+        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
 }

+ 4 - 0
public/assets/js/backend/userscorelog.js

@@ -29,6 +29,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {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: 'user.mobile', title: __('User.mobile'), operate: 'LIKE'},
 //                        {field: 'log_type', title: __('Log_type')},
                         {field: 'log_type_text', title: __('Log_type'),operate:false},
                         {field: 'before', title: __('Before'), operate:'BETWEEN'},
@@ -40,6 +43,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'remark', title: __('Remark'), operate: 'LIKE'},
                         {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
 //                        {field: 'updatetime', title: __('Updatetime'), 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}
                     ]
                 ]