try { $zkServer = empty($zkServer) ? RpcConfig::getZooConfig() : $zkServer; PhpLibLog::info("ZookeeperComponent::getServer serverName:$serverName , zkServer:$zkServer"); $this->zk = new \Zookeeper($zkServer); $serverStr = $this->zk->getChildren("/" . $serverName); PhpLibLog::info("ZookeeperComponent::getServer getChildren success:".json_encode($serverStr)); } catch (Exception $e) { $msg = $e->getMessage(); PhpLibLog::emergency("ZookeeperComponent::getServer ZooException message:$msg"); Throw new ZooException('zookeeper exception:' .$msg); } if (empty($serverStr)) { PhpLibLog::emergency("ZookeeperComponent::getServer RPC service $serverName empty!"); Throw new RpcServiceNotFoundException("未发现RPC服务:" . $serverName . " !"); } //从服务列表中随机取一个 $randKey = array_rand($serverStr, 1);
*/ public function getServer($serverName, $zkServer = null) { $serverData = $this->getServerFromClient($serverName); if (empty($serverData)) { $serverData = $this->getServerFromPhpZk($serverName, $zkServer); } return $serverData; }
* 获取服务地址和端口号 * @return array * @throws \Exception */ protected function getServer() { return $this->zoo->getServer($this->zkServiceName); } /** * 获取连接对象 * @return TSocket */
* BasicService constructor. */ public function __construct() { PhpLibLog::info("zk服务名:" . $this->zkServiceName); $this->zoo = new ZookeeperService(); $this->server = $this->getServer(); $this->connectObj = $this->getConnectObj(); $this->transport = $this->getTransPort(); $this->protocol = $this->getProtocol(); $this->rpcClient = $this->setRpcClient(); $this->transport->open(); }
const LOGIN_STATUS_SUCCESS = 1; /** @var \vso\phplib\rpc\thrift\account\AccountServiceClient $accountRpcService */ private $accountRpcService; public function __construct() { $this->accountRpcService = new AccountService(); } public function loginStatus($username, $vso_token) { $params = [ 'appid' => Yii::$app->params['Api']['app_id'],
$dependencies = $this->resolveDependencies($dependencies, $reflection); if (!$reflection->isInstantiable()) { throw new NotInstantiableException($reflection->name); } if (empty($config)) { return $reflection->newInstanceArgs($dependencies); } $config = $this->resolveDependencies($config); if (!empty($dependencies) && $reflection->implementsInterface('yii\base\Configurable')) { // set $config as the last parameter (existing one will be overwritten)
public function get($class, $params = [], $config = []) { if (isset($this->_singletons[$class])) { // singleton return $this->_singletons[$class]; } elseif (!isset($this->_definitions[$class])) { return $this->build($class, $params, $config); } $definition = $this->_definitions[$class]; if (is_callable($definition, true)) { $params = $this->resolveDependencies($this->mergeParams($class, $params));
$config = array_merge($definition, $config); $params = $this->mergeParams($class, $params); if ($concrete === $class) { $object = $this->build($class, $params, $config); } else { $object = $this->get($concrete, $params, $config); } } elseif (is_object($definition)) { return $this->_singletons[$class] = $definition; } else { throw new InvalidConfigException('Unexpected object definition type: ' . gettype($definition)); }
private $userGrowthService;//用户成长值服务 public function __construct() { $this->nicknameService = Yii::$container->get('Nickname'); $this->backUserService = Yii::$container->get('BackUser'); $this->userService = Yii::$container->get('User'); $this->userGrowthService = Yii::$container->get('UserGrowth'); } /** * 批量获取用户名对应的昵称 * @param array $usernames 用户名数组
$dependencies = $this->resolveDependencies($dependencies, $reflection); if (!$reflection->isInstantiable()) { throw new NotInstantiableException($reflection->name); } if (empty($config)) { return $reflection->newInstanceArgs($dependencies); } $config = $this->resolveDependencies($config); if (!empty($dependencies) && $reflection->implementsInterface('yii\base\Configurable')) { // set $config as the last parameter (existing one will be overwritten)
public function get($class, $params = [], $config = []) { if (isset($this->_singletons[$class])) { // singleton return $this->_singletons[$class]; } elseif (!isset($this->_definitions[$class])) { return $this->build($class, $params, $config); } $definition = $this->_definitions[$class]; if (is_callable($definition, true)) { $params = $this->resolveDependencies($this->mergeParams($class, $params));
*/ protected function resolveDependencies($dependencies, $reflection = null) { foreach ($dependencies as $index => $dependency) { if ($dependency instanceof Instance) { if ($dependency->id !== null) { $dependencies[$index] = $this->get($dependency->id); } elseif ($reflection !== null) { $name = $reflection->getConstructor()->getParameters()[$index]->getName(); $class = $reflection->getName(); throw new InvalidConfigException("Missing required parameter \"$name\" when instantiating \"$class\"."); } }
list($reflection, $dependencies) = $this->getDependencies($class); foreach ($params as $index => $param) { $dependencies[$index] = $param; } $dependencies = $this->resolveDependencies($dependencies, $reflection); if (!$reflection->isInstantiable()) { throw new NotInstantiableException($reflection->name); } if (empty($config)) { return $reflection->newInstanceArgs($dependencies); }
public function get($class, $params = [], $config = []) { if (isset($this->_singletons[$class])) { // singleton return $this->_singletons[$class]; } elseif (!isset($this->_definitions[$class])) { return $this->build($class, $params, $config); } $definition = $this->_definitions[$class]; if (is_callable($definition, true)) { $params = $this->resolveDependencies($this->mergeParams($class, $params));
$config = array_merge($definition, $config); $params = $this->mergeParams($class, $params); if ($concrete === $class) { $object = $this->build($class, $params, $config); } else { $object = $this->get($concrete, $params, $config); } } elseif (is_object($definition)) { return $this->_singletons[$class] = $definition; } else { throw new InvalidConfigException('Unexpected object definition type: ' . gettype($definition)); }
//第三步:协议签订截止时间判断 if (empty(DemandConstantMap::isOfflineTrade($taskBn)) && ($demandInfo['demands_detail']['agree_end_time'] <= time()) ) { //获取需求协议信息 /** @var \frontend\modules\demand\services\foundation\Protocol $protocolService */ $protocolService = Yii::$container->get('frontend\modules\demand\interfaces\ProtocolInterface'); $protocolInfo = $protocolService->getProtocolByTaskBn($taskBn); if (empty($protocolInfo) || $protocolInfo['publisher_signed_status'] == Protocol::PROTOCOL_STATUS_OFF || $protocolInfo['bidder_signed_status'] == Protocol::PROTOCOL_STATUS_OFF ) { return [
//旧的导入的数据不作处理 $oldDemand = Import::isImported($taskBn); if (!empty($oldDemand)) { return ['ret' => true, 'msg' => '']; } //是否满足需求流标关闭需求的条件 $isAbleCloseDemand = $this->isAbleCloseDemand($taskBn); if ($isAbleCloseDemand !== false) { try { //关闭需求 $this->closeDemand($taskBn, $isAbleCloseDemand['data'], $isAbleCloseDemand['status_log_type']); //发送通知消息
// 用于批量获取用户信息 $userArr = []; //自动流标 /** @var \frontend\modules\demand\services\foundation\DemandNoBid $demandNoBidService */ $demandNoBidService = Yii::$container->get('frontend\modules\demand\interfaces\DemandNoBidInterface'); $auto_close_ret = $demandNoBidService->autoCloseDemand($task_bn); if (!$auto_close_ret['ret']) { if (isset($pay_type) && !empty($pay_type) && $pay_type == 'wz_pay') { Tools::redirect_to_url($wzpay_error_url . "?msg=" . $auto_close_ret['msg']); } else { Tools::redirect_to_url( Yii::$app->urlManager->createUrl(['/common/message/index', 'msg' => $auto_close_ret['msg']])
$args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
{ try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
'views' => ['class' => 'task\libs\ViewsPanel'], ], ]; } $application = new yii\web\Application($config); $application->run();
$_GET = [ 'bn' => '8939113994594', ];