stores = $stores; } /** * Execute the job. * * @param StoreService $service * @return void * @throws */ public function handle(StoreService $service) { if (!$this->stores)return; $errors = []; foreach ($this->stores as $store){ try{ if (!$service->createInstantBill($store)) $this->push(__METHOD__."->".__LINE__,"订单生成即时账单",$store->toJson()); }catch(QueryException $qe){ if ($qe->getCode()!='23000'){ $this->push(__METHOD__."->".__LINE__,"入库生成即时账单",$store->toJson()." | ".$qe->getMessage()); $errors = ["store_".$store->id.":".$qe->getMessage()]; } }catch (\Exception $e){ $this->push(__METHOD__."->".__LINE__,"入库生成即时账单",$store->toJson()." | ".$e->getMessage()); $errors = ["store_".$store->id.":".$e->getMessage()]; } } if ($errors)throw new \Exception(json_encode($errors)); } }