'delete'], [['cx_mch_id',], 'required'], ]; } public function delete() { if(!$this->validate()){ return $this->getModelError(); } if(is_array($this->blog_id)){ foreach ($this->blog_id as $blog_id){ $model = BalanceLog::findOne([ 'id' => $blog_id, 'scene' => $this->scene, 'is_delete' => 0, 'user_id' => $this->user_id, 'cx_mch_id' => $this->cx_mch_id ]); if($model == null) continue; $model->is_delete = 1; if(!$model->save()){ return $this->getModelError($model); } } } else { $model = BalanceLog::findOne([ 'id' => $this->blog_id, 'scene' => $this->scene, 'is_delete' => 0, 'user_id' => $this->user_id, 'cx_mch_id' => $this->cx_mch_id ]); if($model == null){ return $this->apiReturnError('钱包明细不存在或已经删除'); } $model->is_delete = 1; if(!$model->save()){ return $this->getModelError($model); } } return $this->apiReturnSuccess("删除成功"); } }