import { Entity, Column } from "typeorm";
import { BaseEntity } from "@/abstrClass/BaseEntity";
import dayjs from "dayjs";

@Entity("nodeceased_retail")
export class noDeceasedRetail extends BaseEntity {
  @Column("varchar", {
    name: "buyer",
    comment: "购买人",
    length: 255,
    default: "",
  })
  buyer: string;

  @Column("datetime", {
    name: "purchase_date",
    comment: "购买日期",
    default: () => "CURRENT_TIMESTAMP", // 默认值为当前时间
    transformer: {
      to(value: Date) {
        return value;
      },
      from(value) {
        return dayjs(new Date(value)).format("YYYY-MM-DD HH:mm:ss");
      },
    },
  })
  purchaseDate: Date;

  @Column("varchar", {
    name: "handler",
    comment: "经办人",
    length: 255,
    default: "",
  })
  handler: string;

  @Column("decimal", {
    name: "sales_amount",
    comment: "销售金额",
    precision: 10,
    scale: 2,
    default: 0.0,
  })
  salesAmount: number;

  @Column("varchar", {
    name: "guide",
    comment: "引导员",
    length: 255,
    default: "",
  })
  guide: string;

  @Column("varchar", {
    name: "family_name",
    comment: "购买人",
    length: 255,
    default: "",
  })
  familyName: string;

  @Column("varchar", {
    name: "family_phone",
    comment: "购买人电话",
    length: 255,
    default: 0,
  })
  familyPhone: string;

  @Column("varchar", {
    name: "service_items",
    comment: "服务项目列表",
  })
  serviceItems: string;

  // 0未结账、1已结账
  @Column("int", {
    name: "retail_state",
    comment: "结账状态",
    default: 0,
  })
  retailState: number;

  // 0正常、1已作废
  @Column("int", {
    name: "cancel_state",
    comment: "作废状态",
    default: 0,
  })
  cancelState: number;
}

export default noDeceasedRetail;
