Authored by Rock Zhang

Merge branch 'java-api' into test

Conflicts:
	yohobuy/m.yohobuy.com/application/controllers/Home.php
@@ -26,7 +26,7 @@ class UserData @@ -26,7 +26,7 @@ class UserData
26 public static function userData($uid) 26 public static function userData($uid)
27 { 27 {
28 $param = array(); 28 $param = array();
29 - $param['uid'] = $uid; 29 + $param['uid'] = 10064;
30 30
31 return Yohobuy::jsonPost(Yohobuy::API_URL_MYCENTER . 'ProfilesRest/getUserprofile', $param); 31 return Yohobuy::jsonPost(Yohobuy::API_URL_MYCENTER . 'ProfilesRest/getUserprofile', $param);
32 } 32 }
@@ -244,11 +244,10 @@ class UserData @@ -244,11 +244,10 @@ class UserData
244 * 优惠券数据 244 * 优惠券数据
245 * 245 *
246 * @param int $uid 用户ID 246 * @param int $uid 用户ID
247 - * @param int $page 第几页,默认1  
248 - * @param int $limit 限制读取的数目,默认10 247 + * @param int $status 优惠券状态,0表示未使用,1表示已使用
249 * @return array 优惠券接口返回的数据 248 * @return array 优惠券接口返回的数据
250 */ 249 */
251 - public static function couponData($uid, $page = 1, $limit = 10) 250 + public static function couponData($uid, $status)
252 { 251 {
253 $param = Yohobuy::param(); 252 $param = Yohobuy::param();
254 $param['uid'] = $uid; 253 $param['uid'] = $uid;
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 <span class="tel">{{mobile}}</span> 6 <span class="tel">{{mobile}}</span>
7 <p class="address-info">{{area}} {{address}}</p> 7 <p class="address-info">{{area}} {{address}}</p>
8 <div class="action iconfont"> 8 <div class="action iconfont">
9 - <span class="edit" data-id="{{address_id}}" data-consignee="{{consignee}}" data-mobile="{{mobile}}" data-area-code="{{areaCode}}" data-area="{{area}}" data-address="{{address}}">&#xe61e;</span> 9 + <span class="edit" data-id="{{address_id}}" data-consignee="{{consignee}}" data-mobile="{{mobile}}" data-area-code="{{area_code}}" data-area="{{area}}" data-address="{{address}}">&#xe61e;</span>
10 <span class="del" data-id="{{address_id}}">&#xe621;</span> 10 <span class="del" data-id="{{address_id}}">&#xe621;</span>
11 </div> 11 </div>
12 </div> 12 </div>
@@ -28,11 +28,11 @@ class HomeController extends AbstractAction @@ -28,11 +28,11 @@ class HomeController extends AbstractAction
28 // @todo 为了方便测试,支持传uid参数 28 // @todo 为了方便测试,支持传uid参数
29 $uid = $this->getUid(); 29 $uid = $this->getUid();
30 if (!$uid) { 30 if (!$uid) {
31 - $uid = $this->_uid = $this->get('uid', 8826435); //$this->getUid(true); 31 + $this->_uid = $this->get('uid', 8826435); //$this->getUid(true);
32 } 32 }
33 - 33 +
34 $action = $this->getRequest()->getActionName(); 34 $action = $this->getRequest()->getActionName();
35 - if (!$uid && $action !== 'index') { 35 + if (!$this->_uid && $action !== 'index') {
36 $this->go(Helpers::url('/signin.html')); 36 $this->go(Helpers::url('/signin.html'));
37 } 37 }
38 38
@@ -51,12 +51,14 @@ class HomeController extends AbstractAction @@ -51,12 +51,14 @@ class HomeController extends AbstractAction
51 'myIndexPage' => true, 51 'myIndexPage' => true,
52 'pageFooter' => true 52 'pageFooter' => true
53 ); 53 );
54 - $uid = $this->getUid();  
55 - if ($uid) {  
56 - 54 + if ($this->_uid) {
57 $data['isLogin'] = true; 55 $data['isLogin'] = true;
58 - $data += UserModel::getUserProfileData($uid);  
59 - $data += UserModel::getInfoNumData($uid); 56 + $data += UserModel::getUserProfileData($this->_uid);
  57 + $data += UserModel::getInfoNumData($this->_uid);
  58 +
  59 + // 优选新品数据
  60 + $channel = Helpers::getChannelByCookie();
  61 + $data['recommendForYou'] = UserModel::getPreferenceData($channel);
60 } 62 }
61 63
62 $this->_view->display('index', $data); 64 $this->_view->display('index', $data);
@@ -91,10 +93,9 @@ class HomeController extends AbstractAction @@ -91,10 +93,9 @@ class HomeController extends AbstractAction
91 $this->setNavHeader('我的收藏', true, SITE_MAIN); 93 $this->setNavHeader('我的收藏', true, SITE_MAIN);
92 94
93 $tab = $this->get('tab', ''); 95 $tab = $this->get('tab', '');
94 - $uid = $this->getUid();  
95 96
96 - $favProducts = UserModel::getFavProductData($uid);  
97 - $favBrands = UserModel::getFavBrandData($uid, 10, 1, 10); 97 + $favProducts = UserModel::getFavProductData($this->_uid);
  98 + $favBrands = UserModel::getFavBrandData($this->_uid, 10, 1, 10);
98 99
99 $data = array( 100 $data = array(
100 'favPage' => true, //加载js 101 'favPage' => true, //加载js
@@ -123,7 +124,7 @@ class HomeController extends AbstractAction @@ -123,7 +124,7 @@ class HomeController extends AbstractAction
123 $uid = $this->getUid(); 124 $uid = $this->getUid();
124 $fav_id = $this->post('fav_id', 0); 125 $fav_id = $this->post('fav_id', 0);
125 126
126 - $result = UserModel::favoriteDelete($uid, $fav_id); 127 + $result = UserModel::favoriteDelete($this->_uid, $fav_id);
127 } 128 }
128 129
129 if (empty($result)) { 130 if (empty($result)) {
@@ -141,12 +142,11 @@ class HomeController extends AbstractAction @@ -141,12 +142,11 @@ class HomeController extends AbstractAction
141 $result = array(); 142 $result = array();
142 143
143 if ($this->isAjax()) { 144 if ($this->isAjax()) {
144 - $uid = $this->getUid();  
145 $udid = $this->getUdid(); 145 $udid = $this->getUdid();
146 $page = $this->get('page', 1); 146 $page = $this->get('page', 1);
147 $limit = $this->get('limit', 100); 147 $limit = $this->get('limit', 100);
148 148
149 - $result = UserModel::browserRecord($uid, $udid, $page, $limit); 149 + $result = UserModel::browserRecord($this->_uid, $udid, $page, $limit);
150 } 150 }
151 151
152 if (empty($result)) { 152 if (empty($result)) {
@@ -159,12 +159,11 @@ class HomeController extends AbstractAction @@ -159,12 +159,11 @@ class HomeController extends AbstractAction
159 /** 159 /**
160 * 个人信息 160 * 个人信息
161 */ 161 */
162 - public function personalDetailsAction() { 162 + public function mydetailsAction() {
163 $this->setTitle('个人信息'); 163 $this->setTitle('个人信息');
164 $this->setNavHeader('个人信息'); 164 $this->setNavHeader('个人信息');
165 165
166 - $uid = $this->getUid();  
167 - $data = UserModel::getUserProfileData($uid); 166 + $data = UserModel::getUserProfileData($this->_uid);
168 $data['personalDetailsPage'] = true; 167 $data['personalDetailsPage'] = true;
169 $data['pageFooter'] = true; 168 $data['pageFooter'] = true;
170 $this->_view->display('personal-details', $data); 169 $this->_view->display('personal-details', $data);
@@ -177,8 +176,7 @@ class HomeController extends AbstractAction @@ -177,8 +176,7 @@ class HomeController extends AbstractAction
177 $this->setTitle('YOHO币'); 176 $this->setTitle('YOHO币');
178 $this->setNavHeader('YOHO币', true, false); 177 $this->setNavHeader('YOHO币', true, false);
179 178
180 - $uid = $this->getUid();  
181 - $currency = UserModel::getYohoCoinData($uid); 179 + $currency = UserModel::getYohoCoinData($this->_uid);
182 180
183 $currency['pageFooter'] = true; 181 $currency['pageFooter'] = true;
184 $this->_view->display('currency', $currency); 182 $this->_view->display('currency', $currency);
@@ -192,11 +190,10 @@ class HomeController extends AbstractAction @@ -192,11 +190,10 @@ class HomeController extends AbstractAction
192 $this->setNavHeader('优惠券', true, SITE_MAIN); 190 $this->setNavHeader('优惠券', true, SITE_MAIN);
193 191
194 // $uid = $this->getUid(); 192 // $uid = $this->getUid();
195 - $uid = 8826435;  
196 $coupons = array( 193 $coupons = array(
197 'couponsUrl' => array( 194 'couponsUrl' => array(
198 - 'used' => \Index\UserModel::getCouponData($uid, 0),  
199 - 'unused' => \Index\UserModel::getCouponData($uid, 1) 195 + 'used' => UserModel::getCouponData($this->_uid, 0),
  196 + 'unused' => UserModel::getCouponData($this->_uid, 1)
200 ), 197 ),
201 'couponsPage' => true 198 'couponsPage' => true
202 ); 199 );
@@ -210,11 +207,10 @@ class HomeController extends AbstractAction @@ -210,11 +207,10 @@ class HomeController extends AbstractAction
210 * 暂时使用老的,因后面APP、PC、WAP会进行一次改版 207 * 暂时使用老的,因后面APP、PC、WAP会进行一次改版
211 */ 208 */
212 public function messageAction() { 209 public function messageAction() {
213 - $uid = $this->getUid();  
214 $page = $this->get('page', 0); 210 $page = $this->get('page', 0);
215 $size = $this->get('size', 10); 211 $size = $this->get('size', 10);
216 212
217 - $messages = UserModel::getMessageData($uid, $page, $size); 213 + $messages = UserModel::getMessageData($this->_uid, $page, $size);
218 214
219 print_r($messages); 215 print_r($messages);
220 } 216 }
@@ -227,9 +223,8 @@ class HomeController extends AbstractAction @@ -227,9 +223,8 @@ class HomeController extends AbstractAction
227 $this->setTitle('地址管理'); 223 $this->setTitle('地址管理');
228 $this->setNavHeader('地址管理'); 224 $this->setNavHeader('地址管理');
229 225
230 - $uid = $this->getUid();  
231 - $address = UserModel::getAddressData($uid);  
232 - $addressList = UserModel::getAddressListData($uid); 226 + $address = UserModel::getAddressData($this->_uid);
  227 + $addressList = UserModel::getAddressListData($this->_uid);
233 228
234 $this->_view->display('address', array( 229 $this->_view->display('address', array(
235 'addressPage' => true, 230 'addressPage' => true,
@@ -246,7 +241,6 @@ class HomeController extends AbstractAction @@ -246,7 +241,6 @@ class HomeController extends AbstractAction
246 $result = array(); 241 $result = array();
247 242
248 if ($this->isAjax()) { 243 if ($this->isAjax()) {
249 - $uid = $this->getUid();  
250 $address = $this->post('address', ''); 244 $address = $this->post('address', '');
251 $area_code = $this->post('area_code', ''); 245 $area_code = $this->post('area_code', '');
252 $consignee = $this->post('consignee', ''); 246 $consignee = $this->post('consignee', '');
@@ -255,7 +249,7 @@ class HomeController extends AbstractAction @@ -255,7 +249,7 @@ class HomeController extends AbstractAction
255 $mobile = $this->post('mobile', ''); 249 $mobile = $this->post('mobile', '');
256 $zip_code = $this->post('zip_code', ''); 250 $zip_code = $this->post('zip_code', '');
257 251
258 - $result = UserModel::saveAddressData($uid, $address, $area_code, $consignee, $email, $id, $mobile, $zip_code); 252 + $result = UserModel::saveAddressData($this->_uid, $address, $area_code, $consignee, $email, $id, $mobile, $zip_code);
259 } 253 }
260 254
261 if (empty($result)) { 255 if (empty($result)) {
@@ -272,9 +266,8 @@ class HomeController extends AbstractAction @@ -272,9 +266,8 @@ class HomeController extends AbstractAction
272 $result = array(); 266 $result = array();
273 267
274 if ($this->isAjax()) { 268 if ($this->isAjax()) {
275 - $uid = $this->getUid();  
276 $id = $this->post('id', ''); 269 $id = $this->post('id', '');
277 - $result = UserModel::setDefaultAddress($uid, $id); 270 + $result = UserModel::setDefaultAddress($this->_uid, $id);
278 } 271 }
279 272
280 if (empty($result)) { 273 if (empty($result)) {
@@ -291,10 +284,9 @@ class HomeController extends AbstractAction @@ -291,10 +284,9 @@ class HomeController extends AbstractAction
291 $result = array(); 284 $result = array();
292 285
293 if ($this->isAjax()) { 286 if ($this->isAjax()) {
294 - $uid = $this->getUid();  
295 $id = $this->post('id', ''); 287 $id = $this->post('id', '');
296 288
297 - $result = UserModel::deleteAddress($uid, $id); 289 + $result = UserModel::deleteAddress($this->_uid, $id);
298 } 290 }
299 291
300 if (empty($result)) { 292 if (empty($result)) {
@@ -338,10 +330,9 @@ class HomeController extends AbstractAction @@ -338,10 +330,9 @@ class HomeController extends AbstractAction
338 public function myGuangAction() { 330 public function myGuangAction() {
339 $page = $this->get('page', 1); 331 $page = $this->get('page', 1);
340 $limit = $this->get('limit', 10); 332 $limit = $this->get('limit', 10);
341 - $uid = $this->getUid();  
342 $gender = Helpers::getGenderByCookie(); 333 $gender = Helpers::getGenderByCookie();
343 $yh_channel = Helpers::getChannelByCookie(); 334 $yh_channel = Helpers::getChannelByCookie();
344 - $guangInfo = \Home\GuangModel::getMyGuang($uid, $page, $yh_channel, $gender, $limit); 335 + $guangInfo = \Home\GuangModel::getMyGuang($this->_uid, $page, $yh_channel, $gender, $limit);
345 $totalPage = $guangInfo['totalPage']; 336 $totalPage = $guangInfo['totalPage'];
346 if ($page == 1) { 337 if ($page == 1) {
347 $this->setTitle('我收藏的'); 338 $this->setTitle('我收藏的');
@@ -412,11 +403,10 @@ class HomeController extends AbstractAction @@ -412,11 +403,10 @@ class HomeController extends AbstractAction
412 */ 403 */
413 public function savesuggestAction() { 404 public function savesuggestAction() {
414 if ($this->isAjax()) { 405 if ($this->isAjax()) {
415 - $uid = $this->getUid();  
416 $content = $this->post('content', ''); 406 $content = $this->post('content', '');
417 $suggest_type = $this->post('suggest_type', 2); 407 $suggest_type = $this->post('suggest_type', 2);
418 $image = $this->post('image', null); 408 $image = $this->post('image', null);
419 - $result = UserModel::saveSuggestData($uid, $content, $image, $suggest_type); 409 + $result = UserModel::saveSuggestData($this->_uid, $content, $image, $suggest_type);
420 410
421 $this->echoJson($result); 411 $this->echoJson($result);
422 } 412 }
@@ -427,10 +417,9 @@ class HomeController extends AbstractAction @@ -427,10 +417,9 @@ class HomeController extends AbstractAction
427 */ 417 */
428 public function upAndDownAction() { 418 public function upAndDownAction() {
429 if ($this->isAjax()) { 419 if ($this->isAjax()) {
430 - $uid = $this->getUid();  
431 $udid = $this->getUdid(); 420 $udid = $this->getUdid();
432 $suggest_id = $this->post('suggest_id', 0); 421 $suggest_id = $this->post('suggest_id', 0);
433 - $result = UserModel::upAndDown($uid, $udid, $suggest_id); 422 + $result = UserModel::upAndDown($this->_uid, $udid, $suggest_id);
434 423
435 $this->echoJson($result); 424 $this->echoJson($result);
436 } 425 }
@@ -444,9 +433,7 @@ class HomeController extends AbstractAction @@ -444,9 +433,7 @@ class HomeController extends AbstractAction
444 $this->setTitle('会员等级'); 433 $this->setTitle('会员等级');
445 //显示网站导航头部信息 434 //显示网站导航头部信息
446 $this->setNavHeader('会员等级'); 435 $this->setNavHeader('会员等级');
447 - $uid = $this->getUid();  
448 - $uid = '3566171'; //临时测试用  
449 - $data = GradeModel::getGrade($uid); 436 + $data = GradeModel::getGrade($this->_uid);
450 $data['pageFooter'] = true; 437 $data['pageFooter'] = true;
451 438
452 $this->_view->display('vip-grade', $data); 439 $this->_view->display('vip-grade', $data);
@@ -500,10 +487,8 @@ class HomeController extends AbstractAction @@ -500,10 +487,8 @@ class HomeController extends AbstractAction
500 $type = $this->get('type', 1); 487 $type = $this->get('type', 1);
501 $page = $this->get('page', 1); 488 $page = $this->get('page', 1);
502 $limit = $this->get('limit', 10); 489 $limit = $this->get('limit', 10);
503 - $uid = $this->getUid();  
504 - $uid = '12';//测试数据  
505 //调用模型层getOrder方法获得并处理数据 490 //调用模型层getOrder方法获得并处理数据
506 - $data = OrderModel::getOrder($type, $page, $limit, $uid); 491 + $data = OrderModel::getOrder($type, $page, $limit, $this->_uid);
507 /* 如果取不到订单数据时,分两种情况: 492 /* 如果取不到订单数据时,分两种情况:
508 1、page>1时,echo一个空格字符串到浏览器。 493 1、page>1时,echo一个空格字符串到浏览器。
509 2、page=1时,就给一个随便逛逛的链接。 494 2、page=1时,就给一个随便逛逛的链接。
@@ -534,11 +519,10 @@ class HomeController extends AbstractAction @@ -534,11 +519,10 @@ class HomeController extends AbstractAction
534 } 519 }
535 //传入order_code和uid以取消订单 520 //传入order_code和uid以取消订单
536 $order_code = $this->get('id'); 521 $order_code = $this->get('id');
537 - $uid = $this->getUid();  
538 $gender = Helpers::getGenderByCookie(); 522 $gender = Helpers::getGenderByCookie();
539 $yh_channel = $this->get('yh_channel', 1); 523 $yh_channel = $this->get('yh_channel', 1);
540 //调用取消订单接口,返回订单取消状态 524 //调用取消订单接口,返回订单取消状态
541 - $data = OrderData::cancelOrderData($order_code, $uid, $gender, $yh_channel); 525 + $data = OrderData::cancelOrderData($order_code, $this->_uid, $gender, $yh_channel);
542 //将取消状态返回至浏览器 526 //将取消状态返回至浏览器
543 $this->echoJson($data); 527 $this->echoJson($data);
544 } 528 }
@@ -554,11 +538,10 @@ class HomeController extends AbstractAction @@ -554,11 +538,10 @@ class HomeController extends AbstractAction
554 } 538 }
555 //传入order_code和uid以删除订单 539 //传入order_code和uid以删除订单
556 $order_code = $this->get('id'); 540 $order_code = $this->get('id');
557 - $uid = $this->getUid();  
558 $gender = Helpers::getGenderByCookie(); 541 $gender = Helpers::getGenderByCookie();
559 $yh_channel = $this->get('yh_channel', 1); 542 $yh_channel = $this->get('yh_channel', 1);
560 //调用接口删除订单,并返回订单删除状态 543 //调用接口删除订单,并返回订单删除状态
561 - $data = OrderData::deleteOrderData($order_code, $uid, $gender, $yh_channel); 544 + $data = OrderData::deleteOrderData($order_code, $this->_uid, $gender, $yh_channel);
562 //将订单删除状态返回至浏览器 545 //将订单删除状态返回至浏览器
563 $this->echoJson($data); 546 $this->echoJson($data);
564 } 547 }
@@ -322,14 +322,15 @@ class UserModel @@ -322,14 +322,15 @@ class UserModel
322 * 处理优惠券数据 322 * 处理优惠券数据
323 * 323 *
324 * @param int $uid 用户ID 324 * @param int $uid 用户ID
  325 + * @param int $status 优惠券状态,0表示未使用,1表示已使用
325 * @return array|mixed 处理之后的优惠券数据 326 * @return array|mixed 处理之后的优惠券数据
326 */ 327 */
327 - public static function getCouponData($uid) 328 + public static function getCouponData($uid, $status)
328 { 329 {
329 $result = array(); 330 $result = array();
330 331
331 // 调用接口获取优惠券数据 332 // 调用接口获取优惠券数据
332 - $coupons = UserData::couponData($uid); 333 + $coupons = UserData::couponData($uid, $status);
333 334
334 // 处理优惠券数据 335 // 处理优惠券数据
335 if (isset($coupons['info']) && $coupons['info']) { 336 if (isset($coupons['info']) && $coupons['info']) {
@@ -353,8 +354,8 @@ class UserModel @@ -353,8 +354,8 @@ class UserModel
353 $address = UserData::addressData($uid); 354 $address = UserData::addressData($uid);
354 355
355 // 处理地址数据 356 // 处理地址数据
356 - if (isset($address['returnObj']) && !empty($address['returnObj'])) {  
357 - $result = $address['returnObj']; 357 + if (!isset($address['code'])) {
  358 + $result = $address;
358 } 359 }
359 360
360 return $result; 361 return $result;