Authored by Rock Zhang

Merge branch 'feature/limitsale' into develop/wap

@@ -133,8 +133,10 @@ class DetailData @@ -133,8 +133,10 @@ class DetailData
133 133
134 /** 134 /**
135 * 为你优选的商品列表 135 * 为你优选的商品列表
136 - * 136 + *
137 * @param int $productSkn 商品SKN号 137 * @param int $productSkn 商品SKN号
  138 + * @param int $channel
  139 + * @param int $brandId
138 * @return array 140 * @return array
139 */ 141 */
140 public static function preference($productSkn, $channel, $brandId) 142 public static function preference($productSkn, $channel, $brandId)
@@ -220,4 +222,26 @@ class DetailData @@ -220,4 +222,26 @@ class DetailData
220 return Yohobuy::get(Yohobuy::API_URL, $param); 222 return Yohobuy::get(Yohobuy::API_URL, $param);
221 } 223 }
222 224
  225 + /**
  226 + * 获取限购商品详情
  227 + *
  228 + * @param int $uid 用户UID
  229 + * @param string $productCode 限购商品商品码
  230 + * @return mixed
  231 + */
  232 + public static function limitProductData($uid, $productCode)
  233 + {
  234 + $param = Yohobuy::param();
  235 + $param['method'] = 'app.limitProduct.limitProductDetail';
  236 + $param['limitProductCode'] = $productCode;
  237 +
  238 + if (!empty($uid)) {
  239 + $param['uid'] = $uid;
  240 + }
  241 +
  242 + $param['client_secret'] = Sign::getSign($param);
  243 +
  244 + return Yohobuy::get(Yohobuy::API_URL, $param);
  245 + }
  246 +
223 } 247 }
@@ -895,4 +895,21 @@ class Helpers @@ -895,4 +895,21 @@ class Helpers
895 } 895 }
896 return $area.'-'.$mobile; 896 return $area.'-'.$mobile;
897 } 897 }
  898 +
  899 + /**
  900 + * 按照数组中指定字段排序二维数组
  901 + *
  902 + * @param array &$array 需要排序的数组
  903 + * @param string $field 字段名称
  904 + * @param boolean $desc 时候降序排列,默认为false
  905 + */
  906 + public static function sortArrByField(&$array, $field, $desc = false)
  907 + {
  908 + $fieldArr = array();
  909 + foreach ($array as $k => $v) {
  910 + $fieldArr[$k] = isset($v[$field]) ? $v[$field] : '';
  911 + }
  912 + $sort = $desc == false ? SORT_ASC : SORT_DESC;
  913 + array_multisort($fieldArr, $sort, $array);
  914 + }
898 } 915 }
@@ -94,7 +94,7 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) { @@ -94,7 +94,7 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) {
94 * @return {undefined} 94 * @return {undefined}
95 */ 95 */
96 function setLimitGoodModeWithSknId(code, sknId) { 96 function setLimitGoodModeWithSknId(code, sknId) {
97 - $('#chose-btn-sure').html('结算'); 97 + $('#chose-btn-sure').html('立即购买');
98 limitProductCode = code; 98 limitProductCode = code;
99 skn = sknId; 99 skn = sknId;
100 } 100 }
@@ -172,7 +172,7 @@ function updateConformButtonClassAndText() { @@ -172,7 +172,7 @@ function updateConformButtonClassAndText() {
172 if (2 === $chosed.closest('.zero-stock').length) { 172 if (2 === $chosed.closest('.zero-stock').length) {
173 $('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄'); 173 $('#chose-btn-sure').css('background-color', '#c0c0c0').html('已售罄');
174 } else if (limitProductCode) { 174 } else if (limitProductCode) {
175 - $('#chose-btn-sure').css('background-color', '#eb0313').html('结算'); 175 + $('#chose-btn-sure').css('background-color', '#eb0313').html('立即购买');
176 } else { 176 } else {
177 $('#chose-btn-sure').css('background-color', '#eb0313').html(isEdit ? '确认' : '加入购物车'); 177 $('#chose-btn-sure').css('background-color', '#eb0313').html(isEdit ? '确认' : '加入购物车');
178 } 178 }
@@ -473,8 +473,8 @@ $yohoPage.on('touchstart', '.btn-minus', function() { @@ -473,8 +473,8 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
473 } else if (limitProductCode) { 473 } else if (limitProductCode) {
474 474
475 // 当前面板选择的是限购商品 475 // 当前面板选择的是限购商品
476 - url = 'http://m.yohobuy.com/cart/index/orderEnsure?code=' + limitProductCode + '&&sku=' +  
477 - productSku + '&&skn=' + skn + '&&buy_num=' + buyNumber; 476 + url = $('#limitProductPay').val() + '?limitproductcode=' + limitProductCode + '&sku=' +
  477 + productSku + '&skn=' + skn + '&buy_number=' + buyNumber;
478 478
479 //打开结算页面,结束函数执行。 479 //打开结算页面,结束函数执行。
480 window.location.href = url; 480 window.location.href = url;
@@ -30,6 +30,26 @@ require('../common'); @@ -30,6 +30,26 @@ require('../common');
30 30
31 lazyLoad(); 31 lazyLoad();
32 32
  33 +function getQueryParam() {
  34 + var queryArray = location.search.substr(1).split('&'),
  35 + i,
  36 + subArr = [],
  37 + obj = {};
  38 +
  39 + for (i = 0; i < queryArray.length; i++) {
  40 + subArr = queryArray[i].split('=');
  41 + obj[subArr[0]] = subArr[1];
  42 + subArr = [];
  43 + }
  44 +
  45 + return obj;
  46 +}
  47 +
  48 +function isLimitGood() {
  49 + return getQueryParam().limitproductcode;
  50 +}
  51 +
  52 +
33 if (window.getUid() !== orderInfo('uid')) { 53 if (window.getUid() !== orderInfo('uid')) {
34 order.init(); 54 order.init();
35 window.location.reload(); 55 window.location.reload();
@@ -46,6 +66,18 @@ if (document.referrer && document.referrer.indexOf('/cart/index/index') !== -1) @@ -46,6 +66,18 @@ if (document.referrer && document.referrer.indexOf('/cart/index/index') !== -1)
46 orderInfo('couponName', null); 66 orderInfo('couponName', null);
47 } 67 }
48 68
  69 +isLimitGood() && (function() {
  70 + var a = [];
  71 +
  72 + var data = getQueryParam();
  73 +
  74 + data['type'] = 'limitcode';
  75 +
  76 + a.push(data);
  77 + orderInfo('skuList', JSON.stringify(a));
  78 + orderInfo('limitUrlSufix', location.search);
  79 +})();
  80 +
49 if (queryString.cartType || queryString.carttype || !orderInfo('cartType')) { 81 if (queryString.cartType || queryString.carttype || !orderInfo('cartType')) {
50 orderInfo('cartType', queryString.cartType || queryString.carttype || 'ordinary'); 82 orderInfo('cartType', queryString.cartType || queryString.carttype || 'ordinary');
51 } 83 }
@@ -102,7 +134,8 @@ function orderCompute() { @@ -102,7 +134,8 @@ function orderCompute() {
102 deliveryId: orderInfo('deliveryId'), 134 deliveryId: orderInfo('deliveryId'),
103 paymentTypeId: orderInfo('paymentTypeId'), 135 paymentTypeId: orderInfo('paymentTypeId'),
104 couponCode: orderInfo('couponCode'), 136 couponCode: orderInfo('couponCode'),
105 - yohoCoin: yohoCoin 137 + yohoCoin: yohoCoin,
  138 + skuList: isLimitGood() ? orderInfo('skuList') : undefined
106 } 139 }
107 }).then(function(res) { 140 }).then(function(res) {
108 var priceHtml; 141 var priceHtml;
@@ -177,7 +210,9 @@ function submitOrder() { @@ -177,7 +210,9 @@ function submitOrder() {
177 paymentTypeId: orderInfo('paymentTypeId'), 210 paymentTypeId: orderInfo('paymentTypeId'),
178 paymentType: orderInfo('paymentType'), //支付方式 211 paymentType: orderInfo('paymentType'), //支付方式
179 couponCode: orderInfo('couponCode'), 212 couponCode: orderInfo('couponCode'),
180 - yohoCoin: orderInfo('yohoCoin') 213 + yohoCoin: orderInfo('yohoCoin'),
  214 + skuList: isLimitGood() ? orderInfo('skuList') : undefined
  215 +
181 } 216 }
182 }).then(function(res) { 217 }).then(function(res) {
183 var url; 218 var url;
@@ -26,7 +26,7 @@ $('.address-item').on('touchend', function() { @@ -26,7 +26,7 @@ $('.address-item').on('touchend', function() {
26 orderInfo('addressId', addressId); 26 orderInfo('addressId', addressId);
27 orderInfo('address', address); 27 orderInfo('address', address);
28 28
29 - window.location.href = $this.data('href'); 29 + window.location.href = $this.data('href') + (orderInfo('limitUrlSufix') || '');
30 }).on('touchend', '.edit', function() { 30 }).on('touchend', '.edit', function() {
31 window.location.href = $(this).data('href'); 31 window.location.href = $(this).data('href');
32 return false; 32 return false;
@@ -68,7 +68,7 @@ $('#likeBtn').on('touchstart', function() { @@ -68,7 +68,7 @@ $('#likeBtn').on('touchstart', function() {
68 68
69 $('#addtoCart').on('touchstart', function() { 69 $('#addtoCart').on('touchstart', function() {
70 $('.cart-bar').hide(); 70 $('.cart-bar').hide();
71 - chosePanel.setLimitGoodModeWithSknId(productCode, skn); 71 + productCode && chosePanel.setLimitGoodModeWithSknId(productCode, skn);
72 chosePanel.show(); 72 chosePanel.show();
73 73
74 //统计代码:用于统计用户加入购物车的动作 74 //统计代码:用于统计用户加入购物车的动作
@@ -8,17 +8,15 @@ @@ -8,17 +8,15 @@
8 line-height: 2.2rem; 8 line-height: 2.2rem;
9 margin-bottom: 0.1rem; 9 margin-bottom: 0.1rem;
10 background-color: #fff; 10 background-color: #fff;
11 - padding: 0.2rem 0; 11 + padding: 0.2rem 0 0.2rem 0.5rem;
12 12
13 13
14 div { 14 div {
15 - width: 20%; 15 + width: 0%;
16 display: inline-block; 16 display: inline-block;
17 float: left; 17 float: left;
18 img { 18 img {
19 width: 1.5rem; 19 width: 1.5rem;
20 - border: 1px solid #ccc;  
21 - border-radius: 100%;  
22 position: relative; 20 position: relative;
23 top: 0.25rem; 21 top: 0.25rem;
24 } 22 }
@@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
43 <ul class="sale-invoice"> 43 <ul class="sale-invoice">
44 {{#if isOrdinaryCart}} 44 {{#if isOrdinaryCart}}
45 <li class="coupon"> 45 <li class="coupon">
46 - <a href="/cart/index/selectCoupon"> 46 + <a href="{{#if isLimit}}javascript:void(0);{{else}}/cart/index/selectCoupon{{/if}}">
47 <span class="title">优惠券</span> 47 <span class="title">优惠券</span>
48 {{# coupon}} 48 {{# coupon}}
49 <!--<span class="coupon-count"> 49 <!--<span class="coupon-count">
@@ -57,7 +57,7 @@ @@ -57,7 +57,7 @@
57 </span> 57 </span>
58 {{^}} 58 {{^}}
59 <span class="not-used coupon-use"> 59 <span class="not-used coupon-use">
60 - 未使用 60 + {{#if isLimit}}该商品不可使用优惠券{{else}}未使用{{/if}}
61 <i class="iconfont">&#xe614;</i> 61 <i class="iconfont">&#xe614;</i>
62 </span> 62 </span>
63 {{/if}} 63 {{/if}}
@@ -136,7 +136,7 @@ @@ -136,7 +136,7 @@
136 136
137 {{#if addToCartUrl}} 137 {{#if addToCartUrl}}
138 <!-- <a id="addtoCart" href="{{addToCartUrl}}" class="addto-cart">加入购物车</a> --> 138 <!-- <a id="addtoCart" href="{{addToCartUrl}}" class="addto-cart">加入购物车</a> -->
139 - <a id="addtoCart" href="javascript:;" class="addto-cart">加入购物车</a> 139 + <a id="addtoCart" href="javascript:;" class="addto-cart">加入购物车</a>
140 {{/if}} 140 {{/if}}
141 141
142 {{#if soldOut}} 142 {{#if soldOut}}
@@ -152,15 +152,16 @@ @@ -152,15 +152,16 @@
152 {{/if}} 152 {{/if}}
153 153
154 {{#if canBuyLimit}} 154 {{#if canBuyLimit}}
155 - <a href="javascript:;" class="addto-cart">立即购买</a> 155 + <a href="javascript:;" id="addtoCart" class="addto-cart">立即购买</a>
156 {{/if}} 156 {{/if}}
157 157
158 {{#if noLimitCode}} 158 {{#if noLimitCode}}
159 <a href="javascript:;" class="sold-out">立即购买</a> 159 <a href="javascript:;" class="sold-out">立即购买</a>
160 {{/if}} 160 {{/if}}
161 - <input type="hidden" name="limitCodeUrl" value="{{limitCodeUrl}}"> 161 + <input type="hidden" id="limitCodeUrl" name="limitCodeUrl" value="{{limitCodeUrl}}">
  162 + <input type="hidden" id="limitProductPay" name="limitProductPay" value="{{limitProductPay}}">
162 {{#limitProductCode}} 163 {{#limitProductCode}}
163 - <input type="hidden" name="limitProductCode" value="{{.}}"> 164 + <input type="hidden" id="limitProductCode" name="limitProductCode" value="{{.}}">
164 {{/limitProductCode}} 165 {{/limitProductCode}}
165 166
166 <a href="javascript:;" id="likeBtn" class="favorite iconfont {{#isCollect}}liked{{/isCollect}}">&#xe605;</a> 167 <a href="javascript:;" id="likeBtn" class="favorite iconfont {{#isCollect}}liked{{/isCollect}}">&#xe605;</a>
1 {{> layout/header}} 1 {{> layout/header}}
2 <div class="limit-good-page yoho-page"> 2 <div class="limit-good-page yoho-page">
3 <div class="top clearfix"> 3 <div class="top clearfix">
4 - <div>  
5 - <img src="{{profile}}" alt="">  
6 - </div>  
7 <p>我在Yoho!Buy有货发现了一个限定发售商品</p> 4 <p>我在Yoho!Buy有货发现了一个限定发售商品</p>
8 </div> 5 </div>
9 <div class="banner"> 6 <div class="banner">
10 - <a href="{{bannerSrc}}">  
11 - <img src="{{banner}}" alt="">  
12 - </a> 7 + <img src="{{banner}}" alt="">
13 </div> 8 </div>
14 <div class="detail clearfix"> 9 <div class="detail clearfix">
15 <p class="name">{{name}}</p> 10 <p class="name">{{name}}</p>
16 <div class="sale-info"> 11 <div class="sale-info">
17 - <span class="price">{{price}}</span> 12 + <span class="price">{{price}}</span>
18 <span class="date"> 13 <span class="date">
19 <span class="iconfont">&#xe603;</span> 14 <span class="iconfont">&#xe603;</span>
20 <span class="text">{{releaseDate}}</span> 15 <span class="text">{{releaseDate}}</span>
@@ -22,28 +17,24 @@ @@ -22,28 +17,24 @@
22 </div> 17 </div>
23 </div> 18 </div>
24 19
  20 + {{# attaches}}
25 <div class="goodDesc"> 21 <div class="goodDesc">
26 - {{#mainImg}}  
27 - <img class="lazy" src="{{mainImg}}" alt="">  
28 - {{/mainImg}}  
29 -  
30 - {{#goodDescription}}  
31 - <p class="desc">{{goodDescription}}</p>  
32 - {{/goodDescription}} 22 + {{#img}}
  23 + <img src="{{attachUrl}}" alt="{{attachName}}">
  24 + {{/img}}
33 25
34 - {{#imgList}}  
35 - <img class="lazy" src="{{img}}" alt="">  
36 - {{/imgList}} 26 + {{#text}}
  27 + <p class="desc">{{intro}}</p>
  28 + {{/text}}
37 29
38 - {{#vedio}} 30 + {{#video}}
39 <video poster="{{img}}" controls="controls" controls="controls" preload="metadata" loop="loop" width="100%" name="media"> 31 <video poster="{{img}}" controls="controls" controls="controls" preload="metadata" loop="loop" width="100%" name="media">
40 - {{#list}}  
41 - <source src="{{src}}" type="video/ogg;codecs=" theora,vorbis"" media="screen" />  
42 - <source src="{{src}}"/>  
43 - {{/list}} 32 + <source src="{{attachUrl}}" type="video/ogg;codecs=" theora,vorbis"" media="screen" />
  33 + <source src="{{attachUrl}}"/>
44 </video> 34 </video>
45 - {{/vedio}} 35 + {{/video}}
46 </div> 36 </div>
  37 + {{/attaches}}
47 38
48 <div class="bottom"> 39 <div class="bottom">
49 <div class="logo"></div> 40 <div class="logo"></div>
@@ -325,7 +325,8 @@ class CartModel @@ -325,7 +325,8 @@ class CartModel
325 $result = array(); 325 $result = array();
326 326
327 $skuList = ''; 327 $skuList = '';
328 - if (!empty($sku) && !empty($skn) && !empty($buyNumber)) { // 存在sku,skn和buyNumber时 328 + $isLimitGoods = !empty($sku) && !empty($skn) && !empty($buyNumber);
  329 + if ($isLimitGoods) { // 存在sku,skn和buyNumber时为限购商品
329 $skuList = json_encode(array( 330 $skuList = json_encode(array(
330 array( 331 array(
331 'type' => 'limitcode', 332 'type' => 'limitcode',
@@ -335,17 +336,22 @@ class CartModel @@ -335,17 +336,22 @@ class CartModel
335 'buy_number' => $buyNumber 336 'buy_number' => $buyNumber
336 ) 337 )
337 )); 338 ));
  339 + $result['isLimit'] = true;
338 } 340 }
339 341
340 $pay = CartData::cartPay($uid, $cartType, 0, $skuList); 342 $pay = CartData::cartPay($uid, $cartType, 0, $skuList);
341 343
342 - // 商品为空返回  
343 - if (!$pay || empty($pay['data']['goods_list'])) {  
344 - $result['cartUrl'] = Helpers::url('/cart/index/index');  
345 - return $result;  
346 - } 344 + do {
  345 + if (!$pay || $pay['code'] != 200 || empty($pay['data']['goods_list'])) {
  346 + if ($isLimitGoods) {
  347 + $result['error'] = true;
  348 + } else {
  349 + $result['cartUrl'] = Helpers::url('/cart/index/index');
  350 + }
  351 +
  352 + break;
  353 + }
347 354
348 - if ($pay && isset($pay['code']) && $pay['code'] === 200) {  
349 $payReturn = $pay['data']; 355 $payReturn = $pay['data'];
350 $address = array(); 356 $address = array();
351 $orderCompute = array(); 357 $orderCompute = array();
@@ -506,7 +512,8 @@ class CartModel @@ -506,7 +512,8 @@ class CartModel
506 $coupons['couponName'] = $orderInfo['couponName']; 512 $coupons['couponName'] = $orderInfo['couponName'];
507 } 513 }
508 $result['coupon'] = $coupons; 514 $result['coupon'] = $coupons;
509 - } 515 +
  516 + } while (false);
510 517
511 return $result; 518 return $result;
512 } 519 }
@@ -44,6 +44,15 @@ class DetailModel @@ -44,6 +44,15 @@ class DetailModel
44 if (empty($baseInfo['productName'])) { 44 if (empty($baseInfo['productName'])) {
45 return $result; 45 return $result;
46 } 46 }
  47 +
  48 + // 是否为限购商品
  49 + $isLimited = ($baseInfo['isLimitBuy'] === 'Y');
  50 + // 如果未登录并且为限购商品,就跳转到登录页
  51 + if (empty($uid) && $isLimited) {
  52 + $result['needLogin'] = true;
  53 + return $result;
  54 + }
  55 +
47 $result['goodsName'] = $baseInfo['productName']; 56 $result['goodsName'] = $baseInfo['productName'];
48 57
49 // 商品促销短语 58 // 商品促销短语
@@ -290,16 +299,10 @@ class DetailModel @@ -290,16 +299,10 @@ class DetailModel
290 $soldOut = ($baseInfo['storage'] == 0) || ($baseInfo['status'] == 0 || $totalStorageNum === 0); 299 $soldOut = ($baseInfo['storage'] == 0) || ($baseInfo['status'] == 0 || $totalStorageNum === 0);
291 $notForSale = $baseInfo['attribute'] == 2; 300 $notForSale = $baseInfo['attribute'] == 2;
292 301
293 - // 是否为限购商品  
294 - $isLimited = ($baseInfo['isLimitBuy'] === 'Y');  
295 -  
296 -  
297 -  
298 // 显示加入购物车链接 302 // 显示加入购物车链接
299 - if (!$soldOut && !$notForSale && !$isLimited) { 303 + if (!$soldOut && !$notForSale) {
300 ksort($colorGroup, SORT_NUMERIC); 304 ksort($colorGroup, SORT_NUMERIC);
301 -  
302 - $result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html'); 305 +
303 $result['cartInfo']['productId'] = $productId; 306 $result['cartInfo']['productId'] = $productId;
304 $result['cartInfo']['thumbs'] = $thumbImageList; 307 $result['cartInfo']['thumbs'] = $thumbImageList;
305 $result['cartInfo']['name'] = isset($result['goodsName']) ? $result['goodsName'] : ''; 308 $result['cartInfo']['name'] = isset($result['goodsName']) ? $result['goodsName'] : '';
@@ -308,6 +311,26 @@ class DetailModel @@ -308,6 +311,26 @@ class DetailModel
308 $result['cartInfo']['totalNum'] = $totalStorageNum; 311 $result['cartInfo']['totalNum'] = $totalStorageNum;
309 $result['cartInfo']['colors'] = $colorGroup; 312 $result['cartInfo']['colors'] = $colorGroup;
310 $result['cartInfo']['sizes'] = $sizeGroup; 313 $result['cartInfo']['sizes'] = $sizeGroup;
  314 +
  315 + // 限购商品
  316 + if ($isLimited) {
  317 + // 是否开售
  318 + $isBeginSale = (isset($baseInfo['saleStatus']) && $baseInfo['saleStatus'] == 1);
  319 + // 限购商品有关的展示状态
  320 + $showStatus = 1;
  321 + if (isset($baseInfo['showStatus'])) {
  322 + $showStatus = intval($baseInfo['showStatus']);
  323 + }
  324 +
  325 + // 处理限购商品有关的按钮状态
  326 + self::procShowStatus($result, $showStatus, $isBeginSale);
  327 +
  328 + $result['cartInfo']['limitProductCode'] = $baseInfo['limitProductCode'];
  329 + $result['cartInfo']['limitCodeUrl'] = self::getLimitCodeUrl($baseInfo['erpProductId']);
  330 + $result['cartInfo']['limitProductPay'] = Helpers::url('/cart/index/orderEnsure');
  331 + } else {
  332 + $result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html');
  333 + }
311 } 334 }
312 // 非卖品 335 // 非卖品
313 elseif ($notForSale) { 336 elseif ($notForSale) {
@@ -317,22 +340,6 @@ class DetailModel @@ -317,22 +340,6 @@ class DetailModel
317 elseif ($soldOut) { 340 elseif ($soldOut) {
318 $result['cartInfo']['soldOut'] = true; 341 $result['cartInfo']['soldOut'] = true;
319 } 342 }
320 - // 限购商品  
321 - elseif ($isLimited) {  
322 - // 是否开售  
323 - $isBeginSale = (isset($baseInfo['saleStatus']) && $baseInfo['saleStatus'] == 1);  
324 - // 限购商品有关的展示状态  
325 - $showStatus = 1;  
326 - if (isset($baseInfo['showStatus'])) {  
327 - $showStatus = intval($baseInfo['showStatus']);  
328 - }  
329 -  
330 - // 处理限购商品有关的按钮状态  
331 - self::procShowStatus($result, $showStatus, $isBeginSale);  
332 -  
333 - $result['cartInfo']['limitProductCode'] = $baseInfo['limitProductCode'];  
334 - $result['cartInfo']['limitCodeUrl'] = 'yohobuy://' . Helpers::url('/product', array('skn' => $baseInfo['erpProductId']));  
335 - }  
336 343
337 // 是否收藏 344 // 是否收藏
338 $result['isCollect'] = false; 345 $result['isCollect'] = false;
@@ -717,6 +724,8 @@ class DetailModel @@ -717,6 +724,8 @@ class DetailModel
717 * 获取为你优选的商品 724 * 获取为你优选的商品
718 * 725 *
719 * @param int $productSkn 商品SKN 726 * @param int $productSkn 商品SKN
  727 + * @param int $channel
  728 + * @param int $brandId
720 * @return array 729 * @return array
721 */ 730 */
722 public static function getPreference($productSkn, $channel, $brandId) 731 public static function getPreference($productSkn, $channel, $brandId)
@@ -738,6 +747,88 @@ class DetailModel @@ -738,6 +747,88 @@ class DetailModel
738 return $result; 747 return $result;
739 } 748 }
740 749
  750 +
  751 + /**
  752 + * 获取限购商品详情
  753 + *
  754 + * @param int $uid 用户UID
  755 + * @param string $productCode
  756 + * @return array
  757 + */
  758 + public static function getLimitProductData($uid, $productCode)
  759 + {
  760 + $result = array();
  761 +
  762 + do {
  763 + $productData = DetailData::limitProductData($uid, $productCode);
  764 +
  765 + if (empty($productData) || empty($productData['data'])) {
  766 + break;
  767 + }
  768 + $product = $productData['data'];
  769 +
  770 + $result['price'] = $product['price'];
  771 + $result['name'] = $product['productName'];
  772 + // 发售日期
  773 + $result['releaseDate'] = $product['saleTime'] . '发售';
  774 + // baner
  775 + $result['banner'] = $product['defaultUrl'];
  776 + $result['description'] = $product['description'];
  777 +
  778 + // 附件
  779 + if (isset($product['attachment'])) {
  780 + foreach ($product['attachment'] as $item) {
  781 + $result['attaches'][] = self::procLimitProductAttach($item);
  782 + }
  783 + }
  784 +
  785 + } while (false);
  786 +
  787 + return $result;
  788 + }
  789 +
  790 + /**
  791 + * 处理限购商品附件数据
  792 + *
  793 + * @param array $attachment 附件数据
  794 + * @return array
  795 + */
  796 + private static function procLimitProductAttach($attachment)
  797 + {
  798 + $result = array();
  799 +
  800 + switch(intval($attachment['attachType'])) {
  801 + case 1: // 大图文字
  802 + $result['img'] = array(
  803 + 'attachUrl' => $attachment['attachUrl'],
  804 + 'attachName' => $attachment['attachName'],
  805 + 'intro' => $attachment['intro'],
  806 + 'orderBy' => $attachment['orderBy']
  807 + );
  808 + break;
  809 + case 2: // 视频
  810 + $result['video'] = array(
  811 + 'attachUrl' => $attachment['attachUrl'],
  812 + 'orderBy' => $attachment['orderBy']
  813 + );
  814 + break;
  815 + case 3: // 文本类型
  816 + $result['text'] = array(
  817 + 'intro' => $attachment['intro'],
  818 + 'orderBy' => $attachment['orderBy']
  819 + );
  820 + break;
  821 + default:
  822 + break;
  823 + }
  824 +
  825 + if(count($result) > 1) {
  826 + Helpers::sortArrByField($result, 'orderBy');
  827 + }
  828 +
  829 + return $result;
  830 + }
  831 +
741 /** 832 /**
742 * 处理限购商品的有关按钮状态(或取现购买以及底部商品购买按钮) 833 * 处理限购商品的有关按钮状态(或取现购买以及底部商品购买按钮)
743 * 834 *
@@ -783,4 +874,22 @@ class DetailModel @@ -783,4 +874,22 @@ class DetailModel
783 } 874 }
784 } 875 }
785 876
  877 + /**
  878 + * 根据设备类型获得限购商品跳转app的url
  879 + *
  880 + * @param string $skn 商品skn
  881 + * @return string 限购商品跳转url
  882 + */
  883 + private static function getLimitCodeUrl($skn)
  884 + {
  885 + $url = 'yohoapp://yoho.app/openwith?product_skn=' . $skn;
  886 +
  887 + // 苹果设备或者苹果IPAD
  888 + if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
  889 + $url = 'yohobuy://' . Helpers::url('/product', array('skn' => $skn));
  890 + }
  891 +
  892 + return $url;
  893 + }
  894 +
786 } 895 }
@@ -295,17 +295,20 @@ class IndexController extends AbstractAction @@ -295,17 +295,20 @@ class IndexController extends AbstractAction
295 } 295 }
296 296
297 // 如果传递了code, sku,skn,buy_number就代表是限购商品 297 // 如果传递了code, sku,skn,buy_number就代表是限购商品
298 - $limitProductCode = $this->get('code', ''); 298 + $limitProductCode = $this->get('limitproductcode', '');
299 $sku = $this->get('sku', ''); 299 $sku = $this->get('sku', '');
300 $skn = $this->get('skn', ''); 300 $skn = $this->get('skn', '');
301 - $buyNumber = $this->get('buy_number', ''); 301 + $buyNumber = $this->get('buy_number', 1);
302 302
303 // 购物车商品为空跳转到购物车页面 303 // 购物车商品为空跳转到购物车页面
304 $uid = $this->getUid(true); 304 $uid = $this->getUid(true);
305 $order = CartModel::cartPay($uid, $cartType, $orderInfo, $limitProductCode, $sku, $skn, $buyNumber); 305 $order = CartModel::cartPay($uid, $cartType, $orderInfo, $limitProductCode, $sku, $skn, $buyNumber);
306 - if (isset($order['cartUrl'])) { 306 + if (isset($order['cartUrl'])) { // 普通或者预售商品为空时
307 $this->go($order['cartUrl']); 307 $this->go($order['cartUrl']);
308 } 308 }
  309 + if (isset($order['error'])) { // 限购商品支付接口返回为空或错误时
  310 + $this->error();
  311 + }
309 312
310 $data = array( 313 $data = array(
311 'orderEnsurePage' => true, 314 'orderEnsurePage' => true,
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 use Action\AbstractAction; 3 use Action\AbstractAction;
4 use Plugin\Helpers; 4 use Plugin\Helpers;
5 use LibModels\Wap\Product\DetailData; 5 use LibModels\Wap\Product\DetailData;
  6 +use Product\DetailModel;
6 7
7 /** 8 /**
8 * 商品详情的控制器 9 * 商品详情的控制器
@@ -33,10 +34,16 @@ class DetailController extends AbstractAction @@ -33,10 +34,16 @@ class DetailController extends AbstractAction
33 $vipLevel = Helpers::getVipLevel($this->_vip); 34 $vipLevel = Helpers::getVipLevel($this->_vip);
34 } 35 }
35 36
36 - $data = \Product\DetailModel::getBaseInfo($productId, $goodsId, $uid, $vipLevel); 37 + $data = DetailModel::getBaseInfo($productId, $goodsId, $uid, $vipLevel);
37 if (array() === $data) { 38 if (array() === $data) {
38 $this->error(); 39 $this->error();
39 } 40 }
  41 +
  42 + // 如果为限购商品且没有登录就跳转到登陆页
  43 + if (isset($data['needLogin'])) {
  44 + $this->go(Helpers::url('/signin.html', array('refer' => Helpers::url($this->server('REQUEST_URI')))));
  45 + }
  46 +
40 $data['goodsDetailPage'] = true; 47 $data['goodsDetailPage'] = true;
41 $data['pageFooter'] = true; 48 $data['pageFooter'] = true;
42 49
@@ -66,7 +73,7 @@ class DetailController extends AbstractAction @@ -66,7 +73,7 @@ class DetailController extends AbstractAction
66 $vipLevel = Helpers::getVipLevel($this->_vip); 73 $vipLevel = Helpers::getVipLevel($this->_vip);
67 } 74 }
68 75
69 - $data = \Product\DetailModel::getBaseInfo(null, null, $uid, $vipLevel, $productSkn); 76 + $data = DetailModel::getBaseInfo(null, null, $uid, $vipLevel, $productSkn);
70 if (array() === $data) { 77 if (array() === $data) {
71 $this->error(); 78 $this->error();
72 } 79 }
@@ -94,7 +101,7 @@ class DetailController extends AbstractAction @@ -94,7 +101,7 @@ class DetailController extends AbstractAction
94 // 加入uid和udid参数,为了实现记录浏览记录的功能 101 // 加入uid和udid参数,为了实现记录浏览记录的功能
95 $uid = $this->getUid(); 102 $uid = $this->getUid();
96 $udid = $this->getUdid(); 103 $udid = $this->getUdid();
97 - $data = \Product\DetailModel::getSizeInfo($productSkn, $uid, $udid); 104 + $data = DetailModel::getSizeInfo($productSkn, $uid, $udid);
98 if (array() === $data) { 105 if (array() === $data) {
99 echo ' '; 106 echo ' ';
100 exit(); 107 exit();
@@ -126,7 +133,7 @@ class DetailController extends AbstractAction @@ -126,7 +133,7 @@ class DetailController extends AbstractAction
126 'goodsCommentsPage' => true, 133 'goodsCommentsPage' => true,
127 'pageFooter' => true, 134 'pageFooter' => true,
128 'comments' => array( 135 'comments' => array(
129 - 'list' => \Product\DetailModel::getComments($productId), 136 + 'list' => DetailModel::getComments($productId),
130 ), 137 ),
131 ); 138 );
132 139
@@ -155,14 +162,14 @@ class DetailController extends AbstractAction @@ -155,14 +162,14 @@ class DetailController extends AbstractAction
155 $this->setTitle('购买咨询'); 162 $this->setTitle('购买咨询');
156 163
157 $uid = $this->getUid(); 164 $uid = $this->getUid();
158 - $consults = \Product\DetailModel::getConsults($uid, $productId); 165 + $consults = DetailModel::getConsults($uid, $productId);
159 $data = array( 166 $data = array(
160 'goodsConsultsPage' => true, 167 'goodsConsultsPage' => true,
161 'pageFooter' => true, 168 'pageFooter' => true,
162 'consults' => array( 169 'consults' => array(
163 'list' => $consults 170 'list' => $consults
164 ), 171 ),
165 - 'faq' => \Product\DetailModel::getCommonConsults(), 172 + 'faq' => DetailModel::getCommonConsults(),
166 'showReadMore' => count($consults) > 2, 173 'showReadMore' => count($consults) > 2,
167 'link' => Helpers::url('/product/detail/consultform', array('product_id' => $productId)), 174 'link' => Helpers::url('/product/detail/consultform', array('product_id' => $productId)),
168 ); 175 );
@@ -184,7 +191,7 @@ class DetailController extends AbstractAction @@ -184,7 +191,7 @@ class DetailController extends AbstractAction
184 $total = $this->post('total', 0); 191 $total = $this->post('total', 0);
185 $uid = $this->getUid(); 192 $uid = $this->getUid();
186 $id = $this->post('id'); 193 $id = $this->post('id');
187 - $result = \Product\DetailModel::upvoteConsult($uid, $id, $productId, $total); 194 + $result = DetailModel::upvoteConsult($uid, $id, $productId, $total);
188 } 195 }
189 196
190 $this->echoJson($result); 197 $this->echoJson($result);
@@ -202,7 +209,7 @@ class DetailController extends AbstractAction @@ -202,7 +209,7 @@ class DetailController extends AbstractAction
202 $total = $this->post('total', 0); 209 $total = $this->post('total', 0);
203 $uid = $this->getUid(); 210 $uid = $this->getUid();
204 $id = $this->post('id'); 211 $id = $this->post('id');
205 - $result = \Product\DetailModel::usefulConsult($uid, $id, $productId, $total); 212 + $result = DetailModel::usefulConsult($uid, $id, $productId, $total);
206 } 213 }
207 214
208 $this->echoJson($result); 215 $this->echoJson($result);
@@ -266,7 +273,7 @@ class DetailController extends AbstractAction @@ -266,7 +273,7 @@ class DetailController extends AbstractAction
266 $productSkn = $this->get('productSkn'); 273 $productSkn = $this->get('productSkn');
267 $brandId = $this->get('brandId'); 274 $brandId = $this->get('brandId');
268 $channel = Helpers::getChannelByCookie(); 275 $channel = Helpers::getChannelByCookie();
269 - $result = \Product\DetailModel::getPreference($productSkn, $channel, $brandId); 276 + $result = DetailModel::getPreference($productSkn, $channel, $brandId);
270 } 277 }
271 278
272 if (empty($result)) { 279 if (empty($result)) {
@@ -276,4 +283,35 @@ class DetailController extends AbstractAction @@ -276,4 +283,35 @@ class DetailController extends AbstractAction
276 } 283 }
277 } 284 }
278 285
  286 + /**
  287 + * 限购商品说明页面
  288 + */
  289 + public function limitHelpAction()
  290 + {
  291 + $data = array();
  292 + $this->_view->display('limit-help', $data);
  293 + }
  294 +
  295 + /**
  296 + * 限购商品详情页
  297 + */
  298 + public function limitAction()
  299 + {
  300 + $productCode = $this->get('code', '');
  301 + if (empty($productCode)) {
  302 + $this->error();
  303 + }
  304 +
  305 + $uid = $this->getUid();
  306 + $data = DetailModel::getLimitProductData($uid, $productCode);
  307 + if (empty($data)) {
  308 + $this->error();
  309 + }
  310 +
  311 + // APP下载链接地址
  312 + $data['appSrc'] = 'http://a.app.qq.com/o/simple.jsp?pkgname=com.yoho';
  313 +
  314 + $this->_view->display('limit', $data);
  315 + }
  316 +
279 } 317 }
@@ -228,54 +228,4 @@ class IndexController extends AbstractAction @@ -228,54 +228,4 @@ class IndexController extends AbstractAction
228 228
229 $this->_view->display('index', $data); 229 $this->_view->display('index', $data);
230 } 230 }
231 -  
232 - public function limitHelpAction()  
233 - {  
234 - $data = array();  
235 - $this->_view->display('limit-help', $data);  
236 - }  
237 -  
238 - public function limitAction()  
239 - {  
240 - $data = array(  
241 - 'profile' => 'http://cdn.yoho.cn/myohobuy/assets/img/me/index/user-avatar.png?1455719653',  
242 - 'banner' => 'http://img11.static.yhbimg.com/yhb-img01/2016/02/25/02/016ed5a17fb9d9bc7542174c22dccb4acf.jpg?imageView/2/w/640/h/240',  
243 - 'bannerSrc' => './',  
244 - 'name' => '潮流尖端商品啊啊啊啊',  
245 - 'price' => '1999',  
246 - 'releaseDate' => '2016年12月发售',  
247 - 'appSrc' => './',  
248 - 'mainImg' => 'http://img11.static.yhbimg.com/yhb-img01/2016/02/25/02/016ed5a17fb9d9bc7542174c22dccb4acf.jpg?imageView/2/w/640/h/240',  
249 - 'goodDescription' => '独独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤独家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤家发售快乐的肌肤立刻就是大老骥伏枥开始的肌肤',  
250 - 'imgList' => array(  
251 - array(  
252 - 'img' => 'http://img11.static.yhbimg.com/yhb-img01/2016/02/25/02/016ed5a17fb9d9bc7542174c22dccb4acf.jpg?imageView/2/w/640/h/240'  
253 - ),  
254 - array(  
255 - 'img' => 'http://img11.static.yhbimg.com/yhb-img01/2016/02/25/02/016ed5a17fb9d9bc7542174c22dccb4acf.jpg?imageView/2/w/640/h/240'  
256 - ),  
257 - array(  
258 - 'img' => 'http://img11.static.yhbimg.com/yhb-img01/2016/02/25/02/016ed5a17fb9d9bc7542174c22dccb4acf.jpg?imageView/2/w/640/h/240'  
259 - )  
260 - ),  
261 - 'vedio' => array(  
262 - 'img' => './',  
263 - 'list' => array(  
264 - array(  
265 - 'src' => 'http://video.yohoboys.com/xuanchuan/wuyifan_mobile.mp4'  
266 - ),  
267 - array(  
268 - 'src' => 'http://video.yohoboys.com/xuanchuan/wuyifan_mobile.webm'  
269 - ),  
270 - array(  
271 - 'src' => 'http://video.yohoboys.com/xuanchuan/wuyifan_mobile.ogv'  
272 - )  
273 - )  
274 - )  
275 - );  
276 -  
277 -  
278 -  
279 - $this->_view->display('limit', $data);  
280 - }  
281 } 231 }