Authored by 郝肖肖

日韩馆 你可能喜欢的接口

@@ -36,7 +36,7 @@ class RecomData @@ -36,7 +36,7 @@ class RecomData
36 $param['yh_channel'] = $channel; 36 $param['yh_channel'] = $channel;
37 $param['client_secret'] = Sign::getSign($param); 37 $param['client_secret'] = Sign::getSign($param);
38 38
39 - return Yohobuy::get(Yohobuy::API_URL, $param, 3600); 39 + return Yohobuy::get(Yohobuy::API_URL, $param, 300);
40 } 40 }
41 41
42 /** 42 /**
@@ -55,7 +55,7 @@ class RecomData @@ -55,7 +55,7 @@ class RecomData
55 $param['yh_channel'] = '3'; 55 $param['yh_channel'] = '3';
56 $param['client_secret'] = Sign::getSign($param); 56 $param['client_secret'] = Sign::getSign($param);
57 57
58 - return Yohobuy::get(Yohobuy::API_URL, $param, 3600); 58 + return Yohobuy::get(Yohobuy::API_URL, $param, 300);
59 } 59 }
60 60
61 /** 61 /**
@@ -74,7 +74,27 @@ class RecomData @@ -74,7 +74,27 @@ class RecomData
74 $param['yh_channel'] = '4'; 74 $param['yh_channel'] = '4';
75 $param['client_secret'] = Sign::getSign($param); 75 $param['client_secret'] = Sign::getSign($param);
76 76
77 - return Yohobuy::get(Yohobuy::API_URL, $param, 3600); 77 + return Yohobuy::get(Yohobuy::API_URL, $param, 300);
  78 + }
  79 +
  80 + /**
  81 + * 活动模板-商品列表接口
  82 + * @param type int $templateId 模板id
  83 + * @param type string $order 排序
  84 + * @param type int $page 页码
  85 + * @param type int $limit 条数
  86 + * @return type []
  87 + */
  88 + public static function newPreference($templateId, $order = '', $page = 1, $limit = 50)
  89 + {
  90 + $param = Yohobuy::param();
  91 + $param['template_id'] = intval($templateId);
  92 + $param['order'] = $order;
  93 + $param['page'] = $page;
  94 + $param['limit'] = $limit;
  95 + $param['client_secret'] = Sign::getSign($param);
  96 +
  97 + return Yohobuy::post(Yohobuy::SERVICE_URL . 'operations/api/v5/activitytemplate/getProduct', $param, 300);
78 } 98 }
79 99
80 } 100 }
@@ -163,5 +163,47 @@ class RecomController extends AbstractAction @@ -163,5 +163,47 @@ class RecomController extends AbstractAction
163 163
164 $this->_view->display('maylikelife', $data); 164 $this->_view->display('maylikelife', $data);
165 } 165 }
  166 +
  167 + /**
  168 + * 日韩馆-你可能喜欢的
  169 + */
  170 + public function newPreferenceAction()
  171 + {
  172 + $data = array();
  173 + do {
  174 + /* 判断是否是AJAX请求 */
  175 + if (!$this->isAjax()) {
  176 + break;
  177 + }
  178 +
  179 + //模板id
  180 + $templateId = $this->get('template_id', 0);
  181 +
  182 + /* 创意生活只有一页数据 */
  183 + $page = $this->get('page', 1);
  184 + if (intval($page) > 1 || empty($templateId)) {
  185 + break;
  186 + }
  187 +
  188 + /* 取可能喜欢的数据 */
  189 + $recom = json_decode(RecomData::newPreference($templateId), true);
  190 +
  191 + /* 构建人气单品数据 */
  192 + if (empty($recom) || empty($recom['data']['product_list'])) {
  193 + break;
  194 + }
  195 +
  196 + $data = array();
  197 + $build = array();
  198 + $build['show'] = true;
  199 + foreach ($recom['data']['product_list'] as $value) {
  200 + $build['goods'][] = Helpers::formatProduct($value, true, false, false);
  201 + }
  202 + $data['goodsContainer'][] = $build;
  203 + } while (false);
  204 +
  205 + $this->_view->display('maylikelife', $data);
  206 +
  207 + }
166 208
167 } 209 }