66 lines
2.2 KiB
PHP
66 lines
2.2 KiB
PHP
|
|
<?php
|
|||
|
|
// +----------------------------------------------------------------------
|
|||
|
|
// | 范氏国香 fsgx — Admin 积分日志接口
|
|||
|
|
// +----------------------------------------------------------------------
|
|||
|
|
|
|||
|
|
namespace app\controller\admin\v1\hjf;
|
|||
|
|
|
|||
|
|
use app\controller\admin\AuthController;
|
|||
|
|
use app\Request;
|
|||
|
|
use think\facade\Db;
|
|||
|
|
|
|||
|
|
class HjfPoints extends AuthController
|
|||
|
|
{
|
|||
|
|
/**
|
|||
|
|
* GET /adminapi/hjf/points/release_log
|
|||
|
|
* 积分释放日志(来自 UserBill,type = integral,mark 包含"积分")
|
|||
|
|
*/
|
|||
|
|
public function releaseLog(Request $request)
|
|||
|
|
{
|
|||
|
|
$page = (int)$request->get('page', 1);
|
|||
|
|
$limit = (int)$request->get('limit', 20);
|
|||
|
|
$keyword = trim((string)$request->get('keyword', ''));
|
|||
|
|
$type = trim((string)$request->get('type', ''));
|
|||
|
|
|
|||
|
|
$query = Db::table('eb_user_bill')
|
|||
|
|
->alias('b')
|
|||
|
|
->leftJoin('eb_user u', 'u.uid = b.uid')
|
|||
|
|
->where('b.category', 'integral')
|
|||
|
|
->field('b.id, b.uid, b.title, b.mark, b.number, b.balance, b.pm, b.add_time, u.nickname, u.avatar');
|
|||
|
|
|
|||
|
|
if ($keyword !== '') {
|
|||
|
|
$query->where(function ($q) use ($keyword) {
|
|||
|
|
$q->whereLike('u.nickname', "%{$keyword}%")
|
|||
|
|
->whereOr('b.uid', $keyword);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($type !== '') {
|
|||
|
|
$typeMap = [
|
|||
|
|
'release' => 'frozen_points_release',
|
|||
|
|
'brokerage'=> 'frozen_points_brokerage',
|
|||
|
|
'consume' => '',
|
|||
|
|
];
|
|||
|
|
if ($type === 'consume') {
|
|||
|
|
$query->where('b.pm', 0);
|
|||
|
|
} elseif (isset($typeMap[$type]) && $typeMap[$type] !== '') {
|
|||
|
|
$query->where('b.link_type', $typeMap[$type]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$count = $query->count();
|
|||
|
|
$list = $query->order('b.id', 'desc')
|
|||
|
|
->page($page, $limit)
|
|||
|
|
->select()
|
|||
|
|
->toArray();
|
|||
|
|
|
|||
|
|
foreach ($list as &$item) {
|
|||
|
|
$item['add_time_str'] = date('Y-m-d H:i:s', (int)$item['add_time']);
|
|||
|
|
$item['pm_label'] = $item['pm'] ? '收入' : '支出';
|
|||
|
|
}
|
|||
|
|
unset($item);
|
|||
|
|
|
|||
|
|
return $this->success(['list' => $list, 'count' => $count]);
|
|||
|
|
}
|
|||
|
|
}
|