const { DataTypes } = require('sequelize');
const sequelize = require('./db');

const Prize = sequelize.define('Prize', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  activityId: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  name: {
    type: DataTypes.STRING,
    allowNull: false
  },
  level: {
    type: DataTypes.ENUM('特等奖', '一等奖', '二等奖', '三等奖', '四等奖', '参与奖', '伴手礼'),
    allowNull: false
  },
  description: DataTypes.TEXT,
  image: DataTypes.STRING,
  quantity: {
    type: DataTypes.INTEGER,
    defaultValue: 1
  },
  sortOrder: {
    type: DataTypes.INTEGER,
    defaultValue: 0,
    comment: '排序值,数字越小越靠前'
  },
  source: {
    type: DataTypes.ENUM('member', 'sponsor', 'purchase'),
    defaultValue: 'purchase',
    comment: '来源: member-群友赞助, sponsor-赞助商提供, purchase-采购'
  },
  sponsor: {
    type: DataTypes.STRING,
    comment: '赞助者名称（群友或赞助商）'
  }
});

module.exports = Prize;
