| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace App\Jobs;
- use App\Model\EnterpriseRecord;
- use App\Model\Record;
- use App\Service\EnterpriseWechatService;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Queue\SerializesModels;
- use Symfony\Component\Console\Output\ConsoleOutput;
- use Symfony\Component\Console\Output\OutputInterface;
- class WxProcessDataJob implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- protected $data;
- public $timeout = 30;
- public function __construct($data)
- {
- $this->data = $data;
- }
- public function handle()
- {
- try {
- list($bool, $msg) = $this->settle();
- if(! $bool) $this->finalDo($msg);
- } catch (\Throwable $e) {
- $this->finalDo("异常:" . $e->getMessage());
- $this->delete();
- }
- }
- private function finalDo($msg){
- $data = $this->data;
- EnterpriseRecord::where('sp_no', $data['sp_no'])
- ->update(['result' => $msg]);
- }
- private function settle()
- {
- $data = $this->data;
- try {
- $no = $data['sp_no'];
- $template_id = $data['template_id'];
- $service = new EnterpriseWechatService();
- $detail = $service->getOA()->approvalDetail($no);
- //todo
- } catch (\Throwable $e) {
- return [false, $e->getMessage()];
- }
- return [true, ''];
- }
- protected function echoMessage(OutputInterface $output)
- {
- //输出消息
- $output->writeln(json_encode($this->data));
- }
- }
|