Authored by Rock Zhang

修改数据处理插件的目录结构,初步完成新品到着,折扣专区的数据结构组装

@@ -57,9 +57,11 @@ class NewsaleData @@ -57,9 +57,11 @@ class NewsaleData
57 $param['client_secret'] = Sign::getSign($param); 57 $param['client_secret'] = Sign::getSign($param);
58 $urlList['new'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); 58 $urlList['new'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
59 $param['dayLimit'] = 2; 59 $param['dayLimit'] = 2;
  60 + unset($param['client_secret']);
60 $param['client_secret'] = Sign::getSign($param); 61 $param['client_secret'] = Sign::getSign($param);
61 $urlList['week'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); 62 $urlList['week'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
62 $param['dayLimit'] = 3; 63 $param['dayLimit'] = 3;
  64 + unset($param['client_secret']);
63 $param['client_secret'] = Sign::getSign($param); 65 $param['client_secret'] = Sign::getSign($param);
64 $urlList['sale'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); 66 $urlList['sale'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
65 //var_dump($urlList);exit; 67 //var_dump($urlList);exit;
@@ -120,7 +122,7 @@ class NewsaleData @@ -120,7 +122,7 @@ class NewsaleData
120 * @param integer $page 分页第几页, 默认第1页 122 * @param integer $page 分页第几页, 默认第1页
121 * @return array 折扣专区商品数据 123 * @return array 折扣专区商品数据
122 */ 124 */
123 - public static function getSaleProducts($gender, $channel, $limit = 50, $page = 1) 125 + public static function getSaleProducts($gender, $channel, $limit = 60, $page = 1)
124 { 126 {
125 $param = Yohobuy::param(); 127 $param = Yohobuy::param();
126 $param['method'] = 'app.search.sales'; 128 $param['method'] = 'app.search.sales';
@@ -133,16 +135,19 @@ class NewsaleData @@ -133,16 +135,19 @@ class NewsaleData
133 $urlList = array(); 135 $urlList = array();
134 $param['p_d'] = '0.1,0.3'; 136 $param['p_d'] = '0.1,0.3';
135 $param['client_secret'] = Sign::getSign($param); 137 $param['client_secret'] = Sign::getSign($param);
136 - $urlList['oneThree'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); 138 + $urlList['1-3折'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
137 $param['p_d'] = '0.4,0.6'; 139 $param['p_d'] = '0.4,0.6';
  140 + unset($param['client_secret']);
138 $param['client_secret'] = Sign::getSign($param); 141 $param['client_secret'] = Sign::getSign($param);
139 - $urlList['fourSix'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); 142 + $urlList['4-6折'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
140 $param['p_d'] = '0.7,0.9'; 143 $param['p_d'] = '0.7,0.9';
  144 + unset($param['client_secret']);
141 $param['client_secret'] = Sign::getSign($param); 145 $param['client_secret'] = Sign::getSign($param);
142 - $urlList['SevenNine'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); 146 + $urlList['7-9折'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
143 $param['p_d'] = '0.1,0.9'; 147 $param['p_d'] = '0.1,0.9';
  148 + unset($param['client_secret']);
144 $param['client_secret'] = Sign::getSign($param); 149 $param['client_secret'] = Sign::getSign($param);
145 - $urlList['OneNine'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); 150 + $urlList['ALL'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
146 151
147 return Yohobuy::getMulti($urlList); 152 return Yohobuy::getMulti($urlList);
148 } 153 }
1 <?php 1 <?php
2 2
3 -namespace Plugin; 3 +namespace Plugin\DataProcess;
4 4
5 /** 5 /**
6 * 分类数据处理类 6 * 分类数据处理类
@@ -35,7 +35,7 @@ class ClassProcess @@ -35,7 +35,7 @@ class ClassProcess
35 35
36 $item['sub'][] = $subitem; 36 $item['sub'][] = $subitem;
37 } 37 }
38 - 38 +
39 $oneClass['ca'][] = $item; 39 $oneClass['ca'][] = $item;
40 } 40 }
41 41
1 <?php 1 <?php
2 2
3 -namespace Plugin; 3 +namespace Plugin\DataProcess;
  4 +use Plugin\Helpers;
4 5
5 /** 6 /**
6 * 楼层数据处理类 7 * 楼层数据处理类
  1 +<?php
  2 +
  3 +namespace Plugin\DataProcess;
  4 +use Plugin\Helpers;
  5 +
  6 +/**
  7 + * 新品到着、折扣专区数据处理类
  8 + */
  9 +class NewSaleProcess
  10 +{
  11 +
  12 + /**
  13 + * 处理新品到着、折扣专区数据
  14 + *
  15 + * @param array $data 接口传回的数据
  16 + * @return array 处理之后的数据
  17 + */
  18 + public static function newSaleData($focus, $products)
  19 + {
  20 + $result = array(
  21 + 'headerBanner' => self::bannerData($focus)
  22 + );
  23 +
  24 + $list = array('list'=>array());
  25 + foreach($products as $single)
  26 + {
  27 + $noTab = true;
  28 + if(isset($single['tabs']) && $noTab)
  29 + {
  30 + $list['tabs'] = array();
  31 + foreach ($single['tabs'] as $one)
  32 + {
  33 + $list['tabs'][] = $one;
  34 + }
  35 + $noTab = false;
  36 + }
  37 +
  38 + $list['list'][] = $single['product_list'];
  39 + }
  40 + $result['listNav'] = $list;
  41 +
  42 + return $result;
  43 + }
  44 +
  45 + /**
  46 + * 处理页面顶部焦点图数据
  47 + *
  48 + * @param array $data 接口传回的焦点图数据
  49 + * @return array 处理之后的数据
  50 + */
  51 + private static function bannerData($data)
  52 + {
  53 + $result = array('list'=>array());
  54 +
  55 + foreach ($data as $single)
  56 + {
  57 + foreach ($single['data'] as $one)
  58 + {
  59 + $banner = array();
  60 + $banner['img'] = Helpers::getImageUrl($one['src'], 750, 364, 1);
  61 + $banner['url'] = $one['url'];
  62 + $result['list'][] = $banner;
  63 + }
  64 + }
  65 +
  66 + return $result;
  67 + }
  68 +}
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 use Action\AbstractAction; 3 use Action\AbstractAction;
4 use LibModels\Wap\Home\IndexData; 4 use LibModels\Wap\Home\IndexData;
5 -use Plugin\FloorProcess; 5 +use Plugin\DataProcess\FloorProcess;
6 /** 6 /**
7 * 男生首页 7 * 男生首页
8 */ 8 */
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 use Action\AbstractAction; 3 use Action\AbstractAction;
4 use LibModels\Wap\Home\IndexData; 4 use LibModels\Wap\Home\IndexData;
5 -use Plugin\FloorProcess; 5 +use Plugin\DataProcess\FloorProcess;
6 /** 6 /**
7 * 女生首页 7 * 女生首页
8 */ 8 */
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 use Action\AbstractAction; 3 use Action\AbstractAction;
4 use LibModels\Wap\Home\IndexData; 4 use LibModels\Wap\Home\IndexData;
5 -use Plugin\FloorProcess; 5 +use Plugin\DataProcess\FloorProcess;
6 /** 6 /**
7 * 儿童首页 7 * 儿童首页
8 */ 8 */
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 use Action\AbstractAction; 3 use Action\AbstractAction;
4 use LibModels\Wap\Home\IndexData; 4 use LibModels\Wap\Home\IndexData;
5 -use Plugin\FloorProcess; 5 +use Plugin\DataProcess\FloorProcess;
6 6
7 /** 7 /**
8 * 创意生活首页 8 * 创意生活首页
1 <?php 1 <?php
2 use Action\AbstractAction; 2 use Action\AbstractAction;
3 use LibModels\Wap\Category\ClassData; 3 use LibModels\Wap\Category\ClassData;
4 -use Plugin\ClassProcess; 4 +use Plugin\DataProcess\ClassProcess;
5 5
6 /** 6 /**
7 * 品牌 7 * 品牌
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 use Action\AbstractAction; 3 use Action\AbstractAction;
4 use LibModels\wap\Product\NewsaleData as Newsale; 4 use LibModels\wap\Product\NewsaleData as Newsale;
5 -use Plugin\Helpers; 5 +use Plugin\DataProcess\NewSaleProcess;
6 /** 6 /**
7 * 新品到着 7 * 新品到着
8 */ 8 */
@@ -10,7 +10,11 @@ class NewsaleController extends AbstractAction @@ -10,7 +10,11 @@ class NewsaleController extends AbstractAction
10 { 10 {
11 public function indexAction() 11 public function indexAction()
12 { 12 {
13 - $this->_view->assign('title', '新品到着'); 13 + $data = array(
  14 + 'header' => array(
  15 + 'title' => '新品到着'
  16 + )
  17 + );
14 18
15 // 新品到着顶部焦点图 19 // 新品到着顶部焦点图
16 $focusData = Newsale::getNewsaleFocus('a7989369aa86681c678bc40f171b8f1d'); 20 $focusData = Newsale::getNewsaleFocus('a7989369aa86681c678bc40f171b8f1d');
@@ -18,58 +22,19 @@ class NewsaleController extends AbstractAction @@ -18,58 +22,19 @@ class NewsaleController extends AbstractAction
18 $focus = array(); 22 $focus = array();
19 if($focusData['code'] == 200) 23 if($focusData['code'] == 200)
20 { 24 {
21 - foreach ($focusData['data'] as $single)  
22 - {  
23 - foreach ($single['data'] as $val) {  
24 - $val['src'] = Helpers::getImageUrl($val['src'], 375, 667, 1);  
25 - $focus[] = $val;  
26 - }  
27 - } 25 + $focus = $focusData['data'];
28 } 26 }
29 -  
30 // 批量获取新品到着商品数据 27 // 批量获取新品到着商品数据
31 $products = Newsale::getNewProducts('1,3', 1, 60); 28 $products = Newsale::getNewProducts('1,3', 1, 60);
32 29
33 - echo '<pre>';  
34 - print_r($focus);print_r($products);exit; 30 + // 添加商品数据
  31 + $data += NewSaleProcess::newSaleData($focus, $products);
35 32
36 - $this->_view->display('new', compact('f/**/ocus', 'products'));  
37 -  
38 - /*$data = array(  
39 - 'headerBanner' => array(  
40 - 'list' => array(  
41 - array(  
42 - 'url' => '',  
43 - 'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480',  
44 - )  
45 - )  
46 - ),  
47 - 'listNav' => array(  
48 - 'list' => array(  
49 - array(  
50 - 'url' => '',  
51 - 'textCn' => '5月27日',  
52 - 'styleClass' => ''  
53 - ),  
54 - array(  
55 - 'url' => '',  
56 - 'textCn' => '本周上新'  
57 - ),  
58 - array(  
59 - 'url' => '',  
60 - 'textCn' => '销量'  
61 - ),  
62 - array(  
63 - 'url' => '',  
64 - 'textCn' => '筛选',  
65 - 'styleClass' => 'screen-nav'  
66 - )  
67 - )  
68 - )  
69 - ); 33 + echo '<pre>';
  34 + print_r($data);exit;
70 35
71 $this->_view->assign('title', '新品到着'); 36 $this->_view->assign('title', '新品到着');
72 - $this->_view->display('new', $data);*/ 37 + $this->_view->display('new', $data);
73 } 38 }
74 39
75 40
@@ -100,118 +65,17 @@ class NewsaleController extends AbstractAction @@ -100,118 +65,17 @@ class NewsaleController extends AbstractAction
100 } 65 }
101 } 66 }
102 67
103 - 68 + /**
  69 + * 折扣专区
  70 + */
104 public function discountAction() 71 public function discountAction()
105 { 72 {
106 73
107 $data = array( 74 $data = array(
108 'header' => array( 75 'header' => array(
109 - 'title' => 'SALE'  
110 - ),  
111 - 'headerBanner' => array(  
112 - 'list' => array(  
113 - array(  
114 - 'url' => '',  
115 - 'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'  
116 - ),  
117 - array(  
118 - 'url' => '',  
119 - 'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'  
120 - ),  
121 - array(  
122 - 'url' => '',  
123 - 'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'  
124 - ),  
125 - array(  
126 - 'url' => '',  
127 - 'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'  
128 - )  
129 - )  
130 - ),  
131 - 'saleSection' => array(  
132 - 'list' => array(  
133 - array(  
134 - 'url' => '',  
135 - 'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'  
136 - ),  
137 - array(  
138 - 'url' => '',  
139 - 'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'  
140 - ),  
141 - array(  
142 - 'url' => '',  
143 - 'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'  
144 - ),  
145 - array(  
146 - 'url' => '',  
147 - 'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'  
148 - )  
149 - )  
150 - ),  
151 - 'latestSale' => array(  
152 - 'list' => '最新降价'  
153 - ),  
154 - 'goodsNav' => array(  
155 - 'newPatterns' => true,  
156 - 'price' => true,  
157 - 'salesVolume' => true,  
158 - 'screen' => true,  
159 - ),  
160 - 'goodsContainer' => array(  
161 - 'goods' => array(  
162 - array(  
163 - 'id' => '',  
164 - 'thumb' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480',  
165 - 'name' => 'GAWS DIGI 丛林数码印花拼接卫衣',  
166 - 'isLike' => false,  
167 - 'price' => 1268,  
168 - 'salePrice' => 589,  
169 - 'isSale' => true,  
170 - 'isFew' => true,  
171 - 'isNew' => false,  
172 - 'url' => ''  
173 - ),  
174 - array(  
175 - 'id' => '',  
176 - 'thumb' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480',  
177 - 'name' => 'GAWS DIGI 丛林数码印花拼接卫衣',  
178 - 'isLike' => false,  
179 - 'price' => 1268,  
180 - 'salePrice' => 589,  
181 - 'isSale' => true,  
182 - 'isFew' => true,  
183 - 'isNew' => false,  
184 - 'url' => ''  
185 - ),  
186 - array(  
187 - 'id' => '',  
188 - 'thumb' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480',  
189 - 'name' => 'GAWS DIGI 丛林数码印花拼接卫衣',  
190 - 'isLike' => false,  
191 - 'price' => 1268,  
192 - 'salePrice' => 589,  
193 - 'isSale' => true,  
194 - 'isFew' => true,  
195 - 'isNew' => false,  
196 - 'url' => ''  
197 - ),  
198 - array(  
199 - 'id' => '',  
200 - 'thumb' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480',  
201 - 'name' => 'GAWS DIGI 丛林数码印花拼接卫衣',  
202 - 'isLike' => false,  
203 - 'price' => 1268,  
204 - 'salePrice' => 589,  
205 - 'isSale' => true,  
206 - 'isFew' => true,  
207 - 'isNew' => false,  
208 - 'url' => ''  
209 - )  
210 - )  
211 - ), 76 + 'title' => '折扣专区'
  77 + )
212 ); 78 );
213 -  
214 - /*$this->_view->assign('title', '折扣专区');  
215 79
216 // 折扣专区顶部焦点图 80 // 折扣专区顶部焦点图
217 $focusData = Newsale::getNewsaleFocus('e9c9be32d72e2906d404a72ee24cb523'); 81 $focusData = Newsale::getNewsaleFocus('e9c9be32d72e2906d404a72ee24cb523');
@@ -219,22 +83,18 @@ class NewsaleController extends AbstractAction @@ -219,22 +83,18 @@ class NewsaleController extends AbstractAction
219 $focus = array(); 83 $focus = array();
220 if($focusData['code'] == 200) 84 if($focusData['code'] == 200)
221 { 85 {
222 - foreach ($focusData['data'] as $single)  
223 - {  
224 - foreach ($single['data'] as $val) {  
225 - $val['src'] = Helpers::getImageUrl($val['src'], 375, 667, 1);  
226 - $focus[] = $val;  
227 - }  
228 - } 86 + $focus = $focusData['data'];
229 } 87 }
230 -  
231 // 折扣专区商品数据 88 // 折扣专区商品数据
232 - $products = Newsale::getNewProducts('1,3', 1, 60); 89 + $products = Newsale::getSaleProducts('1,3', 1);
233 90
234 - echo '<pre>';  
235 - print_r($focus);print_r($products);exit; 91 + // 更新tabs
  92 + $data += array('tabs' => array_keys($products));
  93 + // 添加商品数据
  94 + $data += NewSaleProcess::newSaleData($focus, $products);
236 95
237 - $this->_view->display('new', compact('focus', 'products'));*/ 96 + echo '<pre>';
  97 + var_dump($data);exit;
238 98
239 $this->_view->assign('title', '折扣专区'); 99 $this->_view->assign('title', '折扣专区');
240 $this->_view->display('sale', $data); 100 $this->_view->display('sale', $data);