stanley-king 8 lat temu
rodzic
commit
a99e33077b

+ 39 - 1
helper/activity/bundling.php

@@ -71,7 +71,7 @@ class bundling
                 $bl_id = intval($val['bl_id']);
                 $this->bundling_list[$bl_id] = $val;
                 $this->bundling_goods[$bl_id] = array();
-                $bgoods = $mod->getBundlingGoodsList(array('bl_id' => $bl_id, 'bl_appoint' => 1), 'bl_id,goods_id');
+                $bgoods = $mod->getBundlingGoodsList(array('bl_id' => $bl_id, 'bl_appoint' => 1), 'goods_id,bl_goods_price');
                 foreach ($bgoods as $goods) {
                     $goods_id =intval($goods['goods_id']);
                     array_push($this->bundling_goods[$bl_id],$goods);
@@ -102,6 +102,44 @@ class bundling
         return false;
     }
 
+    private function format($act_id,&$goods_ids)
+    {
+        $val = $this->bundling_list[$act_id];
+
+        $ret['bl_id'] = intval($val['bl_id']);
+        $ret['bl_name'] = $val['bl_name'];
+        $ret['bl_price'] = floatval($val['bl_discount_price']);
+
+        $goods_ids = array();
+
+        $bl_goods = $this->bundling_goods[$act_id];
+        foreach ($bl_goods as $goods)
+        {
+            $goods_id = intval($goods['goods_id']);
+            $item['goods_id'] = $goods_id;
+            $item['bl_goods_price'] = floatval($goods['bl_goods_price']);
+
+            if(algorithm::binary_search($goods_ids,$goods_id) == false) {
+                algorithm::array_insert($goods_ids,$goods_id);
+            }
+
+            $ret['goods'][] = $item;
+        }
+
+        return $ret;
+    }
+
+    public function get_info($act_id,&$goods_ids)
+    {
+        $bl_id = intval($act_id);
+        if(array_key_exists($bl_id,$this->bundling_list) && array_key_exists($bl_id,$this->bundling_goods)) {
+            return $this->format($bl_id,$goods_ids);
+        }
+        else {
+            return false;
+        }
+    }
+
     private function add_goods($goods_id)
     {
         if(algorithm::binary_search($this->goods_ids,$goods_id) == false) {

+ 18 - 11
helper/activity/goods_gift.php

@@ -20,7 +20,6 @@ class goods_gift
 {
     static private $stInstance = null;
     private $cur_version = 0;
-
     private $contents;
 
     private function __construct()
@@ -63,25 +62,33 @@ class goods_gift
             $this->contents = array();
             foreach ($list as $val)
             {
-                $common_id = intval($val['goods_commonid']);
+                $goods_id = intval($val['goods_id']);
                 $giftid = intval($val['gift_goodsid']);
                 $amount = intval($val['gift_amount']);
 
-
-                if(array_key_exists($common_id,$this->contents) == false) {
-                    $this->contents[$common_id] = array();
+                if(array_key_exists($goods_id,$this->contents) == false) {
+                    $this->contents[$goods_id] = array();
                 }
-                $item = array('goods_id' => $giftid,'amount' => $amount);
-                array_push($this->contents[$common_id],$item);
+                $item = array('gift_goods_id' => $giftid,'amount' => $amount);
+                array_push($this->contents[$goods_id],$item);
             }
         }
     }
 
-    public function gifts($common_id)
+    public function gifts($goods_id)
+    {
+        $goods_id = intval($goods_id);
+        if(array_key_exists($goods_id,$this->contents)) {
+            return $this->contents[$goods_id];
+        } else {
+            return false;
+        }
+    }
+    public function have_gift($goods_id)
     {
-        $common_id = intval($common_id);
-        if(array_key_exists($common_id,$this->contents)) {
-            return $this->contents[$common_id];
+        $goods_id = intval($goods_id);
+        if(array_key_exists($goods_id,$this->contents)) {
+            return true;
         } else {
             return false;
         }

+ 2 - 7
helper/activity/limitime.php

@@ -19,13 +19,8 @@ class limit_item
             $this->mParam = $param;
         }
     }
-    static private function img_url($value)
-    {
-        return $value;
-        return cthumb($value['goods_image'], 360, $value['store_id']);
-    }
 
-    public function to_array()
+    public function format()
     {
         $info['xianshi_id']      = intval($this->mParam['xianshi_id']);
         $info['xianshi_name']    = $this->mParam['xianshi_name'];
@@ -136,7 +131,7 @@ class limitime
         if(array_key_exists($act_id,$this->limit_list)) {
             $limit = $this->limit_list[$act_id];
             $item = new limit_item($limit);
-            return $item->to_array();
+            return $item->format();
         }
         else {
             return false;

+ 15 - 14
helper/activity/recommend_combo.php

@@ -14,7 +14,8 @@ class recommend_combo
     static private $stInstance = null;
     private $cur_version = 0;
 
-    private $common_combos;
+    //goods_id 可能包含多个商品形成一个组合
+    private $goods_combos;
 
     private function __construct()
     {
@@ -50,38 +51,38 @@ class recommend_combo
         if($need_reset)
         {
             $mod = Model('goods_combo');
-            $this->common_combos = array();
+            $this->goods_combos = array();
 
-            $list = $mod->getGoodsComboList();
+            $list = $mod->getGoodsComboList(array());
             foreach ($list as $val)
             {
-                $common = intval($val['goods_commonid']);
+                $gid = intval($val['goods_id']);
                 $cgid   = intval($val['combo_goodsid']);
 
-                if(array_key_exists($common,$this->common_combos)) {
-                    array_push($this->common_combos[$common],$cgid);
+                if(array_key_exists($gid,$this->goods_combos)) {
+                    array_push($this->goods_combos[$gid],$cgid);
                 } else {
-                    $this->common_combos[$common] = array($cgid);
+                    $this->goods_combos[$gid] = array($cgid);
                 }
             }
         }
     }
 
-    public function has_combo($commonid)
+    public function have_combo($goods_id)
     {
-        $commonid = intval($commonid);
-        if(array_key_exists($commonid,$this->common_combos)) {
+        $goods_id = intval($goods_id);
+        if(array_key_exists($goods_id,$this->goods_combos)) {
             return true;
         } else {
             return false;
         }
     }
 
-    public function combo_goods($commonid)
+    public function combo_goods($goods_id)
     {
-        $commonid = intval($commonid);
-        if(array_key_exists($commonid,$this->common_combos)) {
-            return $this->common_combos[$commonid];
+        $goods_id = intval($goods_id);
+        if(array_key_exists($goods_id,$this->goods_combos)) {
+            return $this->goods_combos[$goods_id];
         } else {
             return false;
         }

+ 15 - 9
helper/activity_helper.php

@@ -13,9 +13,10 @@ require_once (BASE_ROOT_PATH . '/helper/activity/bundling.php');
 require_once (BASE_ROOT_PATH . '/helper/activity/recommend_combo.php');
 require_once (BASE_ROOT_PATH . '/helper/activity/full_sent.php');
 require_once (BASE_ROOT_PATH . '/helper/activity/recommend_goods.php');
+require_once (BASE_ROOT_PATH . '/helper/activity/goods_gift.php');
 require_once (BASE_ROOT_PATH . '/helper/algorithm.php');
 
-//抢,限,推,三个信息会出现在商品的summary 中,其余的出现在商品的详细信息中
+//抢,限,推,套装,三个信息会出现在商品的summary 中,其余的出现在商品的详细信息中
 class activity_helper
 {
     const ACTIVITY_NONE      = 0;
@@ -48,21 +49,26 @@ class activity_helper
         }
     }
 
+    //赠品信息
+    public static function have_gift($goods_id) {
+        return activity\goods_gift::instance()->have_gift($goods_id);
+    }
+    public static function goods_gifts($goods_id) {
+        return activity\goods_gift::instance()->gifts($goods_id);
+    }
+
     //商品组合
-    public static function has_combo($common_id) {
-        return activity\recommend_combo::instance()->has_combo($common_id);
+    public static function have_combo($goods_id) {
+        return activity\recommend_combo::instance()->have_combo($goods_id);
     }
-    public static function combo_goods($common_id) {
-        return activity\recommend_combo::instance()->combo_goods($common_id);
+    public static function combo_goods($goods_id) {
+        return activity\recommend_combo::instance()->combo_goods($goods_id);
     }
     //满赠活动
     public static function fullsent_contents() {
         return activity\full_sent::instance()->contents();
     }
-    //赠品信息
-    public static function goods_gifts($common_id) {
-        return activity\goods_gift::instance()->gifts($common_id);
-    }
+
     //推荐商品列表
     public static function recomoned_goodsids()
     {

+ 67 - 51
helper/goods_helper.php

@@ -7,12 +7,13 @@
  */
 require_once (BASE_ROOT_PATH . '/helper/field_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/model_helper.php');
+require_once (BASE_ROOT_PATH . '/helper/activity_helper.php');
 
 class goods_helper
 {
     const fieldstr = 'goods_id,goods_commonid,store_id,brand_id,gc_id,goods_name,goods_price,goods_marketprice,goods_promotion_price,goods_jingle,
                   goods_image,goods_salenum,evaluation_good_star,evaluation_count,goods_storage,goods_storage_alarm,is_virtual,is_presell,
-                  is_fcode,have_gift,goods_mobile_name';
+                  is_fcode,have_gift,goods_mobile_name,goods_spec';
     public function __construct() {
     }
 
@@ -34,19 +35,66 @@ class goods_helper
         return $goods_list;
     }
 
-    public function get_summary($goods_ids)
+    //show_gid => 显示这个sku的详情
+    public function get_spu($common_id,$show_gid,&$err)
+    {
+        $err = errcode::Success;
+
+        $common_id = intval($common_id);
+        $mod = Model('goods');
+        $common_info = $mod->getGoodeCommonInfoByID($common_id);
+        if(empty($common_info)) {
+            $err = errcode::ErrParamter;
+            return false;
+        }
+
+        $goods_list = $mod->getGoodsOnlineList(array('goods_commonid' => $common_id),self::fieldstr);
+        if(empty($goods_list)) {
+            $err = errcode::ErrParamter;
+            return false;
+        }
+
+        $ret = array();
+        $gcommon = new goods_common($common_info,$goods_list,$show_gid);
+        $ret['common_info'] = $gcommon->format();
+
+        $ret_summary = $this->do_summary($goods_list,$related_goods);
+        $summary = $ret_summary['summary'];
+
+        if(!empty($related_goods)) {
+            $ret_related = $this->get_summary($related_goods,$x);
+            $summary = array_merge($summary,$ret_related['summary']);
+        }
+
+        $ret['goods_summary'] = $summary;
+        $ret['groupbuy'] = $ret_summary['groupbuy'];
+        $ret['limitime'] = $ret_summary['limitime'];
+        $ret['bundling'] = $ret_summary['bundling'];
+
+        return $ret;
+    }
+
+    public function get_summary($goods_ids,&$related_goods)
     {
         $goods_list = Model('goods')->cls()->getGoodsOnlineList(array('goods_id' => array('in', $goods_ids)),self::fieldstr);
+        return $this->do_summary($goods_list,$related_goods);
+    }
 
+    private function do_summary($goods_list,&$related_goods)
+    {
+        $related_goods = array();
         $summary_list = array();
         foreach ($goods_list as $goods) {
             $summary = new goods_summary($goods);
-            $info = $summary->to_array($act_type,$act_id);
+            $info = $summary->format($act_type,$act_id);
             array_push($summary_list,$info);
+            $related_goods = array_merge($related_goods,$summary->related_goods());
         }
+        $related_goods = array_unique($related_goods);
 
         $gbuys = array();
         $ltimes = array();
+        $bundling = array();
         foreach ($summary_list as $summary)
         {
             $act_id   = intval($summary['act_id']);
@@ -66,6 +114,15 @@ class goods_helper
                     $ltimes[$act_id] = $info;
                 }
             }
+            elseif($act_type == activity_helper::ACTIVITY_BUNDLING)
+            {
+                if(array_key_exists($act_id,$ltimes) == false) {
+                    $info = activity\bundling::instance()->get_info($act_id,$goods_ids);
+                    $bundling[$act_id] = $info;
+                    $related_goods = array_merge($related_goods,$goods_ids);
+                    $related_goods = array_unique($related_goods);
+                }
+            }
         }
 
         $ret = array();
@@ -81,6 +138,11 @@ class goods_helper
             array_push($ret['limitime'],$val);
         }
 
+        $ret['bundling'] = array();
+        foreach ($bundling as $key => $val) {
+            array_push($ret['bundling'],$val);
+        }
+
         return $ret;
     }
 
@@ -90,31 +152,11 @@ class goods_helper
     private function goods_list_extend($goods_list)
     {
         if(empty($goods_list)) return $goods_list;
-        $commonid_array = array_column($goods_list,'goods_commonid');
-        $goodsid_array = array_column($goods_list,'goods_commonid');
-
-        //促销
-        $groupbuy_list = Model('groupbuy')->getGroupbuyListByGoodsCommonIDString(implode(',', $commonid_array));
-        $xianshi_list = Model('p_xianshi_goods')->getXianshiGoodsListByGoodsString(implode(',', $goodsid_array));
 
         foreach ($goods_list as $key => &$value)
         {
-            //抢购
-            if (isset($groupbuy_list[$value['goods_commonid']])) {
-                $value['goods_price'] = $groupbuy_list[$value['goods_commonid']]['groupbuy_price'];
-                $value['group_flag'] = true;
-            } else {
-                $value['group_flag'] = false;
-            }
-
-            //限时折扣
-            if (isset($xianshi_list[$value['goods_id']]) && !$value['group_flag']) {
-                $value['goods_price'] = $xianshi_list[$value['goods_id']]['xianshi_price'];
-                $value['xianshi_flag'] = true;
-            } else {
-                $value['xianshi_flag'] = false;
-            }
-
+            $value['group_flag'] = false;
+            $value['xianshi_flag'] = false;
             //商品图片url
             $value['goods_image_url'] = cthumb($value['goods_image'], 360, $value['store_id']);
             $value['goods_state'] = 1;
@@ -127,30 +169,4 @@ class goods_helper
         }
         return $goods_list;
     }
-
-    private function parse_efficacy($goods_attr)
-    {
-        if(is_null($goods_attr)) return array();
-
-        foreach ($goods_attr as $key => $val)
-        {
-            $attr_item['goods_attr_id'] = intval($key);
-            $attr_item['goods_attr_name'] = $val['name'];
-            if ($attr_item['goods_attr_name'] === '功效')
-            {
-                $goods_attr_value = array();
-                foreach ($val as $id => $name)
-                {
-                    if ($id !== 'name') {
-                        $val_item['value_id'] = intval($id);
-                        $val_item['value_name'] = $name;
-                        array_push($goods_attr_value, $val_item);
-                    }
-                }
-                $attr_item['goods_attr_value'] = $goods_attr_value;
-                break;
-            }
-        }
-        return $attr_item;
-    }
 }

+ 200 - 0
helper/model/goods_common.php

@@ -0,0 +1,200 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 16/8/25
+ * Time: 下午4:18
+ */
+
+
+abstract class common_base
+{
+    protected $commonid;
+    protected $common_info;
+    protected $store_id;
+
+    public function __construct($param)
+    {
+        if (is_array($param)) {
+            $this->common_info = $param;
+            $this->commonid = intval($this->common_info['goods_commonid']);
+            $this->store_id = intval($this->common_info['store_id']);
+        }
+    }
+
+    public abstract function format();
+}
+
+class common_sumary extends common_base
+{
+    public function __construct($param)
+    {
+        parent::__construct($param);
+    }
+
+    public function format()
+    {
+        $ret['goods_commonid'] = intval($this->common_info['goods_commonid']);
+        $ret['goods_commend'] = intval($this->common_info['goods_jingle']);
+        $ret['brand_id'] = intval($this->common_info['brand_id']);
+        $ret['brand_name'] = $this->common_info['brand_name'];
+        $ret['type_id'] = intval($this->common_info['type_id']);
+        $ret['gc_id'] = intval($this->common_info['gc_id_3']);
+        $ret['goods_selltime'] = intval($this->common_info['goods_selltime']);
+        $ret['goods_freight'] = doubleval($this->common_info['goods_freight']);
+
+        return $ret;
+    }
+}
+
+class common_spec extends common_base
+{
+    private $have_spec;
+    private $spec_name;
+    private $spec_list;
+    private $def_goods;
+    private $attr_list;
+
+    public function __construct($param,$goods_list)
+    {
+        parent::__construct($param);
+
+        $spec_name = unserialize($this->common_info['spec_name']);
+        if(empty($spec_name)) {
+            $this->have_spec = false;
+            $this->spec_name = '';
+
+        }
+        else
+        {
+            $this->have_spec = true;
+            foreach ($spec_name as $spid => $spname) {
+                $this->spec_name = $spname;
+                break;
+            }
+        }
+
+        $spec_value = unserialize($this->common_info['spec_value']);
+        if(!empty($spec_value))
+        {
+            foreach ($spec_value as $sp_id => $sp_val)
+            {
+                foreach ($sp_val as $spv_id => $spv_name)
+                {
+                    $this->spec_list[$spv_id]['spv_name'] = $spv_name;
+                }
+            }
+        }
+        else
+        {
+            $this->spec_list = array();
+        }
+
+        foreach ($goods_list as $value)
+        {
+            $goods_id = intval($value['goods_id']);
+            if(!isset($this->def_goods)) {
+                $this->def_goods = $goods_id;
+            }
+            $spec = unserialize($value['goods_spec']);
+            if(!empty($spec))
+            {
+                foreach ($spec as $spv_id => $spv_name)
+                {
+                    $this->spec_list[$spv_id]['goods_id'] = $goods_id;
+                }
+            }
+        }
+
+        $attrs = unserialize($this->common_info['goods_attr']);
+        foreach ($attrs as $key => $val)
+        {
+            foreach ($val as $attr_key => $attr_val)
+            {
+                if($attr_key == "name") {
+                    $name = $attr_val;
+                } else {
+                    $value = $attr_val;
+                }
+            }
+            $this->attr_list[] = array("name" => $name,"value" => $value);
+        }
+    }
+
+    public function format()
+    {
+        $ret['have_spec'] = $this->have_spec;
+        $ret['spec_name'] = $this->spec_name;
+        $ret['skus'] = array();
+        foreach ($this->spec_list as $key => $value) {
+            array_push($ret['skus'],$value);
+        }
+        $ret['goods_id'] = $this->def_goods;
+        $ret['attrs'] = $this->attr_list;
+
+        return $ret;
+    }
+}
+
+class goods_common extends common_base
+{
+    private $goods_list;
+    private $goods_ids;
+    private $show_gid;
+
+    public function __construct($common_info,$goods_list,$show_gid)
+    {
+        parent::__construct($common_info);
+        $this->goods_list = $goods_list;
+        $this->goods_ids = $this->goods_ids();
+        $show_gid = intval($show_gid);
+        if(in_array($show_gid,$this->goods_ids)) {
+            $this->show_gid = $show_gid;
+        } else {
+            $this->show_gid = $this->goods_ids[0];
+        }
+    }
+
+    public function goods_ids()
+    {
+        $ids = array();
+        foreach ($this->goods_list as $value) {
+            $gid = intval($value['goods_id']);
+            array_push($ids,$gid);
+        }
+        return $ids;
+    }
+    static private function img_url($value,$store_id)
+    {
+        return cthumb($value, 360, $store_id);
+    }
+
+    private function goods_images()
+    {
+        $mod = Model('goods');
+        $items = $mod->getGoodsImageListEx(array('goods_commonid' => $this->commonid));
+
+        $images = array();
+        foreach ($items as $val) {
+            $img = $val['goods_image'];
+            $images[] = self::img_url($img,$this->store_id);
+        }
+        return $images;
+    }
+
+    public function format()
+    {
+        $summary = new common_sumary($this->common_info);
+        $base_info = $summary->format();
+
+        $goods_spec = new common_spec($this->common_info,$this->goods_list);
+        $spec = $goods_spec->format();
+
+        $ret = array_merge($base_info,$spec);
+        $ret['images'] = $this->goods_images();
+        $ret['show_goods'] = $this->show_gid;
+
+        return $ret;
+    }
+}

+ 35 - 5
helper/model/goods_summary.php

@@ -40,12 +40,12 @@ class goods_summary
         return $this->goods_commonid;
     }
 
-    static private function img_url($value)
+    static private function img_url($value,$store_id)
     {
-        return cthumb($value, 360, $value['store_id']);
+        return cthumb($value, 360, $store_id);
     }
 
-    public function to_array(&$act_type,&$act_id)
+    public function format(&$act_type, &$act_id)
     {
         $summary['goods_id'] = intval($this->goods_info['goods_id']);
         $summary['goods_commonid'] = intval($this->goods_info['goods_commonid']);
@@ -57,7 +57,7 @@ class goods_summary
         $summary['goods_price'] = $this->goods_info['goods_price'];
         $summary['goods_marketprice'] = $this->goods_info['goods_marketprice'];
         $summary['goods_promotion_price'] = $this->goods_info['goods_promotion_price'];
-        $summary['goods_image_url'] = self::img_url($this->goods_info['goods_image']);
+        $summary['goods_image_url'] = self::img_url($this->goods_info['goods_image'],$this->goods_info['store_id']);
 
         //begin——为兼容以前版本协议
         $summary['goods_state'] = 1;
@@ -66,7 +66,22 @@ class goods_summary
 
         $summary['goods_salenum'] = intval($this->goods_info['goods_salenum']);
         $summary['goods_storage'] = intval($this->goods_info['goods_storage']);
-        $summary['have_gift'] = boolval($this->goods_info['have_gift']);
+
+        $have_gift = boolval($this->goods_info['have_gift']);
+        $summary['have_gift'] = $have_gift;
+        if($have_gift) {
+            $summary['gifts'] = activity_helper::goods_gifts($this->goods_id);
+        } else {
+            $summary['gifts'] = array();
+        }
+
+        $have_combo = activity_helper::have_combo($this->goods_id);
+        $summary['have_combo'] = $have_combo;
+        if($have_combo) {
+            $summary['combos'] = activity_helper::combo_goods($this->goods_id);
+        } else {
+            $summary['combos'] = array();
+        }
 
         $act_id = activity_helper::take_parted($this->goods_id,$act_type);
         if($act_id == false) {
@@ -80,4 +95,19 @@ class goods_summary
 
         return $summary;
     }
+
+    public function related_goods()
+    {
+        $combos = array();
+        $gifts = array();
+
+        if(activity_helper::have_combo($this->goods_id)) {
+            $combos = activity_helper::combo_goods($this->goods_id);
+        }
+        if(activity_helper::have_gift($this->goods_id)) {
+            $gifts = activity_helper::goods_gifts($this->goods_id);
+        }
+        $ret = array_merge($combos,$gifts);
+        return array_unique($ret);
+    }
 }

+ 1 - 0
helper/model_helper.php

@@ -10,3 +10,4 @@ require_once (BASE_ROOT_PATH . "/helper/model/member_info.php");
 require_once (BASE_ROOT_PATH . "/helper/model/order.php");
 require_once (BASE_ROOT_PATH . "/helper/model/ranklist.php");
 require_once (BASE_ROOT_PATH . "/helper/model/goods_summary.php");
+require_once (BASE_ROOT_PATH . "/helper/model/goods_common.php");

+ 0 - 1
mobile/control/cart.php

@@ -71,7 +71,6 @@ class cartControl extends mobileControl
                "class_id","s_class_id","is_vr","vr_city_id","vr_area_id","vr_mall_id","vr_class_id","vr_s_class_id","groupbuy_url","goods_url","start_time_text",
                "end_time_text","groupbuy_state_text","reviewable","cancelable","state_flag","button_text","count_down_text","count_down","groupbuy_intro");
 
-
         if(is_array($goods_info))
         {
             $store_id = $goods_info['store_id'];

+ 0 - 32
mobile/control/goods.php

@@ -669,38 +669,6 @@ class goodsControl extends mobileControl
         return $goods_spec_obj;
     }
 
-    /**
-     * 商品详细页(未启用)
-     */
-    public function goods_bodyOp()
-    {
-        return joutput_error(errcode::ErrProtocolDisabled);
-
-        $goods_id = intval($_GET ['goods_id']);
-        $out_type = $_GET ['type'];
-        $model_goods = Model('goods');
-
-        if (empty($_GET ['goods_commonid'])) {
-            $goods_info = $model_goods->getGoodsInfoByID($goods_id, 'goods_commonid');
-        } else {
-            $goods_info['goods_commonid'] = intval($_GET ['goods_commonid']);
-        }
-        $goods_common_info = $model_goods->getGoodeCommonInfoByID($goods_info['goods_commonid']);
-
-        if ($out_type === 'json') {
-            $goods_common_info['goods_attr'] = $this->_parse_attributes(unserialize($goods_common_info['goods_attr']));
-            $goods_common_info['spec_name'] = unserialize($goods_common_info['spec_name']);
-            $goods_common_info['spec_value'] = unserialize($goods_common_info['spec_value']);
-            $goods_common_info['spec'] = $this->_parse_spec($goods_common_info['spec_name'], $goods_common_info['spec_value']);
-            $goods_common_info['goods_body'] = ''; //base64_encode($goods_common_info['goods_body']);
-            $goods_common_info['mobile_body'] = '';//base64_encode($goods_common_info['mobile_body']);
-            joutput_data($goods_common_info);
-        } else {
-            Tpl::output('goods_common_info', $goods_common_info);
-            Tpl::showpage('goods_body');
-        }
-    }
-
     public function detailOp()
     {
         $commonid = 0;

+ 40 - 0
mobile/control/goods_common.php

@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 16/8/24
+ * Time: 下午10:49
+ */
+
+require_once (BASE_ROOT_PATH . "/helper/goods_helper.php");
+require_once (BASE_ROOT_PATH . "/helper/activity_helper.php");
+
+class goods_commonControl extends mobileControl
+{
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    public function indexOp()
+    {
+        $common_id = intval($_GET['goods_commonid']);
+        $goods_id = intval($_GET['goods_id']);
+
+        if($common_id > 0 && $goods_id > 0)
+        {
+            $helper = new goods_helper();
+            $ret = $helper->get_spu($common_id,$goods_id,$err);
+            if($ret == false) {
+                return self::outerr($err);
+            }
+            else {
+                return self::outsuccess($ret);
+            }
+        }
+        else {
+            return self::outerr(errcode::ErrParamter,"请输入正确的参数.");
+        }
+    }
+}

+ 3 - 2
mobile/control/index.php

@@ -231,7 +231,7 @@ class indexControl extends mobileHomeControl
     public function show_goodsOp()
     {
         //1603
-        $goods_ids = array(4173,3844,4103,4110,4119,4120,4121,1603);
+        $goods_ids = array(2,4173,3844,4103,4110,4119,4120,4121,1603);
         //$goods_ids = array(1269,4127,4217);
 
         $ret = array_chunk($goods_ids,$this->page_size());
@@ -240,10 +240,11 @@ class indexControl extends mobileHomeControl
         $goods_ids = $ret[$page_no - 1];
 
         $helper = new goods_helper();
-        $ret = $helper->get_summary($goods_ids);
+        $ret = $helper->get_summary($goods_ids,$other_goods);
         self::outsuccess(array('goods_list' => $ret['summary'],
             'groupbuy' => $ret['groupbuy'],
             'limitime' => $ret['limitime'],
+            'bundling' => $ret['bundling'],
             'mobile_page' => mobile_page($pages)));
     }
 }

+ 6 - 29
test/activity_helperTest.php

@@ -23,41 +23,18 @@ class activity_helperTest extends PHPUnit_Framework_TestCase
     public function testGift()
     {
         $helper = new goods_helper();
-//        $helper->get_summary(array(1269,4127,4217));
-        $helper->get_summary(array(1269));
-
-    }
-
-    public function testGroupbuy()
-    {
-        $activity = new activity_helper();
-        $activity->groupbuy_list();
-    }
-
-    public function testXianshi()
-    {
-        $activity = new activity_helper();
-        $activity->xianshi_list(6);
+        $helper->get_summary(array(4181),$related_goods);
     }
 
-    public function testMansong()
-    {
-        $activity = new activity_helper();
-        $activity->mansong_list(6);
-    }
     public function testBundling()
     {
-        $activity = new activity_helper();
-        $activity->bundling_list(6);
-    }
-    public function testBooth()
-    {
-        $activity = new activity_helper();
-        $activity->booth_list(6);
+        $helper = new goods_helper();
+        $ret = $helper->get_summary(array(2),$related_goods);
     }
 
-    public function testTakepart()
+    public function testSpu()
     {
-        activity_helper::take_parted(30,$type);
+        $helper = new goods_helper();
+        $ret = $helper->get_spu(2629,4182,$err);
     }
 }