|
@@ -17,13 +17,11 @@ type InvoicePaymentSummary struct {
|
|
ModifyTime time.Time `gorm:"autoUpdateTime:milli;column:modify_time" json:"modify_time" description:"最后更新时间"`
|
|
ModifyTime time.Time `gorm:"autoUpdateTime:milli;column:modify_time" json:"modify_time" description:"最后更新时间"`
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
type ContractRegisterSummary struct {
|
|
type ContractRegisterSummary struct {
|
|
SummaryId int `json:"summary_id" description:"汇总ID"`
|
|
SummaryId int `json:"summary_id" description:"汇总ID"`
|
|
ContractRegister
|
|
ContractRegister
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
// GetInvoicePaymentCensusPageList 获取商品到款统计列表-总数
|
|
// GetInvoicePaymentCensusPageList 获取商品到款统计列表-总数
|
|
func GetInvoicePaymentCensusPageList(condition string, pars []interface{}, order string, startSize, pageSize int) (results []*ContractRegisterSummary, total int64, err error) {
|
|
func GetInvoicePaymentCensusPageList(condition string, pars []interface{}, order string, startSize, pageSize int) (results []*ContractRegisterSummary, total int64, err error) {
|
|
o := orm.NewOrmUsingDB("fms")
|
|
o := orm.NewOrmUsingDB("fms")
|
|
@@ -35,7 +33,7 @@ func GetInvoicePaymentCensusPageList(condition string, pars []interface{}, order
|
|
if condition != "" {
|
|
if condition != "" {
|
|
sql += condition
|
|
sql += condition
|
|
}
|
|
}
|
|
- totalSQl := `SELECT COUNT(1) total FROM (`+sql+`) as a`
|
|
|
|
|
|
+ totalSQl := `SELECT COUNT(1) total FROM (` + sql + `) as a`
|
|
if err = o.Raw(totalSQl, pars).QueryRow(&total); err != nil {
|
|
if err = o.Raw(totalSQl, pars).QueryRow(&total); err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -81,14 +79,14 @@ func GetInvoicePaymentCensusSummaryData(condition string, pars []interface{}) (r
|
|
"IF(c.seller_group_name = '' OR c.seller_group_name IS NULL, d.seller_group_name, c.seller_group_name) AS seller_group_name", "d.origin_amount AS payment_amount", "d.invoice_time AS payment_date", "d.pay_type",
|
|
"IF(c.seller_group_name = '' OR c.seller_group_name IS NULL, d.seller_group_name, c.seller_group_name) AS seller_group_name", "d.origin_amount AS payment_amount", "d.invoice_time AS payment_date", "d.pay_type",
|
|
}
|
|
}
|
|
o := orm.NewOrmUsingDB("fms")
|
|
o := orm.NewOrmUsingDB("fms")
|
|
- sql := `SELECT `+strings.Join(fields, ",")+ ` FROM invoice_payment_summary AS a
|
|
|
|
|
|
+ sql := `SELECT ` + strings.Join(fields, ",") + ` FROM invoice_payment_summary AS a
|
|
JOIN contract_register AS b ON a.register_id = b.contract_register_id AND b.is_deleted = 0
|
|
JOIN contract_register AS b ON a.register_id = b.contract_register_id AND b.is_deleted = 0
|
|
LEFT JOIN contract_invoice AS c ON a.invoice_id = c.contract_invoice_id AND c.is_deleted = 0
|
|
LEFT JOIN contract_invoice AS c ON a.invoice_id = c.contract_invoice_id AND c.is_deleted = 0
|
|
LEFT JOIN contract_invoice AS d ON a.payment_id = d.contract_invoice_id AND d.is_deleted = 0
|
|
LEFT JOIN contract_invoice AS d ON a.payment_id = d.contract_invoice_id AND d.is_deleted = 0
|
|
WHERE `
|
|
WHERE `
|
|
sql += condition
|
|
sql += condition
|
|
|
|
|
|
- _,err = o.Raw(sql, pars).QueryRows(&results)
|
|
|
|
|
|
+ _, err = o.Raw(sql, pars).QueryRows(&results)
|
|
|
|
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -102,8 +100,7 @@ func GetInvoicePaymentCensusSummaryDataIds(condition string, pars []interface{})
|
|
LEFT JOIN contract_invoice AS d ON a.payment_id = d.contract_invoice_id AND d.is_deleted = 0
|
|
LEFT JOIN contract_invoice AS d ON a.payment_id = d.contract_invoice_id AND d.is_deleted = 0
|
|
WHERE `
|
|
WHERE `
|
|
sql += condition
|
|
sql += condition
|
|
- _,err = o.Raw(sql, pars).QueryRows(&summaryIds)
|
|
|
|
-
|
|
|
|
|
|
+ _, err = o.Raw(sql, pars).QueryRows(&summaryIds)
|
|
|
|
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -115,7 +112,7 @@ func GetContractSummaryInvoicePaymentAmountTotal(condition string, pars []interf
|
|
joinCond = `a.payment_id = b.contract_invoice_id`
|
|
joinCond = `a.payment_id = b.contract_invoice_id`
|
|
}
|
|
}
|
|
o := orm.NewOrmUsingDB("fms")
|
|
o := orm.NewOrmUsingDB("fms")
|
|
- sql := `SELECT IFNULL(SUM(b.amount),0) FROM invoice_payment_summary AS a JOIN contract_invoice AS b ON `+ joinCond+` AND b.is_deleted = 0 WHERE `
|
|
|
|
|
|
+ sql := `SELECT IFNULL(SUM(b.amount),0) FROM invoice_payment_summary AS a JOIN contract_invoice AS b ON ` + joinCond + ` AND b.is_deleted = 0 WHERE `
|
|
sql += condition
|
|
sql += condition
|
|
err = o.Raw(sql, pars).QueryRow(&amountTotal)
|
|
err = o.Raw(sql, pars).QueryRow(&amountTotal)
|
|
|
|
|
|
@@ -131,27 +128,25 @@ func GetSummaryListCurrencySum(condition string, pars []interface{}, amountType
|
|
|
|
|
|
o := orm.NewOrmUsingDB("fms")
|
|
o := orm.NewOrmUsingDB("fms")
|
|
sql := `SELECT b.currency_unit, b.invoice_type, SUM(b.amount) AS amount_total, SUM(b.origin_amount) AS origin_amount_total
|
|
sql := `SELECT b.currency_unit, b.invoice_type, SUM(b.amount) AS amount_total, SUM(b.origin_amount) AS origin_amount_total
|
|
- FROM invoice_payment_summary AS a JOIN contract_invoice AS b ON `+ joinCond+` AND b.is_deleted = 0 WHERE `
|
|
|
|
|
|
+ FROM invoice_payment_summary AS a JOIN contract_invoice AS b ON ` + joinCond + ` AND b.is_deleted = 0 WHERE `
|
|
sql += condition
|
|
sql += condition
|
|
|
|
|
|
sql += ` GROUP BY b.currency_unit `
|
|
sql += ` GROUP BY b.currency_unit `
|
|
- _,err = o.Raw(sql, pars).QueryRows(&results)
|
|
|
|
|
|
+ _, err = o.Raw(sql, pars).QueryRows(&results)
|
|
|
|
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
// GetContractSummaryInvoicePaymentAmount 获取汇总金额合计信息
|
|
// GetContractSummaryInvoicePaymentAmount 获取汇总金额合计信息
|
|
func GetContractSummaryInvoicePaymentAmount(condition string, pars []interface{}) (amountTotal float64, err error) {
|
|
func GetContractSummaryInvoicePaymentAmount(condition string, pars []interface{}) (amountTotal float64, err error) {
|
|
joinCond := ` (a.invoice_id = b.contract_invoice_id OR a.payment_id = b.contract_invoice_id) `
|
|
joinCond := ` (a.invoice_id = b.contract_invoice_id OR a.payment_id = b.contract_invoice_id) `
|
|
|
|
|
|
o := orm.NewOrmUsingDB("fms")
|
|
o := orm.NewOrmUsingDB("fms")
|
|
- sql := `SELECT b.amount FROM invoice_payment_summary AS a JOIN contract_invoice AS b ON `+ joinCond+` AND b.is_deleted = 0 WHERE `
|
|
|
|
|
|
+ sql := `SELECT b.amount FROM invoice_payment_summary AS a JOIN contract_invoice AS b ON ` + joinCond + ` AND b.is_deleted = 0 WHERE `
|
|
sql += condition
|
|
sql += condition
|
|
sql += ` GROUP BY id `
|
|
sql += ` GROUP BY id `
|
|
|
|
|
|
- nsql := `SELECT IFNULL( SUM( e.amount ), 0 ) FROM (`+sql+`) as e`
|
|
|
|
-
|
|
|
|
|
|
+ nsql := `SELECT IFNULL( SUM( e.amount ), 0 ) FROM (` + sql + `) as e`
|
|
|
|
|
|
err = o.Raw(nsql, pars).QueryRow(&amountTotal)
|
|
err = o.Raw(nsql, pars).QueryRow(&amountTotal)
|
|
|
|
|
|
@@ -165,3 +160,10 @@ type InvoiceSummary struct {
|
|
ContractRegister
|
|
ContractRegister
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// GetContractRegisterListByStartDate 根据起始日期的时间段筛选合同登记信息。
|
|
|
|
+func GetContractRegisterListByStartDate(startDate string) (results []*ContractRegisterSummary, err error) {
|
|
|
|
+ o := orm.NewOrmUsingDB("fms")
|
|
|
|
+ sql := ` SELECT * FROM contract_register WHERE start_date > ? AND start_date < ? AND is_deleted = 0 AND product_ids LIKE '%2%' `
|
|
|
|
+ _, err = o.Raw(sql, startDate, startDate).QueryRows(&results)
|
|
|
|
+ return
|
|
|
|
+}
|