stanley-king 4 miesięcy temu
rodzic
commit
11f9ed7707

+ 4 - 1
crontab/control/date.php

@@ -20,6 +20,8 @@ require_once(BASE_HELPER_PATH . '/message/publisher.php');
 
 require_once(BASE_HELPER_PATH . '/refill/ops/order_clear.php');
 require_once(BASE_HELPER_PATH . '/refill/ops/pdlog_clear.php');
+require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
+require_once(BASE_HELPER_PATH . '/vendor/yifutongtax.php');
 
 class dateControl extends BaseCronControl
 {
@@ -1237,6 +1239,7 @@ class dateControl extends BaseCronControl
     #易付通含税,定时处理
     public function YiFuTongTaxOp()
     {
-
+        $yft = new vendor\yifutongtax();
+        $yft->run();
     }
 }

+ 1 - 0
docker/compose/xyz/conf/crontab/slavex_root

@@ -0,0 +1 @@
+0   10    *   *   *   php /var/www/html/crontab/index.php date YiFuTongTax

+ 2 - 2
docker/compose/xyz/yz-slaveex/docker-compose.yml

@@ -2,12 +2,12 @@ version: "3.7"
 
 services:
   crontabslaveex:
-    image: php-zts:7.3.18
+    image: php-zts-fcgi:7.3.18
     volumes:
       - ../../../../:${SHOP_ROOT_PATH}
       - ../conf/etc/localtime:/etc/localtime:ro
       - ../conf/php/php.ini:/usr/local/etc/php/php.ini
-      - ../conf/crontab/slave_root:/var/spool/cron/crontabs/root
+      - ../conf/crontab/slavex_root:/var/spool/cron/crontabs/root
       - ${SHOP_UPLOAD_PATH}:${SHOP_ROOT_PATH}/data/upload
       - ${SHOP_LOG_PATH}:${SHOP_ROOT_PATH}/data/log
     container_name: "${CONTAINER_PREFIX}-slavex-cron"

+ 75 - 7
helper/vendor/yifutongtax.php

@@ -12,28 +12,40 @@ namespace vendor;
 
 use Log;
 use refill;
-use refill\util;
 
 class yifutongtax
 {
     const LocalPath = BASE_UPLOAD_PATH . "/YIFUTONG";
     public function handle()
     {
-        $local_files = $this->down_files();
+//        $local_files = $this->down_files();
 //        foreach ($local_files as $file) {
 //            Log::record("file=$file",Log::DEBUG);
 //            $this->parese_file($file);
 //        }
-
-        foreach ($local_files as $file) {
-            Log::record("file=$file",Log::DEBUG);
-            $this->modify_time($file);
-        }
+//        foreach ($local_files as $file) {
+//            Log::record("file=$file",Log::DEBUG);
+//            $this->modify_time($file);
+//        }
     }
 
     public function run()
     {
+        //获取前一天数据
+        $cur_time = time();
+        $file = strftime("%Y%m%d_000110089970029",$cur_time - 86400);
+
+        $local_files = $this->down_file($file);
+        foreach ($local_files as $file) {
+            Log::record("file=$file",Log::DEBUG);
+            $this->parese_file($file);
+        }
 
+        sleep(60);
+        foreach ($local_files as $file) {
+            Log::record("file=$file",Log::DEBUG);
+            $this->modify_time($file);
+        }
     }
 
 
@@ -122,6 +134,62 @@ class yifutongtax
         }
     }
 
+    private function down_file($file)
+    {
+        #北京业务的文件 sftp  221.122.92.145:10022    帐号 ylyw   密码 ylyw123
+        $conn = ssh2_connect('221.122.92.145', 10022);
+        if (!ssh2_auth_password($conn, 'ylyw', 'ylyw123')) {
+            Log::record("Cannot connect to ftp server.", Log::DEBUG);
+            return false;
+        }
+
+        $sftp = ssh2_sftp($conn);
+        if (!$sftp) {
+            Log::record('Cannot init SFTP');
+            return false;
+        }
+
+        $rpath_gen = function ($sftp) {
+            return "ssh2.sftp://" . intval($sftp) . "/";
+
+        };
+
+        $files_downloader = function ($sftp, $files, $local_path) use ($rpath_gen)
+        {
+            $local_files = [];
+            foreach ($files as $name)
+            {
+                $remote_file = $rpath_gen($sftp) . $name;
+
+                if (!file_exists($remote_file)) {
+                    Log::record("$remote_file not exist.", Log::DEBUG);
+                    continue;
+                } else {
+                    Log::record("find file=$remote_file", Log::DEBUG);
+                }
+
+                $local_file = $local_path . "/$name";
+                Log::record("path=$local_file", Log::DEBUG);
+
+                if (!copy($remote_file, $local_file)) {
+                    Log::record("copy $remote_file to $local_file error.", Log::DEBUG);
+                }
+                else
+                {
+                    $local_files[] = $local_file;
+                }
+            }
+
+            return $local_files;
+        };
+
+        $local_files = $files_downloader($sftp, [$file], static::LocalPath);
+
+        ssh2_disconnect($conn);
+
+        return $local_files;
+    }
+
     private function down_files()
     {
         #北京业务的文件 sftp  221.122.92.145:10022    帐号 ylyw   密码 ylyw123