$r_end) { return 1; } elseif($l_end == $r_end) { if($l_type > $r_type) return 1; elseif($l_type < $r_type) return -1; else { if($l_actype > $r_actype) return 1; elseif($l_actype < $r_actype) return -1; else return 0; } } else { return -1; } } function less_startime($left,$right) { $l_start = intval($left['start_time']); $r_start = intval($right['start_time']); $l_type = intval($left['time_type']); $r_type = intval($right['time_type']); $l_actype = $left['act_type']; $r_actype = $left['act_type']; if($l_start > $r_start) { return 1; } elseif($l_start == $r_start) { if($l_type > $r_type) return 1; elseif($l_type < $r_type) return -1; else { if($l_actype > $r_actype) return 1; elseif($l_actype < $r_actype) return -1; else return 0; } } else { return -1; } } //抢,限,推,套装,三个信息会出现在商品的summary 中,其余的出现在商品的详细信息中 class activity_helper { const ACTIVITY_NONE = 0; const ACTIVITY_GROUPBUY = 1; //抢 const ACTIVITY_LIMITTIME = 2; //限 const ACTIVITY_BUNDLING = 3; //套装 public static function take_parted($goods_id,&$act_type) { if(activity\groupbuy::instance()->isTakepart($goods_id,$act_id)) { //抢购 $act_type = self::ACTIVITY_GROUPBUY; return $act_id; } elseif(activity\limitime::instance()->isTakepart($goods_id,$act_id)) { // $act_type = self::ACTIVITY_LIMITTIME; return $act_id; } else { $act_type = self::ACTIVITY_NONE; return false; } } public static function have_recommend($goods_id) { if (activity\recommend_goods::instance()->isTakepart($goods_id)) { return true; } else { return false; } } public static function have_bundling($goods_id) { return activity\bundling::instance()->have_bundling($goods_id); } public static function bundling_goods($bl_id) { return activity\bundling::instance()->bundling_goods($bl_id); } //赠品信息 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 goods_giftids($goods_id) { return activity\goods_gift::instance()->goods_giftids($goods_id); } //商品组合 public static function have_combo($goods_id) { return activity\recommend_combo::instance()->have_combo($goods_id); } public static function combo_goods($goods_id) { return activity\recommend_combo::instance()->combo_goods($goods_id); } //满赠活动 public static function fullsent_rules() { return activity\full_sent::instance()->rules(); } //包邮信息 public static function free_ship() { return activity\full_sent::instance()->free_price(); } //推荐商品列表 public static function recomoned_goodsids() { return activity\recommend_goods::instance()->goods_ids(); } public static function limit_goods($limit_id) { return activity\limitime::instance()->goods($limit_id); } public static function groupbuy_goods($group_id) { return activity\groupbuy::instance()->goods($group_id); } public static function acting() { $limits = activity\limitime::instance()->acting(); $groupbuys = activity\groupbuy::instance()->acting(); $values = []; foreach ($limits as $val) { $val['time_type'] = $val['xianshi_type']; $val['act_type'] = 1; $values[] = $val; } foreach ($groupbuys as $val) { $val['time_type'] = $val['groupbuy_type']; $val['act_type'] = 2; $values[] = $val; } $result = []; if(!empty($values)) { uasort($values,'less_endtime'); foreach ($values as $value) { $result[] = $value; } } return $result; } public static function groupbuy_price($limit_id,&$price) { return activity\groupbuy::instance()->promotion_price($limit_id,$price); } public static function limit_price($limit_id,$goods_id,&$price) { return activity\limitime::instance()->promotion_price($limit_id,$goods_id,$price); } public static function unstart() { $limits = activity\limitime::instance()->unstart(); $groupbuys = activity\groupbuy::instance()->unstart(); $values = []; foreach ($limits as $val) { $values[] = $val; } foreach ($groupbuys as $val) { $values[] = $val; } $result = []; if(!empty($values)) { uasort($values,'less_startime'); foreach ($values as $value) { $result[] = $value; } } return $result; } }