正在显示
5 个修改的文件
包含
30 行增加
和
16 行删除
| @@ -266,7 +266,7 @@ func (statisticsService *StatisticsService) SystemCashStatistics(systemCashStati | @@ -266,7 +266,7 @@ func (statisticsService *StatisticsService) SystemCashStatistics(systemCashStati | ||
| 266 | } | 266 | } |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | -// 获取员工财富值分组统计 | 269 | +// TODO 获取员工财富值分组统计 |
| 270 | func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employeesSuMoneyStatisticsCommand *command.EmployeesSuMoneyStatisticsCommand) (interface{}, error) { | 270 | func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employeesSuMoneyStatisticsCommand *command.EmployeesSuMoneyStatisticsCommand) (interface{}, error) { |
| 271 | if err := employeesSuMoneyStatisticsCommand.ValidateCommand(); err != nil { | 271 | if err := employeesSuMoneyStatisticsCommand.ValidateCommand(); err != nil { |
| 272 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 272 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
| @@ -281,6 +281,7 @@ func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employees | @@ -281,6 +281,7 @@ func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employees | ||
| 281 | defer func() { | 281 | defer func() { |
| 282 | transactionContext.RollbackTransaction() | 282 | transactionContext.RollbackTransaction() |
| 283 | }() | 283 | }() |
| 284 | + | ||
| 284 | var employeeDao *dao.EmployeeDao | 285 | var employeeDao *dao.EmployeeDao |
| 285 | if value, err := factory.CreateEmployeeDao(map[string]interface{}{ | 286 | if value, err := factory.CreateEmployeeDao(map[string]interface{}{ |
| 286 | "transactionContext": transactionContext, | 287 | "transactionContext": transactionContext, |
| @@ -289,6 +290,7 @@ func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employees | @@ -289,6 +290,7 @@ func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employees | ||
| 289 | } else { | 290 | } else { |
| 290 | employeeDao = value | 291 | employeeDao = value |
| 291 | } | 292 | } |
| 293 | + | ||
| 292 | if employeesSuMoneyStatistics, err := employeeDao.CalculateEmployeesSuMoney(employeesSuMoneyStatisticsCommand.CompanyId, employeesSuMoneyStatisticsCommand.StartTime, employeesSuMoneyStatisticsCommand.EndTime); err != nil { | 294 | if employeesSuMoneyStatistics, err := employeeDao.CalculateEmployeesSuMoney(employeesSuMoneyStatisticsCommand.CompanyId, employeesSuMoneyStatisticsCommand.StartTime, employeesSuMoneyStatisticsCommand.EndTime); err != nil { |
| 293 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 295 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 294 | } else { | 296 | } else { |
| @@ -299,7 +301,7 @@ func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employees | @@ -299,7 +301,7 @@ func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employees | ||
| 299 | } | 301 | } |
| 300 | } | 302 | } |
| 301 | 303 | ||
| 302 | -// 获取员工贡献值分组统计 | 304 | +// TODO 获取员工贡献值分组统计 |
| 303 | func (statisticsService *StatisticsService) EmployeesContributionsStatistics(employeesContributionsStatisticsCommand *command.EmployeesContributionsStatisticsCommand) (interface{}, error) { | 305 | func (statisticsService *StatisticsService) EmployeesContributionsStatistics(employeesContributionsStatisticsCommand *command.EmployeesContributionsStatisticsCommand) (interface{}, error) { |
| 304 | if err := employeesContributionsStatisticsCommand.ValidateCommand(); err != nil { | 306 | if err := employeesContributionsStatisticsCommand.ValidateCommand(); err != nil { |
| 305 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 307 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
| @@ -314,6 +316,7 @@ func (statisticsService *StatisticsService) EmployeesContributionsStatistics(emp | @@ -314,6 +316,7 @@ func (statisticsService *StatisticsService) EmployeesContributionsStatistics(emp | ||
| 314 | defer func() { | 316 | defer func() { |
| 315 | transactionContext.RollbackTransaction() | 317 | transactionContext.RollbackTransaction() |
| 316 | }() | 318 | }() |
| 319 | + | ||
| 317 | var employeeDao *dao.EmployeeDao | 320 | var employeeDao *dao.EmployeeDao |
| 318 | if value, err := factory.CreateEmployeeDao(map[string]interface{}{ | 321 | if value, err := factory.CreateEmployeeDao(map[string]interface{}{ |
| 319 | "transactionContext": transactionContext, | 322 | "transactionContext": transactionContext, |
| @@ -322,6 +325,7 @@ func (statisticsService *StatisticsService) EmployeesContributionsStatistics(emp | @@ -322,6 +325,7 @@ func (statisticsService *StatisticsService) EmployeesContributionsStatistics(emp | ||
| 322 | } else { | 325 | } else { |
| 323 | employeeDao = value | 326 | employeeDao = value |
| 324 | } | 327 | } |
| 328 | + | ||
| 325 | if employeesContributionsStatistics, err := employeeDao.CalculateEmployeesContributions(employeesContributionsStatisticsCommand.CompanyId, employeesContributionsStatisticsCommand.StartTime, employeesContributionsStatisticsCommand.EndTime); err != nil { | 329 | if employeesContributionsStatistics, err := employeeDao.CalculateEmployeesContributions(employeesContributionsStatisticsCommand.CompanyId, employeesContributionsStatisticsCommand.StartTime, employeesContributionsStatisticsCommand.EndTime); err != nil { |
| 326 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 330 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 327 | } else { | 331 | } else { |
| @@ -211,13 +211,13 @@ func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time. | @@ -211,13 +211,13 @@ func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time. | ||
| 211 | var ret []struct { | 211 | var ret []struct { |
| 212 | Uid int | 212 | Uid int |
| 213 | EmployeeName string | 213 | EmployeeName string |
| 214 | - EmployeesSuMoney float64 | 214 | + EmployeeSuMoney float64 |
| 215 | } | 215 | } |
| 216 | suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord) | 216 | suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord) |
| 217 | if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint"). | 217 | if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint"). |
| 218 | - //Column("su_money_transaction_record.employee"). | ||
| 219 | - //Column("su_money_transaction_record.employee->>'employeeName'"). | ||
| 220 | - 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"). | 218 | + ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid"). |
| 219 | + ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name"). | ||
| 220 | + ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money"). | ||
| 221 | Where(`e.company_id = ?`, companyId). | 221 | Where(`e.company_id = ?`, companyId). |
| 222 | Where(`e.status = ?`, 1). | 222 | Where(`e.status = ?`, 1). |
| 223 | Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})). // 增加,任务奖励的 | 223 | Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})). // 增加,任务奖励的 |
| @@ -266,7 +266,7 @@ func (dao *EmployeeDao) CalculateEmployeesContributions(companyId int, startTime | @@ -266,7 +266,7 @@ func (dao *EmployeeDao) CalculateEmployeesContributions(companyId int, startTime | ||
| 266 | //Column("su_money_transaction_record.employee"). | 266 | //Column("su_money_transaction_record.employee"). |
| 267 | 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"). | 267 | 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"). |
| 268 | Where(`e.company_id = ?`, companyId). | 268 | Where(`e.company_id = ?`, companyId). |
| 269 | - Where(`su_money_transaction_record.record_type = ?`, 4). | 269 | + Where(`su_money_transaction_record.record_type = ?`, 4). |
| 270 | Where(`e.status = ?`, 1). | 270 | Where(`e.status = ?`, 1). |
| 271 | Where(`su_money_transaction_record.create_time > ?`, startTime). | 271 | Where(`su_money_transaction_record.create_time > ?`, startTime). |
| 272 | Where(`su_money_transaction_record.create_time < ?`, endTime). | 272 | Where(`su_money_transaction_record.create_time < ?`, endTime). |
| @@ -6,7 +6,7 @@ import ( | @@ -6,7 +6,7 @@ import ( | ||
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | type SuMoneyTransactionRecord struct { | 8 | type SuMoneyTransactionRecord struct { |
| 9 | - TableName string `pg:"su_money_transaction_records,alias:su_money_transaction_record,discard_unknown_columns"` | 9 | + TableName string `pg:",discard_unknown_columns,su_money_transaction_records,alias:su_money_transaction_record"` |
| 10 | // 素币事务记录ID | 10 | // 素币事务记录ID |
| 11 | Id int64 `pg:",pk"` | 11 | Id int64 `pg:",pk"` |
| 12 | // 记录类型 | 12 | // 记录类型 |
| @@ -19,12 +19,12 @@ type SuMoneyTransactionRecord struct { | @@ -19,12 +19,12 @@ type SuMoneyTransactionRecord struct { | ||
| 19 | CurrentSuMoney float64 | 19 | CurrentSuMoney float64 |
| 20 | // 事务素币值 | 20 | // 事务素币值 |
| 21 | SuMoney float64 | 21 | SuMoney float64 |
| 22 | - // 事务处理前现金值 | ||
| 23 | - CashBeforeTransaction float64 | ||
| 24 | - // 当前现金值 | ||
| 25 | - CurrentCash float64 | ||
| 26 | - // 事务现金值 | ||
| 27 | - Cash float64 | 22 | + //// 事务处理前现金值 |
| 23 | + //CashBeforeTransaction float64 | ||
| 24 | + //// 当前现金值 | ||
| 25 | + //CurrentCash float64 | ||
| 26 | + //// 事务现金值 | ||
| 27 | + //Cash float64 | ||
| 28 | // 操作人 | 28 | // 操作人 |
| 29 | Operator *domain.EmployeeInfo | 29 | Operator *domain.EmployeeInfo |
| 30 | // 素币事务记录描述 | 30 | // 素币事务记录描述 |
| @@ -103,7 +103,7 @@ func (controller *StatisticsController) SystemCashStatistics() { | @@ -103,7 +103,7 @@ func (controller *StatisticsController) SystemCashStatistics() { | ||
| 103 | controller.ServeJSON() | 103 | controller.ServeJSON() |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | -// 员工财富值 | 106 | +// 获取员工财富值 |
| 107 | func (controller *StatisticsController) EmployeesSuMoneyStatistics() { | 107 | func (controller *StatisticsController) EmployeesSuMoneyStatistics() { |
| 108 | statisticsService := service.NewStatisticsService(nil) | 108 | statisticsService := service.NewStatisticsService(nil) |
| 109 | employeesSuMoneyStatisticsCommand := &command.EmployeesSuMoneyStatisticsCommand{} | 109 | employeesSuMoneyStatisticsCommand := &command.EmployeesSuMoneyStatisticsCommand{} |
| @@ -119,7 +119,7 @@ func (controller *StatisticsController) EmployeesSuMoneyStatistics() { | @@ -119,7 +119,7 @@ func (controller *StatisticsController) EmployeesSuMoneyStatistics() { | ||
| 119 | controller.ServeJSON() | 119 | controller.ServeJSON() |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | -// 员工贡献值 | 122 | +// 获取员工贡献值 |
| 123 | func (controller *StatisticsController) EmployeesContributionsStatistics() { | 123 | func (controller *StatisticsController) EmployeesContributionsStatistics() { |
| 124 | statisticsService := service.NewStatisticsService(nil) | 124 | statisticsService := service.NewStatisticsService(nil) |
| 125 | employeesContributionsStatisticsCommand := &command.EmployeesContributionsStatisticsCommand{} | 125 | employeesContributionsStatisticsCommand := &command.EmployeesContributionsStatisticsCommand{} |
| @@ -338,13 +338,23 @@ func (controller *SuMoneyController) ImportExchangeList () { | @@ -338,13 +338,23 @@ func (controller *SuMoneyController) ImportExchangeList () { | ||
| 338 | fmt.Println(err) | 338 | fmt.Println(err) |
| 339 | return | 339 | return |
| 340 | } | 340 | } |
| 341 | + // TODO 增加导入失败原因返回 | ||
| 342 | + | ||
| 341 | var response utils.JsonResponse | 343 | var response utils.JsonResponse |
| 342 | dataList := make([]interface{}, 0) | 344 | dataList := make([]interface{}, 0) |
| 343 | rows, _ := xlsx.GetRows("Sheet1") | 345 | rows, _ := xlsx.GetRows("Sheet1") |
| 346 | + if len(rows) > 1000 { | ||
| 347 | + controller.Ctx.WriteString( "导入行数超过1000行" ) | ||
| 348 | + return | ||
| 349 | + } | ||
| 344 | for i, row := range rows { | 350 | for i, row := range rows { |
| 345 | if i > 2 { | 351 | if i > 2 { |
| 346 | for _, _ = range row { | 352 | for _, _ = range row { |
| 347 | createExchangeCashPersonCommand.ExchangeCashActivityId = activityId | 353 | createExchangeCashPersonCommand.ExchangeCashActivityId = activityId |
| 354 | + // TODO 非空校验 | ||
| 355 | + if createExchangeCashPersonCommand.PersonName == "" || createExchangeCashPersonCommand.PersonAccount == "" || createExchangeCashPersonCommand.ExchangedSuMoney == 0{ | ||
| 356 | + | ||
| 357 | + } | ||
| 348 | createExchangeCashPersonCommand.Operator = operatorId | 358 | createExchangeCashPersonCommand.Operator = operatorId |
| 349 | createExchangeCashPersonCommand.PersonName = row[0] | 359 | createExchangeCashPersonCommand.PersonName = row[0] |
| 350 | createExchangeCashPersonCommand.PersonAccount = row[1] | 360 | createExchangeCashPersonCommand.PersonAccount = row[1] |
-
请 注册 或 登录 后发表评论