Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop
Showing
30 changed files
with
1318 additions
and
1153 deletions
@@ -1316,3 +1316,29 @@ | @@ -1316,3 +1316,29 @@ | ||
1316 | ] | 1316 | ] |
1317 | } | 1317 | } |
1318 | 1318 | ||
1319 | + | ||
1320 | +### 频道选择页 | ||
1321 | + { | ||
1322 | + 'background' : 'http://img11.static.yhbimg.com/yhb-img01/2015/12/14/03/0189f7499bcb98cbeb4d18d61275606716.png?imageView/2/w/640/h/800', | ||
1323 | + 'searchUrl' : 'http://search.dev.yohobuy.com', | ||
1324 | + 'channelList' : [ | ||
1325 | + { | ||
1326 | + 'href' : '/boys', | ||
1327 | + 'title' : '男生', | ||
1328 | + 'entitle' : 'BOYS', | ||
1329 | + }, { | ||
1330 | + 'href' : '/girls', | ||
1331 | + 'title' : ' 女生', | ||
1332 | + 'entitle' : 'GIRLS', | ||
1333 | + }, { | ||
1334 | + 'href' : '/kids', | ||
1335 | + 'title' : '潮童', | ||
1336 | + 'entitle' : KIDS'', | ||
1337 | + }, { | ||
1338 | + 'href' : '/lifestyle', | ||
1339 | + 'title' : '创意生活', | ||
1340 | + 'entitle' : 'LIFESTYLE', | ||
1341 | + } | ||
1342 | + ], | ||
1343 | + 'showYohood' : true/false | ||
1344 | + } |
@@ -17,257 +17,294 @@ use Api\Yohobuy; | @@ -17,257 +17,294 @@ use Api\Yohobuy; | ||
17 | class CartData | 17 | class CartData |
18 | { | 18 | { |
19 | 19 | ||
20 | - /** | ||
21 | - * 加入购物车接口 | ||
22 | - * | ||
23 | - * @param int $productSku 商品SKU | ||
24 | - * @param int $buyNumber 购买数量 | ||
25 | - * @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品 | ||
26 | - * @param int $isEdit 是否是编辑商品SKU,0表示不是编辑 | ||
27 | - * @param null|int $promotionId 促销id,默认null(加价购有关) | ||
28 | - * @param null|int $uid 用户UID,可以不传 | ||
29 | - * @param string $shoppingKey 购物的凭证 | ||
30 | - * @return array 加入购物车接口返回的数据 | ||
31 | - */ | ||
32 | - public static function addToCart($productSku, $buyNumber, $goodsType, $isEdit = 0, $promotionId = null, $uid = null, $shoppingKey = '') | ||
33 | - { | ||
34 | - $param = Yohobuy::param(); | ||
35 | - $param['method'] = 'app.Shopping.add'; | ||
36 | - $param['product_sku'] = $productSku; | ||
37 | - $param['buy_number'] = $buyNumber; | ||
38 | - $param['goods_type'] = $goodsType; | ||
39 | - $param['edit_product_sku'] = $isEdit; | ||
40 | - $param['selected'] = 'Y'; | ||
41 | - $param['promotion_id'] = $promotionId; | ||
42 | - $param['shopping_key'] = $shoppingKey; | ||
43 | - | ||
44 | - if (!empty($uid)) { | ||
45 | - $param['uid'] = $uid; | ||
46 | - } | ||
47 | - $param['client_secret'] = Sign::getSign($param); | ||
48 | - | ||
49 | - return Yohobuy::get(Yohobuy::API_URL, $param); | ||
50 | - } | ||
51 | - | ||
52 | - /** | ||
53 | - * 购物车数据 | ||
54 | - * | ||
55 | - * @param int $uid 用户ID | ||
56 | - * @param string $shoppingKey 未登录用户唯一识别码 | ||
57 | - * @return array 购物车接口返回的数据 | ||
58 | - */ | ||
59 | - public static function cartData($uid, $shoppingKey) | ||
60 | - { | ||
61 | - $param = Yohobuy::param(); | ||
62 | - $param['method'] = 'app.Shopping.cart'; | ||
63 | - | ||
64 | - if (!empty($uid)) { | ||
65 | - $param['uid'] = $uid; | ||
66 | - } | ||
67 | - if (!empty($shoppingKey)) { | ||
68 | - $param['shopping_key'] = $shoppingKey; | ||
69 | - } | ||
70 | - | ||
71 | - $param['client_secret'] = Sign::getSign($param); | ||
72 | - | ||
73 | - return Yohobuy::get(Yohobuy::API_URL, $param); | ||
74 | - } | ||
75 | - | ||
76 | - /** | ||
77 | - * 移出购物车 | ||
78 | - * | ||
79 | - * @param int $uid 用户ID | ||
80 | - * @param string $sku 商品sku列表 | ||
81 | - * @param string $shoppingKey 未登录用户唯一识别码 | ||
82 | - * @return array 接口返回的数据 | ||
83 | - */ | ||
84 | - public static function removeFromCart($uid, $sku, $shoppingKey) | ||
85 | - { | ||
86 | - $param = Yohobuy::param(); | ||
87 | - $param['method'] = 'app.Shopping.remove'; | ||
88 | - $param['product_sku_list'] = $sku; | ||
89 | - | ||
90 | - if (!empty($uid)) { | ||
91 | - $param['uid'] = $uid; | ||
92 | - } | ||
93 | - if (!empty($shoppingKey)) { | ||
94 | - $param['shopping_key'] = $shoppingKey; | ||
95 | - } | ||
96 | - | ||
97 | - $param['client_secret'] = Sign::getSign($param); | ||
98 | - | ||
99 | - return Yohobuy::get(Yohobuy::API_URL, $param); | ||
100 | - } | ||
101 | - | ||
102 | - /** | ||
103 | - * 移入收藏夹 | ||
104 | - * | ||
105 | - * @param int $uid 用户ID | ||
106 | - * @param string $sku 商品sku列表 | ||
107 | - * @return array 接口返回的数据 | ||
108 | - */ | ||
109 | - public static function addToFav($uid, $sku) | ||
110 | - { | ||
111 | - $param = Yohobuy::param(); | ||
112 | - $param['method'] = 'app.Shopping.addfavorite'; | ||
113 | - $param['product_sku_list'] = $sku; | ||
114 | - $param['uid'] = $uid; | ||
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 $skn 商品skn | ||
125 | - * @return array 接口返回的数据 | ||
126 | - */ | ||
127 | - public static function cartProductData($uid, $skn) | ||
128 | - { | ||
129 | - $param = Yohobuy::param(); | ||
130 | - $param['method'] = 'app.product.data'; | ||
131 | - $param['product_skn'] = $skn; | ||
132 | - $param['showcomment'] = 'N'; | ||
133 | - $param['uid'] = $uid; | ||
134 | - $param['client_secret'] = Sign::getSign($param); | ||
135 | - | ||
136 | - return Yohobuy::get(Yohobuy::API_URL, $param); | ||
137 | - } | ||
138 | - | ||
139 | - /** | ||
140 | - * 获取加价购商品数据 | ||
141 | - * | ||
142 | - * @param int $skn 商品skn | ||
143 | - * @param int $promotionId 加价购商品促销ID | ||
144 | - * @return array 接口返回的数据 | ||
145 | - */ | ||
146 | - public static function giftProductData($skn, $promotionId) | ||
147 | - { | ||
148 | - $param = Yohobuy::param(); | ||
149 | - $param['method'] = 'app.product.gift'; | ||
150 | - $param['product_skn'] = $skn; | ||
151 | - $param['promotion_id'] = $promotionId; | ||
152 | - $param['client_secret'] = Sign::getSign($param); | ||
153 | - | ||
154 | - return Yohobuy::get(Yohobuy::API_URL, $param); | ||
155 | - } | ||
156 | - | ||
157 | - /** | ||
158 | - * 修改购物车商品数据 | ||
159 | - * | ||
160 | - * @param int $uid 用户ID | ||
161 | - * @param string $swapData 商品数据 | ||
162 | - * @param string $shoppingKey 未登录用户唯一识别码 | ||
163 | - * @return array 接口返回的数据 | ||
164 | - */ | ||
165 | - public static function modifyCartProduct($uid, $swapData, $shoppingKey) | ||
166 | - { | ||
167 | - $param = Yohobuy::param(); | ||
168 | - $param['method'] = 'app.Shopping.swap'; | ||
169 | - $param['swap_data'] = $swapData; | ||
170 | - | ||
171 | - if (!empty($uid)) { | ||
172 | - $param['uid'] = $uid; | ||
173 | - } | ||
174 | - if ($shoppingKey !== null) { | ||
175 | - $param['shopping_key'] = $shoppingKey; | ||
176 | - } | ||
177 | - | ||
178 | - $param['client_secret'] = Sign::getSign($param); | ||
179 | - | ||
180 | - return Yohobuy::get(Yohobuy::API_URL, $param); | ||
181 | - } | ||
182 | - | ||
183 | - /** | ||
184 | - * 购物车结算 | ||
185 | - * | ||
186 | - * @param int $uid 用户ID | ||
187 | - * @param string $cartType 购物车类型,ordinary表示普通购物车 | ||
188 | - * @return array 接口返回的数据 | ||
189 | - */ | ||
190 | - public static function cartPay($uid, $cartType) | ||
191 | - { | ||
192 | - $param = Yohobuy::param(); | ||
193 | - $param['method'] = 'app.Shopping.payment'; | ||
194 | - $param['cart_type'] = $cartType; | ||
195 | - $param['uid'] = $uid; | ||
196 | - $param['client_secret'] = Sign::getSign($param); | ||
197 | - | ||
198 | - return Yohobuy::get(Yohobuy::API_URL, $param); | ||
199 | - } | ||
200 | - | ||
201 | - /** | ||
202 | - * 购物车结算--支付方式和配送方式选择 | ||
203 | - * | ||
204 | - * @param int $uid 用户ID | ||
205 | - * @param string $cartType 购物车类型,ordinary表示普通购物车 | ||
206 | - * @param string $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运 | ||
207 | - * @param string $paymentType 支付方式,1表示在线支付,2表示货到付款 | ||
208 | - * @param string $yohoCoin 使用的YOHO币数量,默认为null表示不适用 | ||
209 | - * @return array 接口返回的数据 | ||
210 | - */ | ||
211 | - public static function paymentTypeAndDelivery($uid, $cartType, $deliveryWay, $paymentType, $yohoCoin = null) | ||
212 | - { | ||
213 | - $param = Yohobuy::param(); | ||
214 | - $param['method'] = 'app.Shopping.compute'; | ||
215 | - $param['cart_type'] = $cartType; | ||
216 | - $param['delivery_way'] = $deliveryWay; | ||
217 | - $param['payment_type'] = $paymentType; | ||
218 | - if ($yohoCoin !== null) { | ||
219 | - $param['use_yoho_coin'] = $yohoCoin; | ||
220 | - } | ||
221 | - | ||
222 | - $param['uid'] = $uid; | ||
223 | - $param['client_secret'] = Sign::getSign($param); | ||
224 | - | ||
225 | - return Yohobuy::get(Yohobuy::API_URL, $param); | ||
226 | - } | ||
227 | - | ||
228 | - /** | ||
229 | - * 购物车结算--使用优惠券 | ||
230 | - * | ||
231 | - * @param int $uid 用户ID | ||
232 | - * @param string $couponCode 优惠券代码 | ||
233 | - * @return array 接口返回的数据 | ||
234 | - */ | ||
235 | - public static function getCoupon($uid, $couponCode) | ||
236 | - { | ||
237 | - $param = Yohobuy::param(); | ||
238 | - $param['method'] = 'app.Shopping.useCoupon'; | ||
239 | - $param['coupon_code'] = $couponCode; | ||
240 | - $param['uid'] = $uid; | ||
241 | - $param['client_secret'] = Sign::getSign($param); | ||
242 | - | ||
243 | - return Yohobuy::get(Yohobuy::API_URL, $param); | ||
244 | - } | ||
245 | - | ||
246 | - /** | ||
247 | - * 购物车结算--提交结算信息 | ||
248 | - * | ||
249 | - * @param int $uid 用户ID | ||
250 | - * @param string $couponCode 优惠券代码 | ||
251 | - * @return array 接口返回的数据 | ||
252 | - */ | ||
253 | - public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin) | ||
254 | - { | ||
255 | - $param = Yohobuy::param(); | ||
256 | - $param['method'] = 'app.Shopping.submit'; | ||
257 | - $param['addressId'] = $addressId; | ||
258 | - $param['cart_type'] = $cartType; | ||
259 | - $param['delivery_time'] = $deliveryTime; | ||
260 | - $param['delivery_way'] = $deliveryWay; | ||
261 | - $param['invoices_title'] = $invoiceTitle; | ||
262 | - $param['invoices_type_id'] = $invoiceId; | ||
263 | - $param['payment_id'] = $paymentId; | ||
264 | - $param['payment_type'] = $paymentType; | ||
265 | - $param['remark'] = $remark; | ||
266 | - $param['use_yoho_coin'] = $yohoCoin; | ||
267 | - $param['uid'] = $uid; | ||
268 | - $param['client_secret'] = Sign::getSign($param); | ||
269 | - | ||
270 | - return Yohobuy::get(Yohobuy::API_URL, $param); | ||
271 | - } | 20 | + /** |
21 | + * 加入购物车接口 | ||
22 | + * | ||
23 | + * @param int $productSku 商品SKU | ||
24 | + * @param int $buyNumber 购买数量 | ||
25 | + * @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品 | ||
26 | + * @param int int $isEdit 是否是编辑商品SKU,0表示不是编辑 | ||
27 | + * @param null|int $promotionId 促销id,默认null(加价购有关) | ||
28 | + * @param null|int $uid 用户UID,可以不传 | ||
29 | + * @return array 加入购物车接口返回的数据 | ||
30 | + */ | ||
31 | + public static function addToCart($productSku, $buyNumber, $goodsType, $isEdit = 0, $promotionId = null, $uid = null) | ||
32 | + { | ||
33 | + $param = Yohobuy::param(); | ||
34 | + $param['method'] = 'app.Shopping.add'; | ||
35 | + $param['product_sku'] = $productSku; | ||
36 | + $param['buy_number'] = $buyNumber; | ||
37 | + $param['goods_type'] = $goodsType; | ||
38 | + $param['edit_product_sku'] = $isEdit; | ||
39 | + $param['selected'] = 'Y'; | ||
40 | + $param['promotion_id'] = $promotionId; | ||
41 | + | ||
42 | + if ($uid !== null) { | ||
43 | + $param['uid'] = $uid; | ||
44 | + } | ||
45 | + $param['client_secret'] = Sign::getSign($param); | ||
46 | + | ||
47 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
48 | + } | ||
49 | + | ||
50 | + /** | ||
51 | + * 购物车数据 | ||
52 | + * | ||
53 | + * @param int $uid 用户ID | ||
54 | + * @param string $shoppingKey 未登录用户唯一识别码 | ||
55 | + * @return array 购物车接口返回的数据 | ||
56 | + */ | ||
57 | + public static function cartData($uid, $shoppingKey) | ||
58 | + { | ||
59 | + $param = Yohobuy::param(); | ||
60 | + $param['method'] = 'app.Shopping.cart'; | ||
61 | + | ||
62 | + if (!empty($uid)) { | ||
63 | + $param['uid'] = $uid; | ||
64 | + } | ||
65 | + if (!empty($shoppingKey)) { | ||
66 | + $param['shopping_key'] = $shoppingKey; | ||
67 | + } | ||
68 | + | ||
69 | + $param['client_secret'] = Sign::getSign($param); | ||
70 | + | ||
71 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
72 | + } | ||
73 | + | ||
74 | + /** | ||
75 | + * 移出购物车 | ||
76 | + * | ||
77 | + * @param int $uid 用户ID | ||
78 | + * @param string $sku 商品sku列表 | ||
79 | + * @param string $shoppingKey 未登录用户唯一识别码 | ||
80 | + * @return array 接口返回的数据 | ||
81 | + */ | ||
82 | + public static function removeFromCart($uid, $sku, $shoppingKey) | ||
83 | + { | ||
84 | + $param = Yohobuy::param(); | ||
85 | + $param['method'] = 'app.Shopping.remove'; | ||
86 | + $param['product_sku_list'] = $sku; | ||
87 | + | ||
88 | + if (!empty($uid)) { | ||
89 | + $param['uid'] = $uid; | ||
90 | + } | ||
91 | + if (!empty($shoppingKey)) { | ||
92 | + $param['shopping_key'] = $shoppingKey; | ||
93 | + } | ||
94 | + | ||
95 | + $param['client_secret'] = Sign::getSign($param); | ||
96 | + | ||
97 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
98 | + } | ||
99 | + | ||
100 | + /** | ||
101 | + * 移入收藏夹 | ||
102 | + * | ||
103 | + * @param int $uid 用户ID | ||
104 | + * @param string $sku 商品sku列表 | ||
105 | + * @return array 接口返回的数据 | ||
106 | + */ | ||
107 | + public static function addToFav($uid, $sku) | ||
108 | + { | ||
109 | + $param = Yohobuy::param(); | ||
110 | + $param['method'] = 'app.Shopping.addfavorite'; | ||
111 | + $param['product_sku_list'] = $sku; | ||
112 | + $param['uid'] = $uid; | ||
113 | + $param['client_secret'] = Sign::getSign($param); | ||
114 | + | ||
115 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
119 | + * 获取购物车商品数据 | ||
120 | + * | ||
121 | + * @param int $uid 用户ID | ||
122 | + * @param int $skn 商品skn | ||
123 | + * @return array 接口返回的数据 | ||
124 | + */ | ||
125 | + public static function cartProductData($uid, $skn) | ||
126 | + { | ||
127 | + $param = Yohobuy::param(); | ||
128 | + $param['method'] = 'app.product.data'; | ||
129 | + $param['product_skn'] = $skn; | ||
130 | + $param['showcomment'] = 'N'; | ||
131 | + $param['uid'] = $uid; | ||
132 | + $param['client_secret'] = Sign::getSign($param); | ||
133 | + | ||
134 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
135 | + } | ||
136 | + | ||
137 | + /** | ||
138 | + * 获取加价购商品数据 | ||
139 | + * | ||
140 | + * @param int $skn 商品skn | ||
141 | + * @param int $promotionId 加价购商品促销ID | ||
142 | + * @return array 接口返回的数据 | ||
143 | + */ | ||
144 | + public static function giftProductData($skn, $promotionId) | ||
145 | + { | ||
146 | + $param = Yohobuy::param(); | ||
147 | + $param['method'] = 'app.product.gift'; | ||
148 | + $param['product_skn'] = $skn; | ||
149 | + $param['promotion_id'] = $promotionId; | ||
150 | + $param['client_secret'] = Sign::getSign($param); | ||
151 | + | ||
152 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
153 | + } | ||
154 | + | ||
155 | + /** | ||
156 | + * 修改购物车商品数据 | ||
157 | + * | ||
158 | + * @param int $uid 用户ID | ||
159 | + * @param string $swapData 商品数据 | ||
160 | + * @param string $shoppingKey 未登录用户唯一识别码 | ||
161 | + * @return array 接口返回的数据 | ||
162 | + */ | ||
163 | + public static function modifyCartProduct($uid, $swapData, $shoppingKey) | ||
164 | + { | ||
165 | + $param = Yohobuy::param(); | ||
166 | + $param['method'] = 'app.Shopping.swap'; | ||
167 | + $param['swap_data'] = $swapData; | ||
168 | + | ||
169 | + if (!empty($uid)) { | ||
170 | + $param['uid'] = $uid; | ||
171 | + } | ||
172 | + if ($shoppingKey !== null) { | ||
173 | + $param['shopping_key'] = $shoppingKey; | ||
174 | + } | ||
175 | + | ||
176 | + $param['client_secret'] = Sign::getSign($param); | ||
177 | + | ||
178 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
179 | + } | ||
180 | + | ||
181 | + /** | ||
182 | + * 购物车结算 | ||
183 | + * | ||
184 | + * @param int $uid 用户ID | ||
185 | + * @param string $cartType 购物车类型,ordinary表示普通购物车 | ||
186 | + * @return array 接口返回的数据 | ||
187 | + */ | ||
188 | + public static function cartPay($uid, $cartType) | ||
189 | + { | ||
190 | + $param = Yohobuy::param(); | ||
191 | + $param['method'] = 'app.Shopping.payment'; | ||
192 | + $param['cart_type'] = $cartType; | ||
193 | + $param['uid'] = $uid; | ||
194 | + $param['client_secret'] = Sign::getSign($param); | ||
195 | + | ||
196 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
197 | + } | ||
198 | + | ||
199 | + /** | ||
200 | + * 购物车结算--支付方式和配送方式选择 | ||
201 | + * | ||
202 | + * @param int $uid 用户ID | ||
203 | + * @param string $cartType 购物车类型,ordinary表示普通购物车 | ||
204 | + * @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运 | ||
205 | + * @param int $paymentType 支付方式,1表示在线支付,2表示货到付款 | ||
206 | + * @param string $couponCode 优惠券码 | ||
207 | + * @param mixed $yohoCoin 使用的YOHO币数量 | ||
208 | + * @return array 接口返回的数据 | ||
209 | + */ | ||
210 | + public static function orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin) | ||
211 | + { | ||
212 | + $param = Yohobuy::param(); | ||
213 | + $param['method'] = 'app.Shopping.compute'; | ||
214 | + $param['cart_type'] = $cartType; | ||
215 | + $param['delivery_way'] = $deliveryWay; | ||
216 | + $param['payment_type'] = $paymentType; | ||
217 | + if (!empty($couponCode)) { | ||
218 | + $param['coupon_code'] = $couponCode; | ||
219 | + } | ||
220 | + if (!empty($yohoCoin)) { | ||
221 | + $param['use_yoho_coin'] = $yohoCoin; | ||
222 | + } | ||
223 | + | ||
224 | + $param['uid'] = $uid; | ||
225 | + $param['client_secret'] = Sign::getSign($param); | ||
226 | + | ||
227 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
228 | + } | ||
229 | + | ||
230 | + /** | ||
231 | + * 购物车结算--使用优惠券 | ||
232 | + * | ||
233 | + * @param int $uid 用户ID | ||
234 | + * @param string $couponCode 优惠券代码 | ||
235 | + * @return array 接口返回的数据 | ||
236 | + */ | ||
237 | + public static function searchCoupon($uid, $couponCode) | ||
238 | + { | ||
239 | + $param = Yohobuy::param(); | ||
240 | + $param['method'] = 'app.Shopping.useCoupon'; | ||
241 | + $param['coupon_code'] = $couponCode; | ||
242 | + $param['uid'] = $uid; | ||
243 | + $param['client_secret'] = Sign::getSign($param); | ||
244 | + | ||
245 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
246 | + } | ||
247 | + | ||
248 | + /** | ||
249 | + * 购物车结算--获取优惠券列表 | ||
250 | + * | ||
251 | + * @param int $uid 用户ID | ||
252 | + * @return array 接口返回的数据 | ||
253 | + */ | ||
254 | + public static function getCouponList($uid) | ||
255 | + { | ||
256 | + $param = Yohobuy::param(); | ||
257 | + $param['method'] = 'app.coupons.lists'; | ||
258 | + $param['type'] = 'notuse'; | ||
259 | + $param['page'] = 1; | ||
260 | + $param['limit'] = 1000; | ||
261 | + $param['uid'] = $uid; | ||
262 | + $param['client_secret'] = Sign::getSign($param); | ||
263 | + | ||
264 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
265 | + } | ||
266 | + | ||
267 | + /** | ||
268 | + * 购物车结算--提交结算信息 | ||
269 | + * | ||
270 | + * @param int $uid 用户ID | ||
271 | + * @param int $addressId 地址ID | ||
272 | + * @param int $cartType 购物车类型ID | ||
273 | + * @param int $deliveryTime 寄送时间ID | ||
274 | + * @param int $deliveryWay 寄送方式ID | ||
275 | + * @param string $invoiceTitle 发票说明 | ||
276 | + * @param int $invoiceId 发票类型ID | ||
277 | + * @param int $paymentId 支付方式ID | ||
278 | + * @param int $paymentType 支付类型ID | ||
279 | + * @param string $remark 留言 | ||
280 | + * @param mixed $yohoCoin 使用的YOHO币数量或为空 | ||
281 | + * @return array 接口返回的数据 | ||
282 | + */ | ||
283 | + public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin) | ||
284 | + { | ||
285 | + $param = Yohobuy::param(); | ||
286 | + $param['method'] = 'app.Shopping.submit'; | ||
287 | + $param['addressId'] = $addressId; | ||
288 | + $param['cart_type'] = $cartType; | ||
289 | + $param['delivery_time'] = $deliveryTime; | ||
290 | + $param['delivery_way'] = $deliveryWay; | ||
291 | + if (!empty($invoiceTitle)) { | ||
292 | + $param['invoices_title'] = $invoiceTitle; | ||
293 | + } | ||
294 | + if (!empty($invoiceId)) { | ||
295 | + $param['invoices_type_id'] = $invoiceId; | ||
296 | + } | ||
297 | + | ||
298 | + $param['payment_id'] = $paymentId; | ||
299 | + $param['payment_type'] = $paymentType; | ||
300 | + $param['remark'] = $remark; | ||
301 | + if (!empty($yohoCoin)) { | ||
302 | + $param['use_yoho_coin'] = $yohoCoin; | ||
303 | + } | ||
304 | + $param['uid'] = $uid; | ||
305 | + $param['client_secret'] = Sign::getSign($param); | ||
306 | + | ||
307 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
308 | + } | ||
272 | 309 | ||
273 | } | 310 | } |
static/img/yohood.png
0 → 100755

4.05 KB
@@ -158,6 +158,21 @@ function reMarginFooter(fixedElement) { | @@ -158,6 +158,21 @@ function reMarginFooter(fixedElement) { | ||
158 | $footer.removeClass('hide'); | 158 | $footer.removeClass('hide'); |
159 | }()); | 159 | }()); |
160 | 160 | ||
161 | +(function(w, d, s, j, f) { | ||
162 | + var a = d.createElement(s); | ||
163 | + var m = d.getElementsByTagName(s)[0]; | ||
164 | + | ||
165 | + w.YohoAcquisitionObject = f; | ||
166 | + | ||
167 | + w[f] = function() { | ||
168 | + w[f].p = arguments; | ||
169 | + }; | ||
170 | + | ||
171 | + a.async = 1; | ||
172 | + a.src = j; | ||
173 | + m.parentNode.insertBefore(a, m); | ||
174 | +})(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.13.6.3/yas-debug.js', '_yas'); | ||
175 | + | ||
161 | (function() { | 176 | (function() { |
162 | var uid = getUid(); | 177 | var uid = getUid(); |
163 | 178 | ||
@@ -166,7 +181,7 @@ function reMarginFooter(fixedElement) { | @@ -166,7 +181,7 @@ function reMarginFooter(fixedElement) { | ||
166 | window._ozuid = uid;//暴露ozuid | 181 | window._ozuid = uid;//暴露ozuid |
167 | 182 | ||
168 | if (window._yas) { | 183 | if (window._yas) { |
169 | - window._yas(1 * new Date(), '1.0.13.2', 'yohobuy_m', uid, ''); | 184 | + window._yas(1 * new Date(), '1.0.13.6.3', 'yohobuy_m', uid, '', ''); |
170 | } | 185 | } |
171 | }()); | 186 | }()); |
172 | 187 | ||
@@ -215,8 +230,8 @@ $('.nav-home').on('touchstart', function() { | @@ -215,8 +230,8 @@ $('.nav-home').on('touchstart', function() { | ||
215 | //为了使setTimteout的尽可能的接近每秒60帧的效果 | 230 | //为了使setTimteout的尽可能的接近每秒60帧的效果 |
216 | var timeToCall = Math.max(0, 16 - (currTime - lastTime)); | 231 | var timeToCall = Math.max(0, 16 - (currTime - lastTime)); |
217 | var id = window.setTimeout(function() { | 232 | var id = window.setTimeout(function() { |
218 | - callback(currTime + timeToCall); | ||
219 | - }, timeToCall); | 233 | + callback(currTime + timeToCall); |
234 | + }, timeToCall); | ||
220 | 235 | ||
221 | lastTime = currTime + timeToCall; | 236 | lastTime = currTime + timeToCall; |
222 | return id; | 237 | return id; |
@@ -231,6 +246,23 @@ $('.nav-home').on('touchstart', function() { | @@ -231,6 +246,23 @@ $('.nav-home').on('touchstart', function() { | ||
231 | window.cancelAnimationFrame = cancelAnimationFrame; | 246 | window.cancelAnimationFrame = cancelAnimationFrame; |
232 | }()); | 247 | }()); |
233 | 248 | ||
249 | +// 给jQuery 扩展 queryString函数 | ||
250 | +$.extend({ | ||
251 | + queryString: function() { | ||
252 | + var vars = [], | ||
253 | + hash, | ||
254 | + i; | ||
255 | + var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); | ||
256 | + | ||
257 | + for (i = 0; i < hashes.length; i++) { | ||
258 | + hash = hashes[i].split('='); | ||
259 | + vars.push(hash[0]); | ||
260 | + vars[hash[0]] = hash[1]; | ||
261 | + } | ||
262 | + return vars; | ||
263 | + } | ||
264 | +}); | ||
265 | + | ||
234 | //暴露公共接口 | 266 | //暴露公共接口 |
235 | window.cookie = cookie; | 267 | window.cookie = cookie; |
236 | 268 |
@@ -20,7 +20,8 @@ var $addressForm = $('.edit-address'), | @@ -20,7 +20,8 @@ var $addressForm = $('.edit-address'), | ||
20 | $area = $('.area'), | 20 | $area = $('.area'), |
21 | isSubmiting, | 21 | isSubmiting, |
22 | currentPage = 'edit', | 22 | currentPage = 'edit', |
23 | - newArea = []; | 23 | + newArea = [], |
24 | + queryString = $.queryString(); | ||
24 | 25 | ||
25 | $($editAddressPage, $addressListPage).css('min-height', function() { | 26 | $($editAddressPage, $addressListPage).css('min-height', function() { |
26 | return $(window).height() - $('#yoho-header').height(); | 27 | return $(window).height() - $('#yoho-header').height(); |
@@ -91,7 +92,11 @@ $addressForm.on('submit', function() { | @@ -91,7 +92,11 @@ $addressForm.on('submit', function() { | ||
91 | isSubmiting = false; | 92 | isSubmiting = false; |
92 | loading.hideLoadingMask(); | 93 | loading.hideLoadingMask(); |
93 | } else { | 94 | } else { |
94 | - window.location.href = '/home/address'; | 95 | + if (queryString.refer === 'shopping') { |
96 | + window.location.href = '/shoppingCart/selectAddress'; | ||
97 | + } else { | ||
98 | + window.location.href = '/home/address'; | ||
99 | + } | ||
95 | } | 100 | } |
96 | }).fail(function() { | 101 | }).fail(function() { |
97 | tip.show('网络出了点问题~'); | 102 | tip.show('网络出了点问题~'); |
@@ -69,4 +69,5 @@ $addAddress.on('touchend', function() { | @@ -69,4 +69,5 @@ $addAddress.on('touchend', function() { | ||
69 | $action.on('touchend', '.del', function() { | 69 | $action.on('touchend', '.del', function() { |
70 | deleteId = $(this).data('id'); | 70 | deleteId = $(this).data('id'); |
71 | $confim.fadeIn(); | 71 | $confim.fadeIn(); |
72 | + return false; | ||
72 | }); | 73 | }); |
@@ -30,6 +30,7 @@ if (likeHammer) { | @@ -30,6 +30,7 @@ if (likeHammer) { | ||
30 | opt = 'ok'; | 30 | opt = 'ok'; |
31 | favorite = 1; | 31 | favorite = 1; |
32 | } | 32 | } |
33 | + | ||
33 | $.ajax({ | 34 | $.ajax({ |
34 | type: 'POST', | 35 | type: 'POST', |
35 | url: '/product/opt/favoriteProduct', | 36 | url: '/product/opt/favoriteProduct', |
@@ -51,19 +52,19 @@ if (likeHammer) { | @@ -51,19 +52,19 @@ if (likeHammer) { | ||
51 | } else { | 52 | } else { |
52 | tip.show(data.message); | 53 | tip.show(data.message); |
53 | } | 54 | } |
54 | - | ||
55 | - // 统计代码:用于统计用户加入或取消商品收藏的动作 | ||
56 | - if (window._yas) { | ||
57 | - window._yas.sendCustomInfo({ | ||
58 | - pd: productId, | ||
59 | - fa: favorite | ||
60 | - }); | ||
61 | - } | ||
62 | }, | 55 | }, |
63 | error: function() { | 56 | error: function() { |
64 | tip.show('网络断开连接了~'); | 57 | tip.show('网络断开连接了~'); |
65 | } | 58 | } |
66 | }); | 59 | }); |
60 | + | ||
61 | + // 统计代码:用于统计用户加入或取消商品收藏的动作 | ||
62 | + if (window._yas) { | ||
63 | + window._yas.sendCustomInfo({ | ||
64 | + pd: productId, | ||
65 | + fa: favorite | ||
66 | + }, true); | ||
67 | + } | ||
67 | }); | 68 | }); |
68 | } | 69 | } |
69 | 70 | ||
@@ -75,7 +76,7 @@ if (addToCartHammer) { | @@ -75,7 +76,7 @@ if (addToCartHammer) { | ||
75 | window._yas.sendCustomInfo({ | 76 | window._yas.sendCustomInfo({ |
76 | pd: productId, | 77 | pd: productId, |
77 | by: 1 | 78 | by: 1 |
78 | - }); | 79 | + }, false); |
79 | } | 80 | } |
80 | }); | 81 | }); |
81 | } | 82 | } |
@@ -8,6 +8,7 @@ var $ = require('jquery'), | @@ -8,6 +8,7 @@ var $ = require('jquery'), | ||
8 | Hammer = require('yoho.hammer'), | 8 | Hammer = require('yoho.hammer'), |
9 | lazyLoad = require('yoho.lazyload'); | 9 | lazyLoad = require('yoho.lazyload'); |
10 | 10 | ||
11 | + | ||
11 | //品牌页参数 | 12 | //品牌页参数 |
12 | var $brandHeader = $('#brand-header'), | 13 | var $brandHeader = $('#brand-header'), |
13 | $introBox = $('#intro-box'); | 14 | $introBox = $('#intro-box'); |
@@ -231,6 +232,25 @@ function search(opt) { | @@ -231,6 +232,25 @@ function search(opt) { | ||
231 | loading.hideLoadingMask(); | 232 | loading.hideLoadingMask(); |
232 | 233 | ||
233 | window.rePosFooter(); | 234 | window.rePosFooter(); |
235 | + | ||
236 | + | ||
237 | + // 用于统计点击了商品列表的第几个商品,序号从1开始计算。 | ||
238 | + if (window._yas) { | ||
239 | + switch (navType) { | ||
240 | + case 'newest': | ||
241 | + window._yas(1 * new Date(), '1.0.13.6.3', 'yohobuy_m', window._ozuid, | ||
242 | + '', '.new-goods .good-info .good-detail-img .good-thumb'); | ||
243 | + break; | ||
244 | + case 'price': | ||
245 | + window._yas(1 * new Date(), '1.0.13.6.3', 'yohobuy_m', window._ozuid, | ||
246 | + '', '.new-goods .good-info .good-detail-img .good-thumb'); | ||
247 | + break; | ||
248 | + case 'discount': | ||
249 | + window._yas(1 * new Date(), '1.0.13.6.3', 'yohobuy_m', window._ozuid, | ||
250 | + '', '.new-goods .good-info .good-detail-img .good-thumb'); | ||
251 | + break; | ||
252 | + } | ||
253 | + } | ||
234 | } | 254 | } |
235 | }); | 255 | }); |
236 | 256 | ||
@@ -455,8 +475,3 @@ $listNav.on('touchstart', 'li', function() { | @@ -455,8 +475,3 @@ $listNav.on('touchstart', 'li', function() { | ||
455 | $listNav.find('li').removeClass('bytouch'); | 475 | $listNav.find('li').removeClass('bytouch'); |
456 | }); | 476 | }); |
457 | 477 | ||
458 | -// 用于统计点击了商品列表的第几个商品,序号从1开始计算。 | ||
459 | -if (window._yas) { | ||
460 | - window._yas(1 * new Date(), '1.0.13.2', 'yohobuy_m', window._ozuid, | ||
461 | - '', '#goods-container >div >div .good-thumb >img'); | ||
462 | -} |
static/js/shopping-cart/order-info.js
0 → 100644
1 | +/** | ||
2 | + * 订单信息读取 | ||
3 | + * @author: bikai<kai.bi@yoho.cn> | ||
4 | + * @date: 2015/12/14 | ||
5 | + */ | ||
6 | +var info = window.cookie('order-info'), | ||
7 | + orderInfo; | ||
8 | + | ||
9 | +// info 必须是 JSON 字符串 | ||
10 | +try { | ||
11 | + info = JSON.parse(orderInfo); | ||
12 | +} catch (e) { | ||
13 | + info = {}; | ||
14 | +} | ||
15 | + | ||
16 | +exports.orderInfo = function(key, value) { | ||
17 | + if (value === undefined) { | ||
18 | + return info[key]; | ||
19 | + } | ||
20 | + info[key] = value; | ||
21 | + window.setCookie('order-info', JSON.stringify(info)); | ||
22 | +}; |
static/js/shopping-cart/select-address.js
0 → 100644
1 | +/** | ||
2 | + * 购物车 地址选择 | ||
3 | + * @author: bikai<kai.bi@yoho.cn> | ||
4 | + * @date: 2015/12/14 | ||
5 | + */ | ||
6 | + | ||
7 | +var $ = require('jquery'), | ||
8 | + orderInfo = require('./order-info').orderInfo; | ||
9 | + | ||
10 | +$('.address-item').on('touchend', function() { | ||
11 | + orderInfo('addressId', $(this).data('address-id')); | ||
12 | +}).on('touchend', '.edit', function() { | ||
13 | + window.location.href = $(this).data('href'); | ||
14 | + return false; | ||
15 | +}); |
1 | +/** | ||
2 | + * 优惠券选择 | ||
3 | + * @author: bikai<kai.bi@yoho.cn> | ||
4 | + * @date: 2015/12/10 | ||
5 | + */ | ||
6 | + | ||
1 | var $ = require('jquery'), | 7 | var $ = require('jquery'), |
2 | Handlebars = require('yoho.handlebars'), | 8 | Handlebars = require('yoho.handlebars'), |
3 | ellipsis = require('mlellipsis'), | 9 | ellipsis = require('mlellipsis'), |
4 | loading = require('../plugin/loading'), | 10 | loading = require('../plugin/loading'), |
5 | - tip = require('../plugin/tip'); | 11 | + tip = require('../plugin/tip'), |
12 | + orderInfo = require('./order-info').orderInfo; | ||
6 | 13 | ||
7 | var page = 1, | 14 | var page = 1, |
8 | canGetCoupon = true, | 15 | canGetCoupon = true, |
@@ -16,43 +23,48 @@ ellipsis.init(); | @@ -16,43 +23,48 @@ ellipsis.init(); | ||
16 | $('#search-coupon').on('submit', function() { | 23 | $('#search-coupon').on('submit', function() { |
17 | $.ajax({ | 24 | $.ajax({ |
18 | method: 'POST', | 25 | method: 'POST', |
19 | - url: '', | 26 | + url: '/shoppingCart/coupon', |
20 | data: $(this).serialize() | 27 | data: $(this).serialize() |
21 | }).then(function(res) { | 28 | }).then(function(res) { |
22 | - if (res.avaliable) { | ||
23 | - $('#coupon-list').html(conponTmpl({ | ||
24 | - coupons: res.coupons | ||
25 | - })); | ||
26 | - $('#coupon-list-not').html(''); | 29 | + if (res.code === 200) { |
30 | + tip.show('优惠券可用'); | ||
31 | + orderInfo('couponCode', res.data.coupon_code); | ||
32 | + window.location.href = '/shoppingCart/orderEnsure?coupon_code=' + res.data.coupon_code; | ||
27 | } else { | 33 | } else { |
28 | - tip.show(res.msg); | 34 | + tip.show(res.message); |
29 | } | 35 | } |
36 | + }).fail(function() { | ||
37 | + tip.show('网络错误'); | ||
30 | }); | 38 | }); |
31 | return false; | 39 | return false; |
32 | }); | 40 | }); |
33 | 41 | ||
42 | +$('#coupon-list').on('touchend', 'employ-main', function() { | ||
43 | + orderInfo('couponCode', $(this).data('coupon-code')); | ||
44 | +}); | ||
45 | + | ||
34 | function getCouponHandle(coupons) { | 46 | function getCouponHandle(coupons) { |
35 | var notAvailableCoupons = []; | 47 | var notAvailableCoupons = []; |
36 | 48 | ||
37 | // 后端需要返回一个 coupons 列表,如下 | 49 | // 后端需要返回一个 coupons 列表,如下 |
38 | // notAvailable 表示不可用的优惠券 | 50 | // notAvailable 表示不可用的优惠券 |
39 | - coupons = [{ | ||
40 | - money: '99', | ||
41 | - coupon_name: '满XX-减去吴悠右腿有益于有2222', | ||
42 | - couponValidity: '20150129-20150430', | ||
43 | - coupon_id: '22222' | ||
44 | - }, { | ||
45 | - money: '99', | ||
46 | - coupon_name: '满XX-减去吴悠右腿有益于有2222', | ||
47 | - couponValidity: '20150129-20150430', | ||
48 | - coupon_id: '2222233' | ||
49 | - }, { | ||
50 | - money: '99', | ||
51 | - coupon_name: 'NONO满XX-减去吴悠右腿有益于有2222', | ||
52 | - couponValidity: '20150129-20150430', | ||
53 | - coupon_id: '2222233', | ||
54 | - notAvailable: 1 | ||
55 | - }]; | 51 | + // coupons = [{ |
52 | + // money: '99', | ||
53 | + // coupon_name: '满XX-减去吴悠右腿有益于有2222', | ||
54 | + // couponValidity: '20150129-20150430', | ||
55 | + // coupon_id: '22222' | ||
56 | + // }, { | ||
57 | + // money: '99', | ||
58 | + // coupon_name: '满XX-减去吴悠右腿有益于有2222', | ||
59 | + // couponValidity: '20150129-20150430', | ||
60 | + // coupon_id: '2222233' | ||
61 | + // }, { | ||
62 | + // money: '99', | ||
63 | + // coupon_name: 'NONO满XX-减去吴悠右腿有益于有2222', | ||
64 | + // couponValidity: '20150129-20150430', | ||
65 | + // coupon_id: '2222233', | ||
66 | + // notAvailable: 1 | ||
67 | + // }]; | ||
56 | 68 | ||
57 | // coupons 是个列表,如果不是列表,可能是服务器错误,这次翻页加载不算 | 69 | // coupons 是个列表,如果不是列表,可能是服务器错误,这次翻页加载不算 |
58 | if (!$.isArray(coupons)) { | 70 | if (!$.isArray(coupons)) { |
@@ -106,9 +118,8 @@ function getCouponDate() { | @@ -106,9 +118,8 @@ function getCouponDate() { | ||
106 | $.ajax({ | 118 | $.ajax({ |
107 | type: 'POST', | 119 | type: 'POST', |
108 | url: '/home/couponData', | 120 | url: '/home/couponData', |
109 | - dataType: 'html', | 121 | + dataType: 'json', |
110 | data: { | 122 | data: { |
111 | - statuss: status, | ||
112 | page: page | 123 | page: page |
113 | } | 124 | } |
114 | }).then(getCouponHandle).fail(function() { | 125 | }).then(getCouponHandle).fail(function() { |
@@ -117,7 +117,7 @@ | @@ -117,7 +117,7 @@ | ||
117 | overflow: hidden; | 117 | overflow: hidden; |
118 | padding: 0 10rem / $pxConvertRem;; | 118 | padding: 0 10rem / $pxConvertRem;; |
119 | 119 | ||
120 | - | 120 | + |
121 | } | 121 | } |
122 | 122 | ||
123 | .index-channel { | 123 | .index-channel { |
@@ -143,7 +143,7 @@ | @@ -143,7 +143,7 @@ | ||
143 | font-size: 16px; | 143 | font-size: 16px; |
144 | line-height: 52px; | 144 | line-height: 52px; |
145 | color: #fff; | 145 | color: #fff; |
146 | - background: #000; | 146 | + background-color: #000; |
147 | border: 4px solid #fff; | 147 | border: 4px solid #fff; |
148 | font-weight: bold; | 148 | font-weight: bold; |
149 | &:last-child { | 149 | &:last-child { |
@@ -162,11 +162,11 @@ | @@ -162,11 +162,11 @@ | ||
162 | .homestyle { | 162 | .homestyle { |
163 | margin-bottom: 50rem / $pxConvertRem; | 163 | margin-bottom: 50rem / $pxConvertRem; |
164 | width: 287.3rem / $pxConvertRem; | 164 | width: 287.3rem / $pxConvertRem; |
165 | - } | 165 | + } |
166 | } | 166 | } |
167 | } | 167 | } |
168 | } | 168 | } |
169 | - | 169 | + |
170 | } | 170 | } |
171 | 171 | ||
172 | @import "search","footer", "error"; | 172 | @import "search","footer", "error"; |
@@ -163,6 +163,20 @@ | @@ -163,6 +163,20 @@ | ||
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | + #msg { | ||
167 | + padding-top: pxToRem(20px); | ||
168 | + input { | ||
169 | + padding: pxToRem(10px); | ||
170 | + width: pxToRem(580px); | ||
171 | + height: pxToRem(50px); | ||
172 | + outline: 0; | ||
173 | + border: 0; | ||
174 | + border: 1px solid #f7f7f7; | ||
175 | + border-radius: pxToRem(4px); | ||
176 | + } | ||
177 | + | ||
178 | + } | ||
179 | + | ||
166 | .total { | 180 | .total { |
167 | font-size: 22rem / $pxConvertRem; | 181 | font-size: 22rem / $pxConvertRem; |
168 | margin-top: 20rem / $pxConvertRem; | 182 | margin-top: 20rem / $pxConvertRem; |
@@ -19,12 +19,14 @@ | @@ -19,12 +19,14 @@ | ||
19 | <div class="index-channel"> | 19 | <div class="index-channel"> |
20 | <img class="img" src="{{background}}"> | 20 | <img class="img" src="{{background}}"> |
21 | <div class="index-channel-list"> | 21 | <div class="index-channel-list"> |
22 | - <a href="/boys" class="list-item">男生 <span class="lighter">BOYS</span> <span class="iconfont right-icon"></span></a> | ||
23 | - <a href="/girls" class="list-item">女生 <span class="lighter">GIRLS</span> <span class="iconfont right-icon"></span></a> | ||
24 | - <a href="/kids" class="list-item">潮童 <span class="lighter">KIDS</span> <span class="iconfont right-icon"></span></a> | ||
25 | - <a href="/lifestyle" class="list-item">创意生活 <span class="lighter">LIFESTYLE</span> <span class="iconfont right-icon"></span></a> | ||
26 | - </div> | 22 | + {{#channelList}} |
23 | + <a href="{{href}}" class="list-item">{{title}} <span class="lighter">{{entitle}}</span> <span class="iconfont right-icon"></span></a> | ||
24 | + {{/channelList}} | ||
25 | + {{#showYohood}} | ||
26 | + <a href="/yohood" id="yohood" class="list-item"> <span class="iconfont right-icon"></span></a> | ||
27 | + {{/showYohood}} | ||
28 | + </div> | ||
27 | </div> | 29 | </div> |
28 | </div> | 30 | </div> |
29 | </div> | 31 | </div> |
30 | -{{> layout/footer}} | ||
32 | +{{> layout/footer}} |
@@ -97,6 +97,12 @@ | @@ -97,6 +97,12 @@ | ||
97 | {{/if}} | 97 | {{/if}} |
98 | </ul> | 98 | </ul> |
99 | 99 | ||
100 | + <form id="msg" action="" method="post"> | ||
101 | + <input type="text" name="msg" value="" placeholder="留言"> | ||
102 | + </form> | ||
103 | + </section> | ||
104 | + | ||
105 | + <section class="block"> | ||
100 | <ul class="total"> | 106 | <ul class="total"> |
101 | <li> | 107 | <li> |
102 | <span>总价</span> | 108 | <span>总价</span> |
@@ -2,12 +2,36 @@ | @@ -2,12 +2,36 @@ | ||
2 | <div class="my-address-page select-address-page yoho-page"> | 2 | <div class="my-address-page select-address-page yoho-page"> |
3 | <div class="page-wrap"> | 3 | <div class="page-wrap"> |
4 | {{# address}} | 4 | {{# address}} |
5 | - <a class="address-item" href="/shoppingCart/orderEnsure?address_id={{address_id}}"> | 5 | + <a class="address-item" data-address-id="{{address_id}}" href="/shoppingCart/orderEnsure?address_id={{address_id}}"> |
6 | <span class="name">{{consignee}}</span> | 6 | <span class="name">{{consignee}}</span> |
7 | <span class="tel">{{mobile}}</span> | 7 | <span class="tel">{{mobile}}</span> |
8 | <p class="address-info">{{area}} {{address}}</p> | 8 | <p class="address-info">{{area}} {{address}}</p> |
9 | + <div class="action iconfont"> | ||
10 | + <span class="edit" data-href="/home/addressAct?id={{address_id}}&refer=shopping"></span> | ||
11 | + <span class="del" data-id="{{address_id}}"></span> | ||
12 | + </div> | ||
9 | </a> | 13 | </a> |
10 | {{/ address}} | 14 | {{/ address}} |
15 | + | ||
16 | + <a class="add-address" data-href="/home/addressAct?refer=shopping"> | ||
17 | + 添加新地址 | ||
18 | + </a> | ||
19 | + | ||
20 | + <div class="confim-mask hide"> | ||
21 | + <div class="confim-box"> | ||
22 | + <div class="content"> | ||
23 | + 您确定要删除地址? | ||
24 | + </div> | ||
25 | + <div class="action"> | ||
26 | + <span class="cancel"> | ||
27 | + 取消 | ||
28 | + </span> | ||
29 | + <span class="confim"> | ||
30 | + 确认 | ||
31 | + </span> | ||
32 | + </div> | ||
33 | + </div> | ||
34 | + </div> | ||
11 | </div> | 35 | </div> |
12 | </div> | 36 | </div> |
13 | {{> layout/footer}} | 37 | {{> layout/footer}} |
1 | {{> layout/header}} | 1 | {{> layout/header}} |
2 | <div class="yoho-page select-coupon-page my-coupon-page"> | 2 | <div class="yoho-page select-coupon-page my-coupon-page"> |
3 | <form id="search-coupon" method="POST" action=""> | 3 | <form id="search-coupon" method="POST" action=""> |
4 | - <input type="text" name="coupon-code" value="" placeholder="输入优惠券码"> | 4 | + <input type="text" name="couponCode" value="" placeholder="输入优惠券码"> |
5 | <button type="submit" class="submit">确定</button> | 5 | <button type="submit" class="submit">确定</button> |
6 | </form> | 6 | </form> |
7 | <div id="coupon-list" class="coupon-list"></div> | 7 | <div id="coupon-list" class="coupon-list"></div> |
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | <script id="tmpl-coupon" type="text/tmpl"> | 11 | <script id="tmpl-coupon" type="text/tmpl"> |
12 | \{{#coupons}} | 12 | \{{#coupons}} |
13 | \{{^ notAvailable}} | 13 | \{{^ notAvailable}} |
14 | - <a class="employ-main" href="/shoppingCart/orderEnsure?coupon_id={{ coupon_id}}"> | 14 | + <a class="employ-main" data-coupon-code="{{ coupon_code}}" href="/shoppingCart/orderEnsure?coupon_code={{ coupon_code}}"> |
15 | <span>\{{ money}}</span> | 15 | <span>\{{ money}}</span> |
16 | <p class="coupon-name">\{{ coupon_name}}</p> | 16 | <p class="coupon-name">\{{ coupon_name}}</p> |
17 | <p>有效期:\{{ couponValidity}}</p> | 17 | <p>有效期:\{{ couponValidity}}</p> |
@@ -13,6 +13,7 @@ | @@ -13,6 +13,7 @@ | ||
13 | (function() { | 13 | (function() { |
14 | var hm = document.createElement("script"); | 14 | var hm = document.createElement("script"); |
15 | hm.src = "//hm.baidu.com/hm.js?c6ee7218b8321cb65fb2e98f284d8311"; | 15 | hm.src = "//hm.baidu.com/hm.js?c6ee7218b8321cb65fb2e98f284d8311"; |
16 | + hm.async = 1; | ||
16 | var s = document.getElementsByTagName("script")[0]; | 17 | var s = document.getElementsByTagName("script")[0]; |
17 | s.parentNode.insertBefore(hm, s); | 18 | s.parentNode.insertBefore(hm, s); |
18 | })(); | 19 | })(); |
@@ -22,6 +23,7 @@ | @@ -22,6 +23,7 @@ | ||
22 | (function() { | 23 | (function() { |
23 | var hm = document.createElement("script"); | 24 | var hm = document.createElement("script"); |
24 | hm.src = "//hm.baidu.com/hm.js?65dd99e0435a55177ffda862198ce841"; | 25 | hm.src = "//hm.baidu.com/hm.js?65dd99e0435a55177ffda862198ce841"; |
26 | + hm.async = 1; | ||
25 | var s = document.getElementsByTagName("script")[0]; | 27 | var s = document.getElementsByTagName("script")[0]; |
26 | s.parentNode.insertBefore(hm, s); | 28 | s.parentNode.insertBefore(hm, s); |
27 | })(); | 29 | })(); |
@@ -19,18 +19,7 @@ | @@ -19,18 +19,7 @@ | ||
19 | <script src="http://localhost:8000/static/js/sea.js?nowrap"></script> | 19 | <script src="http://localhost:8000/static/js/sea.js?nowrap"></script> |
20 | <script>seajs.config({base: 'http://localhost:8000/'});</script> | 20 | <script>seajs.config({base: 'http://localhost:8000/'});</script> |
21 | {{/if}} | 21 | {{/if}} |
22 | -<script type="text/javascript"> | ||
23 | - (function(w,d,s,j,f){ | ||
24 | - w['YohoAcquisitionObject']=f; | ||
25 | - w[f]=function(){w[f].p=arguments;}; | ||
26 | - var a=d.createElement(s); | ||
27 | - var m=d.getElementsByTagName(s)[0]; | ||
28 | - a.async=1; | ||
29 | - a.src=j; | ||
30 | - m.parentNode.insertBefore(a,m); | ||
31 | - })(window,document,'script','http://cdn.yoho.cn/yas-jssdk/{{yas_version}}/yas.js','_yas'); | ||
32 | -</script> | ||
33 | -{{> layout/use}} | 22 | + {{> layout/use}} |
34 | {{> layout/analysis}} | 23 | {{> layout/analysis}} |
35 | </body> | 24 | </body> |
36 | </html> | 25 | </html> |
@@ -218,6 +218,12 @@ | @@ -218,6 +218,12 @@ | ||
218 | seajs.use('js/shopping-cart/order-ensure'); | 218 | seajs.use('js/shopping-cart/order-ensure'); |
219 | </script> | 219 | </script> |
220 | {{/if}} | 220 | {{/if}} |
221 | +{{#if selectAddressPage}} | ||
222 | +<script> | ||
223 | + seajs.use('js/me/address'); | ||
224 | + seajs.use('js/shopping-cart/select-address'); | ||
225 | +</script> | ||
226 | +{{/if}} | ||
221 | {{#if selectCouponPage}} | 227 | {{#if selectCouponPage}} |
222 | <script> | 228 | <script> |
223 | seajs.use('js/shopping-cart/select-coupon'); | 229 | seajs.use('js/shopping-cart/select-coupon'); |
@@ -31,351 +31,198 @@ class ShoppingCartController extends AbstractAction | @@ -31,351 +31,198 @@ class ShoppingCartController extends AbstractAction | ||
31 | $this->_view->display('index', $data); | 31 | $this->_view->display('index', $data); |
32 | } | 32 | } |
33 | 33 | ||
34 | - /** | ||
35 | - * 加入购物车 | ||
36 | - * | ||
37 | - * @param string productSku 商品的SKU | ||
38 | - * @param int buyNumber 购买数量 | ||
39 | - * @param int promotionId 促销ID, 加价购有关 | ||
40 | - * @param int goodsType 商品类型,0表示普通商品,1表示加价购商品 | ||
41 | - * @param int isEdit 是否是编辑商品SKU,0表示不是编辑 | ||
42 | - * @return json | ||
43 | - */ | ||
44 | - public function addAction() | ||
45 | - { | ||
46 | - $result = array(); | ||
47 | - | ||
48 | - if ($this->isAjax()) { | ||
49 | - $shoppingKey = Helpers::getShoppingKeyByCookie(); | ||
50 | - $productSku = $this->post('productSku'); | ||
51 | - $buyNumber = $this->post('buyNumber', 1); | ||
52 | - $goodsType = $this->post('goodsType', 0); | ||
53 | - $promotionId = $this->post('promotionId', 0); | ||
54 | - $isEdit = $this->post('isEdit', 0); | ||
55 | - $uid = $this->getUid(true); | ||
56 | - | ||
57 | - // 执行加入购物车操作 | ||
58 | - $result = CartModel::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey); | ||
59 | - | ||
60 | - // 设置加入购物车凭证到客户端浏览器 | ||
61 | - if (isset($result['data']['shopping_key'])) { | ||
62 | - $this->setCookie('_spk', $shoppingKey); | ||
63 | - } | ||
64 | - } | ||
65 | - | ||
66 | - $this->echoJson($result); | ||
67 | - } | ||
68 | - | ||
69 | - /** | ||
70 | - * 移出购物车 | ||
71 | - */ | ||
72 | - public function delAction() | ||
73 | - { | ||
74 | - $result = array(); | ||
75 | - | ||
76 | - if ($this->isAjax()) { | ||
77 | - $productId = $this->post('id', 0); | ||
78 | - $uid = $this->getUid(true); | ||
79 | - $shoppingKey = Helpers::getShoppingKeyByCookie(); | ||
80 | - $result = CartModel::removeFromCart($uid, $productId, $shoppingKey); | ||
81 | - } | ||
82 | - | ||
83 | - if (empty($result)) { | ||
84 | - echo ' '; | ||
85 | - } else { | ||
86 | - $this->echoJson($result); | ||
87 | - } | ||
88 | - } | ||
89 | - | ||
90 | - /** | ||
91 | - * 移入收藏夹 | ||
92 | - */ | ||
93 | - public function colAction() | ||
94 | - { | ||
95 | - $result = array(); | ||
96 | - | ||
97 | - if ($this->isAjax()) { | ||
98 | - $productId = $this->post('id', 0); | ||
99 | - $uid = $this->getUid(true); | ||
100 | - $result = CartModel::addToFav($uid, $productId); | ||
101 | - } | ||
102 | - | ||
103 | - if (empty($result)) { | ||
104 | - echo ' '; | ||
105 | - } else { | ||
106 | - $this->echoJson($result); | ||
107 | - } | ||
108 | - } | ||
109 | - | ||
110 | - /* | ||
111 | - * 获取购物车商品数据 | ||
112 | - */ | ||
113 | - | ||
114 | - public function goodinfoAction() | ||
115 | - { | ||
116 | - $result = array(); | ||
117 | - | ||
118 | - if ($this->isAjax()) { | ||
119 | - $num = $this->get('buy_num', 1); | ||
120 | - $skn = $this->get('id', 1); | ||
121 | - $uid = $this->getUid(true); | ||
122 | - $result = CartModel::cartProductData($uid, $skn, $num); // 测试skn的ID为51172055 | ||
123 | - $result['num'] = $num; | ||
124 | - } | ||
125 | - | ||
126 | - if (empty($result)) { | ||
127 | - echo ' '; | ||
128 | - } else { | ||
129 | - $this->echoJson($result); | ||
130 | - } | ||
131 | - } | ||
132 | - | ||
133 | - /* | ||
134 | - * 获取购物车加价购商品数据 | ||
135 | - */ | ||
136 | - | ||
137 | - public function giftinfoAction() | ||
138 | - { | ||
139 | - $result = array(); | ||
140 | - | ||
141 | - if ($this->isAjax()) { | ||
142 | - $skn = $this->get('skn', null); | ||
143 | - $promotionId = $this->get('promotionId', null); | ||
144 | - $result = CartModel::giftProductData($skn, $promotionId); | ||
145 | - } | ||
146 | - | ||
147 | - if (empty($result)) { | ||
148 | - echo ' '; | ||
149 | - } else { | ||
150 | - $this->echoJson($result); | ||
151 | - } | ||
152 | - } | ||
153 | - | ||
154 | - /** | ||
155 | - * 修改购物车商品数据 | ||
156 | - */ | ||
157 | - public function modifyAction() | ||
158 | - { | ||
159 | - $result = array(); | ||
160 | - | ||
161 | - if ($this->isAjax()) { | ||
162 | - $shoppingKey = Helpers::getShoppingKeyByCookie(); | ||
163 | - $uid = $this->getUid(true); | ||
164 | - | ||
165 | - $params = array(); | ||
166 | - $params['old_product_sku'] = $this->post('old_product_sku', 0); | ||
167 | - $params['new_product_sku'] = $this->post('new_product_sku', 0); | ||
168 | - $params['buy_number'] = $this->post('buy_number', 0); | ||
169 | - $params['selected'] = $this->post('selected', null); | ||
170 | - $result = CartModel::modifyCartProduct($uid, $params, $shoppingKey); | ||
171 | - } | ||
172 | - | ||
173 | - if (empty($result)) { | ||
174 | - echo ' '; | ||
175 | - } else { | ||
176 | - $this->echoJson($result); | ||
177 | - } | ||
178 | - } | ||
179 | - | ||
180 | - /** | ||
181 | - * 购物车结算请求 | ||
182 | - */ | ||
183 | - public function payAction() | ||
184 | - { | ||
185 | - $this->setTitle('购物车'); | ||
186 | - $this->setNavHeader('购物车'); | ||
187 | - | ||
188 | - $cartType = $this->post('cartType', 'ordinary'); | ||
189 | - $uid = $this->getUid(true); | ||
190 | - $data = array( | ||
191 | - 'orderEnsurePage' => true, | ||
192 | - 'orderEnsure' => CartModel::cartPay($uid, $cartType) | ||
193 | - ); | ||
194 | - | ||
195 | - $this->_view->display('order-ensure', $data); | ||
196 | - } | ||
197 | - | ||
198 | - /** | ||
199 | - * 购物车选择支付方式和配送方式接口 | ||
200 | - */ | ||
201 | - public function payAndDeliveryAction() | ||
202 | - { | ||
203 | - $result = array(); | ||
204 | - | ||
205 | - if ($this->isAjax()) { | ||
206 | - $cartType = $this->post('cartType', 'ordinary'); | ||
207 | - $deliveryWay = $this->post('deliveryWay', 1); | ||
208 | - $paymentType = $this->post('paymentType', 1); | ||
209 | - $uid = $this->getUid(true); | ||
210 | - $result = CartModel::paymentTypeAndDelivery($uid, $cartType, $deliveryWay, $paymentType); | ||
211 | - } | ||
212 | - | ||
213 | - if (empty($result)) { | ||
214 | - echo ' '; | ||
215 | - } else { | ||
216 | - $this->echoJson($result); | ||
217 | - } | ||
218 | - } | ||
219 | - | ||
220 | - /** | ||
221 | - * 购物车输入优惠券码使用优惠券 | ||
222 | - */ | ||
223 | - public function couponAction() | ||
224 | - { | ||
225 | - $result = array(); | ||
226 | - | ||
227 | - if ($this->isAjax()) { | ||
228 | - $couponCode = $this->post('couponCode', ''); | ||
229 | - $uid = $this->getUid(true); | ||
230 | - $result = CartModel::getCoupon($uid, $couponCode); | ||
231 | - } | ||
232 | - | ||
233 | - if (empty($result)) { | ||
234 | - echo ' '; | ||
235 | - } else { | ||
236 | - $this->echoJson($result); | ||
237 | - } | ||
238 | - } | ||
239 | - | ||
240 | - /** | ||
241 | - * 购物车使用YOHO币 | ||
242 | - */ | ||
243 | - public function yohoCoinAction() | ||
244 | - { | ||
245 | - $result = array(); | ||
246 | - | ||
247 | - if ($this->isAjax()) { | ||
248 | - $cartType = $this->post('cartType', 'ordinary'); | ||
249 | - $deliveryWay = $this->post('deliveryWay', 1); | ||
250 | - $paymentType = $this->post('paymentType', 1); | ||
251 | - $yohoCoin = $this->post('yohoCoin', 1); | ||
252 | - $result = CartModel::paymentTypeAndDelivery($this->_uid, $cartType, $deliveryWay, $paymentType, $yohoCoin); | ||
253 | - } | ||
254 | - | ||
255 | - if (empty($result)) { | ||
256 | - echo ' '; | ||
257 | - } else { | ||
258 | - $this->echoJson($result); | ||
259 | - } | ||
260 | - } | ||
261 | - | ||
262 | - public function giftAdvanceAction() | ||
263 | - { | ||
264 | - $data = array( | ||
265 | - 'advance' => array( | ||
266 | - array( | ||
267 | - 'title' => '【izzue】加¥19购袜子', | ||
268 | - 'goods' => array( | ||
269 | - 'id' => 1, | ||
270 | - 'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/09/17/03/014cacfa5c458b9732c68adf1af15d7a45.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/90', | ||
271 | - 'name' => 'Life.After.Life纯棉短袜', | ||
272 | - 'salePrice' => 19, | ||
273 | - 'price' => 99, | ||
274 | - 'count' => 1 | ||
275 | - ) | ||
276 | - ), | ||
277 | - array( | ||
278 | - 'title' => '【银鳞堂】加¥9购手绳', | ||
279 | - 'goods' => array( | ||
280 | - 'id' => 1, | ||
281 | - 'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/10/03/10/01bc1878f9154e77ac4f7a6003c954f1b8.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90', | ||
282 | - 'name' => '银鳞堂民族风牛皮手绳', | ||
283 | - 'salePrice' => 9, | ||
284 | - 'price' => 19, | ||
285 | - 'count' => 1 | ||
286 | - ) | ||
287 | - ) | ||
288 | - ) | ||
289 | - ); | ||
290 | - | ||
291 | - $data = array( | ||
292 | - 'gift' => array( | ||
293 | - 'id' => 1, | ||
294 | - 'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/09/17/03/014cacfa5c458b9732c68adf1af15d7a45.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/90', | ||
295 | - 'name' => 'Life.After.Life纯棉短袜', | ||
296 | - 'color' => '黄色', | ||
297 | - 'size' => 'L', | ||
298 | - 'price' => 0, | ||
299 | - 'count' => 1 | ||
300 | - ) | ||
301 | - ); | ||
302 | - | ||
303 | - $this->_view->display('gift-advance', array('giftAdvancePage' => true, 'pageHeader' => array( | ||
304 | - 'navBack' => true, 'navTitle' => '加价购'), 'shoppingCart' => $data)); | ||
305 | - } | ||
306 | - | ||
307 | - /* | ||
308 | - * 确认订单 | ||
309 | - */ | ||
310 | - | ||
311 | - public function orderEnsureAction() | ||
312 | - { | ||
313 | - $data = array( | ||
314 | - 'orderEnsurePage' => true, | ||
315 | - 'orderEnsure' => array( | ||
316 | - 'name' => '申建军', | ||
317 | - 'phoneNum' => '12345678', | ||
318 | - 'address' => '江苏省南京市建邺区', | ||
319 | - 'dispatchMode' => array( | ||
320 | - array( | ||
321 | - 'id' => 1, | ||
322 | - 'name' => '普通快递¥10' | ||
323 | - ), | ||
324 | - array( | ||
325 | - 'id' => 2, | ||
326 | - 'name' => '顺丰速运¥15(仅支持顺丰克配送的地区)' | ||
327 | - ) | ||
328 | - ), | ||
329 | - 'dispatchTime' => array( | ||
330 | - array( | ||
331 | - 'id' => 1, | ||
332 | - 'name' => '工作日、双休日、节假日均可送货' | ||
333 | - ), | ||
334 | - array( | ||
335 | - 'id' => 2, | ||
336 | - 'name' => '只工作日送货' | ||
337 | - ), | ||
338 | - array( | ||
339 | - 'id' => 3, | ||
340 | - 'name' => '只双休日、节假日送货' | ||
341 | - ) | ||
342 | - ), | ||
343 | - 'goods' => array( | ||
344 | - array( | ||
345 | - 'id' => 1, | ||
346 | - 'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90', | ||
347 | - 'name' => 'Adidas Originals ZX FLUXM22508', | ||
348 | - 'color' => '黄', | ||
349 | - 'size' => '43', | ||
350 | - 'price' => '699.00', | ||
351 | - 'count' => '2' | ||
352 | - ), | ||
353 | - array( | ||
354 | - 'id' => 1, | ||
355 | - 'thumb' => 'http://img10.static.yhbimg.com/goodsimg/2015/11/04/05/0188f1aca49ac478a565ec029b5d2d4a6c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90', | ||
356 | - 'name' => 'B.Duck浴室玩伴mini浮水鸭', | ||
357 | - 'gift' => true, | ||
358 | - 'color' => '黄', | ||
359 | - 'size' => '43', | ||
360 | - 'price' => '0.00', | ||
361 | - 'count' => '1' | ||
362 | - ) | ||
363 | - ), | ||
364 | - 'coupon' => array( | ||
365 | - 'count' => 1, | ||
366 | - 'notUsed' => true | ||
367 | - ), | ||
368 | - 'yohoCoin' => '0', | ||
369 | - 'invoice' => true, | ||
370 | - 'sumPrice' => 900, | ||
371 | - 'salePrice' => 90, | ||
372 | - 'freight' => 0, | ||
373 | - 'price' => 810 | ||
374 | - ) | ||
375 | - ); | ||
376 | - | ||
377 | - $this->_view->display('order-ensure', $data); | ||
378 | - } | 34 | + /** |
35 | + * 移出购物车 | ||
36 | + */ | ||
37 | + public function delAction() | ||
38 | + { | ||
39 | + $result = array(); | ||
40 | + | ||
41 | + if ($this->isAjax()) { | ||
42 | + $productId = $this->post('id', 0); | ||
43 | + $uid = $this->getUid(true); | ||
44 | + $shoppingKey = $this->getSession('shoppingKey'); | ||
45 | + $result = CartModel::removeFromCart($uid, $productId, $shoppingKey); | ||
46 | + } | ||
47 | + | ||
48 | + if (empty($result)) { | ||
49 | + echo ' '; | ||
50 | + } else { | ||
51 | + $this->echoJson($result); | ||
52 | + } | ||
53 | + } | ||
54 | + | ||
55 | + /** | ||
56 | + * 移入收藏夹 | ||
57 | + */ | ||
58 | + public function colAction() | ||
59 | + { | ||
60 | + $result = array(); | ||
61 | + | ||
62 | + if ($this->isAjax()) { | ||
63 | + $productId = $this->post('id', 0); | ||
64 | + $uid = $this->getUid(true); | ||
65 | + $result = CartModel::addToFav($uid, $productId); | ||
66 | + } | ||
67 | + | ||
68 | + if (empty($result)) { | ||
69 | + echo ' '; | ||
70 | + } else { | ||
71 | + $this->echoJson($result); | ||
72 | + } | ||
73 | + } | ||
74 | + | ||
75 | + /* | ||
76 | + * 获取购物车商品数据 | ||
77 | + */ | ||
78 | + public function goodinfoAction() | ||
79 | + { | ||
80 | + $result = array(); | ||
81 | + | ||
82 | + if ($this->isAjax()) { | ||
83 | + $num = $this->get('buy_num', 1); | ||
84 | + $skn = $this->get('id', 1); | ||
85 | + $uid = $this->getUid(true); | ||
86 | + $result = CartModel::cartProductData($uid, $skn, $num); // 测试skn的ID为51172055 | ||
87 | + $result['num'] = $num; | ||
88 | + } | ||
89 | + | ||
90 | + if (empty($result)) { | ||
91 | + echo ' '; | ||
92 | + } else { | ||
93 | + $this->echoJson($result); | ||
94 | + } | ||
95 | + } | ||
96 | + | ||
97 | + /* | ||
98 | + * 获取购物车加价购商品数据 | ||
99 | + */ | ||
100 | + public function giftinfoAction() | ||
101 | + { | ||
102 | + $result = array(); | ||
103 | + | ||
104 | + if ($this->isAjax()) { | ||
105 | + $skn = $this->get('skn', null); | ||
106 | + $promotionId = $this->get('promotionId', null); | ||
107 | + $result = CartModel::giftProductData($skn, $promotionId); | ||
108 | + } | ||
109 | + | ||
110 | + if (empty($result)) { | ||
111 | + echo ' '; | ||
112 | + } else { | ||
113 | + $this->echoJson($result); | ||
114 | + } | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * 修改购物车商品数据 | ||
119 | + */ | ||
120 | + public function modifyAction() | ||
121 | + { | ||
122 | + $result = array(); | ||
123 | + | ||
124 | + if ($this->isAjax()) { | ||
125 | + $shoppingKey = $this->getSession('shoppingKey'); | ||
126 | + $uid = $this->getUid(true); | ||
127 | + | ||
128 | + $params = array(); | ||
129 | + $params['old_product_sku']= $this->post('old_product_sku', 0); | ||
130 | + $params['new_product_sku']= $this->post('new_product_sku', 0); | ||
131 | + $params['buy_number']= $this->post('buy_number', 0); | ||
132 | + $params['selected']= $this->post('selected', null); | ||
133 | + $result = CartModel::modifyCartProduct($uid, $params, $shoppingKey); | ||
134 | + } | ||
135 | + | ||
136 | + if (empty($result)) { | ||
137 | + echo ' '; | ||
138 | + } else { | ||
139 | + $this->echoJson($result); | ||
140 | + } | ||
141 | + } | ||
142 | + | ||
143 | + /** | ||
144 | + * 购物车结算请求 | ||
145 | + */ | ||
146 | + public function orderEnsureAction() | ||
147 | + { | ||
148 | + $this->setTitle('购物车'); | ||
149 | + $this->setNavHeader('购物车'); | ||
150 | + | ||
151 | + $cartType = $this->post('cartType', 'ordinary'); | ||
152 | + $cookieData = $this->getCookie('orderInfo', null); | ||
153 | + $uid = $this->getUid(true); | ||
154 | + $data = array( | ||
155 | + 'orderEnsurePage' => true, | ||
156 | + 'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData) | ||
157 | + ); | ||
158 | + | ||
159 | + | ||
160 | + $this->_view->display('order-ensure', $data); | ||
161 | + } | ||
162 | + | ||
163 | + /** | ||
164 | + * 购物车选择改变字段,重新运算订单数据 | ||
165 | + */ | ||
166 | + public function orderComputeAction() | ||
167 | + { | ||
168 | + $result = array(); | ||
169 | + | ||
170 | + if ($this->isAjax()) { | ||
171 | + $cartType = $this->post('cartType', 'ordinary'); | ||
172 | + $deliveryWay = $this->post('deliveryWay', 1); | ||
173 | + $paymentType = $this->post('paymentType', 1); | ||
174 | + $couponCode = $this->post('paymentType', null); | ||
175 | + $yohoCoin = $this->post('paymentType', null); | ||
176 | + $uid = $this->getUid(true); | ||
177 | + $result = CartModel::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin); | ||
178 | + } | ||
179 | + | ||
180 | + if (empty($result)) { | ||
181 | + echo ' '; | ||
182 | + } else { | ||
183 | + $this->echoJson($result); | ||
184 | + } | ||
185 | + } | ||
186 | + | ||
187 | + /** | ||
188 | + * 购物车输入优惠券码使用优惠券 | ||
189 | + */ | ||
190 | + public function couponSearchAction() | ||
191 | + { | ||
192 | + $result = array(); | ||
193 | + | ||
194 | + if ($this->isAjax()) { | ||
195 | + $couponCode = $this->get('couponCode', ''); | ||
196 | + $uid = $this->getUid(true); | ||
197 | + $result = CartModel::searchCoupon($uid, $couponCode); | ||
198 | + } | ||
199 | + | ||
200 | + if (empty($result)) { | ||
201 | + echo ' '; | ||
202 | + } else { | ||
203 | + $this->echoJson($result); | ||
204 | + } | ||
205 | + } | ||
206 | + | ||
207 | + /** | ||
208 | + * 购物车结算--获取优惠券列表 | ||
209 | + */ | ||
210 | + public function couponListAction() | ||
211 | + { | ||
212 | + $result = array(); | ||
213 | + | ||
214 | + if ($this->isAjax()) { | ||
215 | + $uid = $this->getUid(true); | ||
216 | + $page = $this->get('page', 1); | ||
217 | + $result = CartModel::getCouponList($uid); | ||
218 | + } | ||
219 | + | ||
220 | + if (empty($result)) { | ||
221 | + echo ' '; | ||
222 | + } else { | ||
223 | + $this->echoJson($result); | ||
224 | + } | ||
225 | + } | ||
379 | 226 | ||
380 | /** | 227 | /** |
381 | * 下单流程 选择地址 | 228 | * 下单流程 选择地址 |
@@ -386,7 +233,7 @@ class ShoppingCartController extends AbstractAction | @@ -386,7 +233,7 @@ class ShoppingCartController extends AbstractAction | ||
386 | $this->setTitle('选择地址'); | 233 | $this->setTitle('选择地址'); |
387 | $this->setNavHeader('选择地址', Helpers::url('/shoppingCart/orderEnsure')); | 234 | $this->setNavHeader('选择地址', Helpers::url('/shoppingCart/orderEnsure')); |
388 | 235 | ||
389 | - $uid = $this->_uid; | 236 | + $uid = $this->getUid(true); |
390 | $address = UserModel::getAddressData($uid); | 237 | $address = UserModel::getAddressData($uid); |
391 | 238 | ||
392 | $this->_view->display('select-address', array( | 239 | $this->_view->display('select-address', array( |
@@ -404,15 +251,41 @@ class ShoppingCartController extends AbstractAction | @@ -404,15 +251,41 @@ class ShoppingCartController extends AbstractAction | ||
404 | // 设置网站标题 | 251 | // 设置网站标题 |
405 | $this->setTitle('选择优惠券'); | 252 | $this->setTitle('选择优惠券'); |
406 | $this->setNavHeader('选择优惠券', Helpers::url('/shoppingCart/orderEnsure')); | 253 | $this->setNavHeader('选择优惠券', Helpers::url('/shoppingCart/orderEnsure')); |
407 | - | ||
408 | - $uid = $this->_uid; | ||
409 | - $address = UserModel::getAddressData($uid); | ||
410 | - | ||
411 | $this->_view->display('select-coupon', array( | 254 | $this->_view->display('select-coupon', array( |
412 | 'selectCouponPage' => true, | 255 | 'selectCouponPage' => true, |
413 | - 'pageFooter' => true, | ||
414 | - 'address' => $address | 256 | + 'pageFooter' => true |
415 | )); | 257 | )); |
416 | } | 258 | } |
417 | 259 | ||
260 | + /** | ||
261 | + * 确认结算订单 | ||
262 | + */ | ||
263 | + public function orderSubAction() | ||
264 | + { | ||
265 | + $result = array(); | ||
266 | + | ||
267 | + if ($this->isAjax()) { | ||
268 | + $uid = $this->getUid(true); | ||
269 | + $addressId = $this->post('addressId', null); | ||
270 | + $cartType = $this->post('cartType', 'ordinary'); // 默认普通购物车 | ||
271 | + $deliveryTime = $this->post('deliveryTime', 1); // 默认只工作日配送 | ||
272 | + $deliveryWay = $this->post('deliveryWay', 1); // 默认普通快递 | ||
273 | + $invoiceTitle = $this->post('invoiceTitle', null); | ||
274 | + $invoiceId = $this->post('invoiceId', null); | ||
275 | + $paymentId = $this->post('paymentId', 15); | ||
276 | + $paymentType = $this->post('paymentType', 1); // 默认在线支付 | ||
277 | + $remark = $this->post('remark', null); // 默认在线支付 | ||
278 | + $yohoCoin = $this->post('yohoCoin', 1); | ||
279 | + $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin); | ||
280 | + } | ||
281 | + | ||
282 | + if (empty($result)) { | ||
283 | + echo ' '; | ||
284 | + } else { | ||
285 | + // 提交成功清除Cookie | ||
286 | + $this->setCookie('orderInfo', null); | ||
287 | + | ||
288 | + $this->echoJson($result); | ||
289 | + } | ||
290 | + } | ||
418 | } | 291 | } |
@@ -17,463 +17,554 @@ use Plugin\Images; | @@ -17,463 +17,554 @@ use Plugin\Images; | ||
17 | class CartModel | 17 | class CartModel |
18 | { | 18 | { |
19 | 19 | ||
20 | - /** | ||
21 | - * 加入购物车 | ||
22 | - * | ||
23 | - * @param int $productSku 商品SKU | ||
24 | - * @param int $buyNumber 购买数量 | ||
25 | - * @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品 | ||
26 | - * @param int int $isEdit 是否是编辑商品SKU,0表示不是编辑 | ||
27 | - * @param null|int $promotionId 促销id,默认null(加价购有关) | ||
28 | - * @param null|int $uid 用户UID,可以不传 | ||
29 | - * @return array 加入购物车接口返回的数据 | ||
30 | - */ | ||
31 | - public static function addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey) | ||
32 | - { | ||
33 | - $result = array('code' => 400, 'message' => '出错啦~~'); | ||
34 | - | ||
35 | - $addCart = CartData::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey); | ||
36 | - if ($addCart && isset($addCart['code'])) { | ||
37 | - $result = $addCart; | ||
38 | - } | ||
39 | - | ||
40 | - return $result; | ||
41 | - } | ||
42 | - | ||
43 | - /** | ||
44 | - * @param integer $uid 用户ID | ||
45 | - * @param string $shoppingKey 未登录用户唯一识别码 | ||
46 | - * @return array|mixed 处理之后的购物车数据 | ||
47 | - */ | ||
48 | - public static function getCartData($uid, $shoppingKey) | ||
49 | - { | ||
50 | - $result = array('cartNav' => true); | ||
51 | - | ||
52 | - // 用户是否登录 | ||
53 | - if (empty($uid)) { | ||
54 | - $result['showLoginInfo'] = true; | ||
55 | - } | ||
56 | - | ||
57 | - // 调用接口获取购物车的数据 | ||
58 | - $cartData = CartData::cartData($uid, $shoppingKey); | ||
59 | - | ||
60 | - // 处理普通购物车和预售购物车的数据 | ||
61 | - if (isset($cartData['data']) && !empty($cartData['data'])) { | ||
62 | - $cart = $cartData['data']; | ||
63 | - | ||
64 | - /* 普通购物车 */ | ||
65 | - if (isset($cart['ordinary_cart_data'])) { | ||
66 | - $result['commonGoodsCount'] = count($cart['ordinary_cart_data']['goods_list']); | ||
67 | - $result['commonCart'] = self::procCartData($cart['ordinary_cart_data']); | ||
68 | - } | ||
69 | - | ||
70 | - /* 预售购物车 */ | ||
71 | - if (isset($cart['advance_cart_data'])) { | ||
72 | - $result['presellGoodsCount'] = count($cart['advance_cart_data']['goods_list']); | ||
73 | - $result['preSellCart'] = self::procCartData($cart['advance_cart_data']); | ||
74 | - } | ||
75 | - } | ||
76 | - | ||
77 | - return $result; | ||
78 | - } | ||
79 | - | ||
80 | - /** | ||
81 | - * 移出购物车 | ||
82 | - * | ||
83 | - * @param int $uid 用户ID | ||
84 | - * @param string $sku 商品sku列表 | ||
85 | - * @param string $shoppingKey 未登录用户唯一识别码 | ||
86 | - * @return array 接口返回的数据 | ||
87 | - */ | ||
88 | - public static function removeFromCart($uid, $sku, $shoppingKey) | ||
89 | - { | ||
90 | - $result = array('code' => 400, 'message' => '出错啦~'); | ||
91 | - | ||
92 | - // 处理sku | ||
93 | - $sku_list = json_encode(array($sku => 1)); | ||
94 | - | ||
95 | - $remove = CartData::removeFromCart($uid, $sku_list, $shoppingKey); | ||
96 | - if ($remove && isset($remove['code'])) { | ||
97 | - $result['code'] = $remove['code']; | ||
98 | - $result['message'] = $remove['message']; | ||
99 | - } | ||
100 | - | ||
101 | - return $result; | ||
102 | - } | ||
103 | - | ||
104 | - /** | ||
105 | - * 移入收藏夹 | ||
106 | - * | ||
107 | - * @param int $uid 用户ID | ||
108 | - * @param string $sku 商品sku列表 | ||
109 | - * @return array 接口返回的数据 | ||
110 | - */ | ||
111 | - public static function addToFav($uid, $sku) | ||
112 | - { | ||
113 | - $result = array('code' => 400, 'message' => '出错啦~'); | ||
114 | - | ||
115 | - if (empty($uid)) { | ||
116 | - $result['code'] = 300; | ||
117 | - $reult['message'] = '请先登录'; | ||
118 | - $result['data'] = '/signin.html'; | ||
119 | - | ||
120 | - return $result; | ||
121 | - } | ||
122 | - | ||
123 | - // 处理sku | ||
124 | - $sku_list = json_encode(array($sku => 1)); | ||
125 | - | ||
126 | - $add = CartData::addToFav($uid, $sku_list); | ||
127 | - if ($add && isset($add['code'])) { | ||
128 | - $result['code'] = $add['code']; | ||
129 | - $result['message'] = $add['message']; | ||
130 | - } | ||
131 | - | ||
132 | - return $result; | ||
133 | - } | ||
134 | - | ||
135 | - /** | ||
136 | - * 处理购物车商品数据 | ||
137 | - * | ||
138 | - * @param int $uid 用户ID | ||
139 | - * @param int $skn 商品skn | ||
140 | - * @param int $num 购买数目 | ||
141 | - * @return array 接口返回的数据 | ||
142 | - */ | ||
143 | - public static function cartProductData($uid, $skn, $num) | ||
144 | - { | ||
145 | - $result = array('code' => 400, 'message' => '出错啦~'); | ||
146 | - | ||
147 | - $product = CartData::cartProductData($uid, $skn); | ||
148 | - if (isset($product['code']) && $product['code'] === 200) { | ||
149 | - $result['code'] = 200; | ||
150 | - $data = array(); | ||
151 | - $productData = $product['data']; | ||
152 | - | ||
153 | - // 品牌信息 | ||
154 | - if (isset($productData['brand_info']) && !empty($productData['brand_info'])) { | ||
155 | - $data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120); | ||
156 | - } | ||
157 | - | ||
158 | - $data['name'] = $productData['product_name']; | ||
159 | - $data['price'] = $productData['market_price']; | ||
160 | - $data['salePrice'] = $productData['sales_price']; | ||
161 | - $data['storage'] = $productData['storage_sum']; | ||
162 | - $data['num'] = $num; | ||
163 | - | ||
164 | - // 商品选择 | ||
165 | - if (isset($productData['goods_list'])) { | ||
166 | - $goodsList = $productData['goods_list']; | ||
167 | - | ||
168 | - $colors = array(); | ||
169 | - $oneColor = array(); | ||
170 | - $sizes = array(); | ||
171 | - $oneSize = array(); | ||
172 | - foreach ($goodsList as $val) { | ||
173 | - // 颜色 | ||
174 | - $oneColor = array(); | ||
175 | - $oneColor['id'] = $val['color_id']; | ||
176 | - $oneColor['name'] = $val['color_name']; | ||
177 | - | ||
178 | - // 尺码 | ||
179 | - foreach ($val['size_list'] as $one) { | ||
180 | - $oneSize = array(); | ||
181 | - $oneSize['id'] = $one['size_id']; | ||
182 | - $oneSize['name'] = $one['size_name']; | ||
183 | - } | ||
184 | - $sizes[] = $oneSize; | ||
185 | - | ||
186 | - $oneColor['sizes'] = $sizes; | ||
187 | - $colors[] = $oneColor; | ||
188 | - } | ||
189 | - | ||
190 | - $data['colors'] = $colors; | ||
191 | - } | ||
192 | - | ||
193 | - $result['data'] = $data; | ||
194 | - } | ||
195 | - | ||
196 | - return $result; | ||
197 | - } | ||
198 | - | ||
199 | - /** | ||
200 | - * 处理加价购商品数据 | ||
201 | - * | ||
202 | - * @param int $skn 商品skn | ||
203 | - * @param int $promotionId 加价购商品促销ID | ||
204 | - * @return array | ||
205 | - */ | ||
206 | - public static function giftProductData($skn, $promotionId) | ||
207 | - { | ||
208 | - $result = array(); | ||
209 | - | ||
210 | - $product = CartData::giftProductData($skn, $promotionId); | ||
211 | - if (isset($product['code']) && $product['code'] === 200) { | ||
212 | - $result['code'] = 200; | ||
213 | - $data = array(); | ||
214 | - $productData = $product['data']; | ||
215 | - | ||
216 | - // 品牌信息 | ||
217 | - if (isset($productData['brand_info']) && !empty($productData['brand_info'])) { | ||
218 | - $data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120); | ||
219 | - } | ||
220 | - | ||
221 | - $data['name'] = $productData['product_name']; | ||
222 | - $data['price'] = $productData['market_price']; | ||
223 | - $data['salePrice'] = $productData['sales_price']; | ||
224 | - $data['storage'] = $productData['storage_sum']; | ||
225 | - | ||
226 | - // 商品选择 | ||
227 | - if (isset($productData['goods_list'])) { | ||
228 | - $goodsList = $productData['goods_list']; | ||
229 | - | ||
230 | - $colors = array(); | ||
231 | - $oneColor = array(); | ||
232 | - $sizes = array(); | ||
233 | - $oneSize = array(); | ||
234 | - foreach ($goodsList as $val) { | ||
235 | - // 颜色 | ||
236 | - $oneColor = array(); | ||
237 | - $oneColor['id'] = $val['color_id']; | ||
238 | - $oneColor['name'] = $val['color_name']; | ||
239 | - | ||
240 | - // 尺码 | ||
241 | - foreach ($val['size_list'] as $one) { | ||
242 | - $oneSize = array(); | ||
243 | - $oneSize['id'] = $one['size_id']; | ||
244 | - $oneSize['name'] = $one['size_name']; | ||
245 | - } | ||
246 | - $sizes[] = $oneSize; | ||
247 | - | ||
248 | - $oneColor['sizes'] = $sizes; | ||
249 | - $colors[] = $oneColor; | ||
250 | - } | ||
251 | - | ||
252 | - $data['colors'] = $colors; | ||
253 | - } | ||
254 | - | ||
255 | - $result['data'] = $data; | ||
256 | - } | ||
257 | - | ||
258 | - return $result; | ||
259 | - } | ||
260 | - | ||
261 | - /** | ||
262 | - * 修改购物车商品数据 | ||
263 | - * | ||
264 | - * @param int $uid 用户ID | ||
265 | - * @param string $param 要更改的数据 | ||
266 | - * @param string $shoppingKey 未登录用户唯一识别码 | ||
267 | - * @return array 接口返回的数据 | ||
268 | - */ | ||
269 | - public static function modifyCartProduct($uid, $param, $shoppingKey) | ||
270 | - { | ||
271 | - $result = array('code' => 400, 'message' => '出错啦~'); | ||
272 | - | ||
273 | - // 处理要更改的数据 | ||
274 | - $swapData = json_encode(array($param)); | ||
275 | - | ||
276 | - $modify = CartData::modifyCartProduct($uid, $swapData, $shoppingKey); | ||
277 | - if ($modify && isset($modify['code'])) { | ||
278 | - $result['code'] = $modify['code']; | ||
279 | - $result['message'] = $modify['message']; | ||
280 | - } | ||
281 | - | ||
282 | - return $result; | ||
283 | - } | ||
284 | - | ||
285 | - /** | ||
286 | - * 调用购物车结算接口返回的数据处理 | ||
287 | - * | ||
288 | - * @param int $uid 用户ID | ||
289 | - * @param string $cartType 购物车类型,ordinary表示普通购物车 | ||
290 | - * @return array 接口返回的数据 | ||
291 | - */ | ||
292 | - public static function cartPay($uid, $cartType) | ||
293 | - { | ||
294 | - $result = array(); | ||
295 | - | ||
296 | - $pay = CartData::cartPay($uid, $cartType); | ||
297 | - | ||
298 | - if ($pay && isset($pay['code']) && $pay['code'] === 200) { | ||
299 | - $payReturn = $pay['data']; | ||
300 | - $result = array(); | ||
301 | - | ||
302 | - // 收货人有关信息 | ||
303 | - if (isset($payReturn['delivery_address']) && !empty($payReturn['delivery_address'])) { | ||
304 | - $result['name'] = $payReturn['delivery_address']['consignee']; | ||
305 | - $result['phoneNum'] = $payReturn['delivery_address']['mobile'] ? : $payReturn['delivery_address']['phone']; | ||
306 | - $result['address'] = $payReturn['delivery_address']['address']; | ||
307 | - } | ||
308 | - | ||
309 | - // 配送方式 | ||
310 | - if (isset($payReturn['delivery_way'])) { | ||
311 | - $oneDeliv = array(); | ||
312 | - foreach ($payReturn['delivery_way'] as $val) { | ||
313 | - $oneDeliv = array(); | ||
314 | - $oneDeliv['id'] = $val['delivery_way_id']; | ||
315 | - $oneDeliv['name'] = $val['delivery_way_name']; | ||
316 | - $oneDeliv['default'] = ($val['default'] === 'Y'); | ||
317 | - | ||
318 | - $result['dispatchMode'][] = $oneDeliv; | ||
319 | - } | ||
320 | - } | ||
321 | - | ||
322 | - // 配送时间 | ||
323 | - if (isset($payReturn['delivery_time'])) { | ||
324 | - $oneDelivTime = array(); | ||
325 | - foreach ($payReturn['delivery_time'] as $one) { | ||
326 | - $oneDelivTime = array(); | ||
327 | - $oneDelivTime['id'] = $one['delivery_time_id']; | ||
328 | - $oneDelivTime['name'] = $one['delivery_time_string']; | ||
329 | - $oneDelivTime['default'] = ($one['default'] === 'Y'); | ||
330 | - | ||
331 | - $result['dispatchTime'][] = $oneDelivTime; | ||
332 | - } | ||
333 | - } | ||
334 | - | ||
335 | - // 订单商品 | ||
336 | - if (isset($payReturn['goods_list'])) { | ||
337 | - $oneGoods = array(); | ||
338 | - foreach ($payReturn['goods_list'] as $single) { | ||
339 | - $oneGoods = array(); | ||
340 | - $oneGoods['id'] = $single['product_sku']; // TODO 未确定用哪个 | ||
341 | - $oneGoods['thumb'] = Images::getImageUrl($single['goods_images'], 120, 120); | ||
342 | - $oneGoods['name'] = $single['product_name']; | ||
343 | - $oneGoods['color'] = $single['color_name']; | ||
344 | - $oneGoods['size'] = $single['size_name']; | ||
345 | - $oneGoods['price'] = Helpers::transPrice($single['real_price']); // last_price有些带.00,有些不带,real_price都不带.00 | ||
346 | - $oneGoods['count'] = $single['buy_number']; | ||
347 | - | ||
348 | - $result['goods'][] = $oneGoods; | ||
349 | - } | ||
350 | - } | ||
351 | - | ||
352 | - // 支付方式 | ||
353 | - if (isset($payReturn['payment_way'])) { | ||
354 | - $onePay = array(); | ||
355 | - foreach ($payReturn['payment_way'] as $pay) { | ||
356 | - $onePay = array(); | ||
357 | - $onePay['id'] = $pay['payment_id']; | ||
358 | - $onePay['paymentType'] = $pay['payment_type']; | ||
359 | - $onePay['name'] = $pay['payment_type_name']; | ||
360 | - $onePay['default'] = ($pay['default'] === 'Y'); | ||
361 | - | ||
362 | - $result['paymentWay'][] = $onePay; | ||
363 | - } | ||
364 | - } | ||
365 | - | ||
366 | - // 有货币 | ||
367 | - $result['yohoCoin'] = $payReturn['yoho_coin']; | ||
368 | - | ||
369 | - // 订单数据 | ||
370 | - if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) { | ||
371 | - $result['sumPrice'] = Helpers::transPrice($payReturn['shopping_cart_data']['order_amount']); | ||
372 | - $result['salePrice'] = Helpers::transPrice($payReturn['shopping_cart_data']['discount_amount']); | ||
373 | - $result['price'] = Helpers::transPrice($payReturn['shopping_cart_data']['last_order_amount']); | ||
374 | - $result['freight'] = Helpers::transPrice($payReturn['shopping_cart_data']['shipping_cost']); | ||
375 | - } | ||
376 | - | ||
377 | - // 发票有关数据 | ||
378 | - if (isset($payReturn['invoices']) && !empty($payReturn['invoices'])) { | ||
379 | - $one = array(); | ||
380 | - foreach ($payReturn['invoices']['invoices_type_list'] as $inv) { | ||
381 | - $one = array(); | ||
382 | - $one['id'] = $inv['invoices_type_id']; | ||
383 | - $one['name'] = $inv['invoices_type_name']; | ||
384 | - | ||
385 | - $result['invoice'][] = $one; | ||
386 | - } | ||
387 | - } | ||
388 | - | ||
389 | - // 优惠券数据 | ||
390 | - $coupons = array('notUsed' => true); | ||
391 | - $coupons += UserModel::getCouponData($uid, 0, 1, true); | ||
392 | - $result['coupon'] = $coupons; | ||
393 | - } | ||
394 | - | ||
395 | - return $result; | ||
396 | - } | ||
397 | - | ||
398 | - /** | ||
399 | - * 购物车结算--支付方式和配送方式选择以及是否使用YOHO币接口返回的数据处理 | ||
400 | - * | ||
401 | - * @param int $uid 用户ID | ||
402 | - * @param string $cartType 购物车类型,ordinary表示普通购物车 | ||
403 | - * @param string $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运 | ||
404 | - * @param string $paymentType 支付方式,1表示在线支付,2表示货到付款 | ||
405 | - * @return array 接口返回的数据 | ||
406 | - */ | ||
407 | - public static function paymentTypeAndDelivery($uid, $cartType, $deliveryWay, $paymentType) | ||
408 | - { | ||
409 | - $result = array(); | ||
410 | - | ||
411 | - $pay = CartData::paymentTypeAndDelivery($uid, $cartType, $deliveryWay, $paymentType); | ||
412 | - if ($pay && isset($pay['code']) && $pay['code'] === 200) { | ||
413 | - $result = $pay['data']; | ||
414 | - } | ||
415 | - | ||
416 | - return $result; | ||
417 | - } | ||
418 | - | ||
419 | - /** | ||
420 | - * 购物车结算--输入优惠券代码返回的结果处理 | ||
421 | - * | ||
422 | - * @param int $uid 用户ID | ||
423 | - * @param string $couponCode 优惠券代码 | ||
424 | - * @return array 接口返回的数据 | ||
425 | - */ | ||
426 | - public static function getCoupon($uid, $couponCode) | ||
427 | - { | ||
428 | - $result = array('code' => 400, 'message' => '出错啦~'); | ||
429 | - | ||
430 | - $coupon = CartData::getCoupon($uid, $couponCode); | ||
431 | - if ($coupon && isset($coupon['code']) && $coupon['code'] === 200) { | ||
432 | - $result['code'] = $coupon['code']; | ||
433 | - $result['message'] = $coupon['message']; | ||
434 | - } | ||
435 | - | ||
436 | - return $result; | ||
437 | - } | ||
438 | - | ||
439 | - /** | ||
440 | - * 处理不同类型的购物车数据 | ||
441 | - * | ||
442 | - * @param array $data 不同类型购物车数据 | ||
443 | - * @return array $result 处理之后的不同类型购物车数据 | ||
444 | - */ | ||
445 | - private static function procCartData($data) | ||
446 | - { | ||
447 | - $result = array(); | ||
448 | - | ||
449 | - $oneGoods = array(); | ||
450 | - // 购买的商品列表 | ||
451 | - foreach ($data['goods_list'] as $value) { | ||
452 | - $oneGoods['id'] = $value['product_sku']; | ||
453 | - $oneGoods['skn'] = $value['product_skn']; | ||
454 | - $oneGoods['name'] = $value['product_name']; | ||
455 | - $oneGoods['thumb'] = Images::getImageUrl($value['goods_images'], 120, 120); | ||
456 | - $oneGoods['color'] = $value['color_name']; | ||
457 | - $oneGoods['size'] = $value['size_name']; | ||
458 | - $oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据 | ||
459 | - $oneGoods['price'] = $value['real_price']; | ||
460 | - $oneGoods['count'] = $value['buy_number']; | ||
461 | - $oneGoods['lowStocks'] = true; | ||
462 | - | ||
463 | - $result['goods'][] = $oneGoods; | ||
464 | - } | ||
465 | - // 赠品 | ||
466 | - count($data['gift_list']) && $result['freebieOrAdvanceBuy'] = true; | ||
467 | - $result['freebie'] = $data['gift_list']; | ||
468 | - // 加价购 | ||
469 | - $result['advanceBuy'] = $data['price_gift']; | ||
470 | - // 结算数据 | ||
471 | - $result['price'] = $data['shopping_cart_data']['order_amount']; | ||
472 | - $result['activityPrice'] = $data['shopping_cart_data']['discount_amount']; | ||
473 | - $result['count'] = $data['shopping_cart_data']['goods_count']; | ||
474 | - $result['sumPrice'] = $data['shopping_cart_data']['order_amount']; | ||
475 | - | ||
476 | - return $result; | ||
477 | - } | 20 | + /** |
21 | + * 加入购物车 | ||
22 | + * | ||
23 | + * @param int $productSku 商品SKU | ||
24 | + * @param int $buyNumber 购买数量 | ||
25 | + * @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品 | ||
26 | + * @param int int $isEdit 是否是编辑商品SKU,0表示不是编辑 | ||
27 | + * @param null|int $promotionId 促销id,默认null(加价购有关) | ||
28 | + * @param null|int $uid 用户UID,可以不传 | ||
29 | + * @return array 加入购物车接口返回的数据 | ||
30 | + */ | ||
31 | + public static function addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid) | ||
32 | + { | ||
33 | + $result = array('code' => 400, 'message' => '出错啦~~'); | ||
34 | + | ||
35 | + $addCart = CartData::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid); | ||
36 | + if ($addCart && isset($addCart['code'])) { | ||
37 | + $result = $addCart; | ||
38 | + } | ||
39 | + | ||
40 | + return $result; | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * @param integer $uid 用户ID | ||
45 | + * @param string $shoppingKey 未登录用户唯一识别码 | ||
46 | + * @return array|mixed 处理之后的购物车数据 | ||
47 | + */ | ||
48 | + public static function getCartData($uid, $shoppingKey) | ||
49 | + { | ||
50 | + $result = array('cartNav' => true); | ||
51 | + | ||
52 | + // 用户是否登录 | ||
53 | + if (empty($uid)) { | ||
54 | + $result['showLoginInfo'] = true; | ||
55 | + } | ||
56 | + | ||
57 | + // 调用接口获取购物车的数据 | ||
58 | + $cartData = CartData::cartData($uid, $shoppingKey); | ||
59 | + | ||
60 | + // 处理普通购物车和预售购物车的数据 | ||
61 | + if (isset($cartData['data']) && !empty($cartData['data'])) { | ||
62 | + $cart = $cartData['data']; | ||
63 | + | ||
64 | + /* 普通购物车 */ | ||
65 | + if(isset($cart['ordinary_cart_data'])) { | ||
66 | + $result['commonGoodsCount'] = count($cart['ordinary_cart_data']['goods_list']); | ||
67 | + $result['commonCart'] = self::procCartData($cart['ordinary_cart_data']); | ||
68 | + } | ||
69 | + | ||
70 | + /* 预售购物车 */ | ||
71 | + if(isset($cart['advance_cart_data'])) { | ||
72 | + $result['presellGoodsCount'] = count($cart['advance_cart_data']['goods_list']); | ||
73 | + $result['preSellCart'] = self::procCartData($cart['advance_cart_data']); | ||
74 | + } | ||
75 | + | ||
76 | + } | ||
77 | + | ||
78 | + return $result; | ||
79 | + } | ||
80 | + | ||
81 | + /** | ||
82 | + * 移出购物车 | ||
83 | + * | ||
84 | + * @param int $uid 用户ID | ||
85 | + * @param string $sku 商品sku列表 | ||
86 | + * @param string $shoppingKey 未登录用户唯一识别码 | ||
87 | + * @return array 接口返回的数据 | ||
88 | + */ | ||
89 | + public static function removeFromCart($uid, $sku, $shoppingKey) | ||
90 | + { | ||
91 | + $result = array('code' => 400, 'message' => '出错啦~'); | ||
92 | + | ||
93 | + // 处理sku | ||
94 | + $sku_list = json_encode(array($sku => 1)); | ||
95 | + | ||
96 | + $remove = CartData::removeFromCart($uid, $sku_list, $shoppingKey); | ||
97 | + if ($remove && isset($remove['code'])) { | ||
98 | + $result['code'] = $remove['code']; | ||
99 | + $result['message'] = $remove['message']; | ||
100 | + } | ||
101 | + | ||
102 | + return $result; | ||
103 | + } | ||
104 | + | ||
105 | + /** | ||
106 | + * 移入收藏夹 | ||
107 | + * | ||
108 | + * @param int $uid 用户ID | ||
109 | + * @param string $sku 商品sku列表 | ||
110 | + * @return array 接口返回的数据 | ||
111 | + */ | ||
112 | + public static function addToFav($uid, $sku) | ||
113 | + { | ||
114 | + $result = array('code' => 400, 'message' => '出错啦~'); | ||
115 | + | ||
116 | + if (empty($uid)) { | ||
117 | + $result['code'] = 300; | ||
118 | + $reult['message'] = '请先登录'; | ||
119 | + $result['data'] = '/signin.html'; | ||
120 | + | ||
121 | + return $result; | ||
122 | + } | ||
123 | + | ||
124 | + // 处理sku | ||
125 | + $sku_list = json_encode(array($sku => 1)); | ||
126 | + | ||
127 | + $add = CartData::addToFav($uid, $sku_list); | ||
128 | + if ($add && isset($add['code'])) { | ||
129 | + $result['code'] = $add['code']; | ||
130 | + $result['message'] = $add['message']; | ||
131 | + } | ||
132 | + | ||
133 | + return $result; | ||
134 | + } | ||
135 | + | ||
136 | + /** | ||
137 | + * 处理购物车商品数据 | ||
138 | + * | ||
139 | + * @param int $uid 用户ID | ||
140 | + * @param int $skn 商品skn | ||
141 | + * @param int $num 购买数目 | ||
142 | + * @return array 接口返回的数据 | ||
143 | + */ | ||
144 | + public static function cartProductData($uid, $skn, $num) | ||
145 | + { | ||
146 | + $result = array('code' => 400, 'message' => '出错啦~'); | ||
147 | + | ||
148 | + $product = CartData::cartProductData($uid, $skn); | ||
149 | + if (isset($product['code']) && $product['code'] === 200) { | ||
150 | + $result['code'] = 200; | ||
151 | + $data = array(); | ||
152 | + $productData = $product['data']; | ||
153 | + | ||
154 | + // 品牌信息 | ||
155 | + if (isset($productData['brand_info']) && !empty($productData['brand_info'])) { | ||
156 | + $data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120); | ||
157 | + } | ||
158 | + | ||
159 | + $data['name'] = $productData['product_name']; | ||
160 | + $data['price'] = $productData['market_price']; | ||
161 | + $data['salePrice'] = $productData['sales_price']; | ||
162 | + $data['storage'] = $productData['storage_sum']; | ||
163 | + $data['num'] = $num; | ||
164 | + | ||
165 | + // 商品选择 | ||
166 | + if (isset($productData['goods_list'])) { | ||
167 | + $goodsList = $productData['goods_list']; | ||
168 | + | ||
169 | + $colors = array(); | ||
170 | + $oneColor = array(); | ||
171 | + $sizes = array(); | ||
172 | + $oneSize = array(); | ||
173 | + foreach ($goodsList as $val) { | ||
174 | + // 颜色 | ||
175 | + $oneColor = array(); | ||
176 | + $oneColor['id'] = $val['color_id']; | ||
177 | + $oneColor['name'] = $val['color_name']; | ||
178 | + | ||
179 | + // 尺码 | ||
180 | + foreach ($val['size_list'] as $one) { | ||
181 | + $oneSize = array(); | ||
182 | + $oneSize['id'] = $one['size_id']; | ||
183 | + $oneSize['name'] = $one['size_name']; | ||
184 | + } | ||
185 | + $sizes[] = $oneSize; | ||
186 | + | ||
187 | + $oneColor['sizes'] = $sizes; | ||
188 | + $colors[] = $oneColor; | ||
189 | + } | ||
190 | + | ||
191 | + $data['colors'] = $colors; | ||
192 | + } | ||
193 | + | ||
194 | + $result['data'] = $data; | ||
195 | + } | ||
196 | + | ||
197 | + return $result; | ||
198 | + } | ||
199 | + | ||
200 | + /** | ||
201 | + * 处理加价购商品数据 | ||
202 | + * | ||
203 | + * @param int $skn 商品skn | ||
204 | + * @param int $promotionId 加价购商品促销ID | ||
205 | + * @return array | ||
206 | + */ | ||
207 | + public static function giftProductData($skn, $promotionId) | ||
208 | + { | ||
209 | + $result = array(); | ||
210 | + | ||
211 | + $product = CartData::giftProductData($skn, $promotionId); | ||
212 | + if (isset($product['code']) && $product['code'] === 200) { | ||
213 | + $result['code'] = 200; | ||
214 | + $data = array(); | ||
215 | + $productData = $product['data']; | ||
216 | + | ||
217 | + // 品牌信息 | ||
218 | + if (isset($productData['brand_info']) && !empty($productData['brand_info'])) { | ||
219 | + $data['thumb'] = Helpers::getImageUrl($productData['brand_info']['brand_ico'], 120, 120); | ||
220 | + } | ||
221 | + | ||
222 | + $data['name'] = $productData['product_name']; | ||
223 | + $data['price'] = $productData['market_price']; | ||
224 | + $data['salePrice'] = $productData['sales_price']; | ||
225 | + $data['storage'] = $productData['storage_sum']; | ||
226 | + | ||
227 | + // 商品选择 | ||
228 | + if (isset($productData['goods_list'])) { | ||
229 | + $goodsList = $productData['goods_list']; | ||
230 | + | ||
231 | + $colors = array(); | ||
232 | + $oneColor = array(); | ||
233 | + $sizes = array(); | ||
234 | + $oneSize = array(); | ||
235 | + foreach ($goodsList as $val) { | ||
236 | + // 颜色 | ||
237 | + $oneColor = array(); | ||
238 | + $oneColor['id'] = $val['color_id']; | ||
239 | + $oneColor['name'] = $val['color_name']; | ||
240 | + | ||
241 | + // 尺码 | ||
242 | + foreach ($val['size_list'] as $one) { | ||
243 | + $oneSize = array(); | ||
244 | + $oneSize['id'] = $one['size_id']; | ||
245 | + $oneSize['name'] = $one['size_name']; | ||
246 | + } | ||
247 | + $sizes[] = $oneSize; | ||
248 | + | ||
249 | + $oneColor['sizes'] = $sizes; | ||
250 | + $colors[] = $oneColor; | ||
251 | + } | ||
252 | + | ||
253 | + $data['colors'] = $colors; | ||
254 | + } | ||
255 | + | ||
256 | + $result['data'] = $data; | ||
257 | + } | ||
258 | + | ||
259 | + return $result; | ||
260 | + } | ||
261 | + | ||
262 | + /** | ||
263 | + * 修改购物车商品数据 | ||
264 | + * | ||
265 | + * @param int $uid 用户ID | ||
266 | + * @param string $param 要更改的数据 | ||
267 | + * @param string $shoppingKey 未登录用户唯一识别码 | ||
268 | + * @return array 接口返回的数据 | ||
269 | + */ | ||
270 | + public static function modifyCartProduct($uid, $param, $shoppingKey) | ||
271 | + { | ||
272 | + $result = array('code' => 400, 'message' => '出错啦~'); | ||
273 | + | ||
274 | + // 处理要更改的数据 | ||
275 | + $swapData = json_encode(array($param)); | ||
276 | + | ||
277 | + $modify = CartData::modifyCartProduct($uid, $swapData, $shoppingKey); | ||
278 | + if ($modify && isset($modify['code'])) { | ||
279 | + $result['code'] = $modify['code']; | ||
280 | + $result['message'] = $modify['message']; | ||
281 | + } | ||
282 | + | ||
283 | + return $result; | ||
284 | + } | ||
285 | + | ||
286 | + /** | ||
287 | + * 调用购物车结算接口返回的数据处理 | ||
288 | + * | ||
289 | + * @param int $uid 用户ID | ||
290 | + * @param string $cartType 购物车类型,ordinary表示普通购物车 | ||
291 | + * @param null|string $cookieData cookie中记录的一些订单有关数据 | ||
292 | + * @return array 接口返回的数据 | ||
293 | + */ | ||
294 | + public static function cartPay($uid, $cartType, $cookieData) | ||
295 | + { | ||
296 | + $result = array(); | ||
297 | + | ||
298 | + $pay = CartData::cartPay($uid, $cartType); | ||
299 | + | ||
300 | + if ($pay && isset($pay['code']) && $pay['code'] === 200) { | ||
301 | + $payReturn = $pay['data']; | ||
302 | + $orderInfo = array(); | ||
303 | + $address = array(); | ||
304 | + $orderCompute = array(); | ||
305 | + | ||
306 | + // cookie保存的数据 | ||
307 | + if (!empty($cookieData)) { | ||
308 | + $orderInfo = json_decode($cookieData, true); | ||
309 | + $orderCompute = self::orderCompute($uid, $cartType, $orderInfo['deliveryId'], $orderInfo['paymentTypeId'], $orderInfo['couponCode'], $orderInfo['yohoCoin']); | ||
310 | + } | ||
311 | + | ||
312 | + // 根据地址id查询地址信息 | ||
313 | + if (isset($orderInfo['addressId'])) { | ||
314 | + $address = UserModel::getAddressDataById($uid, $orderInfo['addressId']); | ||
315 | + } | ||
316 | + | ||
317 | + // 收货人有关信息 | ||
318 | + if (isset($payReturn['delivery_address']) && !empty($payReturn['delivery_address'])) { | ||
319 | + $result['addressId'] = isset($address['address_id']) ? $address['address_id'] : $payReturn['delivery_address']['address_id']; | ||
320 | + $result['name'] = isset($address['consignee']) ? $address['consignee'] : $payReturn['delivery_address']['consignee']; | ||
321 | + $result['phoneNum'] = isset($address['mobile']) ? $address['mobile'] : $payReturn['delivery_address']['mobile']; | ||
322 | + $result['address'] = isset($address['address']) ? $address['address'] : $payReturn['delivery_address']['address']; | ||
323 | + $result['isSupport'] = ($payReturn['delivery_address']['is_support'] === 'Y'); | ||
324 | + } | ||
325 | + | ||
326 | + // 配送方式 | ||
327 | + if (isset($payReturn['delivery_way'])) { | ||
328 | + $oneDeliv = array(); | ||
329 | + foreach ($payReturn['delivery_way'] as $val) { | ||
330 | + $oneDeliv = array(); | ||
331 | + $oneDeliv['id'] = $val['delivery_way_id']; | ||
332 | + $oneDeliv['name'] = $val['delivery_way_name']; | ||
333 | + $oneDeliv['default'] = ($val['default'] === 'Y'); | ||
334 | + isset($orderInfo['deliveryId']) && $orderInfo['deliveryId'] === $oneDeliv['id'] && $oneDeliv['isSelected'] = true; | ||
335 | + | ||
336 | + $result['dispatchMode'][] = $oneDeliv; | ||
337 | + } | ||
338 | + } | ||
339 | + | ||
340 | + // 配送时间 | ||
341 | + if (isset($payReturn['delivery_time'])) { | ||
342 | + $oneDelivTime = array(); | ||
343 | + foreach ($payReturn['delivery_time'] as $one) { | ||
344 | + $oneDelivTime = array(); | ||
345 | + $oneDelivTime['id'] = $one['delivery_time_id']; | ||
346 | + $oneDelivTime['name'] = $one['delivery_time_string']; | ||
347 | + $oneDelivTime['default'] = ($one['default'] === 'Y'); | ||
348 | + isset($orderInfo['deliveryTimeId']) && $orderInfo['deliveryTimeId'] === $oneDelivTime['id'] && $oneDeliv['isSelected'] = true; | ||
349 | + | ||
350 | + $result['dispatchTime'][] = $oneDelivTime; | ||
351 | + } | ||
352 | + } | ||
353 | + | ||
354 | + // 订单商品 | ||
355 | + if (isset($payReturn['goods_list'])) { | ||
356 | + $oneGoods = array(); | ||
357 | + foreach ($payReturn['goods_list'] as $single) { | ||
358 | + $oneGoods = array(); | ||
359 | + $oneGoods['id'] = $single['product_sku']; // TODO 未确定用哪个 | ||
360 | + $oneGoods['thumb'] = Images::getImageUrl($single['goods_images'], 120, 120); | ||
361 | + $oneGoods['name'] = $single['product_name']; | ||
362 | + $oneGoods['color'] = $single['color_name']; | ||
363 | + $oneGoods['size'] = $single['size_name']; | ||
364 | + $oneGoods['price'] = Helpers::transPrice($single['real_price']); // last_price有些带.00,有些不带,real_price都不带.00 | ||
365 | + $oneGoods['count'] = $single['buy_number']; | ||
366 | + | ||
367 | + $result['goods'][] = $oneGoods; | ||
368 | + } | ||
369 | + } | ||
370 | + | ||
371 | + // 支付方式 | ||
372 | + if (isset($payReturn['payment_way'])) { | ||
373 | + $onePay = array(); | ||
374 | + foreach ($payReturn['payment_way'] as $pay) { | ||
375 | + $onePay = array(); | ||
376 | + $onePay['id'] = $pay['payment_id']; | ||
377 | + $onePay['paymentType'] = $pay['payment_type']; | ||
378 | + $onePay['name'] = $pay['payment_type_name']; | ||
379 | + $onePay['default'] = ($pay['default'] === 'Y'); | ||
380 | + | ||
381 | + $result['paymentWay'][] = $onePay; | ||
382 | + } | ||
383 | + } | ||
384 | + | ||
385 | + // 有货币 | ||
386 | + $result['yohoCoin'] = isset($orderCompute['use_yoho_coin']) ? isset($orderCompute['use_yoho_coin']) : $payReturn['yoho_coin']; | ||
387 | + | ||
388 | + // 订单数据 | ||
389 | + if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) { | ||
390 | + $sumPrice = isset($orderCompute['order_amount']) ? $orderCompute['order_amount'] : $payReturn['shopping_cart_data']['order_amount']; | ||
391 | + $salePrice = isset($orderCompute['discount_amount']) ? $orderCompute['discount_amount'] : $payReturn['shopping_cart_data']['discount_amount']; | ||
392 | + $price = isset($orderCompute['last_order_amount']) ? $orderCompute['last_order_amount'] : $payReturn['shopping_cart_data']['last_order_amount']; | ||
393 | + $freight = isset($orderCompute['promotion_formula_list']['promotion_amount']) ? $orderCompute['promotion_formula_list']['promotion_amount'] : $payReturn['shopping_cart_data']['promotion_formula_list'][1]['promotion_amount']; | ||
394 | + $result['sumPrice'] = Helpers::transPrice($sumPrice); | ||
395 | + $result['salePrice'] = Helpers::transPrice($salePrice); | ||
396 | + $result['price'] = Helpers::transPrice($price); | ||
397 | + $result['freight'] = strtr($freight, array('¥'=>'','¥'=>'')) . '.00'; | ||
398 | + } | ||
399 | + | ||
400 | + // 发票有关数据 | ||
401 | + if (isset($payReturn['invoices']) && !empty($payReturn['invoices'])) { | ||
402 | + $one = array(); | ||
403 | + foreach ($payReturn['invoices']['invoices_type_list'] as $inv) { | ||
404 | + $one = array(); | ||
405 | + $one['id'] = $inv['invoices_type_id']; | ||
406 | + $one['name'] = $inv['invoices_type_name']; | ||
407 | + | ||
408 | + $result['invoice'][] = $one; | ||
409 | + } | ||
410 | + } | ||
411 | + | ||
412 | + // 优惠券数据 | ||
413 | + $coupons = array('notUsed' => true); | ||
414 | + !empty($orderCompute['coupon_amount']) && $coupons['notUsed'] = $orderInfo['couponName']; | ||
415 | + $coupons += self::getCouponList($uid, 0, 1, true); | ||
416 | + $result['coupon'] = $coupons; | ||
417 | + } | ||
418 | + | ||
419 | + return $result; | ||
420 | + } | ||
421 | + | ||
422 | + /** | ||
423 | + * 购物车结算--支付方式和配送方式选择以及是否使用YOHO币接口返回的数据处理 | ||
424 | + * | ||
425 | + * @param int $uid 用户ID | ||
426 | + * @param string $cartType 购物车类型,ordinary表示普通购物车 | ||
427 | + * @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运 | ||
428 | + * @param int $paymentType 支付方式,1表示在线支付,2表示货到付款 | ||
429 | + * @param string $couponCode 优惠券码 | ||
430 | + * @param mixed $yohoCoin 使用的YOHO币数量 | ||
431 | + * @return array 接口返回的数据 | ||
432 | + */ | ||
433 | + public static function orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin) | ||
434 | + { | ||
435 | + $result = array(); | ||
436 | + | ||
437 | + $compute = CartData::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin); | ||
438 | + if ($compute && isset($compute['code']) && $compute['code'] === 200) { | ||
439 | + $result = $compute['data']; | ||
440 | + } | ||
441 | + | ||
442 | + return $result; | ||
443 | + } | ||
444 | + | ||
445 | + /** | ||
446 | + * 购物车结算--输入优惠券代码返回的结果处理 | ||
447 | + * | ||
448 | + * @param int $uid 用户ID | ||
449 | + * @param string $couponCode 优惠券代码 | ||
450 | + * @return array 接口返回的数据 | ||
451 | + */ | ||
452 | + public static function searchCoupon($uid, $couponCode) | ||
453 | + { | ||
454 | + $result = array('code' => 400, 'message' => '出错啦~'); | ||
455 | + | ||
456 | + $coupon = CartData::searchCoupon($uid, $couponCode); | ||
457 | + if ($coupon && isset($coupon['code'])) { | ||
458 | + $result = $coupon; | ||
459 | + } | ||
460 | + | ||
461 | + return $result; | ||
462 | + } | ||
463 | + | ||
464 | + /** | ||
465 | + * 处理优惠券列表数据 | ||
466 | + * | ||
467 | + * @param int $uid 用户ID | ||
468 | + * @param boolean $onlyTotal 只返回总数 | ||
469 | + * @return array|mixed 处理之后的优惠券数据 | ||
470 | + */ | ||
471 | + public static function getCouponList($uid, $onlyTotal = false) | ||
472 | + { | ||
473 | + $result = array(); | ||
474 | + | ||
475 | + // 调用接口获取优惠券数据 | ||
476 | + $coupons = CartData::getCouponList($uid); | ||
477 | + | ||
478 | + // 处理优惠券数据 | ||
479 | + if (isset($coupons['data'])) { | ||
480 | + | ||
481 | + if ($onlyTotal) { | ||
482 | + $result['count'] = $coupons['data']['total']; | ||
483 | + } else { | ||
484 | + $couponArr = array(); | ||
485 | + isset($coupons['data']['couponList']) && $couponArr = $coupons['data']['couponList']; | ||
486 | + | ||
487 | + foreach ($couponArr as &$val) { | ||
488 | + $notAvailableRes = self::searchCoupon($uid, $val['couponCode']); | ||
489 | + // 处理可用的优惠券 | ||
490 | + if (isset($notAvailableRes['code']) && $notAvailableRes['code'] !== 200) { | ||
491 | + $val['notAvailable'] = true; | ||
492 | + } | ||
493 | + } | ||
494 | + !empty($couponArr) && $result['coupons'] = $couponArr; | ||
495 | + } | ||
496 | + } | ||
497 | + | ||
498 | + return $result; | ||
499 | + } | ||
500 | + | ||
501 | + /** | ||
502 | + * 购物车结算--提交结算信息 | ||
503 | + * | ||
504 | + * @param int $uid 用户ID | ||
505 | + * @param int $addressId 地址ID | ||
506 | + * @param int $cartType 购物车类型ID | ||
507 | + * @param int $deliveryTime 寄送时间ID | ||
508 | + * @param int $deliveryWay 寄送方式ID | ||
509 | + * @param string $invoiceTitle 发票说明 | ||
510 | + * @param int $invoiceId 发票类型ID | ||
511 | + * @param int $paymentId 支付方式ID | ||
512 | + * @param int $paymentType 支付类型ID | ||
513 | + * @param string $remark 留言 | ||
514 | + * @param mixed $yohoCoin 使用的YOHO币数量或为空 | ||
515 | + * @return array 接口返回的数据 | ||
516 | + */ | ||
517 | + public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin) | ||
518 | + { | ||
519 | + $result = array(); | ||
520 | + | ||
521 | + $orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin); | ||
522 | + if ($orderSubRes && isset($orderSubRes['code']) && $orderSubRes['code'] === 200) { | ||
523 | + $result = $orderSubRes; | ||
524 | + } | ||
525 | + | ||
526 | + return $result; | ||
527 | + } | ||
528 | + | ||
529 | + | ||
530 | + /** | ||
531 | + * 处理不同类型的购物车数据 | ||
532 | + * | ||
533 | + * @param array $data 不同类型购物车数据 | ||
534 | + * @return array $result 处理之后的不同类型购物车数据 | ||
535 | + */ | ||
536 | + private static function procCartData($data) | ||
537 | + { | ||
538 | + $result = array(); | ||
539 | + | ||
540 | + $oneGoods = array(); | ||
541 | + // 购买的商品列表 | ||
542 | + foreach ($data['goods_list'] as $value) { | ||
543 | + $oneGoods['id'] = $value['product_sku']; | ||
544 | + $oneGoods['skn'] = $value['product_skn']; | ||
545 | + $oneGoods['name'] = $value['product_name']; | ||
546 | + $oneGoods['thumb'] = Images::getImageUrl($value['goods_images'], 120, 120); | ||
547 | + $oneGoods['color'] = $value['color_name']; | ||
548 | + $oneGoods['size'] = $value['size_name']; | ||
549 | + $oneGoods['appearDate'] = '12月'; // 目前app接口没有返回该数据 | ||
550 | + $oneGoods['price'] = $value['real_price']; | ||
551 | + $oneGoods['count'] = $value['buy_number']; | ||
552 | + $oneGoods['lowStocks'] = true; | ||
553 | + | ||
554 | + $result['goods'][] = $oneGoods; | ||
555 | + } | ||
556 | + // 赠品 | ||
557 | + count($data['gift_list']) && $result['freebieOrAdvanceBuy'] = true; | ||
558 | + $result['freebie'] = $data['gift_list']; | ||
559 | + // 加价购 | ||
560 | + $result['advanceBuy'] = $data['price_gift']; | ||
561 | + // 结算数据 | ||
562 | + $result['price'] = $data['shopping_cart_data']['order_amount']; | ||
563 | + $result['activityPrice'] = $data['shopping_cart_data']['discount_amount']; | ||
564 | + $result['count'] = $data['shopping_cart_data']['goods_count']; | ||
565 | + $result['sumPrice'] = $data['shopping_cart_data']['order_amount']; | ||
566 | + | ||
567 | + return $result; | ||
568 | + } | ||
478 | 569 | ||
479 | } | 570 | } |
@@ -374,10 +374,9 @@ class UserModel | @@ -374,10 +374,9 @@ class UserModel | ||
374 | * @param int $uid 用户ID | 374 | * @param int $uid 用户ID |
375 | * @param int $status 优惠券状态,0表示未使用,1表示已使用 | 375 | * @param int $status 优惠券状态,0表示未使用,1表示已使用 |
376 | * @param int $page 第几页 | 376 | * @param int $page 第几页 |
377 | - * @param boolean $onlyTotal 只返回总数 | ||
378 | * @return array|mixed 处理之后的优惠券数据 | 377 | * @return array|mixed 处理之后的优惠券数据 |
379 | */ | 378 | */ |
380 | - public static function getCouponData($uid, $status, $page, $onlyTotal = false) | 379 | + public static function getCouponData($uid, $status, $page) |
381 | { | 380 | { |
382 | $result = array(); | 381 | $result = array(); |
383 | 382 | ||
@@ -386,7 +385,6 @@ class UserModel | @@ -386,7 +385,6 @@ class UserModel | ||
386 | 385 | ||
387 | // 没有获取到优惠券时 | 386 | // 没有获取到优惠券时 |
388 | if (!$coupons) { | 387 | if (!$coupons) { |
389 | - $result['topURL'] = '/product/new'; | ||
390 | $result['noRecord'] = true; | 388 | $result['noRecord'] = true; |
391 | 389 | ||
392 | return $result; | 390 | return $result; |
@@ -395,15 +393,8 @@ class UserModel | @@ -395,15 +393,8 @@ class UserModel | ||
395 | // 处理优惠券数据 | 393 | // 处理优惠券数据 |
396 | if (isset($coupons['data'])) { | 394 | if (isset($coupons['data'])) { |
397 | 395 | ||
398 | - if ($onlyTotal) { | ||
399 | - $result['count'] = $coupons['data']['total']; | ||
400 | - | ||
401 | - return $result; | ||
402 | - } | ||
403 | - | ||
404 | // 不能再查到结果了 | 396 | // 不能再查到结果了 |
405 | if ($page == 1 && $coupons['data']['total'] === 0) { | 397 | if ($page == 1 && $coupons['data']['total'] === 0) { |
406 | - $result['walkwayUrl'] = '/product/new'; | ||
407 | $result['noRecord'] = true; | 398 | $result['noRecord'] = true; |
408 | } else { | 399 | } else { |
409 | $couponArr = array(); | 400 | $couponArr = array(); |
@@ -51,8 +51,6 @@ application.assets.path = ROOT_PATH "/assets" | @@ -51,8 +51,6 @@ application.assets.path = ROOT_PATH "/assets" | ||
51 | 51 | ||
52 | ; 应用的版本号 | 52 | ; 应用的版本号 |
53 | application.version = "1.2.1" | 53 | application.version = "1.2.1" |
54 | -; JS统计代码的版本号 | ||
55 | -application.yas.version = "1.0.13.2" | ||
56 | 54 | ||
57 | ; 网站SEO信息 | 55 | ; 网站SEO信息 |
58 | application.seo.title = "Yoho!Buy有货 | 潮流购物逛不停" | 56 | application.seo.title = "Yoho!Buy有货 | 潮流购物逛不停" |
@@ -51,8 +51,6 @@ application.assets.path = ROOT_PATH "/assets" | @@ -51,8 +51,6 @@ application.assets.path = ROOT_PATH "/assets" | ||
51 | 51 | ||
52 | ; 应用的版本号 | 52 | ; 应用的版本号 |
53 | application.version = "1.2.1" | 53 | application.version = "1.2.1" |
54 | -; JS统计代码的版本号 | ||
55 | -application.yas.version = "1.0.13.2" | ||
56 | 54 | ||
57 | ; 网站SEO信息 | 55 | ; 网站SEO信息 |
58 | application.seo.title = "Yoho!Buy有货 | 潮流购物逛不停" | 56 | application.seo.title = "Yoho!Buy有货 | 潮流购物逛不停" |
@@ -51,8 +51,6 @@ application.assets.path = ROOT_PATH "/assets" | @@ -51,8 +51,6 @@ application.assets.path = ROOT_PATH "/assets" | ||
51 | 51 | ||
52 | ; 应用的版本号 | 52 | ; 应用的版本号 |
53 | application.version = "1.2.1" | 53 | application.version = "1.2.1" |
54 | -; JS统计代码的版本号 | ||
55 | -application.yas.version = "1.0.13.2" | ||
56 | 54 | ||
57 | ; 网站SEO信息 | 55 | ; 网站SEO信息 |
58 | application.seo.title = "Yoho!Buy有货 | 潮流购物逛不停" | 56 | application.seo.title = "Yoho!Buy有货 | 潮流购物逛不停" |
@@ -51,8 +51,6 @@ application.assets.path = ROOT_PATH "/assets" | @@ -51,8 +51,6 @@ application.assets.path = ROOT_PATH "/assets" | ||
51 | 51 | ||
52 | ; 应用的版本号 | 52 | ; 应用的版本号 |
53 | application.version = "1.2.1" | 53 | application.version = "1.2.1" |
54 | -; JS统计代码的版本号 | ||
55 | -application.yas.version = "1.0.13.2" | ||
56 | 54 | ||
57 | ; 网站SEO信息 | 55 | ; 网站SEO信息 |
58 | application.seo.title = "Yoho!Buy有货 | 潮流购物逛不停" | 56 | application.seo.title = "Yoho!Buy有货 | 潮流购物逛不停" |
-
Please register or login to post a comment