Authored by Rock Zhang

完成第三方登录,完善一些缺失的接口(品牌,品类)

... ... @@ -16,6 +16,7 @@ class Yohobuy
const API_URL = 'http://api2.open.yohobuy.com/';
const SERVICE_URL = 'http://service.api.yohobuy.com/';
const YOHOBUY_URL = 'http://www.yohobuy.com/';
/**
* 私钥列表
... ...
... ... @@ -49,4 +49,81 @@ class BrandData
return Yohobuy::get(Yohobuy::SERVICE_URL.'operations/api/v5/resource/get', $param);
}
/**
* 获取品牌介绍
*
* @param integer $brandId 品牌ID
* @return array 品牌介绍信息
*/
public static function getBrandIntro($brandId)
{
// 构建必传参数
$param = Yohobuy::param();
$param['brand_id'] = '$brandId';
$param['method'] = 'app.brand.getBrandIntro';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取品牌banner数据
* @param integer $brandId 品牌ID
* @return array banner数据
*/
public static function getBrandBanner($brandId)
{
// 构建必传参数
$param = Yohobuy::param();
$param['brand_id'] = '$brandId';
$param['method'] = 'app.brand.banner';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 查询品牌数据
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer $brand 品牌Id
* @param integer $sort 品类Id
* @param integer $color 颜色Id
* @param integer $size 尺码Id
* @param string $price 价格
* @param string $p_d 折扣
* @param string $order 排序方式,默认s_t_desc
* @param integer $limit 限制查询的数目,默认为60
* @param integer $page 查询第几页,默认为第1页
* @param integer $channel 表示频道号,1位男生,2为女生
* @return array 品牌数据
*/
public static function selectBrandDetail($gender, $brand, $sort, $color, $size, $price, $p_d, $channel = 1, $order = 's_t_desc', $limit = 60, $page = 1)
{
$selectItems = array(
'gender' => $gender,
'brand' => $brand,
'sort' => $sort,
'color' => $color,
'size' => $size,
'price' => $price,
'p_d' => $p_d
);
// 拉取筛选参数
$queriedParams = array_filter($selectItems, function($v) {return $v !== null;});
// 构建必传参数
$param = Yohobuy::param();
$param['method'] = 'app.search.brand';
$param['page'] = $page;
$param['limit'] = $limit;
$param['yh_channel'] = $channel;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -30,4 +30,46 @@ class ClassData
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 查询品类商品数据
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer $brand 品牌Id
* @param integer $sort 品类Id
* @param integer $color 颜色Id
* @param integer $size 尺码Id
* @param string $price 价格
* @param string $p_d 折扣
* @param string $order 排序方式,默认s_t_desc
* @param integer $limit 限制查询的数目,默认为60
* @param integer $page 查询第几页,默认为第1页
* @param integer $channel 表示频道号,1位男生,2为女生
* @return array 品类商品数据
*/
public static function selectBrandDetail($gender, $brand, $sort, $color, $size, $price, $p_d, $channel = 1, $order = 's_t_desc', $limit = 60, $page = 1)
{
$selectItems = array(
'gender' => $gender,
'brand' => $brand,
'sort' => $sort,
'color' => $color,
'size' => $size,
'price' => $price,
'p_d' => $p_d
);
// 拉取筛选参数
$queriedParams = array_filter($selectItems, function($v) {return $v !== null;});
// 构建必传参数
$param = Yohobuy::param();
$param['method'] = 'app.search.category';
$param['page'] = $page;
$param['limit'] = $limit;
$param['yh_channel'] = $channel;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -50,6 +50,24 @@ class BackData
}
/**
* 根据邮箱验证码修改密码(调用www.yohobuy.com接口)
*
* @param string $pwd 新密码
* @param string $code 邮箱验证码
* @return array 返回状态数据
*/
public static function modifyPasswordByEmail($pwd, $code)
{
$param['pwd'] = $pwd;
$param['re-input'] = $pwd;
$param['code'] = $code;
return Yohobuy::post(Yohobuy::YOHOBUY_URL.'passport/back/update', $param);
}
/**
* 通过手机找回密码
*
* @param string $mobile 手机号
... ...
<?php
namespace LibModels\Wap\Passport;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
use Api\Yohobuy;
use Api\Sign;
class LoginData
{
/**
* 第三方登录接口(包括alipay,qq,sina)
* @param string $nickname 姓名
* @param string $openId 第三方唯一识别码
* @param string $sourceType 登录方式
* @return array 登录返回结果
*/
public static function signinByOpenID($nickname, $openId, $sourceType)
{
// 构建必传参数
$param = Yohobuy::param();
$param['method'] = 'app.passport.signinByOpenID';
$param['openId'] = $openId;
$param['source_type'] = $sourceType;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -70,14 +70,14 @@ class NewsaleData
/**
* 筛选新品到着、折扣专区商品
*
* @param string gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer $brand 品牌Id
* @param integer $sort 品类Id
* @param integer $color 颜色Id
* @param integer $size 尺码Id
* @param string $price 价格
* @param string $p_d 折扣
* @param string $channel 1表示男, 2表示女
* @param integer $channel 表示频道号,1位男生,2为女生
* @param integer $dayLimit 限制读取多少天,默认为1天
* @param integer $limit 查询返回的最大限制数, 默认为50
* @param integer $page 分页第几页, 默认第1页
... ... @@ -92,14 +92,14 @@ class NewsaleData
'color' => $color,
'size' => $size,
'price' => $price,
'p_d' => $p_d
'p_d' => $p_d,
'dayLimit' => $dayLimit
);
// 拉取筛选参数
$queriedParams = array_filter($selectItems, function($v) {return $v !== null;});
$param = Yohobuy::param();
$param['method'] = 'app.search.newProduct';
$param['dayLimit'] = $dayLimit;
$param['page'] = $page;
$param['limit'] = $limit;
$param['yh_channel'] = $channel;
... ...
... ... @@ -27,10 +27,10 @@ class Helpers
* @param array|string $keys 指定键值,数组或者字符串
* @return array 获取的数据
*/
/*public static function array_get($array, $keys)
public static function array_get($array, $keys)
{
return array_intersect_key($array, array_flip((array) $keys));
}
*/
}
\ No newline at end of file
... ...
... ... @@ -15,5 +15,5 @@ return array(
// 访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http
'transport' => 'http',
// 页面跳转同步通知页面路径 (需http://格式的完整路径,不允许加?id=123这类自定义参数)
'return_url' => SITE_MAIN . '/passport/sso/partnercallback/partner/alipay',
'return_url' => SITE_MAIN . '/passport/login/alipaycallback',
);
... ...
... ... @@ -73,7 +73,7 @@ class Call extends Factory
if (is_array($token) && isset($token['openid']))
{
$this->qc = new QC($token['access_token'], $token['openid']);
$this->qc = new \QC($token['access_token'], $token['openid']);
$userInfo = $this->qc->get_user_info();
... ... @@ -110,7 +110,7 @@ class Call extends Factory
if (is_array($token) && isset($token['openid']))
{
$this->qc = new QC($token['access_token'], $token['openid']);
$this->qc = new \QC($token['access_token'], $token['openid']);
$friends = $this->qc->get_idollist($params);
... ... @@ -138,7 +138,7 @@ class Call extends Factory
if (is_array($token) && isset($token['openid']))
{
$this->qc = new QC($token['access_token'], $token['openid']);
$this->qc = new \QC($token['access_token'], $token['openid']);
$param = array('title' => '来自YOHO.CN的分享', 'url' => $link, 'summary' => $content,
'images' => $image, 'site' => 'yoho.cn', 'fromurl' => SITE_MAIN,);
... ...
<?php
defined('SITE_MAIN') || define('SITE_MAIN', 'http://www.yoho.cn');
defined('SITE_MAIN') || define('SITE_MAIN', $_SERVER['HTTP_HOST']);
return array(
'appid' => '100229394',
'appkey' => 'c0af9c29e0900813028c2ccb42021792',
'callback' => SITE_MAIN . '/passport/sso/partnercallback/partner/qqconnect',
'callback' => SITE_MAIN . '/passport/login/qqcallback',
'scope' => 'get_user_info,add_share,upload_pic,get_idollist,get_fanslist',
'errorReport' => false,
);
\ No newline at end of file
... ...
<?php
defined('SITE_MAIN') || define('SITE_MAIN', 'http://www.yoho.cn');
defined('SITE_MAIN') || define('SITE_MAIN', $_SERVER['HTTP_HOST']);
return array(
'appId' => '2707954749',
'appKey' => '431730e25a8a0983964a740731c3cb7d',
'appCallbackUrl' => SITE_MAIN . '/passport/sso/partnercallback/partner/sinaweibo',
'appCallbackUrl' => SITE_MAIN . '/passport/login/sinacallback',
);
\ No newline at end of file
... ...
... ... @@ -2,6 +2,7 @@
use Action\AbstractAction;
use LibModels\Wap\Passport\BackData;
use Hood\Core\Security\AuthCode;
/**
* 频道选择
*/
... ... @@ -37,7 +38,7 @@ class BackController extends AbstractAction
// 发送邮箱验证码
$result = BackData::sendCodeToEmail($email);
$this->echoJson($result);
$this->returnJson($result['code'], $result['message'], $result['data']);
}
}
... ... @@ -63,13 +64,15 @@ class BackController extends AbstractAction
*/
public function passwordByEmailAction()
{
// host是www.yohobuy.com ,只需要code,然后再输入新密码即可
$code = $this->get('code', '');
if($this->isAjax())
{
$pwd = $this->get('pwd', '');
$code = $this->get('code', '');
// 根据邮箱修改密码(接口待定)
// $result = BackData::validateMobileCode($mobile, $code, $area);
$data = BackData::modifyPasswordByEmail($pwd, $code);
$this->echoJson($data);
$this->returnJson(200, '成功', '');// 前端不需要判断结果
}
}
... ... @@ -127,7 +130,7 @@ class BackController extends AbstractAction
// 发送手机验证码
$result = BackData::sendCodeToMobile($mobile, $area);
$this->echoJson($result);
$this->returnJson($result['code'], $result['message'], $result['data']);
}
}
... ... @@ -152,7 +155,7 @@ class BackController extends AbstractAction
/**
* 校验手机验证码
*
* @return array 校验手机验证码的结果
* @return array 校验手机验证码的结果(token)
*/
public function mobilecodeValidateAction()
{
... ... @@ -165,7 +168,7 @@ class BackController extends AbstractAction
// 校验手机验证码
$result = BackData::validateMobileCode($mobile, $code, $area);
$this->echoJson($data);
$this->returnJson($result['code'], $result['message'], $result['data']);
}
}
... ... @@ -212,7 +215,7 @@ class BackController extends AbstractAction
// 根据手机验证码修改密码
$result = BackData::modifyPasswordByMobile($mobile, $token, $newpwd, $area);
$this->echoJson($data);
$this->returnJson($result['code'], $result['message'], $result['data']);
}
}
}
\ No newline at end of file
... ...
... ... @@ -2,6 +2,7 @@
use Action\AbstractAction;
use Plugin\Partner\Factory;
use LibModels\Wap\Passport\LoginData;
class LoginController extends AbstractAction
{
... ... @@ -75,4 +76,83 @@ class LoginController extends AbstractAction
exit();
}
/**
* 支付宝账号登录:回调方法
*/
public function alipaycallbackAction()
{
$nickname = '';
$alipay = Factory::create('alipay');
$access = $alipay->getAccessToken();
if (!isset($_GET['real_name']))
{
/* 获取支付宝用户的详细信息 */
$userInfo = $alipay->getUserInfo($access);
if ($userInfo && $userInfo['is_success'] === 'T' && isset($userInfo['response']['user_info']['user_name']))
{
$nickname = $userInfo['response']['user_info']['user_name'];
$alipayEmail = $userInfo['response']['user_info']['email'];
}
var_dump($userInfo);
}
else
{
$nickname = $_GET['real_name'];
$alipayEmail = isset($_GET['email']) ? $_GET['email'] : '';
}
var_dump($access);
$result = LoginData::signinByOpenID($nickname, $access['user_id'], 'qq');
if($result['code'] == 200)
{
echo '登陆成功';
}
}
/**
* QQ账号登录:回调方法
*/
public function qqcallbackAction()
{
$qqconnect = Factory::create('qqconnect');
$access = $qqconnect->getAccessToken();
/* 获取QQ腾讯用户的详细信息 */
$partnerInfo = $qqconnect->getUserInfo($access);
var_dump($access, $partnerInfo);
if ($partnerInfo && is_array($partnerInfo))
{
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq');
if($result['code'] == 200)
{
echo '登陆成功';
}
}
}
/**
* 新浪微博账号登录:回调方法
*/
public function sinacallbackAction()
{
$sina = Factory::create('sina');
$access = $sina->getAccessToken();
/* 获取QQ腾讯用户的详细信息 */
$partnerInfo = $sina->getUserInfo($access);
var_dump($access, $partnerInfo);
if ($partnerInfo && is_array($partnerInfo))
{
$result = LoginData::signinByOpenID($partnerInfo['screen_name'], $access['uid'], 'sina');
if($result['code'] == 200)
{
echo '登陆成功';
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -36,7 +36,7 @@ class NewsaleController extends AbstractAction
/**
* Ajax方式筛选新品到着商品
* Ajax方式筛选新品到着、折扣专区商品
*
* @return array 根据指定条件筛选之后的商品
*/
... ... @@ -56,9 +56,9 @@ class NewsaleController extends AbstractAction
$limit = $this->get('limit', 50);
$page = $this->get('page', 1);
$data = Newsale::selectNewProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit, $limit, $page);
$data = Newsale::selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit, $limit, $page);
$this->echoJson($data);
$this->returnJson(200, '获取成功', $data);
}
}
... ... @@ -88,31 +88,4 @@ class NewsaleController extends AbstractAction
$this->_view->display('new', compact('focus', 'products'));
}
/**
* Ajax方式筛选折扣专区商品
*
* @return array 根据指定条件筛选之后的商品
*/
public function selectSaleAction()
{
if($this->isAjax())
{
$gender = $this->get('gender', '1,3');
$brand = $this->get('brand', null);
$sort = $this->get('sort', null);
$color = $this->get('color', null);
$size = $this->get('size', null);
$price = $this->get('price', null);
$p_d = $this->get('p_d', null);
$channel = $this->get('channel', '1');
$dayLimit = $this->get('dayLimit', '1');
$limit = $this->get('limit', 50);
$page = $this->get('page', 1);
$data = Newsale::selectSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit, $limit, $page);
$this->echoJson($data);
}
}
}
\ No newline at end of file
... ...