Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYWAP
·
Commits
Go to a project
GitLab
Go to group
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
84d251861a894fea0fadc3fafc17e166d28c4220
1 parent
63442ee1
添加增减购物车商品数量的接口
Code Review By Rock Zhang
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
0 deletions
library/LibModels/Wap/Home/CartData.php
yohobuy/m.yohobuy.com/application/controllers/ShoppingCart.php
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
library/LibModels/Wap/Home/CartData.php
View file @
84d2518
...
...
@@ -179,6 +179,41 @@ class CartData
}
/**
* 增减购物车商品数量
*
* @param int $uid 用户ID
* @param string $sku 商品SKU
* @param int $increaseNum 增加的数目
* @param int $decreaseNum 减少的数目
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public
static
function
modifyProductNum
(
$uid
,
$sku
,
$increaseNum
,
$decreaseNum
,
$shoppingKey
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.Shopping.increase'
;
$param
[
'product_sku'
]
=
$sku
;
if
(
!
empty
(
$increaseNum
))
{
$param
[
'increase_number'
]
=
$increaseNum
;
}
if
(
!
empty
(
$decreaseNum
))
{
$param
[
'decrease_number'
]
=
$decreaseNum
;
}
if
(
!
empty
(
$uid
))
{
$param
[
'uid'
]
=
$uid
;
}
if
(
$shoppingKey
!==
null
)
{
$param
[
'shopping_key'
]
=
$shoppingKey
;
}
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
...
...
yohobuy/m.yohobuy.com/application/controllers/ShoppingCart.php
View file @
84d2518
...
...
@@ -205,6 +205,30 @@ class ShoppingcartController extends AbstractAction
}
/**
* 修改购物车商品数量
*/
public
function
modifyNumAction
()
{
$result
=
array
();
if
(
$this
->
isAjax
())
{
$shoppingKey
=
$this
->
getSession
(
'shoppingKey'
);
$uid
=
$this
->
getUid
(
true
);
$sku
=
$this
->
post
(
'sku'
,
0
);
$increaseNum
=
$this
->
post
(
'increaseNum'
,
null
);
$decreaseNum
=
$this
->
post
(
'decreaseNum'
,
null
);
$result
=
CartModel
::
modifyProductNum
(
$uid
,
$sku
,
$increaseNum
,
$decreaseNum
,
$shoppingKey
);
}
if
(
empty
(
$result
))
{
echo
' '
;
}
else
{
$this
->
echoJson
(
$result
);
}
}
/**
* 修改购物车商品数据
*/
public
function
modifyAction
()
...
...
yohobuy/m.yohobuy.com/application/models/Index/Cart.php
View file @
84d2518
...
...
@@ -298,6 +298,29 @@ class CartModel
}
/**
* 修改购物车商品数量
*
* @param int $uid 用户ID
* @param string $sku 商品SKU
* @param int $increaseNum 增加的数目
* @param int $decreaseNum 减少的数目
* @param string $shoppingKey 未登录用户唯一识别码
* @return array 接口返回的数据
*/
public
static
function
modifyProductNum
(
$uid
,
$sku
,
$increaseNum
,
$decreaseNum
,
$shoppingKey
)
{
$result
=
array
(
'code'
=>
400
,
'message'
=>
'出错啦~'
);
$modify
=
CartData
::
modifyProductNum
(
$uid
,
$sku
,
$increaseNum
,
$decreaseNum
,
$shoppingKey
);
if
(
$modify
&&
isset
(
$modify
[
'code'
]))
{
$result
[
'code'
]
=
$modify
[
'code'
];
$result
[
'message'
]
=
$modify
[
'message'
];
}
return
$result
;
}
/**
* 修改购物车商品数据
*
* @param int $uid 用户ID
...
...
Please
register
or
login
to post a comment