Authored by biao

Merge branch 'hotfix/making-order'

... ... @@ -7,7 +7,7 @@ use WebPlugin\UdpLog;
/**
* 购物车相关的控制器
*
*
* @name IndexController
* @package Cart
* @copyright yoho.inc
... ... @@ -24,13 +24,13 @@ class IndexController extends WebAction
{
$uid = $this->getUid(false);
$shoppingKey = Helpers::getShoppingKeyByCookie();
// 显示一次并清除已删除的COOKIE记录
$cartDelList = $this->getCookie('cart-del-list');
if (!empty($cartDelList)) {
$this->setCookie('cart-del-list', '');
}
$this->setTitle('购物车', true, ' | ');
$this->setSimpleHeader();
$this->_view->display('cart', array(
... ... @@ -39,10 +39,10 @@ class IndexController extends WebAction
'uid' => $uid ? $uid : '',
));
}
/**
* 购物车商品选择与取消
*
*
* @param string skuList 商品sku列表,json格式,如{"744403":1,"777777":3}
* @param bool hasPromotion 标识是不是有promotion_id参数, 后端会去调用不同的接口
* @return json
... ... @@ -61,10 +61,10 @@ class IndexController extends WebAction
$this->echoJson($result);
}
/**
* 修改购物车商品数量
*
*
* @param int sku 商品到尺码的编吗
* @param int increaseNum 增加1
* @param int decreaseNum 减少1
... ... @@ -76,12 +76,12 @@ class IndexController extends WebAction
if ($this->isAjax()) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$uid = $this->getUid(false);
$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['code']) && $result['code'] == 200) {
$this->setShoppingCookie($uid);
... ... @@ -90,10 +90,10 @@ class IndexController extends WebAction
$this->echoJson($result);
}
/**
* 移出购物车
*
*
* @param string skuList 商品sku列表,json格式,如[{"product_sku":1047193,"buy_number":1,"promotion_id":0}]
* @param bool hasPromotion 标识是不是有promotion_id参数, 后端会去调用不同的接口
* @return json
... ... @@ -112,15 +112,15 @@ class IndexController extends WebAction
$this->setShoppingCookie($uid);
}
}
$this->echoJson($result);
}
/**
* 移入收藏夹
*
*
* 支持批量移入收藏夹
*
*
* @param string 商品sku列表,json格式,如{"744403":1,"777777":3}
* @param bool hasPromotion 标识是不是有promotion_id参数, 后端会去调用不同的接口
* @return json
... ... @@ -141,32 +141,32 @@ class IndexController extends WebAction
$this->echoJson($result);
}
/**
* 检查是否收藏
*
*
* @param string sknList 商品productId列表,如["123123","123412"]
*/
public function checkFavAction()
{
$result = array('code' => 200, 'message' => '是否收藏', 'data' => array());
if ($this->isAjax()) {
$uid = $this->getUid(false);
$pidList = $this->post('pidList', '');
$result['data'] = CartModel::checkUserIsFav($uid, $pidList);
}
$this->echoJson($result);
}
/**
* 凑单商品异步请求
*/
public function getTogetherProductAction()
{
$result = array('code' => 200, 'data' => array(), 'message' => '凑单商品');
$result = array('code' => 200, 'data' => array(), 'message' => '凑单商品');
if ($this->isAjax()) {
$page = $this->get('page', 1);
$result = CartModel::getTogetherProduct($page);
... ... @@ -181,15 +181,15 @@ class IndexController extends WebAction
public function getHistroyProductAction()
{
$result = array('code' => 200, 'data' => array(), 'message' => '浏览记录');
// 按照产品把明扬的指示,去掉最近浏览记录
$this->echoJson($result); exit();
do {
if (!$this->isAjax()) {
break;
}
$page = $this->get('page', 1);
// $uid = $this->getUid(false);
// if ($uid) {
... ... @@ -197,7 +197,7 @@ class IndexController extends WebAction
// $result = CartModel::getBrowseProduct($uid, $udid, $page);
// break;
// }
$sknList = $this->getCookie('_browseskn');
if (empty($sknList)) {
break;
... ... @@ -209,7 +209,7 @@ class IndexController extends WebAction
$this->echoJson($result);
}
/**
* 确认订单
*/
... ... @@ -217,67 +217,67 @@ class IndexController extends WebAction
{
$type = $this->get('type', 1);
$refer = Helpers::url('/cart/index/orderEnsure', array('type' => $type));
// 审判用户是否已登录
$this->auditJumpLogin(false, $refer);
$this->setTitle('填写订单', true, ' | ');
$this->setSimpleHeader();
$cartType = ($type == 2) ? 'advance' : 'ordinary';
$isAdvanceCart = ($type == 2) ? true : false;
$uid = $this->getUid(false);
$orderEnsure = CartModel::cartPay($uid, $cartType, $isAdvanceCart);
if (empty($orderEnsure)) {
$this->go(Helpers::url('/shopping/cart'));
}
$this->_view->display('order-ensure', array(
'orderEnsurePage' => true,
'orderEnsurePage' => true,
'orderEnsure' => $orderEnsure,
));
}
/**
* 异步获取地址信息
*
*
* @return json
*/
public function getAddressAction()
{
$result = array('code' => 200, 'data' => array(), 'message' => '地址信息');
if ($this->isAjax()) {
$uid = $this->getUid(false);
$result['data'] = CartModel::userAddressList($uid);
}
$this->echoJson($result);
}
/**
* 设置为默认的地址
*
*
* @param int id 地址ID
* @return json
*/
public function setDefaultAddressAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(false);
$addressId = $this->post('id');
$result = CartModel::setDefaultAddress($uid, $addressId);
}
$this->echoJson($result);
}
/**
* 保存地址信息
*
*
* @param int $id 地址ID ,当修改操作的时候需要传,添加时候不需要传
* @param string $address 地址信息
* @param int $areaCode 城市码
... ... @@ -292,7 +292,7 @@ class IndexController extends WebAction
public function saveAddressAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(false);
$id = $this->post('id', null);
... ... @@ -312,38 +312,38 @@ class IndexController extends WebAction
}
}
}
$this->echoJson($result);
}
/**
* 删除地址
*
*
* @param int id 地址ID
*/
public function delAddressAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(false);
$addressId = $this->post('id');
$result = CartModel::delAddress($uid, $addressId);
}
$this->echoJson($result);
}
/**
* 获取省市区县信息列表
*
*
* @param int id
* @return json
*/
public function getAreaListAction()
{
$result = array('code' => 200, 'message' => '地区信息', 'data' => array());
if ($this->isAjax()) {
$id = $this->get('id', 0);
$result['data'] = CartModel::getAreaList($id);
... ... @@ -351,16 +351,16 @@ class IndexController extends WebAction
$this->echoJson($result);
}
/**
* 获取优惠券列表
*
*
* @return json
*/
public function getCouponListAction()
{
$result = array('code' => 200, 'message' => '优惠券信息', 'data' => array());
if ($this->isAjax()) {
$uid = $this->getUid(false);
$result['data'] = CartModel::getCouponList($uid);
... ... @@ -368,10 +368,10 @@ class IndexController extends WebAction
$this->echoJson($result);
}
/**
* 购物车选择改变字段,重新运算订单数据
*
*
* @param string $cartType 购物车类型,ordinary表示普通, advance表示预售
* @param int $deliveryWay 配送方式,1表示普通快递,2表示顺丰速运
* @param int $paymentType 支付方式,1表示在线支付,2表示货到付款
... ... @@ -390,17 +390,18 @@ class IndexController extends WebAction
$paymentType = $this->post('paymentType', 1);
$couponCode = $this->post('couponCode', null);
$yohoCoin = $this->post('yohoCoin', null);
$promotionCode = $this->post('promotionCode', null);
$redEnvelopes = $this->post('redEnvelopes', null);
$uid = $this->getUid(false);
$result = CartModel::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin, $redEnvelopes);
$result = CartModel::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $promotionCode, $yohoCoin, $redEnvelopes);
}
$this->echoJson($result);
}
/**
* 确认结算订单
*
*
* @param int $addressId 地址ID
* @param int $cartType 购物车类型ID
* @param int $deliveryTimeId 寄送时间ID
... ... @@ -426,20 +427,20 @@ class IndexController extends WebAction
if (!$this->isAjax()) {
break;
}
// 判断用户是否登录
$uid = $this->getUid(false);
if (!$uid) {
$result['message'] = '请先登录';
break;
}
$addressId = $this->post('addressId', null);
$cartType = $this->post('cartType', 'ordinary'); // 默认普通购物车
$deliveryTimeId = $this->post('deliveryTimeId', 1); // 默认只工作日配送
$deliveryWayId = $this->post('deliveryWayId', 1); // 默认普通快递
$invoiceTitle = $this->post('invoiceTitle', null); // 发票抬头
$invoiceId = $this->post('invoiceId', null); // 发票类型
$invoiceId = $this->post('invoiceId', null); // 发票类型
$paymentId = $this->post('paymentId', 15); // 支付ID
$paymentType = $this->post('paymentType', 1); // 默认在线支付
$remark = $this->post('remark', ''); // 备注信息
... ... @@ -448,21 +449,21 @@ class IndexController extends WebAction
$isPreContact = $this->post('isPreContact', false); // 送货前是否联系
$isPrintPrice = $this->post('isPrintPrice', true); // 是否打印价格
$redEnvelopes = $this->post('redEnvelopes', null);
// 调用下单接口
$result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTimeId, $deliveryWayId, $invoiceTitle, $invoiceId,
$result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTimeId, $deliveryWayId, $invoiceTitle, $invoiceId,
$paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $isPreContact, $isPrintPrice, $redEnvelopes);
// 判断是否下单成功
if (empty($result['data']['order_code'])) {
UdpLog::info('【结算信息】判断是否下单成功','order_code'.$result['data']['order_code']);
break;
}
// 跳转到支付的URL链接
$result['data']['payUrl'] = Helpers::url('/shopping/pay', array('ordercode' => $result['data']['order_code']));
}
while (false);
// $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin);
//
// 记录下单异常的数据
... ... @@ -487,10 +488,10 @@ class IndexController extends WebAction
// // do nothing
// }
// }
$this->echoJson($result);
}
/**
* 加入购物车
*
... ... @@ -534,12 +535,12 @@ class IndexController extends WebAction
$this->echoJson($result);
}
/**
* 获取商品信息
*/
public function getProductInfoAction()
{
{
$productId = $this->get('productId');
$uid = $this->getUid();
$vipLevel = -1;
... ... @@ -552,10 +553,10 @@ class IndexController extends WebAction
}
$this->_view->display('goods-detail', $data);
}
/**
* 获取购物车商品总数
*
*
* @return jsonp
*/
public function countAction()
... ... @@ -564,10 +565,10 @@ class IndexController extends WebAction
$uid = $this->getUid(false);
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = CartModel::getCartCount($uid, $shoppingKey);
$this->helpJsonCallbackResult($callback, 200, '总数', $result);
}
/**
* 设置购物车COOKIE信息
*/
... ... @@ -585,5 +586,5 @@ class IndexController extends WebAction
)));
}
}
}
\ No newline at end of file
}
... ...