| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 | 
							- <?php
 
- namespace App\Jobs;
 
- use App\Model\RevenueCostMain;
 
- use App\Service\TPlusServerService;
 
- use Illuminate\Bus\Queueable;
 
- use Illuminate\Contracts\Queue\ShouldQueue;
 
- use Illuminate\Foundation\Bus\Dispatchable;
 
- use Illuminate\Queue\InteractsWithQueue;
 
- use Illuminate\Queue\SerializesModels;
 
- use Illuminate\Support\Facades\DB;
 
- use Illuminate\Support\Facades\Redis;
 
- use MongoDB\Driver\Exception\Exception;
 
- use Symfony\Component\Console\Output\ConsoleOutput;
 
- use Symfony\Component\Console\Output\OutputInterface;
 
- class ProcessDataJob implements ShouldQueue
 
- {
 
-     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 
-     protected $data;
 
-     protected $user;
 
-     protected $type;
 
-     public $timeout = 1800;
 
-     public function __construct($data, $user, $type = 1)
 
-     {
 
-         $this->data = $data;
 
-         $this->user = $user;
 
-         $this->type = $type;
 
-     }
 
-     public function handle()
 
-     {
 
-         $service = new TPlusServerService();
 
-         try {
 
-             $data = $this->data;
 
-             $user = $this->user;
 
-             $type = $this->type;
 
-             if($type == 1){
 
-                 //收付款单
 
-                 list($status, $msg) = $service->synRevenueCostFromTPlus($data, $user);
 
-             }else{
 
-                 list($status, $msg) = $service->synSalaryEmployeeFromMine($data, $user);
 
-             }
 
-             $this->finalDo($msg, $service);
 
-         } catch (\Throwable $e) {
 
-             $this->finalDo("异常:" . $e->getMessage(), $service);
 
-             $this->delete();
 
-         }
 
-     }
 
-     private function finalDo($msg, $service){
 
-         $type = $this->type;
 
-         $service->delTableKey($type);
 
-         if($type == 1) $service->clearTmpTable();
 
-         $user = $this->user;
 
-         $data = $this->data;
 
-         RevenueCostMain::insert([
 
-             'result' => $msg,
 
-             'crt_id' => $user['id'],
 
-             'crt_time' => $data['operation_time'],
 
-             'order_type' => $data['type'],
 
-         ]);
 
-     }
 
-     protected function echoMessage(OutputInterface $output)
 
-     {
 
-         //输出消息
 
-         $output->writeln(json_encode($this->data));
 
-     }
 
- }
 
 
  |