|
@@ -12,8 +12,12 @@
|
|
|
|
|
|
defined('InShopNC') or exit('Access Invalid!');
|
|
|
|
|
|
+require_once (BASE_ROOT_PATH . '/helper/goods_helper.php');
|
|
|
+require_once (BASE_ROOT_PATH . '/helper/special_helper.php');
|
|
|
+
|
|
|
class member_favoritesControl extends mbMemberControl
|
|
|
{
|
|
|
+ static $stTypes = array('goods','brand');
|
|
|
|
|
|
public function __construct()
|
|
|
{
|
|
@@ -22,34 +26,78 @@ class member_favoritesControl extends mbMemberControl
|
|
|
|
|
|
public function indexOp()
|
|
|
{
|
|
|
- $model_favorites = Model('favorites');
|
|
|
- $favorites_list = $model_favorites->getGoodsFavoritesList(array('member_id' => $_SESSION['member_id']), '*', $this->page_size);
|
|
|
- $page_count = $model_favorites->gettotalpage();
|
|
|
- $favorites_id = '';
|
|
|
- foreach ($favorites_list as $value) {
|
|
|
- $favorites_id .= $value['fav_id'] . ',';
|
|
|
+ $mod_favorites = Model('favorites');
|
|
|
+ $favorites = $mod_favorites->getGoodsFavoritesList(array('member_id' => $_SESSION['member_id']), '*', $this->page_size);
|
|
|
+ $page_count = $mod_favorites->gettotalpage();
|
|
|
+
|
|
|
+ $gids = [];
|
|
|
+ foreach ($favorites as $item)
|
|
|
+ {
|
|
|
+ if($item['fav_type'] == 'goods') {
|
|
|
+ $gids[] = intval($item['fav_id']);
|
|
|
+ }
|
|
|
+ elseif($item['fav_type'] == 'brand') {
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
- $favorites_id = rtrim($favorites_id, ',');
|
|
|
-
|
|
|
- $model_goods = Model('goods');
|
|
|
- $field = 'goods_id,goods_name,goods_price,goods_image,store_id';
|
|
|
- $goods_list = $model_goods->getGoodsList(array('goods_id' => array('in', $favorites_id)), $field);
|
|
|
- foreach ($goods_list as $key => $value) {
|
|
|
- $goods_list[$key]['fav_id'] = $value['goods_id'];
|
|
|
- $goods_list[$key]['goods_image_url'] = cthumb($value['goods_image'], 240, $value['store_id']);
|
|
|
+
|
|
|
+ if(empty($gids))
|
|
|
+ {
|
|
|
+ return self::outsuccess(array('special_list' => null,
|
|
|
+ 'summary' => null,
|
|
|
+ 'groupbuy' => null,
|
|
|
+ 'limitime' => null,
|
|
|
+ 'bundling' => null,
|
|
|
+ 'mobile_page' => mobile_page($page_count)));
|
|
|
}
|
|
|
|
|
|
- output_data(array('favorites_list' => $goods_list), mobile_page($page_count));
|
|
|
+ $helper = new goods_helper();
|
|
|
+ $ret = $helper->cart_summary($gids,$related_goods);
|
|
|
+ $blocks = $this->format($gids,$ret['sort_summary']);
|
|
|
+
|
|
|
+ return self::outsuccess(array('special_list' => $blocks,
|
|
|
+ 'summary' => $ret['summary'],
|
|
|
+ 'groupbuy' => $ret['groupbuy'],
|
|
|
+ 'limitime' => $ret['limitime'],
|
|
|
+ 'bundling' => $ret['bundling'],
|
|
|
+ 'mobile_page' => mobile_page($page_count)));
|
|
|
}
|
|
|
|
|
|
- public function addOp()
|
|
|
+ private function format($goods_ids,$sort_summary)
|
|
|
{
|
|
|
- static $stTypes = array('goods','brands');
|
|
|
+ $result = [];
|
|
|
|
|
|
+ foreach ($goods_ids as $goods_id)
|
|
|
+ {
|
|
|
+ $block = [];
|
|
|
+ $block['item_title'] = '';
|
|
|
+ $block['item_type'] = 'home1';
|
|
|
+
|
|
|
+ $summary = $sort_summary[$goods_id];
|
|
|
+ $item['image'] = $summary['goods_image_url'];
|
|
|
+ $item['show_type'] = "favorite";
|
|
|
+ $item['show_data'] = strval($goods_id);
|
|
|
+ $item['type'] = "goods";
|
|
|
+ $item['data'] = strval($goods_id);
|
|
|
+ $item['title'] = $summary['goods_mobile_name'];
|
|
|
+
|
|
|
+ $block['items'][] = $item;
|
|
|
+ $result[] = $block;
|
|
|
+ $result[] = special_formater::def_divider();
|
|
|
+ }
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addOp()
|
|
|
+ {
|
|
|
$fav_type = $_POST['fav_type'];
|
|
|
- $fav_id = intval($_POST['data_id']);
|
|
|
+ $fav_id = intval($_POST['fav_id']);
|
|
|
|
|
|
- if ($fav_id <= 0 || empty($fav_type) || !in_array($fav_type,$stTypes)) {
|
|
|
+ if ($fav_id <= 0 || empty($fav_type) || !in_array($fav_type,self::$stTypes)) {
|
|
|
return self::outerr(errcode::ErrParamter,"参数错误");
|
|
|
}
|
|
|
|
|
@@ -82,20 +130,23 @@ class member_favoritesControl extends mbMemberControl
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public function delOp()
|
|
|
{
|
|
|
$fav_id = intval($_POST['fav_id']);
|
|
|
- if ($fav_id <= 0) {
|
|
|
+ $fav_type = $_POST['fav_type'];
|
|
|
+
|
|
|
+ if ($fav_id <= 0 || empty($fav_type) || !in_array($fav_type,self::$stTypes)) {
|
|
|
return self::outerr(errcode::ErrParamter,"参数错误");
|
|
|
}
|
|
|
|
|
|
$model_favorites = Model('favorites');
|
|
|
- $ret = $model_favorites->delFavorites(array('autofv_id' => $fav_id,'member_id' => $_SESSION['member_id']));
|
|
|
+ $ret = $model_favorites->delFavorites(array('fav_id' => $fav_id,'fav_type' => $fav_type, 'member_id' => $_SESSION['member_id']));
|
|
|
if($ret == false) {
|
|
|
return self::outerr(errcode::ErrParamter,"该收藏不存在或者已经被删除.");
|
|
|
}
|
|
|
else {
|
|
|
- return self::outsuccess(null);
|
|
|
+ return self::outsuccess(array('fav_id' => $fav_id));
|
|
|
}
|
|
|
}
|
|
|
}
|