Browse Source

申请发票新增申请编号

master
wanghongjun 1 year ago
parent
commit
c35c6c56f7
  1. 3
      app/controller/api/InvoiceIssuance.php
  2. 15
      app/service/invoice/InvoiceIssuanceService.php

3
app/controller/api/InvoiceIssuance.php

@ -171,7 +171,8 @@ class InvoiceIssuance extends Base
} else { } else {
validate(InvoiceIssuanceValidate::class)->scene('add')->check($params); validate(InvoiceIssuanceValidate::class)->scene('add')->check($params);
$data['create_time'] = time(); $data['create_time'] = time();
$data['serial_number'] = (new InvoiceIssuanceService())->getSerialNumber();
(new InvoiceIssuanceModel())->save($data); (new InvoiceIssuanceModel())->save($data);
} }

15
app/service/invoice/InvoiceIssuanceService.php

@ -54,12 +54,12 @@ class InvoiceIssuanceService
$model = (new InvoiceIssuance()); $model = (new InvoiceIssuance());
$data = $model->where($where) $data = $model->where($where)
->field('id,project_id,invoice_head_id,amount,create_time,status') ->field('id,project_id,invoice_head_id,amount,create_time,status,serial_number')
->order('create_time desc') ->order('create_time desc')
->paginate($limit, false) ->paginate($limit, false)
->each(function ($item, $key) { ->each(function ($item, $key) {
$InvoiceHead = (new InvoiceHead)->find($item->invoice_head_id); $InvoiceHead = (new InvoiceHead)->find($item->invoice_head_id);
$item->serial_number = date("YmdHis") . rand(0000, 9999); $item->serial_number = !empty($item->serial_number) ? $item->serial_number : $this->getSerialNumber();
$item->head_type = ''; $item->head_type = '';
$item->head_title = ''; $item->head_title = '';
if ($InvoiceHead) { if ($InvoiceHead) {
@ -72,6 +72,15 @@ class InvoiceIssuanceService
return $data->toArray(); return $data->toArray();
} }
/**
* 获取订单编号
* @return string
*/
public function getSerialNumber(): string
{
return date("YmdHis") . rand(0000, 9999);
}
/** /**
* 验证缴费 * 验证缴费
* @param $pucode * @param $pucode
@ -269,7 +278,7 @@ class InvoiceIssuanceService
(new InvoiceIssuanceData())->saveData($invoiceIssuance['id'], $bdznsrsbh, $jsyj, $assetID, $pdfFilepath); (new InvoiceIssuanceData())->saveData($invoiceIssuance['id'], $bdznsrsbh, $jsyj, $assetID, $pdfFilepath);
(new InvoiceIssuance())->where('id', $invoiceIssuance['id'])->save(['status' => 3]); (new InvoiceIssuance())->where('id', $invoiceIssuance['id'])->save(['status' => 3, 'issuance_time' => time()]);
} else if ($realTimeProcessing['code'] == 302) { } else if ($realTimeProcessing['code'] == 302) {
// 加工失败 // 加工失败

Loading…
Cancel
Save