diff --git a/app/Admin/Controllers/PointLogController.php b/app/Admin/Controllers/PointLogController.php index 581e7bd3..540ee2ae 100644 --- a/app/Admin/Controllers/PointLogController.php +++ b/app/Admin/Controllers/PointLogController.php @@ -37,7 +37,7 @@ class PointLogController extends AdminController return Grid::make($builder, function (Grid $grid) { - $grid->export()->disableExportAll()->titles([ + $grid->export()->titles([ 'id' => 'ID', 'username' => '用户昵称', 'user_id' => __('point-log.fields.user.phone'), @@ -59,8 +59,10 @@ class PointLogController extends AdminController ])->rows(function ($rows) { foreach ($rows as &$row) { $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(); - $vipCount = UserVip::where('user_id', $row['user_id'])->where('status', UserVip::STATUS_SUCCESS)->count(); + $userVips = UserVip::where('user_id', $row['user_id'])->where('status', UserVip::STATUS_SUCCESS)->get(); + + $firstVip = $userVips->sortBy('success_time')->first(); + $vipCount = $userVips->count(); $row['user_id'] = data_get($row, 'user.phone'); $row['username'] = data_get($userInfo, 'nickname'); @@ -75,12 +77,12 @@ class PointLogController extends AdminController $row['renew_rechare_money_total'] = ''; if ($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(); - $row['renew_rechare_type'] = data_get($latestVip, 'name'); - $row['renew_rechare_latest_time'] = data_get($latestVip, 'success_time'); - - $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; + $latestVip = $userVips->sortByDesc('success_time')->first(); + if ($latestVip) { + $row['renew_rechare_type'] = $latestVip->name; + $row['renew_rechare_latest_time'] = $latestVip->success_time->format('Y-m-d H:i:s'); + } + $row['renew_rechare_money_total'] = $userVips->sum('price') - data_get($firstVip, 'price', 0); } $row['action'] = PointLogAction::getLabel(data_get($row, 'action')); diff --git a/app/Services/DistributeService.php b/app/Services/DistributeService.php index 3c0ffa22..b8d3139e 100644 --- a/app/Services/DistributeService.php +++ b/app/Services/DistributeService.php @@ -260,7 +260,7 @@ class DistributeService 'wx_share' => $order->wx_share ? array_merge($order->wx_share, $attributes) : $attributes, 'profit_paid' => now(), ]); - $this->success($list, $result); + $this->success($list); } }