Преглед изворни кода

Merge branch 'goods' of 121.43.114.153:/home/git/repositories/shopnc into goods

root пре 9 година
родитељ
комит
3313ff226c

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

@@ -8,6 +8,10 @@
 
 
 defined('InShopNC') or exit('Access Invalid!');
+
+require_once(BASE_CORE_PATH . '/framework/function/statistic_tm.php');
+
+
 class Db
 {
 	private static $link = array();
@@ -114,9 +118,10 @@ class Db
 	public static function query($sql, $host = 'master')
 	{
 		self::connect($host);
-		if (C('debug')) addUpTime('queryStartTime');
+		$staer = new statistic_tm();
 		$query = self::$link[$host]->query($sql);
-		if (C('debug')) addUpTime('queryEndTime');
+		$staer->end();
+
 		if ($query === false)
 		{
 		    $error = 'Db Error: '.mysqli_error(self::$link[$host]);
@@ -130,7 +135,7 @@ class Db
 		}
 		else
 		{
-		    Log::record($sql." [ RunTime:".addUpTime('queryStartTime','queryEndTime',6)."s ]",Log::SQL);
+			Log::record($sql . " [ RunTime:" . $staer->elapsed(6) . "s ]", Log::SQL);
 			return $query;
 		}
 	}

+ 1 - 1
core/framework/function/core.php

@@ -885,7 +885,7 @@ if(!function_exists('memory_get_usage')){
 	}
 }
 
-// 记录和统计时间(微秒)
+//记录和统计时间(微秒)
 function addUpTime($start,$end='',$dec=3) {
     static $_info = array();
     if(!empty($end)) { // 统计时间

+ 29 - 0
core/framework/function/statistic_tm.php

@@ -0,0 +1,29 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 16/1/26
+ * Time: 上午10:32
+ */
+
+
+class statistic_tm
+{
+    private $start;
+    private $end;
+    public function __construct()
+    {
+        $this->start = microtime(TRUE);
+    }
+
+    public function end()
+    {
+        $this->end = microtime(TRUE);
+    }
+
+    public function elapsed($dec = 3)
+    {
+        $this->end = microtime(TRUE);
+        return number_format(($this->end - $this->start),$dec);
+    }
+}

+ 54 - 1
crontab/crawl/body_filter.php

@@ -94,6 +94,47 @@ class body_filder
         }
     }
 
+    private function filter_table($val,$commid)
+    {
+        $style = '/\s*<img\s*[^>]*src\s*=\s*\"([^>\"]*)\"\s*[^>]*>/i';
+        $val = preg_match_all($style,$val,$match);
+        if(!empty($val) && $val > 0)
+        {
+            $imgs = array();
+
+            $num = 1;
+            foreach($match[1] as $url)
+            {
+                $info = pathinfo($url);
+                if(empty($info['extension'])) continue;
+
+                $name = md5($url) . '.' . $info['extension'];
+                $path = self::$down_path . '/' . $name;
+
+                if(file_exists($path) || $this->download($url,$path))
+                {
+                    $name = "{$commid}-{$num}.{$info['extension']}";
+                    $newpath = self::$save_path . "/{$name}";
+
+                    if(file_exists($newpath)) {
+                        unlink($newpath);
+                    }
+                    copy($path,$newpath);
+
+                    ++$num;
+                    array_push({$name});
+                }
+            }
+            if(isset($imgs)) {
+                return $imgs;
+            } else {
+                return false;
+            }
+        } else {
+            return false;
+        }
+    }
+
     public function fillbody()
     {
         $tm_goods = Model('tm_goods');
@@ -107,6 +148,12 @@ class body_filder
         }
     }
 
+    private function layout($pics)
+    {
+
+
+    }
+
     public function proc()
     {
         $goods = $this->goods_common->field('goods_commonid,goods_body')->limit(false)->select();
@@ -115,12 +162,18 @@ class body_filder
             $body = $val['goods_body'];
             $comm_id = $val['goods_commonid'];
             $body = $this->filter_gif($body);
-            $body = $this->filterex($body,$comm_id);
+            $imgs = $this->filter_table($body,$comm_id);
+
+            if($imgs == false) continue;
+            $body = $this->layout($imgs);
+
             if(!empty($body)) {
                 $this->goods_common->where(array('goods_commonid' => $comm_id))->update(array('goods_body' => $body));
             }
         }
     }
+
+    public function
 }
 
 

+ 3 - 0
data/model/goods.model.php

@@ -1284,6 +1284,8 @@ class goodsModel extends Model
             return null;
         }
 
+        Log::record("goods_common_info = " . (string)$goods_common_info);
+
         $goods_common_info['goods_body'] = '';//base64_encode($goods_common_info['goods_body']);
         $goods_common_info['goods_attr'] = $this->_formatGoodsAttr(unserialize($goods_common_info['goods_attr']));
 
@@ -1331,6 +1333,7 @@ class goodsModel extends Model
         $result = array();
         $result['request_goods_id'] = $goods_id;
         $result['goods_info'] = $goods_common_info;
+        //$result['goods_info']['goods_id'] = $goods_id;
 
         Log::record(" return 4 result = {$result}.",Log::DEBUG);
 

+ 6 - 6
mobile/control/goods.php

@@ -234,14 +234,14 @@ class goodsControl extends mobileHomeControl
     public function goods_commonOp()
     {
         $goods_id = intval($_GET ['goods_id']);
-        if(empty($_GET ['goods_id']) && $goods_id > 0) {
+        if(empty($_GET ['goods_id']) || $goods_id < 0) {
             return joutput_error(errcode::ErrParamter,"goods_id = {$goods_id} must be > 0.");
         }
 
-        $item = Model()->table('goods')->field('*')->where(array('goods_id' => $goods_id))->select();
-        if(empty($item) || count($item) == 0) {
-            return joutput_error(0,"goods_id = {$goods_id} goods = 0.");
-        }
+//        $item = Model()->table('goods')->field('*')->where(array('goods_id' => $goods_id))->select();
+//        if(empty($item) || count($item) == 0) {
+//            return joutput_error(0,"goods_id = {$goods_id} goods = 0.");
+//        }
 
         // 商品详细信息
         $model_goods = Model('goods');
@@ -276,7 +276,7 @@ class goodsControl extends mobileHomeControl
     private function _goods_common_extend($goods_detail)
     {
         //商品链接
-        $goods_detail['goods_info']['goods_url'] = urlShop('goods', 'index', array('goods_id' => $goods_detail['goods_info']['goods_id']));
+        $goods_detail['goods_info']['goods_url'] = urlShop('goods', 'index', array('goods_id' => $goods_detail['request_goods_id']));
 
         //整理数据
         unset($goods_detail['goods_info']['goods_commonid']);

+ 31 - 10
mobile/dispatch_notify.php

@@ -9,16 +9,37 @@
 try
 {
     //tid-订单号,status-1,consign_time-发货时间,logistics_no-快递流水,logistics_company-快递公司
-    $tid = $_POST['tid'];
-    $status = $_POST['status'];
-    $consign_time = $_POST['consign_time'];
-    $logistics_no = $_POST['logistics_no'];
-    $logistics_company = $_POST['logistics_company'];
+    $order_sn = trim($_POST['tid']);
+    $status = intval($_POST['status']);
+    //$consign_time = $_POST['consign_time'];
+    $logistics_no = trim($_POST['logistics_no']);
+    //$logistics_company = $_POST['logistics_company'];
+
+    Log::record("dispatch notify value: order_sn = {$order_sn},status={$status},consign_time = {$consign_time} logistics_no = {$logistics_no} logistics_company = {$logistics_company}.",Log::DEBUG);
+
+    $remote_addr = $_SERVER['REMOTE_ADDR'];
+
+    if(!empty($order_sn) && !empty($logistics_no))
+    {
+        if($status == 1)
+        {
+            $ret = Model()->table('order')->where(array('order_sn' => $order_sn))->update(array('order_state' => ORDER_STATE_SEND,'shipping_code' => $logistics_no));
+            if($ret) {
+                echo 'SUCCESS';
+            } else {
+                echo 'AGAIN';
+            }
+        }
+        else{
+            echo 'SUCCESS';
+        }
+    }
+    else
+    {
+        echo 'FAIL';
+    }
 
-    Log::record("dispatch notify value: tid = {$tid},status={$status},consign_time = {$consign_time} logistics_no = {$logistics_no} logistics_company = {$logistics_company}.",Log::DEBUG);
-    echo 'SUCCESS';
 } catch (WxPayException $e){
-    Log::record($e->getTraceAsString(),Log::ERR);
-    $msg = $e->errorMessage();
-    echo 'FAIL';
+    Log::record($e->errorMessage(),Log::ERR);
+    echo 'AGAIN';
 }