|
|
@@ -0,0 +1,67 @@
|
|
|
+<?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));
|
|
|
+ }
|
|
|
+}
|