...
|
...
|
@@ -32,41 +32,6 @@ 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()
|
...
|
...
|
@@ -76,7 +41,7 @@ class ShoppingCartController extends AbstractAction |
|
|
if ($this->isAjax()) {
|
|
|
$productId = $this->post('id', 0);
|
|
|
$uid = $this->getUid(true);
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$shoppingKey = $this->getSession('shoppingKey');
|
|
|
$result = CartModel::removeFromCart($uid, $productId, $shoppingKey);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -110,7 +75,6 @@ class ShoppingCartController extends AbstractAction |
|
|
/*
|
|
|
* 获取购物车商品数据
|
|
|
*/
|
|
|
|
|
|
public function goodinfoAction()
|
|
|
{
|
|
|
$result = array();
|
...
|
...
|
@@ -133,7 +97,6 @@ class ShoppingCartController extends AbstractAction |
|
|
/*
|
|
|
* 获取购物车加价购商品数据
|
|
|
*/
|
|
|
|
|
|
public function giftinfoAction()
|
|
|
{
|
|
|
$result = array();
|
...
|
...
|
@@ -159,14 +122,14 @@ class ShoppingCartController extends AbstractAction |
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$shoppingKey = $this->getSession('shoppingKey');
|
|
|
$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);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -180,25 +143,27 @@ class ShoppingCartController extends AbstractAction |
|
|
/**
|
|
|
* 购物车结算请求
|
|
|
*/
|
|
|
public function payAction()
|
|
|
public function orderEnsureAction()
|
|
|
{
|
|
|
$this->setTitle('购物车');
|
|
|
$this->setNavHeader('购物车');
|
|
|
|
|
|
$cartType = $this->post('cartType', 'ordinary');
|
|
|
$cookieData = $this->getCookie('order-info', null);
|
|
|
$uid = $this->getUid(true);
|
|
|
$data = array(
|
|
|
'orderEnsurePage' => true,
|
|
|
'orderEnsure' => CartModel::cartPay($uid, $cartType)
|
|
|
'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData)
|
|
|
);
|
|
|
|
|
|
|
|
|
$this->_view->display('order-ensure', $data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 购物车选择支付方式和配送方式接口
|
|
|
* 购物车选择改变字段,重新运算订单数据
|
|
|
*/
|
|
|
public function payAndDeliveryAction()
|
|
|
public function orderComputeAction()
|
|
|
{
|
|
|
$result = array();
|
|
|
|
...
|
...
|
@@ -206,8 +171,10 @@ class ShoppingCartController extends AbstractAction |
|
|
$cartType = $this->post('cartType', 'ordinary');
|
|
|
$deliveryWay = $this->post('deliveryWay', 1);
|
|
|
$paymentType = $this->post('paymentType', 1);
|
|
|
$couponCode = $this->post('paymentType', null);
|
|
|
$yohoCoin = $this->post('paymentType', null);
|
|
|
$uid = $this->getUid(true);
|
|
|
$result = CartModel::paymentTypeAndDelivery($uid, $cartType, $deliveryWay, $paymentType);
|
|
|
$result = CartModel::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
...
|
...
|
@@ -220,14 +187,14 @@ class ShoppingCartController extends AbstractAction |
|
|
/**
|
|
|
* 购物车输入优惠券码使用优惠券
|
|
|
*/
|
|
|
public function couponAction()
|
|
|
public function couponSearchAction()
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
$couponCode = $this->post('couponCode', '');
|
|
|
$couponCode = $this->get('couponCode', '');
|
|
|
$uid = $this->getUid(true);
|
|
|
$result = CartModel::getCoupon($uid, $couponCode);
|
|
|
$result = CartModel::searchCoupon($uid, $couponCode);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
...
|
...
|
@@ -238,18 +205,16 @@ class ShoppingCartController extends AbstractAction |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 购物车使用YOHO币
|
|
|
* 购物车结算--获取优惠券列表
|
|
|
*/
|
|
|
public function yohoCoinAction()
|
|
|
public function couponListAction()
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
$cartType = $this->post('cartType', 'ordinary');
|
|
|
$deliveryWay = $this->post('deliveryWay', 1);
|
|
|
$paymentType = $this->post('paymentType', 1);
|
|
|
$yohoCoin = $this->post('yohoCoin', 1);
|
|
|
$result = CartModel::paymentTypeAndDelivery($this->_uid, $cartType, $deliveryWay, $paymentType, $yohoCoin);
|
|
|
$uid = $this->getUid(true);
|
|
|
$page = $this->get('page', 1);
|
|
|
$result = CartModel::getCouponList($uid);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
...
|
...
|
@@ -259,124 +224,6 @@ class ShoppingCartController extends AbstractAction |
|
|
}
|
|
|
}
|
|
|
|
|
|
public function giftAdvanceAction()
|
|
|
{
|
|
|
$data = array(
|
|
|
'advance' => array(
|
|
|
array(
|
|
|
'title' => '【izzue】加¥19购袜子',
|
|
|
'goods' => array(
|
|
|
'id' => 1,
|
|
|
'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/09/17/03/014cacfa5c458b9732c68adf1af15d7a45.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/90',
|
|
|
'name' => 'Life.After.Life纯棉短袜',
|
|
|
'salePrice' => 19,
|
|
|
'price' => 99,
|
|
|
'count' => 1
|
|
|
)
|
|
|
),
|
|
|
array(
|
|
|
'title' => '【银鳞堂】加¥9购手绳',
|
|
|
'goods' => array(
|
|
|
'id' => 1,
|
|
|
'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/10/03/10/01bc1878f9154e77ac4f7a6003c954f1b8.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
|
|
|
'name' => '银鳞堂民族风牛皮手绳',
|
|
|
'salePrice' => 9,
|
|
|
'price' => 19,
|
|
|
'count' => 1
|
|
|
)
|
|
|
)
|
|
|
)
|
|
|
);
|
|
|
|
|
|
$data = array(
|
|
|
'gift' => array(
|
|
|
'id' => 1,
|
|
|
'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/09/17/03/014cacfa5c458b9732c68adf1af15d7a45.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/90',
|
|
|
'name' => 'Life.After.Life纯棉短袜',
|
|
|
'color' => '黄色',
|
|
|
'size' => 'L',
|
|
|
'price' => 0,
|
|
|
'count' => 1
|
|
|
)
|
|
|
);
|
|
|
|
|
|
$this->_view->display('gift-advance', array('giftAdvancePage' => true, 'pageHeader' => array(
|
|
|
'navBack' => true, 'navTitle' => '加价购'), 'shoppingCart' => $data));
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 确认订单
|
|
|
*/
|
|
|
|
|
|
public function orderEnsureAction()
|
|
|
{
|
|
|
$data = array(
|
|
|
'orderEnsurePage' => true,
|
|
|
'orderEnsure' => array(
|
|
|
'name' => '申建军',
|
|
|
'phoneNum' => '12345678',
|
|
|
'address' => '江苏省南京市建邺区',
|
|
|
'dispatchMode' => array(
|
|
|
array(
|
|
|
'id' => 1,
|
|
|
'name' => '普通快递¥10'
|
|
|
),
|
|
|
array(
|
|
|
'id' => 2,
|
|
|
'name' => '顺丰速运¥15(仅支持顺丰克配送的地区)'
|
|
|
)
|
|
|
),
|
|
|
'dispatchTime' => array(
|
|
|
array(
|
|
|
'id' => 1,
|
|
|
'name' => '工作日、双休日、节假日均可送货'
|
|
|
),
|
|
|
array(
|
|
|
'id' => 2,
|
|
|
'name' => '只工作日送货'
|
|
|
),
|
|
|
array(
|
|
|
'id' => 3,
|
|
|
'name' => '只双休日、节假日送货'
|
|
|
)
|
|
|
),
|
|
|
'goods' => array(
|
|
|
array(
|
|
|
'id' => 1,
|
|
|
'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
|
|
|
'name' => 'Adidas Originals ZX FLUXM22508',
|
|
|
'color' => '黄',
|
|
|
'size' => '43',
|
|
|
'price' => '699.00',
|
|
|
'count' => '2'
|
|
|
),
|
|
|
array(
|
|
|
'id' => 1,
|
|
|
'thumb' => 'http://img10.static.yhbimg.com/goodsimg/2015/11/04/05/0188f1aca49ac478a565ec029b5d2d4a6c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
|
|
|
'name' => 'B.Duck浴室玩伴mini浮水鸭',
|
|
|
'gift' => true,
|
|
|
'color' => '黄',
|
|
|
'size' => '43',
|
|
|
'price' => '0.00',
|
|
|
'count' => '1'
|
|
|
)
|
|
|
),
|
|
|
'coupon' => array(
|
|
|
'count' => 1,
|
|
|
'notUsed' => true
|
|
|
),
|
|
|
'yohoCoin' => '0',
|
|
|
'invoice' => true,
|
|
|
'sumPrice' => 900,
|
|
|
'salePrice' => 90,
|
|
|
'freight' => 0,
|
|
|
'price' => 810
|
|
|
)
|
|
|
);
|
|
|
|
|
|
$this->_view->display('order-ensure', $data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 下单流程 选择地址
|
|
|
*/
|
...
|
...
|
@@ -386,7 +233,7 @@ class ShoppingCartController extends AbstractAction |
|
|
$this->setTitle('选择地址');
|
|
|
$this->setNavHeader('选择地址', Helpers::url('/shoppingCart/orderEnsure'));
|
|
|
|
|
|
$uid = $this->_uid;
|
|
|
$uid = $this->getUid(true);
|
|
|
$address = UserModel::getAddressData($uid);
|
|
|
|
|
|
$this->_view->display('select-address', array(
|
...
|
...
|
@@ -404,15 +251,41 @@ class ShoppingCartController extends AbstractAction |
|
|
// 设置网站标题
|
|
|
$this->setTitle('选择优惠券');
|
|
|
$this->setNavHeader('选择优惠券', Helpers::url('/shoppingCart/orderEnsure'));
|
|
|
|
|
|
$uid = $this->_uid;
|
|
|
$address = UserModel::getAddressData($uid);
|
|
|
|
|
|
$this->_view->display('select-coupon', array(
|
|
|
'selectCouponPage' => true,
|
|
|
'pageFooter' => true,
|
|
|
'address' => $address
|
|
|
'pageFooter' => true
|
|
|
));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 确认结算订单
|
|
|
*/
|
|
|
public function orderSubAction()
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
$uid = $this->getUid(true);
|
|
|
$addressId = $this->post('addressId', null);
|
|
|
$cartType = $this->post('cartType', 'ordinary'); // 默认普通购物车
|
|
|
$deliveryTime = $this->post('deliveryTime', 1); // 默认只工作日配送
|
|
|
$deliveryWay = $this->post('deliveryWay', 1); // 默认普通快递
|
|
|
$invoiceTitle = $this->post('invoiceTitle', null);
|
|
|
$invoiceId = $this->post('invoiceId', null);
|
|
|
$paymentId = $this->post('paymentId', 15);
|
|
|
$paymentType = $this->post('paymentType', 1); // 默认在线支付
|
|
|
$remark = $this->post('remark', null); // 默认在线支付
|
|
|
$yohoCoin = $this->post('yohoCoin', 1);
|
|
|
$result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $yohoCoin);
|
|
|
}
|
|
|
|
|
|
if (empty($result)) {
|
|
|
echo ' ';
|
|
|
} else {
|
|
|
// 提交成功清除Cookie
|
|
|
$this->setCookie('orderInfo', null);
|
|
|
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|