128], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => '商城ID', 'level_name' => '等级名称', 'level' => '等级(权重),数字越大,等级越高', 'bonus_rate' => '分红比例,5%,填5', 'status' => '状态:-1删除,0禁用,1启用', 'created_at' => '创建时间', 'updated_at' => '更新时间', ]; } /** * 数据设置 */ public static function setData(array $params) { try{ if (!isset($params['mall_id']) || empty($params['mall_id'])) throw new Exception('缺少商城ID'); if (isset($params['id']) && !empty($params['id'])) { $model = self::findOne(['id' => $params['id'], 'mall_id' => $params['mall_id'], 'status' => [StatusEnum::DISABLED, StatusEnum::ENABLED]]); if(empty($model)) throw new Exception('招商员等级不存在或已删除'); } else { $model = new self(); $model->loadDefaultValues(); $model->mall_id = $params['mall_id']; } if (!$model->load($params,'') || !$model->save()) throw new Exception($model->getErrorMessage()); return $model; }catch(Exception $e){ self::setStaticError($e->getMessage()); return false; } } }