TimestampBehavior::class ] ]; } /** * @inheritdoc */ public function rules() { return [ [['id', 'user_id', 'store_id', 'created_at', 'updated_at', 'parent_user_id'], 'integer'], [['direct_price', 'support_price', 'group_price', 'total_price', 'price'], 'number'] ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => '', 'user_id' => '用户ID', 'parent_user_id' => '上级用户ID', 'store_id' => 'Store Id', 'direct_price' => '当前点位直推佣金', 'support_price' => '当前点位扶持佣金', 'group_price' => '成团佣金', 'total_price' => '累计佣金', 'price' => '可提现佣金', 'created_at' => '', 'updated_at' => '', ]; } public function beforeSave($insert) { if (parent::beforeSave($insert)) { if ($insert) { $self = self::findOne(['user_id' => $this->user_id]); if ($self) { $this->addError('user', '用户已存在'); return false; } } return true; } return false; } }