package model

import (
	"database/sql"
	"gorm.io/gorm"
	"time"
)

type MarketplaceCollection struct {
	ID                      int       `json:"id" csv:"id"`
	OrderID                 string    `json:"order_id,omitempty" csv:"order_id"`
	MkID                    string    `json:"mk_id,omitempty" csv:"mk_id"`
	RelatedID               string    `json:"related_id,omitempty" csv:"related_id"`
	RevrecMonth             string    `json:"revrec_month,omitempty" csv:"revrec_month"`
	OrgID                   string    `json:"org_id,omitempty" csv:"org_id"`
	AccountName             string    `json:"account_name,omitempty" csv:"account_name"`
	AccountID               string    `json:"account_id,omitempty" csv:"account_id"`
	SalesforceOrderNumber   string    `json:"salesforce_order_number,omitempty" csv:"salesforce_order_number"`
	CollectionMonth         string    `json:"collection_month,omitempty" csv:"collection_month"`
	CollectionStatus        string    `json:"collection_status,omitempty" csv:"collection_status"`
	CollectionType          string    `json:"collection_type,omitempty" csv:"collection_type"`
	CollectedAfterListing   string    `json:"collected_after_listing,omitempty" csv:"collected_after_listing"`
	ListingFee              string    `json:"listing_fee,omitempty" csv:"listing_fee"`
	PayableAmount           string    `json:"payable_amount,omitempty" csv:"payable_amount"`
	RefundedAmount          string    `json:"refunded_amount,omitempty" csv:"refunded_amount"`
	ContractEntity          string    `json:"contract_entity,omitempty" csv:"contract_entity"`
	ReasonOfRefund          string    `json:"reason_of_refund,omitempty" csv:"reason_of_refund"`
	WhichMarketplace        string    `json:"which_marketplace,omitempty" csv:"which_marketplace"`
	LastModifiedDate        time.Time `json:"last_modified_date,omitempty" csv:"last_modified_date"`
	MonthlyDedAmt           string    `json:"monthly_ded_amt,omitempty" csv:"monthly_ded_amt"`
	PayableDate             string    `json:"payable_date,omitempty" csv:"payable_date"`
	CollectionID            string    `json:"collection_id,omitempty" csv:"collection_id"`
	CollectionsDate         string    `json:"collections_date,omitempty" csv:"collections_date"`
	CreatedCollectionID     string    `json:"created_collection_id,omitempty" csv:"created_collection_id"`
	CreatedCollectionNumber string    `json:"created_collection_number,omitempty" csv:"created_collection_number"`
	Sync                    int       `json:"sync,omitempty" csv:"sync"`

	// not in db
	Schange bool `json:"schange"`
	Dchange bool `json:"dchange"`
}

func (MarketplaceCollection) TableName() string {
	return "marketplace_collection"
}

type MarketplaceCollectionStatus struct {
	ID               int            `json:"id"`
	CreatedAt        time.Time      `json:"created_at"`
	UpdatedAt        sql.NullTime   `json:"updated_at"`
	DeletedAt        gorm.DeletedAt `json:"deleted_at"`
	RelatedMkID      string         `json:"related_mk_id"`
	CollectionID     string         `json:"collection_id"`
	CollectionNumber string         `json:"collection_number"`
	Sync             int            `json:"sync"`
	SyncTime         time.Time      `json:"sync_time"`
}

func (MarketplaceCollectionStatus) TableName() string {
	return "marketplace_collection_status"
}

type MarketplaceCollectionBak struct {
	ID                    int       `json:"id"`
	OrderID               string    `json:"order_id,omitempty"`
	MkID                  string    `json:"mk_id,omitempty"`
	RelatedID             string    `json:"related_id,omitempty"`
	RevrecMonth           string    `json:"revrec_month,omitempty"`
	OrgID                 string    `json:"org_id,omitempty"`
	AccountName           string    `json:"account_name,omitempty"`
	AccountID             string    `json:"account_id,omitempty"`
	SalesforceOrderNumber string    `json:"salesforce_order_number,omitempty"`
	CollectionMonth       string    `json:"collection_month,omitempty"`
	CollectionStatus      string    `json:"collection_status,omitempty"`
	CollectionType        string    `json:"collection_type,omitempty"`
	CollectedAfterListing string    `json:"collected_after_listing,omitempty"`
	ListingFee            string    `json:"listing_fee,omitempty"`
	PayableAmount         string    `json:"payable_amount,omitempty"`
	RefundedAmount        string    `json:"refunded_amount,omitempty"`
	ContractEntity        string    `json:"contract_entity,omitempty"`
	ReasonOfRefund        string    `json:"reason_of_refund,omitempty"`
	WhichMarketplace      string    `json:"which_marketplace,omitempty"`
	LastModifiedDate      time.Time `json:"last_modified_date,omitempty"`
	MonthlyDedAmt         string    `json:"monthly_ded_amt,omitempty"`
	PayableDate           string    `json:"payable_date,omitempty"`
	CollectionID          string    `json:"collection_id,omitempty"`
	Sync                  int       `json:"sync,omitempty"`
}

func (MarketplaceCollectionBak) TableName() string {
	return "marketplace_collection_bak"
}
