Browse Source

Merge branch 'raccount' of 39.97.239.116:gyfl/xyzshop into raccount

haru haru 2 years ago
parent
commit
6be498054d

+ 2 - 2
admin/control/orderstats.php

@@ -198,9 +198,9 @@ class orderstatsControl extends SystemControl
 
         $condition = ['end' => $end_unixtime];
 
-        $end_txt = date("Y-m-d H:i:s");
+        $end_txt = date("Y-m-d",$end_unixtime);
         $manager = new task\manager();
-        $task = $manager->add_task('refill_balance_stat_all',$condition,1,-1,"对账统计-{$end_txt}");
+        $task = $manager->add_task('refill_balance_stat_all',$condition,1,-1,"{$end_txt}-对账统计");
         if ($task->completed() && $task->success()) {
             exit(json_encode(['code' => true, 'msg' => '操作成功,此记录已新建成功。']));
         } else {

+ 12 - 4
core/framework/libraries/log.php

@@ -50,6 +50,8 @@ class Log
     private $mPathFileName;
     private $mPathFile;
 
+    private $mShortName;
+
     private static $stInstance = null;
     private function __construct()
     {
@@ -67,6 +69,8 @@ class Log
 
         $this->mPathFileName = '';
         $this->mPathFile = false;
+
+        $this->mShortName = empty(APP_ID) ? '' : APP_ID;
     }
 
     public static function instance()
@@ -77,6 +81,12 @@ class Log
         return self::$stInstance;
     }
 
+    public static function short_name($name)
+    {
+        $pThis = self::instance();
+        $pThis->mShortName = $name;
+    }
+
     public static function start_sql_log()
     {
         $pThis = self::instance();
@@ -170,15 +180,13 @@ class Log
             $pid = posix_getpid();
         }
 
-        $appid = empty(APP_ID) ? '' : APP_ID;
-        $content = "[{$appid} {$pid} {$now}] {$level}: {$message}\r\n";
+        $content = "[{$this->mShortName} {$pid} {$now}] {$level}: {$message}\r\n";
         return $content;
     }
 
     private function write($content)
     {
-        $appid = empty(APP_ID) ? '' : APP_ID;
-        $log_file = BASE_DATA_PATH . '/log/' . date('Ymd', time()) . '-' . $appid . '.log';
+        $log_file = BASE_DATA_PATH . '/log/' . date('Ymd', time()) . '-' . $this->mShortName . '.log';
 
         if ($this->mAppFileName != $log_file)
         {

+ 3 - 0
crontab/control/minutes.php

@@ -412,6 +412,9 @@ class minutesControl extends BaseCronControl
     //任务队列处理
     public function taskOp()
     {
+        Log::short_name('task');
+        Log::record('start task',Log::DEBUG);
+
         $task_manager = new task\manager();
         $task_id = 0;
         while (true)

+ 1 - 0
crontab/index.php

@@ -3,6 +3,7 @@
 if (empty($_SERVER['argv'][1])) exit('Access Invalid!');
 
 defined('APP_ID') or define('APP_ID','crontab');
+
 defined('BASE_ROOT_PATH') or define('BASE_ROOT_PATH',str_replace('/crontab','',dirname(__FILE__)));
 defined('BASE_PATH') or define('BASE_PATH',BASE_ROOT_PATH . '/crontab');
 

+ 7 - 16
helper/statistics/refill_balance.php

@@ -136,19 +136,19 @@ class refill_balance
             $item = $mod_refill->table('refill_order')->field('order_id,order_time')
                 ->where(['order_time' => ['lt', $end]])
                 ->order('order_id asc')->find();
-            $time = $item['order_time'] ?? 0;
+            $time = $item['order_time'] ?? $end;
         } elseif ($type == 'merchant') {
             $mod_refill = Model('refill_order');
             $item = $mod_refill->table('refill_order')->field('order_id,order_time')
                 ->where(['mchid' => $cid, 'order_time' => ['lt', $end]])
                 ->order('order_id asc')->find();
-            $time = $item['order_time'] ?? 0;
+            $time = $item['order_time'] ?? $end;
         } else {
             $mod_refill = Model('vr_order');
             $item = $mod_refill->table('vr_order')->field('order_id,add_time')
                 ->where(['store_id' => $cid,'add_time' => ['lt', $end]])
                 ->order('order_id asc')->find();
-            $time = $item['order_time'] ?? 0;
+            $time = $item['add_time'] ?? $end;
         }
 
         return $time;
@@ -176,7 +176,7 @@ class refill_balance
                 ->find();
         }
 
-        $time = $item['madd_time'] ?? 0;
+        $time = $item['madd_time'] ?? $end;
         return $time;
     }
 
@@ -202,7 +202,7 @@ class refill_balance
                 ->find();
         }
 
-        $time = $item['madd_time'] ?? 0;
+        $time = $item['madd_time'] ?? $end;
         return $time;
     }
 
@@ -256,20 +256,11 @@ class refill_balance
             $balance = ncPriceFormat($in - $order_stat['channel_amounts']);
         }
 
-        if($start == 0)
-        {
-            $time = min($refill_time,$pay_time);
-            if($time == 0) {
-                return [];
-            }
-
+        if ($start == 0) {
+            $time = min($refill_time, $pay_time);
             $start = strtotime(date('Y-m-d', $time));
         }
 
-        if($start === $end) {
-            return [];
-        }
-
         $accumuter = function ($parent_id)
         {
             if ($parent_id > 0) {

+ 2 - 0
test/TestRefillBalance.php

@@ -22,6 +22,8 @@ class TestRefillBalance extends TestCase
 
     public function testAddBalance()
     {
+        Log::short_name('testAddBalance');
+        Log::record("xxx",Log::DEBUG);
         $refill_balance = new statistics\refill_balance();
         $refill_balance->add_balance('system', 0, 0, strtotime('2021-12-01'), 'order_time');
     }