Db::startTrans();
try{
Db::commit();
} catch (Exception $e) {
Db::rollback();
}
use thinkDb; public function addInfoData($member_id, $type, $money, $invoice_name, $invoice_tel, $email, $taxpayer_number, $id) { Db::startTrans(); try{ $invoice_id = $this->insertGetId($data);//添加 发票记录 $pay_log_model = new PayLog(); $pay_log_res = $pay_log_model->updateDataByWhere([['id', 'IN', $id]], ['invoice_id' => $invoice_id]);//更新 支付订单 if($invoice_id && $pay_log_res){ Db::commit(); return ['code' => 200]; }else{ addlog('/upload/running_log/invoice','invoice', '申请开票失败,$invoice_id:'.$invoice_id.';$pay_log_res:'.$pay_log_res.'开票订单详情:'.json_encode($data)); Db::rollback(); return ['code' => -100, 'msg' => '修改失败']; } } catch (Exception $e) { addlog('/upload/running_log/invoice','invoice', '申请开票失败,开票订单详情:'.json_encode($data).'----结果:'.$e->getMessage()); Db::rollback(); return ['code' => -100, 'msg' => '修改失败']; } }