流量直充
@param string $phoneNum 手机号
@param int $grade 充值数量
@param string $outRechargeId 唯一流水号
@param int $scope 0:全国漫游流量 1:省内流量
@param bool $isProvince 是否分省通道(scope为0时生效)
@param string $reason 充值原因
@return FlowCharge
324775
public function flowCharge($phoneNum, $grade, $outRechargeId, $scope = 0, $isProvince = false, $reason = '')
    {
        return new FlowCharge($phoneNum, $grade, $outRechargeId, $scope, $isProvince, $reason);
    }
761742
protected function buildOperationQueryInterpreter(
            Interpretations\IOperationInterpretation $operationInterpretation,
            IScopeInterpreter $scopeInterpreter,
            O\IEvaluationContext $evaluationContext = null
    ) {
        return new OperationQueryInterpreter($operationInterpretation, $scopeInterpreter, $evaluationContext);
    }
719874
public function getPhoneInfo($bookID, $phoneNumber)
    {
        if (empty($bookID)) {
            return $this->handleError('Empty book id');
        }

        $requestResult = $this->sendRequest('/sms/numbers/info/'.$bookID.'/'.$phoneNumber);

        return $this->handleResult($requestResult);
    }
216202
public function create_evidence_item_grade($grade, $description, $credential_id, $hidden = false){

        if(is_numeric($grade) && intval($grade) >= 0 && intval($grade) <= 100){

            $evidence_item = array(
                "evidence_item" => array(
                    "description" => $description,
                    "category" => "grade",
                    "string_object" => (string) $grade,
                    "hidden" => $hidden
                )
            );

            $result = $this->create_evidence_item($evidence_item, $credential_id);

            return $result;

        } else {
            throw new \InvalidArgumentException("$grade must be a numeric value between 0 and 100.");
        }
    }
1161053
public function createJsBizPackage($totalFee, $outTradeNo, $orderName, $notifyUrl, $wapUrl, $wapName)
    {
        $config = array(
            'mch_id' => $this->mchid,
            'appid' => $this->appid,
            'key' => $this->apiKey,
        );
        $scene_info = array(
            'h5_info' =>array(
                'type'=>'Wap',
                'wap_url'=>$wapUrl,
                'wap_name'=>$wapName,
            )
        );
        $unified = array(
            'appid' => $config['appid'],
            'attach' => 'pay',             //商家数据包，原样返回，如果填写中文，请注意转换为utf-8
            'body' => $orderName,
            'mch_id' => $config['mch_id'],
            'nonce_str' => self::createNonceStr(),
            'notify_url' => $notifyUrl,
            'out_trade_no' => $outTradeNo,
            'spbill_create_ip' => $_SERVER['REMOTE_ADDR'],
            'total_fee' => intval($totalFee * 100),       //单位 转为分
            'trade_type' => 'MWEB',
            'scene_info'=>json_encode($scene_info)
        );
        $unified['sign'] = self::getSign($unified, $config['key']);
        $responseXml = self::curlPost('https://api.mch.weixin.qq.com/pay/unifiedorder', self::arrayToXml($unified));
        $unifiedOrder = simplexml_load_string($responseXml, 'SimpleXMLElement', LIBXML_NOCDATA);
        if ($unifiedOrder->return_code != 'SUCCESS') {
            die($unifiedOrder->return_msg);
        }
        if($unifiedOrder->mweb_url){
            return $unifiedOrder->mweb_url;
        }
        exit('error');
    }
446405
public function reportItem($type, Model $model, $id, $reason = null, $user_id = null) {
        $report = ClassRegistry::init('Admin.ItemReport');

        // Validate type
        if (!$report->enum('type', $type)) {
            throw new InvalidArgumentException(__d('admin', 'Invalid item report type'));
        }

        // Get model ID if null
        if (!$id) {
            $id = $model->id;
        }

        // Get logged in user ID
        if (!$user_id) {
            $user_id = $this->Auth->user('id');
        }

        // Validate record
        $result = $this->getRecordById($model, $id);

        if (!$result) {
            throw new NotFoundException();
        }

        return $report->reportItem(array(
            'reporter_id' => $user_id,
            'type' => $type,
            'model' => ($model->plugin ? $model->plugin . '.' : '') . $model->name,
            'foreign_key' => $id,
            'item' => $result[$model->alias][$model->displayField],
            'reason' => $reason
        ));
    }
766757
public static function create_new($definitionid, $raterid, $itemid) {
        global $DB;
        $instance = new stdClass();
        $instance->definitionid = $definitionid;
        $instance->raterid = $raterid;
        $instance->itemid = $itemid;
        $instance->status = self::INSTANCE_STATUS_INCOMPLETE;
        $instance->timemodified = time();
        $instance->feedbackformat = FORMAT_MOODLE;
        $instanceid = $DB->insert_record('grading_instances', $instance);
        return $instanceid;
    }
554023
protected function buildRequestQueryInterpreter(
            Interpretations\IRequestInterpretation $requestInterpretation,
            IScopeInterpreter $scopeInterpreter,
            O\IEvaluationContext $evaluationContext = null
    ) {
        return new RequestQueryInterpreter($requestInterpretation, $scopeInterpreter, $evaluationContext);
    }
482841
public function validate($number, $callback = null, $account = null)
    {
        if (! starts_with($number, '2547')) {
            throw new InvalidArgumentException('The subscriber number must start with 2547');
        }

        $time = Carbon::now()->format('YmdHis');
        $configs = (new ConfigurationRepository)->useAccount($account);

        $shortCode = $configs->getAccountKey('lnmo.shortcode');
        $passkey   = $configs->getAccountKey('lnmo.passkey');
        $callback  = $configs->getAccountKey('lnmo.callback');

        $defaultCallback = $configs->getAccountKey('id_validation_callback');
        $initiator = $configs->getAccountKey('initiator');

        $body = [
            'Initiator'         => $initiator,
            'BusinessShortCode' => $shortCode,
            'Password'          => $this->getPassword($shortCode, $passkey, $time),
            'Timestamp'         => $time,
            'TransactionType'   => 'CheckIdentity',
            'PhoneNumber'       => $number,
            'CallBackURL'       => $callback ?: $defaultCallback,
            'TransactionDesc'   => ' '
        ];

        try {
            $response = $this->makeRequest(
                $body,
                Core::instance()->getEndpoint(MPESA_ID_CHECK, $account),
                $account
            );

            return json_decode($response->getBody());
        } catch (RequestException $exception) {
            return json_decode($exception->getResponse()->getBody());
        }
    }
1184816
public function resolve($object, array $args, $context, ResolveInfo $info)
    {
        // Get the args
        $id = $args['ID'];
        $rollbackVersion = $args['ToVersion'];

        // Pull the latest version of the record
        /** @var Versioned|DataObject $record */
        $record = Versioned::get_latest_version($this->getDataObjectClass(), $id);

        // Assert permission
        $user = $context['currentUser'];
        if (!$record->canEdit($user)) {
            throw new InvalidArgumentException('Current user does not have permission to roll back this resource');
        }

        // Perform the rollback
        $record = $record->rollbackRecursive($rollbackVersion);

        return $record;
    }
954004
public function hasManyThrough($model, $through, $foreignKey = '', $throughKey = '', $localKey = '')
    {
        // 记录当前关联信息
        $model      = $this->parseModel($model);
        $through    = $this->parseModel($through);
        $localKey   = $localKey ?: $this->getPk();
        $foreignKey = $foreignKey ?: $this->getForeignKey($this->name);
        $throughKey = $throughKey ?: $this->getForeignKey($through);

        return new HasManyThrough($this, $model, $through, $foreignKey, $throughKey, $localKey);
    }
461334
public static function factory($level = Constants::QR_ECLEVEL_L, $size = 3, $margin = 4)
    {
        $enc = new QRencode();
        $enc->size = $size;
        $enc->margin = $margin;

        switch ($level.'') {
            case '0':
            case '1':
            case '2':
            case '3':
                    $enc->level = $level;
                break;
            case 'l':
            case 'L':
                    $enc->level = Constants::QR_ECLEVEL_L;
                break;
            case 'm':
            case 'M':
                    $enc->level = Constants::QR_ECLEVEL_M;
                break;
            case 'q':
            case 'Q':
                    $enc->level = Constants::QR_ECLEVEL_Q;
                break;
            case 'h':
            case 'H':
                    $enc->level = Constants::QR_ECLEVEL_H;
                break;
        }

        return $enc;
    }
531447
protected static function transform_grade(grade_grade $gg, context $context, bool $ishistory) {
        $gi = $gg->load_grade_item();
        $timemodified = $gg->timemodified ? transform::datetime($gg->timemodified) : null;
        $timecreated = $gg->timecreated ? transform::datetime($gg->timecreated) : $timemodified; // When null we use timemodified.

        $filearea = $ishistory ? GRADE_HISTORY_FEEDBACK_FILEAREA : GRADE_FEEDBACK_FILEAREA;
        $itemid = $ishistory ? $gg->historyid : $gg->id;
        $subpath = $ishistory ? get_string('feedbackhistoryfiles', 'core_grades') : get_string('feedbackfiles', 'core_grades');

        $pathtofiles = [
            get_string('grades', 'core_grades'),
            $subpath
        ];
        $gg->feedback = writer::with_context($gg->get_context())->rewrite_pluginfile_urls(
            $pathtofiles,
            GRADE_FILE_COMPONENT,
            $filearea,
            $itemid,
            $gg->feedback
        );

        return [
            'gradeobject' => $gg,
            'item' => $gi->get_name(),
            'grade' => $gg->finalgrade,
            'grade_formatted' => grade_format_gradevalue($gg->finalgrade, $gi),
            'feedback' => format_text($gg->feedback, $gg->feedbackformat, ['context' => $context]),
            'information' => format_text($gg->information, $gg->informationformat, ['context' => $context]),
            'timecreated' => $timecreated,
            'timemodified' => $timemodified,
        ];
    }
797370
protected function buildRequestQuery(
            Queries\IScope $scope,
            Queries\IRequest $request
    ) {
        return new Queries\RequestQuery($scope, $request);
    }
265831
public function notice(Request $request, &$paymentId, &$money, &$message, &$payId)
    {
        $xml = $request->getRawBody();

        //如果返回成功则验证签名
        try {
            $params = $this->convertXmlToArray($xml);
            $paymentId = $params['out_trade_no'];
            $money = $params['total_fee'];
            $message = $params['return_code'];
            $payId = $params['transaction_id'];
            if ($params['return_code'] == 'SUCCESS') {
                if ($params['sign'] == $this->createSign($params)) {
                    echo '<xml>
  <return_code><![CDATA[SUCCESS]]></return_code>
  <return_msg><![CDATA[OK]]></return_msg>
</xml>';
                    return true;
                }
            }
        } catch (\Exception $e) {

        }
        echo '<xml>
  <return_code><![CDATA[FAIL]]></return_code>
  <return_msg><![CDATA[FAIL]]></return_msg>
</xml>';
        return false;
    }
754437
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $container = ContainerScope::getContainer();
        if (empty($container)) {
            throw new ScopeException("Unable to run SpiralCommand outside of IoC scope.");
        }

        $reflection = new \ReflectionMethod($this, 'perform');
        $reflection->setAccessible(true);

        /** @var ResolverInterface $resolver */
        $resolver = $container->get(ResolverInterface::class);

        try {
            list($this->input, $this->output) = [$input, $output];

            //Executing perform method with method injection
            return $reflection->invokeArgs($this, $resolver->resolveArguments(
                $reflection,
                compact('input', 'output')
            ));
        } finally {
            list($this->input, $this->output) = [null, null];
        }
    }
1372064
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope) : Type {
        $returnType = $methodReflection->getReturnType();
        $origReturnDescribe = $returnType->describe();
        $error = false;

        if ($returnType instanceof ObjectType) {
            if ($methodCall->var instanceof Variable) {
                $scopedType = $scope->getType($methodCall->var);
                if ($class = $this->findSubclass($scopedType, static::$className))
                    $returnType = new ObjectType($class.'DAO');
            } else $error = true(echoPre('(1) '.simpleClassName(static::$className).'->'.$methodCall->name.'() cannot resolve callee of instance method call: class($methodCall->var) = '.get_class($methodCall->var)));
        } else     $error = true(echoPre('(2) '.simpleClassName(static::$className).'->'.$methodCall->name.'() encountered unexpected return type: '.get_class($returnType).' => '.$returnType->describe()));

        $returnDescribe = $returnType->describe();

        if (0 || $error) echoPre('call of: '.simpleClassName(static::$className).'->'.$methodCall->name.'()  in: '.$this->getScopeDescription($scope).'  shall return: '.$returnDescribe.($returnDescribe==$origReturnDescribe ? ' (pass through)' : ' (was '.$origReturnDescribe.')'));
        return $returnType;
    }