...
|
...
|
@@ -188,31 +188,48 @@ class UserModel |
|
|
$favProduct = UserData::favoriteProductData($uid, $page, $limit);
|
|
|
|
|
|
// 处理用户收藏的商品数据
|
|
|
if (isset($favProduct['data']) && $page <= $favProduct['data']['page_total']) {
|
|
|
$datas = array();
|
|
|
$product = array();
|
|
|
foreach ($favProduct['data']['product_list'] as $val) {
|
|
|
if (empty($val['product_skn'])) {
|
|
|
continue;
|
|
|
}
|
|
|
do {
|
|
|
// 开始就没获取到数据或者获取的数据为空时的处理
|
|
|
if (!isset($favProduct['data']['product_list']) && $page == 1) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// 加载第二页以及第二页之后的数据时接口不返回时的处理
|
|
|
if ($page > 1 && !$favProduct) {
|
|
|
$result['end'] = true;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if ($page <= $favProduct['data']['page_total']) {
|
|
|
$datas = array();
|
|
|
$product = array();
|
|
|
$product['fav_id'] = $val['product_id'];
|
|
|
$product['link'] = isset($val['goodsId'], $val['cnAlphabet']) ? Helpers::url('/product/pro_' . $val['product_id'] . '_' . $val['goodsId'] . '/' . $val['cnAlphabet'] . '.html') : '';
|
|
|
$product['imgUrl'] = !empty($val['image']) ? Helpers::getImageUrl($val['image'], 447, 596) : '';
|
|
|
;
|
|
|
$product['title'] = $val['product_name'];
|
|
|
$product['price'] = '¥' . Helpers::transPrice($val['market_price']);
|
|
|
$product['discountPrice'] = ($val['market_price'] - $val['sales_price'] > 0) ? '¥' . Helpers::transPrice($val['sales_price']) : false;
|
|
|
$product['savePrice'] = ($val['price_down'] > 0) ? '¥' . Helpers::transPrice($val['price_down']) : false;
|
|
|
$product['sellOut'] = ($val['storage'] <= 0);
|
|
|
|
|
|
$datas[] = $product;
|
|
|
}
|
|
|
!empty($datas) && $result['hasFavProduct'] = $datas;
|
|
|
} else if (($page > 1 && !$favProduct) || $page > $favProduct['data']['page_total']) {
|
|
|
$result['end'] = true;
|
|
|
}
|
|
|
foreach ($favProduct['data']['product_list'] as $val) {
|
|
|
if (empty($val['product_skn'])) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
$product = array();
|
|
|
$product['fav_id'] = $val['product_id'];
|
|
|
$product['link'] = isset($val['goodsId'], $val['cnAlphabet']) ? Helpers::url('/product/pro_' . $val['product_id'] . '_' . $val['goodsId'] . '/' . $val['cnAlphabet'] . '.html') : '';
|
|
|
$product['imgUrl'] = !empty($val['image']) ? Helpers::getImageUrl($val['image'], 447, 596) : '';
|
|
|
;
|
|
|
$product['title'] = $val['product_name'];
|
|
|
$product['price'] = '¥' . Helpers::transPrice($val['market_price']);
|
|
|
$product['discountPrice'] = ($val['market_price'] - $val['sales_price'] > 0) ? '¥' . Helpers::transPrice($val['sales_price']) : false;
|
|
|
$product['savePrice'] = ($val['price_down'] > 0) ? '¥' . Helpers::transPrice($val['price_down']) : false;
|
|
|
$product['sellOut'] = ($val['storage'] <= 0);
|
|
|
|
|
|
$datas[] = $product;
|
|
|
}
|
|
|
|
|
|
if (!empty($datas)) {
|
|
|
$result['hasFavProduct'] = $datas;
|
|
|
}
|
|
|
} else {
|
|
|
$result['end'] = true;
|
|
|
}
|
|
|
|
|
|
} while (false);
|
|
|
|
|
|
return $result;
|
|
|
}
|
...
|
...
|
@@ -234,40 +251,56 @@ class UserModel |
|
|
$favBrand = UserData::favoriteBrandData($uid, $gender, $page, $limit);
|
|
|
|
|
|
// 处理用户收藏的品牌数据
|
|
|
if (isset($favBrand['data']) && $page <= $favBrand['data']['page_total']) {
|
|
|
$datas = array();
|
|
|
$brand = array();
|
|
|
foreach ($favBrand['data']['brand_list'] as $val) {
|
|
|
$brand = array();
|
|
|
$brand['id'] = $val['brand_id'];
|
|
|
$brand['brandImg'] = !empty($val['brand_ico']) ? Images::getImageUrl($val['brand_ico'], 47, 47) : '';
|
|
|
$brand['brandName'] = $val['brand_name'];
|
|
|
$brand['update'] = $val['new_product_num'];
|
|
|
$brand['discount'] = $val['product_discount_num'];
|
|
|
$brand['link'] = Helpers::url('', array(), $val['brand_domain']);
|
|
|
|
|
|
// 处理品牌产品
|
|
|
$product = array();
|
|
|
foreach ($val['new_product'] as $one) {
|
|
|
if (empty($one['product_skn'])) {
|
|
|
continue;
|
|
|
}
|
|
|
do {
|
|
|
// 开始就没获取到数据或者获取的数据为空时的处理
|
|
|
if (!isset($favBrand['data']['brand_list']) && $page == 1) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// 加载第二页以及第二页之后的数据时接口不返回时的处理
|
|
|
if ($page > 1 && !$favBrand) {
|
|
|
$result['end'] = true;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if ($page <= $favBrand['data']['page_total']) {
|
|
|
$datas = array();
|
|
|
$brand = array();
|
|
|
foreach ($favBrand['data']['brand_list'] as $val) {
|
|
|
$brand = array();
|
|
|
$brand['id'] = $val['brand_id'];
|
|
|
$brand['brandImg'] = !empty($val['brand_ico']) ? Images::getImageUrl($val['brand_ico'], 47, 47) : '';
|
|
|
$brand['brandName'] = $val['brand_name'];
|
|
|
$brand['update'] = $val['new_product_num'];
|
|
|
$brand['discount'] = $val['product_discount_num'];
|
|
|
$brand['link'] = Helpers::url('', array(), $val['brand_domain']);
|
|
|
|
|
|
// 处理品牌产品
|
|
|
$product = array();
|
|
|
$product['link'] = isset($one['goods'][0], $one['cnAlphabet']) ? Helpers::url('/product/pro_' . $one['product_id'] . '_' . $one['goods'][0]['id'] . '/' . $one['cnAlphabet'] . '.html') : '';
|
|
|
$product['imgUrl'] = (isset($one['default_images']) && !empty($one['default_images'])) ? Images::getImageUrl($one['default_images'], 235, 314) : '';
|
|
|
$product['price'] = '¥' . Helpers::transPrice($one['market_price']);
|
|
|
$product['discount'] = ($one['market_price'] > $one['sales_price']) ? '¥' . Helpers::transPrice($one['sales_price']) : false;
|
|
|
foreach ($val['new_product'] as $one) {
|
|
|
if (empty($one['product_skn'])) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
$product = array();
|
|
|
$product['link'] = isset($one['goods'][0], $one['cnAlphabet']) ? Helpers::url('/product/pro_' . $one['product_id'] . '_' . $one['goods'][0]['id'] . '/' . $one['cnAlphabet'] . '.html') : '';
|
|
|
$product['imgUrl'] = (isset($one['default_images']) && !empty($one['default_images'])) ? Images::getImageUrl($one['default_images'], 235, 314) : '';
|
|
|
$product['price'] = '¥' . Helpers::transPrice($one['market_price']);
|
|
|
$product['discount'] = ($one['market_price'] > $one['sales_price']) ? '¥' . Helpers::transPrice($one['sales_price']) : false;
|
|
|
|
|
|
$brand['productList'][] = $product;
|
|
|
}
|
|
|
|
|
|
$brand['productList'][] = $product;
|
|
|
$datas[] = $brand;
|
|
|
}
|
|
|
|
|
|
$datas[] = $brand;
|
|
|
if (!empty($datas)) {
|
|
|
$result['hasFavBrand'] = $datas;
|
|
|
}
|
|
|
} else {
|
|
|
$result['end'] = true;
|
|
|
}
|
|
|
!empty($datas) && $result['hasFavBrand'] = $datas;
|
|
|
} else if (($page > 1 && !$favBrand) || $page > $favBrand['data']['page_total']) {
|
|
|
$result['end'] = true;
|
|
|
}
|
|
|
} while (false);
|
|
|
|
|
|
return $result;
|
|
|
}
|
...
|
...
|
|