|
@@ -0,0 +1,149 @@
|
|
|
+package fms
|
|
|
+
|
|
|
+import (
|
|
|
+ "hongze/fms_api/models/base"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+// ContractInvoice 合同开票表
|
|
|
+type ContractPrePayment struct {
|
|
|
+ ContractInvoiceId int `gorm:"primaryKey;column:contract_invoice_id" json:"contract_invoice_id" description:"开票ID"`
|
|
|
+ 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:"货币国际代码"`
|
|
|
+ InvoiceType int `gorm:"column:invoice_type" json:"invoice_type" description:"类型: 1-开票登记; 2-到款登记"`
|
|
|
+ InvoiceDate time.Time `gorm:"column:invoice_time" json:"invoice_time" description:"开票日期/到款月"`
|
|
|
+ SellerId int `gorm:"column:seller_id" json:"seller_id" description:"销售ID"`
|
|
|
+ SellerName string `gorm:"column:seller_name" json:"seller_name" description:"销售名称"`
|
|
|
+ SellerGroupId int `gorm:"column:seller_group_id" json:"seller_group_id" description:"销售分组ID"`
|
|
|
+ SellerGroupName string `gorm:"column:seller_group_name" json:"seller_group_name" description:"销售分组名称"`
|
|
|
+ SellerTeamId int `gorm:"column:seller_team_id" json:"seller_team_id" description:"销售小组ID"`
|
|
|
+ SellerTeamName string `gorm:"column:seller_team_name" json:"seller_team_name" description:"销售小组名称"`
|
|
|
+ PayType int `gorm:"column:pay_type" json:"pay_type" description:"付款方式:0-无;1-年付;2-半年付;3-季付;4-次付;5-异常"`
|
|
|
+ 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:"备注信息"`
|
|
|
+ IsDeleted int `gorm:"column:is_deleted" json:"is_deleted" description:"是否已删除: 0-正常; 1-已删除"`
|
|
|
+ base.TimeBase
|
|
|
+}
|
|
|
+
|
|
|
+func (c *ContractPrePayment) TableName() string {
|
|
|
+ return "contract_pre_payment"
|
|
|
+}
|
|
|
+
|
|
|
+//// ContractInvoiceItem 合同开票/到款
|
|
|
+//type ContractInvoiceItem struct {
|
|
|
+// ContractInvoiceId int `gorm:"column:contract_invoice_id" json:"contract_invoice_id" description:"开票ID"`
|
|
|
+// 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 `json:"unit_name" description:"货币单位名称"`
|
|
|
+// InvoiceType int `gorm:"column:invoice_type" json:"invoice_type" description:"类型: 1-开票登记; 2-到款登记"`
|
|
|
+// InvoiceDate string `gorm:"column:invoice_time" json:"invoice_time" description:"开票日期/到款月"`
|
|
|
+// SellerId int `gorm:"column:seller_id" json:"seller_id" description:"销售ID"`
|
|
|
+// SellerName string `gorm:"column:seller_name" json:"seller_name" description:"销售名称"`
|
|
|
+// PayType int `gorm:"column:pay_type" json:"pay_type" description:"付款方式:0-无;1-年付;2-半年付;3-季付;4-次付;5-异常"`
|
|
|
+// Remark string `gorm:"column:remark" json:"remark" description:"备注信息"`
|
|
|
+// CreateTime string `gorm:"column:create_time" json:"create_time" description:"创建时间"`
|
|
|
+//}
|
|
|
+//
|
|
|
+//func (c *ContractInvoice) Create() (err error) {
|
|
|
+// err = global.DEFAULT_MYSQL.Create(c).Error
|
|
|
+// return
|
|
|
+//}
|
|
|
+//
|
|
|
+//func (c *ContractInvoice) AddInBatches(list []*ContractInvoice) (err error) {
|
|
|
+// err = global.DEFAULT_MYSQL.CreateInBatches(list, len(list)).Error
|
|
|
+// return
|
|
|
+//}
|
|
|
+//
|
|
|
+//func (c *ContractInvoice) Update(updateCols []string) (err error) {
|
|
|
+// err = global.DEFAULT_MYSQL.Model(c).Select(updateCols).Updates(c).Error
|
|
|
+// return
|
|
|
+//}
|
|
|
+//
|
|
|
+//func (c *ContractInvoice) Fetch(id int) (item *ContractInvoice, err error) {
|
|
|
+// err = global.DEFAULT_MYSQL.Model(c).Where("is_deleted = 0 AND contract_invoice_id = ?", id).First(&item).Error
|
|
|
+// return
|
|
|
+//}
|
|
|
+//
|
|
|
+//func (c *ContractInvoice) Sum(field, condition string, pars []interface{}) (total float64, err error) {
|
|
|
+// totalList := make([]float64, 0)
|
|
|
+// err = global.DEFAULT_MYSQL.Model(c).
|
|
|
+// Where("is_deleted = 0").
|
|
|
+// Where(condition, pars...).
|
|
|
+// Pluck(field, &totalList).Error
|
|
|
+// for i := range totalList {
|
|
|
+// total += totalList[i]
|
|
|
+// }
|
|
|
+// return
|
|
|
+//}
|
|
|
+//
|
|
|
+//func (c *ContractInvoice) List(condition string, pars []interface{}, orderRule string) (list []*ContractInvoice, err error) {
|
|
|
+// list = make([]*ContractInvoice, 0)
|
|
|
+// query := global.DEFAULT_MYSQL.Model(c).
|
|
|
+// Where("is_deleted = 0").
|
|
|
+// Where(condition, pars...)
|
|
|
+// if orderRule != "" {
|
|
|
+// query.Order(orderRule)
|
|
|
+// } else {
|
|
|
+// query.Order("contract_invoice_id ASC")
|
|
|
+// }
|
|
|
+// err = query.Find(&list).Error
|
|
|
+// return
|
|
|
+//}
|
|
|
+//
|
|
|
+//func (c *ContractInvoice) PageList(page base.IPage, condition string, pars []interface{}) (count int64, results []*ContractInvoice, err error) {
|
|
|
+// results = make([]*ContractInvoice, 0)
|
|
|
+// query := global.DEFAULT_MYSQL.Model(c).
|
|
|
+// Where("is_deleted = 0").
|
|
|
+// 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(&results).Error
|
|
|
+// return
|
|
|
+//}
|
|
|
+//
|
|
|
+//// DeleteAndCreateNewInvoice 删除并新增登记
|
|
|
+//func (c *ContractInvoice) DeleteAndCreateNewInvoice(contractRegisterId, invoiceType int, deleteInvoiceIds []int, invoices []*ContractInvoice) (err error) {
|
|
|
+// tx := global.DEFAULT_MYSQL.Begin()
|
|
|
+// defer func() {
|
|
|
+// if err != nil {
|
|
|
+// tx.Rollback()
|
|
|
+// } else {
|
|
|
+// tx.Commit()
|
|
|
+// }
|
|
|
+// }()
|
|
|
+//
|
|
|
+// if len(deleteInvoiceIds) > 0 {
|
|
|
+// err = tx.Model(c).
|
|
|
+// Where("contract_register_id = ? AND invoice_type = ? AND contract_invoice_id IN (?)", contractRegisterId, invoiceType, deleteInvoiceIds).
|
|
|
+// UpdateColumn("is_deleted", 1).Error
|
|
|
+// if err != nil {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if len(invoices) > 0 {
|
|
|
+// err = tx.CreateInBatches(invoices, len(invoices)).Error
|
|
|
+// if err != nil {
|
|
|
+// return
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return
|
|
|
+//}
|
|
|
+
|
|
|
+
|
|
|
+// 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:"合同结束日期"`
|
|
|
+ base.PageReq
|
|
|
+}
|
|
|
+
|