20], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => '商城ID', 'user_id' => '用户id', 'buy_numbers' => '购买次数', 'total_pay_money' => '交易金额', 'date' => '日期', 'status' => '状态[-1:删除;0:禁用;1启用;]', 'created_at' => '创建时间', 'updated_at' => '上次更新数据时间', ]; } public static function getConfigList($key = null) { $config_list = [ 1 => ['min' => 1, 'max' => 30, 'desc' => 'R<30'], 2 => ['min' => 30, 'max' => 90, 'desc' => '30<=R<90'], 3 => ['min' => 90, 'max' => 180, 'desc' => '90<=R<180'], 4 => ['min' => 180, 'max' => 365, 'desc' => '180<=R<365'], 5 => ['min' => 365, 'max' => 365, 'desc' => 'R>=365'], ]; if ($key !== null && isset($config_list[$key])) { return $config_list[$key]; } return $config_list; } public static function setData($params) { try { if (empty($params['mall_id']) || empty($params['date']) || empty($params['user_id'])) return false; $model = self::findOne(['mall_id' => $params['mall_id'], 'user_id' => $params['user_id'], 'date' => $params['date'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if (empty($model)) { $model = new self(); $model->date = $params['date']; $model->user_id = $params['user_id']; $model->mall_id = $params['mall_id']; $model->loadDefaultValues(); } if (!empty($params['buy_numbers'])) $model->buy_numbers += $params['buy_numbers']; if (!empty($params['total_pay_money'])) $model->total_pay_money += $params['total_pay_money']; if (!$model->save()) throw new \Exception($model->getErrorMessage()); return $model; } catch (\Exception $e) { self::$static_error = $e->getMessage(); return false; } } }