Showing
5 changed files
with
519 additions
and
4 deletions
library/LibModels/Wap/Home/UserData.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace LibModels\Wap\Home; | ||
4 | + | ||
5 | +use Api\Sign; | ||
6 | +use Api\Yohobuy; | ||
7 | + | ||
8 | +/** | ||
9 | + * 个人中心的数据模型 | ||
10 | + * | ||
11 | + * @name UserData | ||
12 | + * @package LibModels/Wap/Home | ||
13 | + * @copyright yoho.inc | ||
14 | + * @version 1.0 (2015-11-09 16:30:27) | ||
15 | + * @author Gtskk <tttt6399998@126.com> | ||
16 | + */ | ||
17 | +class UserData | ||
18 | +{ | ||
19 | + | ||
20 | + /** | ||
21 | + * 个人详情数据 | ||
22 | + * | ||
23 | + * @param int $uid 用户ID | ||
24 | + * @return array 个人详情接口返回的数据 | ||
25 | + */ | ||
26 | + public static function userData($uid) | ||
27 | + { | ||
28 | + $param = Yohobuy::param(); | ||
29 | + $param['method'] = 'app.passport.profile'; | ||
30 | + $param['uid'] = $uid; | ||
31 | + $param['client_secret'] = Sign::getSign($param); | ||
32 | + | ||
33 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
34 | + } | ||
35 | + | ||
36 | + /** | ||
37 | + * 订单数据 | ||
38 | + * | ||
39 | + * @param int $uid 用户ID | ||
40 | + * @param int $type 订单类型,1表示全部,2表示待付款,3表示待发货,4表示待收货,5表示待评价 | ||
41 | + * @param int $page 第几页,默认1 | ||
42 | + * @param int $limit 限制读取的数目,默认10 | ||
43 | + * @return array 订单接口返回的数据 | ||
44 | + */ | ||
45 | + public static function orderData($uid, $type, $page = 1, $limit = 10) | ||
46 | + { | ||
47 | + $param = Yohobuy::param(); | ||
48 | + $param['method'] = 'app.SpaceOrders.get'; | ||
49 | + $param['uid'] = $uid; | ||
50 | + $param['type'] = $type; | ||
51 | + $param['page'] = $page; | ||
52 | + $param['limit'] = $limit; | ||
53 | + $param['client_secret'] = Sign::getSign($param); | ||
54 | + | ||
55 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
56 | + } | ||
57 | + | ||
58 | + /** | ||
59 | + * 收藏的商品数据 | ||
60 | + * | ||
61 | + * @param int $uid 用户ID | ||
62 | + * @param int $page 第几页,默认1 | ||
63 | + * @param int $limit 限制读取的数目,默认10 | ||
64 | + * @return array 收藏的商品接口返回的数据 | ||
65 | + */ | ||
66 | + public static function favoriteProductData($uid, $page = 1, $limit = 10) | ||
67 | + { | ||
68 | + $param = Yohobuy::param(); | ||
69 | + $param['method'] = 'app.favorite.product'; | ||
70 | + $param['uid'] = $uid; | ||
71 | + $param['page'] = $page; | ||
72 | + $param['limit'] = $limit; | ||
73 | + $param['client_secret'] = Sign::getSign($param); | ||
74 | + | ||
75 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * 收藏的品牌数据 | ||
80 | + * | ||
81 | + * @param int $uid 用户ID | ||
82 | + * @param string $gender 性别 1,3表示男,2,3表示女,1,2,3表示全部 | ||
83 | + * @param int $page 第几页,默认1 | ||
84 | + * @param int $limit 限制读取的数目,默认10 | ||
85 | + * @return array 收藏的品牌接口返回的数据 | ||
86 | + */ | ||
87 | + public static function favoriteBrandData($uid, $gender, $page = 1, $limit = 10) | ||
88 | + { | ||
89 | + $param = Yohobuy::param(); | ||
90 | + $param['method'] = 'app.favorite.brand'; | ||
91 | + $param['uid'] = $uid; | ||
92 | + $param['gender'] = $gender; | ||
93 | + $param['page'] = $page; | ||
94 | + $param['limit'] = $limit; | ||
95 | + $param['client_secret'] = Sign::getSign($param); | ||
96 | + | ||
97 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
98 | + } | ||
99 | + | ||
100 | + /** | ||
101 | + * YOHO币数据 | ||
102 | + * | ||
103 | + * @param int $uid 用户ID | ||
104 | + * @param int $page 第几页,默认1 | ||
105 | + * @param int $limit 限制读取的数目,默认10 | ||
106 | + * @return array YOHO币接口返回的数据 | ||
107 | + */ | ||
108 | + public static function yohoCoinData($uid, $page = 1, $limit = 10) | ||
109 | + { | ||
110 | + $param = Yohobuy::param(); | ||
111 | + $param['method'] = 'app.yohocoin.lists'; | ||
112 | + $param['uid'] = $uid; | ||
113 | + $param['page'] = $page; | ||
114 | + $param['limit'] = $limit; | ||
115 | + $param['client_secret'] = Sign::getSign($param); | ||
116 | + | ||
117 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
118 | + } | ||
119 | + | ||
120 | + /** | ||
121 | + * 优惠券数据 | ||
122 | + * | ||
123 | + * @param int $uid 用户ID | ||
124 | + * @param int $status 优惠券状态,0表示未使用,1表示已使用 | ||
125 | + * @param int $page 第几页,默认1 | ||
126 | + * @param int $limit 限制读取的数目,默认10 | ||
127 | + * @return array 优惠券接口返回的数据 | ||
128 | + */ | ||
129 | + public static function couponData($uid, $status, $page = 1, $limit = 10) | ||
130 | + { | ||
131 | + $param = Yohobuy::param(); | ||
132 | + $param['method'] = 'app.yohocoin.lists'; | ||
133 | + $param['uid'] = $uid; | ||
134 | + $param['status'] = $status; | ||
135 | + $param['page'] = $page; | ||
136 | + $param['limit'] = $limit; | ||
137 | + $param['client_secret'] = Sign::getSign($param); | ||
138 | + | ||
139 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
140 | + } | ||
141 | + | ||
142 | + /** | ||
143 | + * 地址数据 | ||
144 | + * | ||
145 | + * @param int $uid 用户ID | ||
146 | + * @return array 地址接口返回的数据 | ||
147 | + */ | ||
148 | + public static function addressData($uid) | ||
149 | + { | ||
150 | + $param = Yohobuy::param(); | ||
151 | + $param['method'] = 'app.address.get'; | ||
152 | + $param['uid'] = $uid; | ||
153 | + $param['client_secret'] = Sign::getSign($param); | ||
154 | + | ||
155 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
156 | + } | ||
157 | + | ||
158 | + /** | ||
159 | + * 意见反馈数据 | ||
160 | + * | ||
161 | + * @param string $udid 客户端唯一标识 | ||
162 | + * @param int $page 第几页,默认1 | ||
163 | + * @param int $limit 限制读取的数目,默认10 | ||
164 | + * @return array 意见反馈接口返回的数据 | ||
165 | + */ | ||
166 | + public static function suggestData($udid, $page = 1, $limit = 30) | ||
167 | + { | ||
168 | + $param = Yohobuy::param(); | ||
169 | + $param['udid'] = $udid; | ||
170 | + $param['page'] = $page; | ||
171 | + $param['limit'] = $limit; | ||
172 | + $param['client_secret'] = Sign::getSign($param); | ||
173 | + | ||
174 | + return Yohobuy::get(Yohobuy::SERVICE_URL . 'suggest/api/v1/suggest/getList', $param); | ||
175 | + } | ||
176 | + | ||
177 | + /** | ||
178 | + * 提交意见反馈接口 | ||
179 | + * | ||
180 | + * @param int $uid 用户ID | ||
181 | + * @param string $content 意见内容 | ||
182 | + * @param int $suggest_type 意见类型 | ||
183 | + * @return array 意见反馈接口返回的数据 | ||
184 | + */ | ||
185 | + public static function suggestData($uid, $content, $suggest_type, $limit = 30) | ||
186 | + { | ||
187 | + $param = Yohobuy::param(); | ||
188 | + $param['uid'] = $uid; | ||
189 | + $param['content'] = $content; | ||
190 | + $param['client_secret'] = Sign::getSign($param); | ||
191 | + | ||
192 | + return Yohobuy::get(Yohobuy::SERVICE_URL . 'suggest/api/v1/suggest/saveSuggest', $param); | ||
193 | + } | ||
194 | + | ||
195 | +} |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | +use Plugin\Helpers; | ||
4 | 5 | ||
5 | /** | 6 | /** |
6 | * 个人中心相关的控制器 | 7 | * 个人中心相关的控制器 |
@@ -18,8 +19,117 @@ class HomeController extends AbstractAction | @@ -18,8 +19,117 @@ class HomeController extends AbstractAction | ||
18 | */ | 19 | */ |
19 | public function indexAction() | 20 | public function indexAction() |
20 | { | 21 | { |
21 | - // 目前跳到老站 | ||
22 | - // $this->go(OLD_MAIN . '/home'); | 22 | + $uid = $uid = $this->getUid();; |
23 | + | ||
24 | + $data = \Index\UserModel::getUserProfileData($uid); | ||
25 | + | ||
26 | + print_r($data); | ||
23 | } | 27 | } |
28 | + | ||
29 | + /** | ||
30 | + * 用户订单 | ||
31 | + */ | ||
32 | + public function ordersAction() | ||
33 | + { | ||
34 | + $uid = $this->getUid(); | ||
35 | + $type = $this->get('type', 1); | ||
36 | + | ||
37 | + $orders = \Index\UserModel::getUserOrderData(967016, $type); | ||
38 | + | ||
39 | + print_r($orders); | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * 用户收藏的商品 | ||
44 | + */ | ||
45 | + public function favoriteAction() | ||
46 | + { | ||
47 | + $uid = $this->getUid(); | ||
48 | + | ||
49 | + $favProducts = \Index\UserModel::getFavProductData($uid); | ||
50 | + | ||
51 | + print_r($favProducts); | ||
52 | + } | ||
53 | + | ||
54 | + /** | ||
55 | + * 用户收藏的品牌 | ||
56 | + */ | ||
57 | + public function favoritebrandAction() | ||
58 | + { | ||
59 | + $uid = $this->getUid(); | ||
60 | + $gender = Helpers::getGenderByCookie(); | ||
61 | + | ||
62 | + $favBrands = \Index\UserModel::getFavBrandData($uid, $gender); | ||
63 | + | ||
64 | + print_r($favBrands); | ||
65 | + } | ||
66 | + | ||
67 | + /** | ||
68 | + * YOHO币 | ||
69 | + */ | ||
70 | + public function currencyAction() | ||
71 | + { | ||
72 | + $uid = $this->getUid(); | ||
73 | + | ||
74 | + $favBrands = \Index\UserModel::getYohoCoinData($uid); | ||
75 | + | ||
76 | + print_r($favBrands); | ||
77 | + } | ||
78 | + | ||
79 | + /** | ||
80 | + * 优惠券 | ||
81 | + */ | ||
82 | + public function couponsAction() | ||
83 | + { | ||
84 | + $uid = $this->getUid(); | ||
85 | + $status = $this->get('status', 0); | ||
86 | + | ||
87 | + $coupons = \Index\UserModel::getCouponData($uid, $status); | ||
88 | + | ||
89 | + print_r($coupons); | ||
90 | + } | ||
91 | + | ||
92 | + /** | ||
93 | + * 地址管理 | ||
94 | + */ | ||
95 | + public function addressAction() | ||
96 | + { | ||
97 | + $uid = $this->getUid(); | ||
98 | + | ||
99 | + $address = \Index\UserModel::getAddressData($uid); | ||
100 | + | ||
101 | + print_r($address); | ||
102 | + } | ||
103 | + | ||
104 | + /** | ||
105 | + * 意见反馈 | ||
106 | + */ | ||
107 | + public function suggestAction() | ||
108 | + { | ||
109 | + $udid = $this->getUdid(); | ||
110 | + $page = $this->get('page', 1); | ||
111 | + $limit = $this->get('limit', 30); | ||
112 | + | ||
113 | + $suggest = \Index\UserModel::getSuggestData($udid, $page, $limit); | ||
114 | + | ||
115 | + print_r($suggest); | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
119 | + * 异步保存意见反馈数据 | ||
120 | + */ | ||
121 | + public function savesuggestAction() | ||
122 | + { | ||
123 | + if($this->isAjax()) { | ||
124 | + $uid = $this->getUid(); | ||
125 | + $content = $this->post('content', ''); | ||
126 | + $suggest_type = $this->get('suggest_type', 2); | ||
127 | + | ||
128 | + $result = \Index\UserModel::saveSuggestData($uid, $content, $suggest_type); | ||
129 | + | ||
130 | + $this->echoJson($result); | ||
131 | + } | ||
132 | + | ||
133 | + } | ||
24 | 134 | ||
25 | } | 135 | } |
@@ -12,9 +12,10 @@ class ShoppingCartController extends AbstractAction | @@ -12,9 +12,10 @@ class ShoppingCartController extends AbstractAction | ||
12 | $this->setTitle('购物车'); | 12 | $this->setTitle('购物车'); |
13 | $this->setNavHeader('购物车'); | 13 | $this->setNavHeader('购物车'); |
14 | 14 | ||
15 | + $uid = $this->getUid(); | ||
15 | $data = array( | 16 | $data = array( |
16 | 'shoppingCartPage' => true, | 17 | 'shoppingCartPage' => true, |
17 | - 'shoppingCart' => \Index\CartModel::getCartData(967016) | 18 | + 'shoppingCart' => \Index\CartModel::getCartData($uid) |
18 | ); | 19 | ); |
19 | 20 | ||
20 | // 渲染模板 | 21 | // 渲染模板 |
@@ -31,7 +31,6 @@ class CartModel | @@ -31,7 +31,6 @@ class CartModel | ||
31 | $cartData = CartData::cartData($uid); | 31 | $cartData = CartData::cartData($uid); |
32 | 32 | ||
33 | // 处理普通购物车和预售购物车的数据 | 33 | // 处理普通购物车和预售购物车的数据 |
34 | - /* 普通购物车 */ | ||
35 | if (isset($cartData['data']) && !empty($cartData['data'])) { | 34 | if (isset($cartData['data']) && !empty($cartData['data'])) { |
36 | $cart = $cartData['data']; | 35 | $cart = $cartData['data']; |
37 | 36 |
1 | +<?php | ||
2 | + | ||
3 | +namespace Index; | ||
4 | + | ||
5 | +use LibModels\Wap\Home\UserData; | ||
6 | +use Plugin\Images; | ||
7 | + | ||
8 | +/** | ||
9 | + * | ||
10 | + * @name UserModel | ||
11 | + * @package models/Index | ||
12 | + * @copyright yoho.inc | ||
13 | + * @version 1.0 (2015-11-09 14:05:09) | ||
14 | + * @author Gtskk (tttt6399998@126.com) | ||
15 | + */ | ||
16 | +class UserModel | ||
17 | +{ | ||
18 | + | ||
19 | + /** | ||
20 | + * 处理用户个人详情数据 | ||
21 | + * | ||
22 | + * @param int $uid 用户ID | ||
23 | + * @return array|mixed 处理之后的个人详情数据 | ||
24 | + */ | ||
25 | + public static function getUserProfileData($uid) | ||
26 | + { | ||
27 | + $result = array(); | ||
28 | + | ||
29 | + // 调用接口获取个人详情 | ||
30 | + $userData = UserData::userData($uid); | ||
31 | + | ||
32 | + // 处理个人详情数据 | ||
33 | + if (isset($userData['data']) && !empty($userData['data'])) { | ||
34 | + $result = $userData['data']; | ||
35 | + | ||
36 | + $result['head_ico'] = Images::getImageUrl($result['head_ico'], 150, 150); | ||
37 | + } | ||
38 | + | ||
39 | + return $result; | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * 处理用户订单数据 | ||
44 | + * | ||
45 | + * @param int $uid 用户ID | ||
46 | + * @param int $type 订单类型,1表示全部,2表示待付款,3表示待发货,4表示待收货,5表示待评价 | ||
47 | + * @return array|mixed 处理之后的个人详情数据 | ||
48 | + */ | ||
49 | + public static function getUserOrderData($uid, $type) | ||
50 | + { | ||
51 | + $result = array(); | ||
52 | + | ||
53 | + // 调用接口获取用户订单数据 | ||
54 | + $orderData = UserData::orderData($uid, $type); | ||
55 | + | ||
56 | + // 处理用户订单数据 | ||
57 | + if (isset($orderData['data']) && !empty($orderData['data'])) { | ||
58 | + $result = $orderData['data']; | ||
59 | + } | ||
60 | + | ||
61 | + return $result; | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * 处理用户收藏的商品数据 | ||
66 | + * | ||
67 | + * @param int $uid 用户ID | ||
68 | + * @return array|mixed 处理之后的收藏的商品数据 | ||
69 | + */ | ||
70 | + public static function getFavProductData($uid) | ||
71 | + { | ||
72 | + $result = array(); | ||
73 | + | ||
74 | + // 调用接口获取用户收藏的商品数据 | ||
75 | + $favProduct = UserData::favoriteProductData($uid); | ||
76 | + | ||
77 | + // 处理用户收藏的商品数据 | ||
78 | + if (isset($favProduct['data']) && !empty($favProduct['data'])) { | ||
79 | + $result = $favProduct['data']; | ||
80 | + } | ||
81 | + | ||
82 | + return $result; | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * 处理用户收藏的品牌数据 | ||
87 | + * | ||
88 | + * @param int $uid 用户ID | ||
89 | + * @param string $gender 性别 1,3表示男,2,3表示女,1,2,3表示全部 | ||
90 | + * @return array|mixed 处理之后的收藏的品牌数据 | ||
91 | + */ | ||
92 | + public static function getFavBrandData($uid, $gender) | ||
93 | + { | ||
94 | + $result = array(); | ||
95 | + | ||
96 | + // 调用接口获取户收藏的品牌数据 | ||
97 | + $favBrand = UserData::favoriteBrandData($uid, $gender); | ||
98 | + | ||
99 | + // 处理用户收藏的品牌数据 | ||
100 | + if (isset($favBrand['data']) && !empty($favBrand['data'])) { | ||
101 | + $result = $favBrand['data']; | ||
102 | + } | ||
103 | + | ||
104 | + return $result; | ||
105 | + } | ||
106 | + | ||
107 | + /** | ||
108 | + * 处理YOHO币数据 | ||
109 | + * | ||
110 | + * @param int $uid 用户ID | ||
111 | + * @return array|mixed 处理之后的YOHO币数据 | ||
112 | + */ | ||
113 | + public static function getYohoCoinData($uid) | ||
114 | + { | ||
115 | + $result = array(); | ||
116 | + | ||
117 | + // 调用接口获取YOHO币 | ||
118 | + $yohoCoin = UserData::yohoCoinData($uid); | ||
119 | + | ||
120 | + // 处理YOHO币数据 | ||
121 | + if (isset($yohoCoin['data']) && !empty($yohoCoin['data'])) { | ||
122 | + $result = $yohoCoin['data']; | ||
123 | + } | ||
124 | + | ||
125 | + return $result; | ||
126 | + } | ||
127 | + | ||
128 | + /** | ||
129 | + * 处理优惠券数据 | ||
130 | + * | ||
131 | + * @param int $uid 用户ID | ||
132 | + * @return array|mixed 处理之后的优惠券数据 | ||
133 | + */ | ||
134 | + public static function getCouponData($uid, $status) | ||
135 | + { | ||
136 | + $result = array(); | ||
137 | + | ||
138 | + // 调用接口获取优惠券数据 | ||
139 | + $coupons = UserData::couponData($uid, $status); | ||
140 | + | ||
141 | + // 处理优惠券数据 | ||
142 | + if (isset($coupons['data']) && !empty($coupons['data'])) { | ||
143 | + $result = $coupons['data']; | ||
144 | + } | ||
145 | + | ||
146 | + return $result; | ||
147 | + } | ||
148 | + | ||
149 | + /** | ||
150 | + * 处理地址数据 | ||
151 | + * | ||
152 | + * @param int $uid 用户ID | ||
153 | + * @return array|mixed 处理之后的地址数据 | ||
154 | + */ | ||
155 | + public static function getAddressData($uid) | ||
156 | + { | ||
157 | + $result = array(); | ||
158 | + | ||
159 | + // 调用接口获取地址数据 | ||
160 | + $address = UserData::addressData($uid); | ||
161 | + | ||
162 | + // 处理地址数据 | ||
163 | + if (isset($address['data']) && !empty($address['data'])) { | ||
164 | + $result = $address['data']; | ||
165 | + } | ||
166 | + | ||
167 | + return $result; | ||
168 | + } | ||
169 | + | ||
170 | + /** | ||
171 | + * 处理意见反馈数据 | ||
172 | + * | ||
173 | + * @param string $udid 客户端唯一标识 | ||
174 | + * @param int $page 第几页,默认1 | ||
175 | + * @param int $limit 限制读取的数目,默认10 | ||
176 | + * @return array|mixed 处理之后的意见反馈数据 | ||
177 | + */ | ||
178 | + public static function getSuggestData($udid, $page, $limit) | ||
179 | + { | ||
180 | + $result = array(); | ||
181 | + | ||
182 | + // 调用接口获取地址数据 | ||
183 | + $suggest = UserData::suggestData($udid, $page, $limit); | ||
184 | + print_r($suggest); | ||
185 | + | ||
186 | + // 处理意见反馈数据 | ||
187 | + if (isset($suggest['data']) && !empty($suggest['data'])) { | ||
188 | + $result = $suggest['data']; | ||
189 | + } | ||
190 | + | ||
191 | + return $result; | ||
192 | + } | ||
193 | + | ||
194 | + /** | ||
195 | + * 保存意见反馈数据 | ||
196 | + * | ||
197 | + * @param int $uid 用户ID | ||
198 | + * @param string $content 意见内容 | ||
199 | + * @param int $suggest_type 意见类型 | ||
200 | + * @return array|mixed 保存意见反馈数据之后的返回 | ||
201 | + */ | ||
202 | + public static function saveSuggestData($uid, $content, $suggest_type) | ||
203 | + { | ||
204 | + $result = array(); | ||
205 | + | ||
206 | + // 调用接口保存意见反馈数据 | ||
207 | + return UserData::suggestData($uid, $content, $suggest_type); | ||
208 | + } | ||
209 | + | ||
210 | +} |
-
Please register or login to post a comment