作者 陈志颖

fix:去除验收任务现金池

... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"time"
"github.com/astaxie/beego/validation"
)
... ... @@ -15,6 +16,8 @@ type CreateEmployeeCommand struct {
EmployeeAccount string `json:"employeeAccount,omitempty"`
// 员工头像URL
EmployeeAvatarUrl string `json:"employeeAvatarUrl,omitempty"`
// 创建时间
CreateTime time.Time `json:"createTime"`
}
func (createEmployeeCommand *CreateEmployeeCommand) ValidateCommand() error {
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"time"
"github.com/astaxie/beego/validation"
)
... ... @@ -9,6 +10,8 @@ import (
type RemoveEmployeeCommand struct {
// 统一用户UID
Uid int64 `json:"uid" valid:"Required"`
// 创建时间
CreateTime time.Time `json:"createTime"`
}
func (removeEmployeeCommand *RemoveEmployeeCommand) ValidateCommand() error {
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"time"
"github.com/astaxie/beego/validation"
)
... ... @@ -17,6 +18,8 @@ type UpdateEmployeeCommand struct {
EmployeeAvatarUrl string `json:"employeeAvatarUrl,omitempty"`
// 员工权限集合
Permissions []int `json:"permissions,omitempty"`
// 创建时间
CreateTime time.Time `json:"createTime"`
}
func (updateEmployeeCommand *UpdateEmployeeCommand) ValidateCommand() error {
... ...
package domain
import "time"
// 员工
type Employee struct {
// 员工ID
... ... @@ -14,6 +16,8 @@ type Employee struct {
Status int `json:"status"`
// 员工权限集合
Permissions []int `json:"permissions"`
// 创建时间
CreateTime time.Time `json:"createTime"`
}
type EmployeeRepository interface {
... ... @@ -50,6 +54,9 @@ func (employee *Employee) Update(data map[string]interface{}) error {
if permissions, ok := data["permissions"]; ok {
employee.Permissions = permissions.([]int)
}
if createTime, ok := data["createTime"]; ok && !createTime.(time.Time).IsZero() {
employee.CreateTime = createTime.(time.Time)
}
return nil
}
... ...
... ... @@ -342,7 +342,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
//queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
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")
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")
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")
queryWealth = queryWealth.Where(`e.status = ?`, 1)
//queryWealth = queryWealth.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
queryWealth = queryWealth.GroupExpr("su_money_transaction_record.employee->>'uid'")
... ... @@ -382,7 +382,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
queryWealthWith = queryWealthWith.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
queryWealthWith = queryWealthWith.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
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")
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")
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")
queryWealthWith = queryWealthWith.Where(`e.status = ?`, 1)
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryWealthWith = queryWealthWith.Where("e.company_id = ?", companyId)
... ... @@ -420,7 +420,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
//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.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")
queryContributions = queryContributions.Where(`e.status = ?`, 1)
//queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid'")
... ... @@ -459,7 +459,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
queryContributionsWith = queryContributionsWith.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
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.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")
queryContributionsWith = queryContributionsWith.Where(`e.status = ?`, 1)
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryContributionsWith = queryContributionsWith.Where("e.company_id = ?", companyId)
... ...
... ... @@ -2,10 +2,8 @@ package domain_service
import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/event"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
... ... @@ -22,7 +20,7 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64
var employeeRepository domain.EmployeeRepository
var taskRepository domain.TaskRepository
var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
var cashPoolRepository domain.CashPoolRepository
//var cashPoolRepository domain.CashPoolRepository
var employeeDao *dao.EmployeeDao
if repository, err := repository.NewEmployeeRepository(service.transactionContext); err != nil {
... ... @@ -40,11 +38,11 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64
} else {
suMoneyTransactionRecordRepository = repository
}
if repository, err := repository.NewCashPoolRepository(service.transactionContext); err != nil {
return nil, err
} else {
cashPoolRepository = repository
}
//if repository, err := repository.NewCashPoolRepository(service.transactionContext); err != nil {
// return nil, err
//} else {
// cashPoolRepository = repository
//}
if dao, err := dao.NewEmployeeDao(service.transactionContext); err != nil {
return nil, err
} else {
... ... @@ -136,40 +134,40 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64
return nil, err
}
// 更新现金池未兑换素币
cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
"companyId": task.CompanyId,
})
if err != nil {
return nil, err
}
if cashPoolFound != nil {
// 获取平台素币兑换情况
systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(task.CompanyId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if systemSuMoneyStatistics == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
}
systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
cashPool := &domain.CashPool{
Cash: cashPoolFound.Cash,
CompanyId: cashPoolFound.CompanyId,
ExchangedCash: cashPoolFound.ExchangedCash,
UnExchangeCash: cashPoolFound.UnExchangeCash,
ExchangedSuMoney: cashPoolFound.ExchangedSuMoney,
UnExchangeSuMoney: systemUnExchangeSuMoney,
Rate: cashPoolFound.Rate,
LastRate: cashPoolFound.LastRate,
}
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
}
}
//// 更新现金池未兑换素币
//cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
// "companyId": task.CompanyId,
//})
//if err != nil {
// return nil, err
//}
//if cashPoolFound != nil {
// // 获取平台素币兑换情况
// systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(task.CompanyId)
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
// if systemSuMoneyStatistics == nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
// }
// systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
// cashPool := &domain.CashPool{
// Cash: cashPoolFound.Cash,
// CompanyId: cashPoolFound.CompanyId,
// ExchangedCash: cashPoolFound.ExchangedCash,
// UnExchangeCash: cashPoolFound.UnExchangeCash,
// ExchangedSuMoney: cashPoolFound.ExchangedSuMoney,
// UnExchangeSuMoney: systemUnExchangeSuMoney,
// Rate: cashPoolFound.Rate,
// LastRate: cashPoolFound.LastRate,
// }
// 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 {
return nil, err
... ...
package models
import "time"
type Employee struct {
TableName string `pg:"employees,alias:employee"`
// 员工ID
... ... @@ -22,4 +24,6 @@ type Employee struct {
Status int `pg:",notnull,default:1"`
// 员工权限集合
Permissions []int `pg:",array"`
// 创建时间
CreateTime time.Time
}
... ...