Ver código fonte

modify birthday return type

stanley-king 9 anos atrás
pai
commit
f737522bf4

+ 8 - 5
core/framework/core/base.php

@@ -7,6 +7,8 @@
  */
 defined('InShopNC') or exit('Access Invalid!');
 
+require_once (BASE_ROOT_PATH . '/helper/performance_helper.php');
+
 final class Base
 {
 	const CPURL = '';
@@ -96,13 +98,13 @@ final class Base
 		$class_name = $_GET['act'].'Control';
 
 		if (!file_exists($act_file) || !@require_once($act_file)) {
-			throw new Exception("Base Error: access file isn't exists!");
+			throw new Exception("Base Error: access file={$act_file} isn't exists!");
 		}
 
 		if(class_exists($class_name)) {
 			$main = new $class_name();
 		} else {
-			$error = "Base Error: class $class_name isn't exists!";
+			$error = "Base Error: class {$class_name} isn't exists!";
 			throw new Exception($error);
 		}
 
@@ -114,11 +116,11 @@ final class Base
 			} elseif (method_exists($main,'indexOp')) {
 				$main->indexOp();
 			} else {
-				$error = "Base Error: function $function not in $class_name!";
+				$error = "Base Error: function {$function} not in $class_name!";
 				throw new Exception($error);
 			}
 		} else {
-			$error = "Base Error: class $class_name isn't exists!";
+			$error = "Base Error: class {$class_name} isn't exists!";
 			throw new Exception($error);
 		}
 	}
@@ -126,7 +128,8 @@ final class Base
 	/**
 	 * run
 	 */
-	public static function run(){
+	public static function run() {
+		performance_helper::clear();
 	    self::cp();
 	    self::init();
         self::control();

+ 4 - 3
core/framework/db/mysqli.php

@@ -151,9 +151,10 @@ class Db
 		$result = self::query($sql, $host);
 		if ($result === false) return array();
 		$array = array();
-		while ($tmp=mysqli_fetch_array($result,MYSQLI_ASSOC)){
-			$array[] = $tmp;
-		}
+//		while ($tmp=mysqli_fetch_array($result,MYSQLI_ASSOC)){
+//			$array[] = $tmp;
+//		}
+		$array = mysqli_fetch_all($result,MYSQLI_ASSOC);
 		return !empty($array) ? $array : null;
 	}
 

+ 2 - 0
core/framework/function/core.php

@@ -1661,6 +1661,7 @@ function array_under_reset($array, $key, $type=1){
  */
 function rkcache($key, $callback = false)
 {
+	$start = microtime(true);
     if (C('cache_open')) {
         $cacher = Cache::getInstance('cacheredis');
     } else {
@@ -1685,6 +1686,7 @@ function rkcache($key, $callback = false)
         wkcache($key, $value);
     }
 
+	perfor_period("rkcache",$start,$key);
     return $value;
 }
 

+ 1 - 0
fooder.php

@@ -32,4 +32,5 @@ require_once(BASE_CORE_PATH.'/framework/function/goods.php');
 require_once(BASE_CORE_PATH . '/framework/libraries/validate.php');
 require_once(BASE_CORE_PATH.'/framework/libraries/resizeimage.php');
 require_once (BASE_MOBILE_PATH . '/control/log.php');
+require_once (BASE_ROOT_PATH . '/helper/performance_helper.php');
 ?>

+ 1 - 0
helper/fcgi_server.php

@@ -56,6 +56,7 @@ class fcgi_server
         while(($ret = fcgi_accept()) >= 0)
         {
             ob_start();
+            performance_helper::clear();
             http_header::instance()->start();
             try
             {

+ 11 - 1
helper/goods_helper.php

@@ -14,8 +14,12 @@ class goods_helper
 
     public function get_infos($goods_ids,$fieldstr)
     {
+        perfor_start();
         $goods_list = Model('goods')->cls()->getGoodsOnlineList(array('goods_id' => array('in', $goods_ids)),$fieldstr);
+        perfor_end("get_infos");
+
         $goods_list = $this->goods_list_extend($goods_list);
+        perfor_end("goods_list_extend");
 
         return $goods_list;
     }
@@ -26,12 +30,17 @@ 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');
+        perfor_end("goods_list_extend 1");
+
         //促销
         $groupbuy_list = Model('groupbuy')->getGroupbuyListByGoodsCommonIDString(implode(',', $commonid_array));
+        perfor_end("goods_list_extend 2");
+
         $xianshi_list = Model('p_xianshi_goods')->getXianshiGoodsListByGoodsString(implode(',', $goodsid_array));
+        perfor_end("goods_list_extend 3");
+
         foreach ($goods_list as $key => &$value)
         {
             //抢购
@@ -59,6 +68,7 @@ class goods_helper
                 'is_fcode,have_gift,goods_storage,goods_storage_alarm,goods_attr,group_flag,xianshi_flag';
             field_helper::unset_column($value,$fields);
         }
+        perfor_end("goods_list_extend 4");
 
         return $goods_list;
     }

+ 71 - 0
helper/performance_helper.php

@@ -0,0 +1,71 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 16/4/6
+ * Time: 下午9:25
+ */
+
+class performance_helper
+{
+    private $mMsgs;
+    private $mStart;
+    static private $stInstance = NULL;
+
+    public function __construct() {
+        $this->mMsgs = array();
+        $this->mStart = microtime(true);
+    }
+    static public function instance()
+    {
+        if(self::$stInstance == NULL) {
+            self::$stInstance = new performance_helper();
+        }
+
+        return self::$stInstance;
+    }
+    public function start()
+    {
+        $this->mStart = microtime(true);
+    }
+    public function push($tag,$info = '',$start = NULL)
+    {
+        if($start == NULL) {
+            $start = $this->mStart;
+            $this->mStart = microtime(true);
+        }
+
+        if(empty($info)) {
+            $msg = sprintf("%s:%.6f",$tag,microtime(true) - $start);
+        } else {
+            $msg = sprintf("%s:%.6f,info=",$tag,microtime(true) - $start);
+            $msg = $msg.$info;
+        }
+        array_push($this->mMsgs,$msg);
+    }
+
+    public static function clear() {
+        self::instance()->mMsgs = array();
+    }
+
+    public static function format_log() {
+        foreach(self::instance()->mMsgs as $val) {
+            echo $val . "<br/><br/>";
+        }
+    }
+}
+
+function perfor_start()
+{
+    performance_helper::instance()->start();
+}
+
+function perfor_end($tag,$info = '')
+{
+    performance_helper::instance()->push($tag,$info);
+}
+
+function perfor_period($tag,$start,$info = '')
+{
+    performance_helper::instance()->push($tag,$info,$start);
+}

+ 5 - 3
mobile/control/control.php

@@ -87,8 +87,9 @@ class mobileControl
                 $msg = errcode::msg($code);
             }
             echo joutput_error($code,$msg,'web') . "<br/>";
-            $eclipse_time = sprintf("eclipse_time = %.6f <br/><br/>", self::eclipse_time());
-            echo $eclipse_time;
+            echo sprintf("eclipse_time = %.6f <br/><br/>", self::eclipse_time());
+            echo "性能关键统计:<br/><br/>";
+            performance_helper::format_log();
 
             $sqls = Log::sql_log();
             echo "sql count = " . count($sqls) . "<br/><br/>";
@@ -120,7 +121,8 @@ class mobileControl
             joutput_data($data,'web');
             echo "<br/><br/>";
             echo sprintf("eclipse_time = %.6f <br/><br/>", self::eclipse_time());
-
+            echo "性能关键统计:<br/><br/>";
+            performance_helper::format_log();
             $sqls = Log::sql_log();
             echo "sql count = " . count($sqls) . "<br/><br/>";
             foreach($sqls as $sql) {

+ 8 - 2
mobile/control/member_info.php

@@ -23,8 +23,14 @@ class member_infoControl extends mbMemberControl
         $ret = array();
         foreach($fields as $val)
         {
-            if(array_key_exists($val,$_SESSION)) {
-                $ret[$val] = $_SESSION[$val];
+            if(array_key_exists($val,$_SESSION))
+            {
+                if($val == 'member_birthday') {
+                    $time = $_SESSION[$val];
+                    $ret[$val] = strtotime($time);
+                } else {
+                    $ret[$val] = $_SESSION[$val];
+                }
             }
         }
 

+ 9 - 13
mobile/control/member_refund.php

@@ -21,17 +21,11 @@ class member_refundControl extends mbMemberControl
     }
 
     /**
-     * 
      * 退款接口(全退, 商品,全款全退, 不能指定)
      */
+
     public function refundOp()
     {
-    	// 登录验证
-    	// $token = trim($_GET['key']);
-     //    if (false == $this->checkToken($token)) {
-     //        return joutput_error($this->err_code);
-     //    }
-
         $order_info = Model('order')->getOrderInfo(array('order_sn' => $_GET['order_sn']));
         if (empty($order_info)) {
             joutput_error(array("errorMessage" => "订单为空"));
@@ -59,12 +53,15 @@ class member_refundControl extends mbMemberControl
         //$goods_pay_price = $goods['goods_pay_price'];//商品实际成交价
         $goods_pay_price = $order_amount;   // 默认全退款
         $goods_num = 1; // 数量,  默认为1
-        if (is_array($goods_id)) {// 计算物品数量
+        if (is_array($goods_id))
+        {// 计算物品数量
             $goods_pay_price = 0.0;
             $goods_num = count($goods_id);
-            foreach ($goods_list as $value) {
+            foreach ($goods_list as $value)
+            {
                 $tmp_goods_id = $value['goods_id'];
-                foreach ($goods_id as $goods_id_value) {
+                foreach ($goods_id as $goods_id_value)
+                {
                     if (intval($goods_id_value) == intval($tmp_goods_id)) {
                         $goods_pay_price += floatval($value['goods_pay_price']);
                     }
@@ -126,15 +123,14 @@ class member_refundControl extends mbMemberControl
         $refund_array['add_time'] = time();
         $state = $model_refund->addRefundReturn($refund_array,$order,$goods);
 
-        if ($state) {
+        if ($state)
+        {
             if ($order['order_state'] == $order_shipped) {
                 $model_refund->editOrderLock($order_id);
             }
-
             joutput_data(array("errorMessage" => ""));
         } else {
             joutput_error(array("errorMessage" => "更新退款退货记录失败"));
-            
         }
     }
 }

+ 4 - 0
run.php

@@ -3,6 +3,10 @@
 
 define('InShopNC',true);
 
+$x = time();
+
+$member_birthday = strftime ("%Y-%m-%d %H:%M:%S",time());
+
 function is_date($time)
 {
     $pattern = '/[\d]{4}-[\d]{1,2}-[\d]{1,2}/';