package com.ms.biz.consts;

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

public class DsOrderConst {

    public static final String ORDER_STATUS_WAIT_PURCHASE = "waitPurchase";//待采购
    public static final String ORDER_STATUS_WAIT_PAY = "waitPay";//待付款
    public static final String ORDER_STATUS_WAIT_SELLER_SEND_GOODS = "waitSellerSendGoods";//待发货
    public static final String ORDER_STATUS_WAIT_BUYER_CONFIRM_GOODS = "waitBuyerConfirmGoods";//已发货
    public static final String ORDER_STATUS_REFUNDING = "refunding";//退款中
    public static final String ORDER_STATUS_FINISH = "finish";//已完成
    public static final String ORDER_STATUS_CLOSE = "close";//已关闭
    public static final String ORDER_STATUS_ISOLATION = "isolation";//已隔离

    public static final String PURCHASE_TAB_WAIT_PURCHASE = "waitPurchase";
    public static final String PURCHASE_TAB_WAIT_PAY = "waitPay";
    public static final String PURCHASE_TAB_WAIT_SEND = "waitSend";
    public static final String PURCHASE_TAB_HAS_SEND = "hasSend";
    public static final String PURCHASE_TAB_REFUNDING = "refunding";
    public static final String PURCHASE_TAB_FINISH = "finish";
    public static final String PURCHASE_TAB_CLOSE = "close";
    public static final String PURCHASE_TAB_ISOLATION = "isolation";
    public static final String PURCHASE_TAB_ALL = "all";

    public static final String REFUND_STATUS_REFUNDING = "refunding";
    public static final String REFUND_STATUS_CLOSE = "close";
    public static final String REFUND_STATUS_FINISH = "finish";

    public static final Integer DS_WAIT_PAY_STATUS_PART_WAIT_PAY = 1;//部分未付款
    public static final Integer DS_WAIT_PAY_STATUS_FULL_PAY = 2;//已全部付款
    public static final Integer DS_WAIT_PAY_STATUS_ALL_UNPAID = 3;//全部未付款

    public static final String DS_ORDER_RELATE_STATE_ALL = "all"; //全部
    public static final String DS_ORDER_RELATE_STATE_RELATED = "relatedSource";//已关联货源
    public static final String DS_ORDER_RELATE_STATE_UNRELATED = "unrelatedSource";//未关联货源

    public static final Integer _DS_RELATION_SOURCE_STATUS_NONE_PRODUCT = 0;// 未关联货源
    public static final Integer _DS_RELATION_SOURCE_STATUS_PART_PRODUCT = 1;// 部分关联货源
    public static final Integer _DS_RELATION_SOURCE_STATUS_ALL_PRODUCT = 2;// 全部关联货源

    public static final Integer DS_PURCHASE_STATUS_WAIT_PURCHASE = 0;//待采购
    public static final Integer DS_PURCHASE_STATUS_PART_PURCHASE = 1;//部分采购
    public static final Integer DS_PURCHASE_STATUS_WAIT_SEND = 2;//待发货
    public static final Integer DS_PURCHASE_STATUS_PART_SEND = 4;//部分发货
    public static final Integer DS_PURCHASE_STATUS_WAIT_PAY = 5;//待付款
    public static final Integer DS_PURCHASE_STATUS_HAS_SEND = 6;//已发货

    public static final String FILTER_PURCHASE_STATUS_WAIT_PURCHASE = "0";
    public static final String FILTER_PURCHASE_STATUS_PART_PURCHASE = "1";
    public static final String FILTER_PURCHASE_STATUS_HAS_PURCHASE = "2";
    public static final String FILTER_PURCHASE_STATUS_MANUAL_HAS_PURCHASE = "3";

    public static final String ACTION_SOURCE_PLATFORM_BATCH_PURCHASE = "platform_batch_purchase";
    public static final String ACTION_SOURCE_PLATFORM_SINGLE_PURCHASE = "platform_single_purchase";
    public static final String ACTION_SOURCE_MOBILE_PLATFORM_BATCH_PURCHASE = "mobile_platform_batch_purchase";
    public static final String ACTION_SOURCE_MOBILE_PLATFORM_SINGLE_PURCHASE = "mobile_platform_single_purchase";
    public static final String ACTION_SOURCE_PLATFORM_SINGLE_REPURCHASE = "platform_single_repurchase";
    public static final String ACTION_SOURCE_PLATFORM_CANCEL = "platform_cancel";
    public static final String ACTION_SOURCE_BATCH_PURCHASE = "batch_purchase";
    public static final String ACTION_SOURCE_SINGLE_PURCHASE = "single_purchase";
    public static final String ACTION_SOURCE_CACNEL = "cancel";
    public static final String ACTION_SOURCE_PLATFORM_CLOSE_CANCEL = "platform_close_cancel";
    public static final String ACTION_SOURCE_CLOSE_CANCEL = "close_cancel";
    public static final String ACTION_SOURCE_PLATFORM_AUTO_PURCHASE = "platform_auto_purchase";

    public static final String PLATFORM_PRODUCT_RELATE_SOURCE_ITEM_TYPE_ADD = "add";
    public static final String PLATFORM_PRODUCT_RELATE_SOURCE_ITEM_TYPE_DELETE = "delete";

    public static final String PURCHASE_SOURCE_PLATFORM_BATCH = "platform_batch";
    public static final String PURCHASE_SOURCE_MOBILE_PLATFORM_SINGLE = "mobile_platform_single";
    public static final String PURCHASE_SOURCE_MOBILE_PLATFORM_BATCH = "mobile_platform_batch";
    public static final String PURCHASE_SOURCE_PLATFORM_AUTO = "platform_auto";
    public static final String PURCHASE_SOURCE_PLATFORM = "platform";

    public static final String FLOW_FENXIAO = "fenxiao";
    public static final String FLOW_CHOICENESS = "ttpft";//精选货源下单

    public static final String AUTO_AFS_ACTION_TYPE_WAIT_SEND_REFUND = "waitSendRefund";
    public static final String AUTO_AFS_ACTION_TYPE_CLOSE_ORDER = "closeOrder";
    public static final String AUTO_AFS_ACTION_TYPE_EXCEPTION = "exception";

    public static String getAppOrderStatusByOrderStatus( Integer orderStatus) {
        String returnAppOrderStatus = "";
        Map<String, List<Integer>> map = getDdOrderStatusAndPlatformOrderStatusMap();
        for (Map.Entry<String, List<Integer>> entry : map.entrySet()) {
            if (!entry.getValue().contains(orderStatus)){
                continue;
            }
            returnAppOrderStatus = entry.getKey();
        }
        return returnAppOrderStatus;
    }

    public static Map<String, List<Integer>> getDdOrderStatusAndPlatformOrderStatusMap() {
        Map<String, List<Integer>> map = new HashMap<>();

        map.put(ORDER_STATUS_WAIT_PURCHASE, Arrays.asList(OrderConst.ORDER_STATUS_WAIT_SELLER_SEND_GOODS, OrderConst.ORDER_STATUS_PART_DELIVERY));
        map.put(ORDER_STATUS_WAIT_SELLER_SEND_GOODS, Arrays.asList(OrderConst.ORDER_STATUS_WAIT_SELLER_SEND_GOODS, OrderConst.ORDER_STATUS_PART_DELIVERY));
        map.put(ORDER_STATUS_WAIT_BUYER_CONFIRM_GOODS, Collections.singletonList(OrderConst.ORDER_STATUS_WAIT_BUYER_CONFIRM_GOODS));
        map.put(ORDER_STATUS_FINISH, Collections.singletonList(OrderConst.ORDER_STATUS_FINISH));
        map.put(ORDER_STATUS_CLOSE, OrderConst.getPurchaseOrderTabCanceledAllOrderStatus());

        return map;
    }

    public static List<Integer> getAppOrderStatusRefundingAfterSaleOrderStatus() {
        return Arrays.asList(
            AfterSaleConst.AFTERSALE_STATUS_AFTER_SALE_AUDIT,
            AfterSaleConst.AFTERSALE_STATUS_WAIT_BUYER_RETURN_GOODS,
            AfterSaleConst.AFTERSALE_STATUS_AUDIT_REFUNDING,
            AfterSaleConst.AFTERSALE_STATUS_PRE_SALE_ALL_AUDIT,
            AfterSaleConst.AFTERSALE_STATUS_REFUND_AUDIT,
            AfterSaleConst.AFTERSALE_STATUS_RETURN_AUDIT,
            AfterSaleConst.AFTERSALE_STATUS_EXCHANGE_AUDIT,
            AfterSaleConst.AFTERSALE_STATUS_WAIT_SELLER_SEND_GOODS,
            AfterSaleConst.AFTERSALE_STATUS_RETURN_RECEIVE,
            AfterSaleConst.AFTERSALE_STATUS_RETURN_SHIP
            );
    }
    public static String getDsRefundStatusName(String refundStatus) {
        Map<String, String> map = new HashMap<>();
        map.put(REFUND_STATUS_REFUNDING, "售后中");
        map.put(REFUND_STATUS_CLOSE, "售后关闭");
        map.put(REFUND_STATUS_FINISH, "售后完成");
        return map.get(refundStatus);
    }
}
