package fms import ( "hongze/fms_api/global" "hongze/fms_api/models/base" "hongze/fms_api/utils" "time" ) // ContractInvoice 合同开票表 type ContractPrePayment struct { PrePayId int `gorm:"primaryKey;column:pre_pay_id" json:"pre_pay_id" description:"预付款ID"` CompanyName string `json:"company_name" description:"客户名称"` ContractRegisterId int `gorm:"column:contract_register_id" json:"contract_register_id" description:"登记ID"` ContractCode string `gorm:"column:contract_code" json:"contract_code" description:"合同编号"` Amount float64 `gorm:"column:amount" json:"amount" description:"换算后的金额(人民币)"` OriginAmount float64 `gorm:"column:origin_amount" json:"origin_amount" description:"到款金额"` CurrencyUnit string `gorm:"column:currency_unit" json:"currency_unit" description:"货币国际代码"` SellerId int `gorm:"column:seller_id" json:"seller_id" description:"销售ID"` SellerName string `gorm:"column:seller_name" json:"seller_name" description:"销售名称"` AdminId int `gorm:"column:admin_id" json:"admin_id" description:"操作人ID"` AdminName string `gorm:"column:admin_name" json:"admin_name" description:"操作人姓名"` Remark string `gorm:"column:remark" json:"remark" description:"备注信息"` StartDate time.Time `gorm:"column:start_date" json:"start_date" description:"约定开始时间"` EndDate time.Time `gorm:"column:end_date" json:"end_date" description:"约定结束时间"` NewCompany int `gorm:"column:new_company" json:"new_company" description:"是否为新客户: 0-否; 1-是"` PaymentDate time.Time `gorm:"column:payment_date" json:"payment_date" description:"约定结束时间"` base.TimeBase } type ContractPrePaymentRespItem struct { PrePayId int `gorm:"primaryKey;column:pre_pay_id" json:"pre_pay_id" description:"预付款ID"` CompanyName string `json:"company_name" description:"客户名称"` ContractRegisterId int `gorm:"column:contract_register_id" json:"contract_register_id" description:"登记ID"` ContractCode string `gorm:"column:contract_code" json:"contract_code" description:"合同编号"` Amount float64 `gorm:"column:amount" json:"amount" description:"换算后的金额(人民币)"` OriginAmount float64 `gorm:"column:origin_amount" json:"origin_amount" description:"到款金额"` CurrencyUnit string `gorm:"column:currency_unit" json:"currency_unit" description:"货币国际代码"` UnitName string `gorm:"unit_name" json:"unit_name" description:"单位名称"` SellerId int `gorm:"column:seller_id" json:"seller_id" description:"销售ID"` SellerName string `gorm:"column:seller_name" json:"seller_name" description:"销售名称"` AdminId int `gorm:"column:admin_id" json:"admin_id" description:"操作人ID"` AdminName string `gorm:"column:admin_name" json:"admin_name" description:"操作人姓名"` Remark string `gorm:"column:remark" json:"remark" description:"备注信息"` StartDate string `gorm:"column:start_date" json:"start_date" description:"约定开始时间"` EndDate string `gorm:"column:end_date" json:"end_date" description:"约定结束时间"` PaymentDate string `gorm:"column:payment_date" json:"payment_date" description:"约定结束时间"` NewCompany int `gorm:"column:new_company" json:"new_company" description:"是否为新客户: 0-否; 1-是"` CreateTime string `gorm:"autoCreateTime;column:create_time" json:"create_time" description:"创建时间"` ModifyTime string `gorm:"autoUpdateTime:milli;column:modify_time" json:"modify_time" description:"最后更新时间"` } func (c *ContractPrePayment) TableName() string { return "contract_pre_payment" } // ContractRegisterListReq 合同登记列表请求体 type PrePayListReq struct { Keyword string `json:"keyword" form:"keyword" binding:"omitempty" description:"关键词"` StartDate string `json:"start_date" form:"start_date" binding:"omitempty,datetime=2006-01-02" description:"约定开始时间"` EndDate string `json:"end_date" form:"end_date" binding:"omitempty,datetime=2006-01-02" description:"约定结束时间"` SortType int `json:"sort_type" form:"sort_type" description:"排序方式: 1-正序; 2-倒序"` base.PageReq } // GetPrePayItemPageList 获取预登记列表-分页 func GetPrePayItemPageList(page base.IPage, condition string, pars []interface{}) (count int64, results []*ContractPrePaymentRespItem, err error) { list := make([]*ContractPrePayment, 0) query := global.DEFAULT_MYSQL.Table("contract_pre_payment"). Where(condition, pars...) query.Count(&count) if len(page.GetOrderItemsString()) > 0 { query = query.Order(page.GetOrderItemsString()) } err = query.Limit(int(page.GetPageSize())).Offset(int(page.Offset())).Find(&list).Error if err != nil { return } for i := range list { results = append(results, formatPrePay2Item(list[i])) } return } // formatPrePay2Item 格式化PrePay func formatPrePay2Item(item *ContractPrePayment) (formatItem *ContractPrePaymentRespItem) { formatItem = new(ContractPrePaymentRespItem) formatItem.PrePayId = item.PrePayId formatItem.ContractRegisterId = item.ContractRegisterId formatItem.ContractCode = item.ContractCode formatItem.CompanyName = item.CompanyName formatItem.SellerId = item.SellerId formatItem.SellerName = item.SellerName formatItem.Amount = item.Amount formatItem.OriginAmount = item.OriginAmount formatItem.CurrencyUnit = item.CurrencyUnit formatItem.StartDate = utils.TimeTransferString(utils.FormatDate, item.StartDate) formatItem.EndDate = utils.TimeTransferString(utils.FormatDate, item.EndDate) formatItem.AdminId = item.AdminId formatItem.AdminName = item.AdminName formatItem.Remark = item.Remark formatItem.NewCompany = item.NewCompany formatItem.PaymentDate = utils.TimeTransferString(utils.FormatDate, item.PaymentDate) formatItem.CreateTime = utils.TimeTransferString(utils.FormatDateTime, item.CreateTime) formatItem.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, item.ModifyTime) return } // PrepayAddReq 新增到款预登记请求体 type PreRegisterAddReq struct { CompanyName string `json:"company_name" binding:"required" description:"客户名称"` StartDate string `json:"start_date" description:"约定开始日期"` EndDate string `json:"end_date" description:"约定结束日期"` RegisterType int `json:"register_type" description:"预登记类型 3-开票预登记 4-到款预登记"` ProductIds string `gorm:"column:product_ids" json:"product_ids" description:"产品ID:1-FICC; 2-权益, 如果两者都有,则用英文逗号拼接"` SellerIds string `json:"seller_ids" description:"CRM系统-销售ID"` ContractType int `json:"contract_type" binding:"oneof=1 2 3 4" description:"合同类型: 1-新签; 2-续约; 3-代付; 4-补充协议"` HasPayment int `json:"has_payment" description:"是否有代付: 0-无; 1-有"` List []PreRegisterAddReqItem `json:"list" binding:"required" description:"预登记列表"` Services []ContractServiceAddReq `json:"services" description:"服务套餐内容"` } type PreRegisterAddReqItem struct { Amount float64 `json:"amount" binding:"required" description:"到款金额"` CurrencyUnit string `json:"currency_unit" binding:"required" description:"货币单位"` Remark string `json:"remark" description:"备注信息"` RegisterDate string `json:"register_date" description:"到款或开票日期"` SellerId int `gorm:"column:seller_id" json:"seller_id" description:"销售ID"` SellerName string `gorm:"column:seller_name" json:"seller_name" description:"销售名称"` ServiceProductId int `gorm:"column:service_product_id" json:"service_product_id" description:"套餐类型:1ficc套餐,2权益套餐"` } func (c *ContractPrePayment) Create() (err error) { err = global.DEFAULT_MYSQL.Create(c).Error return } func (c *ContractPrePayment) Fetch(id int) (item *ContractPrePayment, err error) { err = global.DEFAULT_MYSQL.Model(c).Where(" pre_pay_id = ?", id).First(&item).Error return } func (c *ContractPrePayment) Update(updateCols []string) (err error) { err = global.DEFAULT_MYSQL.Model(c).Select(updateCols).Updates(c).Error return } // 删除 func (c *ContractPrePayment) Delete() (err error) { err = global.DEFAULT_MYSQL.Delete(c).Error return } // PrepayEditReq 编辑到款预登记请求体 type PreRegisterEditReq struct { PreRegisterId int `json:"pre_register_id" description:"预登记ID"` ContractRegisterId int `json:"contract_register_id" binding:"required,gte=1" description:"登记ID"` CompanyName string `json:"company_name" binding:"required" description:"客户名称"` StartDate string `json:"start_date" description:"约定开始日期"` EndDate string `json:"end_date" description:"约定结束日期"` RegisterType int `json:"register_type" description:"预登记类型 3-开票预登记 4-到款预登记"` ProductIds string `gorm:"column:product_ids" json:"product_ids" description:"产品ID:1-FICC; 2-权益, 如果两者都有,则用英文逗号拼接"` SellerIds string `json:"seller_ids" description:"CRM系统-销售ID"` DelInvoiceIds []int `json:"del_invoice_ids" description:"删除的开票到款记录ids"` DelPreRegisterIds []int `json:"del_pre_register_ids" description:"删除的预登记记录ids"` ContractType int `json:"contract_type" binding:"oneof=1 2 3 4" description:"合同类型: 1-新签; 2-续约; 3-代付; 4-补充协议"` HasPayment int `json:"has_payment" description:"是否有代付: 0-无; 1-有"` List []*PreRegisterEditReqItem Services []ContractServiceAddReq `json:"services" description:"服务套餐内容"` } type PreRegisterEditReqItem struct { PreRegisterId int `json:"pre_register_id" description:"预登记ID"` InvoiceId int `json:"contract_invoice_id" description:"开票ID"` ArriveId int `json:"arrive_id" description:"到款ID"` Amount float64 `json:"amount" binding:"required" description:"到款金额"` CurrencyUnit string `json:"currency_unit" binding:"required" description:"货币单位"` Remark string `json:"remark" description:"备注信息"` RegisterDate string `json:"register_date" description:"到款或开票日期"` SellerId int `gorm:"column:seller_id" json:"seller_id" description:"销售ID"` SellerName string `gorm:"column:seller_name" json:"seller_name" description:"销售名称"` ServiceProductId int `gorm:"column:service_product_id" json:"service_product_id" description:"套餐类型:1ficc套餐,2权益套餐"` } // PreRegisterDelReq 预登记删除请求体 type PreRegisterDelReq struct { ContractRegisterId int `json:"contract_register_id" binding:"required,gte=1" description:"登记ID"` InvoiceId int `json:"invoice_id" description:"开票ID"` ArriveId int `json:"arrive_id" description:"到款ID"` PreRegisterId int `json:"pre_register_id" description:"预登记ID"` } type PreRegisterSaveReqItem struct { PreRegisterId int `json:"pre_register_id" description:"预登记ID"` InvoiceId int `json:"contract_invoice_id" description:"开票ID"` Amount float64 `json:"amount" binding:"required" description:"到款金额"` CurrencyUnit string `json:"currency_unit" binding:"required" description:"货币单位"` Remark string `json:"remark" description:"备注信息"` RegisterDate string `json:"register_date" description:"到款或开票日期"` SellerId int `gorm:"column:seller_id" json:"seller_id" description:"销售ID"` SellerName string `gorm:"column:seller_name" json:"seller_name" description:"销售名称"` ServiceProductId int `gorm:"column:service_product_id" json:"service_product_id" description:"套餐类型:1ficc套餐,2权益套餐"` } // PreRegisterSaveReq 预登记保存请求体 type PreRegisterSaveReq struct { PreRegisterId int `json:"pre_register_id" description:"预登记ID"` ContractRegisterId int `json:"contract_register_id" binding:"required,gte=1" description:"登记ID"` CompanyName string `json:"company_name" description:"客户名称"` StartDate string `json:"start_date" binding:"required" description:"约定开始日期"` EndDate string `json:"end_date" binding:"required" description:"约定结束日期"` RegisterType int `json:"register_type" description:"预登记类型 3-开票预登记 4-到款预登记"` ProductIds string `gorm:"column:product_ids" json:"product_ids" description:"产品ID:1-FICC; 2-权益, 如果两者都有,则用英文逗号拼接"` SellerIds string `json:"seller_ids" description:"CRM系统-销售ID"` ContractType int `json:"contract_type" binding:"oneof=1 2 3 4" description:"合同类型: 1-新签; 2-续约; 3-代付; 4-补充协议"` HasPayment int `json:"has_payment" description:"是否有代付: 0-无; 1-有"` List []PreRegisterSaveReqItem `json:"list" binding:"required" description:"预登记列表"` Services []ContractServiceAddReq `json:"services" description:"服务套餐内容"` }