statistic.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package models
  2. import (
  3. "hongze/fms_api/global"
  4. "hongze/fms_api/models/fms"
  5. )
  6. // 收入统计图表数据
  7. type IncomeChartResp struct {
  8. Title string `description:"图表名称"`
  9. Date []string `description:"月份"`
  10. ContractMoney []float64 `description:"开票金额"`
  11. ArrivalMoney []float64 `description:"到款金额"`
  12. }
  13. type IncomeItem struct {
  14. ContractMoney float64 `description:"开票金额"`
  15. ArrivalMoney float64 `description:"到款金额"`
  16. }
  17. func GetIncomeListCount(cond string) (results *IncomeItem, err error) {
  18. sql := `SELECT a.contract_money, b.arrival_money FROM (
  19. SELECT SUM(amount) contract_money FROM contract_invoice WHERE is_deleted = 0 AND (invoice_type = 1 OR invoice_type = 3) ` + cond + ` ) AS a,
  20. (SELECT SUM(amount) arrival_money FROM contract_invoice WHERE is_deleted = 0 AND (invoice_type = 2 OR invoice_type = 4) ` + cond + ` ) AS b WHERE 1=1 `
  21. err = global.DEFAULT_MYSQL.Raw(sql).First(&results).Error
  22. return
  23. }
  24. // 收入统计图表数据
  25. type CensusIncomeChartResp struct {
  26. Title string `description:"图表名称"`
  27. Date []string `description:"月份"`
  28. TotalMoney []float64 `description:"总金额"`
  29. PrevTotalMoney []float64 `description:"历史总金额"`
  30. Yoy []string `description:"同比值"`
  31. DataList []*fms.IncomeSummaryItem ` json:"-"`
  32. }