You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
4.0 KiB

package model
import (
"database/sql"
"github.com/shopspring/decimal"
"time"
)
const (
ContractSalePayTypeFullPayment = 1 // 全款
ContractSalePayTypeMortgage = 2 // 按揭
ContractSaleTransferTypeLocal = 1 // 本地
ContractSaleTransferTypeNonLocal = 2 // 外迁
ContractSaleThirdPartKindNone = 1 // 无中间方
ContractSaleThirdPartKindPlatForm = 2 // 平台
ContractSaleThirdPartKindDealer = 3 // 车商
)
type ContractSale struct {
Id uint `gorm:"primaryKey"`
ContractSn string // 合同编号
EssFlow ThirdTencentEssFlow `gorm:"foreignKey:ContractId"`
CarId uint // 车辆id
Car Car `gorm:"foreignKey:CarId"`
ModelId uint // 车型id
Model CarModel `gorm:"foreignKey:ModelId;references:ModelId"`
BrokerId uint // 经纪人id
Broker Broker `gorm:"foreignKey:BrokerId"`
CustomerChannel uint // 1=小程序 2=线下
CustomerId uint // 客户id
Customer Customer `gorm:"foreignKey:CustomerId"`
ThirdPartKind uint // 中间方类型 1=无 2=自平台 3=车商
ThirdPartId uint // 第三方车商id
ThirdPart BrokerBusinessStore `gorm:"foreignKey:ThirdPartId"`
Amount decimal.Decimal // 成交价
Deposit decimal.Decimal // 定金
DownPayment decimal.Decimal // 首付
BalancePayment decimal.Decimal // 尾款
DeliverDate sql.NullTime // 交付日期
DeliverAddress string // 交付地点
TransferFee decimal.Decimal // 过户费
TransferFeeHolder uint // 过户费承担方1=甲方2=乙方
AgentFee decimal.Decimal // 代办费
AgentFeeHolder uint // 代办费承担方1=甲方2=乙方
SaleServiceFee decimal.Decimal // 服务费
SaleServiceFeeRate decimal.Decimal // 服务费比例
PurchaseServiceFee decimal.Decimal // 服务费
PurchaseServiceFeeRate decimal.Decimal // 服务费比例
PayType uint // 支付方式
TransferType uint // 过户方式
Remark string // 备注
Source uint // 车辆来源 1=个人直卖 2=车商
SellerCustomerId uint // 来源个人寄卖时车辆持有客户id
SellerCustomer Customer `gorm:"foreignKey:SellerCustomerId"`
SellerDealerId uint // 车辆挂载门店
SellerDealer BrokerBusinessStore `gorm:"foreignKey:SellerDealerId"`
SellerMasterId uint
SellerMaster ContractMaster `gorm:"foreignKey:SellerMasterId"`
BuyerMasterId uint
BuyerMaster ContractMaster `gorm:"foreignKey:BuyerMasterId"`
Status uint // 状态
DealerAuditId uint // 车商审核
DealerAudit DealerAuditing `gorm:"foreignKey:DealerAuditId"`
SignAt sql.NullTime // 签名时间
CancelAt sql.NullTime // 取消时间
CreatedAt time.Time
UpdatedAt time.Time
}
func (*ContractSale) GetPayTypeName(tp uint) (result string) {
switch tp {
case ContractSalePayTypeFullPayment:
return "全款"
case ContractSalePayTypeMortgage:
return "按揭"
default:
return "未知"
}
}
func (*ContractSale) GetTransferTypeName(tp uint) (result string) {
switch tp {
case ContractSaleTransferTypeLocal:
return "本地"
case ContractSaleTransferTypeNonLocal:
return "外迁"
default:
return "未知"
}
}
func (*ContractSale) GetThirdPartKindName(kind uint) (result string) {
switch kind {
case ContractSaleThirdPartKindNone:
return "无中间方"
case ContractSaleThirdPartKindPlatForm:
return "平台"
case ContractSaleThirdPartKindDealer:
return "车商"
default:
return "未知"
}
}
func (*ContractSale) GetHolderName(holder uint) (result string) {
switch holder {
case 1:
return "甲方"
case 2:
return "乙方"
default:
return "未知"
}
}