stanley-king 3 năm trước cách đây
mục cha
commit
eebea49ac7

+ 0 - 207
core/framework/libraries/logold.php

@@ -1,207 +0,0 @@
-<?php
-/**
- * 记录日志
- ***/
-defined('InShopNC') or exit('Access Invalid!');
-
-class scope_trace
-{
-    private $mTag;
-
-    public function __construct($tag)
-    {
-        $this->mTag = $tag;
-        Log::record("{$this->mTag} begin----------------------------", Log::DEBUG);
-    }
-
-    public function __destruct()
-    {
-        Log::record("{$this->mTag} end  ----------------------------", Log::DEBUG);
-    }
-}
-
-class Log
-{
-    const open_sql = true;
-    const SQL = 1;
-    const INFO = 2;
-    const DEBUG = 3;
-    const WARING = 4;
-    const ERR = 5;
-    const RUN = 6;
-    const WAIT_HANDLE = 10;
-    const cur_level = self::DEBUG;
-
-    private static $log = [];
-
-    private static $sqlog = false;
-
-    public static function start_sql_log()
-    {
-        self::$sqlog = [];
-    }
-
-    public static function sql_log()
-    {
-        if (is_array(self::$sqlog)) {
-            return self::$sqlog;
-        } else {
-            return [];
-        }
-    }
-
-    public static function end_sql_log()
-    {
-        self::$sqlog = false;
-    }
-
-    private static function add_sql_log($log)
-    {
-        if (is_array(self::$sqlog)) {
-            self::$sqlog[] = $log;
-        }
-    }
-
-    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-    static private $cur_path_file_name = '';
-    static private $cur_path_file;
-
-    public static function record_path($content)
-    {
-        $path_file = BASE_DATA_PATH . '/log/' . date('Ymd', time()) . '_path.log';
-        if (self::$cur_path_file_name != $path_file) {
-            if (self::$cur_path_file != null) {
-                fclose(self::$cur_path_file);
-            }
-            self::$cur_path_file = fopen($path_file, 'a');
-        }
-
-        if (@flock(self::$cur_path_file, LOCK_EX)) {
-            fwrite(self::$cur_path_file, $content);
-            fwrite(self::$cur_path_file, "\r\n");
-            @flock(self::$cur_path_file, LOCK_UN);
-        }
-    }
-
-    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-    public static function record($message, $lev = self::ERR)
-    {
-        $now = date('Y-m-d H:i:s', time());
-        $pid = posix_getpid();
-
-        if ($lev == self::WAIT_HANDLE) {
-            $level = 'WAIT_HANDLE';
-            $log_file = BASE_DATA_PATH . '/log/' . date('Ymd', time()) . '-wait.log';
-            $content = "[{$pid} {$now}] {$level}: {$message}\r\n";
-            file_put_contents($log_file, $content, FILE_APPEND);
-            return;
-        }
-
-        if ($lev == self::SQL) {
-            $level = 'SQL';
-            if (self::open_sql) {
-                self::write($message, $level);
-            }
-            return;
-        }
-
-        if ($lev >= self::cur_level && $lev <= self::RUN) {
-            $level = self::get_level($lev);
-            self::write($message, $level);
-        }
-
-        if ($lev == self::ERR) {
-            self::msg();
-        }
-    }
-
-    private static $cur_file_name;
-    private static $cur_file = null;
-
-    private static function write($message, $level)
-    {
-        $now = @date('Y-m-d H:i:s', time());
-        if(defined('USE_COROUTINE') && USE_COROUTINE === true) {
-            $pid = getmypid();
-            $cid = Swoole\Coroutine::getCid();
-
-            $pid = "{$pid}-{$cid}";
-        }
-        else {
-            $pid = posix_getpid();
-        }
-
-
-        $appid = empty(APP_ID) ? '' : APP_ID;
-
-        $log_file = BASE_DATA_PATH . '/log/' . date('Ymd', time()) . '-' . $appid . '.log';
-        if (self::$cur_file_name != $log_file) {
-            if (self::$cur_file != null) {
-                fclose(self::$cur_file);
-            }
-            self::$cur_file_name = $log_file;
-            self::$cur_file = fopen($log_file, 'a+');
-        }
-
-        $content = "[{$pid} {$now}] {$level}: {$message}\r\n";
-        $ret = fwrite(self::$cur_file, $content);
-        if ($ret === false) {
-            self::$cur_file = fopen($log_file, 'a+');
-            fwrite(self::$cur_file, $content);
-        }
-        fflush(self::$cur_file);
-    }
-
-    public static function endl($lev = self::ERR)
-    {
-        $content = "\r\n";
-
-        if ($lev == self::SQL && self::open_sql) {
-            $log_file = BASE_DATA_PATH . '/log/' . date('Ymd', time()) . '.log';
-            file_put_contents($log_file, $content, FILE_APPEND);
-            return;
-        }
-
-        if ($lev >= self::cur_level) {
-            $log_file = BASE_DATA_PATH . '/log/' . date('Ymd', time()) . '.log';
-            file_put_contents($log_file, $content, FILE_APPEND);
-        }
-    }
-
-    public static function msg()
-    {
-        $debugInfo = debug_backtrace();
-
-        $stack = "[";
-        foreach ($debugInfo as $key => $val) {
-            if (array_key_exists("file", $val)) {
-                $stack .= ",file:" . $val["file"];
-            }
-            if (array_key_exists("line", $val)) {
-                $stack .= ",line:" . $val["line"];
-            }
-            if (array_key_exists("function", $val)) {
-                $stack .= ",function:" . $val["function"];
-            }
-        }
-        $stack .= "]";
-
-        return $stack;
-    }
-
-    private static function get_level($lev)
-    {
-        if ($lev == self::INFO) return 'INFO';
-        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';
-    }
-
-    public static function read()
-    {
-        return self::$log;
-    }
-}

+ 5 - 5
data/config/xyz/refill.ini.php

@@ -2557,17 +2557,17 @@ $yuanta_phone = ['name' => 'yuanta', 'store_id' => 128, 'qualitys' => '5',
             ['goods_id' => 7121, 'price' => 183.6, 'quality' => 5, 'card_type' => 'chinamobile'],
             ['goods_id' => 7121, 'price' => 183, 'quality' => 5, 'card_type' => 'chinaunicom'],
 //            ['goods_id' => 7121, 'price' => 191.2, 'quality' => 5, 'card_type' => 'chinatelecom']
-        ],
-        300 => [
+        ]
+//        300 => [
 //            ['goods_id' => 7122, 'price' => 275.4, 'quality' => 5, 'card_type' => 'chinamobile'],
 //            ['goods_id' => 7122, 'price' => 274.5, 'quality' => 5, 'card_type' => 'chinaunicom'],
 //            ['goods_id' => 7122, 'price' => 286.8, 'quality' => 5, 'card_type' => 'chinatelecom']
-        ],
-        500 => [
+//        ],
+//        500 => [
 //            ['goods_id' => 7123, 'price' => 459, 'quality' => 5, 'card_type' => 'chinamobile'],
 //            ['goods_id' => 7123, 'price' => 457.5, 'quality' => 5, 'card_type' => 'chinaunicom'],
 //            ['goods_id' => 7123, 'price' => 478, 'quality' => 5, 'card_type' => 'chinatelecom']
-        ]
+//        ]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 

+ 5 - 5
data/config/xyzadm/refill.ini.php

@@ -2557,17 +2557,17 @@ $yuanta_phone = ['name' => 'yuanta', 'store_id' => 128, 'qualitys' => '5',
             ['goods_id' => 7121, 'price' => 183.6, 'quality' => 5, 'card_type' => 'chinamobile'],
             ['goods_id' => 7121, 'price' => 183, 'quality' => 5, 'card_type' => 'chinaunicom'],
 //            ['goods_id' => 7121, 'price' => 191.2, 'quality' => 5, 'card_type' => 'chinatelecom']
-        ],
-        300 => [
+        ]
+//        300 => [
 //            ['goods_id' => 7122, 'price' => 275.4, 'quality' => 5, 'card_type' => 'chinamobile'],
 //            ['goods_id' => 7122, 'price' => 274.5, 'quality' => 5, 'card_type' => 'chinaunicom'],
 //            ['goods_id' => 7122, 'price' => 286.8, 'quality' => 5, 'card_type' => 'chinatelecom']
-        ],
-        500 => [
+//        ],
+//        500 => [
 //            ['goods_id' => 7123, 'price' => 459, 'quality' => 5, 'card_type' => 'chinamobile'],
 //            ['goods_id' => 7123, 'price' => 457.5, 'quality' => 5, 'card_type' => 'chinaunicom'],
 //            ['goods_id' => 7123, 'price' => 478, 'quality' => 5, 'card_type' => 'chinatelecom']
-        ]
+//        ]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 

+ 5 - 0
data/model/refill_order.model.php

@@ -9,6 +9,11 @@ defined('InShopNC') or exit('Access Invalid!');
 
 class refill_orderModel extends Model
 {
+    public function __construct($table = null)
+    {
+        parent::__construct($table);
+    }
+
     public function getOrderInfo($condition = [], $fields = '*', $master = false, $lock = false)
     {
         $order_info = $this->table('refill_order')->field($fields)->where($condition)->order('')->master($master)->lock($lock)->find();

+ 13 - 10
helper/refill/api/xyz/dashang/RefillPhone.php

@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=0);
 
 namespace refill\dashang;
 
@@ -6,7 +7,6 @@ require_once(BASE_HELPER_RAPI_PATH . '/dashang/config.php');
 
 use refill;
 use Log;
-use mtopcard;
 
 class RefillPhone extends refill\IRefillPhone
 {
@@ -50,7 +50,9 @@ class RefillPhone extends refill\IRefillPhone
             $status = $resp['status'];
             $code   = $resp['code'];
 
-            if ($status === 'success' && $code === '00') {
+            if (!in_array($status, ['success', 'failed'])) {
+                return [false, '网络错误', true];
+            } elseif ($code === '00') {
                 return [true, $resp['bizOrderId'], false];
             } elseif (in_array($code, [23, 31])) {
                 $net_errno = "HTTP-{$code}";
@@ -86,28 +88,29 @@ class RefillPhone extends refill\IRefillPhone
             {
                 $status = $resp['status'];
                 $code   = $resp['code'];
-                if($status === 'success' && $code === '00')
+
+                if (!in_array($status, ['success', 'failed'])) {
+                    return [false, $status];
+                }
+                elseif($code === '00')
                 {
                     $status = intval($resp['data']['status']);
                     if ($status === 2) {
-                        $updata['official_sn'] = $resp['data']['outOrderNo'];
-                        Model('refill_order')->edit($refill_info['order_id'], $updata);
+                        Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $resp['data']['outOrderNo']]);
                         $order_state = ORDER_STATE_SUCCESS;
                     } elseif ($status === 3) {
                         $order_state = ORDER_STATE_CANCEL;
-                    } elseif (in_array($status, [0,1,4,9])) {
+                    } elseif (in_array($status, [0, 1, 4, 9])) {
                         $order_state = ORDER_STATE_SEND;
                     } else {
                         return [false, $status];
                     }
                     return [true, $order_state];
                 }
-                elseif($code === '22' && (time() - $refill_info['commit_time'] >= 600))
-                {
+                elseif ($code === '22' && (time() - $refill_info['commit_time'] >= 600)) {
                     return [true, ORDER_STATE_NOEXIST];
                 }
-                else
-                {
+                else {
                     return [false, $code];
                 }
             }