|
@@ -6,6 +6,113 @@
|
|
|
* Time: 下午4:45
|
|
|
*/
|
|
|
|
|
|
+require_once(BASE_ROOT_PATH . '/helper/activity_helper.php');
|
|
|
+require_once(BASE_ROOT_PATH . '/helper/goods_helper.php');
|
|
|
+
|
|
|
+class act_formater
|
|
|
+{
|
|
|
+ private $mActivities;
|
|
|
+
|
|
|
+ public function __construct($activities)
|
|
|
+ {
|
|
|
+ $this->mActivities = $activities;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function format()
|
|
|
+ {
|
|
|
+ $specials = [];
|
|
|
+ $goods_ids = [];
|
|
|
+ foreach ($this->mActivities as $act)
|
|
|
+ {
|
|
|
+ if(array_key_exists('xianshi_id',$act))
|
|
|
+ {
|
|
|
+ $specials[] = $this->format_limit($act,$gids);
|
|
|
+ self::array_copy($goods_ids,$gids);
|
|
|
+ }
|
|
|
+ elseif(array_key_exists('groupbuy_id',$act))
|
|
|
+ {
|
|
|
+ $specials[] = $this->format_groupbuy($act,$gids);
|
|
|
+ self::array_copy($goods_ids,$gids);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $goods_ids = array_unique($goods_ids);
|
|
|
+ if(!empty($goods_ids))
|
|
|
+ {
|
|
|
+ $helper = new goods_helper();
|
|
|
+ $ret = $helper->get_summary($goods_ids,$related);
|
|
|
+
|
|
|
+ return array('special_list' => $specials,
|
|
|
+ 'summary' => $ret['summary'],
|
|
|
+ 'groupbuy' => $ret['groupbuy'],
|
|
|
+ 'limitime' => $ret['limitime'],
|
|
|
+ 'bundling' => $ret['bundling'],
|
|
|
+ 'mobile_page' => mobile_page(1));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return array('special_list' => null,
|
|
|
+ 'summary' => null,
|
|
|
+ 'groupbuy' => null,
|
|
|
+ 'limitime' => null,
|
|
|
+ 'bundling' => null,
|
|
|
+ 'mobile_page' => mobile_page(1));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private function format_limit($limt,&$gids)
|
|
|
+ {
|
|
|
+ $result =[];
|
|
|
+
|
|
|
+ $limt_id = intval($limt['xianshi_id']);
|
|
|
+ $result['item_title'] = strval($limt_id);
|
|
|
+ $result['item_type'] = 'home_limit';
|
|
|
+
|
|
|
+ $gids = activity_helper::limit_goods($limt_id);
|
|
|
+ if(empty($gids)) return array();
|
|
|
+ foreach ($gids as $gid) {
|
|
|
+ $item['type'] = 'goods';
|
|
|
+ $item['data'] = strval($gid);
|
|
|
+ $item['image'] = '';
|
|
|
+ $item['title'] = '';
|
|
|
+
|
|
|
+ $result['items'][] = $item;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function format_groupbuy($group, &$gids)
|
|
|
+ {
|
|
|
+ $result =[];
|
|
|
+
|
|
|
+ $act_id = intval($group['groupbuy_id']);
|
|
|
+ $result['item_title'] = strval($act_id);
|
|
|
+ $result['item_type'] = 'home_group';
|
|
|
+
|
|
|
+ $gids = activity_helper::groupbuy_goods($act_id);
|
|
|
+ if(empty($gids)) return array();
|
|
|
+ foreach ($gids as $gid) {
|
|
|
+ $item['type'] = 'goods';
|
|
|
+ $item['data'] = strval($gid);
|
|
|
+ $item['image'] = '';
|
|
|
+ $item['title'] = '';
|
|
|
+
|
|
|
+ $result['items'][] = $item;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static function array_copy(&$dest,$src)
|
|
|
+ {
|
|
|
+ if(empty($src)) return $dest;
|
|
|
+ foreach ($src as $value) {
|
|
|
+ array_push($dest,$value);
|
|
|
+ }
|
|
|
+ return $dest;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
class activityControl extends mobileControl
|
|
|
{
|
|
|
public function __construct()
|
|
@@ -13,6 +120,23 @@ class activityControl extends mobileControl
|
|
|
parent::__construct();
|
|
|
}
|
|
|
|
|
|
+ public function actingOp()
|
|
|
+ {
|
|
|
+ $actings = activity_helper::acting();
|
|
|
+ $formater = new act_formater($actings);
|
|
|
+ $result = $formater->format();
|
|
|
+
|
|
|
+ return self::outsuccess($result);
|
|
|
+ }
|
|
|
+ public function unstartOp()
|
|
|
+ {
|
|
|
+ $actings = activity_helper::unstart();
|
|
|
+ $formater = new act_formater($actings);
|
|
|
+ $result = $formater->format();
|
|
|
+
|
|
|
+ return self::outsuccess($result);
|
|
|
+ }
|
|
|
+
|
|
|
public function limit_entraOp()
|
|
|
{
|
|
|
$_SESSION['client_type'] = "wap";
|