/** * @param $id * @param $credit1 * @param $credit2 * @return $this|bool|null * 根据ID修改余额和积分 */ function updateCreditById($id, $credit1, $credit2){ if(!check_id($id)){ return false; } try{ $where = [ 'uid' => $id ]; if ($credit1 < 0) { $where['credit1'] = ['>=', abs($credit1)]; } if ($credit2 < 0) { $where['credit2'] = ['>=', abs($credit2)]; } $result = Db::table('tb_member') ->where($where) ->inc('credit1', $credit1) ->inc('credit2', $credit2) ->exp('update_time', TIMESTAMP) ->update(); //echo Db::getLastSql();exit; return $result > 0; }catch (Exception $e){ Log::error(__FILE__.':'.__LINE__.' 错误:'.$e->getMessage()); return null; } }
如果本文对你有帮助,欢迎打赏本站