65 lines
5.7 KiB
Go
65 lines
5.7 KiB
Go
package model
|
||
|
||
import (
|
||
"gorm.io/gorm"
|
||
"hospital-admin-api/global"
|
||
"time"
|
||
)
|
||
|
||
// OrderServicePackage 订单-服务包表
|
||
type OrderServicePackage struct {
|
||
OrderServiceId int64 `gorm:"column:order_service_id;type:bigint(19);primary_key;comment:主键id" json:"order_service_id"`
|
||
OrderId int64 `gorm:"column:order_id;type:bigint(19);comment:订单id;NOT NULL" json:"order_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;NOT NULL" json:"doctor_id"`
|
||
FamilyId int64 `gorm:"column:family_id;type:bigint(19);comment:家庭成员id(就诊用户);NOT NULL" json:"family_id"`
|
||
OrderServiceType int `gorm:"column:order_service_type;type:tinyint(1);comment:服务包类型(1:健康包 2:随访包);NOT NULL" json:"order_service_type"`
|
||
OrderServiceStatus int `gorm:"column:order_service_status;type:tinyint(4);comment:订单状态(1:待支付 2:未开始 3:服务中 4:服务完成 5:服务取消);NOT NULL" json:"order_service_status"`
|
||
IsDelete int `gorm:"column:is_delete;type:tinyint(1);default:0;comment:删除状态(0:否 1:是)" json:"is_delete"`
|
||
RefundStatus int `gorm:"column:refund_status;type:tinyint(1);default:0;comment:订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常 7:部分退款);NOT NULL" json:"refund_status"`
|
||
PayChannel int `gorm:"column:pay_channel;type:tinyint(1);comment:支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付);NOT NULL" json:"pay_channel"`
|
||
PayStatus int `gorm:"column:pay_status;type:tinyint(1);default:1;comment:支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款);NOT NULL" json:"pay_status"`
|
||
OrderServiceNo string `gorm:"column:order_service_no;type:varchar(30);comment:系统订单编号;NOT NULL" json:"order_service_no"`
|
||
EscrowTradeNo string `gorm:"column:escrow_trade_no;type:varchar(100);comment:第三方支付流水号;NOT NULL" 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);default:0.00;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"`
|
||
StartTime LocalTime `gorm:"column:start_time;type:datetime;comment:开始服务时间" json:"start_time"`
|
||
FinishTime LocalTime `gorm:"column:finish_time;type:datetime;comment:结束服务时间" json:"finish_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:主动取消 4:客服取消 5:支付超时)" json:"cancel_reason"`
|
||
CancelRemarks string `gorm:"column:cancel_remarks;type:varchar(255);comment:取消订单备注" json:"cancel_remarks"`
|
||
AddFinishStatus int `gorm:"column:add_finish_status;type:tinyint(1);default:0;comment:添加完成订单延迟队列状态(0:未添加 1:已添加 2:添加失败)" json:"add_finish_status"`
|
||
AddFinishTime LocalTime `gorm:"column:add_finish_time;type:datetime;comment:添加完成订单延迟队列时间" json:"add_finish_time"`
|
||
AddFinishFailReason string `gorm:"column:add_finish_fail_reason;type:varchar(255);comment:添加完成订单延迟队列失败原因" json:"add_finish_fail_reason"`
|
||
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"`
|
||
Model
|
||
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
|
||
User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"` // 患者
|
||
OrderServicePackageInquiry []*OrderServicePackageInquiry `gorm:"foreignKey:OrderServiceId;references:order_service_id" json:"order_service_package_inquiry"` // 关联问诊订单
|
||
OrderServicePackageProduct []*OrderServicePackageProduct `gorm:"foreignKey:OrderServiceId;references:order_service_id" json:"order_service_package_product"` // 关联商品订单
|
||
}
|
||
|
||
func (m *OrderServicePackage) TableName() string {
|
||
return "gdxz_order_service_package"
|
||
}
|
||
|
||
func (m *OrderServicePackage) BeforeCreate(tx *gorm.DB) error {
|
||
if m.OrderServiceId == 0 {
|
||
m.OrderServiceId = 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
|
||
}
|