package cn.pluss.platform.vo;

import cn.pluss.platform.converter.Converter;
import cn.pluss.platform.entity.MercMemberSet;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class MercMemberSetVO extends MercMemberSet {

    private String scopeDesc;

    public static MercMemberSetVO toVO(MercMemberSet entity) {
        MercMemberSetVO vo = Converter.INSTANCE.toVO(entity);

        // 如果没有记录，则标记为老商户的通用配置
        if (vo == null) {
            vo = new MercMemberSetVO();
            vo.setStatus(STATUS_ON);
            vo.setScope(SCOPE_ALL);
        }

        if (vo.getScope() == null) {
            return vo;
        }

        switch (vo.getScope()) {
            case SCOPE_OFFLINE:
                vo.setScopeDesc("线下扫码");
                break;
            case SCOPE_ONLINE:
                vo.setScopeDesc("外卖和扫码点单");
                break;
            case SCOPE_ALL:
                vo.setScopeDesc("全部");
                break;
        }

        return vo;
    }
}
