laravel事务,参数问题
第一种方法
DB::transaction(function ()use($id,$service_user_id) {
});
第二种方法
//开启事务 DB::beginTransaction(); $s = DB::table('coupon_receives')->insert([ ['coupon_id' => $id, 'service_user_id' => $service_user_id , 'coupon_money' => $coupon['coupon_money'] , 'full_money' => $coupon['full_money'] ] ]); $s = $s && DB::table('coupons')->where('coupon_id',$id)->increment('coupon_amount'); if($s){ DB::commit(); }else{ DB::rollBack(); }