table.dart 4.79 KB

import 'package:json_annotation/json_annotation.dart';

import 'notebook.dart';

part 'table.g.dart';

@JsonSerializable()
class Table {
  Table();

  String? id; //主键id
  String? rid; //关联区域id
  String? tid; //桌位类型 1散座 2包间 3卡座
  String? name; //桌位名称
  String? table_pnum; //桌位最少可坐人数
  String? most_pnum; //桌位最多可坐人数
  String? order_o; //桌位排序编号
  String? status; //桌位状态 0未使用 1使用中 2已删除
  String? tablestatus; //桌位状态 0未使用 1使用中 2已删除
  String? enable; //0禁用 1启用
  String? spell; //1拼桌
  String? rname; //关联区域名称
  dynamic isExitsClass; //表示这个桌子已经关联到包间分类了   null是没有
  String? max; //最多可坐人数
  String? low; //最低消费
  String? sign; //标签 桌位状态 0:待确认,1:已订座,2:确认到店,3:用餐完成,4:取消预订,5:安排包间,6拒绝订单
  String? reserver; //订餐人
  String? notebookId; //桌位对应的预订id
  bool? selected; //是否选中
  int? isPhoto; //桌位是否有照片
  String? pnum; //预计人数
  String? nickName; //操作人
  String? noteName; //操作人
  String? place_order_name; //预订人
  String? isLock; //是否被合并上锁
  String? isMerge; //是否打开桌位合并开关
  String? tids; //被合并桌位tids

  String? tidsCancel; //关闭开关取消合并的时候使用,
  String? lockTname; //被谁合并了
  String? lockTid; //被合并桌位id
  String? label; //底部标签 (新客,婚宴)
  String? reserveCount; //预订总次数
  String? phone; //订餐人电话

  Notebook? notebook;

//预订总次数显示
  String get reserveCountShow {
    if (reserveCount == '1'
        // ||
        // reserver == null ||
        // reserver.isEmpty ||
        // reserver == ''
        ) {
      // 预订次数== 1 或者 姓名或者客户电话号码为空的时候 ,显示首次预订
      return "新客";
    } else if (reserveCount != null &&
        reserveCount != '0' &&
        reserveCount != '') {
      return '第${reserveCount}次进店';
    } else {
      return '';
    }
  }

  //获取桌位类型
  String get tidStr {
    switch (tid) {
      case "1":
        return "散座";
      case "2":
        return "包间";
      case "3":
        return "卡座";
        default:
        return '';
    }
  }

  String get maxText {
    if (max == null || max == "0" || max == "null") {
      return "";
    } else {
      return "最多可坐" + max! + "人";
    }
  }

  //获取桌位可坐人数
  String get tableNum {
    if (table_pnum == null || table_pnum!.isEmpty || table_pnum == "0") {
      return "";
    } else if (most_pnum != null &&
        most_pnum!.isNotEmpty &&
        most_pnum != "0" &&
        most_pnum != "null") {
      if (table_pnum == most_pnum) {
        return "$table_pnum人";
      } else {
        return "$table_pnum-$most_pnum人";
      }
    } else {
      return "$table_pnum人";
    }
  }

  //获取最低消费
  String get lowStr {
    return (low == null || low!.isEmpty || low == "0") ? "" : "最低消费\n$low元";
  }

  String get signStr {
    if (sign != null && sign!.isNotEmpty) {
      switch (sign) {
        case "1": //已预订
        case "5": //已安排包间
          // itemRv.setBackgroundResource(R.drawable.table_white);
          //                     if(item.getOrder_status()==3){
          //                         status.setBackgroundResource(R.drawable.table_bg_bottom_yellow);
          //                         status.setText("已买单");
          //                     }else{
          //                         status.setBackgroundResource(R.drawable.table_bg_bottom_red);
          //                         status.setText("已预订");
          //                     }
          //                     status.setVisibility(View.VISIBLE);
          //                     pnum.setText(item.getNoteName());
          return "已预订";
        case "2": //用餐中
          return "已预订";
        case "10": //婚宴
          return "已预订";
        default:
          return "";
      }
    }
    if (enable == "0") return "已停用";
    return "";
  }

  factory Table.fromJson(Map<String, dynamic> json) => _$TableFromJson(json);
  Map<String, dynamic> toJson() => _$TableToJson(this);

  @override
  String toString() {
    return 'Table{id: $id,is_photo:$isPhoto rid: $rid, tid: $tid, name: $name, table_pnum: $table_pnum, most_pnum: $most_pnum, order_o: $order_o, status: $status, tablestatus: $tablestatus, enable: $enable, spell: $spell, rname: $rname, isExitsClass:$isExitsClass,max: $max, low: $low, is_lock: $isLock, is_merge: $isMerge,tids:$tids,lock_tname:$lockTname,reserveCount:$reserveCount,phone:$phone,lock_tid:$lockTid,rname:$rname,}';
  }
}