ztt 9 months ago
parent 25646be3f7
commit d10cd97b2b
  1. 64
      application/admin/controller/ScoreLog.php
  2. 5
      application/admin/model/shopro/user/WalletLog.php
  3. 10
      application/admin/view/score_log/index.html
  4. 31
      public/assets/js/backend/score_log.js

@ -2,8 +2,10 @@
namespace app\admin\controller; namespace app\admin\controller;
use addons\shopro\library\Operator;
use app\admin\model\shopro\commission\Level as LevelModel;
use app\admin\model\shopro\user\WalletLog as WalletLogModel;
use app\common\controller\Backend; use app\common\controller\Backend;
/** /**
* 用户资金日志 * 用户资金日志
* *
@ -22,7 +24,58 @@ class ScoreLog extends Backend
{ {
parent::_initialize(); parent::_initialize();
$this->model = new \app\admin\model\ScoreLog; $this->model = new \app\admin\model\ScoreLog;
// var_dump((new Level())->getList());
$this->assignconfig("levelList", $this->getList());
}
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
->where($where)
->order($sort, $order)
->paginate($limit);
$result = ['total' => $list->total(), 'rows' => $list->items()];
return json($result);*/
//如果发送的来源是 Selectpage,则转发到 Selectpage
if (false === $this->request->isAjax()) {
return $this->view->fetch();
}
if ($this->request->request('keyField')) {
return $this->selectpage();
}
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
$walletLogs = WalletLogModel::where($where)
->with(['user.agent.levelInfo'])
->score()
->order($sort, $order)
->paginate($limit);
// 多态关联 oper
$morphs = [
'user' => \app\admin\model\shopro\user\User::class,
'admin' => \app\admin\model\Admin::class,
'system' => \app\admin\model\Admin::class,
];
$walletLogs = morph_to($walletLogs, $morphs, ['oper_type', 'oper_id']);
$walletLogs = $walletLogs->toArray();
// 解析操作人信息
foreach ($walletLogs['data'] as &$log) {
$log['oper'] = Operator::info($log['oper_type'], $log['oper'] ?? null);
}
$result = ['total' => $walletLogs['total'], 'rows' => $walletLogs['data']];
return json($result);
} }
@ -33,5 +86,14 @@ class ScoreLog extends Backend
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/ */
public function getList() {
$data = (new LevelModel())->field('level, name, image, commission_rules')->select();
$new_data = [];
foreach ($data as $item) {
$new_data[$item['level']] = $item['name'];
}
return $new_data;
}
} }

@ -76,4 +76,9 @@ class WalletLog extends Common
{ {
return $this->eventMap[$data['type']][$data['event']] ?? ''; return $this->eventMap[$data['type']][$data['event']] ?? '';
} }
public function user()
{
return $this->belongsTo(User::class, 'user_id', 'id');
}
} }

@ -7,9 +7,9 @@
<div class="widget-body no-padding"> <div class="widget-body no-padding">
<div id="toolbar" class="toolbar"> <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-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('score_log/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a> <!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('score_log/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('score_log/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> <!-- <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('score_log/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('score_log/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> <!-- <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('score_log/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>-->
@ -17,8 +17,8 @@
</div> </div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap" <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('score_log/edit')}" data-operate-edit=""
data-operate-del="{:$auth->check('score_log/del')}" data-operate-del=""
width="100%"> width="100%">
</table> </table>
</div> </div>

@ -28,24 +28,31 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[ [
{checkbox: true}, {checkbox: true},
{field: 'id', title: __('Id')}, {field: 'id', title: __('Id')},
{field: 'user_id', title: __('User_id')}, {field: 'user.nickname', title: '用户昵称',operate: 'LIKE'},
{field: 'type', title: __('Type'), operate: 'LIKE'}, {field: 'user.agent.level_info.name', title: '用户等级', searchList: Config.levelList},
{field: 'event', title: __('Event'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'user.mobile', title: '手机号',operate: 'LIKE'},
{field: 'amount', title: __('Amount'), operate:'BETWEEN'}, {field: 'amount', title: '积分变动额度',operate:'BETWEEN'},
{field: 'before', title: __('Before'), operate:'BETWEEN'}, {field: 'memo', title: '积分变动类型'},
{field: 'after', title: __('After'), operate:'BETWEEN'}, {field: 'after', title: '当前积分'},
{field: 'memo', title: __('Memo'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'createtime', title: '变动时间',operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'ext', title: __('Ext'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, // // {field: 'type', title: __('Type'), operate: 'LIKE'},
{field: 'oper_type', title: __('Oper_type'), operate: 'LIKE'}, // {field: 'event', title: __('Event'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'oper_id', title: __('Oper_id')}, // {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, // {field: 'before', title: __('Before'), operate:'BETWEEN'},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} // {field: 'after', title: __('After'), operate:'BETWEEN'},
// {field: 'memo', title: __('Memo'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
// {field: 'ext', title: __('Ext'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
// {field: 'oper_type', title: __('Oper_type'), operate: 'LIKE'},
// {field: 'oper_id', title: __('Oper_id')},
// {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); Table.api.bindevent(table);
console.log(Config.levelList)
}, },
add: function () { add: function () {
Controller.api.bindevent(); Controller.api.bindevent();

Loading…
Cancel
Save