syntax = "proto3";

package com.ywt.gapi.nat;

option java_multiple_files = true;
option java_package = "com.ywt.gapi.nat";
option java_outer_classname = "NatProto";

message CreateOrderRequest {
    int32 hospitalId = 1;// 医院 id
    int32 userId = 2;
    string name = 3;
    string idCardNo = 4;
    string mobile = 5;
    string regDate = 6;// 预约日期，yyyy-MM-dd
    int32 regTimePeriod = 7;// 预约时间段：1-上午；2-下午；
    string address = 8;// 现住址
    int32 amount = 9;// 前端传来的价格
}

message CreateOrderResponse {
    int32 code = 1;
    string info = 2;
    int32 orderId = 3;
    string orderNo = 4;
    bool hasPaid = 5;// 是否已支付，对于 0 元订单，直接返回支付成功，前端不需唤起支付。
    int32 natOrderId = 6;
}

message GetConfigRequest {
    int32 hospitalId = 1;
}

message GetConfigResponse {
    int32 code = 1;
    string info = 2;
    int32 fee = 3;// 后台设置的费用
}

message GetOrderDetailRequest {
    int32 natOrderId = 1;// 核酸检测订单 id, nat_order 表主键
    string orderNo = 2;// 订单编号，nat_order 表 order_no
    int32 orderId = 3;// nat_order 表 order_id
    int32 userId = 4;
}

message OrderDetail {
    int32 id = 1;
    int32 orderId = 2;
    string orderNo = 3;
    int32 hospitalId = 4;
    int64 createTime = 5;
    int32 amount = 6;
    int32 userId = 7;
    string patientName = 8;
    string idCard = 9;
    string mobile = 10;
    string regDate = 11;
    int32 regTimePeriod = 12;
    string address = 13;
    int32 status = 14;
    int32 paymentStatus = 15;
    int64 payTime = 16;
    int64 refundTime = 17;
    string paymentCode = 18;
    string vaccineCode = 19;
    string remark = 20;
    int32 extStatus = 21;
}

message GetOrderDetailResponse {
    int32 code = 1;
    string info = 2;
    OrderDetail orderDetail = 3;
}

message GetOrderListRequest {
    int32 pageIndex = 1;
    int32 pageSize = 2;
    int32 hospitalId = 3;
    int32 userId = 4;
}

message GetOrderListResponse {
    int32 code = 1;
    string info = 2;
    repeated OrderDetail orderDetail = 3;
    int32 count = 4; //总条数
    int32 totalPages = 5; //总页数
}

//订单支付成功通知消息
message PayCallbackRequest{
    string orderNo = 1;
    int32 orderId = 2;
    int32 payType = 3; //1: 微信; 2: 管理员线下收费
    string custom = 4; //回发创建单时设置的自定义数据
    int32 bizId = 5;
    string paymentNo = 6; //订单中心支付流水号
    int32 userId = 7;//用户id
    string prepayId = 8; //本次支付微信 prepay_id
    int32 terminal = 9;  //发起支付终端
    string openid = 10; //完成微信支付的微信用户 openid
    int32 paymentChannel = 11;
    string oneTimeCustom = 12;//本次操作自定义数据
    string wxTransactionId = 13; //本次微信支付交易流水号
    int64 payFinishDate = 14; //支付完成时间，单位：秒
}

//订单支付成功通知响应消息
message PayCallbackResponse{
    int32 code = 1;
    string info = 2;
}


//核酸检测订单退款回调
message RefundNatOrderCallbackRequest{
    int32 amount = 1;       //已退金额
    int32 bizId = 2;
    int32 orderId = 3;
    string orderNo = 4;
    string refundNo = 5;    //退款单号
    int32 refundStatus = 6; //退款状态 1: 退款成功，2: 退款异常，3: 退款关闭
    string custom = 7;      //回发 custom 数据
}

message RefundNatOrderCallbackResponse{
    int32 code = 1;
    string info = 2;
}

message RefundOrderRequest {
    int32 natOrderId = 1;// nat_order 表主键
    string remark = 2;// 备注
}

message BaseInfoResponse {
    int32 code = 1;
    string info = 2;
}

message CancelOrderRequest {
    int32 natOrderId = 1;// nat_order 表主键
    int32 userId = 2;
}

// 核酸检测服务
service NatService {
    // 创建核酸检测订单
    rpc createOrder(CreateOrderRequest) returns (CreateOrderResponse);
    // 获取核酸检测配置
    rpc getConfig(GetConfigRequest) returns (GetConfigResponse);
    // 获取详情
    rpc getOrderDetail(GetOrderDetailRequest) returns (GetOrderDetailResponse);
    // 获取订单列表
    rpc getOrderList(GetOrderListRequest) returns (GetOrderListResponse);
    // 支付成功回调
    rpc payCallback(PayCallbackRequest) returns (PayCallbackResponse);
    // 退款成功回调
    rpc refundNatOrderCallback(RefundNatOrderCallbackRequest) returns (RefundNatOrderCallbackResponse);
    // 退款
    rpc refund(RefundOrderRequest) returns (BaseInfoResponse);
    // 取消订单
    rpc cancelOrder(CancelOrderRequest) returns (BaseInfoResponse);
}