do debug call product detail page api
Showing
5 changed files
with
29 additions
and
11 deletions
@@ -45,4 +45,6 @@ class CacheConfig | @@ -45,4 +45,6 @@ class CacheConfig | ||
45 | const KEY_ACTION_GUANG_DETAIL_DATA = 'key_action_guang_detail_data'; // 逛内容详情 | 45 | const KEY_ACTION_GUANG_DETAIL_DATA = 'key_action_guang_detail_data'; // 逛内容详情 |
46 | const KEY_ACTION_GUANG_RSS_DATA = 'key_action_guang_detail_data'; // 逛订阅内容 | 46 | const KEY_ACTION_GUANG_RSS_DATA = 'key_action_guang_detail_data'; // 逛订阅内容 |
47 | 47 | ||
48 | + const KEY_ACTION_ADDRESS_LIST_DATA = 'key_action_address_list_data'; // 地址树数据 | ||
49 | + | ||
48 | } | 50 | } |
@@ -171,12 +171,11 @@ class UserData | @@ -171,12 +171,11 @@ class UserData | ||
171 | * 优惠券数据 | 171 | * 优惠券数据 |
172 | * | 172 | * |
173 | * @param int $uid 用户ID | 173 | * @param int $uid 用户ID |
174 | - * @param int $status 优惠券状态,0表示未使用,1表示已使用 | ||
175 | * @param int $page 第几页,默认1 | 174 | * @param int $page 第几页,默认1 |
176 | * @param int $limit 限制读取的数目,默认10 | 175 | * @param int $limit 限制读取的数目,默认10 |
177 | * @return array 优惠券接口返回的数据 | 176 | * @return array 优惠券接口返回的数据 |
178 | */ | 177 | */ |
179 | - public static function couponData($uid, $status, $page = 1, $limit = 10) | 178 | + public static function couponData($uid, $page = 1, $limit = 10) |
180 | { | 179 | { |
181 | $urlList = array(); | 180 | $urlList = array(); |
182 | 181 |
@@ -149,13 +149,12 @@ class HomeController extends AbstractAction | @@ -149,13 +149,12 @@ class HomeController extends AbstractAction | ||
149 | */ | 149 | */ |
150 | public function couponsAction() | 150 | public function couponsAction() |
151 | { | 151 | { |
152 | - | ||
153 | $this->setTitle('优惠券'); | 152 | $this->setTitle('优惠券'); |
154 | $this->setNavHeader('优惠券'); | 153 | $this->setNavHeader('优惠券'); |
154 | + | ||
155 | $uid = $this->getUid(); | 155 | $uid = $this->getUid(); |
156 | - $status = $this->get('status', 0); | ||
157 | $coupons = array( | 156 | $coupons = array( |
158 | - 'couponsUrl' => \Index\UserModel::getCouponData($uid, $status), | 157 | + 'couponsUrl' => \Index\UserModel::getCouponData($uid), |
159 | 'couponsPage' => true | 158 | 'couponsPage' => true |
160 | ); | 159 | ); |
161 | $this->_view->display('coupons', $coupons); | 160 | $this->_view->display('coupons', $coupons); |
@@ -258,12 +258,12 @@ class UserModel | @@ -258,12 +258,12 @@ class UserModel | ||
258 | * @param int $uid 用户ID | 258 | * @param int $uid 用户ID |
259 | * @return array|mixed 处理之后的优惠券数据 | 259 | * @return array|mixed 处理之后的优惠券数据 |
260 | */ | 260 | */ |
261 | - public static function getCouponData($uid, $status) | 261 | + public static function getCouponData($uid) |
262 | { | 262 | { |
263 | $result = array(); | 263 | $result = array(); |
264 | 264 | ||
265 | // 调用接口获取优惠券数据 | 265 | // 调用接口获取优惠券数据 |
266 | - $coupons = UserData::couponData($uid, $status); | 266 | + $coupons = UserData::couponData($uid); |
267 | 267 | ||
268 | // 处理优惠券数据 | 268 | // 处理优惠券数据 |
269 | if (!empty($coupons['unused'])) { | 269 | if (!empty($coupons['unused'])) { |
@@ -307,6 +307,15 @@ class UserModel | @@ -307,6 +307,15 @@ class UserModel | ||
307 | { | 307 | { |
308 | $result = array(); | 308 | $result = array(); |
309 | 309 | ||
310 | + if (USE_CACHE) { | ||
311 | + $key = CacheConfig::KEY_ACTION_ADDRESS_LIST_DATA; | ||
312 | + // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
313 | + $result = Cache::get($key, 'master'); | ||
314 | + if (!empty($result)) { | ||
315 | + return $result; | ||
316 | + } | ||
317 | + } | ||
318 | + | ||
310 | // 调用接口获取地址列表数据 | 319 | // 调用接口获取地址列表数据 |
311 | $address = UserData::addressListData($uid); | 320 | $address = UserData::addressListData($uid); |
312 | 321 | ||
@@ -315,6 +324,17 @@ class UserModel | @@ -315,6 +324,17 @@ class UserModel | ||
315 | $result = $address['data']; | 324 | $result = $address['data']; |
316 | } | 325 | } |
317 | 326 | ||
327 | + if (USE_CACHE) { | ||
328 | + // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
329 | + if (empty($result)) { | ||
330 | + $result = Cache::get($key, 'slave'); | ||
331 | + } | ||
332 | + // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
333 | + else { | ||
334 | + Cache::set($key, $result, 1800); // 缓存30分钟 | ||
335 | + } | ||
336 | + } | ||
337 | + | ||
318 | return $result; | 338 | return $result; |
319 | } | 339 | } |
320 | 340 |
@@ -186,15 +186,13 @@ class LoginController extends AbstractAction | @@ -186,15 +186,13 @@ class LoginController extends AbstractAction | ||
186 | $userInfo = $alipay->getUserInfo($access); | 186 | $userInfo = $alipay->getUserInfo($access); |
187 | if ($userInfo && $userInfo['is_success'] === 'T' && isset($userInfo['response']['user_info']['user_name'])) { | 187 | if ($userInfo && $userInfo['is_success'] === 'T' && isset($userInfo['response']['user_info']['user_name'])) { |
188 | $nickname = $userInfo['response']['user_info']['user_name']; | 188 | $nickname = $userInfo['response']['user_info']['user_name']; |
189 | - $alipayEmail = $userInfo['response']['user_info']['email']; | 189 | + // $alipayEmail = $userInfo['response']['user_info']['email']; |
190 | } | 190 | } |
191 | - var_dump($userInfo); | ||
192 | } | 191 | } |
193 | else { | 192 | else { |
194 | $nickname = $_GET['real_name']; | 193 | $nickname = $_GET['real_name']; |
195 | - $alipayEmail = isset($_GET['email']) ? $_GET['email'] : ''; | 194 | + // $alipayEmail = isset($_GET['email']) ? $_GET['email'] : ''; |
196 | } | 195 | } |
197 | - var_dump($access); | ||
198 | 196 | ||
199 | $result = LoginData::signinByOpenID($nickname, $access['user_id'], 'qq'); | 197 | $result = LoginData::signinByOpenID($nickname, $access['user_id'], 'qq'); |
200 | 198 |
-
Please register or login to post a comment