Files
biz_xfj_cloud/lib/common/models/api/hard_api_models.dart
T
2026-07-28 21:34:12 +08:00

759 lines
17 KiB
Dart

import 'package:json_annotation/json_annotation.dart';
import 'package:pj_supermarket_cloud/common/index.dart';
part 'hard_api_models.g.dart';
@JsonSerializable()
class ServiceHardware extends ServiceBase {
/// 编号
final String? id;
/// 设备名
final String? name;
/// 设备类型
final String? type;
/// 设备类型enum
final String? typeEnum;
/// 商户id
final String? merchantId;
/// 商户部门id
final String? merchantDeptId;
/// 硬件分组id
final String? hardGroupId;
/// 商户名
final String? merchantStr;
/// mq连接id
final String? mqClientId;
/// android唯一id
final String? uniqueCode;
/// 当前设备的topic
final String? mainTopic;
/// mq地址
final String? mqSocketAddress;
/// mq端口
final String? mqSocketPort;
/// mq用户名
final String? mqUsername;
/// mq密码
final String? mqPassword;
/// 同步次数版本
final int? mqSyncCount;
/// 人脸appId
final String? faceAppId;
/// 人脸sdkKey
final String? faceSdkKey;
/// 人脸activeKey
final String? faceActiveKey;
ServiceHardware({
this.id,
this.name,
this.type,
this.typeEnum,
this.merchantId,
this.merchantDeptId,
this.hardGroupId,
this.merchantStr,
this.mqClientId,
this.uniqueCode,
this.mainTopic,
this.mqSocketAddress,
this.mqSocketPort,
this.mqUsername,
this.mqPassword,
this.mqSyncCount,
this.faceAppId,
this.faceSdkKey,
this.faceActiveKey,
});
factory ServiceHardware.fromJson(Map<String, dynamic> json) =>
_$ServiceHardwareFromJson(json);
@override
Map<String, dynamic> toJson() => _$ServiceHardwareToJson(this);
}
@JsonSerializable()
class ServiceCar {
/// 编号
final String? id;
/// 父购物车id
final String? parentCarId;
/// 商品名
final String? productName;
/// 商品价格
final int? productPrice;
/// 商品id
final String? productId;
/// 数量
final int? productCount;
/// 总价(分)
@JsonKey(fromJson: JsonTool.stringToInt, toJson: JsonTool.intToString)
final int? totalPrice;
/// 商品图片
final String? productPic;
ServiceCar({
this.id,
this.parentCarId,
this.productName,
this.productPrice,
this.productId,
this.productCount,
this.totalPrice,
this.productPic,
});
factory ServiceCar.fromJson(Map<String, dynamic> json) =>
_$ServiceCarFromJson(json);
Map<String, dynamic> toJson() => _$ServiceCarToJson(this);
}
@JsonSerializable()
class ServiceGenerateInvoice {
/// 图片
final String? pic;
/// 记录id
final String? historyId;
ServiceGenerateInvoice({
this.pic,
this.historyId,
});
factory ServiceGenerateInvoice.fromJson(Map<String, dynamic> json) =>
_$ServiceGenerateInvoiceFromJson(json);
Map<String, dynamic> toJson() => _$ServiceGenerateInvoiceToJson(this);
}
@JsonSerializable()
class ServiceQRCode {
/// 总id
@JsonKey(fromJson: JsonTool.intToString, toJson: JsonTool.stringToInt)
final String? id;
/// 子id
@JsonKey(fromJson: JsonTool.intToString, toJson: JsonTool.stringToInt)
final String? itemId;
/// 类型id 比如钱包类型
@JsonKey(fromJson: JsonTool.intToString, toJson: JsonTool.stringToInt)
final String? typeId;
/// 用户id
@JsonKey(fromJson: JsonTool.intToString, toJson: JsonTool.stringToInt)
final String? userId;
/// 订单类型
@JsonKey(
fromJson: JsonTool.stringToOrderType,
toJson: JsonTool.orderTypeToString,
)
final OrderType? orderType;
/// 支付类型
@JsonKey(
fromJson: JsonTool.stringToOrderPayType,
toJson: JsonTool.orderPayTypeToString,
)
final OrderPayType? payType;
/// 过期时间 -1 代表没有限制
final int? exceedTime;
/// 额外的用户信息
final String? extra;
ServiceQRCode({
this.id,
this.itemId,
this.typeId,
this.userId,
this.orderType,
this.payType,
this.exceedTime,
this.extra,
});
factory ServiceQRCode.fromJson(Map<String, dynamic> json) =>
_$ServiceQRCodeFromJson(json);
Map<String, dynamic> toJson() => _$ServiceQRCodeToJson(this);
}
@JsonSerializable()
class ServiceHardOrder {
/// 用户id
final String? userId;
/// 用户名
final String? username;
/// 用户手机号
final String? userMobile;
/// 用户头像
final String? userAvatar;
/// 订单类型
final String? orderType;
/// 订单状态
final String? orderStatus;
/// 支付方式
final String? payType;
/// 支付方式
final String? walletId;
ServiceHardOrder({
this.userId,
this.username,
this.userMobile,
this.userAvatar,
this.orderType,
this.orderStatus,
this.payType,
this.walletId,
});
factory ServiceHardOrder.fromJson(Map<String, dynamic> json) =>
_$ServiceHardOrderFromJson(json);
Map<String, dynamic> toJson() => _$ServiceHardOrderToJson(this);
}
/// 当前终端预约核销记录的服务端查询参数。
@JsonSerializable(includeIfNull: false)
class VerificationRecordQueryRequest {
const VerificationRecordQueryRequest({
required this.hardId,
required this.startDate,
required this.endDate,
this.verificationType,
});
final int hardId;
final String startDate;
final String endDate;
final String? verificationType;
factory VerificationRecordQueryRequest.fromJson(Map<String, dynamic> json) =>
_$VerificationRecordQueryRequestFromJson(json);
Map<String, dynamic> toJson() => _$VerificationRecordQueryRequestToJson(this);
}
/// 核销记录只承载列表展示字段,不复用本地订单实体,避免混淆远端与本地状态。
@JsonSerializable()
class ServiceVerificationRecord {
const ServiceVerificationRecord({
required this.orderId,
required this.orderNo,
required this.verificationType,
required this.verificationTypeName,
required this.username,
required this.productDesc,
required this.payTypeName,
required this.totalPrice,
required this.verificationTime,
this.userDeptName,
});
/// 后端 Long 为避免跨端精度丢失可能序列化为字符串,终端同时兼容数字返回。
@JsonKey(fromJson: JsonTool.anyToInt)
final int orderId;
final String orderNo;
final String verificationType;
final String verificationTypeName;
final String username;
final String? userDeptName;
final String productDesc;
final String payTypeName;
/// 金额仍按整数分使用,同时兼容部分环境将数值序列化为字符串。
@JsonKey(fromJson: JsonTool.anyToInt)
final int totalPrice;
final DateTime verificationTime;
factory ServiceVerificationRecord.fromJson(Map<String, dynamic> json) =>
_$ServiceVerificationRecordFromJson(json);
Map<String, dynamic> toJson() => _$ServiceVerificationRecordToJson(this);
}
@JsonSerializable()
class ServiceVerificationRecordPage extends ServicePageBase {
ServiceVerificationRecordPage({this.records});
final List<ServiceVerificationRecord>? records;
factory ServiceVerificationRecordPage.fromJson(Map<String, dynamic> json) =>
_$ServiceVerificationRecordPageFromJson(json);
@override
Map<String, dynamic> toJson() => _$ServiceVerificationRecordPageToJson(this);
}
@JsonSerializable()
class ServiceOpenCard {
/// 用户名
String? username;
/// 用户手机号
String? mobile;
/// 用户头像
String? avatar;
/// 饭卡状态
String? cardStatus;
/// 编号
String? id;
/// 部门名
String? deptId;
/// 部门名
String? deptName;
/// 用户编号
String? userId;
/// 饭卡类型Id
String? walletTypeId;
/// 饭卡类型
String? walletTypeUniqueCode;
/// 饭卡图标
String? walletTypeIcon;
/// 用户卡号
String? cardNumber;
/// 钱包编号
String? walletId;
/// 是否激活
@JsonKey(fromJson: JsonTool.stringToBoolean, toJson: JsonTool.booleanToString)
bool? isActiveHardware;
ServiceOpenCard({
this.username,
this.mobile,
this.avatar,
this.cardStatus,
this.id,
this.deptId,
this.deptName,
this.userId,
this.walletTypeId,
this.walletTypeUniqueCode,
this.walletTypeIcon,
this.cardNumber,
this.walletId,
this.isActiveHardware,
});
factory ServiceOpenCard.fromJson(Map<String, dynamic> json) =>
_$ServiceOpenCardFromJson(json);
Map<String, dynamic> toJson() => _$ServiceOpenCardToJson(this);
}
@JsonSerializable()
class ServiceOpenCardPage extends ServicePageBase {
List<ServiceOpenCard>? records;
ServiceOpenCardPage({
this.records,
});
factory ServiceOpenCardPage.fromJson(Map<String, dynamic> json) =>
_$ServiceOpenCardPageFromJson(
json,
);
Map<String, dynamic> toJson() => _$ServiceOpenCardPageToJson(this);
}
@JsonSerializable()
class ServiceChartLatitude {
/// 早餐、中餐、晚餐
final List<ServiceChartLatitudeItem> dayTotal;
/// 每天的交易量
final List<ServiceChartLatitudeItem> weekTotal;
/// 每天的交易金额
final List<ServiceChartLatitudeItem> monthTotal;
/// 每周的交易量
final List<ServiceChartLatitudeItem> yearTotal;
/// 每周的交易量
final List<ServiceChartLatitudeItem> allTotal;
ServiceChartLatitude({
required this.dayTotal,
required this.weekTotal,
required this.monthTotal,
required this.yearTotal,
required this.allTotal,
});
factory ServiceChartLatitude.fromJson(Map<String, dynamic> json) =>
_$ServiceChartLatitudeFromJson(
json,
);
Map<String, dynamic> toJson() => _$ServiceChartLatitudeToJson(this);
}
@JsonSerializable()
class ServiceChartLatitudeItem {
/// 早餐、中餐、晚餐
final String? hourType;
/// 每月的交易量
final String? deptId;
/// 每月的交易量
final String? sum;
/// 每月的交易量
final String? count;
ServiceChartLatitudeItem({
this.hourType,
this.deptId,
this.sum,
this.count,
});
factory ServiceChartLatitudeItem.fromJson(Map<String, dynamic> json) =>
_$ServiceChartLatitudeItemFromJson(
json,
);
Map<String, dynamic> toJson() => _$ServiceChartLatitudeItemToJson(this);
}
@JsonSerializable()
class ServiceBroadcastToday {
/// 广播id
final String id;
/// 预定用户
final String userId;
/// 用户名
final String username;
/// 用户手机号
final String userMobile;
/// 硬件id
final String hardId;
/// mq主题
final String topic;
/// 业务类型
final String? bizType;
/// 关联业务编号
final String? bizId;
/// 预定标题
final String title;
/// 预定内容
final String content;
/// 当前广播次数
final int? broadcastCount;
/// 最大广播次数
final int? broadcastMaxCount;
/// 是否广播语音
@JsonKey(fromJson: JsonTool.stringToBoolean, toJson: JsonTool.booleanToString)
final bool isBroadcast;
/// 用餐时间段
final String? hourType;
/// 商品介绍
String productDesc;
/// 支付价格
int payPrice;
/// 创建时间
String createTime;
ServiceBroadcastToday({
required this.id,
required this.userId,
required this.username,
required this.userMobile,
required this.hardId,
required this.topic,
this.bizType,
this.bizId,
required this.title,
required this.content,
this.broadcastCount,
this.broadcastMaxCount,
required this.isBroadcast,
this.hourType,
required this.productDesc,
required this.payPrice,
required this.createTime,
});
factory ServiceBroadcastToday.fromJson(Map<String, dynamic> json) =>
_$ServiceBroadcastTodayFromJson(
json,
);
Map<String, dynamic> toJson() => _$ServiceBroadcastTodayToJson(this);
}
@JsonSerializable()
class ServiceBroadcastTodayPage extends ServicePageBase {
List<ServiceBroadcastToday>? records;
ServiceBroadcastTodayPage({
this.records,
});
factory ServiceBroadcastTodayPage.fromJson(Map<String, dynamic> json) =>
_$ServiceBroadcastTodayPageFromJson(
json,
);
Map<String, dynamic> toJson() => _$ServiceBroadcastTodayPageToJson(this);
}
@JsonSerializable()
class ServiceHardCreateHardQrCodeScanOrder {
/// 订单id
String orderId;
/// 订单id
String mchId;
/// 订单id
String qrCodeData;
ServiceHardCreateHardQrCodeScanOrder({
required this.orderId,
required this.mchId,
required this.qrCodeData,
});
factory ServiceHardCreateHardQrCodeScanOrder.fromJson(
Map<String, dynamic> json) =>
_$ServiceHardCreateHardQrCodeScanOrderFromJson(
json,
);
Map<String, dynamic> toJson() =>
_$ServiceHardCreateHardQrCodeScanOrderToJson(this);
}
/// 终端本人预约菜单查询参数。
@JsonSerializable(includeIfNull: false)
class ReservationMenuQueryRequest {
const ReservationMenuQueryRequest({
required this.hardId,
required this.recognitionType,
required this.maskName,
this.cardNumber,
this.faceUserId,
});
/// 当前终端设备 ID。
final int hardId;
/// 本人识别方式,沿用后端 CARD、FACE 契约。
final String recognitionType;
/// 是否由服务端脱敏用户姓名。
final bool maskName;
/// 饭卡卡号,仅 CARD 识别时传递。
final String? cardNumber;
/// 人脸插件识别出的用户 ID,仅 FACE 识别时传递。
final int? faceUserId;
factory ReservationMenuQueryRequest.fromJson(Map<String, dynamic> json) =>
_$ReservationMenuQueryRequestFromJson(json);
Map<String, dynamic> toJson() => _$ReservationMenuQueryRequestToJson(this);
}
/// 终端识别本人后返回的预约菜单,姓名由服务端按终端配置决定是否脱敏。
@JsonSerializable(explicitToJson: true)
class ServiceReservationMenuQuery {
/// 服务端按终端配置返回的用户姓名;字段名保留用于兼容既有协议。
final String maskedName;
/// 用户所属部门名称。
final String? deptName;
/// 当前终端绑定的食堂名称。
final String merchantName;
/// 查询结果中包含预约的日期数量。
final int totalDayCount;
/// 查询结果中包含预约的餐段数量。
final int totalMealCount;
/// 按预约日期升序排列的菜单列表。
final List<ServiceReservationDay> days;
const ServiceReservationMenuQuery({
required this.maskedName,
this.deptName,
required this.merchantName,
required this.totalDayCount,
required this.totalMealCount,
required this.days,
});
factory ServiceReservationMenuQuery.fromJson(Map<String, dynamic> json) =>
_$ServiceReservationMenuQueryFromJson(json);
Map<String, dynamic> toJson() => _$ServiceReservationMenuQueryToJson(this);
}
@JsonSerializable(explicitToJson: true)
class ServiceReservationDay {
/// 预约用餐日期,格式为 yyyy-MM-dd。
final String date;
/// 当天按餐段顺序排列的预约菜单。
final List<ServiceReservationMeal> meals;
const ServiceReservationDay({
required this.date,
required this.meals,
});
factory ServiceReservationDay.fromJson(Map<String, dynamic> json) =>
_$ServiceReservationDayFromJson(json);
Map<String, dynamic> toJson() => _$ServiceReservationDayToJson(this);
}
@JsonSerializable(explicitToJson: true)
class ServiceReservationMeal {
/// 预约餐段编码,沿用硬件订单餐段契约。
final String hourType;
/// 预约餐段显示名称。
final String mealTitle;
/// 当前餐段所有预约订单的去重餐品汇总,用于兼容旧服务端和旧终端。
final List<String> items;
/// 当前餐段可核销的预约订单 ID 列表。
@JsonKey(fromJson: JsonTool.anyListToIntList)
final List<int> orderIds;
/// 当前餐段内每笔预约订单与餐品的明确对应关系。
final List<ServiceReservationOrder> orders;
const ServiceReservationMeal({
required this.hourType,
required this.mealTitle,
required this.items,
this.orderIds = const [],
this.orders = const [],
});
factory ServiceReservationMeal.fromJson(Map<String, dynamic> json) =>
_$ServiceReservationMealFromJson(json);
Map<String, dynamic> toJson() => _$ServiceReservationMealToJson(this);
}
/// 同一餐段内单笔预约与餐品的对应关系;旧服务端没有该字段时保持空列表。
@JsonSerializable(explicitToJson: true)
class ServiceReservationOrder {
/// 可核销的预约订单 ID。
@JsonKey(fromJson: JsonTool.anyToInt)
final int orderId;
/// 该笔预约订单实际购买的商品与数量明细。
final List<ServiceReservationOrderItem> items;
const ServiceReservationOrder({
required this.orderId,
required this.items,
});
factory ServiceReservationOrder.fromJson(Map<String, dynamic> json) =>
_$ServiceReservationOrderFromJson(json);
Map<String, dynamic> toJson() => _$ServiceReservationOrderToJson(this);
}
/// 单笔预约订单中的商品与购买数量。
@JsonSerializable()
class ServiceReservationOrderItem {
/// 订单中的商品名称。
final String productName;
/// 订单中的商品图片地址。
final String? productPic;
/// 订单中的商品购买数量;历史异常数据缺失时允许为空。
final int? productCount;
const ServiceReservationOrderItem({
required this.productName,
this.productPic,
this.productCount,
});
factory ServiceReservationOrderItem.fromJson(Map<String, dynamic> json) =>
_$ServiceReservationOrderItemFromJson(json);
Map<String, dynamic> toJson() => _$ServiceReservationOrderItemToJson(this);
}