设置所属行业
@param array $data
@return bool
@throws \yii\web\HttpException
768071
public function setTemplateIndustry(array $data)
    {
        $result = $this->httpRaw(self::WECHAT_TEMPLATE_INDUSTRY_SET_PREFIX, $data, [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['errcode']) && !$result['errcode'];
    }
181479
protected function sendCustomMessage(array $data)
    {
        $result = $this->httpRaw(self::WECHAT_CUSTOM_MESSAGE_SEND_URL . 'access_token=' . $this->getAccessToken(), $data);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok';
    }
1320221
public function getOrderByFilter(array $data)
    {
        $result = $this->wechat->httpRaw(self::WECHAT_ORDER_FILTER_GET_PREFIX, $data, [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success' ? $result['order_list'] : false;
    }
609940
public function data(array $data)
    {
        foreach ($data as $name => $rows) {
            // 允许直接传入文案，不传颜色，如 ['first' => '恭喜你购买成功！']
            if (!is_array($rows)) {
                $data[$name] = ['value' => $rows];
            }

            // 空值则显示默认值
            if ($name !== 'remark' && !$this->wei->isPresent($data[$name]['value'])) {
                $data[$name]['value'] = '-';
            }
        }

        $this->request['data'] = $data;

        return $this;
    }
1214057
public function batchSyncUser(array $data)
    {
        $result = $this->httpRaw(self::WECHAT_USER_BATCH_SYNC_PREFIX, $data, [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok' ? $result['jobid'] : $this->dump($result);
    }
598046
public function execute($data = null)
    {
        if (class_exists(DebuggerHelper::class)) {
            DebuggerHelper::disableConsole();
        }

        // Simple Json Error Handler
        $this->controller->getContainer()
            ->get('error.handler')
            ->addHandler(function ($exception) {
                /** @var $exception \Exception|\Throwable */
                $data = [
                    'error' => !WINDWALKER_DEBUG ? $exception->getMessage() : sprintf(
                        '#%d %s - File: %s (%d)',
                        $exception->getCode(),
                        $exception->getMessage(),
                        $exception->getFile(),
                        $exception->getLine()
                    ),
                ];

                $response = (new JsonResponse($data))->withStatus(
                    ErrorManager::normalizeCode($exception->getCode()),
                    ErrorManager::normalizeMessage($exception->getMessage())
                );

                $this->controller
                    ->app
                    ->getServer()
                    ->getOutput()
                    ->respond($response);
            }, 'default');

        $response = $data->response;

        $this->controller->setResponse(new JsonResponse(null, $response->getStatusCode(), $response->getHeaders()));

        $result = $this->next->execute($data);

        // Check is already json string.
        if (is_array($result) || is_object($result)) {
            return json_encode($result);
        }

        return $result;
    }
231107
public function updateProductStatus(array $data)
    {
        $result = $this->wechat->httpRaw(self::WECHAT_PRODUCT_STATUS_UPDATE_PREFIX, $data, [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success';
    }
181171
public function execute($data)
    {
        $client = null;
        $bindId = $data['bind_id'] ?? null;
        if ($bindId != null) { // 绑定
            $client = $this->bindPool[$bindId]['client'] ?? null;
            $sql = strtolower($data['sql']);
            if ($sql != 'begin' && $client == null) {
                throw new Exception('error mysql affairs not begin.');
            }
        }
        if ($client == null) {
            if (count($this->pool) == 0) { // 代表目前没有可用的连接
                $this->prepareOne();
                $this->commands->push($data);
                return;
            } else {
                $client = $this->pool->shift();
                if ($client->isClose ?? false) {
                    $this->reconnect($client);
                    $this->commands->push($data);
                    return;
                }
                
                if ($bindId != null) { // 添加绑定
                    $this->bindPool[$bindId]['client'] = $client;
                }
            }
        }
        
        $sql = $data['sql'];
        $client->query($sql, function ($client, $result) use ($data) {
            if ($result === false) {
                if ($client->errno == 2006 || $client->errno == 2013) { // 断线重连
                    $this->reconnect($client);
                    if (! isset($data['bind_id'])) { // 非事务可以重新执行
                        $this->commands->unshift($data);
                    }
                    return;
                    // 发生错误
                } else {
                    // 事务出错不需要自动回滚，否则会带来新问题，调整为手工回滚（modified by xudianyang）
                    // if (isset($data['bind_id'])) {
                    // $data['sql'] = 'rollback';
                    // $this->commands->push($data);
                    // }
                    // 设置错误信息
                    $data['result']['error'] = "[mysql]:" . $client->error . "[sql]:" . $data['sql'];
                }
            }
            $sql = strtolower($data['sql']);
            if ($sql == 'begin') {
                $data['result'] = $data['bind_id'];
            } else {
                $data['result']['client_id'] = $client->client_id;
                $data['result']['result'] = $result;
                $data['result']['affected_rows'] = $client->affected_rows;
                $data['result']['insert_id'] = $client->insert_id;
            }
            // 给worker发消息
            $this->asynManager->sendMessageToWorker($this, $data);
            
            // 不是绑定的连接就回归连接
            if (! isset($data['bind_id'])) {
                $this->pushToPool($client);
            } else { // 事务
                $bindId = $data['bind_id'];
                if ($sql == 'commit' || $sql == 'rollback') { // 结束事务
                    $this->freeBind($bindId);
                }
            }
        });
    }
453712
public function run()
    {
        if (yii::$app->getRequest()->getIsPost()) {//只允许post删除
            $id = yii::$app->getRequest()->get($this->paramSign, null);
            $param = yii::$app->getRequest()->post($this->paramSign, null);
            if($param !== null){
                $id = $param;
            }

            if( yii::$app->getRequest()->getIsAjax() ){
                yii::$app->getResponse()->format = $this->ajaxResponseFormat;
            }
            if (! $id) {
                throw new BadRequestHttpException(yii::t('app', "Id doesn't exit"));
            }
            if(is_array($id)){
                $ids = $id;
            }else{
                $ids = explode(',', $id);
            }

            $errorIds = [];
            /* @var $model yii\db\ActiveRecord */
            $model = null;
            foreach ($ids as $one) {
                $model = call_user_func([$this->modelClass, 'findOne'], $one);
                if ($model) {
                    $model->setScenario($this->scenario);
                    if (! $result = $model->delete()) {
                        $errorIds[] = $one;
                    }
                }
            }
            if (count($errorIds) == 0) {
                if( !yii::$app->getRequest()->getIsAjax() ) return $this->controller->redirect(yii::$app->getRequest()->headers['referer']);
                return ['status'=>true,'msg'=>yii::t('app','Success')];
            } else {
                $errors = $model->getErrors();
                $err = '';
                foreach ($errors as $v) {
                    $err .= $v[0];
                }
                if ($err != '') {
                    $err = '.' . $err;
                }
                throw new UnprocessableEntityHttpException('id ' . implode(',', $errorIds) . $err);
            }
        } else {
            throw new MethodNotAllowedHttpException(yii::t('app', "Delete must be POST http method"));
        }
    }
362394
public function getUpStreamMessageHour(array $data)
    {
        $result = $this->wechat->httpRaw(self::WECHAT_UP_STREAM_MESSAGE_HOUR_GET_PREFIX, $data, [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['list']) ? $result['list'] : false;
    }
1335270
public function getUserReadHour(array $data)
    {
        $result = $this->wechat->httpRaw(self::WECHAT_USER_READ_HOUR_GET_PREFIX, $data, [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['list']) ? $result['list'] : false;
    }
660410
public function execute($data = null)
    {
        $this->controller->setResponse(new HtmlResponse(
            '',
            $data->response->getStatusCode(),
            $data->response->getHeaders()
        ));

        $result = $this->next->execute($data);

        $this->controller->setRedirect(null);

        return $result;
    }
310626
public function updateUserGroup(array $data)
    {
        $result = $this->httpRaw(self::WECHAT_MEMBER_GROUP_UPDATE_PREFIX, $data, [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok';
    }
410088
public function getUserShare(array $data)
    {
        $result = $this->wechat->httpRaw(self::WECHAT_USER_SHARE_GET_PREFIX, $data, [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['list']) ? $result['list'] : false;
    }
1007930
public function create(array $data)
    {
        if ( $this->validator->with($data)->passes() )
        {
            $data['permissions'] = explode(',', $data['permissions']);
            $this->permission->create($data);
            return true;
        }
        else
        {
            return false;
        }
    }
1147203
public function update($data) {
        #移除表中不存在字段
        $data = $this->connection->filterTableField($data);
        foreach ($data as $k => $v) {
            $this->build()->bindExpression('set', $k);
            $this->build()->bindParams('values', $v);
        }
        if (!$this->build()->getBindExpression('where')) {
            #有主键时使用主键做条件
            $pri = $this->connection->getPrimaryKey();
            if (isset($data[$pri])) {
                $this->where($pri, '=', $data[$pri]);
            }
        }
        return $this->connection->execute($this->build()->update(), $this->build()->getUpdateParams());
    }
134857
public function delete($data = null)
    {
        // 分析查询表达式
        $options = $this->parseExpress();
        $pk      = $this->getPk($options);
        if (isset($options['cache']) && is_string($options['cache']['key'])) {
            $key = $options['cache']['key'];
        }

        if (!is_null($data) && true !== $data) {
            if (!isset($key) && !is_array($data)) {
                // 缓存标识
                $key = 'think:' . $options['table'] . '|' . $data;
            }
            // AR模式分析主键条件
            $this->parsePkWhere($data, $options);
        } elseif (!isset($key) && is_string($pk) && isset($options['where']['AND'][$pk])) {
            $key = $this->getCacheKey($options['where']['AND'][$pk], $options, $this->bind);
        }

        if (true !== $data && empty($options['where'])) {
            // 如果条件为空 不进行删除操作 除非设置 1=1
            throw new Exception('delete without condition');
        }
        // 生成删除SQL语句
        $sql = $this->builder->delete($options);
        // 获取参数绑定
        $bind = $this->getBind();
        if ($options['fetch_sql']) {
            // 获取实际执行的SQL语句
            return $this->connection->getRealSql($sql, $bind);
        }

        // 执行操作
        $result = $this->execute($sql, $bind);
        if ($result) {
            if (!is_array($data) && is_string($pk) && isset($key) && strpos($key, '|')) {
                list($a, $val) = explode('|', $key);
                unset($a);
                $item[$pk]     = $val;
                $data          = $item;
            }
            $options['data'] = $data;
            $this->trigger('after_delete', $options);
        }
        return $result;
    }