255], [['explain'], 'string', 'max' => 5000], [['cloud_stock_level'], 'string', 'max' => 5000], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => '商城id', 'level' => '等级权重id', 'cloud_stock_level' => '代理等级', 'name' => '等级名称', 'checked_condition_values' => '升级条件', 'checked_condition_keys' => '升级条件选中的key集合', 'condition_type' => '0 未选择、1满足其一 2、满足所有', 'upgrade_type_condition' => '是否开启条件升级', 'explain' => '等级说明', 'money' => '当前池金额', 'total_money' => '累计池金额', 'goods_setting' => '商品设置', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } public static function setData(array $params){ try{ if(!empty($params['id'])){ $model = self::findOne(['and',['id' => $params['id'],'mall_id' => $params['mall_id']],['<>','status',StatusEnum::DELETE]]); if(empty($model)) throw new \Exception('等级不存在或已删除'); // 判断等级是否有被修改 if ($model->level != $params['level']) { $user = CloudStockBonusPoolUser::find()->where(['mall_id' => $model->mall_id, 'level' => $model->level, 'status' => StatusEnum::ENABLED])->asArray()->one(); if ($user) throw new Exception('该等级下存在用户,不能被修改'); } }else{ $model = new self(); $model->mall_id = $params['mall_id']; $model->loadDefaultValues(); } if(!$model->load($params,'') || !$model->save()){ throw new Exception($model->getErrorMessage()); } return $model->toArray(); }catch(\Exception $e){ self::$static_error = $e->getMessage(); return false; } } public static function getMap($mall_id) { $data = []; $list = self::find()->select('level,name')->where(['mall_id' => $mall_id, 'status' => [StatusEnum::ENABLED,StatusEnum::DISABLED]])->orderBy('level asc')->asArray()->all(); if ($list) { foreach ($list as $item) { $data[$item['level']] = $item['name']; } } return $data; } }