$user_id, 'contract_id'=>$contract_id ])->lock(true)->find(); if(empty($info)){ // 如果没有则创建 $info = new self; $info->user_id = $user_id; $info->contract_id = $contract_id; $info->usable_num = 0; $info->frozen_num = 0; $info->create_time = date('Y-m-d H:i:s'); $info->update_time = date('Y-m-d H:i:s'); $info->save(); } return $info->toArray(); } public static function updateUserStockIndexInr(array $update_data,array $where) { $update_data['update_time']=date('Y-m-d H:i:s'); $res=self::where($where)->save($update_data); //echo self::where($where)->getLastSql(); return $res; } }