255], [['share_title', 'share_content'], 'string', 'max' => 65], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'is_enabled' => 'Is Enabled', 'is_check' => 'Is Check', 'release_rule' => 'Release Rule', 'award_status' => 'Award Status', 'award_type' => 'Award Type', 'award_percentage' => 'Award Percentage', 'award_money' => 'Award Money', 'purchase_times_status' => 'Purchase Times Status', 'purchase_times' => 'Purchase Times', 'purchase_cost_status' => 'Purchase Cost Status', 'purchase_cost' => 'Purchase Cost', 'purchase_goods_status' => 'Purchase Goods Status', 'purchase_goods_id' => 'Purchase Goods ID', 'video_lenght' => 'Video Lenght', 'agreement' => 'Agreement', 'status' => 'Status', 'client_status' => 'Client Status', 'start_up_diagram' => 'Start Up Diagram', 'share_img' => 'Share Img', 'share_title' => 'Share Title', 'share_content' => 'Share Content', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } public static function getConfig(int $mall_id) { $cache = \Yii::$app->cache; $configs = $cache->get(self::$cache_key . $mall_id); // dd($configs); if (!empty($configs)) return $configs; $configs = self::find() ->where(['mall_id' => $mall_id, 'status' => StatusEnum::ENABLED, 'is_enabled' => AddonsShortVideoEnum::IS_ENABLE_YES]) ->asArray() ->orderBy('updated_at desc') ->limit(1) ->one(); if (!empty($configs)) { if (1 == $configs['purchase_goods_status'] && !empty($configs['purchase_goods_id'])) { $good = Goods::findOne(['mall_id' => $mall_id, 'status' => StatusEnum::ENABLED, 'id' => $configs['purchase_goods_id']]); $configs['purchase_goods_name'] = $good->goods_name; } $cache->set(self::$cache_key . $mall_id, $configs, 3600); } else { $configs = []; } return $configs; } public static function setData(int $mall_id, array $data) { if (!empty($data['id'])) { $model = self::findOne(['mall_id' => $mall_id, 'status' => StatusEnum::ENABLED, 'id' => $data['id']]); if (empty($model)) { self::$static_error = '配置数据不存在'; return false; } } else { $model = new self(); $model->loadDefaultValues(); $model->mall_id = $mall_id; } foreach ($data as $key => $val) { $model->$key = $val; } if (!$model->save()) { self::$static_error = '保存奖励数据失败:' . $model->getErrorMessage(); return false; } \Yii::$app->cache->delete(self::$cache_key . $mall_id); return $model; } }