0, 'delete_time' => 0]; $InvoiceIssuanceData = (new InvoiceIssuanceModel())->where($where)->page(1, $limit)->select(); foreach ($InvoiceIssuanceData as $InvoiceIssuanceValue) { $result = (new InvoiceIssuanceService())->IssueAnInvoice($InvoiceIssuanceValue); if ($result === true) { $this->invoiceSuccess($InvoiceIssuanceValue); } } return $this->buildSuccess(); } /** * 开票失败 修改为虚拟 继续发起 * @return \think\Response * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function runCancelInitiateAgain() { $limit = 100; $where = ['status' => 1, 'delete_time' => 0]; $InvoiceIssuanceData = (new InvoiceIssuanceModel())->where($where)->page(1, $limit)->select(); foreach ($InvoiceIssuanceData as $InvoiceIssuanceValue) { $result = (new InvoiceIssuanceService())->cancelInitiateAgain($InvoiceIssuanceValue); if ($result === true) { $this->invoiceSuccess($InvoiceIssuanceValue); } } return $this->buildSuccess(); } private function invoiceSuccess($InvoiceIssuanceValue) { if ($InvoiceIssuanceValue['email']) { // 发送发票到邮箱 $path = InvoiceIssuanceService::getQrCode($InvoiceIssuanceValue['id']); $emailResult = (new EmailService())->sendInvoice($InvoiceIssuanceValue['email'], '发票', $path); if ($emailResult === true && $InvoiceIssuanceValue['mobile']) { // 发送短信 $SmsService = new SmsService(); $SmsService->sendSms($InvoiceIssuanceValue['mobile'], $SmsService->smsInvoiceTemplate($InvoiceIssuanceValue['email'])); } } } }