作者 陈志颖

feat:添加财富值榜单总榜

package service
import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/statistics/command"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
"time"
)
// 数据统计服务
... ... @@ -305,6 +307,15 @@ func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employees
employeeDao = value
}
fmt.Print(employeesSuMoneyStatisticsCommand, "\n")
if employeesSuMoneyStatisticsCommand.StartTime.IsZero() && employeesSuMoneyStatisticsCommand.EndTime.IsZero() {
employeesSuMoneyStatisticsCommand.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location())
employeesSuMoneyStatisticsCommand.EndTime = time.Now().Local()
}
fmt.Print(employeesSuMoneyStatisticsCommand, "\n")
if employeesSuMoneyStatistics, err := employeeDao.CalculateEmployeesSuMoney(employeesSuMoneyStatisticsCommand.CompanyId, employeesSuMoneyStatisticsCommand.StartTime, employeesSuMoneyStatisticsCommand.EndTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ...
... ... @@ -57,6 +57,7 @@ func (dao *EmployeeDao) TransferSuMoney(uid int64, suMoney float64) error {
return err
}
// 计算个人未读消息
func (dao *EmployeeDao) CalculatePersonUnReadNotification(uid int64) (map[string]int, error) {
var unReadSystemNotification int
var unReadInteractionNotification int
... ... @@ -86,6 +87,7 @@ func (dao *EmployeeDao) CalculatePersonUnReadNotification(uid int64) (map[string
}, nil
}
// 计算个人素币情况
func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{}, error) {
var incomeSuMoney float64
var incomeSuMoneyOfYesterday float64
... ... @@ -233,6 +235,54 @@ func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time.
}, nil
}
//func (dao *EmployeeDao) CalculateEmployeesSuMoney(queryOptions map[string]interface{}) (map[string]interface{}, error) {
// var ret []struct {
// Uid int
// EmployeeName string
// EmployeeSuMoney float64
// }
// tx := dao.transactionContext.PgTx
// var (
// startTime time.Time
// endTime time.Time
// companyId int
// )
// if company, ok := queryOptions["companyId"].(int); ok {
// companyId = company
// }
// if start, ok := queryOptions["startTime"].(time.Time); ok {
// startTime = start
// } else {
// startTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location())
// }
// if end, ok := queryOptions["endTime"].(time.Time); ok {
// endTime = end
// } else {
// endTime = time.Now()
// }
// fmt.Print(startTime, "\n")
// fmt.Print(endTime, "\n")
// fmt.Print(companyId, "\n")
// suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
// if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
// ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid").
// ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name").
// ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money").
// Where(`e.company_id = ?`, companyId).
// Where(`e.status = ?`, 1).
// Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})). // 增加,任务奖励的
// Where(`su_money_transaction_record.create_time > ?`, startTime).
// Where(`su_money_transaction_record.create_time < ?`, endTime).
// Group("su_money_transaction_record.employee").
// Order("employee_su_money DESC").
// Select(&ret); err != nil {
// return nil, err
// }
// return map[string]interface{}{
// "employeesSuMoney": ret,
// }, nil
//}
// 员工贡献值统计
func (dao *EmployeeDao) CalculateEmployeesContributions(companyId int, startTime time.Time, endTime time.Time) (map[string]interface{}, error) {
var ret []struct { // 员工贡献值
... ...
... ... @@ -2,6 +2,7 @@ package controllers
import (
"encoding/json"
"fmt"
"github.com/astaxie/beego"
"github.com/linmadan/egglib-go/web/beego/utils"
... ... @@ -108,6 +109,7 @@ func (controller *StatisticsController) EmployeesSuMoneyStatistics() {
statisticsService := service.NewStatisticsService(nil)
employeesSuMoneyStatisticsCommand := &command.EmployeesSuMoneyStatisticsCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), employeesSuMoneyStatisticsCommand)
fmt.Print(employeesSuMoneyStatisticsCommand, "\n")
data, err := statisticsService.EmployeesSuMoneyStatistics(employeesSuMoneyStatisticsCommand)
var response utils.JsonResponse
if err != nil {
... ... @@ -124,6 +126,7 @@ func (controller *StatisticsController) EmployeesContributionsStatistics() {
statisticsService := service.NewStatisticsService(nil)
employeesContributionsStatisticsCommand := &command.EmployeesContributionsStatisticsCommand{}
json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), employeesContributionsStatisticsCommand)
fmt.Print(employeesContributionsStatisticsCommand, "\n")
data, err := statisticsService.EmployeesContributionsStatistics(employeesContributionsStatisticsCommand)
var response utils.JsonResponse
if err != nil {
... ...