stanley-king 2 years ago
parent
commit
ae9cae8a86
1 changed files with 9 additions and 3 deletions
  1. 9 3
      helper/task/handler.php

+ 9 - 3
helper/task/handler.php

@@ -237,7 +237,9 @@ class handler
 
                     if(empty($items)) break;
 
-                    $order_id = intval(end($items)['order_id']);
+                    $last_item = end($items);
+                    $order_id = intval($last_item['order_id']);
+                    Log::record("handler order_id={$order_id}",Log::DEBUG);
                     yield [$items,$total_stage,$cur_stage];
                 }
                 $cur_stage++;
@@ -322,10 +324,12 @@ class handler
             [$items,$total_stage,$cur_stage] = $result;
             foreach ($items as $order)
             {
+                Log::record("handler write order index={$execl_index}",Log::DEBUG);
+
                 $execl_writer($order,$execl_index);
                 $execl_index += 1;
             }
-            Log::record("total_stage={$total_stage} cur_stage={$cur_stage}",Log::DEBUG);
+            Log::record("handler total_stage={$total_stage} cur_stage={$cur_stage}",Log::DEBUG);
             if($stage == 0) {
                 $stage = $cur_stage;
             }
@@ -334,6 +338,9 @@ class handler
                 $stage = $cur_stage;
             }
         }
+        if($stage > 0) {
+            $percentor($total_stage,$total_stage);
+        }
 
         try {
             $path = BASE_ROOT_PATH . "/data/upload/task/";
@@ -346,7 +353,6 @@ class handler
             $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
             $objWriter->save($file_path);
 
-
             return [true, $filename];
         } catch (Exception $e) {
             Log::record($e->getMessage(),Log::ERR);