package com.ms.biz.consts;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class OrderConst {

    public static final Integer ORDER_STATUS_WAIT_PAY = 1; // 在线支付订单待支付；货到付款订单待确认
    public static final Integer ORDER_STATUS_WAIT_SELLER_SEND_GOODS = 2; // 备货中（只有此状态下，才可发货）
    public static final Integer ORDER_STATUS_WAIT_BUYER_CONFIRM_GOODS = 3; // 已发货
    public static final Integer ORDER_STATUS_CANCEL = 4; // 已取消：1.用户未支付时取消订单；2.用户超时未支付，系统自动取消订单；3.货到付款订单，用户拒收
    public static final Integer ORDER_STATUS_FINISH = 5; // 已完成：1.在线支付订单，商家发货后，用户收货、拒收或者15天无物流更新；2.货到付款订单，用户确认收货
    public static final Integer ORDER_STATUS_RISK = 105; // 105状态：当订单支付成功，但出于特定业务场景处理中（风控核验、拼团待成团等）是，订单状态将推进到105状态，当前状态不允许发货
    public static final Integer ORDER_STATUS_PART_DELIVERY = 101; // 部分发货

    public static final Integer RETURNING_AND_USER_APPLY = 6; // 退货中-用户申请
    public static final Integer RETURNING_AND_SELLER_AGREE = 7; // 退货中-商家同意退货
    public static final Integer RETURNING_AND_CUSTOMER_SERVICE_ARBITRATION = 8; // 退货中-客服仲裁
    public static final Integer CLOSE_AND_RETURN_GOODS_FAIL = 9; // 已关闭-退货失败
    public static final Integer RETURNING_AND_CUSTOMER_SERVICE_AGREE = 10; // 退货中-客服同意
    public static final Integer RETURNING_AND_USER_FILLED_IN_LOGISTICS = 11; // 退货中-用户已填物流
    public static final Integer RETURN_GOODS_SUCCESS_AND_SELLER_AGREE = 12; // 退货成功-商户同意
    public static final Integer RETURNING_AND_AGAIN_CUSTOMER_SERVICE_ARBITRATION = 13; // 退货中-再次客服仲裁
    public static final Integer RETURNING_AND_CUSTOMER_SERVICE_AGREES_TO_REFUND = 14; // 退货中-客服同意退款
    public static final Integer RETURN_GOODS_AND_USER_CANCEL = 15; // 退货-用户取消
    public static final Integer REFUNDING_AND_USER_APPLY = 16; // 退款中-用户申请(备货中)
    public static final Integer REFUNDING_AND_SELLER_AGREE_AND_WAIT_SEND_GOODS = 17; // 退款中-商家同意(备货中)
    public static final Integer REFUND_SUCCESS_AND_WAIT_SEND_GOODS = 21; // 退款成功-订单退款（备货中，用户申请退款，最终退款成功）
    public static final Integer REFUND_SUCCESS_AND_WAIT_BUYER_CONFIRM_GOODS = 22; // 退款成功-订单退款 (已发货时，用户申请退货，最终退货退款成功)
    public static final Integer RETURN_GOODS_SUCCESS_AND_SELLER_AGREE_AND_CASH_ON_DELIVERY = 24; // 退货成功-商户已退款 (特指货到付款订单，已发货时，用户申请退货，最终退货退款成功)
    public static final Integer REFUNDING_AND_USER_CANCEL = 25; // 退款中-用户取消(备货中)
    public static final Integer REFUNDING_AND_SELLER_REFUSED = 26; // 退款中-商家拒绝（备货中）
    public static final Integer RETURNING_AND_WAIT_BUYER_PROCESSING = 27; // 退货中-等待买家处理（已发货，商家拒绝用户退货申请）
    public static final Integer RETURN_GOODS_FAIL = 28; // 退货失败（已发货，商家拒绝用户退货申请，客服仲裁支持商家）
    public static final Integer RETURNING_AND_WAIT_BUYER_PROCESSING_AND_USER_FILLED_IN_LOGISTICS = 29; //退货中-等待买家处理（已发货，用户填写退货物流，商家拒绝）

    // 退款中-退款申请（已发货，用户申请仅退款）
    public static final Integer REFUNDING_AND_REFUND_APPLY = 30;
    // 退款申请取消（已发货，用户申请仅退款时，取消申请）
    public static final Integer REFUND_APPLY_CANCEL = 31;
    // 退款中-商家同意（已发货，用户申请仅退款，商家同意申请）
    public static final Integer REFUNDING_AND_SELLER_AGREE_AND_WAIT_BUYER_CONFIRM_GOODS = 32;
    // 退款中-商家拒绝（已发货，用户申请仅退款，商家拒绝申请）
    public static final Integer REFUNDING_AND_SELLER_REFUSED_AND_WAIT_BUYER_CONFIRM_GOODS = 33;
    // 退款中-客服仲裁（已发货，用户申请仅退款，商家拒绝申请，买家申请客服仲裁）
    public static final Integer REFUNDING_AND_CUSTOMER_SERVICE_ARBITRATION = 34;
    // 退款中-客服同意（已发货，用户申请仅退款，商家拒绝申请，客服仲裁支持买家）
    public static final Integer REFUNDING_AND_CUSTOMER_SERVICE_AGREE = 35;
    // 退款中-支持商家（已发货，用户申请仅退款，商家拒绝申请，客服仲裁支持商家）
    public static final Integer REFUNDING_AND_SUPPORT_SELLER = 36;
    // 已关闭-退款失败（已发货，用户申请仅退款时，退款关闭）
    public static final Integer CLOSE_AND_REFUND_FAIL = 37;
    // 退款成功-售后退款（特指货到付款订单，已发货，用户申请仅退款时，最终退款成功）
    public static final Integer REFUND_SUCCESS_AND_AFTER_SALES = 38;
    // 退款成功-订单退款（已发货，用户申请仅退款时，最终退款成功）
    public static final Integer REFUND_SUCCESS = 39;

    public static final Integer PAY_TYPE_HDHK = 0;
    public static final Integer PAY_TYPE_WECHAT = 1;
    public static final Integer PAY_TYPE_ALIPAY = 2;
    public static final Integer PAY_TYPE_APPLETS = 3;
    public static final Integer PAY_TYPE_BANK_CARD = 4;
    public static final Integer PAY_TYPE_BALANCE = 5;
    public static final Integer PAY_TYPE_NO_NEED_PAYMENT = 7;
    public static final Integer PAY_TYPE_CREDIT_PAYMENT = 8;
    public static final Integer PAY_TYPE_NEW_CARD_PAYMENT = 9;

    public static final String CUSTOM_PAY_TYPE_PAID = "custom_pay_type_paid";
    //实物
    public static final Integer ORDER_TYPE_REAL_GOODS = 0;
    //普通虚拟
    public static final Integer ORDER_TYPE_GENERAL_VIRTUAL = 2;
    //poi核销
    public static final Integer ORDER_TYPE_POI_WRITE_OFF = 4;
    //三方核销
    public static final Integer ORDER_TYPE_TRIPARTITE_WRITE_OFF = 5;
    //服务市场
    public static final Integer ORDER_TYPE_SERVICE_MARKET = 6;

    public static final String FULLNAME_SEARCH_TYPE_OLD = "old";
    public static final String FULLNAME_SEARCH_TYPE_NEW = "new";
    public static final String MOBILE_SEARCH_TYPE_OLD = "old";
    public static final String MOBILE_SEARCH_TYPE_NEW = "new";

    //订单已进入拣货环节
    public static final Integer ADDRESS_IS_APPROVED_VALUE_PICKING = 1001;
    //订单已进入配货环节
    public static final Integer ADDRESS_APPROVED_VALUE_DISTRIBUTION = 1002;
    // 订单已进入仓库环节
    public static final Integer ADDRESS_APPROVED_VALUE_WAREHOUSE = 1003;
    // 订单已进入出库环节
    public static final Integer ADDRESS_APPROVED_VALUE_OUTSTORAGE = 1004;
    // 订单已进入发货环节
    public static final Integer ADDRESS_APPROVED_VALUE_DELIVER = 1005;

    // 系统自动审核
    public static final Integer ORDER_ADDRESS_CHANGE_OPERATE_SHOP_ID_SYSTEM = 0;
    // 平台自动审核
    public static final Integer ORDER_ADDRESS_CHANGE_OPERATE_SHOP_ID_PLATFORM = 1;

    // 将要延迟发货
    public static final String DELAY_SEND_STATUS_WILL_DELAY_SEND = "willDelaySend";
    // 已经延迟发货
    public static final String DELAY_SEND_STATUS_HAS_DELAY_SEND = "hasDelaySend";

    // 未退款
    public static final Integer FILTER_REFUND_NO_REFUND = 0;
    // 部分退款
    public static final Integer FILTER_REFUND_PART_REFUND = 1;
    // 整单退
    public static final Integer FILTER_REFUND_ALL_REFUND = 2;

    // 姓名敏感信息类型
    public static final Integer SENSITIVE_TYPE_FULLNAME = 2;
    // 手机号敏感信息类型
    public static final Integer SENSITIVE_TYPE_MOBILE = 3;
    // 地址敏感信息类型
    public static final Integer SENSITIVE_TYPE_ADDRESS = 1;

    // 打印包裹来源
    public static final String OP_PACKAGE_SOURCE_PRInteger = "prInteger";
    // 手动发货包裹来源
    public static final String OP_PACKAGE_SOURCE_MANUAL_SEND = "manual_send";
    // DD包裹来源
    public static final String OP_PACKAGE_SOURCE_DD = "dd";
    // 自动发货包裹来源
    public static final String OP_PACKAGE_SOURCE_AUTO_SEND = "auto_send";

    // 面单物流状态
    public static final Integer WAYBILL_LOGISTICS_STATE_OUT_STORAGE = 13; //已发货
    public static final Integer WAYBILL_LOGISTICS_STATE_ACCEPT = 1; //已揽收
    public static final Integer WAYBILL_LOGISTICS_STATE_TRANSIT = 0; //运输中
    public static final Integer WAYBILL_LOGISTICS_STATE_DELIVERY = 5; //派送中
    public static final Integer WAYBILL_LOGISTICS_STATE_UNPICKED = 12; //待取件
    public static final Integer WAYBILL_LOGISTICS_STATE_SIGNED = 3; //已签收

    public static final String WAYBILL_WARNING_STATUS_NORMAL = "normal";
    public static final String WAYBILL_WARNING_STATUS_ABNORMAL = "abnormal";
    public static final String WAYBILL_WARNING_STATUS_WARN = "warn";
    public static final String WAYBILL_WARNING_SETTING_ON = "on";

    public static final String DECRYPT_SOURCE_DS_PURCHASE = "dsPurchase";
    public static final String DECRYPT_SOURCE_DS_AUTO_PURCHASE = "dsAutoPurchase";
    public static final String DECRYPT_SOURCE_DS_BATCH_PURCHASE = "dsBatchPurchase";
    public static final String DECRYPT_SOURCE_LTAO_PURCHASE = "ltaoPurchase";
    public static final String DECRYPT_SOURCE_SOOXIE_PURCHASE = "sooxiePurchase";
    public static final String DECRYPT_SOURCE_PURCHASE = "purchase";
    public static final String DECRYPT_SOURCE_CUSTOM_PR_INTEGER = "customPrInteger";
    public static final String DECRYPT_SOURCE_ADD_CUSTOM_ORDER = "addCustomOrder";
    public static final String DECRYPT_SOURCE_PR_INTEGER = "prInteger";
    public static final String DECRYPT_SOURCE_PR_INTEGER_COPY = "prIntegerCopy";
    public static final String DECRYPT_SOURCE_PR_INTEGER_SINGLE_DECRYPT = "prIntegerSingleDecrypt";
    public static final String DECRYPT_SOURCE_PR_INTEGER_UPDATE_ADDRESS = "prIntegerUpdateAddress";
    public static final String DECRYPT_SOURCE_DO_MULTI_PR_INTEGER = "doMultiPrInteger";
    public static final String DECRYPT_SOURCE_DO_BATCH_PR_INTEGER = "doBatchPrInteger";
    public static final String DECRYPT_SOURCE_DO_SINGLE_PR_INTEGER = "doSinglePrInteger";
    public static final String DECRYPT_SOURCE_ORDER_ADDRESS_HISTORY = "orderAddressHistory";
    public static final String DECRYPT_SOURCE_ADDRESS_AUDIT = "addressAudit";
    public static final String DECRYPT_SOURCE_PLUGIN_PURCHASE = "pluginPurchase";
    public static final String DECRYPT_SOURCE_LOGISTICS_REACHABLE = "logisticsReachable";
    public static final String DECRYPT_SOURCE_CG_PURCHASE = "cgPurchase";
    public static final String DECRYPT_SOURCE_CG_PREVIEW = "cgPreview";
    public static final String DECRYPT_SOURCE_GO_PLUGIN_PURCHASE = "goPluginPurchase";
    public static final String DECRYPT_SOURCE_GO_CART_PURCHASE = "goCartPurchase";
    public static final String DECRYPT_SOURCE_PURCHASE_PAGE_COPY = "purchasePageCopy";
    public static final String DECRYPT_SOURCE_PURCHASE_SINGLE_DECRYPT = "purchaseSingleDecrypt";
    public static final String DECRYPT_SOURCE_AFTER_SALE = "afterSale";

    public static final Integer ORDER_BIZ_TYPE_SHOP_SELF = 8; // 小店自卖
    public static final Integer ORDER_BIZ_TYPE_ALLIANCE = 2; // 精选联盟

    public static final String DECRYPT_IP_ABNORMAL_TYPE_OVERSEAS = "overseas";
    public static final String DECRYPT_IP_ABNORMAL_TYPE_NOT_COMMON_LOGIN_REGION = "notCommonLoginRegion";
    public static final String DECRYPT_IP_ABNORMAL_TYPE_NOT_MATCH_LOGIN_IP = "notMatchLoginIp";

    // 订单标记-收货地址修改
    public static final String ORDER_TAG_RECEIVER_ADDRESS_CHANGED = "receiverAddressChanged";

    /**
     * 订单同步延迟处理的业务:
     * 商品信息
     */
    public static final String ORDER_RSYNC_DELAY_BIZ_PRODUCT_INFO = "productInfo";

    public static List<Integer> getPurchaseOrderTabCanceledAllOrderStatus() {
        return Arrays.asList(
            ORDER_STATUS_CANCEL,
            RETURN_GOODS_SUCCESS_AND_SELLER_AGREE,
            REFUND_SUCCESS_AND_WAIT_SEND_GOODS,
            REFUND_SUCCESS_AND_WAIT_BUYER_CONFIRM_GOODS,
            RETURN_GOODS_SUCCESS_AND_SELLER_AGREE_AND_CASH_ON_DELIVERY,
            REFUND_SUCCESS_AND_AFTER_SALES,
            REFUND_SUCCESS
        );
    }

    public static Map<Integer, String> getAllOrderStatusMap() {
        Map<Integer, String> orderStatusMap = new HashMap<>();
        orderStatusMap.put(ORDER_STATUS_WAIT_PAY, "待支付");
        orderStatusMap.put(ORDER_STATUS_WAIT_SELLER_SEND_GOODS, "待发货");
        orderStatusMap.put(ORDER_STATUS_WAIT_BUYER_CONFIRM_GOODS, "已发货");
        orderStatusMap.put(ORDER_STATUS_CANCEL, "已取消");
        orderStatusMap.put(ORDER_STATUS_FINISH, "已完成");
        orderStatusMap.put(RETURNING_AND_USER_APPLY, "退货中-用户申请");
        orderStatusMap.put(RETURNING_AND_SELLER_AGREE, "退货中-商家同意退货");
        orderStatusMap.put(RETURNING_AND_CUSTOMER_SERVICE_ARBITRATION, "退货中-客服仲裁");
        orderStatusMap.put(CLOSE_AND_RETURN_GOODS_FAIL, "已关闭-退货失败");
        orderStatusMap.put(RETURNING_AND_CUSTOMER_SERVICE_AGREE, "退货中-客服同意");
        orderStatusMap.put(RETURNING_AND_USER_FILLED_IN_LOGISTICS, "退货中-用户已填物流");
        orderStatusMap.put(RETURN_GOODS_SUCCESS_AND_SELLER_AGREE, "退货成功-商户同意");
        orderStatusMap.put(RETURNING_AND_AGAIN_CUSTOMER_SERVICE_ARBITRATION, "退货中-再次客服仲裁");
        orderStatusMap.put(RETURNING_AND_CUSTOMER_SERVICE_AGREES_TO_REFUND, "退货中-客服同意退款");
        orderStatusMap.put(RETURN_GOODS_AND_USER_CANCEL, "退货-用户取消");
        orderStatusMap.put(REFUNDING_AND_USER_APPLY, "退款中-用户申请");
        orderStatusMap.put(REFUNDING_AND_SELLER_AGREE_AND_WAIT_SEND_GOODS, "退款中-商家同意");
        orderStatusMap.put(REFUND_SUCCESS_AND_WAIT_SEND_GOODS, "退款成功-订单退款");
        orderStatusMap.put(REFUND_SUCCESS_AND_WAIT_BUYER_CONFIRM_GOODS, "退款成功-订单退款");
        orderStatusMap.put(RETURN_GOODS_SUCCESS_AND_SELLER_AGREE_AND_CASH_ON_DELIVERY, "退货成功-商户已退款");
        orderStatusMap.put(REFUNDING_AND_USER_CANCEL, "退款中-用户取消");
        orderStatusMap.put(REFUNDING_AND_SELLER_REFUSED, "退款中-商家拒绝");
        orderStatusMap.put(RETURNING_AND_WAIT_BUYER_PROCESSING, "退货中-等待买家处理");
        orderStatusMap.put(RETURN_GOODS_FAIL, "退货失败");
        orderStatusMap.put(RETURNING_AND_WAIT_BUYER_PROCESSING_AND_USER_FILLED_IN_LOGISTICS, "退货中-等待买家处理");
        orderStatusMap.put(REFUNDING_AND_REFUND_APPLY, "退款中-退款申请");
        orderStatusMap.put(REFUND_APPLY_CANCEL, "退款申请取消");
        orderStatusMap.put(REFUNDING_AND_SELLER_AGREE_AND_WAIT_BUYER_CONFIRM_GOODS, "退款中-商家同意");
        orderStatusMap.put(REFUNDING_AND_SELLER_REFUSED_AND_WAIT_BUYER_CONFIRM_GOODS, "退款中-商家拒绝");
        orderStatusMap.put(REFUNDING_AND_CUSTOMER_SERVICE_ARBITRATION, "退款中-客服仲裁");
        orderStatusMap.put(REFUNDING_AND_CUSTOMER_SERVICE_AGREE, "退款中-客服同意");
        orderStatusMap.put(REFUNDING_AND_SUPPORT_SELLER, "退款中-支持商家");
        orderStatusMap.put(CLOSE_AND_REFUND_FAIL, "已关闭-退款失败");
        orderStatusMap.put(REFUND_SUCCESS_AND_AFTER_SALES, "退款成功-售后退款");
        orderStatusMap.put(REFUND_SUCCESS, "退款成功-订单退款");
        orderStatusMap.put(ORDER_STATUS_RISK, "订单支付成功，风控处理中或待成团");
        orderStatusMap.put(ORDER_STATUS_PART_DELIVERY, "部分发货");

        return orderStatusMap;
    }

    public static String getOrderStatusText(Integer orderStatus) {
        return getAllOrderStatusMap().getOrDefault(orderStatus,null);
    }
}