|
@@ -16,7 +16,7 @@ type ContractInvoice struct {
|
|
|
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-到款登记;3-开票预登记;4-到款预登记"`
|
|
|
+ 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:"销售名称"`
|
|
@@ -62,6 +62,7 @@ type ContractInvoiceItem struct {
|
|
|
StartDate string `gorm:"column:start_date" json:"start_date" description:"约定开始时间"`
|
|
|
EndDate string `gorm:"column:end_date" json:"end_date" description:"约定结束时间"`
|
|
|
CreateTime string `gorm:"column:create_time" json:"create_time" description:"创建时间"`
|
|
|
+ CompanyName string `gorm:"column:company_name" json:"company_name" description:"客户名称"`
|
|
|
}
|
|
|
|
|
|
func (c *ContractInvoice) Create() (err error) {
|
|
@@ -221,7 +222,7 @@ func formatContractInvoice2ItemList(list []*ContractInvoice) (itemList []*Contra
|
|
|
type ContractInvoiceListReq struct {
|
|
|
InvoiceType int `json:"invoice_type" form:"invoice_type" binding:"oneof=1 2" description:"类型: 1-开票登记; 2-到款登记"`
|
|
|
SellerIds string `json:"seller_ids" form:"seller_ids" description:"销售ID, 多个id用逗号拼接"`
|
|
|
- ContractCode string `json:"contract_code" form:"contract_code" binding:"omitempty" description:"合同编号"`
|
|
|
+ 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:"结束日期"`
|
|
|
MinAmount float64 `json:"min_amount" form:"min_amount" description:"开票金额区间-最小值"`
|
|
@@ -233,9 +234,11 @@ type ContractInvoiceListReq struct {
|
|
|
|
|
|
// GetContractInvoiceItemPageList 获取合同开票/到款列表-分页
|
|
|
func GetContractInvoiceItemPageList(page base.IPage, condition string, pars []interface{}) (count int64, results []*ContractInvoiceItem, err error) {
|
|
|
- list := make([]*ContractInvoice, 0)
|
|
|
- query := global.DEFAULT_MYSQL.Table("contract_invoice").
|
|
|
- Where("is_deleted = 0").
|
|
|
+ list := make([]*ContractInvoiceRespItem, 0)
|
|
|
+ query := global.DEFAULT_MYSQL.Table("contract_invoice AS a").
|
|
|
+ Select("a.*, b.company_name").
|
|
|
+ Joins("JOIN contract_register b ON a.contract_register_id = b.contract_register_id").
|
|
|
+ Where("a.is_deleted = 0").
|
|
|
Where(condition, pars...)
|
|
|
query.Count(&count)
|
|
|
if len(page.GetOrderItemsString()) > 0 {
|
|
@@ -252,7 +255,7 @@ func GetContractInvoiceItemPageList(page base.IPage, condition string, pars []in
|
|
|
}
|
|
|
|
|
|
// formatContractInvoice2Item 格式化ContractInvoiceItem
|
|
|
-func formatContractInvoice2Item(item *ContractInvoice) (formatItem *ContractInvoiceItem) {
|
|
|
+func formatContractInvoice2Item(item *ContractInvoiceRespItem) (formatItem *ContractInvoiceItem) {
|
|
|
formatItem = new(ContractInvoiceItem)
|
|
|
formatItem.ContractInvoiceId = item.ContractInvoiceId
|
|
|
formatItem.ContractRegisterId = item.ContractRegisterId
|
|
@@ -269,6 +272,7 @@ func formatContractInvoice2Item(item *ContractInvoice) (formatItem *ContractInvo
|
|
|
formatItem.IsPrePay = item.IsPrePay
|
|
|
formatItem.ServiceProductId = item.ServiceProductId
|
|
|
formatItem.CreateTime = utils.TimeTransferString(utils.FormatDateTime, item.CreateTime)
|
|
|
+ formatItem.CompanyName = item.CompanyName
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -501,9 +505,9 @@ type InvoiceListCurrencySum struct {
|
|
|
|
|
|
// GetInvoiceListCurrencySum 获取开票/到款分货币合计
|
|
|
func GetInvoiceListCurrencySum(condition string, pars []interface{}, groupRule string) (results []*InvoiceListCurrencySum, err error) {
|
|
|
- query := global.DEFAULT_MYSQL.Table("contract_invoice").
|
|
|
- Select("currency_unit, invoice_type, SUM(amount) AS amount_total, SUM(origin_amount) AS origin_amount_total").
|
|
|
- Where("is_deleted = 0").
|
|
|
+ query := global.DEFAULT_MYSQL.Table("contract_invoice AS a").
|
|
|
+ Select("a.currency_unit, a.invoice_type, SUM(a.amount) AS amount_total, SUM(a.origin_amount) AS origin_amount_total, b.company_name").
|
|
|
+ Joins("JOIN contract_register b ON a.contract_register_id = b.contract_register_id").
|
|
|
Where(condition, pars...).
|
|
|
Group(groupRule)
|
|
|
err = query.Find(&results).Error
|
|
@@ -580,3 +584,8 @@ func formatContractInvoice2DetailItemList(list []*ContractInvoice) (itemList []*
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+type ContractInvoiceRespItem struct {
|
|
|
+ ContractInvoice
|
|
|
+ CompanyName string `gorm:"column:company_name" json:"company_name" description:"客户名称"`
|
|
|
+}
|