import 'package:flutter/material.dart';

class OrderConstant {
  // 用户的订单菜单栏
  static const List<dynamic> userOrderType = [
    {"name": "全部", "value": "USER_ALL"},
    {"name": "待付款", "value": "TO_PAY"},
    {"name": "待确认", "value": "USER_TO_SURE"},
    {"name": "待评价", "value": "TO_EVA"},
    {"name": "申诉", "value": "TO_APPEAL"}
  ];

  // 专家订单菜单栏
  static const List<dynamic> expertOrderType = [
    {"name": "全部", "value": "CHARGE_ALL"},
    {"name": "待报价", "value": "TO_OFFER"},
    {"name": "待打卡", "value": "TO_CLOCK"},
    {"name": "待确认", "value": "CHARGE_TO_SURE"},
    {"name": "待归档", "value": "TO_ARCHIVE"}
  ];

  // 问诊状态
  // showUserAppealInfo 是否显示申诉信息
  // showUserPaymentButton 是否显示立即付款按钮
  // showUserConfirmPunchButton 是否显示确认打卡按钮
  // showUserAppealButton 是否显示提出申诉按钮
  // showUserConfirmOrderButton 是否显示确认订单按钮
  // showUserEvaluationButton 是否显示评价按钮
  // showUserChooseExpertButton 是否显示重新选择专家按钮
  // showExpertQuoteButton 是否显示立即报价按钮
  // showExpertPunchButton 是否显示立即打卡按钮
  // showExpertConfirmOrderButton 是否显示专家确认按钮
  // showExpertArchiveButton 是否显示归档按钮
  static const List<dynamic> inquiryStatus = [
    {
      "id": 0,
      "name": "待付款",
      'iconFontData': const IconData(0xe659, fontFamily: "Iconfont"),
      "desc": "您的订单已提交，请在30分钟内完成支付，超时订单将自动取消;",
      'ExpertDesc': '',
      "showUserAppealInfo": false,
      "showUserPaymentButton": true,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": false,
      "showUserCancelOrderButton": true,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    },
    {
      "id": 1,
      "name": "待接单",
      'iconFontData': const IconData(0xe654, fontFamily: "Iconfont"),
      "desc": "您的订单已提交，请耐心等待专家接单;",
      'ExpertDesc': '',
      "showUserAppealInfo": false,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": false,
      "showUserCancelOrderButton": false,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    },
    {
      "id": 2,
      "name": "已接单",
      'iconFontData': const IconData(0xe65e, fontFamily: "Iconfont"),
      "desc": "专家已接受您的订单，您可以进入聊天室咨询相关问题了",
      'ExpertDesc': '您已接单，您可以进入聊天室回答用户问题 ',
      "showUserAppealInfo": false,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": false,
      "showUserCancelOrderButton": false,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": true,
      "showExpertArchiveButton": false
    },
    {
      "id": 3,
      "name": "用户待确认",
      'iconFontData': const IconData(0xe681, fontFamily: "Iconfont"),
      "desc": "您的订单专家已确认完成，请在24小时内确认，超时订单将自动确认",
      'ExpertDesc': '您已确认完成，等待用户确认',
      "showUserAppealInfo": false,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": true,
      "showUserConfirmOrderButton": true,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": false,
      "showUserCancelOrderButton": false,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    },
    {
      "id": 5,
      "name": "待评价",
      'iconFontData': const IconData(0xe75b, fontFamily: "Iconfont"),
      "desc": "您的订单已完成，请给本次服务评价一下吧~",
      'ExpertDesc': '您的接单已完成，请提醒用户评价订单',
      "showUserAppealInfo": false,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": true,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": false,
      "showUserCancelOrderButton": false,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    },
    {
      "id": 4,
      "name": "待归档",
      'iconFontData': const IconData(0xe63f, fontFamily: "Iconfont"),
      "desc": "您的订单已完成，请等待专家归档问题~",
      'ExpertDesc': '您的接单已完成，请将此咨询归档至问题库便于后续参考',
      "showUserAppealInfo": false,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": false,
      "showUserCancelOrderButton": false,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": true
    },
    {
      "id": 6,
      "name": "已完成",
      'iconFontData': const IconData(0xe75b, fontFamily: "Iconfont"),
      "desc": "您的订单已完成！",
      'ExpertDesc': '您的接单已完成！',
      "showUserAppealInfo": false,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": false,
      "showUserCancelOrderButton": false,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    },
    {
      "id": 7,
      "name": "申诉中",
      'iconFontData': const IconData(0xe660, fontFamily: "Iconfont"),
      "desc": "申诉中",
      'ExpertDesc': '',
      "showUserAppealInfo": true,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": false,
      "showUserCancelOrderButton": false,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    },
    {
      "id": 8,
      "name": "已拒绝",
      'iconFontData': const IconData(0xe660, fontFamily: "Iconfont"),
      "desc": "您的订单已被专家拒绝，重新选择其他专家吧~",
      'ExpertDesc': '',
      "showUserAppealInfo": false,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": true,
      "showUserDeleteOrderButton": true,
      "showUserCancelOrderButton": false,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    },
    {
      "id": 9,
      "name": "已取消",
      'iconFontData': const IconData(0xe660, fontFamily: "Iconfont"),
      "desc": "您的订单已取消",
      'ExpertDesc': '您的接单用户已取消',
      "showUserAppealInfo": false,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": true,
      "showUserCancelOrderButton": false,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    }
  ];

  // 出诊状态
  static const List<dynamic> expeditionStatus = [
    {
      "id": 0,
      "name": "待接单",
      'iconFontData': const IconData(0xe654, fontFamily: "Iconfont"),
      "desc": "您的订单已提交，请耐心等待专家接单;",
      'ExpertDesc': '',
      "showUserAppealInfo": false,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": false,
      "showUserCancelOrderButton": true,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    },
    {
      "id": 1,
      "name": "待报价",
      'iconFontData': const IconData(0xe68f, fontFamily: "Iconfont"),
      "desc": "您的订单已接单，请等待专家报价;",
      'ExpertDesc': '您已接受此订单，请尽快与用户沟通协商完成报价！',
      "showUserAppealInfo": false,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": false,
      "showUserCancelOrderButton": true,
      "showExpertQuoteButton": true,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    },
    {
      "id": 2,
      "name": "待付款",
      'iconFontData': const IconData(0xe659, fontFamily: "Iconfont"),
      "desc": "请快速完成付款，专家将在指定时间到场解决问题，如有疑问联系专家",
      'ExpertDesc': '您已报价，请等待用户付款;',
      "showUserAppealInfo": false,
      "showUserPaymentButton": true,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": false,
      "showUserCancelOrderButton": true,
      "showExpertQuoteButton": true,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    },
    {
      "id": 3,
      "name": "待打卡",
      'iconFontData': const IconData(0xe639, fontFamily: "Iconfont"),
      "desc": "您已付款，请等待专家到现场打卡",
      'ExpertDesc': '您的接单用户已付款，请在订单有效时间内完成打卡并上传维修前视频 ',
      "showUserAppealInfo": false,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": true,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": false,
      "showUserCancelOrderButton": false,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": true,
      "showExpertConfirmOrderButton": true,
      "showExpertArchiveButton": false
    },
    {
      "id": 4,
      "name": "待确认",
      'iconFontData': const IconData(0xe639, fontFamily: "Iconfont"),
      "desc": "专家已确认完成，请确认专家是否完成服务;",
      'ExpertDesc': '您已确认完成服务，请等待用户确认',
      "showUserAppealInfo": false,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": true,
      "showUserConfirmOrderButton": true,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": false,
      "showUserCancelOrderButton": false,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    },
    {
      "id": 5,
      "name": "待评价",
      'iconFontData': const IconData(0xe75b, fontFamily: "Iconfont"),
      "desc": "您的订单已完成，请给本次服务评价一下吧",
      'ExpertDesc': '您的接单已完成，请提醒用户评价订单',
      "showUserAppealInfo": false,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": true,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": false,
      "showUserCancelOrderButton": false,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    },
    {
      "id": 6,
      "name": "已完成",
      'iconFontData': const IconData(0xe75b, fontFamily: "Iconfont"),
      "desc": "您的订单已完成!",
      'ExpertDesc': '您的接单已完成!',
      "showUserAppealInfo": false,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": false,
      "showUserCancelOrderButton": false,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    },
    {
      "id": 7,
      "name": "申诉中",
      "desc": "申诉中",
      "ExpertDesc": "申诉中",
      'iconFontData': const IconData(0xe660, fontFamily: "Iconfont"),
      "showUserAppealInfo": true,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": false,
      "showUserCancelOrderButton": false,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    },
    {
      "id": 8,
      "name": "已拒绝",
      'iconFontData': const IconData(0xe660, fontFamily: "Iconfont"),
      "desc": "您的订单已被专家拒绝，重新选择其他专家吧~",
      'ExpertDesc': '您的接单已完成!',
      "showUserAppealInfo": false,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": false,
      "showUserDeleteOrderButton": true,
      "showUserChooseExpertButton": true,
      "showUserCancelOrderButton": false,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    },
    {
      "id": 9,
      "name": "已取消",
      'iconFontData': const IconData(0xe660, fontFamily: "Iconfont"),
      "desc": "您的接单用户已取消",
      'ExpertDesc': '您的订单已取消',
      "showUserAppealInfo": false,
      "showUserPaymentButton": false,
      "showUserConfirmPunchButton": false,
      "showUserAppealButton": false,
      "showUserConfirmOrderButton": false,
      "showUserEvaluationButton": false,
      "showUserChooseExpertButton": false,
      "showUserDeleteOrderButton": true,
      "showUserCancelOrderButton": false,
      "showExpertQuoteButton": false,
      "showExpertPunchButton": false,
      "showExpertConfirmOrderButton": false,
      "showExpertArchiveButton": false
    }
  ];

  // 通过id和类型获取状态名称
  // dataTable 1问诊，2出诊
  static String getStatusName(statuz, dataTable,
      {int arrivedFlag = 0, int examineFlag, String userType = 'USER'}) {
    List statusList;
    // if(statuz == 8){
    //   return "已拒绝";
    // }
    if (dataTable == 1) {
      if (userType == "USER" && (statuz == 6)) {
        return "已完成";
      }
      if ((statuz == 4)) {
        if (examineFlag == 2) {
          return "已驳回";
        } else if (examineFlag == 0) {
          return '归档待审核';
        }
      }
      statusList = inquiryStatus;
    } else if (dataTable == 2) {
      statusList = expeditionStatus;
      if (statuz == 3) {
        return arrivedFlag == 0 ? "待打卡" : "已打卡";
      }
    }
    for (var i = 0; i < statusList.length; i++) {
      if (statusList[i]['id'] == statuz) {
        return statusList[i]['name'];
      }
    }
    return '';
  }

// 通过id和类型获取状态名称
  // dataTable 1问诊，2出诊
  static String getdetailStatusName(statuz, dataTable,
      {int arrivedFlag = 0, int examineFlag, String userType = 'USER'}) {
    List statusList;
    // if(statuz == 8){
    //   return "已拒绝";
    // }
    if (dataTable == 1) {
      if ((statuz == 4)) {
        if (examineFlag == 2) {
          return "归档已驳回";
        } else if (examineFlag == 0) {
          return '归档已提交，等待审核中';
        }
        if (userType == "USER") {
          return '专家待归档';
        }
      }
      // if (userType == "USER" && (statuz == 5 || statuz == 6)) {
      //   return "已完成";
      // }
      // if (userType != "USER" && (statuz == 4)) {
      //   return '订单已完成,等待用户评价';
      // }
      statusList = inquiryStatus;
    } else if (dataTable == 2) {
      statusList = expeditionStatus;
      if (userType != "USER" && statuz == 3) {
        // return arrivedFlag == 0 ? "待打卡" : "已打卡";
        if (arrivedFlag == 0) {
          return '您的接单用户已付款，请在订单有效时间内完成打卡';
        } else if (arrivedFlag == 2) {
          return '您已打卡，请等待用户确认';
        } else if (arrivedFlag == 1) {
          return '确认到现场，完成服务后请上传维修后视频并点击确认完成 ';
        }

        return arrivedFlag == 0 ? '您的接单用户已付款，请在订单有效时间内完成打卡' : '您已打卡，请等待用户确认 ';
      }
      if (userType == "USER" && statuz == 3) {
        // return arrivedFlag == 0 ? "待打卡" : "已打卡";
        if (arrivedFlag == 0) {
          return '您已付款，请等待专家到现场打卡';
        } else if (arrivedFlag == 2) {
          return '专家已打卡，请确认专家是否到达现场';
        } else if (arrivedFlag == 1) {
          return '已确认专家打卡，请等待专家完成任务；';
        }

        return arrivedFlag == 0 ? '您已付款，请等待专家到现场打卡' : '专家已打卡，请确认专家是否到达现场';
        //  '专家已打卡，请确认专家是否到达现场' : '已确认专家打卡，请等待专家完成任务';
      }
      // if (userType == "USER" && (statuz == 1)) {
      //   return "等待专家报价";
      // }

      // if (userType == "USER" && (statuz == 2)) {
      //   return "您的订单已提交，请在29分50秒内完成支付，超时订单将自动取消";
      // }
    }
    for (var i = 0; i < statusList.length; i++) {
      if (statusList[i]['id'] == statuz) {
        return userType == "USER"
            ? statusList[i]['desc']
            : statusList[i]['ExpertDesc'];
      }
    }
    return '';
  }

// 通过id和类型获取状态名称
  // dataTable 1问诊，2出诊
  static getIconFontCode(statuz, dataTable) {
    List statusList;

    if (dataTable == 1) {
      statusList = inquiryStatus;
    } else if (dataTable == 2) {
      statusList = expeditionStatus;
    }
    for (var i = 0; i < statusList.length; i++) {
      if (statusList[i]['id'] == statuz) {
        return statusList[i]['iconFontData'];
        // return const IconData(statusList[i]['iconFontData'],
        //     fontFamily: "Iconfont");
      }
    }
    // return '';
  }

  // 通过id、类型和按钮关键字，判断内容是否显示
  static bool isShow(statuz, dataTable, type,
      {int arrivedFlag, int examineFlag}) {
    List statusList;
    if (dataTable == 1) {
      statusList = inquiryStatus;
    } else if (dataTable == 2) {
      statusList = expeditionStatus;
    }
    for (var i = 0; i < statusList.length; i++) {
      if (statusList[i]['id'] == statuz && statusList[i][type]) {
        if (type == 'showUserConfirmPunchButton') {
          // 如果专家没有打卡，用户可以协助打卡
          if (arrivedFlag == 0 || arrivedFlag == 1) {
            return false;
          } else {
            return true;
          }
        }
        if (type == 'showExpertConfirmOrderButton' && dataTable == 2) {
          // 如果专家已经打卡，才能专家确认
          if (arrivedFlag != 1) {
            return false;
          } else {
            return true;
          }
        }
        if (type == 'showExpertArchiveButton' && dataTable == 1) {
          if (examineFlag == 2) {
            return true;
          } else if (examineFlag == 0) {
            return false;
          }
        }

        return true;
      }
    }
    return false;
  }
}
