255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'store_id' => 'Store ID', 'key' => 'Key', 'value' => 'Value', 'created_at' => '创建时间', 'updated_at' => '修改时间', 'is_delete' => '是否删除 0--未删除 1--已删除', 'deleted_at' => '删除时间', ]; } /** * 获取数据 * @param null $key * @param null $mall_id * @param int $store_id * @return bool|string */ public static function getValueByKey($key = null, $mall_id = null,$store_id = 0) { if (!$key) { return false; } if (!$mall_id) { $mall_id = Yii::$app->mall->id; } if (!$mall_id) { return false; } $model = BossSetting::findOne(['mall_id' => $mall_id,'store_id' => $store_id, 'is_delete' => 0, 'key' => $key]); if ($model) { return $model->value; } return false; } public static function strToNumber($key, $str) { $default = ['is_enable', 'compute_period', 'compute_type']; if (in_array($key, $default)) { return round($str, 2); } return $str; } /** * 获取股东配置,并组成key-value数组 * @param $mallId * @param $store_id * @return array */ public static function getData($mallId,$store_id = 0) { $list = self::find()->where(['mall_id' => $mallId,'store_id' => $store_id, 'is_delete' => 0])->all(); $newList = []; /* @var self[] $list */ foreach ($list as $item) { $newList[$item->key] = self::strToNumber($item->key, Yii::$app->serializer->decode($item->value)); } return $newList; } }