shensong 5 gadi atpakaļ
vecāks
revīzija
65df4acf2e

+ 13 - 3
app/Console/Commands/ErrorLogMonitor.php

25
     {
25
     {
26
         //本地测试路径
26
         //本地测试路径
27
 //        $path = dirname(__FILE__).'\..\..\..\public';
27
 //        $path = dirname(__FILE__).'\..\..\..\public';
28
-$path = '\log\seafood_log\error';
29
-        $fileName = '\\'.date('Y-m-d',time()).'.txt';
28
+        $path1 = '/log/seafood_log/error';
29
+        $res1 = $this->chargeFile($path1);
30
+        $path2 = '/log/seafood_log/script_error';
31
+        $res2 = $this->chargeFile($path2);
32
+        if($res1 || $res2){
33
+            $this->sendMsg('13161864516');
34
+        }
35
+    }
36
+
37
+    public function chargeFile($path){
38
+        $fileName = '/'.date('Y-m-d',time()).'.txt';
30
         //判断文件是否存在
39
         //判断文件是否存在
31
         $fileName = $path.$fileName;
40
         $fileName = $path.$fileName;
32
         $fileRes = file_exists($fileName);
41
         $fileRes = file_exists($fileName);
39
             //判断最后一行时间是否在3分钟内
48
             //判断最后一行时间是否在3分钟内
40
             if(time()-$time <= 180){
49
             if(time()-$time <= 180){
41
                 //报警
50
                 //报警
42
-                $this->sendMsg('13161864516');
51
+                return true;
43
             }
52
             }
44
         }
53
         }
54
+        return false;
45
     }
55
     }
46
 
56
 
47
     //获取文件最后一行内容
57
     //获取文件最后一行内容

+ 9 - 3
app/Console/Commands/SyncMjWarehouse.php

32
     {
32
     {
33
         try {
33
         try {
34
             $this->SyncMjWarehouse();
34
             $this->SyncMjWarehouse();
35
-//            $this->diffRealPriceSkuListArr = array('banjiexia-03','csxpxx-01');
35
+//            $this->diffRealPriceSkuListArr = array(
36
+//                0=>array('code'=>'banjiexia-03','oldPrice'=>'10','newPrice'=>'20'),
37
+//                1=>array('code'=>'csxpxx-01','oldPrice'=>'100','newPrice'=>'50'),
38
+//            );
36
             if (count($this->diffRealPriceSkuListArr) > 0) {
39
             if (count($this->diffRealPriceSkuListArr) > 0) {
37
                 $this->skuRealPriceMonitor();
40
                 $this->skuRealPriceMonitor();
38
             }
41
             }
102
                         if($oldRealPrice != 0){
105
                         if($oldRealPrice != 0){
103
                             $result = $this->getNumberDiffAbs($newRealPrice,$oldRealPrice);
106
                             $result = $this->getNumberDiffAbs($newRealPrice,$oldRealPrice);
104
                             if($result >= 0.1){
107
                             if($result >= 0.1){
105
-                                $this->diffRealPriceSkuListArr[] = $code;
108
+                                $json['code'] = $code;
109
+                                $json['oldPrice'] = $oldRealPrice;
110
+                                $json['newPrice'] = $newRealPrice;
111
+                                $this->diffRealPriceSkuListArr[] = $json;
106
                             }
112
                             }
107
                         }
113
                         }
108
                     }
114
                     }
129
         #发送验证码报警
135
         #发送验证码报警
130
         $this->sendMsg('13161864516',$text);
136
         $this->sendMsg('13161864516',$text);
131
         $this->sendMsg('18410900527',$text);
137
         $this->sendMsg('18410900527',$text);
132
-        error_log(date('Y-m-d H:i:s',time()).' skuList:'.$text." \n ",3,"/log/seafood_log/script_success/".date('Y-m-d',time()).'MonitorRealPrice.log');
138
+//        error_log(date('Y-m-d H:i:s',time()).' skuList:'.$text." \n ",3,"/log/seafood_log/script_success/".date('Y-m-d',time()).'MonitorRealPrice.log');
133
 
139
 
134
     }
140
     }
135
 
141