|
@@ -12,16 +12,19 @@ require_once(BASE_ROOT_PATH . '/helper/goods_helper.php');
|
|
|
class act_formater
|
|
|
{
|
|
|
private $mActivities;
|
|
|
+ private $mGoodsActContainer;
|
|
|
|
|
|
public function __construct($activities)
|
|
|
{
|
|
|
$this->mActivities = $activities;
|
|
|
+ $this->mGoodsActContainer = [];
|
|
|
}
|
|
|
|
|
|
- public function format()
|
|
|
+ public function format_acting()
|
|
|
{
|
|
|
$specials = [];
|
|
|
$goods_ids = [];
|
|
|
+
|
|
|
foreach ($this->mActivities as $act)
|
|
|
{
|
|
|
if(array_key_exists('xianshi_id',$act))
|
|
@@ -56,7 +59,82 @@ class act_formater
|
|
|
'bundling' => null,
|
|
|
'mobile_page' => mobile_page(1));
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ public function format_unstart()
|
|
|
+ {
|
|
|
+ $specials = [];
|
|
|
+ $goods_ids = [];
|
|
|
+
|
|
|
+ $group_ids = [];
|
|
|
+ $limit_ids = [];
|
|
|
+
|
|
|
+ foreach ($this->mActivities as $act)
|
|
|
+ {
|
|
|
+ if(array_key_exists('xianshi_id',$act))
|
|
|
+ {
|
|
|
+ $limit_ids[] = intval($act['xianshi_id']);
|
|
|
+ $specials[] = $this->format_limit($act,$gids);
|
|
|
+ self::array_copy($goods_ids,$gids);
|
|
|
+ }
|
|
|
+ elseif(array_key_exists('groupbuy_id',$act))
|
|
|
+ {
|
|
|
+ $group_ids[] = intval($act['groupbuy_id']);
|
|
|
+ $specials[] = $this->format_groupbuy($act,$gids);
|
|
|
+ self::array_copy($goods_ids,$gids);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Log::record("an error activity.",Log::ERR);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $goods_ids = array_unique($goods_ids);
|
|
|
+ if(!empty($goods_ids))
|
|
|
+ {
|
|
|
+ $helper = new goods_helper();
|
|
|
+ $ret = $helper->get_summary($goods_ids,$related);
|
|
|
|
|
|
+ $summarys = $ret['summary'];
|
|
|
+ foreach ($summarys as &$summary) {
|
|
|
+ $goods_id = $summary['goods_id'];
|
|
|
+ $act = $this->mGoodsActContainer[$goods_id];
|
|
|
+ $summary['act_id'] = $act['act_id'];
|
|
|
+ $summary['act_type'] = $act['act_type'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $groups = [];
|
|
|
+ foreach ($group_ids as $group_id)
|
|
|
+ {
|
|
|
+ $item = activity\groupbuy::instance()->get_info($group_id);
|
|
|
+ if($item != false) {
|
|
|
+ $groups[] = $item;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $limits = [];
|
|
|
+ foreach ($limit_ids as $limit_id)
|
|
|
+ {
|
|
|
+ $item = activity\limitime::instance()->get_info($limit_id);
|
|
|
+ if($item != false) {
|
|
|
+ $limits[] = $item;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return array('special_list' => $specials,
|
|
|
+ 'summary' => $summarys,
|
|
|
+ 'groupbuy' => $groups,
|
|
|
+ 'limitime' => $limits,
|
|
|
+ '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)
|
|
@@ -74,8 +152,9 @@ class act_formater
|
|
|
$item['data'] = strval($gid);
|
|
|
$item['image'] = '';
|
|
|
$item['title'] = '';
|
|
|
-
|
|
|
$result['items'][] = $item;
|
|
|
+
|
|
|
+ $this->mGoodsActContainer[$gid] = array('act_id' => $limt_id,'act_type' => activity_helper::ACTIVITY_LIMITTIME);
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
@@ -98,6 +177,7 @@ class act_formater
|
|
|
$item['title'] = '';
|
|
|
|
|
|
$result['items'][] = $item;
|
|
|
+ $this->mGoodsActContainer[$gid] = array('act_id' => $act_id,'act_type' => activity_helper::ACTIVITY_GROUPBUY);
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
@@ -124,7 +204,7 @@ class activityControl extends mobileControl
|
|
|
{
|
|
|
$actings = activity_helper::acting();
|
|
|
$formater = new act_formater($actings);
|
|
|
- $result = $formater->format();
|
|
|
+ $result = $formater->format_acting();
|
|
|
|
|
|
return self::outsuccess($result);
|
|
|
}
|
|
@@ -132,7 +212,7 @@ class activityControl extends mobileControl
|
|
|
{
|
|
|
$actings = activity_helper::unstart();
|
|
|
$formater = new act_formater($actings);
|
|
|
- $result = $formater->format();
|
|
|
+ $result = $formater->format_unstart();
|
|
|
|
|
|
return self::outsuccess($result);
|
|
|
}
|