255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'name' => 'Name', 'pic_type' => 'Pic Type', 'pic' => 'Pic', 'level' => 'Level', 'price' => 'Price', 'goods_id' => 'Goods ID', 'recommend_reward' => 'Recommend Reward', 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'is_range' => 'is_range', 'is_achievement_user' => 'is_achievement_user', 'not_get_price_difference' => 'not_get_price_difference', 'not_distribute_payment_for_goods' => 'not_distribute_payment_for_goods', ]; } public static function setData(array $params) { try { if (!empty($params['id'])) { $model = self::findOne(['mall_id' => $params['mall_id'], 'id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if (empty($model)) throw new \Exception('服务不存在或已删除'); $obj = self::findOne(['mall_id' => $params['mall_id'], 'level' => $params['level'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if (!empty($obj) && $obj->id != $params['id']) { throw new \Exception('该等级已有礼包'); } } else { $model = self::findOne(['mall_id' => $params['mall_id'], 'level' => $params['level'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if (!empty($model)) { throw new \Exception('该等级已有礼包'); } $model = new self(); $model->loadDefaultValues(); } if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage()); if (!$model->save()) throw new \Exception($model->getErrorMessage()); return $model; } catch (\Exception $e) { self::$static_error = $e->getMessage(); return false; } } }