package com.cusc.nirvana.user.rnr.fp.service.impl;

import com.cusc.nirvana.user.rnr.fp.constants.MbCodeEnum;
import com.cusc.nirvana.user.rnr.fp.service.OperatorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @className: OperatorServiceImpl
 * @description: 运营商配置
 * @author: jk
 * @date: 2022/8/2 11:19
 * @version: 1.0
 **/
@Service
@Slf4j
public class OperatorServiceImpl implements OperatorService {

    @Value("${mbCodeEnum.cmcc}")
    private  String cmcc;

    @Value("${mbCodeEnum.cucc}")
    private  String cucc;

    @Value("${mbCodeEnum.ctcc}")
    private static String ctcc;

    @Value("${mbCodeEnum.qt}")
    private static String qt;

    @Override
    public  String get(String iccid) {

        if (cmcc.indexOf(iccid.substring(0, 6)) != -1) {

            return MbCodeEnum.CMCC.getCode();
        }

        if (cucc.indexOf(iccid.substring(0, 6)) != -1) {
            return MbCodeEnum.CUCC.getCode();

        }

        if (ctcc.indexOf(iccid.substring(0, 6)) != -1) {
            return MbCodeEnum.CTCC.getCode();

        }

        if (qt.indexOf(iccid.substring(0, 6)) != -1) {
            return MbCodeEnum.QT.getCode();
        }
        return null;
    }
}
