|
@@ -19,7 +19,8 @@ class ROITJController extends CatchController
|
|
|
'start_at' => 'nullable|date_format:Y-m-d',
|
|
|
'end_at' => 'nullable|date_format:Y-m-d|after_or_equal:start_at',
|
|
|
'ranse_id' => 'nullable|integer|min:1',
|
|
|
- 'miniprogram_id' => 'nullable|integer|min:1'
|
|
|
+ 'miniprogram_id' => 'nullable|integer|min:1',
|
|
|
+ 'puser_id' => 'nullable|integer|min:1'
|
|
|
]);
|
|
|
|
|
|
$startAt = $request->input('start_at');
|
|
@@ -35,6 +36,9 @@ class ROITJController extends CatchController
|
|
|
if ($roles->contains('optimizer')) {
|
|
|
$userId = $this->getLoginUserId();
|
|
|
}
|
|
|
+ if($roles->contains('administrator')) {
|
|
|
+ $puserId = $request->input('puser_id');
|
|
|
+ }
|
|
|
|
|
|
return DB::table('tj_promotion_day_charge')
|
|
|
->when($startAt, function ($query, $startAt) {
|
|
@@ -75,15 +79,16 @@ class ROITJController extends CatchController
|
|
|
->whereIn('id', $result->pluck('miniprogram_id'))
|
|
|
->select('id', 'name')
|
|
|
->get()->keyBy('id');
|
|
|
- $companyUserName = DB::table('users')
|
|
|
- ->where('id', $result->first()->puser_id)->value('username');
|
|
|
+ $companyUserNames = DB::table('users')
|
|
|
+ ->whereIn('id', $result->pluck('puser_id'))->select('id','username')
|
|
|
+ ->get()->keyBy('id');
|
|
|
$promotions = DB::table('promotions')
|
|
|
->whereIn('id', $result->pluck('promotion_id'))
|
|
|
->select('id', 'name')
|
|
|
->get()->keyBy('id');
|
|
|
foreach ($result as $item) {
|
|
|
// 商户
|
|
|
- $item->company_username = $companyUserName;
|
|
|
+ $item->company_username = $companyUserNames->get($item->puser_id)->username ?? '';
|
|
|
// 优化师
|
|
|
$item->optimizer_name = $users->get($item->user_id)->username ?? '';
|
|
|
// 小程序
|