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

namespace App\Services\Base;

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

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

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

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

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

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

    public const CONFIG_ALI_PRODUCT_KEY_NEED = 601;

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

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

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

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

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

    // 错误常量枚举
    private static $_msg = [
        self::NOT_LOGIN                   => '用户未登录',
        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              => '系统当日提现金额达到上限！',
    ];

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

        return null;
    }
}
