作者 陈志颖

fix:修复员工财富值统计问题

... ... @@ -266,7 +266,7 @@ func (statisticsService *StatisticsService) SystemCashStatistics(systemCashStati
}
}
// 获取员工财富值分组统计
// TODO 获取员工财富值分组统计
func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employeesSuMoneyStatisticsCommand *command.EmployeesSuMoneyStatisticsCommand) (interface{}, error) {
if err := employeesSuMoneyStatisticsCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -281,6 +281,7 @@ func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employees
defer func() {
transactionContext.RollbackTransaction()
}()
var employeeDao *dao.EmployeeDao
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -289,6 +290,7 @@ func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employees
} else {
employeeDao = value
}
if employeesSuMoneyStatistics, err := employeeDao.CalculateEmployeesSuMoney(employeesSuMoneyStatisticsCommand.CompanyId, employeesSuMoneyStatisticsCommand.StartTime, employeesSuMoneyStatisticsCommand.EndTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -299,7 +301,7 @@ func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employees
}
}
// 获取员工贡献值分组统计
// TODO 获取员工贡献值分组统计
func (statisticsService *StatisticsService) EmployeesContributionsStatistics(employeesContributionsStatisticsCommand *command.EmployeesContributionsStatisticsCommand) (interface{}, error) {
if err := employeesContributionsStatisticsCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -314,6 +316,7 @@ func (statisticsService *StatisticsService) EmployeesContributionsStatistics(emp
defer func() {
transactionContext.RollbackTransaction()
}()
var employeeDao *dao.EmployeeDao
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -322,6 +325,7 @@ func (statisticsService *StatisticsService) EmployeesContributionsStatistics(emp
} else {
employeeDao = value
}
if employeesContributionsStatistics, err := employeeDao.CalculateEmployeesContributions(employeesContributionsStatisticsCommand.CompanyId, employeesContributionsStatisticsCommand.StartTime, employeesContributionsStatisticsCommand.EndTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ...
... ... @@ -211,13 +211,13 @@ func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time.
var ret []struct {
Uid int
EmployeeName string
EmployeesSuMoney float64
EmployeeSuMoney float64
}
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
//Column("su_money_transaction_record.employee").
//Column("su_money_transaction_record.employee->>'employeeName'").
ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid, su_money_transaction_record.employee->>'employeeName' AS employeeName, sum(su_money_transaction_record.su_money) AS employee_su_money").
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})). // 增加,任务奖励的
... ... @@ -266,7 +266,7 @@ func (dao *EmployeeDao) CalculateEmployeesContributions(companyId int, startTime
//Column("su_money_transaction_record.employee").
ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid, su_money_transaction_record.employee->>'employeeName' AS employeeName, sum(su_money_transaction_record.su_money) AS employees_contributions_decrease").
Where(`e.company_id = ?`, companyId).
Where(`su_money_transaction_record.record_type = `, 4).
Where(`su_money_transaction_record.record_type = ?`, 4).
Where(`e.status = ?`, 1).
Where(`su_money_transaction_record.create_time > ?`, startTime).
Where(`su_money_transaction_record.create_time < ?`, endTime).
... ...
... ... @@ -6,7 +6,7 @@ import (
)
type SuMoneyTransactionRecord struct {
TableName string `pg:"su_money_transaction_records,alias:su_money_transaction_record,discard_unknown_columns"`
TableName string `pg:",discard_unknown_columns,su_money_transaction_records,alias:su_money_transaction_record"`
// 素币事务记录ID
Id int64 `pg:",pk"`
// 记录类型
... ... @@ -19,12 +19,12 @@ type SuMoneyTransactionRecord struct {
CurrentSuMoney float64
// 事务素币值
SuMoney float64
// 事务处理前现金值
CashBeforeTransaction float64
// 当前现金值
CurrentCash float64
// 事务现金值
Cash float64
//// 事务处理前现金值
//CashBeforeTransaction float64
//// 当前现金值
//CurrentCash float64
//// 事务现金值
//Cash float64
// 操作人
Operator *domain.EmployeeInfo
// 素币事务记录描述
... ...
... ... @@ -103,7 +103,7 @@ func (controller *StatisticsController) SystemCashStatistics() {
controller.ServeJSON()
}
// 员工财富值
// 获取员工财富值
func (controller *StatisticsController) EmployeesSuMoneyStatistics() {
statisticsService := service.NewStatisticsService(nil)
employeesSuMoneyStatisticsCommand := &command.EmployeesSuMoneyStatisticsCommand{}
... ... @@ -119,7 +119,7 @@ func (controller *StatisticsController) EmployeesSuMoneyStatistics() {
controller.ServeJSON()
}
// 员工贡献值
// 获取员工贡献值
func (controller *StatisticsController) EmployeesContributionsStatistics() {
statisticsService := service.NewStatisticsService(nil)
employeesContributionsStatisticsCommand := &command.EmployeesContributionsStatisticsCommand{}
... ...
... ... @@ -338,13 +338,23 @@ func (controller *SuMoneyController) ImportExchangeList () {
fmt.Println(err)
return
}
// TODO 增加导入失败原因返回
var response utils.JsonResponse
dataList := make([]interface{}, 0)
rows, _ := xlsx.GetRows("Sheet1")
if len(rows) > 1000 {
controller.Ctx.WriteString( "导入行数超过1000行" )
return
}
for i, row := range rows {
if i > 2 {
for _, _ = range row {
createExchangeCashPersonCommand.ExchangeCashActivityId = activityId
// TODO 非空校验
if createExchangeCashPersonCommand.PersonName == "" || createExchangeCashPersonCommand.PersonAccount == "" || createExchangeCashPersonCommand.ExchangedSuMoney == 0{
}
createExchangeCashPersonCommand.Operator = operatorId
createExchangeCashPersonCommand.PersonName = row[0]
createExchangeCashPersonCommand.PersonAccount = row[1]
... ...