Toggle navigation
Toggle navigation
This project
Loading...
Sign in
wangshusheng
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to dashboard
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
Rock Zhang
9 years ago
Commit
38f3f30d2e153cf625225743ebdf9dcc407abad6
1 parent
eaf0e380
修复限购商品详情页的一些逻辑
Code Review By Rock Zhang
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
25 deletions
template/m.yohobuy.com/actions/product/detail/index.phtml
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
yohobuy/m.yohobuy.com/application/models/Product/Detail.php
yohobuy/m.yohobuy.com/application/modules/Cart/controllers/Index.php
yohobuy/m.yohobuy.com/application/modules/Product/controllers/Detail.php
template/m.yohobuy.com/actions/product/detail/index.phtml
View file @
38f3f30
...
...
@@ -136,7 +136,7 @@
{
{#if
addToCartUrl
}
}
<!--
<a
id=
"addtoCart"
href=
"{{addToCartUrl}}"
class=
"addto-cart"
>加入购物车</a>
-->
<a
id=
"addtoCart"
href=
"javascript:;"
class=
"addto-cart"
>加入购物车</a>
<a
id=
"addtoCart"
href=
"javascript:;"
class=
"addto-cart"
>加入购物车</a>
{
{/if
}
}
{
{#if
soldOut
}
}
...
...
@@ -152,7 +152,7 @@
{
{/if
}
}
{
{#if
canBuyLimit
}
}
<a
href=
"javascript:;"
class=
"addto-cart"
>立即购买</a>
<a
href=
"javascript:;"
id=
"addtoCart"
class=
"addto-cart"
>立即购买</a>
{
{/if
}
}
{
{#if
noLimitCode
}
}
...
...
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
View file @
38f3f30
...
...
@@ -325,7 +325,8 @@ class CartModel
$result
=
array
();
$skuList
=
''
;
if
(
!
empty
(
$sku
)
&&
!
empty
(
$skn
)
&&
!
empty
(
$buyNumber
))
{
// 存在sku,skn和buyNumber时
$isLimitGoods
=
!
empty
(
$sku
)
&&
!
empty
(
$skn
)
&&
!
empty
(
$buyNumber
);
if
(
$isLimitGoods
)
{
// 存在sku,skn和buyNumber时为限购商品
$skuList
=
json_encode
(
array
(
array
(
'type'
=>
'limitcode'
,
...
...
@@ -339,7 +340,18 @@ class CartModel
$pay
=
CartData
::
cartPay
(
$uid
,
$cartType
,
0
,
$skuList
);
// 商品为空返回
// 限购商品结算接口返回逻辑判定
if
(
$isLimitGoods
)
{
if
(
!
$pay
)
{
$result
[
'needReload'
]
=
true
;
}
elseif
(
isset
(
$pay
[
'code'
])
&&
$pay
[
'code'
]
!=
200
)
{
$result
[
'error'
]
=
true
;
}
return
$result
;
}
// 普通或者预售商品为空返回
if
(
!
$pay
||
empty
(
$pay
[
'data'
][
'goods_list'
]))
{
$result
[
'cartUrl'
]
=
Helpers
::
url
(
'/cart/index/index'
);
return
$result
;
...
...
yohobuy/m.yohobuy.com/application/models/Product/Detail.php
View file @
38f3f30
...
...
@@ -300,10 +300,9 @@ class DetailModel
$notForSale
=
$baseInfo
[
'attribute'
]
==
2
;
// 显示加入购物车链接
if
(
!
$soldOut
&&
!
$notForSale
&&
!
$isLimited
)
{
if
(
!
$soldOut
&&
!
$notForSale
)
{
ksort
(
$colorGroup
,
SORT_NUMERIC
);
$result
[
'cartInfo'
][
'addToCartUrl'
]
=
Helpers
::
url
(
'/product/buy_'
.
$productId
.
'_'
.
$goodsId
.
'.html'
);
$result
[
'cartInfo'
][
'productId'
]
=
$productId
;
$result
[
'cartInfo'
][
'thumbs'
]
=
$thumbImageList
;
$result
[
'cartInfo'
][
'name'
]
=
isset
(
$result
[
'goodsName'
])
?
$result
[
'goodsName'
]
:
''
;
...
...
@@ -312,6 +311,25 @@ class DetailModel
$result
[
'cartInfo'
][
'totalNum'
]
=
$totalStorageNum
;
$result
[
'cartInfo'
][
'colors'
]
=
$colorGroup
;
$result
[
'cartInfo'
][
'sizes'
]
=
$sizeGroup
;
// 限购商品
if
(
$isLimited
)
{
// 是否开售
$isBeginSale
=
(
isset
(
$baseInfo
[
'saleStatus'
])
&&
$baseInfo
[
'saleStatus'
]
==
1
);
// 限购商品有关的展示状态
$showStatus
=
1
;
if
(
isset
(
$baseInfo
[
'showStatus'
]))
{
$showStatus
=
intval
(
$baseInfo
[
'showStatus'
]);
}
// 处理限购商品有关的按钮状态
self
::
procShowStatus
(
$result
,
$showStatus
,
$isBeginSale
);
$result
[
'cartInfo'
][
'limitProductCode'
]
=
$baseInfo
[
'limitProductCode'
];
$result
[
'cartInfo'
][
'limitCodeUrl'
]
=
self
::
getLimitCodeUrl
(
$baseInfo
[
'erpProductId'
]);
}
else
{
$result
[
'cartInfo'
][
'addToCartUrl'
]
=
Helpers
::
url
(
'/product/buy_'
.
$productId
.
'_'
.
$goodsId
.
'.html'
);
}
}
// 非卖品
elseif
(
$notForSale
)
{
...
...
@@ -321,22 +339,6 @@ class DetailModel
elseif
(
$soldOut
)
{
$result
[
'cartInfo'
][
'soldOut'
]
=
true
;
}
// 限购商品
elseif
(
$isLimited
)
{
// 是否开售
$isBeginSale
=
(
isset
(
$baseInfo
[
'saleStatus'
])
&&
$baseInfo
[
'saleStatus'
]
==
1
);
// 限购商品有关的展示状态
$showStatus
=
1
;
if
(
isset
(
$baseInfo
[
'showStatus'
]))
{
$showStatus
=
intval
(
$baseInfo
[
'showStatus'
]);
}
// 处理限购商品有关的按钮状态
self
::
procShowStatus
(
$result
,
$showStatus
,
$isBeginSale
);
$result
[
'cartInfo'
][
'limitProductCode'
]
=
$baseInfo
[
'limitProductCode'
];
$result
[
'cartInfo'
][
'limitCodeUrl'
]
=
self
::
getLimitCodeUrl
(
$baseInfo
[
'erpProductId'
]);
}
// 是否收藏
$result
[
'isCollect'
]
=
false
;
...
...
yohobuy/m.yohobuy.com/application/modules/Cart/controllers/Index.php
View file @
38f3f30
...
...
@@ -303,9 +303,15 @@ class IndexController extends AbstractAction
// 购物车商品为空跳转到购物车页面
$uid
=
$this
->
getUid
(
true
);
$order
=
CartModel
::
cartPay
(
$uid
,
$cartType
,
$orderInfo
,
$limitProductCode
,
$sku
,
$skn
,
$buyNumber
);
if
(
isset
(
$order
[
'cartUrl'
]))
{
if
(
isset
(
$order
[
'cartUrl'
]))
{
// 普通或者预售商品为空时
$this
->
go
(
$order
[
'cartUrl'
]);
}
if
(
isset
(
$order
[
'needReload'
]))
{
// 限购商品支付接口返回为空时
$this
->
go
(
Helpers
::
url
(
$this
->
server
(
'REQUEST_URI'
)));
}
if
(
isset
(
$order
[
'error'
]))
{
// 限购商品支付接口返回为错误时
$this
->
error
();
}
$data
=
array
(
'orderEnsurePage'
=>
true
,
...
...
yohobuy/m.yohobuy.com/application/modules/Product/controllers/Detail.php
View file @
38f3f30
...
...
@@ -334,7 +334,7 @@ class DetailController extends AbstractAction
)
);*/
$productCode
=
$this
->
get
(
'code'
,
'
2016030711453248
'
);
$productCode
=
$this
->
get
(
'code'
,
''
);
$uid
=
$this
->
getUid
();
$data
=
DetailModel
::
getLimitProductData
(
$uid
,
$productCode
);
...
...
Please
register
or
login
to post a comment