package xiaoqu.home.open.constant;

/**
 * 0成功 1-100 系统错误 101-200 用户
 * 
 * @author naida
 *
 */
public enum Errors {
	USER_NOT_EXIST(101, "用户不存在"), PASSWORD_ERROR(102, "密码错误"), SYSTEM_REQUEST_PARAM_ERROR(103,"参数格式错误"), 
	USER_TOKEN_ERROR(104,"用户token失效"), USER_WXOPENID_ERROR(105, "用户wxopenid获取不到用户信息"), NOT_WEIXIN_ERROR(106, "请使用微信客户端登录"),
	PARAM_ERROR(107, "参数传递错误"),COMMAND_ERROR(108, "指令错误"),GETINFO_ERROR(109, "获取详细信息错误"),NOT_Register(110, "未注册"),ACCOUNT_Type(111, "账号登录类型错误"),
	TimeStamp_ERROR(112, "时间戳失效"),Signature_ERROR(113, "签名无效"),Authority_ERROR(114, "权限无效"),
	DR_HOUSE_EN_NAME_REPEAT(201, "项目名称重复"), VER_CODE_FAIL(202, "验证码错误"),PASSWORD_FAIL(203, "密码错误"),ChECKCODE_NOT_EXIST(204, "随机码不存在"),
	ChECKCODE_NOT_Bind(205, "随机码未绑定"),SNCODE_NOT_INSTALL(206, "未绑定安装信息"),ChECKCODE_NOT_Permission(207, "没有权限更换二维码"),	HARDNOTEXIT(208, "设备不存在或没权限"),
	// 微信支付
	WX_PAY_USER_NOT_EXIST(301, "微信用户未找到或者未登录"),

	TRANSFER_ENCODING_NOT_EXIST(3, "业务不存在"), FORM_VALID(2, "表单验证错误"), SYSTEM_ERROR(1, "系统错误"), 
	SUCCESS(0,"操作成功"), USERNAME_REPEAT(401, "用户名重复"), COMPANY_EXIST(402, "该公司已经被注册"), OUTPUT_PAPER_ERROR(403, "设备异常"),
	//商城错误码
	stock_shortage_null(600,"部分商品缺货或已下架,请返回购物车重新选择"),goods_null(601,"商品明细为空"),order_fail(602,"下单失败"),offlinePayment_fail(603,"线下付款超过单笔限额")
	,monthlySettlement_fail(604,"累计月结订单额度已超过当月额度"),monthlySettlement_not_fail(605,"没有设置月结额度,请联系平台管理员"),nonPaymentCount_fail(606,"请完成已有订单的支付"),
	order_cancel(607,"订单已取消"),order_state_except(608,"订单状态异常"),order_rePay_except(609,"退款异常"),order_delete_except(610,"该状态下订单无法删除"),
	order_delete_bill_except(611,"相应账单尚未完成，无法删除该订单"),order_not_except(612,"订单不存在"),bill_not_order_except(613,"该账单没有待还款的订单"),bill_money_except(614,"支付金额和未付款金额不一致"),
	bill_not_exist_except(615,"账单不存在"),order_repeatOrder(616,"请勿重复下单"),order_cancle_fail(617,"该状态下的订单无法取消"),order_cancel_except(618,"订单取消异常，请联系销售");

	public int code;
	public String label;

	private Errors(int code, String label) {
		this.code = code;
		this.label = label;
	}

	/**
	 *
	 * @param code
	 *            状态
	 * @return 描述
	 */
	public static String getLabel(int code) {
		String result = "";
		for (Errors status : Errors.values()) {
			if (status.code == code) {
				result = status.label;
			}
		}
		return result;
	}

	public static Errors getErrors(int code) {
		for (Errors errors : Errors.values()) {
			if (code == errors.code) {
				return errors;
			}
		}

		return null;
	}
}
