request->isAjax) { if (\Yii::$app->request->isGet) { $params = \Yii::$app->request->get(); $where[] = ['mall_id' => $this->mall_id]; $where[] = ['status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]; $where[] = ['verify_type' => ClerkLog::VERIFY_ELECTRON_COUPON]; if (!empty($get['keyword'])) { $user_list = User::lists(['where'=>[['mall_id'=>$this->mall_id],[ 'or', ['like', 'mobile', $get['keyword']] ]],'select'=>'id']); $user_ids = array_column($user_list,'id'); $where[] = ['user_id'=>$user_ids]; } if (!empty($params['user_id'])) $where[] = ['user_id'=>$params['user_id']]; if (!empty($params['start'])) $where[] = $where[] = ['>=', 'created_at', strtotime($params['start'])]; if (!empty($params['end'])) $where[] =$where[] = ['<=', 'created_at', strtotime($params['end'])]; $params['where'] = $where; $params['order'] = 'id DESC'; $params['select'] = 'id,mall_id,store_id,clerk_id,user_id,mobile,commission,title,created_at'; $pageData = ClerkLog::listPage($params, false); if (!empty($pageData['list'])) { $user_ids = array_column($pageData['list'], 'user_id'); $store_ids = array_column($pageData['list'], 'store_id'); $user_list = User ::lists(['where' => [['id' => $user_ids]], 'select' => 'id,nickname,mobile,username', 'index' => 'id']); if (MallAddons::isInstall($this->mall_id, AddonsEnum::ADDONS_NAME_STORE)) { $store_list = Store::lists(['where' => [['id' => $store_ids]], 'select' => 'id,store_name', 'index' => 'id']); } foreach ($pageData['list'] as &$item) { $item['nickname'] = $item['mobile'] = $item['username'] = $item['store_name'] = ''; if (isset($user_list[$item['user_id']])) { $user = $user_list[$item['user_id']]; $item['nickname'] = $user['nickname']; $item['mobile'] = $user['mobile']; $item['username'] = $user['username']; } if (isset($store_list[$item['store_id']])) { $item['store_name'] = $store_list[$item['store_id']]['store_name']; } } } return $this->success('操作成功', $pageData); } } return $this->render('index',[ ]); } }