作者 陈志颖

fix:新增兑换素币清单过滤离职员工

... ... @@ -1307,6 +1307,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
getEmployee := map[string]interface{}{
"account": createExchangeCashPersonCommand.PersonAccount,
"companyId": activityFound.CompanyId,
"status": 1,
}
// 判断当前员工是否有效
... ... @@ -1808,6 +1809,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
getEmployee := map[string]interface{}{
"uid": createExchangeCashPersonCommand.Uid,
"companyId": activityFound.CompanyId,
"status": 1,
}
// 判断当前员工是否有效
... ...
... ... @@ -92,9 +92,7 @@ func (dao *EmployeeDao) CalculatePersonUnReadNotification(uid int64) (map[string
// 计算个人素币收益,昨日收益:做任务验收获得的素币+额外增加-扣除素币-兑换物资-兑换现金
func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{}, error) {
var incomeSuMoney float64
//var expendSuMoney float64
var incomeSuMoneyOfYesterday float64
//var expendSuMoneyOfYesterday float64
tx := dao.transactionContext.PgTx
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
yesterday := time.Now().Local().AddDate(0, 0, -1)
... ... @@ -102,41 +100,20 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{
if err := tx.Model(suMoneyTransactionRecordModel).
ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
//Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})).
Where(`su_money_transaction_record.record_type = ?`, 2).
Where(`su_money_transaction_record.create_time > ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 0, 0, 0, 0, yesterday.Location())).
Where(`su_money_transaction_record.create_time < ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 23, 59, 59, 0, yesterday.Location())).
Select(&incomeSuMoneyOfYesterday); err != nil {
return nil, err
}
//// 昨日支出
//if err := tx.Model(suMoneyTransactionRecordModel).
// ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
// Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
// //Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{1, 4, 5})).
// Where(`su_money_transaction_record.record_type = ?`, 2).
// Where(`su_money_transaction_record.create_time > ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 0, 0, 0, 0, yesterday.Location())).
// Where(`su_money_transaction_record.create_time < ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 23, 59, 59, 0, yesterday.Location())).
// Select(&expendSuMoneyOfYesterday); err != nil {
// return nil, err
//}
// 收益
if err := tx.Model(suMoneyTransactionRecordModel).
ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
//Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3, 6})).
Where(`su_money_transaction_record.record_type = ?`, 2).
Select(&incomeSuMoney); err != nil {
return nil, err
}
//// 支出
//if err := tx.Model(suMoneyTransactionRecordModel).
// ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
// Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
// Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{1, 4, 5})).
// Select(&expendSuMoney); err != nil {
// return nil, err
//}
return map[string]interface{}{
"incomeSuMoney": incomeSuMoney,
"incomeSuMoneyOfYesterday": incomeSuMoneyOfYesterday,
... ...
... ... @@ -69,7 +69,9 @@ func (repository *EmployeeRepository) FindOne(queryOptions map[string]interface{
if companyId, ok := queryOptions["companyId"]; ok {
query = query.Where("employee.company_id = ?", companyId)
}
query = query.Where(`employee.status = ?`, 1) // 筛除已离职员工
if status, ok := queryOptions["status"]; ok {
query = query.Where(`employee.status = ?`, status) // 筛除已离职员工
}
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此员工")
... ... @@ -137,7 +139,7 @@ func (repository *EmployeeRepository) Find(queryOptions map[string]interface{})
query = query.Where("employee.company_id = ?", companyId)
}
}
query = query.Where(`employee.status = ?`, 1)
//query = query.Where(`employee.status = ?`, 1)
if isPrincipal, ok := queryOptions["isPrincipal"]; ok && isPrincipal.(bool) != false {
query = query.Where("employee.is_principal = ? ", isPrincipal)
}
... ...