Commit 8c125d65 authored by rlgy's avatar rlgy

update

parent 1c1229e8
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-7-24
* Time: 下午2:13
*/
namespace common\business;
use common\service\zhaobi\ZhaobiService;
class ZhaobiBusiness
{
/**
* @param integer $uid
* @param string $codetype
* @param integer $code
* @param string $type
* @return array
*/
public static function validateCode($uid, $codetype, $code, $type)
{
$service = new ZhaobiService();
$params = [
'uid' => $uid,
'codetype' => $codetype,
'code' => $code,
'type' => $type
];
return $service->validatecode($params);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-7-24
* Time: 下午1:53
*/
namespace common\service\zhaobi;
use Yii;
use common\helpers\Curl;
/**
* Class ZhaobiService
* 找币接口
*
* @package common\service\fzmca
*/
class ZhaobiService
{
private $ch = null;
public function __construct()
{
$this->ch = new Curl();
}
public function validatecode($params)
{
$config = Yii::$app->params['service']['ZhaobiService']['validatecode'];
$url = self::urlBuild($config['scheme'], $config['host'], $config['port'], $config['path']);
return $this->send('POST', $url, $params, false);
}
/**
* @param string $method
* @param string $url
* @param array $params
* @param boolean $isRow false:将返回json数据decode
* @return array
*/
private function send($method = 'POST', $url = '', $params = [], $isRow = false)
{
$result = '';
if (strtolower($method) == 'post') {
$this->ch->setPostParams($params);
$result = $this->ch->post($url, $isRow);
} else {
$this->ch->setGetParams($params);
$result = $this->ch->get($url, $isRow);
}
if ($result) {
return $result;
}
return ['code' => -1, 'message' => '请求失败'];
}
/**
* @param string $scheme
* @param string $host
* @param string $port
* @param string $path
* @return string
*/
private static function urlBuild($scheme = 'http', $host = '', $port = '', $path = '')
{
$base = strtolower($scheme) == 'http' ? 'http' : 'https';
$base .= '://' . $host;
$base = ltrim($base, '/');
return $port ? $base . ':' . $port . $path : $base . $path;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment