作者 陈志颖

fix:个人贡献值修复

@@ -334,7 +334,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -334,7 +334,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
334 } 334 }
335 335
336 tx := dao.transactionContext.PgTx 336 tx := dao.transactionContext.PgTx
337 -  
338 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord) 337 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
339 338
340 // 财富值排行榜 339 // 财富值排行榜
@@ -421,8 +420,8 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -421,8 +420,8 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
421 queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name") 420 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") 421 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") 422 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")
424 - //queryContributions = queryContributions.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3}))  
425 queryContributions = queryContributions.Where(`e.status = ?`, 1) 423 queryContributions = queryContributions.Where(`e.status = ?`, 1)
  424 + queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
426 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 425 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
427 queryContributions = queryContributions.Where("e.company_id = ?", companyId) 426 queryContributions = queryContributions.Where("e.company_id = ?", companyId)
428 } 427 }
@@ -432,7 +431,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -432,7 +431,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
432 if endTime, ok := queryOptions["endTime"]; ok && !endTime.(time.Time).IsZero() { 431 if endTime, ok := queryOptions["endTime"]; ok && !endTime.(time.Time).IsZero() {
433 queryContributions = queryContributions.Where(`su_money_transaction_record.create_time < ?`, endTime) 432 queryContributions = queryContributions.Where(`su_money_transaction_record.create_time < ?`, endTime)
434 } 433 }
435 - queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")  
436 if offset, ok := queryOptions["offset"]; ok { 434 if offset, ok := queryOptions["offset"]; ok {
437 offset := offset.(int) 435 offset := offset.(int)
438 if offset > -1 { 436 if offset > -1 {
@@ -460,7 +458,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -460,7 +458,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
460 queryContributionsWith = queryContributionsWith.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name") 458 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") 459 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") 460 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")
463 - //queryContributionsWith = queryContributionsWith.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3}))  
464 queryContributionsWith = queryContributionsWith.Where(`e.status = ?`, 1) 461 queryContributionsWith = queryContributionsWith.Where(`e.status = ?`, 1)
465 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 462 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
466 queryContributionsWith = queryContributionsWith.Where("e.company_id = ?", companyId) 463 queryContributionsWith = queryContributionsWith.Where("e.company_id = ?", companyId)
@@ -471,7 +468,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -471,7 +468,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
471 if endTime, ok := queryOptions["endTime"]; ok && !endTime.(time.Time).IsZero() { 468 if endTime, ok := queryOptions["endTime"]; ok && !endTime.(time.Time).IsZero() {
472 queryContributionsWith = queryContributionsWith.Where(`su_money_transaction_record.create_time < ?`, endTime) 469 queryContributionsWith = queryContributionsWith.Where(`su_money_transaction_record.create_time < ?`, endTime)
473 } 470 }
474 - contributionsWith := queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'") 471 + contributionsWith := queryContributionsWith.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
475 querySelfContributions := tx.Model() 472 querySelfContributions := tx.Model()
476 querySelfContributions = querySelfContributions.With("t", contributionsWith) 473 querySelfContributions = querySelfContributions.With("t", contributionsWith)
477 querySelfContributions = querySelfContributions.Table("t") 474 querySelfContributions = querySelfContributions.Table("t")
@@ -137,13 +137,13 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 @@ -137,13 +137,13 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64
137 } 137 }
138 138
139 // 更新现金池未兑换素币 139 // 更新现金池未兑换素币
140 - _, cashPoolFound, err := cashPoolRepository.Find(map[string]interface{}{ 140 + cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
141 "companyId": task.CompanyId, 141 "companyId": task.CompanyId,
142 }) 142 })
143 if err != nil { 143 if err != nil {
144 return nil, err 144 return nil, err
145 } 145 }
146 - if len(cashPoolFound) > 0 { 146 + if cashPoolFound != nil {
147 // 获取平台素币兑换情况 147 // 获取平台素币兑换情况
148 systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(task.CompanyId) 148 systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(task.CompanyId)
149 if err != nil { 149 if err != nil {
@@ -153,30 +153,25 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64 @@ -153,30 +153,25 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64
153 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司") 153 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
154 } 154 }
155 systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) 155 systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
156 -  
157 - // 现金池更新命令  
158 cashPool := &domain.CashPool{ 156 cashPool := &domain.CashPool{
159 - Cash: cashPoolFound[0].Cash,  
160 - CompanyId: cashPoolFound[0].CompanyId,  
161 - ExchangedCash: cashPoolFound[0].ExchangedCash,  
162 - UnExchangeCash: cashPoolFound[0].UnExchangeCash,  
163 - ExchangedSuMoney: cashPoolFound[0].ExchangedSuMoney, 157 + Cash: cashPoolFound.Cash,
  158 + CompanyId: cashPoolFound.CompanyId,
  159 + ExchangedCash: cashPoolFound.ExchangedCash,
  160 + UnExchangeCash: cashPoolFound.UnExchangeCash,
  161 + ExchangedSuMoney: cashPoolFound.ExchangedSuMoney,
164 UnExchangeSuMoney: systemUnExchangeSuMoney, 162 UnExchangeSuMoney: systemUnExchangeSuMoney,
165 - Rate: cashPoolFound[0].Rate,  
166 - LastRate: cashPoolFound[0].LastRate, 163 + Rate: cashPoolFound.Rate,
  164 + LastRate: cashPoolFound.LastRate,
167 } 165 }
168 - // 更新现金池  
169 - if err := cashPoolFound[0].Update(tool_funs.SimpleStructToMap(cashPool)); err != nil { 166 + if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(cashPool)); err != nil {
170 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 167 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
171 } 168 }
172 -  
173 - // 保存现金池更新  
174 if _, err := cashPoolRepository.Save(cashPool); err != nil { 169 if _, err := cashPoolRepository.Save(cashPool); err != nil {
175 return nil, err 170 return nil, err
176 } 171 }
177 } 172 }
178 } 173 }
179 - if task, err := taskRepository.Save(task); err != nil { 174 + if task, err := taskRepository.Save(task); err != nil {
180 return nil, err 175 return nil, err
181 } else { 176 } else {
182 taskAcceptancedEvent := new(event.TaskAcceptanced) 177 taskAcceptancedEvent := new(event.TaskAcceptanced)