95 lines
2.1 KiB
PHP
95 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Models\Merchant;
|
|
use App\Models\MerchantLog;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
|
|
class MerchantLogController extends BaseDefaultController
|
|
{
|
|
public function setPagesInfo()
|
|
{
|
|
$this->pages = [
|
|
'name' => '商户日志'
|
|
];
|
|
}
|
|
public function indexData()
|
|
{
|
|
$merchant = Merchant::get();
|
|
return ['merchant' => $merchant];
|
|
}
|
|
|
|
public function shareData($show = '')
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
public function checkRule($id = '')
|
|
{
|
|
|
|
}
|
|
|
|
public function setErrorMsg()
|
|
{
|
|
$messages = [
|
|
|
|
];
|
|
return $messages;
|
|
}
|
|
|
|
public function setModel()
|
|
{
|
|
return new MerchantLog();
|
|
}
|
|
|
|
public function apiJson(Request $request)
|
|
{
|
|
$offset = $request->input('page', 1);
|
|
$pagesize = $request->input('limit', 1);
|
|
$offset = ($offset - 1) * $pagesize;
|
|
$merchant_id = $request->input('merchant_id', '');
|
|
$order_id = $request->input('sort', 'id');
|
|
$order_type = $request->input('order', 'desc');
|
|
$debug = $request->input('debug', 0);
|
|
$model = $this->setModel();
|
|
|
|
|
|
$search_arr = [
|
|
'merchant_id' => [
|
|
'type' => '=',
|
|
'value' => $merchant_id
|
|
]
|
|
|
|
|
|
];
|
|
$model = $this->searchKey($model, $search_arr, 2);
|
|
|
|
|
|
$total = $model->count();
|
|
$result = $model->skip($offset)->with('merchants')->orderBy($order_id, $order_type)->orderBy('id', 'desc')->take($pagesize)->get();;
|
|
$narr = array();
|
|
|
|
foreach ($result as $k => $v) {
|
|
|
|
$v['admin_name'] = $v->merchants['name'];
|
|
$narr[] = $v;
|
|
}
|
|
$json = [
|
|
"status" => 1,
|
|
'code' => $total > 0 ? 0 : 1,
|
|
'msg' => $total > 0 ? '请求数据成功' : '暂无数据',
|
|
'count' => $total,
|
|
'data' => $narr
|
|
];
|
|
|
|
if ($debug) {
|
|
return $this->jsonDebug($json);
|
|
}
|
|
return response()->json($json);
|
|
}
|
|
}
|