...
|
...
|
@@ -10,16 +10,16 @@ use Plugin\Helpers; |
|
|
*/
|
|
|
class ShoppingCartController extends AbstractAction
|
|
|
{
|
|
|
|
|
|
/*
|
|
|
* 购物车首页
|
|
|
*/
|
|
|
|
|
|
public function indexAction()
|
|
|
{
|
|
|
$this->setTitle('购物车');
|
|
|
$this->setNavHeader('购物车');
|
|
|
|
|
|
$shoppingKey = $this->getSession('shoppingKey');
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$uid = $this->getUid(true);
|
|
|
|
|
|
$data = array(
|
...
|
...
|
@@ -32,6 +32,41 @@ class ShoppingCartController extends AbstractAction |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 加入购物车
|
|
|
*
|
|
|
* @param string productSku 商品的SKU
|
|
|
* @param int buyNumber 购买数量
|
|
|
* @param int promotionId 促销ID, 加价购有关
|
|
|
* @param int goodsType 商品类型,0表示普通商品,1表示加价购商品
|
|
|
* @param int isEdit 是否是编辑商品SKU,0表示不是编辑
|
|
|
* @return json
|
|
|
*/
|
|
|
public function addAction()
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$productSku = $this->post('productSku');
|
|
|
$buyNumber = $this->post('buyNumber', 1);
|
|
|
$goodsType = $this->post('goodsType', 0);
|
|
|
$promotionId = $this->post('promotionId', 0);
|
|
|
$isEdit = $this->post('isEdit', 0);
|
|
|
$uid = $this->getUid(true);
|
|
|
|
|
|
// 执行加入购物车操作
|
|
|
$result = CartModel::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey);
|
|
|
|
|
|
// 设置加入购物车凭证到客户端浏览器
|
|
|
if (isset($result['data']['shopping_key'])) {
|
|
|
$this->setCookie('_spk', $shoppingKey);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 移出购物车
|
|
|
*/
|
|
|
public function delAction()
|
...
|
...
|
@@ -41,7 +76,7 @@ class ShoppingCartController extends AbstractAction |
|
|
if ($this->isAjax()) {
|
|
|
$productId = $this->post('id', 0);
|
|
|
$uid = $this->getUid(true);
|
|
|
$shoppingKey = $this->getSession('shoppingKey');
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$result = CartModel::removeFromCart($uid, $productId, $shoppingKey);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -75,6 +110,7 @@ class ShoppingCartController extends AbstractAction |
|
|
/*
|
|
|
* 获取购物车商品数据
|
|
|
*/
|
|
|
|
|
|
public function goodinfoAction()
|
|
|
{
|
|
|
$result = array();
|
...
|
...
|
@@ -97,6 +133,7 @@ class ShoppingCartController extends AbstractAction |
|
|
/*
|
|
|
* 获取购物车加价购商品数据
|
|
|
*/
|
|
|
|
|
|
public function giftinfoAction()
|
|
|
{
|
|
|
$result = array();
|
...
|
...
|
@@ -122,14 +159,14 @@ class ShoppingCartController extends AbstractAction |
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
$shoppingKey = $this->getSession('shoppingKey');
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$uid = $this->getUid(true);
|
|
|
|
|
|
$params = array();
|
|
|
$params['old_product_sku']= $this->post('old_product_sku', 0);
|
|
|
$params['new_product_sku']= $this->post('new_product_sku', 0);
|
|
|
$params['buy_number']= $this->post('buy_number', 0);
|
|
|
$params['selected']= $this->post('selected', null);
|
|
|
$params['old_product_sku'] = $this->post('old_product_sku', 0);
|
|
|
$params['new_product_sku'] = $this->post('new_product_sku', 0);
|
|
|
$params['buy_number'] = $this->post('buy_number', 0);
|
|
|
$params['selected'] = $this->post('selected', null);
|
|
|
$result = CartModel::modifyCartProduct($uid, $params, $shoppingKey);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -270,6 +307,7 @@ class ShoppingCartController extends AbstractAction |
|
|
/*
|
|
|
* 确认订单
|
|
|
*/
|
|
|
|
|
|
public function orderEnsureAction()
|
|
|
{
|
|
|
$data = array(
|
...
|
...
|
@@ -342,8 +380,8 @@ class ShoppingCartController extends AbstractAction |
|
|
/**
|
|
|
* 下单流程 选择地址
|
|
|
*/
|
|
|
|
|
|
public function selectAddressAction() {
|
|
|
public function selectAddressAction()
|
|
|
{
|
|
|
// 设置网站标题
|
|
|
$this->setTitle('选择地址');
|
|
|
$this->setNavHeader('选择地址', Helpers::url('/shoppingCart/orderEnsure'));
|
...
|
...
|
@@ -356,14 +394,13 @@ class ShoppingCartController extends AbstractAction |
|
|
'pageFooter' => true,
|
|
|
'address' => $address
|
|
|
));
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 下单流程 选择优惠券
|
|
|
*/
|
|
|
|
|
|
public function selectCouponAction() {
|
|
|
public function selectCouponAction()
|
|
|
{
|
|
|
// 设置网站标题
|
|
|
$this->setTitle('选择优惠券');
|
|
|
$this->setNavHeader('选择优惠券', Helpers::url('/shoppingCart/orderEnsure'));
|
...
|
...
|
@@ -376,6 +413,6 @@ class ShoppingCartController extends AbstractAction |
|
|
'pageFooter' => true,
|
|
|
'address' => $address
|
|
|
));
|
|
|
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|