作者 陈志颖

fix:去除验收任务现金池

@@ -2,6 +2,7 @@ package command @@ -2,6 +2,7 @@ package command
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "time"
5 6
6 "github.com/astaxie/beego/validation" 7 "github.com/astaxie/beego/validation"
7 ) 8 )
@@ -15,6 +16,8 @@ type CreateEmployeeCommand struct { @@ -15,6 +16,8 @@ type CreateEmployeeCommand struct {
15 EmployeeAccount string `json:"employeeAccount,omitempty"` 16 EmployeeAccount string `json:"employeeAccount,omitempty"`
16 // 员工头像URL 17 // 员工头像URL
17 EmployeeAvatarUrl string `json:"employeeAvatarUrl,omitempty"` 18 EmployeeAvatarUrl string `json:"employeeAvatarUrl,omitempty"`
  19 + // 创建时间
  20 + CreateTime time.Time `json:"createTime"`
18 } 21 }
19 22
20 func (createEmployeeCommand *CreateEmployeeCommand) ValidateCommand() error { 23 func (createEmployeeCommand *CreateEmployeeCommand) ValidateCommand() error {
@@ -2,6 +2,7 @@ package command @@ -2,6 +2,7 @@ package command
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "time"
5 6
6 "github.com/astaxie/beego/validation" 7 "github.com/astaxie/beego/validation"
7 ) 8 )
@@ -9,6 +10,8 @@ import ( @@ -9,6 +10,8 @@ import (
9 type RemoveEmployeeCommand struct { 10 type RemoveEmployeeCommand struct {
10 // 统一用户UID 11 // 统一用户UID
11 Uid int64 `json:"uid" valid:"Required"` 12 Uid int64 `json:"uid" valid:"Required"`
  13 + // 创建时间
  14 + CreateTime time.Time `json:"createTime"`
12 } 15 }
13 16
14 func (removeEmployeeCommand *RemoveEmployeeCommand) ValidateCommand() error { 17 func (removeEmployeeCommand *RemoveEmployeeCommand) ValidateCommand() error {
@@ -2,6 +2,7 @@ package command @@ -2,6 +2,7 @@ package command
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "time"
5 6
6 "github.com/astaxie/beego/validation" 7 "github.com/astaxie/beego/validation"
7 ) 8 )
@@ -17,6 +18,8 @@ type UpdateEmployeeCommand struct { @@ -17,6 +18,8 @@ type UpdateEmployeeCommand struct {
17 EmployeeAvatarUrl string `json:"employeeAvatarUrl,omitempty"` 18 EmployeeAvatarUrl string `json:"employeeAvatarUrl,omitempty"`
18 // 员工权限集合 19 // 员工权限集合
19 Permissions []int `json:"permissions,omitempty"` 20 Permissions []int `json:"permissions,omitempty"`
  21 + // 创建时间
  22 + CreateTime time.Time `json:"createTime"`
20 } 23 }
21 24
22 func (updateEmployeeCommand *UpdateEmployeeCommand) ValidateCommand() error { 25 func (updateEmployeeCommand *UpdateEmployeeCommand) ValidateCommand() error {
1 package domain 1 package domain
2 2
  3 +import "time"
  4 +
3 // 员工 5 // 员工
4 type Employee struct { 6 type Employee struct {
5 // 员工ID 7 // 员工ID
@@ -14,6 +16,8 @@ type Employee struct { @@ -14,6 +16,8 @@ type Employee struct {
14 Status int `json:"status"` 16 Status int `json:"status"`
15 // 员工权限集合 17 // 员工权限集合
16 Permissions []int `json:"permissions"` 18 Permissions []int `json:"permissions"`
  19 + // 创建时间
  20 + CreateTime time.Time `json:"createTime"`
17 } 21 }
18 22
19 type EmployeeRepository interface { 23 type EmployeeRepository interface {
@@ -50,6 +54,9 @@ func (employee *Employee) Update(data map[string]interface{}) error { @@ -50,6 +54,9 @@ func (employee *Employee) Update(data map[string]interface{}) error {
50 if permissions, ok := data["permissions"]; ok { 54 if permissions, ok := data["permissions"]; ok {
51 employee.Permissions = permissions.([]int) 55 employee.Permissions = permissions.([]int)
52 } 56 }
  57 + if createTime, ok := data["createTime"]; ok && !createTime.(time.Time).IsZero() {
  58 + employee.CreateTime = createTime.(time.Time)
  59 + }
53 return nil 60 return nil
54 } 61 }
55 62
@@ -342,7 +342,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -342,7 +342,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
342 queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid") 342 queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
343 //queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name") 343 //queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
344 queryWealth = queryWealth.ColumnExpr("sum(case WHEN su_money_transaction_record.record_type IN (2, 3, 6) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type IN (4, 1, 5) THEN su_money_transaction_record.su_money ELSE 0 end) AS employee_su_money") 344 queryWealth = queryWealth.ColumnExpr("sum(case WHEN su_money_transaction_record.record_type IN (2, 3, 6) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type IN (4, 1, 5) THEN su_money_transaction_record.su_money ELSE 0 end) AS employee_su_money")
345 - queryWealth = queryWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(case WHEN su_money_transaction_record.record_type IN (2, 3, 6) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type IN (4, 1, 5) THEN su_money_transaction_record.su_money ELSE 0 end) DESC) AS ranking") 345 + queryWealth = queryWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(case WHEN su_money_transaction_record.record_type IN (2, 3, 6) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type IN (4, 1, 5) THEN su_money_transaction_record.su_money ELSE 0 end), e.create_time DESC) AS ranking")
346 queryWealth = queryWealth.Where(`e.status = ?`, 1) 346 queryWealth = queryWealth.Where(`e.status = ?`, 1)
347 //queryWealth = queryWealth.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'") 347 //queryWealth = queryWealth.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
348 queryWealth = queryWealth.GroupExpr("su_money_transaction_record.employee->>'uid'") 348 queryWealth = queryWealth.GroupExpr("su_money_transaction_record.employee->>'uid'")
@@ -382,7 +382,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -382,7 +382,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
382 queryWealthWith = queryWealthWith.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid") 382 queryWealthWith = queryWealthWith.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
383 queryWealthWith = queryWealthWith.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name") 383 queryWealthWith = queryWealthWith.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
384 queryWealthWith = queryWealthWith.ColumnExpr("sum(case WHEN su_money_transaction_record.record_type IN (2, 3, 6) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type IN (4, 1, 5) THEN su_money_transaction_record.su_money ELSE 0 end) AS employee_su_money") 384 queryWealthWith = queryWealthWith.ColumnExpr("sum(case WHEN su_money_transaction_record.record_type IN (2, 3, 6) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type IN (4, 1, 5) THEN su_money_transaction_record.su_money ELSE 0 end) AS employee_su_money")
385 - queryWealthWith = queryWealthWith.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(case WHEN su_money_transaction_record.record_type IN (2, 3, 6) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type IN (4, 1, 5) THEN su_money_transaction_record.su_money ELSE 0 end) DESC) AS ranking") 385 + queryWealthWith = queryWealthWith.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(case WHEN su_money_transaction_record.record_type IN (2, 3, 6) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type IN (4, 1, 5) THEN su_money_transaction_record.su_money ELSE 0 end), e.create_time DESC) AS ranking")
386 queryWealthWith = queryWealthWith.Where(`e.status = ?`, 1) 386 queryWealthWith = queryWealthWith.Where(`e.status = ?`, 1)
387 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 387 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
388 queryWealthWith = queryWealthWith.Where("e.company_id = ?", companyId) 388 queryWealthWith = queryWealthWith.Where("e.company_id = ?", companyId)
@@ -420,7 +420,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -420,7 +420,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
420 queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid") 420 queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
421 //queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name") 421 //queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
422 queryContributions = queryContributions.ColumnExpr("sum(case WHEN su_money_transaction_record.record_type IN (2, 3) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type = 4 THEN su_money_transaction_record.su_money ELSE 0 end) AS employees_contributions") 422 queryContributions = queryContributions.ColumnExpr("sum(case WHEN su_money_transaction_record.record_type IN (2, 3) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type = 4 THEN su_money_transaction_record.su_money ELSE 0 end) AS employees_contributions")
423 - queryContributions = queryContributions.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(case WHEN su_money_transaction_record.record_type IN (2, 3) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type = 4 THEN su_money_transaction_record.su_money ELSE 0 end) DESC) AS ranking") 423 + queryContributions = queryContributions.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(case WHEN su_money_transaction_record.record_type IN (2, 3) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type = 4 THEN su_money_transaction_record.su_money ELSE 0 end), e.create_time DESC) AS ranking")
424 queryContributions = queryContributions.Where(`e.status = ?`, 1) 424 queryContributions = queryContributions.Where(`e.status = ?`, 1)
425 //queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'") 425 //queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
426 queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid'") 426 queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid'")
@@ -459,7 +459,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -459,7 +459,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
459 queryContributionsWith = queryContributionsWith.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid") 459 queryContributionsWith = queryContributionsWith.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
460 queryContributionsWith = queryContributionsWith.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name") 460 queryContributionsWith = queryContributionsWith.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
461 queryContributionsWith = queryContributionsWith.ColumnExpr("sum(case WHEN su_money_transaction_record.record_type IN (2, 3) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type = 4 THEN su_money_transaction_record.su_money ELSE 0 end) AS employees_contributions") 461 queryContributionsWith = queryContributionsWith.ColumnExpr("sum(case WHEN su_money_transaction_record.record_type IN (2, 3) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type = 4 THEN su_money_transaction_record.su_money ELSE 0 end) AS employees_contributions")
462 - queryContributionsWith = queryContributionsWith.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(case WHEN su_money_transaction_record.record_type IN (2, 3) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type = 4 THEN su_money_transaction_record.su_money ELSE 0 end) DESC) AS ranking") 462 + queryContributionsWith = queryContributionsWith.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(case WHEN su_money_transaction_record.record_type IN (2, 3) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type = 4 THEN su_money_transaction_record.su_money ELSE 0 end) DESC), e.create_time AS ranking")
463 queryContributionsWith = queryContributionsWith.Where(`e.status = ?`, 1) 463 queryContributionsWith = queryContributionsWith.Where(`e.status = ?`, 1)
464 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 464 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
465 queryContributionsWith = queryContributionsWith.Where("e.company_id = ?", companyId) 465 queryContributionsWith = queryContributionsWith.Where("e.company_id = ?", companyId)
@@ -2,10 +2,8 @@ package domain_service @@ -2,10 +2,8 @@ package domain_service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 - "github.com/linmadan/egglib-go/core/application"  
6 coreDomain "github.com/linmadan/egglib-go/core/domain" 5 coreDomain "github.com/linmadan/egglib-go/core/domain"
7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
8 - "github.com/linmadan/egglib-go/utils/tool_funs"  
9 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" 7 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
10 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/event" 8 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/event"
11 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao" 9 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
@@ -22,7 +20,7 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 @@ -22,7 +20,7 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64
22 var employeeRepository domain.EmployeeRepository 20 var employeeRepository domain.EmployeeRepository
23 var taskRepository domain.TaskRepository 21 var taskRepository domain.TaskRepository
24 var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository 22 var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
25 - var cashPoolRepository domain.CashPoolRepository 23 + //var cashPoolRepository domain.CashPoolRepository
26 24
27 var employeeDao *dao.EmployeeDao 25 var employeeDao *dao.EmployeeDao
28 if repository, err := repository.NewEmployeeRepository(service.transactionContext); err != nil { 26 if repository, err := repository.NewEmployeeRepository(service.transactionContext); err != nil {
@@ -40,11 +38,11 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 @@ -40,11 +38,11 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64
40 } else { 38 } else {
41 suMoneyTransactionRecordRepository = repository 39 suMoneyTransactionRecordRepository = repository
42 } 40 }
43 - if repository, err := repository.NewCashPoolRepository(service.transactionContext); err != nil {  
44 - return nil, err  
45 - } else {  
46 - cashPoolRepository = repository  
47 - } 41 + //if repository, err := repository.NewCashPoolRepository(service.transactionContext); err != nil {
  42 + // return nil, err
  43 + //} else {
  44 + // cashPoolRepository = repository
  45 + //}
48 if dao, err := dao.NewEmployeeDao(service.transactionContext); err != nil { 46 if dao, err := dao.NewEmployeeDao(service.transactionContext); err != nil {
49 return nil, err 47 return nil, err
50 } else { 48 } else {
@@ -136,40 +134,40 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 @@ -136,40 +134,40 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64
136 return nil, err 134 return nil, err
137 } 135 }
138 136
139 - // 更新现金池未兑换素币  
140 - cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{  
141 - "companyId": task.CompanyId,  
142 - })  
143 - if err != nil {  
144 - return nil, err  
145 - }  
146 - if cashPoolFound != nil {  
147 - // 获取平台素币兑换情况  
148 - systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(task.CompanyId)  
149 - if err != nil {  
150 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
151 - }  
152 - if systemSuMoneyStatistics == nil {  
153 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")  
154 - }  
155 - systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)  
156 - cashPool := &domain.CashPool{  
157 - Cash: cashPoolFound.Cash,  
158 - CompanyId: cashPoolFound.CompanyId,  
159 - ExchangedCash: cashPoolFound.ExchangedCash,  
160 - UnExchangeCash: cashPoolFound.UnExchangeCash,  
161 - ExchangedSuMoney: cashPoolFound.ExchangedSuMoney,  
162 - UnExchangeSuMoney: systemUnExchangeSuMoney,  
163 - Rate: cashPoolFound.Rate,  
164 - LastRate: cashPoolFound.LastRate,  
165 - }  
166 - if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(cashPool)); err != nil {  
167 - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())  
168 - }  
169 - if _, err := cashPoolRepository.Save(cashPool); err != nil {  
170 - return nil, err  
171 - }  
172 - } 137 + //// 更新现金池未兑换素币
  138 + //cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
  139 + // "companyId": task.CompanyId,
  140 + //})
  141 + //if err != nil {
  142 + // return nil, err
  143 + //}
  144 + //if cashPoolFound != nil {
  145 + // // 获取平台素币兑换情况
  146 + // systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(task.CompanyId)
  147 + // if err != nil {
  148 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  149 + // }
  150 + // if systemSuMoneyStatistics == nil {
  151 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
  152 + // }
  153 + // systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
  154 + // cashPool := &domain.CashPool{
  155 + // Cash: cashPoolFound.Cash,
  156 + // CompanyId: cashPoolFound.CompanyId,
  157 + // ExchangedCash: cashPoolFound.ExchangedCash,
  158 + // UnExchangeCash: cashPoolFound.UnExchangeCash,
  159 + // ExchangedSuMoney: cashPoolFound.ExchangedSuMoney,
  160 + // UnExchangeSuMoney: systemUnExchangeSuMoney,
  161 + // Rate: cashPoolFound.Rate,
  162 + // LastRate: cashPoolFound.LastRate,
  163 + // }
  164 + // if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(cashPool)); err != nil {
  165 + // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  166 + // }
  167 + // if _, err := cashPoolRepository.Save(cashPool); err != nil {
  168 + // return nil, err
  169 + // }
  170 + //}
173 } 171 }
174 if task, err := taskRepository.Save(task); err != nil { 172 if task, err := taskRepository.Save(task); err != nil {
175 return nil, err 173 return nil, err
1 package models 1 package models
2 2
  3 +import "time"
  4 +
3 type Employee struct { 5 type Employee struct {
4 TableName string `pg:"employees,alias:employee"` 6 TableName string `pg:"employees,alias:employee"`
5 // 员工ID 7 // 员工ID
@@ -22,4 +24,6 @@ type Employee struct { @@ -22,4 +24,6 @@ type Employee struct {
22 Status int `pg:",notnull,default:1"` 24 Status int `pg:",notnull,default:1"`
23 // 员工权限集合 25 // 员工权限集合
24 Permissions []int `pg:",array"` 26 Permissions []int `pg:",array"`
  27 + // 创建时间
  28 + CreateTime time.Time
25 } 29 }