package com.pj.project.tb_item_type;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.*;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.pj.project.tb_item.TbItem;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;

import lombok.Data;
import lombok.Getter;
import lombok.experimental.Accessors;

/**
 * Model: tb_item_type -- 业务项类型
 *
 * @author qzy
 */
@Data
@Accessors(chain = true)
@TableName(TbItemType.TABLE_NAME)
@EqualsAndHashCode(callSuper = false)
public class TbItemType extends Model<TbItemType> implements Serializable {

    // ---------- 模块常量 ----------
    /**
     * 序列化版本id
     */
    private static final long serialVersionUID = 1L;
    /**
     * 此模块对应的表名
     */
    public static final String TABLE_NAME = "tb_item_type";
    /**
     * 此模块对应的权限码
     */
    public static final String PERMISSION_CODE = "tb-item-type";


    // ---------- 表中字段 ----------
    /**
     * 主键
     */
    private String id;

    /**
     * 名称
     */
    private String name;

    /**
     * 税率
     */
    private BigDecimal taxRate = new BigDecimal(0);

    /**
     * 是否必须(0=否,1=是)
     */
    private int need;
    private String code;
    private Integer inc = 0;

    /**
     * 业务类型1,消杀；2装卸；0默认
     */
    private String businessType = "0";
    private Integer business = 1;
    private Integer sort;
    /**
     * 可以支付步骤1：生成即可，2：确认后
     */
    private Integer payStep = 2;

    @TableField(exist = false)
    private List<TbItem> items = new ArrayList<>();

    @TableField(exist = false)
    private String itemId;
    @TableField(exist = false)
    private Integer num = 1;
    @TableField(exist = false)
    private String itemName;

    @Getter
    @AllArgsConstructor
    public static enum PayStep {
        BEFORE_CONFIRM(1,"下单后"),
        AFTER_CONFIRM(2,"确认订单后");
        private Integer code;
        private String desc;
        public static List<Map<String, Object>> getList() {
            List<Map<String, Object>> list = new ArrayList<>();
            for (PayStep tbItem : PayStep.values()) {
                Map<String, Object> map = new HashMap<>();
                map.put("id", tbItem.getCode());
                map.put("name", tbItem.getDesc());
                list.add(map);
            }
            return list;
        }
    }



}
