package model

import (
	"encoding/json"
	"gorm.io/gorm"
)

// BundleOrderRecords struct
type BundleOrderRecords struct {
	gorm.Model
	UUID                  string                `json:"uuid" gorm:"column:uuid;type:varchar(1024);comment:UUID"`
	OrderNo               string                `json:"orderNo" gorm:"column:order_no;type:varchar(1024);comment:交易编号"`
	BundleUUID            string                `json:"bundleUUID" gorm:"column:bundle_uuid;type:varchar(1024);comment:套餐UUID"`
	BundleName            string                `json:"bundleName" gorm:"column:bundle_name;type:varchar(2048);comment:套餐名"`
	CustomerID            string                `json:"customerID" gorm:"column:customer_id;type:varchar(1024);comment:客户ID"`
	CustomerNum           string                `json:"customerNum" gorm:"column:customer_num;type:varchar(1024);comment:客户编号"`
	CustomerName          string                `json:"customerName" gorm:"column:customer_name;type:varchar(1024);comment:客户名"`
	Amount                float32               `json:"amount" gorm:"column:amount;type:decimal(12,2);comment:套餐金额"`
	AmountType            int64                 `json:"amountType" gorm:"column:amount_type;type:int;comment:金额类型"`
	ValueAddBundleUUID    string                `json:"valueAddBundleUUID" gorm:"column:value_add_bundle_uuid;type:varchar(1024);comment:增值套餐记录UUID"`
	ValueAddBundleAmount  float32               `json:"valueAddBundleAmount" gorm:"column:value_add_bundle_amount;type:decimal(12,2);comment:增值套餐金额"`
	ValueAddOriginalPrice float32               `json:"valueAddOriginalPrice" gorm:"column:value_add_original_price;type:decimal(12,2);comment:原单价"`
	ValueAddDiscountPrice float32               `json:"valueAddDiscountPrice" gorm:"column:value_add_discount_price;type:decimal(12,2);comment:优惠单价"`
	ValueAddSavedAmount   float32               `json:"valueAddSavedAmount" gorm:"column:value_add_saved_amount;type:decimal(12,2);comment:节省金额"`
	TotalAmount           float32               `json:"totalAmount" gorm:"column:total_amount;type:decimal(12,2);comment:总金额"`
	Num                   int32                 `json:"num" gorm:"column:num;type:int;comment:视频数量"`
	SignContract          string                `json:"signContract" gorm:"column:sign_contract;type:varchar(1024);comment:签约合同"`
	Signature             string                `json:"signature" gorm:"column:signature;type:text;comment:签字"`
	SignedTime            string                `json:"signedTime" gorm:"column:signed_time;type:varchar(1024);comment:签约时间(北京时间)"`
	PayType               int64                 `json:"payType" gorm:"column:pay_type;type:int;comment:支付类型"`
	PayTime               string                `json:"payTime" gorm:"column:pay_time;type:varchar(1024);comment:支付时间(北京时间)"`
	CheckoutSessionId     string                `json:"checkoutSessionId" gorm:"column:checkout_session_id;type:varchar(1024);default:null;comment:checkoutSessionId"`
	CheckoutSessionUrl    string                `json:"checkoutSessionUrl" gorm:"column:checkout_session_url;type:varchar(1024);default:null;comment:checkoutSessionUrl"`
	Status                int64                 `json:"status" gorm:"column:status;type:int;comment:状态 1:已签未支付 2:已签已支付"`
	ContractNo            string                `json:"contractNo" gorm:"column:contract_no;type:varchar(1024);comment:合同编号"`
	BundleCommonUid       string                `json:"bundleCommonUid" gorm:"column:bundle_common_uid;type:text;comment:套餐公共ID"`
	AddBundleCommonUid    string                `json:"addBundleCommonUid" gorm:"column:add_bundle_common_uid;type:text;comment:附加套餐公共ID"`
	FinancialConfirmation int32                 `json:"financialConfirmation" gorm:"column:financial_confirmation;type:int;comment:财务确认 1:未确认 2:已确认"`
	ExpirationTime        string                `json:"expirationTime" gorm:"column:expiration_time;comment:套餐过期时间"`
	BundleCommonJson      json.RawMessage       `json:"bundle_common_json" gorm:"column:bundle_common_json;type:json;serializer:json;comment:套餐信息"`
	Language              string                `gorm:"column:language;comment:语言" json:"language"`
	BundleOrderValueAdd   []BundleOrderValueAdd `gorm:"foreignKey:OrderUUID;references:UUID" json:"bundleOrderValueAdd"`
}
type BundleOrderValueAdd struct {
	gorm.Model
	UUID               string  `json:"uuid" gorm:"column:uuid;type:varchar(1024);comment:UUID"`
	OrderNo            string  `json:"orderNo" gorm:"column:order_no;type:varchar(1024);comment:交易编号"`
	OrderUUID          string  `json:"orderUUID" gorm:"column:order_uuid;type:varchar(1024);comment:套餐UUID"`
	CustomerID         string  `json:"customerID" gorm:"column:customer_id;type:varchar(1024);comment:客户ID"`
	CustomerNum        string  `json:"customerNum" gorm:"column:customer_num;type:varchar(1024);comment:客户编号"`
	CustomerName       string  `json:"customerName" gorm:"column:customer_name;type:varchar(1024);comment:客户名"`
	ServiceType        int32   `json:"serviceType" gorm:"column:service_type;type:int;comment:服务类型 1:视频 2:图文 3:数据报表 4:账号数 5:可用时长"`
	CurrencyType       int64   `json:"currencyType" gorm:"column:currency_type;type:int;comment:货币类型"`
	Amount             float64 `json:"amount" gorm:"column:amount;type:decimal(12,2);comment:金额"`
	Num                int32   `json:"num" gorm:"column:num;type:int;comment:数量"`
	Unit               string  `json:"unit" gorm:"column:unit;type:varchar(1024);comment:单位 1个 2条 3天 4月 5年"`
	ValueAddUUID       string  `json:"valueAddUUID" gorm:"column:value_add_uuid;type:varchar(1024);comment:增值服务UUID"`
	Source             int     `json:"source" gorm:"column:source;comment:增加方式 1套餐 2单独购买 3拓展"`
	Remark             string  `json:"remark" gorm:"column:remark;comment:备注"`
	PaymentStatus      int     `json:"paymentStatus" gorm:"column:payment_status;comment:支付状态 1未支付 2已支付"`
	PaymentTime        string  `gorm:"column:payment_time;comment:支付时间" json:"paymentTime"`
	SignContract       string  `json:"signContract" gorm:"column:sign_contract;type:varchar(1024);comment:签约合同"`
	Signature          string  `json:"signature" gorm:"column:signature;type:text;comment:签字"`
	SignedTime         string  `json:"signedTime" gorm:"column:signed_time;type:varchar(1024);comment:签约时间(北京时间)"`
	Snapshot           string  `gorm:"column:snapshot;comment:快照" json:"snapshot"` //订单快照
	CheckoutSessionId  string  `json:"checkoutSessionId" gorm:"column:checkout_session_id;type:varchar(1024);default:null;comment:checkoutSessionId"`
	CheckoutSessionUrl string  `json:"checkoutSessionUrl" gorm:"column:checkout_session_url;type:varchar(1024);default:null;comment:checkoutSessionUrl"`
}

// 财务确认状态
const (
	ConfirmationNotConfirmed = 1
	ConfirmationConfirmed    = 2
)