作者 王智

222

@@ -78,7 +78,12 @@ class Invoice extends Api @@ -78,7 +78,12 @@ class Invoice extends Api
78 'invoice_type' => $param['invoice_type'], 78 'invoice_type' => $param['invoice_type'],
79 ]; 79 ];
80 } 80 }
81 - $res = Db::name('invoice_ziliao')->insert($data); 81 + $invoice_id = Db::name('invoice_ziliao')->where(['type' => $param['type']])->where(['invoice_type' => $param['invoice_type']])->value('id');
  82 + if (empty($invoice_id)) {
  83 + $res = Db::name('invoice_ziliao')->insert($data);
  84 + } else {
  85 + $res = Db::name('invoice_ziliao')->where(['id' => $invoice_id])->update($data);
  86 + }
82 if ($res) { 87 if ($res) {
83 $this->success('成功', 1); 88 $this->success('成功', 1);
84 } else { 89 } else {