Db::startTrans();
try{
Db::commit();
} catch (\Exception $e) {
Db::rollback();
}
use think\Db; 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', 'the IN', $ ID ]], [ 'INVOICE_ID' => $ INVOICE_ID ]); // update payment orders IF ( $ INVOICE_ID && $ pay_log_res ) { Db :: the commit () ; return [ 'code' => 200 is ]; } the else { addlog ( '/ Upload / running_log / Invoice', 'Invoice', 'application billing failure, $ INVOICE_ID:'. $ INVOICE_ID '; $ pay_log_res:'.. $ pay_log_res 'billing order details:'.. json_encode ( $ the Data )); Db ::rollback(); return[ 'code' => -100, 'msg' => ' modification failure' ]; } } the catch (\ Exception $ E ) { addlog ( '/ Upload / running_log / Invoice', 'Invoice', 'billing application fails, billing Information Order: 'json_encode (. $ Data ) .'---- results:'. $ E -> the getMessage ()); Db :: ROLLBACK (); return [ 'code' => -100, 'MSG' => 'modification failure' ]; } }