diff --git a/app/service/invoice/InvoiceIssuanceService.php b/app/service/invoice/InvoiceIssuanceService.php index 9337a7f..c74751d 100644 --- a/app/service/invoice/InvoiceIssuanceService.php +++ b/app/service/invoice/InvoiceIssuanceService.php @@ -198,6 +198,25 @@ class InvoiceIssuanceService return $feeUsers; } + /** + * 获取被代征纳税人识别号 + * @param $invoice_head_id // 抬头id + * @return mixed|string + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function getTaxNumber($invoice_head_id) + { + $bdznsrsbh = '91440300772709730N'; // 被代征纳税人识别号 【默认大工业水务税号】 + // 如果是企业 需要取填写抬头的税号 + $invoice_head = (new InvoiceHead())->where('id', $invoice_head_id)->where('type', 0)->field('tax_number')->find(); + if ($invoice_head) { + $bdznsrsbh = $invoice_head['tax_number'] ?? ''; + } + return $bdznsrsbh; + } + /** * 开具完税证明 * @param $invoiceIssuance // 开票信息 @@ -217,7 +236,7 @@ class InvoiceIssuanceService $feeUsers = $this->getFeeUserData($pucode); - $bdznsrsbh = '91440300772709730N'; // 被代征纳税人识别号 + $bdznsrsbh = $this->getTaxNumber($invoiceIssuance['invoice_head_id']); // 被代征纳税人识别号 $feeUsers['bdznsrsbh'] = $bdznsrsbh; @@ -328,7 +347,7 @@ class InvoiceIssuanceService throw new FuncException('上次发起数据不存在'); } - $bdznsrsbh = '91440300772709730N'; // 被代征纳税人识别号 + $bdznsrsbh = $this->getTaxNumber($invoiceIssuance['invoice_head_id']); // 被代征纳税人识别号 $sbpch = $InvoiceIssuanceData['sbpch']; $ChinaTaxes = new ChinaTaxes($feeUsers, []);