Authored by hf

fixes bug refs YW-1678

@@ -248,9 +248,9 @@ class OrderModel @@ -248,9 +248,9 @@ class OrderModel
248 //待收货状态,给查看物流url 248 //待收货状态,给查看物流url
249 $result['unreceived'] = true; 249 $result['unreceived'] = true;
250 $result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code'])); 250 $result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code']));
251 - if ($showLogistics) {  
252 - $result['logisticsCompany'] = isset($order['caption']) ? $order['caption'] : '';  
253 - $result['logisticsNum'] = isset($order['express_number']) ? $order['express_number'] : ''; 251 + if ($showLogistics && isset($order['caption'])) {
  252 + $result['logisticsCompany'] = $order['caption'];
  253 + $result['logisticsNum'] = $order['express_number'];
254 } 254 }
255 break; 255 break;
256 case 6: 256 case 6:
@@ -241,7 +241,7 @@ class DetailModel @@ -241,7 +241,7 @@ class DetailModel
241 'numInCart' => 0, 241 'numInCart' => 0,
242 'goodsInstore' => $baseInfo['storage'], // 库存量 242 'goodsInstore' => $baseInfo['storage'], // 库存量
243 ); 243 );
244 - $soldOut = $totalStorageNum === 0; 244 + $soldOut = ($baseInfo['storage'] == 0) || ($totalStorageNum === 0);
245 $notForSale = $baseInfo['attribute'] == 2; 245 $notForSale = $baseInfo['attribute'] == 2;
246 // 显示加入购物车链接 246 // 显示加入购物车链接
247 if (!$soldOut && !$notForSale) { 247 if (!$soldOut && !$notForSale) {
@@ -17,26 +17,25 @@ class BindController extends AbstractAction @@ -17,26 +17,25 @@ class BindController extends AbstractAction
17 public function indexAction() 17 public function indexAction()
18 { 18 {
19 $refer = $this->get('refer'); 19 $refer = $this->get('refer');
20 - if (!empty($refer))  
21 - { 20 + if (!empty($refer)) {
22 $this->setCookie('refer', $refer); 21 $this->setCookie('refer', $refer);
23 } 22 }
24 23
25 $this->setTitle('绑定手机号'); 24 $this->setTitle('绑定手机号');
26 - 25 +
27 $openId = $this->get('openId'); 26 $openId = $this->get('openId');
28 $sourceType = $this->get('sourceType'); 27 $sourceType = $this->get('sourceType');
29 $nickname = $this->get('nickname'); 28 $nickname = $this->get('nickname');
30 $data = array( 29 $data = array(
31 - 'bindIndex'=>true,//js标识  
32 - 'backUrl' => '/', // 返回的URL链接 30 + 'bindIndex' => true, //js标识
  31 + 'backUrl' => Helpers::url('/signin.html'), // 返回的URL链接
33 'showHeaderImg' => true, // 控制显示头部图片 32 'showHeaderImg' => true, // 控制显示头部图片
34 'isPassportPage' => true, // 模板中模块标识 33 'isPassportPage' => true, // 模板中模块标识
35 'sourceType' => $sourceType, // 第三方登录来源 34 'sourceType' => $sourceType, // 第三方登录来源
36 - 'platform'=>$sourceType, 35 + 'platform' => $sourceType,
37 'openId' => $openId, // openId 36 'openId' => $openId, // openId
38 - 'areaCode'=>'+86',//默认区号  
39 - 'countrys'=>RegData::getAreasData(),//国别码 37 + 'areaCode' => '+86', //默认区号
  38 + 'countrys' => RegData::getAreasData(), //国别码
40 'nickname' => $nickname, //昵称 39 'nickname' => $nickname, //昵称
41 ); 40 );
42 41
@@ -49,26 +48,25 @@ class BindController extends AbstractAction @@ -49,26 +48,25 @@ class BindController extends AbstractAction
49 */ 48 */
50 public function codeAction() 49 public function codeAction()
51 { 50 {
52 -  
53 $this->setTitle('验证手机'); 51 $this->setTitle('验证手机');
54 $openId = $this->get('openId'); 52 $openId = $this->get('openId');
55 $sourceType = $this->get('sourceType'); 53 $sourceType = $this->get('sourceType');
56 $nickname = $this->get('nickname'); 54 $nickname = $this->get('nickname');
57 $areaCode = $this->get('areaCode', '86'); 55 $areaCode = $this->get('areaCode', '86');
58 $isReg = $this->get('isReg'); 56 $isReg = $this->get('isReg');
59 - $phoneNum=$this->get('phoneNum');  
60 - 57 + $phoneNum = $this->get('phoneNum');
  58 +
61 $data = array( 59 $data = array(
62 - 'bindCode'=>true,//js标识  
63 - 'backUrl' => '/', // 返回的URL链接 60 + 'bindCode' => true, //js标识
  61 + 'backUrl' => Helpers::url('/signin.html'), // 返回的URL链接
64 'showHeaderImg' => true, // 控制显示头部图片 62 'showHeaderImg' => true, // 控制显示头部图片
65 'isPassportPage' => true, // 模板中模块标识 63 'isPassportPage' => true, // 模板中模块标识
66 'sourceType' => $sourceType, // 第三方登录来源 64 'sourceType' => $sourceType, // 第三方登录来源
67 'openId' => $openId, // openId 65 'openId' => $openId, // openId
68 'nickname' => $nickname, //昵称 66 'nickname' => $nickname, //昵称
69 'isReg' => $isReg, //是否是已注册过的手机号 67 'isReg' => $isReg, //是否是已注册过的手机号
70 - 'areaCode' => $areaCode, //国别码  
71 - 'phoneNum'=>$phoneNum,//手机号码 68 + 'areaCode' => $areaCode, //国别码
  69 + 'phoneNum' => $phoneNum, //手机号码
72 ); 70 );
73 71
74 // 渲染模板 72 // 渲染模板
@@ -80,22 +78,21 @@ class BindController extends AbstractAction @@ -80,22 +78,21 @@ class BindController extends AbstractAction
80 */ 78 */
81 public function passwordAction() 79 public function passwordAction()
82 { 80 {
83 -  
84 $this->setTitle('重新设置登录密码'); 81 $this->setTitle('重新设置登录密码');
85 $openId = $this->get('openId'); 82 $openId = $this->get('openId');
86 $sourceType = $this->get('sourceType'); 83 $sourceType = $this->get('sourceType');
87 $nickname = $this->get('nickname'); 84 $nickname = $this->get('nickname');
88 $areaCode = $this->get('areaCode', '86'); 85 $areaCode = $this->get('areaCode', '86');
89 - $phoneNum=$this->get('phoneNum'); 86 + $phoneNum = $this->get('phoneNum');
90 $data = array( 87 $data = array(
91 - 'bindPwd'=>true,//js标识  
92 - 'backUrl' => '/', // 返回的URL链接 88 + 'bindPwd' => true, //js标识
  89 + 'backUrl' => Helpers::url('/signin.html'), // 返回的URL链接
93 'showHeaderImg' => true, // 控制显示头部图片 90 'showHeaderImg' => true, // 控制显示头部图片
94 'isPassportPage' => true, // 模板中模块标识 91 'isPassportPage' => true, // 模板中模块标识
95 'sourceType' => $sourceType, // 第三方登录来源 92 'sourceType' => $sourceType, // 第三方登录来源
96 'openId' => $openId, // openId 93 'openId' => $openId, // openId
97 'nickname' => $nickname, //昵称 94 'nickname' => $nickname, //昵称
98 - 'areaCode' => $areaCode, //国别码 95 + 'areaCode' => $areaCode, //国别码
99 'phoneNum' => $phoneNum //国别码 96 'phoneNum' => $phoneNum //国别码
100 ); 97 );
101 98
@@ -108,11 +105,9 @@ class BindController extends AbstractAction @@ -108,11 +105,9 @@ class BindController extends AbstractAction
108 { 105 {
109 $data = array('code' => 400, 'message' => '', 'data' => ''); 106 $data = array('code' => 400, 'message' => '', 'data' => '');
110 107
111 - do  
112 - { 108 + do {
113 /* 判断是不是AJAX请求 */ 109 /* 判断是不是AJAX请求 */
114 - if (!$this->isAjax())  
115 - { 110 + if (!$this->isAjax()) {
116 break; 111 break;
117 } 112 }
118 113
@@ -123,27 +118,21 @@ class BindController extends AbstractAction @@ -123,27 +118,21 @@ class BindController extends AbstractAction
123 $nickname = $this->post('nickname'); 118 $nickname = $this->post('nickname');
124 119
125 120
126 - if (!is_numeric($phoneNum) || !$openId || !$areaCode || !$sourceType)  
127 - { 121 + if (!is_numeric($phoneNum) || !$openId || !$areaCode || !$sourceType) {
128 break; 122 break;
129 } 123 }
130 124
131 $res = BindData::bindCheck($phoneNum, $openId, $sourceType); 125 $res = BindData::bindCheck($phoneNum, $openId, $sourceType);
132 - if (!isset($res['code']))  
133 - { 126 + if (!isset($res['code'])) {
134 break; 127 break;
135 } 128 }
136 - if ($res['code'] == 200)  
137 - { 129 + if ($res['code'] == 200) {
138 $next = Helpers::url('/passport/bind/code', array('isReg' => $res['data']['is_register'], 'openId' => $openId, 'sourceType' => $sourceType, 'nickname' => $nickname, 'areaCode' => $areaCode, 'phoneNum' => $phoneNum)); 130 $next = Helpers::url('/passport/bind/code', array('isReg' => $res['data']['is_register'], 'openId' => $openId, 'sourceType' => $sourceType, 'nickname' => $nickname, 'areaCode' => $areaCode, 'phoneNum' => $phoneNum));
139 $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('isReg' => $res['data']['is_register'], 'next' => $next)); 131 $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('isReg' => $res['data']['is_register'], 'next' => $next));
  132 + } else {
  133 + $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => isset($res['data']) ? $res['data'] : '');
140 } 134 }
141 - else  
142 - {  
143 - $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => isset($res['data'])?$res['data']:'');  
144 - }  
145 - }  
146 - while (false); 135 + } while (false);
147 136
148 $this->echoJson($data); 137 $this->echoJson($data);
149 } 138 }
@@ -153,29 +142,24 @@ class BindController extends AbstractAction @@ -153,29 +142,24 @@ class BindController extends AbstractAction
153 { 142 {
154 $data = array('code' => 400, 'message' => '', 'data' => ''); 143 $data = array('code' => 400, 'message' => '', 'data' => '');
155 144
156 - do  
157 - { 145 + do {
158 /* 判断是不是AJAX请求 */ 146 /* 判断是不是AJAX请求 */
159 - if (!$this->isAjax())  
160 - { 147 + if (!$this->isAjax()) {
161 break; 148 break;
162 } 149 }
163 150
164 $phoneNum = $this->post('phoneNum'); 151 $phoneNum = $this->post('phoneNum');
165 $areaCode = $this->post('areaCode'); 152 $areaCode = $this->post('areaCode');
166 153
167 - if (!is_numeric($phoneNum))  
168 - { 154 + if (!is_numeric($phoneNum)) {
169 break; 155 break;
170 } 156 }
171 157
172 - $data = BindData::sendBindMsg($areaCode,$phoneNum);  
173 - if (!isset($data['code']))  
174 - { 158 + $data = BindData::sendBindMsg($areaCode, $phoneNum);
  159 + if (!isset($data['code'])) {
175 break; 160 break;
176 } 161 }
177 - }  
178 - while (false); 162 + } while (false);
179 163
180 $this->echoJson($data); 164 $this->echoJson($data);
181 } 165 }
@@ -185,11 +169,9 @@ class BindController extends AbstractAction @@ -185,11 +169,9 @@ class BindController extends AbstractAction
185 { 169 {
186 $data = array('code' => 400, 'message' => '', 'data' => ''); 170 $data = array('code' => 400, 'message' => '', 'data' => '');
187 171
188 - do  
189 - { 172 + do {
190 /* 判断是不是AJAX请求 */ 173 /* 判断是不是AJAX请求 */
191 - if (!$this->isAjax())  
192 - { 174 + if (!$this->isAjax()) {
193 break; 175 break;
194 } 176 }
195 177
@@ -197,18 +179,15 @@ class BindController extends AbstractAction @@ -197,18 +179,15 @@ class BindController extends AbstractAction
197 $code = $this->post('code'); 179 $code = $this->post('code');
198 $areaCode = $this->post('areaCode'); 180 $areaCode = $this->post('areaCode');
199 181
200 - if (!is_numeric($phoneNum) || !$code)  
201 - { 182 + if (!is_numeric($phoneNum) || !$code) {
202 break; 183 break;
203 } 184 }
204 185
205 - $data = BindData::checkBindCode($areaCode,$phoneNum, $code);  
206 - if (!isset($data['code']))  
207 - { 186 + $data = BindData::checkBindCode($areaCode, $phoneNum, $code);
  187 + if (!isset($data['code'])) {
208 break; 188 break;
209 } 189 }
210 - }  
211 - while (false); 190 + } while (false);
212 191
213 $this->echoJson($data); 192 $this->echoJson($data);
214 } 193 }
@@ -218,11 +197,9 @@ class BindController extends AbstractAction @@ -218,11 +197,9 @@ class BindController extends AbstractAction
218 { 197 {
219 $data = array('code' => 400, 'message' => '', 'data' => ''); 198 $data = array('code' => 400, 'message' => '', 'data' => '');
220 199
221 - do  
222 - { 200 + do {
223 /* 判断是不是AJAX请求 */ 201 /* 判断是不是AJAX请求 */
224 - if (!$this->isAjax())  
225 - { 202 + if (!$this->isAjax()) {
226 break; 203 break;
227 } 204 }
228 205
@@ -233,42 +210,33 @@ class BindController extends AbstractAction @@ -233,42 +210,33 @@ class BindController extends AbstractAction
233 $nickname = $this->post('nickname'); 210 $nickname = $this->post('nickname');
234 $password = $this->post('password'); 211 $password = $this->post('password');
235 212
236 - if (!is_numeric($phoneNum) || !$openId || !$sourceType || !$areaCode)  
237 - { 213 + if (!is_numeric($phoneNum) || !$openId || !$sourceType || !$areaCode) {
238 break; 214 break;
239 } 215 }
240 216
241 $res = BindData::bindMobile($openId, $nickname, $sourceType, $phoneNum, $areaCode, $password); 217 $res = BindData::bindMobile($openId, $nickname, $sourceType, $phoneNum, $areaCode, $password);
242 - if (!isset($res['code']))  
243 - { 218 + if (!isset($res['code'])) {
244 break; 219 break;
245 } 220 }
246 221
247 //绑定成功,跳转页面 222 //绑定成功,跳转页面
248 $refer = $this->getCookie('refer'); 223 $refer = $this->getCookie('refer');
249 - if (empty($refer))  
250 - { 224 + if (empty($refer)) {
251 $refer = SITE_MAIN . '/?go=1'; 225 $refer = SITE_MAIN . '/?go=1';
252 - }  
253 - else  
254 - { 226 + } else {
255 $refer = rawurldecode($refer); 227 $refer = rawurldecode($refer);
256 } 228 }
257 -  
258 - if (isset($res['code']) && $res['code'] == 200 && !empty($res['data']['uid']))  
259 - { 229 +
  230 + if (isset($res['code']) && $res['code'] == 200 && !empty($res['data']['uid'])) {
260 $token = Helpers::makeToken($res['data']['uid']); 231 $token = Helpers::makeToken($res['data']['uid']);
261 $this->setCookie('_TOKEN', $token); 232 $this->setCookie('_TOKEN', $token);
262 $this->setSession('_TOKEN', $token); 233 $this->setSession('_TOKEN', $token);
263 $refer = Helpers::syncUserSession($res['data']['uid'], $refer); 234 $refer = Helpers::syncUserSession($res['data']['uid'], $refer);
264 $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('refer' => $refer)); 235 $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('refer' => $refer));
265 - }  
266 - else  
267 - { 236 + } else {
268 $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('refer' => $refer)); 237 $data = array('code' => $res['code'], 'message' => $res['message'], 'data' => array('refer' => $refer));
269 } 238 }
270 - }  
271 - while (false); 239 + } while (false);
272 240
273 $this->echoJson($data); 241 $this->echoJson($data);
274 } 242 }
@@ -79,7 +79,7 @@ class LoginController extends AbstractAction @@ -79,7 +79,7 @@ class LoginController extends AbstractAction
79 $refer = $this->server('HTTP_REFERER', SITE_MAIN); 79 $refer = $this->server('HTTP_REFERER', SITE_MAIN);
80 $token = $this->get('token'); 80 $token = $this->get('token');
81 if (!empty($token)) { 81 if (!empty($token)) {
82 - $this->go( Helpers::logoutSession($token, $refer) ); 82 + $this->go(Helpers::logoutSession($token, $refer));
83 } 83 }
84 84
85 $this->go($refer); 85 $this->go($refer);
@@ -119,7 +119,7 @@ class LoginController extends AbstractAction @@ -119,7 +119,7 @@ class LoginController extends AbstractAction
119 } 119 }
120 120
121 /* 调用登录接口进行登录 */ 121 /* 调用登录接口进行登录 */
122 - $data = LoginData::signin($area, $profile, $password); 122 + $data = LoginData::signin($area, $profile, $password);
123 if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) { 123 if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['uid'])) {
124 break; 124 break;
125 } 125 }
@@ -182,12 +182,10 @@ class LoginController extends AbstractAction @@ -182,12 +182,10 @@ class LoginController extends AbstractAction
182 if (isset($realName, $email, $userId)) { 182 if (isset($realName, $email, $userId)) {
183 $result = LoginData::signinByOpenID($realName, $userId, 'alipay'); 183 $result = LoginData::signinByOpenID($realName, $userId, 'alipay');
184 } 184 }
185 - 185 +
186 //判定是否需要绑定手机号 186 //判定是否需要绑定手机号
187 - $isBind = $result['data']['is_bind'];  
188 - if ($isBind == 'N')  
189 - {  
190 - $this->go(Helpers::url('/passport/bind/index',array('openId'=>$userId,'sourceType'=>'alipay','nickname'=>$realName))); 187 + if (isset($result['data']['is_bind']) && $result['data']['is_bind'] == 'N') {
  188 + $this->go(Helpers::url('/passport/bind/index', array('openId' => $userId, 'sourceType' => 'alipay', 'nickname' => $realName)));
191 } 189 }
192 190
193 $refer = $this->getCookie('refer'); 191 $refer = $this->getCookie('refer');
@@ -217,37 +215,29 @@ class LoginController extends AbstractAction @@ -217,37 +215,29 @@ class LoginController extends AbstractAction
217 /* 获取QQ腾讯用户的详细信息 */ 215 /* 获取QQ腾讯用户的详细信息 */
218 $partnerInfo = $qqconnect->getUserInfo($access); 216 $partnerInfo = $qqconnect->getUserInfo($access);
219 $result = array(); 217 $result = array();
220 - if (!empty($partnerInfo) && isset($partnerInfo['nickname']))  
221 - { 218 + if (!empty($partnerInfo) && isset($partnerInfo['nickname'])) {
222 $result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq'); 219 $result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq');
223 } 220 }
224 221
225 //判定是否需要绑定手机号 222 //判定是否需要绑定手机号
226 $isBind = $result['data']['is_bind']; 223 $isBind = $result['data']['is_bind'];
227 - if ($isBind == 'N')  
228 - {  
229 - $this->go(Helpers::url('/passport/bind/index',array('openId'=>$access['openid'],'sourceType'=>'qq','nickname'=>$partnerInfo['nickname']))); 224 + if ($isBind == 'N') {
  225 + $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['openid'], 'sourceType' => 'qq', 'nickname' => $partnerInfo['nickname'])));
230 } 226 }
231 227
232 $refer = $this->getCookie('refer'); 228 $refer = $this->getCookie('refer');
233 - if (empty($refer))  
234 - { 229 + if (empty($refer)) {
235 $refer = SITE_MAIN . '/?go=1'; 230 $refer = SITE_MAIN . '/?go=1';
236 - }  
237 - else  
238 - { 231 + } else {
239 $refer = rawurldecode($refer); 232 $refer = rawurldecode($refer);
240 } 233 }
241 234
242 - if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid']))  
243 - { 235 + if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
244 $token = Helpers::makeToken($result['data']['uid']); 236 $token = Helpers::makeToken($result['data']['uid']);
245 $this->setCookie('_TOKEN', $token); 237 $this->setCookie('_TOKEN', $token);
246 $this->setSession('_TOKEN', $token); 238 $this->setSession('_TOKEN', $token);
247 $this->go(Helpers::syncUserSession($result['data']['uid'], $refer)); 239 $this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
248 - }  
249 - else  
250 - { 240 + } else {
251 $this->go($refer); 241 $this->go($refer);
252 } 242 }
253 } 243 }
@@ -258,9 +248,9 @@ class LoginController extends AbstractAction @@ -258,9 +248,9 @@ class LoginController extends AbstractAction
258 public function sinacallbackAction() 248 public function sinacallbackAction()
259 { 249 {
260 $sina = Factory::create('sinaweibo'); 250 $sina = Factory::create('sinaweibo');
261 - $access = $sina->getAccessToken(); 251 + $access = $sina->getAccessToken();
262 /* 获取用户的详细信息 */ 252 /* 获取用户的详细信息 */
263 - $partnerInfo = $sina->getUserInfo($access); 253 + $partnerInfo = $sina->getUserInfo($access);
264 254
265 $result = array(); 255 $result = array();
266 if ($partnerInfo && is_array($partnerInfo)) { 256 if ($partnerInfo && is_array($partnerInfo)) {
@@ -268,11 +258,10 @@ class LoginController extends AbstractAction @@ -268,11 +258,10 @@ class LoginController extends AbstractAction
268 } 258 }
269 //判定是否需要绑定手机号 259 //判定是否需要绑定手机号
270 $isBind = $result['data']['is_bind']; 260 $isBind = $result['data']['is_bind'];
271 - if ($isBind == 'N')  
272 - {  
273 - $this->go(Helpers::url('/passport/bind/index',array('openId'=>$access['uid'],'sourceType'=>'sina','nickname'=>$partnerInfo['screen_name']))); 261 + if ($isBind == 'N') {
  262 + $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
274 } 263 }
275 - 264 +
276 $refer = $this->getCookie('refer'); 265 $refer = $this->getCookie('refer');
277 if (empty($refer)) { 266 if (empty($refer)) {
278 $refer = SITE_MAIN . '/?go=1'; 267 $refer = SITE_MAIN . '/?go=1';
@@ -289,5 +278,5 @@ class LoginController extends AbstractAction @@ -289,5 +278,5 @@ class LoginController extends AbstractAction
289 $this->go($refer); 278 $this->go($refer);
290 } 279 }
291 } 280 }
292 - 281 +
293 } 282 }