6
0
Fork 0

后台 积分记录 导出

base
panliang 2026-03-25 11:20:22 +08:00
parent 86899df055
commit 2de5eb7e43
2 changed files with 12 additions and 10 deletions

View File

@ -37,7 +37,7 @@ class PointLogController extends AdminController
return Grid::make($builder, function (Grid $grid) { return Grid::make($builder, function (Grid $grid) {
$grid->export()->disableExportAll()->titles([ $grid->export()->titles([
'id' => 'ID', 'id' => 'ID',
'username' => '用户昵称', 'username' => '用户昵称',
'user_id' => __('point-log.fields.user.phone'), 'user_id' => __('point-log.fields.user.phone'),
@ -59,8 +59,10 @@ class PointLogController extends AdminController
])->rows(function ($rows) { ])->rows(function ($rows) {
foreach ($rows as &$row) { foreach ($rows as &$row) {
$userInfo = UserInfo::where('user_id', $row['user_id'])->first(); $userInfo = UserInfo::where('user_id', $row['user_id'])->first();
$firstVip = UserVip::where('user_id', $row['user_id'])->where('status', UserVip::STATUS_SUCCESS)->orderBy('success_time', 'asc')->first(); $userVips = UserVip::where('user_id', $row['user_id'])->where('status', UserVip::STATUS_SUCCESS)->get();
$vipCount = UserVip::where('user_id', $row['user_id'])->where('status', UserVip::STATUS_SUCCESS)->count();
$firstVip = $userVips->sortBy('success_time')->first();
$vipCount = $userVips->count();
$row['user_id'] = data_get($row, 'user.phone'); $row['user_id'] = data_get($row, 'user.phone');
$row['username'] = data_get($userInfo, 'nickname'); $row['username'] = data_get($userInfo, 'nickname');
@ -75,12 +77,12 @@ class PointLogController extends AdminController
$row['renew_rechare_money_total'] = ''; $row['renew_rechare_money_total'] = '';
if ($vipCount > 1) { if ($vipCount > 1) {
$row['renew_rechare_count'] = $vipCount - 1; $row['renew_rechare_count'] = $vipCount - 1;
$latestVip = UserVip::where('user_id', $row['user_id'])->where('status', UserVip::STATUS_SUCCESS)->orderBy('success_time', 'desc')->first(); $latestVip = $userVips->sortByDesc('success_time')->first();
$row['renew_rechare_type'] = data_get($latestVip, 'name'); if ($latestVip) {
$row['renew_rechare_latest_time'] = data_get($latestVip, 'success_time'); $row['renew_rechare_type'] = $latestVip->name;
$row['renew_rechare_latest_time'] = $latestVip->success_time->format('Y-m-d H:i:s');
$sum = UserVip::where('user_id', $row['user_id'])->where('status', UserVip::STATUS_SUCCESS)->where('id', '!=', $firstVip->id)->sum('price'); }
$row['renew_rechare_money_total'] = $sum; $row['renew_rechare_money_total'] = $userVips->sum('price') - data_get($firstVip, 'price', 0);
} }
$row['action'] = PointLogAction::getLabel(data_get($row, 'action')); $row['action'] = PointLogAction::getLabel(data_get($row, 'action'));

View File

@ -260,7 +260,7 @@ class DistributeService
'wx_share' => $order->wx_share ? array_merge($order->wx_share, $attributes) : $attributes, 'wx_share' => $order->wx_share ? array_merge($order->wx_share, $attributes) : $attributes,
'profit_paid' => now(), 'profit_paid' => now(),
]); ]);
$this->success($list, $result); $this->success($list);
} }
} }