Authored by 周少峰

home page add new customer floor

@@ -29,11 +29,11 @@ class Yohobuy @@ -29,11 +29,11 @@ class Yohobuy
29 // const YOHOBUY_URL = 'http://www.yohobuy.com/'; 29 // const YOHOBUY_URL = 'http://www.yohobuy.com/';
30 // const API_OLD = 'http://api2.open.yohobuy.com/'; 30 // const API_OLD = 'http://api2.open.yohobuy.com/';
31 31
32 - const API_URL = 'http://api.yoho.cn/';  
33 - const API_URL2 = 'http://api.yoho.cn/';  
34 - const SERVICE_URL = 'http://service.yoho.cn/';  
35 - const YOHOBUY_URL = 'http://www.yohobuy.com/';  
36 - const API_OLD = 'http://api2.open.yohobuy.com/'; 32 +// const API_URL = 'http://api.yoho.cn/';
  33 +// const API_URL2 = 'http://api.yoho.cn/';
  34 +// const SERVICE_URL = 'http://service.yoho.cn/';
  35 +// const YOHOBUY_URL = 'http://www.yohobuy.com/';
  36 +// const API_OLD = 'http://api2.open.yohobuy.com/';
37 37
38 /* 预览环境 java API */ 38 /* 预览环境 java API */
39 // const API_URL = 'http://preapi.yoho.cn/'; 39 // const API_URL = 'http://preapi.yoho.cn/';
@@ -43,14 +43,14 @@ class Yohobuy @@ -43,14 +43,14 @@ class Yohobuy
43 // const API_OLD = 'http://api2.open.yohobuy.com/'; 43 // const API_OLD = 'http://api2.open.yohobuy.com/';
44 44
45 /* 测试环境 java API*/ 45 /* 测试环境 java API*/
46 -// const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://devapi.yoho.cn:58078/'; 46 + const API_URL = 'http://testapi.yoho.cn:28078/'; // 'http://devapi.yoho.cn:58078/';
47 // const API_URL = 'http://devapi.yoho.cn:58078/'; 47 // const API_URL = 'http://devapi.yoho.cn:58078/';
48 -// const DEV_API_URL = 'http://devapi.yoho.cn:58078/';  
49 -// const SERVICE_URL = 'http://testservice.yoho.cn:28077/'; // 'http://devservice.yoho.cn:58077/';  
50 -// const DEV_SERVICE_URL = 'http://devservice.yoho.cn:58077/';  
51 -// const PRD_SERVICE_URL = 'http://serviceh5.yoho.cn/';  
52 -// const YOHOBUY_URL = 'http://www.yohobuy.com/';  
53 -// const API_OLD = 'http://test2.open.yohobuy.com/'; 48 + const DEV_API_URL = 'http://devapi.yoho.cn:58078/';
  49 + const SERVICE_URL = 'http://testservice.yoho.cn:28077/'; // 'http://devservice.yoho.cn:58077/';
  50 + const DEV_SERVICE_URL = 'http://devservice.yoho.cn:58077/';
  51 + const PRD_SERVICE_URL = 'http://serviceh5.yoho.cn/';
  52 + const YOHOBUY_URL = 'http://www.yohobuy.com/';
  53 + const API_OLD = 'http://test2.open.yohobuy.com/';
54 54
55 /* 测试环境 php API*/ 55 /* 测试环境 php API*/
56 // const API_URL = 'http://test2.open.yohobuy.com/'; 56 // const API_URL = 'http://test2.open.yohobuy.com/';
@@ -54,17 +54,24 @@ class IndexData @@ -54,17 +54,24 @@ class IndexData
54 * @param string $contentCode 内容位置码 54 * @param string $contentCode 内容位置码
55 * @param integer $limit 查询返回的最大限字数,默认为20 55 * @param integer $limit 查询返回的最大限字数,默认为20
56 * @param integer $page 分页第几页,默认为第1页 56 * @param integer $page 分页第几页,默认为第1页
  57 + * @param integer $uid 用户id
  58 + * @modify sefon 2016-4-19 13:33:49
57 * @return array 首页频道数据 59 * @return array 首页频道数据
58 */ 60 */
59 - public static function getResourceData($gender, $contentCode, $limit = 20, $page = 1) 61 + public static function getResourceData($gender, $contentCode, $limit = 20, $page = 1, $uid = 0)
60 { 62 {
61 $param = Yohobuy::param(); 63 $param = Yohobuy::param();
  64 + if ($uid) {
  65 + $param['uid'] = $uid;
  66 + } else {
  67 + //新设备(用户未登录状态,默认新设备):Y/N
  68 + $param['new_device'] = 'Y';
  69 + }
62 $param['gender'] = $gender; 70 $param['gender'] = $gender;
63 $param['content_code'] = $contentCode; 71 $param['content_code'] = $contentCode;
64 $param['page'] = $page; 72 $param['page'] = $page;
65 $param['limit'] = $limit; 73 $param['limit'] = $limit;
66 $param['client_secret'] = Sign::getSign($param); 74 $param['client_secret'] = Sign::getSign($param);
67 -  
68 return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/resource/home', $param, false, false, 2); 75 return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/resource/home', $param, false, false, 2);
69 } 76 }
70 77
@@ -451,4 +451,32 @@ class FloorProcess @@ -451,4 +451,32 @@ class FloorProcess
451 return $result; 451 return $result;
452 } 452 }
453 453
  454 + /**
  455 + * 新人专享
  456 + * @param $data
  457 + * @param $type
  458 + * @author sefon 2016-4-19 11:43:56
  459 + * @return array
  460 + */
  461 + private static function new_user_floor($data, $type)
  462 + {
  463 + $result = array();
  464 + $result['title']['title'] = $data['title']['title'];
  465 + $result['title']['name'] = $data['title']['name'];
  466 + $result['big_image']['url'] = $data['banner_image'][0]['url'];
  467 + $result['big_image']['title'] = $data['banner_image'][0]['title'];
  468 + $result['big_image']['img'] = Helpers::getImageUrl($data['banner_image'][0]['src'], 640, 200);
  469 + if (empty($data['list'])) {
  470 + return $result;
  471 + }
  472 + foreach ($data['list'] as $key => $val) {
  473 + $result['list'][$key]['url'] = Helpers::getUrlBySkc($val['product_id'], $val['goods_list'][0]['goods_id'], $val['cn_alphabet']);
  474 + $result['list'][$key]['img'] = helpers::getImageUrl($val['default_images'], 235, 314);
  475 + $result['list'][$key]['title'] = $val['product_name'];
  476 + $result['list'][$key]['salePrice'] = $val['sales_price'];
  477 + $result['list'][$key]['price'] = $val['market_price'];
  478 + }
  479 + return array('freshOnly'=>$result);
  480 + }
  481 +
454 } 482 }
@@ -22,15 +22,14 @@ class BoysController extends AbstractAction @@ -22,15 +22,14 @@ class BoysController extends AbstractAction
22 // 设置浏览器缓存5分钟 22 // 设置浏览器缓存5分钟
23 $this->setExpires(300); // 缓存5分钟 23 $this->setExpires(300); // 缓存5分钟
24 } 24 }
25 -  
26 // 设置网站标题 25 // 设置网站标题
27 $this->setTitle('男生首页'); 26 $this->setTitle('男生首页');
28 // 显示侧边栏 27 // 显示侧边栏
29 $this->setNavSide('boys'); 28 $this->setNavSide('boys');
30 // 显示底部TAB 29 // 显示底部TAB
31 $this->setNavFooterTab(); 30 $this->setNavFooterTab();
32 -  
33 - $content = Index\HomeModel::getBoysFloor(); 31 + $uid = $this->getUid();
  32 + $content = Index\HomeModel::getBoysFloor($uid);
34 // $content[] = array( 33 // $content[] = array(
35 // 'notice' => array( 34 // 'notice' => array(
36 // 'open' => true, 35 // 'open' => true,
@@ -23,13 +23,13 @@ class GirlsController extends AbstractAction @@ -23,13 +23,13 @@ class GirlsController extends AbstractAction
23 $this->setNavSide('girls'); 23 $this->setNavSide('girls');
24 // 显示底部TAB 24 // 显示底部TAB
25 $this->setNavFooterTab(); 25 $this->setNavFooterTab();
26 - 26 + $uid = $this->getUid();
27 // 渲染模板并输出 27 // 渲染模板并输出
28 $this->_view->display('index', array( 28 $this->_view->display('index', array(
29 'grilsHomePage' => true, 29 'grilsHomePage' => true,
30 'homeHeader' => array('searchUrl' => Helpers::url('/search', null, 'search')), 30 'homeHeader' => array('searchUrl' => Helpers::url('/search', null, 'search')),
31 'maybeLike' => true, 31 'maybeLike' => true,
32 - 'content' => Index\HomeModel::getGirlsFloor(), 32 + 'content' => Index\HomeModel::getGirlsFloor($uid),
33 'pageFooter' => true, 33 'pageFooter' => true,
34 )); 34 ));
35 } 35 }
@@ -23,13 +23,13 @@ class KidsController extends AbstractAction @@ -23,13 +23,13 @@ class KidsController extends AbstractAction
23 $this->setNavSide('kids'); 23 $this->setNavSide('kids');
24 // 显示底部TAB 24 // 显示底部TAB
25 $this->setNavFooterTab(); 25 $this->setNavFooterTab();
26 - 26 + $uid = $this->getUid();
27 // 渲染模板并输出 27 // 渲染模板并输出
28 $this->_view->display('index', array( 28 $this->_view->display('index', array(
29 'kidsHomePage' => true, 29 'kidsHomePage' => true,
30 'homeHeader' => array('searchUrl' => Helpers::url('/search', null, 'search')), 30 'homeHeader' => array('searchUrl' => Helpers::url('/search', null, 'search')),
31 'maybeLike' => true, 31 'maybeLike' => true,
32 - 'content' => Index\HomeModel::getKidsFloor(), 32 + 'content' => Index\HomeModel::getKidsFloor($uid),
33 'pageFooter' => true, 33 'pageFooter' => true,
34 )); 34 ));
35 } 35 }
@@ -23,13 +23,13 @@ class LifestyleController extends AbstractAction @@ -23,13 +23,13 @@ class LifestyleController extends AbstractAction
23 $this->setNavSide('lifestyle'); 23 $this->setNavSide('lifestyle');
24 // 显示底部TAB 24 // 显示底部TAB
25 $this->setNavFooterTab(); 25 $this->setNavFooterTab();
26 - 26 + $uid = $this->getUid();
27 // 渲染模板并输出 27 // 渲染模板并输出
28 $this->_view->display('index', array( 28 $this->_view->display('index', array(
29 'lifestyleHomePage' => true, 29 'lifestyleHomePage' => true,
30 'homeHeader' => array('searchUrl' => Helpers::url('/search', null, 'search')), 30 'homeHeader' => array('searchUrl' => Helpers::url('/search', null, 'search')),
31 'maybeLike' => true, 31 'maybeLike' => true,
32 - 'content' => Index\HomeModel::getLifestyleFloor(), 32 + 'content' => Index\HomeModel::getLifestyleFloor($uid),
33 'pageFooter' => true, 33 'pageFooter' => true,
34 )); 34 ));
35 } 35 }
@@ -178,10 +178,9 @@ class HomeModel @@ -178,10 +178,9 @@ class HomeModel
178 * 178 *
179 * @return array | false 179 * @return array | false
180 */ 180 */
181 - public static function getBoysFloor() 181 + public static function getBoysFloor($uid = 0)
182 { 182 {
183 $result = array(); 183 $result = array();
184 -  
185 if (USE_CACHE) { 184 if (USE_CACHE) {
186 // 先尝试获取一级缓存(master), 有数据则直接返回. 185 // 先尝试获取一级缓存(master), 有数据则直接返回.
187 $result = Cache::get(CacheConfig::KEY_ACTION_BOYS_INDEX, 'master'); 186 $result = Cache::get(CacheConfig::KEY_ACTION_BOYS_INDEX, 'master');
@@ -189,9 +188,8 @@ class HomeModel @@ -189,9 +188,8 @@ class HomeModel
189 return $result; 188 return $result;
190 } 189 }
191 } 190 }
192 -  
193 // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式 191 // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式
194 - $channelData = IndexData::getResourceData('1,3', self::CODE_FLOOR_BOYS); 192 + $channelData = IndexData::getResourceData('1,3', self::CODE_FLOOR_BOYS, 20, 1, $uid);
195 if (isset($channelData['code']) && $channelData['code'] == 200) { 193 if (isset($channelData['code']) && $channelData['code'] == 200) {
196 $result = FloorProcess::getContent($channelData['data']); 194 $result = FloorProcess::getContent($channelData['data']);
197 } 195 }
@@ -215,7 +213,7 @@ class HomeModel @@ -215,7 +213,7 @@ class HomeModel
215 * 213 *
216 * @return array | false 214 * @return array | false
217 */ 215 */
218 - public static function getGirlsFloor() 216 + public static function getGirlsFloor($uid = 0)
219 { 217 {
220 $result = array(); 218 $result = array();
221 219
@@ -228,7 +226,7 @@ class HomeModel @@ -228,7 +226,7 @@ class HomeModel
228 } 226 }
229 227
230 // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式 228 // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式
231 - $channelData = IndexData::getResourceData('2,3', self::CODE_FLOOR_GIRLS); 229 + $channelData = IndexData::getResourceData('2,3', self::CODE_FLOOR_GIRLS, 20, 1, $uid);
232 if (isset($channelData['code']) && $channelData['code'] == 200) { 230 if (isset($channelData['code']) && $channelData['code'] == 200) {
233 $result = FloorProcess::getContent($channelData['data'], 2); 231 $result = FloorProcess::getContent($channelData['data'], 2);
234 } 232 }
@@ -249,10 +247,11 @@ class HomeModel @@ -249,10 +247,11 @@ class HomeModel
249 247
250 /** 248 /**
251 * 获取潮童首页的楼层数据 249 * 获取潮童首页的楼层数据
252 - * 250 + * @param int $uid
  251 + * @modify sefon 2016-4-19 13:21:28
253 * @return array | false 252 * @return array | false
254 */ 253 */
255 - public static function getKidsFloor() 254 + public static function getKidsFloor($uid = 0)
256 { 255 {
257 $result = false; 256 $result = false;
258 257
@@ -267,7 +266,7 @@ class HomeModel @@ -267,7 +266,7 @@ class HomeModel
267 // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式 266 // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式
268 $channelData = IndexData::getResourceData('', self::CODE_FLOOR_KIDS); 267 $channelData = IndexData::getResourceData('', self::CODE_FLOOR_KIDS);
269 if (isset($channelData['code']) && $channelData['code'] == 200) { 268 if (isset($channelData['code']) && $channelData['code'] == 200) {
270 - $result = FloorProcess::getContent($channelData['data'], 3); 269 + $result = FloorProcess::getContent($channelData['data'], 3, 20, 1, $uid);
271 } 270 }
272 271
273 if (USE_CACHE) { 272 if (USE_CACHE) {
@@ -286,10 +285,11 @@ class HomeModel @@ -286,10 +285,11 @@ class HomeModel
286 285
287 /** 286 /**
288 * 获取创意生活首页的楼层数据 287 * 获取创意生活首页的楼层数据
289 - * 288 + * @param int $uid
  289 + * @modify sefon 2016-4-19 13:22:34
290 * @return array | false 290 * @return array | false
291 */ 291 */
292 - public static function getLifestyleFloor() 292 + public static function getLifestyleFloor($uid = 0)
293 { 293 {
294 $result = false; 294 $result = false;
295 295
@@ -302,7 +302,7 @@ class HomeModel @@ -302,7 +302,7 @@ class HomeModel
302 } 302 }
303 303
304 // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式 304 // 调用接口获取楼层数据, 并封装成模板渲染需要的数据格式
305 - $channelData = IndexData::getResourceData('', self::CODE_FLOOR_LIFESTYLE); 305 + $channelData = IndexData::getResourceData('', self::CODE_FLOOR_LIFESTYLE, 20, 1, $uid);
306 if (isset($channelData['code']) && $channelData['code'] == 200) { 306 if (isset($channelData['code']) && $channelData['code'] == 200) {
307 $result = FloorProcess::getContent($channelData['data'], 4); 307 $result = FloorProcess::getContent($channelData['data'], 4);
308 } 308 }