CREATE TABLE "public"."member_benefits" (
    "id" int4 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
    "type" varchar(32),
    "value" decimal(10,2),
    "ref_id" int4,
    "num" int2 default 1,
    "receive_type" varchar(32),
    "goods_level" int2,
    "status" int2 default 0,
    "super_tag" int2 default 0,
    "create_time" timestamp,
    "update_time" timestamp,
    PRIMARY KEY ("id")
);

COMMENT ON COLUMN "public"."member_benefits"."type" IS '权益类型,关联商品:goods,优惠劵:coupon,积分权益:point,折扣:goods_discount,组队折扣:group_discount,运费券:shipping_free';

COMMENT ON COLUMN "public"."member_benefits"."value" IS '数值类权益值,积分倍数,商品折扣';

COMMENT ON COLUMN "public"."member_benefits"."ref_id" IS '关联权益值id,商品id,优惠劵id等';

COMMENT ON COLUMN "public"."member_benefits"."num" IS '数量';

COMMENT ON COLUMN "public"."member_benefits"."receive_type" IS '赠送类权益领取次数,once:一次,month:月,year:年等';

COMMENT ON COLUMN "public"."member_benefits"."goods_level" IS '可看见的商品等级';

COMMENT ON COLUMN "public"."member_benefits"."status" IS '状态,0:新建,1:在线';

COMMENT ON COLUMN "public"."member_benefits"."super_tag" IS '专属标签,根据标签在特殊场合使用特殊特效';



CREATE TABLE "public"."member_benefits_manage" (
    "id" int4 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
    "member_id" int4,
    "member_benefits_id" int4,
    "time_type" int4 default 0,
    "start_time" timestamp,
    "end_time" timestamp,
    "create_time" timestamp,
    PRIMARY KEY ("id")
);


COMMENT ON COLUMN "public"."member_benefits_manage"."member_id" IS '会员id';

COMMENT ON COLUMN "public"."member_benefits_manage"."member_benefits_id" IS '权益id';

COMMENT ON COLUMN "public"."member_benefits_manage"."time_type" IS '权益生效时间类型,0:永久,1:自定义时间段';

COMMENT ON COLUMN "public"."member_benefits_manage"."start_time" IS '权益生效开始时间';

COMMENT ON COLUMN "public"."member_benefits_manage"."end_time" IS '权益生效结束时间';



CREATE TABLE "public"."member_benefits_record" (
    "id" int4 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
    "user_id" int4,
    "member_id" int4,
    "member_benefits_id" int4,
    "benefits_ref_id" int4,
    "status" int2 default 0,
    "receive_num" int2 default 1,
    "user_num" int2 default 0,
    "create_time" timestamp,
    "update_time" timestamp,
    PRIMARY KEY ("id")
);


COMMENT ON COLUMN "public"."member_benefits_record"."user_id" IS '用户id';

COMMENT ON COLUMN "public"."member_benefits_record"."member_id" IS '会员id';

COMMENT ON COLUMN "public"."member_benefits_record"."member_benefits_id" IS '权益id';

COMMENT ON COLUMN "public"."member_benefits_record"."benefits_ref_id" IS '权益关联id';

COMMENT ON COLUMN "public"."member_benefits_record"."receive_num" IS '领取数量';

COMMENT ON COLUMN "public"."member_benefits_record"."user_num" IS '使用数量';