package cn.newfeifan.mall.module.system.enums.sms;

import cn.hutool.core.util.ArrayUtil;
import cn.newfeifan.mall.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 用户短信验证码发送场景的枚举
 *
 * @author 非繁源码
 */
@Getter
@AllArgsConstructor
public enum SmsSceneEnum implements IntArrayValuable {

    MEMBER_LOGIN(1, "user-sms-login", "会员用户 - 手机号登陆"),
    MEMBER_UPDATE_MOBILE(2, "user-update-mobile", "会员用户 - 修改手机"),
    MEMBER_UPDATE_PASSWORD(3, "user-update-password", "会员用户 - 修改密码"),
    MEMBER_RESET_PASSWORD(4, "user-reset-password", "会员用户 - 忘记密码"),
    MEMBER_UPDATE_NEW_MOBILE(5, "user-update-mobile", "会员用户 - 修改手机号时新输入的手机号"),
    MEMBER_WITHDRAWAL_ERROR(6, "user-withdrawal-error", "会员用户 - 提现失败时发送通知给用户"),
    SPU_APPLY_INFORM(7, "spu-apply-inform", "系统用户 - 商品审核申请通知"),
    SPU_APPLY_ERROR(8, "spu-apply-error", "系统用户 - 商品审核驳回通知"),
    SPU_APPLY_SUCCESS(9, "spu-apply-success", "系统用户 - 商品审核通过通知"),
    TOP_UP_CONSUMPTION(10, "top-up-consumption", "系统用户 - 充值消费分"),
    CONSUMPTION_TRANSFER(11, "consumption-transfer", "会员用户 - 消费分转让"),
    ZERO_PURCHASE(12, "zero-purchase", "会员用户 - 零元购"),
    CONSUMPTION_POINTS_ERROR_WARNING(13, "consumption-points-error-warning", "系统用户 - 消费分异动提醒"),
    CONSUMPTION_POINTS_TOP_UP(14,"consumption_points_top_up","会员用户 - 平台充值消费分通知"),
    CONSUMPTION_POINTS_TRANSFER_INFORM(15,"consumption_points_transfer_inform","会员用户 - 消费分转让通知"),

    ADMIN_MEMBER_LOGIN(21, "admin-sms-login", "后台用户 - 手机号登录");

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(SmsSceneEnum::getScene).toArray();

    /**
     * 验证场景的编号
     */
    private final Integer scene;
    /**
     * 模版编码
     */
    private final String templateCode;
    /**
     * 描述
     */
    private final String description;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static SmsSceneEnum getCodeByScene(Integer scene) {
        return ArrayUtil.firstMatch(sceneEnum -> sceneEnum.getScene().equals(scene),
                values());
    }

}
