stanley-king 9 лет назад
Родитель
Сommit
a4e1ea6d93

+ 0 - 7
admin/control/predeposit.php

@@ -620,11 +620,6 @@ class predepositControl extends SystemControl{
 		}
 	}
 	
-	
-	
-	
-	
-	
 	/**
 	 * 添加余额
 	 */
@@ -711,8 +706,6 @@ class predepositControl extends SystemControl{
 				$this->log($log_msg,0);
 				showMessage($e->getMessage(),'index.php?act=predeposit&op=pd_log_list','html','error');
 			}
-		
-		
 	}
 	
 	

+ 10 - 4
core/framework/function/core.php

@@ -1489,10 +1489,15 @@ function pagecmd($cmd ='', $arg = ''){
  */
 function throw_exception($error)
 {
-	if (!defined('IGNORE_EXCEPTION')) {
-		showMessage($error,'','exception');
+	Log::record($error,Log::ERR);
+	if(!is_mobile())
+	{
+		if (!defined('IGNORE_EXCEPTION')) {
+			showMessage($error,'','exception');
+		}
+	} else {
+		throw new Exception($error);
 	}
-	log::record($error);
 }
 
 /**
@@ -1547,7 +1552,8 @@ function halt($error){
  * @param array $args
  * @return object
  */
-function get_obj_instance($class, $method='', $args = array()){
+function get_obj_instance($class, $method='', $args = array())
+{
 	static $_cache = array();
 	$key = $class.$method.(empty($args) ? null : md5(serialize($args)));
 	if (isset($_cache[$key])){

+ 10 - 1
core/framework/libraries/log.php

@@ -15,6 +15,7 @@ class Log
     const DEBUG = 2;
     const WARING = 3;
     const ERR = 4;
+    const RUN = 5;
 
     private static $log = array();
 
@@ -30,7 +31,14 @@ class Log
             return;
         }
 
-        if($lev >= self::cur_level) {
+        if($lev >= self::cur_level && $lev < self::ERR) {
+            $level = self::get_level($lev);
+            $log_file = BASE_DATA_PATH . '/log/' . date('Ymd', TIMESTAMP) . '.log';
+            $content = "[{$now}] {$level}: {$message}\r\n";
+            file_put_contents($log_file, $content, FILE_APPEND);
+        }
+        else
+        {
             $level = self::get_level($lev);
             $log_file = BASE_DATA_PATH . '/log/' . date('Ymd', TIMESTAMP) . '.log';
             $url = $_SERVER['REQUEST_URI'] ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF'];
@@ -50,6 +58,7 @@ class Log
         if($lev == self::DEBUG) return 'DEBUG';
         if($lev == self::WARING) return 'WARING';
         if($lev == self::ERR) return 'ERR';
+        if($lev == self::RUN) return 'RUN';
         return 'Unknown';
     }
 

+ 24 - 15
core/framework/libraries/model.php

@@ -666,24 +666,33 @@ class ModelDb
 
     public function select($options=array()) 
     {
-     	static $_cache = array();
-		$sql = $this->buildSelectSql($options);
-
-        Log::record("Select Sql: ".$sql, Log::ERR);
+        if(is_mobile())
+        {
+            $sql = $this->buildSelectSql($options);
+            Log::record($sql, Log::SQL);
+            $result = DB::getAll($sql,($options['lock'] === true || $options['master'] === true || defined('TRANS_MASTER')) ? 'master' : 'slave');
+            return $result;
 
-        //if ($options['cache'] !== false)
-        if ($options['cache'] === true)
+        }
+        else
         {
-            $key =  is_string($_cache['cache_key']) ? $_cache['cache_key'] : md5($sql);
-            if (isset($_cache[$key])){
-            	return $_cache[$key];
+            static $_cache = array();
+            $sql = $this->buildSelectSql($options);
+            Log::record($sql, Log::SQL);
+
+            if ($options['cache'] === true)
+            {
+                $key =  is_string($_cache['cache_key']) ? $_cache['cache_key'] : md5($sql);
+                if (isset($_cache[$key])){
+                    return $_cache[$key];
+                }
             }
+            $result = DB::getAll($sql,($options['lock'] === true || $options['master'] === true || defined('TRANS_MASTER')) ? 'master' : 'slave');
+            if ($options['cache'] === true && !isset($_cache[$key])){
+                $_cache[$key] = $result;
+            }
+            return $result;
         }
-        $result = DB::getAll($sql,($options['lock'] === true || $options['master'] === true || defined('TRANS_MASTER')) ? 'master' : 'slave');
-        if ($options['cache'] === true && !isset($_cache[$key])){
-         	$_cache[$key] = $result;
-        }
-        return $result;
     }
 
     public function buildSelectSql($options=array()) 
@@ -1087,8 +1096,8 @@ class ModelDb
             }
         }
         $sql   =  ($replace?'REPLACE ':'INSERT ').$this->parseAttr($options).' INTO '.$this->parseTable($options).' ('.implode(',', $fields).') VALUES ('.implode(',', $values).')';
-
         Log::record($sql,Log::SQL);
+
         return DB::execute($sql);
     }
 

+ 15 - 14
crontab/crawl/fetch_goods.php

@@ -41,17 +41,18 @@ function not_null($str)
 
 $str = md5('stanley%lrlz&00991122887733447755');
 
-//$tmreq = new tmrequest();
-//$tmreq->proc();
-//
-//$cat = new category();
-//$cat->proc();
-//
-//$treater = new pretreat_tmdata();
-//$treater->proc();
-//
-//$spec = new spec_attr_parser();
-//$spec->proc();
-
-$importer = new product_importer();
-$importer->proc();
+
+$tmreq = new tmrequest();
+$tmreq->proc();
+
+$cat = new category();
+$cat->proc();
+
+$treater = new pretreat_tmdata();
+$treater->proc();
+
+$spec = new spec_attr_parser();
+$spec->proc();
+
+//$importer = new product_importer();
+//$importer->proc();

+ 8 - 6
crontab/crawl/product_importer.php

@@ -63,7 +63,7 @@ class product_importer
 
     private function get_tmgoods()
     {
-        $bodys = $this->tm_goods->field('num_iid,body,description')->where(array('imported' => 0))->limit(false)->order('num_iid')->select();
+        $bodys = $this->tm_goods->field('num_iid,shop_id,body,description')->where(array('imported' => 0))->limit(false)->order('num_iid')->select();
         $result = array();
 
         foreach($bodys as $body) {
@@ -72,6 +72,7 @@ class product_importer
             $product['body'] = $item['item_seller_get_response']['item'];
             $product['desc'] = $body['description'];
             $product['num_iid'] = $body['num_iid'];
+            $product['shop_id'] = $body['shop_id'];
 
             array_push($result,$product);
         }
@@ -276,11 +277,12 @@ class product_importer
         return $specs;
     }
 
-    private function fill_general($cid,$item, &$general,&$name)
+    private function fill_general($cid,$item, &$general,&$name,$num_iid,$shop_id)
     {
         $this->fill_class($cid, $general,$name);
 
-        $general['num_iid'] = $item['num_iid'];
+        $general['num_iid'] = $num_iid;
+        $general['tm_shop'] = $shop_id;
         $general['store_id'] = self::store_id;
         $general['store_name'] = self::store_name;
         $general['goods_name'] = not_null($item['title']);
@@ -385,12 +387,12 @@ class product_importer
 
 
 
-    private function import_item($item,$desc)
+    private function import_item($item,$desc,$num_iid,$shop_id)
     {
         $cid = $item['cid'];
 
         $general = array();
-        $this->fill_general($cid,$item,$general,$name);
+        $this->fill_general($cid,$item,$general,$name,$num_iid,$shop_id);
 
         //属于SKU 信息中
         $skus = &$item['skus'];
@@ -520,7 +522,7 @@ class product_importer
         $items = $this->get_tmgoods();
         foreach($items as $item) {
             print "handle num_iid=" . $item['num_iid'] . " start.\r\n";
-            $this->import_item($item['body'],$item['desc']);
+            $this->import_item($item['body'],$item['desc'],$item['num_iid'],$item['shop_id']);
 
             $this->tm_goods->where(array('num_iid' => $item['num_iid']))->update(array('imported' => 1));
             print "handle num_iid=" . $item['num_iid'] . " end. \r\n";

+ 9 - 1
crontab/crawl/tm_pagereq.php

@@ -33,7 +33,7 @@ class tm_pagereq
         do
         {
             if($this->get_onsale($page_no) == false) {
-                echo("error request.");
+                Log::record("error request.",Log::ERR);
                 return NULL;
             }
             $page_no++;
@@ -60,7 +60,15 @@ class tm_pagereq
         if(!empty($resp))
         {
             $this->total_items = $resp->total_results;
+            Log::record("total={$this->total_items}\r\n",Log::DEBUG);
             $items = $resp->items->item;
+            if($items == NULL) {
+                Log::record("total={$this->total_items}\r\n",Log::DEBUG);
+                echo "total={$this->total_items}\r\n";
+                flush();
+                return NULL;
+            }
+
             if($this->leftcount < 0) {
                 $this->leftcount = $this->total_items;
             }

+ 44 - 33
crontab/crawl/tmrequest.php

@@ -20,42 +20,17 @@ class tmrequest
         $this->tm_shop = Model('tm_shop');
         $this->tm_goods = Model('tm_goods');
     }
+    public function proc_one($shopid)
+    {
+        $items = $this->tm_shop->where(array('shop_id' => $shopid))->field('shop_id,shop_name,appKey,sercetCode,sessionKey')->limit(false)->select();
+        $this->request($items);
+
+    }
 
     public function proc()
     {
-        //->where(array('shop_id' => 17))
         $items = $this->tm_shop->field('shop_id,shop_name,appKey,sercetCode,sessionKey')->limit(false)->select();
-        foreach($items as $item)
-        {
-            echo "Inof: shop id =".$item["shop_id"]." name=".$item["shop_name"]." appKey=".$item['appKey']." sercetCode=".$item['sercetCode']." sessionKey=".$item['sessionKey']."\r\n";
-
-            $this->appkey = $item['appKey'];
-            $this->secretKey = $item['sercetCode'];
-            $this->sessionKey = $item['sessionKey'];
-
-            $shop_id = $item["shop_id"];
-
-            $sale_items = $this->get_onsale();
-            if(empty($sale_items)) {
-                echo "Error: get product info from taobao err where "."shop id =".$item["shop_id"]." name=".$item["shop_name"]."\r\n";
-            }
-            else
-            {
-                foreach($sale_items as $sale_item)
-                {
-                    $num_iid = $sale_item->num_iid;
-                    $issale = $sale_item->approve_status == "onsale" ? true : false;
-                    if($issale)
-                    {
-                        $body = $this->get_body($num_iid);
-                        $desc = $this->get_desc($num_iid);
-                        if(!empty($body)) {
-                            $this->store_data($body,$desc,$shop_id);
-                        }
-                    }
-                }
-            }
-        }
+        $this->request($items);
     }
 
     //添加基础数据。
@@ -91,7 +66,6 @@ sell_point,valid_thru,outer_id,
 barcode,sold_quantity,price,post_fee,express_fee,ems_fee,global_stock_type,global_stock_country,prop_img';
 
         //desc wireless_desc wap_desc
-
         $c = new TopClient;
         $c->appkey = $this->appkey;
         $c->secretKey = $this->secretKey;
@@ -137,4 +111,41 @@ barcode,sold_quantity,price,post_fee,express_fee,ems_fee,global_stock_type,globa
         $req = new tm_pagereq($this->appkey,$this->secretKey,$this->sessionKey);
         return $req->proc();
     }
+
+    /**
+     * @param $items
+     */
+    private function request($items)
+    {
+        foreach ($items as $item)
+        {
+            echo "Inof: shop id =" . $item["shop_id"] . " name=" . $item["shop_name"] . " appKey=" . $item['appKey'] . " sercetCode=" . $item['sercetCode'] . " sessionKey=" . $item['sessionKey'] . "\r\n";
+
+            $this->appkey = $item['appKey'];
+            $this->secretKey = $item['sercetCode'];
+            $this->sessionKey = $item['sessionKey'];
+
+            $shop_id = $item["shop_id"];
+
+            $sale_items = $this->get_onsale();
+            if (empty($sale_items)) {
+                echo "Error: get product info from taobao err where " . "shop id =" . $item["shop_id"] . " name=" . $item["shop_name"] . "\r\n";
+            }
+            else
+            {
+                foreach ($sale_items as $sale_item)
+                {
+                    $num_iid = $sale_item->num_iid;
+                    $issale = $sale_item->approve_status == "onsale" ? true : false;
+                    if ($issale) {
+                        $body = $this->get_body($num_iid);
+                        $desc = $this->get_desc($num_iid);
+                        if (!empty($body)) {
+                            $this->store_data($body, $desc, $shop_id);
+                        }
+                    }
+                }
+            }
+        }
+    }
 }

+ 0 - 1
crontab/crawl/transport_data.php

@@ -255,7 +255,6 @@ class ModelOperator
                     $this->mod_attr_tcpid->insert(array("attr_id" => $attrid, "cid" => $cid, "pid" => $pid));
                 } else {
                     // add log...
-
                 }
             }
 

+ 1 - 1
data/api/smsapi/yuntx/SendSMS.php

@@ -30,7 +30,7 @@ function sendSMS($to,$datas,$tempId)
     $appId = '8a48b5515018a0f4015059a74f0f7565';
 
     //请求地址,格式如下,不需要写https://
-    $serverIP = 'sandboxapp.cloopen.com';
+    $serverIP = 'app.cloopen.com';
 
     //请求端口 
     $serverPort = '8883';

+ 6 - 6
data/logic/buy.logic.php

@@ -75,7 +75,7 @@ class buyLogic {
 
         //取得POST ID和购买数量
         $buy_items = $this->_parseItems($cart_id);
-        Log::record('Buy item '. json_encode($buy_items),Log::ERR);
+        Log::record('Buy item '. json_encode($buy_items),Log::DEBUG);
         if (empty($buy_items)) {
             return callback(false, '所购商品无效');
         }
@@ -165,7 +165,7 @@ class buyLogic {
         //重新计算优惠后(满即送)的店铺实际商品总金额
         $store_goods_total = $this->_logic_buy_1->reCalcGoodsTotal($store_goods_total,$store_mansong_rule_list,'mansong');
 
-        Log::record("Store goods total ".$store_goods_total, Log::ERR);
+        Log::record("Store goods total ".$store_goods_total, Log::DEBUG);
 
         //返回店铺可用的代金券
         $store_voucher_list = $this->_logic_buy_1->getStoreAvailableVoucherList($store_goods_total, $member_id);
@@ -304,12 +304,12 @@ class buyLogic {
         //$city_id计算运费模板,$area_id计算货到付款
         $city_id = intval($city_id);
         $area_id = intval($area_id);
-        Log::record("Start Change Address  $city_id, $area_id, $member_id", log::ERR);
+        Log::record("Start Change Address  $city_id, $area_id, $member_id", log::DEBUG);
         if ($city_id <= 0 || $area_id <= 0) return null;
     
         //将hash解密,得到运费信息(店铺ID,运费,运费模板ID,购买数量),hash内容有效期为1小时
         $freight_list = $this->buyDecrypt($freight_hash, $member_id);
-        Log::record("Parse Freight ".json_encode($freight_list). " count " .count($freight_list), log::ERR);
+        Log::record("Parse Freight ".json_encode($freight_list). " count " .count($freight_list), log::DEBUG);
 
         //算运费
         $store_freight_list = $this->_logic_buy_1->calcStoreFreight($freight_list, $city_id);
@@ -383,7 +383,7 @@ class buyLogic {
 
         //取得商品ID和购买数量
         $input_buy_items = $this->_parseItems($post['cart_id']);
-        Log::record('Input buy item '. json_encode($input_buy_items),Log::ERR);
+        Log::record('Input buy item '. json_encode($input_buy_items),Log::DEBUG);
         if (empty($input_buy_items)) {
             throw new Exception('所购商品无效');
         }
@@ -404,7 +404,7 @@ class buyLogic {
 
         //是否开增值税发票
         $input_if_vat = $this->buyDecrypt($post['vat_hash'], $this->_member_info['member_id']);
-        Log::record('Input if vat '. json_encode($input_if_vat),Log::ERR);
+        Log::record('Input if vat '. json_encode($input_if_vat),Log::DEBUG);
         if (!in_array($input_if_vat,array('allow_vat','deny_vat'))) {
             throw new Exception('订单保存出现异常[值税发票出现错误],请重试');
         }

+ 6 - 5
data/logic/buy_1.logic.php

@@ -257,8 +257,9 @@ class buy_1Logic {
      * @param array $store_goods_total 每个店铺的商品金额小计,以店铺ID为下标
      * @return array
      */
-    public function getStoreFreightDescList($store_goods_total) {
-        Log::record("Store goods total ".json_encode($store_goods_total), Log::ERR);
+    public function getStoreFreightDescList($store_goods_total)
+    {
+        Log::record("Store goods total ".json_encode($store_goods_total), Log::DEBUG);
         if (empty($store_goods_total) || !is_array($store_goods_total)) return array(array(),array());
 
         //定义返回数组
@@ -268,7 +269,7 @@ class buy_1Logic {
         //如果商品金额未达到免运费设置下线,则需要计算运费
         $condition = array('store_id' => array('in',array_keys($store_goods_total)));
         $store_list = Model('store')->getStoreOnlineList($condition,null,'','store_id,store_free_price');
-        Log::record("Store list ".json_encode($store_list), Log::ERR);
+        Log::record("Store list ".json_encode($store_list), Log::DEBUG);
         foreach ($store_list as $store_info) {
             $limit_price = floatval($store_info['store_free_price']);
             if ($limit_price == 0 || $limit_price > $store_goods_total[$store_info['store_id']]) {
@@ -356,12 +357,12 @@ class buy_1Logic {
 		//免费和固定运费计算结果
 		$return_list = $freight_list['iscalced'];
 
-        Log::record("No freight ".json_encode($return_list)." count ".count($return_list), Log::ERR);
+        Log::record("No freight ".json_encode($return_list)." count ".count($return_list), Log::DEBUG);
 
 		//使用运费模板的信息(array(店铺ID=>array(运费模板ID=>购买数量))
 		$nocalced_list = $freight_list['nocalced'];
 
-        Log::record("Freight ".json_encode($nocalced_list)." count ".count($nocalced_list), Log::ERR);
+        Log::record("Freight ".json_encode($nocalced_list)." count ".count($nocalced_list), Log::DEBUG);
 
 		//然后计算使用运费运费模板的在该$city_id时的运费值
 		if (!empty($nocalced_list) && is_array($nocalced_list)) {

+ 6 - 5
mobile/control/member_buy.php

@@ -21,12 +21,13 @@ class member_buyControl extends mobileMemberControl {
     /**
      * 购物车、直接购买第一步:选择收获地址和配置方式
      */
-    public function buy_step1Op() {
+    public function buy_step1Op()
+    {
         $cart_id = explode(',', urldecode($_POST['cart_id']));
-        Log::record('Create cart_id list'. urldecode($_POST['cart_id']),Log::ERR);
+        Log::record('Create cart_id list'. urldecode($_POST['cart_id']),Log::DEBUG);
 
         $logic_buy = logic('buy');
-        Log::record('Create buy logic model',Log::ERR);
+        Log::record('Create buy logic model',Log::DEBUG);
 
         //得到购买数据
         $result = $logic_buy->buyStep1($cart_id, $_POST['ifcart'], $this->member_info['member_id'], $this->member_info['store_id']);
@@ -35,7 +36,7 @@ class member_buyControl extends mobileMemberControl {
         } else {
             $result = $result['data'];
         }
-        Log::record('Get buy data',Log::ERR);
+        Log::record('Get buy data',Log::DEBUG);
         //整理数据
         $store_cart_list = array();
         foreach ($result['store_cart_list'] as $key => $value) {
@@ -79,7 +80,7 @@ class member_buyControl extends mobileMemberControl {
         $param = array();
         $param['ifcart'] = $_POST['ifcart'];
         $param['cart_id']  = explode(',', urldecode($_POST['cart_id']));
-        Log::record('Create cart_id list'. urldecode($_POST['cart_id']),Log::ERR);
+        Log::record('Create cart_id list'. urldecode($_POST['cart_id']),Log::DEBUG);
         $param['address_id'] = $_POST['address_id'];
         $param['vat_hash'] = $_POST['vat_hash'];
         $param['offpay_hash'] = $_POST['offpay_hash'];

+ 1 - 1
run.php

@@ -4,7 +4,7 @@
 define('BASE_ROOT_PATH',str_replace('\\','/',dirname(__FILE__)));
 
 require_once (BASE_ROOT_PATH . '/fooder.php');
-$gfcgi_run = 1;
+$gfcgi_run = 2;
 
 if($gfcgi_run == 0) { //模拟请求
     $file = BASE_ROOT_PATH . '/debug_run.php';