瀏覽代碼

Merge remote-tracking branch 'origin/dev' into dev

2545307760@qq.com 7 月之前
父節點
當前提交
b4c69047c4
共有 4 個文件被更改,包括 18 次插入8 次删除
  1. 6 2
      server/api/v1/admin/expenses.go
  2. 4 1
      server/dao/monthExpenses.go
  3. 4 1
      server/dao/projectMonthFee.go
  4. 4 4
      server/service/admin/expenses.go

+ 6 - 2
server/api/v1/admin/expenses.go

@@ -6,6 +6,7 @@ import (
 	"server/global"
 	"server/model/common/request"
 	"server/model/common/response"
+	"strconv"
 )
 
 type ExpensesApi struct{}
@@ -89,7 +90,8 @@ func (ea *ExpensesApi) QuerySurplus(c *gin.Context) {
 func (ea *ExpensesApi) QueryProjectMonthFee(c *gin.Context) {
 	monthTime := c.Query("monthTime")
 	yearTime := c.Query("yearTime")
-	fee, err := expensesService.QueryProjectMonthFee(monthTime, yearTime)
+	code := c.Query("code")
+	fee, err := expensesService.QueryProjectMonthFee(monthTime, yearTime, code)
 	if err != nil {
 		response.FailWithMessage("失败", c)
 		global.GVA_LOG.Error("QueryProjectMonthFee ====== " + err.Error())
@@ -101,7 +103,9 @@ func (ea *ExpensesApi) QueryProjectMonthFee(c *gin.Context) {
 func (ea *ExpensesApi) QueryMonthExpenses(c *gin.Context) {
 	monthTime := c.Query("monthTime")
 	yearTime := c.Query("yearTime")
-	fee, err := expensesService.QueryMonthExpenses(monthTime, yearTime)
+	genre := c.Query("genre")
+	genreId, _ := strconv.Atoi(genre)
+	fee, err := expensesService.QueryMonthExpenses(monthTime, yearTime, genreId)
 	if err != nil {
 		response.FailWithMessage("失败", c)
 		global.GVA_LOG.Error("QueryMonthExpenses ====== " + err.Error())

+ 4 - 1
server/dao/monthExpenses.go

@@ -20,7 +20,7 @@ func (MonthExpenses) TableName() string {
 	return "month_expenses"
 }
 
-func QueryMonthExpenses(monthTime, yearTime string) (monthExpenses []MonthExpenses, err error) {
+func QueryMonthExpenses(monthTime, yearTime string, genreId int) (monthExpenses []MonthExpenses, err error) {
 	db := global.GVA_DB.Debug().Model(&MonthExpenses{}).Select("department_id, SUM(total_deposit) AS total_deposit, SUM(total_expenditure) AS total_expenditure")
 	if monthTime != "" {
 		db = db.Where("DATE_FORMAT(CONCAT(settlement_month, '-01'), '%Y-%m') = ?", monthTime)
@@ -28,6 +28,9 @@ func QueryMonthExpenses(monthTime, yearTime string) (monthExpenses []MonthExpens
 	if yearTime != "" {
 		db = db.Where("DATE_FORMAT(CONCAT(settlement_month, '-01'), '%Y') = ?", yearTime)
 	}
+	if genreId != 0 {
+		db = db.Where("genre = ?", genreId)
+	}
 	err = db.Group("department_id").Preload("ExpensesGenre").Preload("Department").Find(&monthExpenses).Error
 	return monthExpenses, err
 }

+ 4 - 1
server/dao/projectMonthFee.go

@@ -20,7 +20,7 @@ func (ProjectMonthFee) TableName() string {
 	return "project_month_fee"
 }
 
-func QueryProjectMonthFee(monthTime, yearTime string) (monthFees []ProjectMonthFee, err error) {
+func QueryProjectMonthFee(monthTime, yearTime, code string) (monthFees []ProjectMonthFee, err error) {
 	db := global.GVA_DB.Model(&ProjectMonthFee{}).Select("genre, SUM(total_deposit) AS total_deposit, SUM(total_expenditure) AS total_expenditure")
 	if monthTime != "" {
 		db = db.Where("DATE_FORMAT(CONCAT(settlement_month, '-01'), '%Y-%m') = ?", monthTime)
@@ -28,6 +28,9 @@ func QueryProjectMonthFee(monthTime, yearTime string) (monthFees []ProjectMonthF
 	if yearTime != "" {
 		db = db.Where("DATE_FORMAT(CONCAT(settlement_month, '-01'), '%Y') = ?", yearTime)
 	}
+	if code != "" {
+		db = db.Where("project_code =?", code)
+	}
 	err = db.Group("genre").Preload("ProjectFeeGenre").Preload("Project").Find(&monthFees).Error
 	return monthFees, err
 }

+ 4 - 4
server/service/admin/expenses.go

@@ -47,12 +47,12 @@ func (es *ExpensesService) QuerySurplus() (interface{}, error) {
 	return dao.QuerySurplus()
 }
 
-func (es *ExpensesService) QueryProjectMonthFee(monthTime, yearTime string) ([]dao.ProjectMonthFee, error) {
-	return dao.QueryProjectMonthFee(monthTime, yearTime)
+func (es *ExpensesService) QueryProjectMonthFee(monthTime, yearTime, code string) ([]dao.ProjectMonthFee, error) {
+	return dao.QueryProjectMonthFee(monthTime, yearTime, code)
 }
 
-func (es *ExpensesService) QueryMonthExpenses(monthTime, yearTime string) ([]dao.MonthExpenses, error) {
-	return dao.QueryMonthExpenses(monthTime, yearTime)
+func (es *ExpensesService) QueryMonthExpenses(monthTime, yearTime string, genreId int) ([]dao.MonthExpenses, error) {
+	return dao.QueryMonthExpenses(monthTime, yearTime, genreId)
 }
 
 func (es *ExpensesService) CreateExpenses(expenses dao.Expenses) error {