65 lines
5.7 KiB
Go
65 lines
5.7 KiB
Go
package model
|
||
|
||
import (
|
||
"gorm.io/gorm"
|
||
"hospital-open-api/global"
|
||
"time"
|
||
)
|
||
|
||
// OrderInquiry 订单-问诊表
|
||
type OrderInquiry struct {
|
||
OrderInquiryId int64 `gorm:"column:order_inquiry_id;type:bigint(19);primary_key;comment:主键id" json:"order_inquiry_id"`
|
||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id-患者;NOT NULL" json:"user_id"`
|
||
PatientId int64 `gorm:"column:patient_id;type:bigint(19);comment:患者id;NOT NULL" json:"patient_id"`
|
||
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id(未分配时为null)" json:"doctor_id"`
|
||
FamilyId int64 `gorm:"column:family_id;type:bigint(19);comment:家庭成员id(就诊用户);NOT NULL" json:"family_id"`
|
||
InquiryType int `gorm:"column:inquiry_type;type:tinyint(1);comment:订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测);NOT NULL" json:"inquiry_type"`
|
||
InquiryMode int `gorm:"column:inquiry_mode;type:tinyint(1);comment:订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员);NOT NULL" json:"inquiry_mode"`
|
||
InquiryStatus int `gorm:"column:inquiry_status;type:tinyint(1);default:1;comment:问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消);NOT NULL" json:"inquiry_status"`
|
||
IsDelete int `gorm:"column:is_delete;type:tinyint(1);default:0;comment:删除状态(0:否 1:是)" json:"is_delete"`
|
||
InquiryRefundStatus int `gorm:"column:inquiry_refund_status;type:tinyint(1);default:0;comment:问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)" json:"inquiry_refund_status"`
|
||
InquiryPayChannel int `gorm:"column:inquiry_pay_channel;type:tinyint(1);comment:支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)" json:"inquiry_pay_channel"`
|
||
InquiryPayStatus int `gorm:"column:inquiry_pay_status;type:tinyint(1);default:1;comment:支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款);NOT NULL" json:"inquiry_pay_status"`
|
||
InquiryNo string `gorm:"column:inquiry_no;type:varchar(30);comment:系统订单编号;NOT NULL" json:"inquiry_no"`
|
||
EscrowTradeNo string `gorm:"column:escrow_trade_no;type:varchar(100);comment:第三方支付流水号" json:"escrow_trade_no"`
|
||
AmountTotal float64 `gorm:"column:amount_total;type:decimal(10,2);default:0.00;comment:订单金额" json:"amount_total"`
|
||
CouponAmountTotal float64 `gorm:"column:coupon_amount_total;type:decimal(10,2);comment:优惠卷总金额" json:"coupon_amount_total"`
|
||
PaymentAmountTotal float64 `gorm:"column:payment_amount_total;type:decimal(10,2);default:0.00;comment:实际付款金额" json:"payment_amount_total"`
|
||
PayTime LocalTime `gorm:"column:pay_time;type:datetime;comment:支付时间" json:"pay_time"`
|
||
ReceptionTime LocalTime `gorm:"column:reception_time;type:datetime;comment:接诊时间(已接诊)" json:"reception_time"`
|
||
CompleteTime LocalTime `gorm:"column:complete_time;type:datetime;comment:订单完成时间(问诊完成时间)" json:"complete_time"`
|
||
FinishTime LocalTime `gorm:"column:finish_time;type:datetime;comment:订单结束时间" json:"finish_time"`
|
||
StatisticsStatus int `gorm:"column:statistics_status;type:tinyint(1);default:0;comment:订单统计状态(0:未统计 1:已统计 2:统计失败)" json:"statistics_status"`
|
||
StatisticsTime LocalTime `gorm:"column:statistics_time;type:datetime;comment:订单统计时间" json:"statistics_time"`
|
||
IsWithdrawal int `gorm:"column:is_withdrawal;type:tinyint(1);default:0;comment:是否提现(0:否 1:是 2:提现中)" json:"is_withdrawal"`
|
||
WithdrawalTime LocalTime `gorm:"column:withdrawal_time;type:datetime;comment:提现时间" json:"withdrawal_time"`
|
||
CancelTime LocalTime `gorm:"column:cancel_time;type:datetime;comment:订单取消时间" json:"cancel_time"`
|
||
CancelReason int `gorm:"column:cancel_reason;type:tinyint(1);comment:取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)" json:"cancel_reason"`
|
||
CancelRemarks string `gorm:"column:cancel_remarks;type:varchar(255);comment:取消订单备注(自动添加)" json:"cancel_remarks"`
|
||
PatientName string `gorm:"column:patient_name;type:varchar(255);comment:患者姓名-就诊人" json:"patient_name"`
|
||
PatientNameMask string `gorm:"column:patient_name_mask;type:varchar(255);comment:患者姓名-就诊人(掩码)" json:"patient_name_mask"`
|
||
PatientSex int `gorm:"column:patient_sex;type:tinyint(1);default:0;comment:患者性别-就诊人(0:未知 1:男 2:女)" json:"patient_sex"`
|
||
PatientAge int `gorm:"column:patient_age;type:int(1);comment:患者年龄-就诊人" json:"patient_age"`
|
||
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
|
||
PatientUser *User `gorm:"foreignKey:UserId;references:user_id" json:"patient_user"` // 用户-患者
|
||
Model
|
||
}
|
||
|
||
func (m *OrderInquiry) TableName() string {
|
||
return "gdxz_order_inquiry"
|
||
}
|
||
|
||
func (m *OrderInquiry) BeforeCreate(tx *gorm.DB) error {
|
||
if m.OrderInquiryId == 0 {
|
||
m.OrderInquiryId = global.Snowflake.Generate().Int64()
|
||
}
|
||
|
||
m.CreatedAt = LocalTime(time.Now())
|
||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||
|
||
m.UpdatedAt = LocalTime(time.Now())
|
||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||
|
||
return nil
|
||
}
|