作者 陈志颖

fix:个人贡献值修复

... ... @@ -334,7 +334,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
}
tx := dao.transactionContext.PgTx
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
// 财富值排行榜
... ... @@ -421,8 +420,8 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
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")
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")
//queryContributions = queryContributions.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3}))
queryContributions = queryContributions.Where(`e.status = ?`, 1)
queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryContributions = queryContributions.Where("e.company_id = ?", companyId)
}
... ... @@ -432,7 +431,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
if endTime, ok := queryOptions["endTime"]; ok && !endTime.(time.Time).IsZero() {
queryContributions = queryContributions.Where(`su_money_transaction_record.create_time < ?`, endTime)
}
queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
if offset, ok := queryOptions["offset"]; ok {
offset := offset.(int)
if offset > -1 {
... ... @@ -460,7 +458,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
queryContributionsWith = queryContributionsWith.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
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")
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")
//queryContributionsWith = queryContributionsWith.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3}))
queryContributionsWith = queryContributionsWith.Where(`e.status = ?`, 1)
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryContributionsWith = queryContributionsWith.Where("e.company_id = ?", companyId)
... ... @@ -471,7 +468,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
if endTime, ok := queryOptions["endTime"]; ok && !endTime.(time.Time).IsZero() {
queryContributionsWith = queryContributionsWith.Where(`su_money_transaction_record.create_time < ?`, endTime)
}
contributionsWith := queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
contributionsWith := queryContributionsWith.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
querySelfContributions := tx.Model()
querySelfContributions = querySelfContributions.With("t", contributionsWith)
querySelfContributions = querySelfContributions.Table("t")
... ...
... ... @@ -137,13 +137,13 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64
}
// 更新现金池未兑换素币
_, cashPoolFound, err := cashPoolRepository.Find(map[string]interface{}{
cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
"companyId": task.CompanyId,
})
if err != nil {
return nil, err
}
if len(cashPoolFound) > 0 {
if cashPoolFound != nil {
// 获取平台素币兑换情况
systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(task.CompanyId)
if err != nil {
... ... @@ -153,30 +153,25 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
}
systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
// 现金池更新命令
cashPool := &domain.CashPool{
Cash: cashPoolFound[0].Cash,
CompanyId: cashPoolFound[0].CompanyId,
ExchangedCash: cashPoolFound[0].ExchangedCash,
UnExchangeCash: cashPoolFound[0].UnExchangeCash,
ExchangedSuMoney: cashPoolFound[0].ExchangedSuMoney,
Cash: cashPoolFound.Cash,
CompanyId: cashPoolFound.CompanyId,
ExchangedCash: cashPoolFound.ExchangedCash,
UnExchangeCash: cashPoolFound.UnExchangeCash,
ExchangedSuMoney: cashPoolFound.ExchangedSuMoney,
UnExchangeSuMoney: systemUnExchangeSuMoney,
Rate: cashPoolFound[0].Rate,
LastRate: cashPoolFound[0].LastRate,
Rate: cashPoolFound.Rate,
LastRate: cashPoolFound.LastRate,
}
// 更新现金池
if err := cashPoolFound[0].Update(tool_funs.SimpleStructToMap(cashPool)); err != nil {
if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(cashPool)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
// 保存现金池更新
if _, err := cashPoolRepository.Save(cashPool); err != nil {
return nil, err
}
}
}
if task, err := taskRepository.Save(task); err != nil {
if task, err := taskRepository.Save(task); err != nil {
return nil, err
} else {
taskAcceptancedEvent := new(event.TaskAcceptanced)
... ...