|
@@ -103,7 +103,7 @@ type InvoicePaymentSummaryItem struct {
|
|
|
func GetInvoicePaymentCensusSummaryData(condition string, pars []interface{}) (results []*InvoicePaymentSummaryItem, err error) {
|
|
|
fields := []string{"a.id AS summary_id", "a.register_id", "a.invoice_id", "a.payment_id", "a.service_product_id", "b.company_name", "b.start_date", "b.end_date",
|
|
|
"c.origin_amount AS invoice_amount", "c.invoice_time AS invoice_date", "IF(c.seller_id > 0, c.seller_id, d.seller_id) AS seller_id", "IF(c.seller_name = '' OR c.seller_name IS NULL, d.seller_name, c.seller_name) AS seller_name", "IF(c.seller_group_id > 0,c.seller_group_id,d.seller_group_id) AS seller_group_id",
|
|
|
- "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","b.currency_unit",
|
|
|
+ "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", "b.currency_unit",
|
|
|
}
|
|
|
query := global.DEFAULT_MYSQL.Table("invoice_payment_summary AS a").
|
|
|
Select(strings.Join(fields, ",")).
|
|
@@ -218,6 +218,9 @@ type InvoiceSummary struct {
|
|
|
SummaryId int `json:"summary_id" description:"汇总ID"`
|
|
|
PaymentAmountCount float64 `gorm:"column:payment_amount_count" json:"payment_amount_count" description:"到款金额"`
|
|
|
InvoicedAmountCount float64 `gorm:"column:invoiced_amount_count" json:"invoiced_amount_count" description:"开票金额"`
|
|
|
+ InvoiceOrigin float64 `gorm:"column:invoice_origin" json:"invoice_origin" description:"开票原始金额"`
|
|
|
+ PaymentOrigin float64 `gorm:"column:payment_origin" json:"payment_origin" description:"到款原始金额"`
|
|
|
+ ServiceProductId int `json:"service_product_id" description:"套餐类型:1ficc套餐,2权益套餐"`
|
|
|
ContractRegister
|
|
|
}
|
|
|
|
|
@@ -348,11 +351,11 @@ func GetNoInvoicePaymentCensusData(condition string, pars []interface{}) (result
|
|
|
// GetInvoiceCensusList 获取未开票统计列表
|
|
|
func GetInvoiceCensusList(condition string, pars []interface{}) (results []*InvoiceSummary, err error) {
|
|
|
query := global.DEFAULT_MYSQL.Table("contract_register AS b").
|
|
|
- Select("b.*, a.id as summary_id, IF(a.invoice_id >0, 1,0) as sort_invoice_id, IF(a.payment_id >0, 1,0) as sort_payment_id, COALESCE(SUM( c.amount ),0) AS invoiced_amount_count,COALESCE(SUM( d.amount ),0) AS payment_amount_count ").
|
|
|
+ Select("b.*, a.id as summary_id, IF(a.invoice_id >0, 1,0) as sort_invoice_id, IF(a.payment_id >0, 1,0) as sort_payment_id, COALESCE(SUM( c.amount ),0) AS invoiced_amount_count,COALESCE(SUM( d.amount ),0) AS payment_amount_count,a.service_product_id,c.origin_amount AS invoice_origin,d.origin_amount AS payment_origin ").
|
|
|
Joins("left JOIN invoice_payment_summary AS a ON a.register_id = b.contract_register_id AND b.is_deleted = 0").
|
|
|
Joins("LEFT JOIN contract_invoice AS c ON a.invoice_id = c.contract_invoice_id AND c.is_deleted = 0").
|
|
|
Joins("LEFT JOIN contract_invoice AS d ON a.payment_id = d.contract_invoice_id AND d.is_deleted = 0").
|
|
|
- Where(condition, pars...).Group("contract_register_id")
|
|
|
+ Where(condition, pars...).Group("contract_register_id,service_product_id")
|
|
|
|
|
|
nq := global.DEFAULT_MYSQL.Table("(?) AS e", query).
|
|
|
Select("*").Where(" e.invoiced_amount_count <> e.contract_amount ")
|