Pārlūkot izejas kodu

refactor activity code

stanley-king 8 gadi atpakaļ
vecāks
revīzija
a08ef8c0d1

+ 4 - 4
helper/activity/groupbuy.php

@@ -29,7 +29,7 @@ class group_item
         return cthumb($value, 360, $store_id);
     }
 
-    public function to_array()
+    public function format()
     {
         $info['groupbuy_id']     = intval($this->mParam['groupbuy_id']);
         $info['groupbuy_name']   = $this->mParam['groupbuy_name'];
@@ -166,7 +166,7 @@ class groupbuy
         $result = [];
         foreach ($groups as $val) {
             $item = new group_item($val);
-            $result[] = $item->to_array();
+            $result[] = $item->format();
         }
 
         return $result;
@@ -187,7 +187,7 @@ class groupbuy
         $result = [];
         foreach ($groups as $val) {
             $item = new group_item($val);
-            $result[] = $item->to_array();
+            $result[] = $item->format();
         }
 
         return $result;
@@ -244,7 +244,7 @@ class groupbuy
         if(isset($act_id,$this->group_list[$act_id])) {
             $param = $this->group_list[$act_id];
             $item = new group_item($param);
-            return $item->to_array();
+            return $item->format();
         } else {
             return false;
         }

+ 10 - 4
mobile/control/activity.php

@@ -329,8 +329,9 @@ class limit_outer
 
         $act_id = $act['xianshi_id'];
         $gids = activity_helper::limit_goods($act_id);
-        $goods_ids = array($gids[0]);
+        if(empty($gids)) return false;
 
+        $goods_ids = array($gids[0]);
         $helper = new goods_helper();
         $ret = $helper->online_summary($goods_ids,$related);
 
@@ -363,8 +364,9 @@ class limit_outer
         $act = $this->mAct;
         $act_id = $act['groupbuy_id'];
         $gids = activity_helper::groupbuy_goods($act_id);
-        $goods_ids = array($gids[0]);
+        if(empty($gids)) return false;
 
+        $goods_ids = array($gids[0]);
         $helper = new goods_helper();
         $ret = $helper->online_summary($goods_ids,$related);
 
@@ -425,7 +427,9 @@ class activityControl extends mobileControl
             $act = $acts[0];
             $outer = new limit_outer(limit_outer::WAIT_END,$act);
             $result = $outer->format();
-            return self::outsuccess($result,"activity/limit_entra");
+            if($result != false) {
+                return self::outsuccess($result,"activity/limit_entra");
+            }
         }
 
         $unstarts = activity_helper::unstart();
@@ -433,7 +437,9 @@ class activityControl extends mobileControl
             $act = $unstarts[0];
             $outer = new limit_outer(limit_outer::WAIT_START,$act);
             $result = $outer->format();
-            return self::outsuccess($result,"activity/limit_entra");
+            if($result != false) {
+                return self::outsuccess($result,"activity/limit_entra");
+            }
         }
 
         return self::outsuccess(null,"activity/limit_entra");

+ 1 - 1
test/TestSearch.php

@@ -52,7 +52,7 @@ class TestSearch extends PHPUnit_Framework_TestCase
         $result = $searcher->get_result(array('keyword' => '妮维雅','order' =>'price','sort' => 'desc','page_no' => 1,'page_size' => 10));
 
 
-        $result = $searcher->match_price(array('price' => 1303020.97,'page_no' => 1,'page_size' => 10));
+        $result = $searcher->match_price(array('price' => 9.27,'page_no' => 1,'page_size' => 10));
         $x = 100;
     }
 

+ 2 - 1
test/bonus_helperTest.php

@@ -25,8 +25,9 @@ class bonus_helperTest extends PHPUnit_Framework_TestCase
 
     public function testScaler()
     {
-        $scaler = new \bonus\scaler([10 => 10,100 => 100,50 => 50, 30 => 30]);
+        //$scaler = new \bonus\scaler([10 => 10,100 => 100,50 => 50, 30 => 30]);
         //$scaler = new \bonus\scaler([10 => 10,50 => 50, 20 => 60,100 => 100]);
+        $scaler = new \bonus\scaler([30 => 0.62,100 => 1.26]);
         $ret = $scaler->calc();
     }
     public function testModel()