0, 'delete_time' => 0]; $InvoiceIssuanceData = (new InvoiceIssuanceModel())->where($where)->page(1, $this->limit)->select()->toArray(); foreach ($InvoiceIssuanceData as $InvoiceIssuanceValue) { $result = (new InvoiceIssuanceService())->tempIssueAnInvoice($InvoiceIssuanceValue); if ($result === true) { $this->invoiceSuccess($InvoiceIssuanceValue); } } return $this->buildSuccess(); } /** * 开票失败 修改为虚拟 继续发起 * @return Response * @throws \fast\FuncException * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function runCancelInitiateAgain(): Response { $where = ['status' => 1, 'delete_time' => 0]; $InvoiceIssuanceData = (new InvoiceIssuanceModel())->where($where)->page(1, $this->limit)->select()->toArray(); foreach ($InvoiceIssuanceData as $InvoiceIssuanceValue) { $result = (new InvoiceIssuanceService())->cancelInitiateAgain($InvoiceIssuanceValue); if ($result === true) { $this->invoiceSuccess($InvoiceIssuanceValue); } } return $this->buildSuccess(); } /** * 保存结报数据 * @return Response */ public function runSummaryReport(): Response { $result = (new InvoiceIssuanceService())->saveSummaryReport(); if ($result !== true) { return $this->buildFailed('0', $result); } return $this->buildSuccess(); } /** * 开票成功 发送邮箱及短信提示 * @param $InvoiceIssuanceValue * @throws \fast\FuncException */ private function invoiceSuccess($InvoiceIssuanceValue) { if ($InvoiceIssuanceValue['email']) { // 发送发票到邮箱 $path = InvoiceQrCode::getDownFileUrl($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'])); } } } }