...
|
...
|
@@ -36,6 +36,9 @@ class CartModel |
|
|
public static function myCartData($uid, $shoppingKey, $cartDelList)
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
// 存放分析用的数据
|
|
|
$analysisData = array('ipinyou' => '');
|
|
|
|
|
|
do {
|
|
|
$result['isEmpty'] = false;
|
...
|
...
|
@@ -47,7 +50,7 @@ class CartModel |
|
|
|
|
|
// 调用接口,获取购物车数据
|
|
|
$cartData = CartData::cartData($uid, $shoppingKey);
|
|
|
|
|
|
|
|
|
// 接口异常时,购物车置为空
|
|
|
if (empty($cartData['data'])) {
|
|
|
$result['isEmpty'] = true;
|
...
|
...
|
@@ -55,7 +58,7 @@ class CartModel |
|
|
$result['viewOrderUrl'] = Helpers::url('/home/orders', array('t' => time()));
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
|
|
|
$ordinaryCartData = $cartData['data']['ordinary_cart_data'];
|
|
|
$advanceCartData = $cartData['data']['advance_cart_data'];
|
|
|
|
...
|
...
|
@@ -71,7 +74,7 @@ class CartModel |
|
|
$ordinaryOffShelves = empty($ordinaryCartData['off_shelves_goods_list']);
|
|
|
// 预售商品是否有失效的
|
|
|
$advanceOffShelves = empty($advanceCartData['off_shelves_goods_list']);
|
|
|
|
|
|
|
|
|
/* 移除的商品列表 */
|
|
|
if (!empty($cartDelList)) {
|
|
|
$result['deleteShop'] = json_decode($cartDelList, true);
|
...
|
...
|
@@ -121,44 +124,36 @@ class CartModel |
|
|
// 普通的
|
|
|
if (!empty($ordinaryCartData['goods_list'])) {
|
|
|
$result['commonSell']['cartProductNum'] = strval($ordinaryCount);
|
|
|
$result['commonSell']['productItem'] = Helpers::formatCartGoods($ordinaryCartData['goods_list'], false, true);
|
|
|
$result['commonSell']['productItem'] = Helpers::formatCartGoods($ordinaryCartData['goods_list'], false, true, false, $analysisData);
|
|
|
}
|
|
|
// 预售的
|
|
|
if (!empty($advanceCartData['goods_list'])) {
|
|
|
$result['preSell']['cartProductNum'] = strval($advanceCount);
|
|
|
$result['preSell']['productItem'] = Helpers::formatCartGoods($advanceCartData['goods_list'], true, true);
|
|
|
$result['preSell']['productItem'] = Helpers::formatCartGoods($advanceCartData['goods_list'], true, true, false, $analysisData);
|
|
|
}
|
|
|
|
|
|
/* 已售磬失效 */
|
|
|
// 普通的
|
|
|
if (!$ordinarySoldOut) {
|
|
|
//$result['commonSell']['cartProductNum'] += count($ordinaryCartData['sold_out_goods_list']);
|
|
|
$result['commonSell']['productItem'] = isset($result['commonSell']['productItem'])
|
|
|
? self::appendProductItem($result['commonSell']['productItem'], Helpers::formatCartGoods($ordinaryCartData['sold_out_goods_list'], false, true), count($result['commonSell']['productItem']))
|
|
|
: Helpers::formatCartGoods($ordinaryCartData['sold_out_goods_list'], false, true);
|
|
|
$result['commonSell']['productItem'] = isset($result['commonSell']['productItem']) ? self::appendProductItem($result['commonSell']['productItem'], Helpers::formatCartGoods($ordinaryCartData['sold_out_goods_list'], false, true), count($result['commonSell']['productItem'])) : Helpers::formatCartGoods($ordinaryCartData['sold_out_goods_list'], false, true, false, $analysisData);
|
|
|
}
|
|
|
// 预售的
|
|
|
if (!$advanceSoldOut) {
|
|
|
//$result['preSell']['cartProductNum'] += count($advanceCartData['sold_out_goods_list']);
|
|
|
$result['preSell']['productItem'] = isset($result['preSell']['productItem'])
|
|
|
? self::appendProductItem($result['preSell']['productItem'], Helpers::formatCartGoods($advanceCartData['sold_out_goods_list'], true, true), count($result['preSell']['productItem']))
|
|
|
: Helpers::formatCartGoods($advanceCartData['sold_out_goods_list'], true, true);
|
|
|
$result['preSell']['productItem'] = isset($result['preSell']['productItem']) ? self::appendProductItem($result['preSell']['productItem'], Helpers::formatCartGoods($advanceCartData['sold_out_goods_list'], true, true), count($result['preSell']['productItem'])) : Helpers::formatCartGoods($advanceCartData['sold_out_goods_list'], true, true, false, $analysisData);
|
|
|
}
|
|
|
|
|
|
|
|
|
/* 已失效的 */
|
|
|
// 普通的
|
|
|
if (!$ordinaryOffShelves) {
|
|
|
//$result['commonSell']['cartProductNum'] += count($ordinaryCartData['off_shelves_goods_list']);
|
|
|
$result['commonSell']['productItem'] = isset($result['commonSell']['productItem'])
|
|
|
? self::appendProductItem($result['commonSell']['productItem'], Helpers::formatCartGoods($ordinaryCartData['off_shelves_goods_list'], false, true, true), count($result['commonSell']['productItem']))
|
|
|
: Helpers::formatCartGoods($ordinaryCartData['off_shelves_goods_list'], false, true, true);
|
|
|
$result['commonSell']['productItem'] = isset($result['commonSell']['productItem']) ? self::appendProductItem($result['commonSell']['productItem'], Helpers::formatCartGoods($ordinaryCartData['off_shelves_goods_list'], false, true, true), count($result['commonSell']['productItem'])) : Helpers::formatCartGoods($ordinaryCartData['off_shelves_goods_list'], false, true, true, $analysisData);
|
|
|
}
|
|
|
// 预售的
|
|
|
if (!$advanceOffShelves) {
|
|
|
//$result['preSell']['cartProductNum'] += count($advanceCartData['off_shelves_goods_list']);
|
|
|
$result['preSell']['productItem'] = isset($result['preSell']['productItem'])
|
|
|
? self::appendProductItem($result['preSell']['productItem'], Helpers::formatCartGoods($advanceCartData['off_shelves_goods_list'], true, true, true), count($result['preSell']['productItem']))
|
|
|
: Helpers::formatCartGoods($advanceCartData['off_shelves_goods_list'], true, true, true);
|
|
|
$result['preSell']['productItem'] = isset($result['preSell']['productItem']) ? self::appendProductItem($result['preSell']['productItem'], Helpers::formatCartGoods($advanceCartData['off_shelves_goods_list'], true, true, true), count($result['preSell']['productItem'])) : Helpers::formatCartGoods($advanceCartData['off_shelves_goods_list'], true, true, true, $analysisData);
|
|
|
}
|
|
|
|
|
|
/* 赠品 */
|
...
|
...
|
@@ -168,22 +163,17 @@ class CartModel |
|
|
}
|
|
|
// 普通的
|
|
|
if (!empty($ordinaryCartData['gift_list'])) {
|
|
|
$result['subjoinItem'] = isset($result['subjoinItem']) ? self::appendProductItem($result['subjoinItem'], Helpers::formatGiftPriceGoods($ordinaryCartData['gift_list'], true), count($result['subjoinItem']))
|
|
|
: Helpers::formatGiftPriceGoods($ordinaryCartData['gift_list'], true);
|
|
|
$result['subjoinItem'] = isset($result['subjoinItem']) ? self::appendProductItem($result['subjoinItem'], Helpers::formatGiftPriceGoods($ordinaryCartData['gift_list'], true), count($result['subjoinItem'])) : Helpers::formatGiftPriceGoods($ordinaryCartData['gift_list'], true);
|
|
|
}
|
|
|
|
|
|
/* 加价购 */
|
|
|
// 预售的
|
|
|
if (!empty($advanceCartData['price_gift'])) {
|
|
|
$result['subjoinItem'] = isset($result['subjoinItem'])
|
|
|
? self::appendProductItem($result['subjoinItem'], Helpers::formatGiftPriceGoods($advanceCartData['price_gift'], false), count($result['subjoinItem']))
|
|
|
: Helpers::formatGiftPriceGoods($advanceCartData['price_gift'], false);
|
|
|
$result['subjoinItem'] = isset($result['subjoinItem']) ? self::appendProductItem($result['subjoinItem'], Helpers::formatGiftPriceGoods($advanceCartData['price_gift'], false), count($result['subjoinItem'])) : Helpers::formatGiftPriceGoods($advanceCartData['price_gift'], false);
|
|
|
}
|
|
|
// 普通的
|
|
|
if (!empty($ordinaryCartData['price_gift'])) {
|
|
|
$result['subjoinItem'] = isset($result['subjoinItem'])
|
|
|
? self::appendProductItem($result['subjoinItem'], Helpers::formatGiftPriceGoods($ordinaryCartData['price_gift'], false), count($result['subjoinItem']))
|
|
|
: Helpers::formatGiftPriceGoods($ordinaryCartData['price_gift'], false);
|
|
|
$result['subjoinItem'] = isset($result['subjoinItem']) ? self::appendProductItem($result['subjoinItem'], Helpers::formatGiftPriceGoods($ordinaryCartData['price_gift'], false), count($result['subjoinItem'])) : Helpers::formatGiftPriceGoods($ordinaryCartData['price_gift'], false);
|
|
|
}
|
|
|
|
|
|
/* 促销短语 */
|
...
|
...
|
@@ -197,13 +187,19 @@ class CartModel |
|
|
//$result['salesPromotion'] = array_merge($result['salesPromotion'], self::buildPromotionData($advanceCartData['promotion_info']));
|
|
|
$result['salesPromotion'] = self::buildPromotionData($advanceCartData['promotion_info']);
|
|
|
}
|
|
|
|
|
|
|
|
|
// 清空变量
|
|
|
$advanceCartData = array();
|
|
|
$ordinaryCartData = array();
|
|
|
$cartData = array();
|
|
|
|
|
|
} while (false);
|
|
|
|
|
|
// 增加第三方分析用的数据
|
|
|
$result['ids'] = empty($analysisData['ids']) ? '' : implode(',', $analysisData['ids']);
|
|
|
$result['ipinyou'] = empty($analysisData['ipinyou']) ? '' : $analysisData['ipinyou'];
|
|
|
$result['ipinyouAmount'] = isset($result['productAllA']) ? $result['productAllA'] : '0.00';
|
|
|
$result['criteo'] = empty($analysisData['criteo']) ? '' : json_encode($analysisData['criteo']);
|
|
|
|
|
|
return $result;
|
|
|
}
|
...
|
...
|
@@ -423,7 +419,7 @@ class CartModel |
|
|
break;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$result['data']['hasPrev'] = false;
|
|
|
$result['data']['hasNext'] = true;
|
|
|
if (intval($page) > 1) {
|
...
|
...
|
@@ -476,20 +472,20 @@ class CartModel |
|
|
if (empty($sknList)) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
|
|
|
// 组装 skn => goodsId 对应关系
|
|
|
$sknArr = array();
|
|
|
foreach ($sknList as $value) {
|
|
|
$value = explode('-', $value);
|
|
|
if (isset($value[1])) {
|
|
|
$sknArr[ $value[0] ] = $value[1];
|
|
|
$sknArr[$value[0]] = $value[1];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (array() === $sknArr) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
|
|
|
// 通过SKN列表搜索调用商品信息
|
|
|
$browse = CartData::browseRecordFromSearch(implode(' ', array_keys($sknArr)));
|
|
|
if (empty($browse['data']['product_list'])) {
|
...
|
...
|
@@ -532,11 +528,11 @@ class CartModel |
|
|
$build['href'] = Helpers::url('/product/pro_' . $value['product_id'] . '_' . $goodsId . '/' . $value['cn_alphabet'] . '.html', null, 'item');
|
|
|
|
|
|
$result['data']['item'][] = $build;
|
|
|
|
|
|
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// 当数据量不足6个时,判定为没有下一页
|
|
|
if (!isset($result['data']['item'][5])) {
|
|
|
$result['data']['hasNext'] = false;
|
...
|
...
|
@@ -574,7 +570,7 @@ class CartModel |
|
|
if ($value['payment_type'] == 1 && $value['is_support'] === 'Y') {
|
|
|
$result['onlinePay']['checked'] = $isDefault ? true : false;
|
|
|
$result['onlinePay']['paymentId'] = $value['payment_id'];
|
|
|
}
|
|
|
}
|
|
|
// 货到付款
|
|
|
elseif ($value['payment_type'] == 2 && $value['is_support'] === 'Y') {
|
|
|
$result['deliveryPay']['checked'] = $isDefault ? true : false;
|
...
|
...
|
@@ -586,7 +582,7 @@ class CartModel |
|
|
$result['defaultPayWay'] = $value['payment_type_name'];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 未设置时,设置默认
|
|
|
if (!isset($result['defaultPayWay'])) {
|
...
|
...
|
@@ -597,7 +593,7 @@ class CartModel |
|
|
$result['defaultPayWay'] = '在线支付';
|
|
|
$result['supportDeliveryPay'] = true;
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!empty($pay['data']['delivery_time'])) {
|
|
|
$build = array();
|
|
|
foreach ($pay['data']['delivery_time'] as $value) {
|
...
|
...
|
@@ -610,8 +606,8 @@ class CartModel |
|
|
}
|
|
|
$result['delivery'][] = $build;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 默认
|
|
|
if (!isset($result['defaultDelivery'])) {
|
|
|
$result['defaultDelivery'] = '只工作日送货(双休日、节假日不送)';
|
...
|
...
|
@@ -619,7 +615,7 @@ class CartModel |
|
|
$result['delivery'][0]['checked'] = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// 支付支持的平台
|
|
|
$result['supportLine'] = array(
|
|
|
array('src' => 'http://static.yohobuy.com/images/pay/icon/zhifubao.png'),
|
...
|
...
|
@@ -738,7 +734,7 @@ class CartModel |
|
|
$result['isPreSell'] = $isAdvanceCart ? true : false;
|
|
|
// 顺丰查看详情
|
|
|
$result['sfUrl'] = Helpers::url('/help/index/logisticsarea', null, 'default');
|
|
|
|
|
|
|
|
|
// 是否是新客访问, 控制显示新手引导
|
|
|
$isNewUser = Helpers::isNewUser();
|
|
|
// 新用户(未下单)且未设置收货地址的,提示引导
|
...
|
...
|
@@ -746,7 +742,6 @@ class CartModel |
|
|
$isNewUser = false;
|
|
|
}
|
|
|
$result['isNewUser'] = $isNewUser ? true : false;
|
|
|
|
|
|
} while (false);
|
|
|
|
|
|
return $result;
|
...
|
...
|
@@ -904,7 +899,7 @@ class CartModel |
|
|
$phone = explode('-', strtr($value['phone'], array('null' => '')));
|
|
|
$mobile = strtr($value['mobile'], array('null' => ''));
|
|
|
$mobile = substr($mobile, 0, 3) . '****' . substr($mobile, 7);
|
|
|
|
|
|
|
|
|
$build = array();
|
|
|
$build['id'] = $value['address_id'];
|
|
|
$build['user'] = $value['consignee'];
|
...
|
...
|
@@ -1007,7 +1002,7 @@ class CartModel |
|
|
} else if (!empty($phoneNum) && !is_numeric($phoneNum)) {
|
|
|
$result['code'] = 406;
|
|
|
$result['message'] = '输入的固定电话格式不正确';
|
|
|
} else if ((!empty($phoneNum) && empty($phoneCode)) || (!empty($phoneCode) && empty($phoneNum)) ) {
|
|
|
} else if ((!empty($phoneNum) && empty($phoneCode)) || (!empty($phoneCode) && empty($phoneNum))) {
|
|
|
$result['code'] = 407;
|
|
|
$result['message'] = '输入的固定电话格式不正确';
|
|
|
} else {
|
...
|
...
|
@@ -1105,7 +1100,6 @@ class CartModel |
|
|
$result[] = $build;
|
|
|
}
|
|
|
$couponList = array();
|
|
|
|
|
|
} while (false);
|
|
|
|
|
|
return $result;
|
...
|
...
|
@@ -1140,7 +1134,7 @@ class CartModel |
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取购物车总数
|
|
|
*
|
...
|
...
|
@@ -1152,7 +1146,7 @@ class CartModel |
|
|
{
|
|
|
return CartData::cartCount($uid, $shoppingKey);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 追加商品
|
|
|
*
|
...
|
...
|
@@ -1165,9 +1159,9 @@ class CartModel |
|
|
{
|
|
|
foreach ($data as $value) {
|
|
|
$source[$index] = $value;
|
|
|
++ $index;
|
|
|
++$index;
|
|
|
}
|
|
|
|
|
|
|
|
|
return $source;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -1178,10 +1172,10 @@ class CartModel |
|
|
* @param int $default 默认值
|
|
|
* @return float
|
|
|
*/
|
|
|
private static function genProductAmount($promotionList, $default)
|
|
|
private static function genProductAmount($promotionList, $default)
|
|
|
{
|
|
|
$result = $default;
|
|
|
|
|
|
|
|
|
$vipAmount = null;
|
|
|
foreach ($promotionList as $value) {
|
|
|
if ($value['promotion'] === 'VIP优惠') {
|
...
|
...
|
@@ -1193,10 +1187,10 @@ class CartModel |
|
|
$result = floatval($default) - floatval($vipAmount);
|
|
|
}
|
|
|
$result = Helpers::transPrice($result);
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 构建促销短语数据
|
|
|
*
|
...
|
...
|
|