100 lines
3.1 KiB
PHP
100 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller;
|
|
|
|
class Log extends Base
|
|
{
|
|
public function index(){
|
|
if(request()->isAjax()){
|
|
$param = input('param.');
|
|
$limit = $param['pageSize'];
|
|
$offset = ($param['pageNumber'] - 1) * $limit;
|
|
|
|
$result = db('system_log')->limit($offset, $limit)->order('id', 'desc')->select();
|
|
$ip2region = new \Ip2Region();
|
|
|
|
foreach($result as $key=>$vo){
|
|
$info = $ip2region->btreeSearch($vo['ip']);
|
|
$city = explode('|', $info['region']);
|
|
|
|
if(0 != $info['city_id']){
|
|
$result[$key]['ip'] = $city['2'] . $city['3'] .'---'. $city['4'];
|
|
}else{
|
|
$result[$key]['ip'] = $city['0'];
|
|
}
|
|
|
|
$result[$key]['operate'] = $this->makeBtn($vo['id']);
|
|
}
|
|
$return['total'] = db('system_log')->count(); //总数据
|
|
$return['rows'] = $result;
|
|
|
|
return json($return);
|
|
|
|
}
|
|
|
|
return $this->fetch();
|
|
}
|
|
|
|
public function del(){
|
|
if(request()->isAjax()){
|
|
$id = input('param.id/d');
|
|
|
|
try{
|
|
db('system_log')->where('id', $id)->delete();
|
|
}catch(\Exception $e){
|
|
return json(['code' => -1, 'data' => '', 'msg' => $e->getMessage()]);
|
|
}
|
|
return json(['code' => 1, 'data' => '', 'msg' => '删除成功']);
|
|
}
|
|
}
|
|
|
|
public function paymentActionLog(){
|
|
if(request()->isAjax()){
|
|
$param = input('param.');
|
|
$limit = $param['pageSize'];
|
|
$offset = ($param['pageNumber'] - 1) * $limit;
|
|
|
|
$instance = db('payment_action_log');
|
|
if(empty($param['searchText'])){
|
|
$result = $instance->limit($offset, $limit)->order('id', 'desc')->select();
|
|
}else{
|
|
$result = $instance->where('action_user',$param['searchText'])->whereOr('pay_account',$param['searchText'])->limit($offset, $limit)->order('id', 'desc')->select();
|
|
}
|
|
|
|
foreach($result as $key=>$vo){
|
|
$result[$key]['operate'] = $this->makeBtn($vo['id']);
|
|
}
|
|
$return['total'] = count($result);
|
|
$return['rows'] = $result;
|
|
|
|
return json($return);
|
|
|
|
}
|
|
|
|
return $this->fetch('paymentLog');
|
|
}
|
|
|
|
public function paymentLogDel(){
|
|
if(request()->isAjax()){
|
|
$id = input('param.id/d');
|
|
|
|
try{
|
|
db('payment_action_log')->where('id', $id)->delete();
|
|
}catch(\Exception $e){
|
|
return json(['code' => -1, 'data' => '', 'msg' => $e->getMessage()]);
|
|
}
|
|
return json(['code' => 1, 'data' => '', 'msg' => '删除成功']);
|
|
}
|
|
}
|
|
|
|
// 生成操作按钮
|
|
private function makeBtn($id)
|
|
{
|
|
$operate = '<a href="javascript:del(' . $id . ')"><button type="button" class="btn btn-danger btn-sm">';
|
|
$operate .= '<i class="fa fa-trash-o"></i> 删除</button></a> ';
|
|
|
|
return $operate;
|
|
}
|
|
|
|
|
|
} |