package com.ylx.massage.enums;

import com.ylx.common.utils.StringUtils;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * 商品订单状态枚举
 */
@Getter
public enum ProductOrderStatusEnum {

    /**
     * 待付款
     */
    WAIT_PAY(0, "待付款"),

    /**
     * 待发货
     */
    WAIT_DELIVERY(1, "待发货"),

    /**
     * 待收货
     */
    WAIT_RECEIVE(2, "待收货"),

    /**
     * 已收货
     */
    RECEIVED(3, "已收货"),

    /**
     * 售后中
     */
    AFTER_SALES(4, "售后中"),

    /**
     * 已取消
     */
    CANCELLED(11, "已取消");

    private final Integer code;
    private final String info;

    ProductOrderStatusEnum(Integer code, String info) {
        this.code = code;
        this.info = info;
    }

    /**
     * 根据状态码获取描述
     * @param code 状态码
     * @return String描述信息
     */
    public static String getDescByCode(Integer code) {
        if (code == null) {
            return StringUtils.EMPTY;
        }
        for (ProductOrderStatusEnum value : ProductOrderStatusEnum.values()) {
            if (value.getCode().equals(code)) {
                return value.getInfo();
            }
        }
        return StringUtils.EMPTY;
    }

    /**
     * 获取商品订单状态枚举列表
     * @return List<EnumProject> 商品订单状态枚举列表
     */
    public static List<EnumProject> getStatusEnum() {
        List<EnumProject> list = new ArrayList<>();
        for (ProductOrderStatusEnum value : ProductOrderStatusEnum.values()) {
            EnumProject enumProject = new EnumProject();
            enumProject.setCode(value.getCode());
            enumProject.setInfo(value.getInfo());
            list.add(enumProject);
        }
        return list;
    }

    @lombok.Data
    public static class EnumProject {
        private Integer code;
        private String info;
    }
}