先删除home文件夹,改大写。优化gradedata.php
Showing
3 changed files
with
2 additions
and
162 deletions
@@ -15,10 +15,11 @@ class GradeData | @@ -15,10 +15,11 @@ class GradeData | ||
15 | /** | 15 | /** |
16 | * 获取会员等级数据 | 16 | * 获取会员等级数据 |
17 | * @param string $yh_channel 频道数据,1->男,2->女,3->潮童,4->创意生活,5->其他 | 17 | * @param string $yh_channel 频道数据,1->男,2->女,3->潮童,4->创意生活,5->其他 |
18 | + * @param strint $gender 用户性别 | ||
18 | * @param string $uid 用户id | 19 | * @param string $uid 用户id |
19 | * @return array 接口返回的会员等级数据 | 20 | * @return array 接口返回的会员等级数据 |
20 | */ | 21 | */ |
21 | - public function getGradeData($channel, $uid) { | 22 | + public function getGradeData($gender,$channel, $uid) { |
22 | $urlList = array(); | 23 | $urlList = array(); |
23 | //获取会员等级数据 | 24 | //获取会员等级数据 |
24 | $param = Yohobuy::param(); | 25 | $param = Yohobuy::param(); |
@@ -29,7 +30,6 @@ class GradeData | @@ -29,7 +30,6 @@ class GradeData | ||
29 | $urlList['grade'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); | 30 | $urlList['grade'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); |
30 | 31 | ||
31 | //获取用户基本信息数据(用来得到username) | 32 | //获取用户基本信息数据(用来得到username) |
32 | - $param = array(); | ||
33 | $param = Yohobuy::param(); | 33 | $param = Yohobuy::param(); |
34 | $param['gender'] = $gender; | 34 | $param['gender'] = $gender; |
35 | $param['uid'] = $uid; | 35 | $param['uid'] = $uid; |
@@ -39,7 +39,6 @@ class GradeData | @@ -39,7 +39,6 @@ class GradeData | ||
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 | - //return Yohobuy::get(Yohobuy::API_URL, $param); | ||
43 | } | 42 | } |
44 | 43 | ||
45 | /** | 44 | /** |
@@ -58,18 +57,4 @@ class GradeData | @@ -58,18 +57,4 @@ class GradeData | ||
58 | return Yohobuy::get(Yohobuy::API_URL, $param); | 57 | return Yohobuy::get(Yohobuy::API_URL, $param); |
59 | } | 58 | } |
60 | 59 | ||
61 | -// /** | ||
62 | -// * 获取用户基本信息数据 | ||
63 | -// */ | ||
64 | -// public function getUserProfileData($gender, $uid, $channel) { | ||
65 | -// $param = Yohobuy::param(); | ||
66 | -// $param['gender'] = $gender; | ||
67 | -// $param['uid'] = $uid; | ||
68 | -// $param['yh_channel'] = $channel; | ||
69 | -// $param['method'] = 'app.passport.profile'; | ||
70 | -// $param['client_secret'] = Sign::getSign($param); | ||
71 | -// | ||
72 | -// return Yohobuy::get("http://api.open.yohobuy.com/",$param); | ||
73 | -// } | ||
74 | - | ||
75 | } | 60 | } |
1 | -<?php | ||
2 | - | ||
3 | -namespace home; | ||
4 | - | ||
5 | -use LibModels\Wap\Home\GradeData; | ||
6 | -use Action\AbstractAction; | ||
7 | -use Plugin\Helpers; | ||
8 | - | ||
9 | -/** | ||
10 | - * 会员等级相关数据处理 | ||
11 | - */ | ||
12 | -class GradeModel | ||
13 | -{ | ||
14 | - /* | ||
15 | - * 获取个人中心-会员等级数据 | ||
16 | - */ | ||
17 | - | ||
18 | - public function getGrade($gender, $channel, $uid) { | ||
19 | - $result = array(); | ||
20 | - | ||
21 | - if (USE_CACHE) { | ||
22 | - // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
23 | - $result = Cache::get(CacheConfig::KEY_ACTION_HOME_GRADE, 'master'); | ||
24 | - if (!empty($result)) { | ||
25 | - return $result; | ||
26 | - } | ||
27 | - } | ||
28 | - //调用接口获取数据 | ||
29 | - $data = GradeData::getGradeData($gender,$channel, $uid); | ||
30 | - print_r($data); | ||
31 | - if (isset($data['code']) && $data['code'] === 200 && isset($data['data'])) { | ||
32 | - switch (intval($data['data']['current_vip_level'])) { | ||
33 | - case 0://普通会员 | ||
34 | - $result['vipGrade']['vip0'] = true; | ||
35 | - break; | ||
36 | - case 1://银卡会员 | ||
37 | - $result['vipGrade']['vip1'] = true; | ||
38 | - break; | ||
39 | - case 2://金卡会员 | ||
40 | - $result['vipGrade']['vip2'] = true; | ||
41 | - break; | ||
42 | - case 3://白金会员 | ||
43 | - $result['vipGrade']['vip3'] = true; | ||
44 | - break; | ||
45 | - } | ||
46 | - | ||
47 | - //今年总消费 | ||
48 | - $result['vipGrade']['costOfThisYear'] = $data['data']['current_year_cost']; | ||
49 | - //升级下一等级会员的进度; | ||
50 | - $result['vipGrade']['percent'] = 100*(round($data['data']['current_total_cost'] / $data['data']['next_need_cost'], 2)); | ||
51 | - //距离升级所需消费金额 | ||
52 | - | ||
53 | - if ($data['data']['current_vip_level'] != 3) { | ||
54 | - $result['vipGrade']['costGap'] = $data['data']['upgrade_need_cost']; | ||
55 | - } | ||
56 | - //消费总计 | ||
57 | - $result['vipGrade']['sumCost'] = $data['data']['current_total_cost']; | ||
58 | - //username 调用获取用户基本信息数据,获得username; | ||
59 | - $userProfile = GradeData::getUserProfileData($gender,$uid,$channel); | ||
60 | - $result['vipGrade']['name'] = $userProfile['data']['username']; | ||
61 | - //跳转url(会员特权详情) | ||
62 | - $result['vipGrade']['allUrl'] = Helpers::url('/Home/preferential',null); | ||
63 | - //当前vip等级享受的特权 | ||
64 | - $result['vipGrade']['privilege'] = $data['data']['enjoy_preferential']; | ||
65 | - } | ||
66 | - | ||
67 | - if (USE_CACHE) { | ||
68 | - // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
69 | - if (empty($result)) { | ||
70 | - $result = Cache::get(CacheConfig::KEY_ACTION_HOME_GRADE, 'slave'); | ||
71 | - } | ||
72 | - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
73 | - else { | ||
74 | - Cache::set(CacheConfig::KEY_ACTION_HOME_GRADE, $result); | ||
75 | - } | ||
76 | - } | ||
77 | - | ||
78 | - return $result; | ||
79 | - } | ||
80 | - | ||
81 | - /* | ||
82 | - * 获取个人中心-会员特权详情页 | ||
83 | - */ | ||
84 | - | ||
85 | - public function getPreferential($channel, $uid) { | ||
86 | - $result = array(); | ||
87 | - | ||
88 | - if (USE_CACHE) { | ||
89 | - // 先尝试获取一级缓存(master), 有数据则直接返回. | ||
90 | - $result = Cache::get(CacheConfig::KEY_ACTION_HOME_PREFERENTIAL, 'master'); | ||
91 | - if (!empty($result)) { | ||
92 | - return $result; | ||
93 | - } | ||
94 | - } | ||
95 | - //调取接口获得数据 | ||
96 | - $data = GradeData::getPreferentialData($channel, $uid); | ||
97 | - if (isset($data['code']) && $data['code'] == 200) { | ||
98 | - $result['vipGrade']['privilege'] = $data['data']; | ||
99 | - } | ||
100 | - | ||
101 | - | ||
102 | - if (USE_CACHE) { | ||
103 | - // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. | ||
104 | - if (empty($result)) { | ||
105 | - $result = Cache::get(CacheConfig::KEY_ACTION_HOME_GRADE, 'slave'); | ||
106 | - } | ||
107 | - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 | ||
108 | - else { | ||
109 | - Cache::set(CacheConfig::KEY_ACTION_HOME_PREFERENTIAL, $result); | ||
110 | - } | ||
111 | - } | ||
112 | - | ||
113 | - return $result; | ||
114 | - } | ||
115 | - | ||
116 | -} |
1 | -<?php | ||
2 | - | ||
3 | - namespace home; | ||
4 | - | ||
5 | - use LibModels\Wap\Home\OrderData; | ||
6 | -/* | ||
7 | - * To change this license header, choose License Headers in Project Properties. | ||
8 | - * To change this template file, choose Tools | Templates | ||
9 | - * and open the template in the editor. | ||
10 | - */ | ||
11 | - | ||
12 | -/** | ||
13 | - * Description of Order | ||
14 | - * | ||
15 | - */ | ||
16 | -class OrderModel | ||
17 | -{ | ||
18 | - | ||
19 | - /** | ||
20 | - * 订单相关数据处理 | ||
21 | - */ | ||
22 | - public function getOrder($type = 1,$page = 1,$limit,$gender,$yh_channel,$uid){ | ||
23 | - | ||
24 | - $data = OrderData::getOrderData($type,$page,$limit,$gender,$yh_channel,$uid); | ||
25 | - | ||
26 | - return $data; | ||
27 | - } | ||
28 | - | ||
29 | -} |
-
Please register or login to post a comment