package com.fs.live.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor
public enum LiveOrderCancleReason {

    //不小心点错商品/数量
//发现更便宜的渠道
//优惠券未生效
//想等折扣再买
//重复下单
//不需要了
//找到更好的替代品
//家人/朋友已帮忙购买
//客服沟通不畅
//发现商品差评较多
    REASON_1("1", "不小心点错商品/数量"),
    REASON_2("2", "发现更便宜的渠道"),
    REASON_3("3", "优惠券未生效"),
    REASON_4("4", "想等折扣再买"),
    REASON_5("5", "重复下单"),
    REASON_6("6", "不需要了"),
    REASON_7("7", "找到更好的替代品"),
    REASON_8("8", "家人/朋友已帮忙购买"),
    REASON_9("9", "客服沟通不畅"),
    REASON_10("10", "发现商品差评较多");

    private final String code;
    private final String desc;


    public static String getDescByCode(String code) {
        for (LiveOrderCancleReason reason : values()) {
            if (reason.getCode().equals(code)) {
                return reason.getDesc();
            }
        }
        return null;
    }


    //返回所有code:desc的map集合
    public static List<Map<String, String>> getAllCodeDescMap() {
        return Arrays.stream(values())
                .map(reason -> new HashMap<String, String>() {{
                    put("code", reason.getCode());
                    put("desc", reason.getDesc());
                }})
                .collect(Collectors.toList());
    }
}
