Authored by 郝肖肖

日韩馆 你可能喜欢的接口

... ... @@ -36,7 +36,7 @@ class RecomData
$param['yh_channel'] = $channel;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param, 3600);
return Yohobuy::get(Yohobuy::API_URL, $param, 300);
}
/**
... ... @@ -55,7 +55,7 @@ class RecomData
$param['yh_channel'] = '3';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param, 3600);
return Yohobuy::get(Yohobuy::API_URL, $param, 300);
}
/**
... ... @@ -74,7 +74,27 @@ class RecomData
$param['yh_channel'] = '4';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param, 3600);
return Yohobuy::get(Yohobuy::API_URL, $param, 300);
}
/**
* 活动模板-商品列表接口
* @param type int $templateId 模板id
* @param type string $order 排序
* @param type int $page 页码
* @param type int $limit 条数
* @return type []
*/
public static function newPreference($templateId, $order = '', $page = 1, $limit = 50)
{
$param = Yohobuy::param();
$param['template_id'] = intval($templateId);
$param['order'] = $order;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::SERVICE_URL . 'operations/api/v5/activitytemplate/getProduct', $param, 300);
}
}
... ...
... ... @@ -163,5 +163,47 @@ class RecomController extends AbstractAction
$this->_view->display('maylikelife', $data);
}
/**
* 日韩馆-你可能喜欢的
*/
public function newPreferenceAction()
{
$data = array();
do {
/* 判断是否是AJAX请求 */
if (!$this->isAjax()) {
break;
}
//模板id
$templateId = $this->get('template_id', 0);
/* 创意生活只有一页数据 */
$page = $this->get('page', 1);
if (intval($page) > 1 || empty($templateId)) {
break;
}
/* 取可能喜欢的数据 */
$recom = json_decode(RecomData::newPreference($templateId), true);
/* 构建人气单品数据 */
if (empty($recom) || empty($recom['data']['product_list'])) {
break;
}
$data = array();
$build = array();
$build['show'] = true;
foreach ($recom['data']['product_list'] as $value) {
$build['goods'][] = Helpers::formatProduct($value, true, false, false);
}
$data['goodsContainer'][] = $build;
} while (false);
$this->_view->display('maylikelife', $data);
}
}
... ...