mall_id; $name = $params['name'] ?? ''; $mobile = $params['mobile'] ?? ''; $status = $params['status'] ?? ''; $user_id = $params['user_id'] ?? ''; $user_keyword = $params['user_keyword'] ?? ''; return ApplyList::getPageList( $this->getPage($params), $this->getLimit($params), function ($query) use ($mall_id, $user_keyword, $name, $mobile, $user_id, $status) { // 商场ID $query->andWhere(['mall_id' => $mall_id]); // 会员ID if (!empty($user_id)) { $query->andWhere(['user_id' => $user_id]); } // 会员名称 if (!empty($name)) { $query->andWhere(['name' => $name]); } // 联系电话 if (!empty($mobile)) { $query->andWhere(['mobile' => $mobile]); } // 状态 if (!empty($status)) { $query->andWhere(['status' => $status]); } // 会员信息查询 if (!empty($user_keyword)) { $query->andWhere(['user_id' => MallUser::getUserIdByUserKeyWord($this->mall_id, $user_keyword)]); } $query->with(['user' => function ($query) { $query->select(['id', 'nickname', 'username', 'mobile', 'avatar_url']); }]); } ); } /** * 通过审核 * * @param integer $id * @param integer $idlevel_id * @return boolean */ public function pass(int $id, int $level_id) { // 申请记录 $apply = ApplyList::getApplyingById($this->mall_id, $id); if (empty($apply)) return $this->error('申请记录不存在'); // 等级 $level = Level::getLevelDetail($this->mall_id, $level_id); if (empty($level)) return $this->error('等级不存在'); // 转换经纬度 $geocoder = QqMapHelper::Geocoder($apply->getOperationAddress()); if ($geocoder['status'] != 0) return $this->error('地址转换失败'); // 经纬度 if (empty($geocoder['result']['location'])) return $this->error('地址转换失败2'); $location = array_values($geocoder['result']['location']); list($lon, $lat) = $location; $t = Yii::$app->db->beginTransaction(); try { // 添加用户中心 UserCenter::addUserByApply($apply, $level, $lon, $lat); // 升级记录 UpgradeLog::addUpgradeLog( $this->mall_id, $apply->user_id, $level->level, UpgradeLog::APPLY ); // 通过审核 $apply->pass($level); } catch (Exception $e) { $t->rollBack(); return $this->error($e->getMessage()); } $t->commit(); return true; } /** * 驳回审核 * * @param integer $id * @param string $content * @return boolean */ public function reject(int $id, string $content = '') { $apply = ApplyList::getApplyingById($this->mall_id, $id); if (empty($apply)) return $this->error('申请记录不存在'); return $apply->reject($content); } }