<?php
/**
 *------------------------------------------------------
 * BaseProcess.php
 *------------------------------------------------------
 *
 * @author    Mike
 * @date      2016/5/26 11:17
 * @version   V1.0
 *
 */

namespace App\Services\Base;

final class ErrorCode
{
    /**
     * 上传附件相关
     */
     const ATTACHMENT_SAVE_FAILED = 603;
     const ATTACHMENT_UPLOAD_INVALID = 602;
     const ATTACHMENT_SIZE_EXCEEDED = 1201;
     const ATTACHMENT_RECORD_DELETE_FAILED = 606;
     const ATTACHMENT_DELETE_FAILED = 605;

    /**
     * 通用常量
     */
    const NOT_LOGIN = 100;
    const NOT_ALLOW = 112;  
    const PARAMS_ERROR = 101;
    const REGISTER_FALSE = 102;
    const REGISTER_CONFIRM_FALSE = 103;
    const DATA_SAVE_FALSE = 104;
    //const MODULE_IS_NOT_USE = 105;
    const NEED_CONFIGURE = 106;
    const DATA_NOT_FOUND = 107;
    const DATA_DECODE_FAILURE = 108;
    const VERIFY_CODE_FALSE = 109;
    const MOBILE_CODE_FALSE = 110;
    const ILLEGAL_OPERATION = 111;

    /**
     * 微信常量
     */
    const WECHAT_CONFIG_LACK = 201;
    const GET_OPENID_FALSE = 202;
    const SESSION_KEY_INVALID = 203;

    /**
     * 定位服务常量
     */
    //const LOCATION_FALSE = 301;

    const CONFIGURE_SMS_TEMPLATE = 401;
    const SMS_AUTH_FAILED = 402;
    const SMS_RETURN_ERROR = 403;


    //const USER_IN_BLACK_LIST = 501;
    const USER_NO_AUTH = 502;
    //const USER_TRANSPORT_NO_AUTH = 503;
    //const USER_ACCOUNT_NOT_ENOUGH = 504;
    //const USER_IDENTIFY_NOT_ALLOW = 505;
    //const USER_FREEZE_ERROR = 506;
    //const USER_IS_APPLY = 507;

    const CONFIG_ALI_PRODUCT_KEY_NEED = 601;

    const DEVICE_NOT_FOUND = 701;
    const DEVICE_INFO_ERROR = 702;
    const DEVICE_NORMAL_ERROR = 703;
    const DEVICE_NET_ERROR = 704;

    /**
     * 订单常量
     */
    const ORDER_CREATE_ERROR = 801;
    //const RECHARGE_WECHAT_FAILURE = 802;

    /**
     * 提现常量
     */
    //const CASH_NEED_CONFIG = 901;
    //const CASH_METHOD_NOT_ALLOW = 902;
    //const CASH_TIMES_OUT = 903;
    //const CASH_MONEY_FEW = 904;
    //const CASH_MONEY_NO_ENOUGH = 905;
    //const CASH_MONEY_MAX = 906;

    // const ATTACHMENT_NOT_EXIST = 1203;
    // const ATTACHMENT_MIME_NOT_ALLOWED = 1202;
    // const MERCHANT_CREDIT_NOT_ENOUGH = 1304;
    // const MEMBER_CREDIT_NOT_ENOUGH = 1305;
    // const MERCHANT_NOT_EXIST = 1300;
    // const FAVORITE_NOT_EXIST = 1900;
    // const MERCHANT_ADD_MEMBER_FAILED = 1301;
    // const MERCHANT_STATUS_NOT_OK = 1302;
    // const BALANCE_NOT_ENOUGH = 1303;
    // const MERCHANT_BALANCE_NOT_ENOUGH = 1311;
    // const PAY_TYPE_UNSUPPORTED = 2000;
    // const MEMBER_NOT_EXIST = 1500;
    // const COIN_NOT_ENOUGH = 1501;

    //const CANT_ADD_SERVICE_SAME_MERCHANT = 1405;
    //const SERVICE_STATUS_INVALID_CHANGE = 1406;
    //const SERVICE_COST_OVERFLOW_BALANCE = 1407;
    //const CREATE_SERVICE_OVER_MAX = 1408;
    //const OPERATION_FAILED = 700;
    //const REMOVE_MODEL_FAILED = 701;
    // const MODEL_NOT_EXIST = 702;
    // const ATTACHMENT_UPLOAD_FAILED = 1200;
    // const PROTO_PATH_NOT_EXIST = 100;
    // const PROTO_TRY_TO_SET_VALUE_ON_NULL = 101;
    // const CONNET_NOT_EXIST = 1700;
    // const ORDER_GENERATE_FAILED = 1800;
    // const CONSUME_LOG_NOT_EXIST = 1600;
    // const SERVICE_CODE_FAILED= 1610;
    // const PHONE_NUMBER_ALREADY_REGISTERED = 1100;
    //const INCORRECT_VERIFY_CODE = 1101;
    //const INCORRECT_USER_OR_PASS = 1102;
    //const VERIFY_CODE_TOO_MUCH = 1103;
    //const LOGOUT_FAILED = 1104;
    //const USER_DOES_NOT_EXIST = 1105;
    //const USER_DOES_EXIST = 1106;
    // const DELETE_OP_FAILED = 1001;
    // const CLIENT_WRONG_PARAMS = 1000;
    // const DREAM_NOT_EXIST = 1308;
    // const LOCK_USER = 1309;
    // const LOGIN_FAILED = 1311;
    // const KEY_ERROR = 1310;
    // const SUP_TOP = 1410;
    // const SUP_ERROR = 1411;
    // const DREAM_STATUS = 1412;
    // const OPERATION_SUCCESS = 200;
    // const INTERACTION_NOT_EXIST = 2001;
    // const NOT_ROOT = 2002;


    //错误常量枚举
    private static $_msg = [
        self::NOT_LOGIN => '用户未登录',
        self::NOT_ALLOW => '不允许绑定',
        self::PARAMS_ERROR => '参数异常',
        self::WECHAT_CONFIG_LACK => '微信参数未配置',
        self::GET_OPENID_FALSE => 'openId获取失败',
        self::REGISTER_FALSE => '注册失败',
        self::REGISTER_CONFIRM_FALSE => '用户验证失败',
        self::DATA_SAVE_FALSE => '数据保存失败',
        //self::MODULE_IS_NOT_USE => '模块未安装，请检查后台配置',
        self::CONFIGURE_SMS_TEMPLATE => '请先配置短信模板',
        self::SMS_AUTH_FAILED => '短信授权错误',
        self::SMS_RETURN_ERROR => '短信返回错误',
        self::NEED_CONFIGURE => '请先至后台配置',
        //self::USER_IN_BLACK_LIST => '用户被拉入黑名单',
        self::USER_NO_AUTH => '用户无权限',
        self::CONFIG_ALI_PRODUCT_KEY_NEED => '请在后台配置阿里云物联网产品key',
        self::DEVICE_NOT_FOUND => '设备不存在',
        self::DEVICE_INFO_ERROR => '设备信息异常',
        self::DEVICE_NORMAL_ERROR => '设备故障请联系客服!',
        self::ORDER_CREATE_ERROR => '订单创建失败',
        //self::RECHARGE_WECHAT_FAILURE => '微信充值创建订单失败',
        self::DATA_NOT_FOUND => '数据不存在',
        //self::CASH_NEED_CONFIG => '请先填写提现配置',
        //self::CASH_METHOD_NOT_ALLOW => '无效的提现方式',
        //self::CASH_MONEY_FEW => '提现金额必须大于最小设置金额',
        //self::CASH_TIMES_OUT => '当日提现次数达到上限',
        //self::CASH_MONEY_NO_ENOUGH => '余额不足',
        self::DATA_DECODE_FAILURE => '解密失败',
        self::MOBILE_CODE_FALSE => '请先获取验证码',
        self::VERIFY_CODE_FALSE => '验证码错误',
        self::SESSION_KEY_INVALID => 'sessionKey无效',
        self::ILLEGAL_OPERATION => '非法操作',
        //self::USER_IDENTIFY_NOT_ALLOW => '请先通过身份审核！',
        //self::USER_FREEZE_ERROR => '用户被冻结！',
        //self::USER_IS_APPLY => '用户加盟审核中！',
        //self::USER_ACCOUNT_NOT_ENOUGH => '用户余额不足！',
        self::DEVICE_NET_ERROR => '设备无网络！',
        //self::USER_TRANSPORT_NO_AUTH => '用户无收运权限！',
        //self::CASH_MONEY_MAX => '系统当日提现金额达到上限！',
        self::ATTACHMENT_SAVE_FAILED => '附件保存失败',
        self::ATTACHMENT_UPLOAD_INVALID => '附件上传非法',
        self::ATTACHMENT_SIZE_EXCEEDED => '附件大小超出限制',
        self::ATTACHMENT_RECORD_DELETE_FAILED => '附件记录删除失败',
        self::ATTACHMENT_DELETE_FAILED => '附件删除失败'
    ];

    public static function message($code)
    {
        if (isset(self::$_msg[$code])) {
            return self::$_msg[$code];
        } else {
            return null;
        }
    }

}
