Authored by ccbikai

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

framework @ 75bbc3b0
1 -Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05 1 +Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
@@ -18,14 +18,15 @@ class Yohobuy @@ -18,14 +18,15 @@ class Yohobuy
18 { 18 {
19 19
20 /* 正式环境 */ 20 /* 正式环境 */
21 - // const API_URL = 'http://api2.open.yohobuy.com/';  
22 - // const SERVICE_URL = 'http://service.api.yohobuy.com/';  
23 - // const YOHOBUY_URL = 'http://www.yohobuy.com/'; 21 + const API_URL = 'http://api2.open.yohobuy.com/';
  22 + const API_URL2 = 'http://api.open.yohobuy.com/';
  23 + const SERVICE_URL = 'http://service.api.yohobuy.com/';
  24 + const YOHOBUY_URL = 'http://www.yohobuy.com/';
24 25
25 /* 测试环境 */ 26 /* 测试环境 */
26 - const API_URL = 'http://test2.open.yohobuy.com/';  
27 - const SERVICE_URL = 'http://test.service.api.yohobuy.com/';  
28 - const YOHOBUY_URL = 'http://www.yohobuy.com/'; 27 +// const API_URL = 'http://test2.open.yohobuy.com/';
  28 +// const SERVICE_URL = 'http://test.service.api.yohobuy.com/';
  29 +// const YOHOBUY_URL = 'http://www.yohobuy.com/';
29 30
30 /** 31 /**
31 * 私钥列表 32 * 私钥列表
@@ -42,5 +42,6 @@ class CacheConfig @@ -42,5 +42,6 @@ class CacheConfig
42 const KEY_ACTION_HOME_PREFERENTIAL = 'key_action_home_preferential';//会员特权详情 42 const KEY_ACTION_HOME_PREFERENTIAL = 'key_action_home_preferential';//会员特权详情
43 const KEY_ACTION_GUANG_PLUSTAR_DATA = 'key_action_guang_plustar_data'; // 逛PLUSTAR 43 const KEY_ACTION_GUANG_PLUSTAR_DATA = 'key_action_guang_plustar_data'; // 逛PLUSTAR
44 const KEY_ACTION_GUANG_DETAIL_DATA = 'key_action_guang_detail_data'; // 逛内容详情 44 const KEY_ACTION_GUANG_DETAIL_DATA = 'key_action_guang_detail_data'; // 逛内容详情
  45 + const KEY_ACTION_HOME_ORDER_ORDER = 'key_action_home_order_order';//订单列表
45 46
46 } 47 }
@@ -19,7 +19,7 @@ class GradeData @@ -19,7 +19,7 @@ class GradeData
19 * @param string $uid 用户id 19 * @param string $uid 用户id
20 * @return array 接口返回的会员等级数据 20 * @return array 接口返回的会员等级数据
21 */ 21 */
22 - public function getGradeData($gender,$channel, $uid) { 22 + public function getGradeData($gender, $channel, $uid) {
23 $urlList = array(); 23 $urlList = array();
24 //获取会员等级数据 24 //获取会员等级数据
25 $param = Yohobuy::param(); 25 $param = Yohobuy::param();
@@ -27,7 +27,7 @@ class GradeData @@ -27,7 +27,7 @@ class GradeData
27 $param['uid'] = $uid; 27 $param['uid'] = $uid;
28 $param['method'] = 'app.Passport.vip'; 28 $param['method'] = 'app.Passport.vip';
29 $param['client_secret'] = Sign::getSign($param); 29 $param['client_secret'] = Sign::getSign($param);
30 - $urlList['grade'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); 30 + $urlList['grade'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
31 31
32 //获取用户基本信息数据(用来得到username) 32 //获取用户基本信息数据(用来得到username)
33 $param = Yohobuy::param(); 33 $param = Yohobuy::param();
@@ -36,7 +36,7 @@ class GradeData @@ -36,7 +36,7 @@ class GradeData
36 $param['yh_channel'] = $channel; 36 $param['yh_channel'] = $channel;
37 $param['method'] = 'app.passport.profile'; 37 $param['method'] = 'app.passport.profile';
38 $param['client_secret'] = Sign::getSign($param); 38 $param['client_secret'] = Sign::getSign($param);
39 - $urlList['userProfile'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); 39 + $urlList['userProfile'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
40 40
41 return Yohobuy::getMulti($urlList); 41 return Yohobuy::getMulti($urlList);
42 } 42 }
@@ -4,6 +4,7 @@ namespace LibModels\Wap\Home; @@ -4,6 +4,7 @@ namespace LibModels\Wap\Home;
4 4
5 use Api\Yohobuy; 5 use Api\Yohobuy;
6 use Api\Sign; 6 use Api\Sign;
  7 +
7 /* 8 /*
8 * To change this license header, choose License Headers in Project Properties. 9 * To change this license header, choose License Headers in Project Properties.
9 * To change this template file, choose Tools | Templates 10 * To change this template file, choose Tools | Templates
@@ -22,7 +23,9 @@ class OrderData @@ -22,7 +23,9 @@ class OrderData
22 * To change this template file, choose Tools | Templates 23 * To change this template file, choose Tools | Templates
23 * and open the template in the editor. 24 * and open the template in the editor.
24 */ 25 */
25 - public function getOrderData($type,$page,$limit,$gender,$yh_channel,$uid){ 26 +
  27 + public function getOrderData($type, $page, $limit, $gender, $yh_channel, $uid) {
  28 + //构建必传参数
26 $param = Yohobuy::param(); 29 $param = Yohobuy::param();
27 $param['gender'] = $gender; 30 $param['gender'] = $gender;
28 $param['limit'] = $limit; 31 $param['limit'] = $limit;
@@ -32,7 +35,8 @@ class OrderData @@ -32,7 +35,8 @@ class OrderData
32 $param['uid'] = $uid; 35 $param['uid'] = $uid;
33 $param['yh_channel'] = $yh_channel; 36 $param['yh_channel'] = $yh_channel;
34 $param['client_secret'] = Sign::getSign($param); 37 $param['client_secret'] = Sign::getSign($param);
35 - print_r($param);  
36 - return Yohobuy::get(Yohobuy::API_URL,$param); 38 + //调用接口获得数据
  39 + return Yohobuy::get(Yohobuy::API_URL2, $param);
37 } 40 }
  41 +
38 } 42 }
@@ -8,18 +8,18 @@ var page = 1, @@ -8,18 +8,18 @@ var page = 1,
8 hotnav, 8 hotnav,
9 listTop, 9 listTop,
10 navSwiper, 10 navSwiper,
11 - notab=0, 11 + notab = 0,
12 sort = '', 12 sort = '',
13 id = ''; 13 id = '';
14 14
15 function hotrank(page, sort, tabId, notab) { 15 function hotrank(page, sort, tabId, notab) {
  16 + console.log(sort);
16 $.ajax({ 17 $.ajax({
17 type: 'GET', 18 type: 'GET',
18 - url: '/product/newsale/selectHotrank', 19 + url: '/product/newsale/selectHotrank?'+sort,
19 dataType: 'html', 20 dataType: 'html',
20 data: { 21 data: {
21 page: page, 22 page: page,
22 - sort: sort,  
23 tab_id: tabId, 23 tab_id: tabId,
24 notab: notab 24 notab: notab
25 }, 25 },
@@ -48,8 +48,8 @@ function hotrank(page, sort, tabId, notab) { @@ -48,8 +48,8 @@ function hotrank(page, sort, tabId, notab) {
48 hotnav = new Hammer($('.s-goods-nav .nav-item')[index]); 48 hotnav = new Hammer($('.s-goods-nav .nav-item')[index]);
49 hotnav.on('tap', function(e) { 49 hotnav.on('tap', function(e) {
50 var navItme = $('.s-goods-nav .nav-item').eq(index); 50 var navItme = $('.s-goods-nav .nav-item').eq(index);
51 -  
52 id = navItme.data('id') ? navItme.data('id') : ''; 51 id = navItme.data('id') ? navItme.data('id') : '';
  52 + sort = navItme.data('sort') ? navItme.data('sort') : '';
53 page = 1; 53 page = 1;
54 notab = 1; 54 notab = 1;
55 hotrank(page, sort, id, notab); 55 hotrank(page, sort, id, notab);
@@ -16,11 +16,11 @@ use Plugin\Helpers; @@ -16,11 +16,11 @@ use Plugin\Helpers;
16 */ 16 */
17 class HomeController extends AbstractAction 17 class HomeController extends AbstractAction
18 { 18 {
  19 +
19 /** 20 /**
20 * 个人中心入口 21 * 个人中心入口
21 */ 22 */
22 - public function indexAction()  
23 - { 23 + public function indexAction() {
24 // 设置网站标题 24 // 设置网站标题
25 $this->setTitle('个人中心'); 25 $this->setTitle('个人中心');
26 $this->setNavHeader('个人中心', true, SITE_MAIN); 26 $this->setNavHeader('个人中心', true, SITE_MAIN);
@@ -44,11 +44,9 @@ class HomeController extends AbstractAction @@ -44,11 +44,9 @@ class HomeController extends AbstractAction
44 /** 44 /**
45 * 用户订单 45 * 用户订单
46 */ 46 */
47 - public function ordersAction()  
48 - { 47 + public function ordersAction() {
49 // $uid = $this->getUid(); 48 // $uid = $this->getUid();
50 // $type = $this->get('type', 1); 49 // $type = $this->get('type', 1);
51 -  
52 // $orders = \Index\UserModel::getUserOrderData(967016, $type); 50 // $orders = \Index\UserModel::getUserOrderData(967016, $type);
53 51
54 $order = array( 52 $order = array(
@@ -91,8 +89,7 @@ class HomeController extends AbstractAction @@ -91,8 +89,7 @@ class HomeController extends AbstractAction
91 /** 89 /**
92 * 用户收藏的商品 90 * 用户收藏的商品
93 */ 91 */
94 - public function favoriteAction()  
95 - { 92 + public function favoriteAction() {
96 $uid = $this->getUid(); 93 $uid = $this->getUid();
97 94
98 $favProducts = \Index\UserModel::getFavProductData($uid); 95 $favProducts = \Index\UserModel::getFavProductData($uid);
@@ -116,8 +113,7 @@ class HomeController extends AbstractAction @@ -116,8 +113,7 @@ class HomeController extends AbstractAction
116 /** 113 /**
117 * 用户收藏的品牌 114 * 用户收藏的品牌
118 */ 115 */
119 - public function favoritebrandAction()  
120 - { 116 + public function favoritebrandAction() {
121 $uid = $this->getUid(); 117 $uid = $this->getUid();
122 $gender = Helpers::getGenderByCookie(); 118 $gender = Helpers::getGenderByCookie();
123 119
@@ -129,8 +125,7 @@ class HomeController extends AbstractAction @@ -129,8 +125,7 @@ class HomeController extends AbstractAction
129 /** 125 /**
130 * 个人信息 126 * 个人信息
131 */ 127 */
132 - public function personalDetailsAction()  
133 - { 128 + public function personalDetailsAction() {
134 $this->setTitle('个人信息'); 129 $this->setTitle('个人信息');
135 $this->setNavHeader('个人信息', true, SITE_MAIN); 130 $this->setNavHeader('个人信息', true, SITE_MAIN);
136 131
@@ -139,30 +134,18 @@ class HomeController extends AbstractAction @@ -139,30 +134,18 @@ class HomeController extends AbstractAction
139 $data = \Index\UserModel::getUserProfileData($uid); 134 $data = \Index\UserModel::getUserProfileData($uid);
140 $data['pageFooter'] = true; 135 $data['pageFooter'] = true;
141 $this->_view->display('personal-details', $data); 136 $this->_view->display('personal-details', $data);
142 -  
143 -  
144 } 137 }
145 138
146 /** 139 /**
147 * YOHO币 140 * YOHO币
148 */ 141 */
149 - public function currencyAction()  
150 - { 142 + public function currencyAction() {
151 // $uid = $this->getUid(); 143 // $uid = $this->getUid();
152 $this->setNavHeader('YOHO币', true, false); 144 $this->setNavHeader('YOHO币', true, false);
153 145
154 $uid = 967016; 146 $uid = 967016;
155 $currency = \Index\UserModel::getYohoCoinData($uid); 147 $currency = \Index\UserModel::getYohoCoinData($uid);
156 148
157 - $this->_view->display('currency', $currency);  
158 - }  
159 -  
160 - /**  
161 - * 优惠券  
162 - */  
163 - public function couponsAction()  
164 - {  
165 -  
166 $this->setTitle('优惠券'); 149 $this->setTitle('优惠券');
167 $this->setNavHeader('优惠券', true, SITE_MAIN); 150 $this->setNavHeader('优惠券', true, SITE_MAIN);
168 // $uid = $this->getUid(); 151 // $uid = $this->getUid();
@@ -176,14 +159,30 @@ class HomeController extends AbstractAction @@ -176,14 +159,30 @@ class HomeController extends AbstractAction
176 ); 159 );
177 160
178 $this->_view->display('coupons', $coupons); 161 $this->_view->display('coupons', $coupons);
  162 + }
  163 + /**
  164 + * 优惠券
  165 + */
  166 + public function couponsAction() {
  167 +
  168 + $this->setTitle('优惠券');
  169 + $this->setNavHeader('优惠券', true, SITE_MAIN);
  170 + // $uid = $this->getUid();
  171 + $uid = 8826435;
  172 + $status = $this->get('status', 0);
  173 + $coupons = array(
  174 + 'couponsUrl' => \Index\UserModel::getCouponData($uid, $status),
  175 + 'couponsPage' => true
  176 + );
179 177
  178 + print_r($coupons);
  179 + $this->_view->display('coupons', $coupons);
180 } 180 }
181 181
182 /** 182 /**
183 * 我的消息 183 * 我的消息
184 */ 184 */
185 - public function messageAction()  
186 - { 185 + public function messageAction() {
187 // $uid = $this->getUid(); 186 // $uid = $this->getUid();
188 $page = $this->get('page', 0); 187 $page = $this->get('page', 0);
189 $size = $this->get('size', 10); 188 $size = $this->get('size', 10);
@@ -192,14 +191,12 @@ class HomeController extends AbstractAction @@ -192,14 +191,12 @@ class HomeController extends AbstractAction
192 $messages = \Index\UserModel::getMessageData($uid, $page, $size); 191 $messages = \Index\UserModel::getMessageData($uid, $page, $size);
193 192
194 print_r($messages); 193 print_r($messages);
195 -  
196 } 194 }
197 195
198 /** 196 /**
199 * 地址管理 197 * 地址管理
200 */ 198 */
201 - public function addressAction()  
202 - { 199 + public function addressAction() {
203 // 设置网站标题 200 // 设置网站标题
204 $this->setTitle('地址管理'); 201 $this->setTitle('地址管理');
205 $this->setNavHeader('地址管理', true, SITE_MAIN); 202 $this->setNavHeader('地址管理', true, SITE_MAIN);
@@ -273,8 +270,7 @@ class HomeController extends AbstractAction @@ -273,8 +270,7 @@ class HomeController extends AbstractAction
273 } 270 }
274 271
275 //在线客服 272 //在线客服
276 - public function onlineServiceAction()  
277 - { 273 + public function onlineServiceAction() {
278 // 设置网站标题 274 // 设置网站标题
279 $this->setTitle('在线客服'); 275 $this->setTitle('在线客服');
280 $this->setNavHeader('在线客服', true, SITE_MAIN); 276 $this->setNavHeader('在线客服', true, SITE_MAIN);
@@ -289,8 +285,7 @@ class HomeController extends AbstractAction @@ -289,8 +285,7 @@ class HomeController extends AbstractAction
289 } 285 }
290 286
291 //在线客服-具体详情 287 //在线客服-具体详情
292 - public function onlineServiceDetailAction()  
293 - { 288 + public function onlineServiceDetailAction() {
294 $service = array(); 289 $service = array();
295 $cateId = $this->get('cateId', 0); 290 $cateId = $this->get('cateId', 0);
296 $cateName = $this->get('cateName', ''); 291 $cateName = $this->get('cateName', '');
@@ -306,16 +301,14 @@ class HomeController extends AbstractAction @@ -306,16 +301,14 @@ class HomeController extends AbstractAction
306 /** 301 /**
307 * 我的逛 302 * 我的逛
308 */ 303 */
309 - public function myGuangAction()  
310 - { 304 + public function myGuangAction() {
311 echo 'My Guang'; 305 echo 'My Guang';
312 } 306 }
313 307
314 /** 308 /**
315 * 意见反馈 309 * 意见反馈
316 */ 310 */
317 - public function suggestAction()  
318 - { 311 + public function suggestAction() {
319 $udid = $this->getUdid(); 312 $udid = $this->getUdid();
320 $page = $this->get('page', 1); 313 $page = $this->get('page', 1);
321 $limit = $this->get('limit', 30); 314 $limit = $this->get('limit', 30);
@@ -352,15 +345,13 @@ class HomeController extends AbstractAction @@ -352,15 +345,13 @@ class HomeController extends AbstractAction
352 'bad' => false) 345 'bad' => false)
353 ) 346 )
354 )); 347 ));
355 -  
356 } 348 }
357 349
358 /** 350 /**
359 * 异步保存意见反馈数据 351 * 异步保存意见反馈数据
360 */ 352 */
361 - public function savesuggestAction()  
362 - {  
363 - if($this->isAjax()) { 353 + public function savesuggestAction() {
  354 + if ($this->isAjax()) {
364 $uid = $this->getUid(); 355 $uid = $this->getUid();
365 $content = $this->post('content', ''); 356 $content = $this->post('content', '');
366 $suggest_type = $this->get('suggest_type', 2); 357 $suggest_type = $this->get('suggest_type', 2);
@@ -369,13 +360,12 @@ class HomeController extends AbstractAction @@ -369,13 +360,12 @@ class HomeController extends AbstractAction
369 360
370 $this->echoJson($result); 361 $this->echoJson($result);
371 } 362 }
372 -  
373 } 363 }
374 364
375 /** 365 /**
376 * 会员等级展示页 366 * 会员等级展示页
377 */ 367 */
378 - public function gradeAction(){ 368 + public function gradeAction() {
379 //设置网站seo信息 369 //设置网站seo信息
380 $this->setTitle('会员等级'); 370 $this->setTitle('会员等级');
381 //显示网站导航头部信息 371 //显示网站导航头部信息
@@ -383,102 +373,64 @@ class HomeController extends AbstractAction @@ -383,102 +373,64 @@ class HomeController extends AbstractAction
383 373
384 $gender = Helpers::getGenderByCookie(); 374 $gender = Helpers::getGenderByCookie();
385 $channel = Helpers::getChannelByCookie(); 375 $channel = Helpers::getChannelByCookie();
386 - $uid = $this -> getUid();  
387 - $uid = '7566245';//临时测试用  
388 - $data = GradeModel::getGrade($gender,$channel,$uid); 376 + $uid = $this->getUid();
  377 + $uid = '7566245'; //临时测试用
  378 + $data = GradeModel::getGrade($gender, $channel, $uid);
389 $data['pageFooter'] = true; 379 $data['pageFooter'] = true;
390 - $this -> _view -> display('vip-grade',$data); 380 + $this->_view->display('vip-grade', $data);
391 } 381 }
  382 +
392 /* 383 /*
393 - *会员特权查看页 384 + * 会员特权查看页
394 */ 385 */
395 - public function preferentialAction(){ 386 +
  387 + public function preferentialAction() {
396 //设置网站seo信息 388 //设置网站seo信息
397 $this->setTitle('会员等级'); 389 $this->setTitle('会员等级');
398 //显示网站导航头部信息 390 //显示网站导航头部信息
399 $this->setNavHeader('会员特权详情'); 391 $this->setNavHeader('会员特权详情');
400 392
401 $channel = Helpers::getChannelByCookie(); 393 $channel = Helpers::getChannelByCookie();
402 - $uid = $this -> getUid();  
403 - $data = GradeModel::getPreferential($channel,$uid); 394 + $uid = $this->getUid();
  395 + $data = GradeModel::getPreferential($channel, $uid);
404 $data['pageFooter'] = true; 396 $data['pageFooter'] = true;
405 - $this -> _view -> display('privilege',$data); 397 + $this->_view->display('privilege', $data);
406 } 398 }
407 399
408 /* 400 /*
409 - *我的订单页面 401 + * 我的订单页面
410 */ 402 */
411 - public function orderAction(){  
412 403
413 - do{  
414 - //判断是不是ajax请求  
415 -// if(!$this -> isAjax()){  
416 -// break;  
417 -// }  
418 - //判断参数是否有效  
419 - $type = $this -> get('type',1);  
420 - $page = $this -> get('page',1);  
421 - $limit = $this -> get('limit',10); 404 + public function orderAction() {
  405 + //获取基本参数:type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论
  406 + $type = $this->get('type', 1);
  407 + $page = $this->get('page', 1);
  408 + $limit = $this->get('limit', 10);
422 $gender = Helpers::getGenderByCookie(); 409 $gender = Helpers::getGenderByCookie();
423 - $yh_channel = $this -> get('yh_channel',1);  
424 - $uid = $this -> getUid();  
425 - if(!empty($type) && !is_numeric($type)){  
426 - break;  
427 - }  
428 - //$data = OrderModel::getOrder();  
429 - $data = OrderModel::getOrder($type,$page,$limit,$gender,$yh_channel,$uid);  
430 - //print_r($data);  
431 - }  
432 - while(false);  
433 - //$this -> _view -> display('order',$data); 410 + $yh_channel = $this->get('yh_channel', 1);
  411 + $uid = $this->getUid();
  412 + $uid = '7566245'; //测试用
  413 + //调用模型层getOrder方法获得并处理数据
  414 + $data = OrderModel::getOrder($type, $page, $limit, $gender, $yh_channel, $uid);
  415 + //渲染模板
  416 + $this->_view->display('order', array(
  417 + 'order' => array(
  418 + 'orders' => $data
  419 + )
  420 + ));
434 } 421 }
435 422
436 - /**  
437 - * 订单详情页 423 + /*
  424 + * 我的订单-处理ajax请求页面(切换订单状态)
438 */ 425 */
439 - public function orderDetailAction()  
440 - {  
441 - $data = array(  
442 - 'name' => '毛毛莉Lydia',  
443 - 'phoneNum' => '18600001133',  
444 - 'address' => '南京市建邺区嘉陵江东街18号国家广告产业园5栋17楼',  
445 - 'orderStatus' => '待收货',  
446 - 'orderNum' => '418358063',  
447 - 'orderTime' => '2014-03-10 17:25:10',  
448 -  
449 - 'unreceived' => true,  
450 - 'logisticsUrl' => '',  
451 - 'logisticsCompany' => '顺丰',  
452 - 'logisticsNum' => '51537443456',  
453 426
454 - 'goods' => array(  
455 - array(  
456 - 'id' => 1,  
457 - 'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',  
458 - 'name' => 'Adidas Originals ZX FLUXM22508',  
459 - 'color' => '黄',  
460 - 'size' => '43',  
461 - 'price' => '699.00',  
462 - 'count' => '2'  
463 - ),  
464 - array(  
465 - 'id' => 1,  
466 - 'thumb' => 'http://img10.static.yhbimg.com/goodsimg/2015/11/04/05/0188f1aca49ac478a565ec029b5d2d4a6c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',  
467 - 'name' => 'B.Duck浴室玩伴mini浮水鸭',  
468 - 'gift' => true,  
469 - 'color' => '黄',  
470 - 'size' => '43',  
471 - 'price' => '0.00',  
472 - 'count' => '1'  
473 - )  
474 - ), 427 + public function orderAjaxAction() {
475 428
476 - 'sumPrice' => 799,  
477 - 'salePrice' => 80,  
478 - 'freight' => 5,  
479 - 'yohoCoin' => 5,  
480 - 'price' => 719  
481 - );  
482 - $this->_view->display('order-detail', array('orderDetail' => $data, 'orderDetailPage' => true)); 429 + //判断是不是ajax请求
  430 + if (!$this->isAjax()) {
  431 + $this->error();
483 } 432 }
  433 + self::orderAction();
  434 + }
  435 +
484 } 436 }
@@ -26,7 +26,7 @@ class GradeModel @@ -26,7 +26,7 @@ class GradeModel
26 } 26 }
27 } 27 }
28 //调用接口获取数据 28 //调用接口获取数据
29 - $data = GradeData::getGradeData($gender,$channel, $uid); 29 + $data = GradeData::getGradeData($gender, $channel, $uid);
30 switch (intval($data['grade']['current_vip_level'])) { 30 switch (intval($data['grade']['current_vip_level'])) {
31 case 0://普通会员 31 case 0://普通会员
32 $result['vipGrade']['vip0'] = true; 32 $result['vipGrade']['vip0'] = true;
@@ -45,7 +45,7 @@ class GradeModel @@ -45,7 +45,7 @@ class GradeModel
45 //今年总消费 45 //今年总消费
46 $result['vipGrade']['costOfThisYear'] = $data['grade']['current_year_cost']; 46 $result['vipGrade']['costOfThisYear'] = $data['grade']['current_year_cost'];
47 //升级下一等级会员的进度; 47 //升级下一等级会员的进度;
48 - $result['vipGrade']['percent'] = 100*(round($data['grade']['current_total_cost'] / $data['grade']['next_need_cost'], 2)); 48 + $result['vipGrade']['percent'] = 100 * (round($data['grade']['current_total_cost'] / $data['grade']['next_need_cost'], 2));
49 //距离升级所需消费金额 49 //距离升级所需消费金额
50 50
51 if ($data['grade']['current_vip_level'] != 3) { 51 if ($data['grade']['current_vip_level'] != 3) {
@@ -57,7 +57,7 @@ class GradeModel @@ -57,7 +57,7 @@ class GradeModel
57 //$userProfile = GradeData::getUserProfileData($gender,$uid,$channel); 57 //$userProfile = GradeData::getUserProfileData($gender,$uid,$channel);
58 $result['vipGrade']['name'] = $data['userProfile']['username']; 58 $result['vipGrade']['name'] = $data['userProfile']['username'];
59 //跳转url(会员特权详情) 59 //跳转url(会员特权详情)
60 - $result['vipGrade']['allUrl'] = Helpers::url('/Home/preferential',null); 60 + $result['vipGrade']['allUrl'] = Helpers::url('/Home/preferential', null);
61 //当前vip等级享受的特权 61 //当前vip等级享受的特权
62 $result['vipGrade']['privilege'] = $data['grade']['enjoy_preferential']; 62 $result['vipGrade']['privilege'] = $data['grade']['enjoy_preferential'];
63 63
1 <?php 1 <?php
2 2
3 - namespace home; 3 +namespace home;
  4 +
  5 +use LibModels\Wap\Home\OrderData;
  6 +use Plugin\Helpers;
  7 +use Configs\CacheConfig;
4 8
5 - use LibModels\Wap\Home\OrderData;  
6 /* 9 /*
7 * To change this license header, choose License Headers in Project Properties. 10 * To change this license header, choose License Headers in Project Properties.
8 * To change this template file, choose Tools | Templates 11 * To change this template file, choose Tools | Templates
@@ -19,11 +22,100 @@ class OrderModel @@ -19,11 +22,100 @@ class OrderModel
19 /** 22 /**
20 * 订单相关数据处理 23 * 订单相关数据处理
21 */ 24 */
22 - public function getOrder($type = 1,$page = 1,$limit,$gender,$yh_channel,$uid){ 25 + public function getOrder($type = 1, $page = 1, $limit, $gender, $yh_channel, $uid) {
  26 + $result = array();
  27 + if (USE_CACHE) {
  28 + $key = CacheConfig::KEY_ACTION_HOME_ORDER_ORDER;
  29 + // 先尝试获取一级缓存(master), 有数据则直接返回.
  30 + $result = Cache::get($key, 'master');
  31 + if (!empty($result)) {
  32 + return $result;
  33 + }
  34 + }
  35 + //调用接口获得数据
  36 + $data = OrderData::getOrderData($type, $page, $limit, $gender, $yh_channel, $uid);
  37 + //检查数据返回是否正常,正常则处理数据
  38 + if ($data['code'] == 200 && isset($data['data'])) {
  39 + foreach ($data['data']['order_list'] as $key => $vo) {
  40 + //订单号,支付状态,订单商品数量,订单总价格
  41 + $result[$key]['orderNum'] = $vo['order_code'];
  42 + $result[$key]['tradingStatus'] = $vo['status_str'];
  43 + $result[$key]['count'] = count($vo['order_goods']);
  44 + $result[$key]['sumCost'] = $vo['amount'] + $vo['shipping_cost'];
  45 + //订单商品列表数据
  46 + $result[$key]['goods'] = self::formatOrderGoods($vo['order_goods']);
  47 + //订单status判断订单处于什么状态。
  48 + do {
  49 + //订单取消状态
  50 + if ($vo['is_cancel'] === 'Y') {
  51 + $result[$key]['canceled'] = true;
  52 + break;
  53 + }
  54 + //支付方式不是货到付款时,计算订单状态
  55 + if ($vo['payment_type'] != 2) {
  56 + switch ($vo['status']) {
  57 + case 0:
  58 + $result[$key]['unpaid'] = true;
  59 + break;
  60 + case 1 || 2 || 3 || 4 || 5:
  61 + $result[$key]['unreceived'] = true;
  62 + $resault[$key]['logisticsUrl'] = "暂无logisticsUrl数据";
  63 + break;
  64 + case 6:
  65 + $result[$key]['completed'] = true;
  66 + break;
  67 + default:
  68 + break;
  69 + }
  70 + } elseif ($vo['payment_type'] == 2) {
  71 + //订单为货到付款订单时,订单没有未支付状态
  72 + switch ($vo['status']) {
  73 + case 0 || 1 || 2 || 3 || 4 || 5:
  74 + $result[$key]['unreceived'] = true;
  75 + //此处备注,接口没有返回logisticsUrl数据
  76 + $resault[$key]['logisticsUrl'] = "备注:暂无logisticsUrl数据";
  77 + break;
  78 + case 6:
  79 + $result[$key]['completed'] = true;
  80 + break;
  81 + default:
  82 + break;
  83 + }
  84 + }
  85 + } while (false);
  86 + }
  87 + }
23 88
24 - $data = OrderData::getOrderData($type,$page,$limit,$gender,$yh_channel,$uid); 89 + if (USE_CACHE) {
  90 + // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
  91 + if (empty($result)) {
  92 + $result = Cache::get($key, 'slave');
  93 + }
  94 + // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
  95 + else {
  96 + Cache::set($key, $result);
  97 + }
  98 + }
  99 + return $result;
  100 + }
25 101
26 - return $data; 102 + //格式化订单商品
  103 + static function formatOrderGoods($orderGoods) {
  104 + $arr = array();
  105 + foreach ($orderGoods as $key => $vo) {
  106 + $arr[$key]['thumb'] = Helpers::getImageUrl($vo['goods_image'], 90, 120);
  107 + $arr[$key]['name'] = $vo['product_name'];
  108 + $arr[$key]['color'] = $vo['color_name'];
  109 + $arr[$key]['size'] = $vo['size_name'];
  110 + $arr[$key]['price'] = $vo['goods_price'];
  111 + $arr[$key]['count'] = $vo['buy_number'];
  112 + if ($vo['goods_type'] == 'gift') {
  113 + $arr[$key]['gift'] = true;
  114 + } elseif ($vo['goods_type'] == 'price_gift') {
  115 + $arr[$key]['advanceBuy'] = true;
  116 + }
  117 + }
  118 + return $arr;
27 } 119 }
28 120
29 } 121 }