作者 陈志颖

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

@@ -1307,6 +1307,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1307,6 +1307,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1307 getEmployee := map[string]interface{}{ 1307 getEmployee := map[string]interface{}{
1308 "account": createExchangeCashPersonCommand.PersonAccount, 1308 "account": createExchangeCashPersonCommand.PersonAccount,
1309 "companyId": activityFound.CompanyId, 1309 "companyId": activityFound.CompanyId,
  1310 + "status": 1,
1310 } 1311 }
1311 1312
1312 // 判断当前员工是否有效 1313 // 判断当前员工是否有效
@@ -1808,6 +1809,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -1808,6 +1809,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
1808 getEmployee := map[string]interface{}{ 1809 getEmployee := map[string]interface{}{
1809 "uid": createExchangeCashPersonCommand.Uid, 1810 "uid": createExchangeCashPersonCommand.Uid,
1810 "companyId": activityFound.CompanyId, 1811 "companyId": activityFound.CompanyId,
  1812 + "status": 1,
1811 } 1813 }
1812 1814
1813 // 判断当前员工是否有效 1815 // 判断当前员工是否有效
@@ -92,9 +92,7 @@ func (dao *EmployeeDao) CalculatePersonUnReadNotification(uid int64) (map[string @@ -92,9 +92,7 @@ func (dao *EmployeeDao) CalculatePersonUnReadNotification(uid int64) (map[string
92 // 计算个人素币收益,昨日收益:做任务验收获得的素币+额外增加-扣除素币-兑换物资-兑换现金 92 // 计算个人素币收益,昨日收益:做任务验收获得的素币+额外增加-扣除素币-兑换物资-兑换现金
93 func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{}, error) { 93 func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{}, error) {
94 var incomeSuMoney float64 94 var incomeSuMoney float64
95 - //var expendSuMoney float64  
96 var incomeSuMoneyOfYesterday float64 95 var incomeSuMoneyOfYesterday float64
97 - //var expendSuMoneyOfYesterday float64  
98 tx := dao.transactionContext.PgTx 96 tx := dao.transactionContext.PgTx
99 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord) 97 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
100 yesterday := time.Now().Local().AddDate(0, 0, -1) 98 yesterday := time.Now().Local().AddDate(0, 0, -1)
@@ -102,41 +100,20 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{ @@ -102,41 +100,20 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{
102 if err := tx.Model(suMoneyTransactionRecordModel). 100 if err := tx.Model(suMoneyTransactionRecordModel).
103 ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money"). 101 ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
104 Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid). 102 Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
105 - //Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})).  
106 Where(`su_money_transaction_record.record_type = ?`, 2). 103 Where(`su_money_transaction_record.record_type = ?`, 2).
107 Where(`su_money_transaction_record.create_time > ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 0, 0, 0, 0, yesterday.Location())). 104 Where(`su_money_transaction_record.create_time > ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 0, 0, 0, 0, yesterday.Location())).
108 Where(`su_money_transaction_record.create_time < ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 23, 59, 59, 0, yesterday.Location())). 105 Where(`su_money_transaction_record.create_time < ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 23, 59, 59, 0, yesterday.Location())).
109 Select(&incomeSuMoneyOfYesterday); err != nil { 106 Select(&incomeSuMoneyOfYesterday); err != nil {
110 return nil, err 107 return nil, err
111 } 108 }
112 - //// 昨日支出  
113 - //if err := tx.Model(suMoneyTransactionRecordModel).  
114 - // ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").  
115 - // Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).  
116 - // //Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{1, 4, 5})).  
117 - // Where(`su_money_transaction_record.record_type = ?`, 2).  
118 - // Where(`su_money_transaction_record.create_time > ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 0, 0, 0, 0, yesterday.Location())).  
119 - // Where(`su_money_transaction_record.create_time < ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 23, 59, 59, 0, yesterday.Location())).  
120 - // Select(&expendSuMoneyOfYesterday); err != nil {  
121 - // return nil, err  
122 - //}  
123 // 收益 109 // 收益
124 if err := tx.Model(suMoneyTransactionRecordModel). 110 if err := tx.Model(suMoneyTransactionRecordModel).
125 ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money"). 111 ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
126 Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid). 112 Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
127 - //Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3, 6})).  
128 Where(`su_money_transaction_record.record_type = ?`, 2). 113 Where(`su_money_transaction_record.record_type = ?`, 2).
129 Select(&incomeSuMoney); err != nil { 114 Select(&incomeSuMoney); err != nil {
130 return nil, err 115 return nil, err
131 } 116 }
132 - //// 支出  
133 - //if err := tx.Model(suMoneyTransactionRecordModel).  
134 - // ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").  
135 - // Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).  
136 - // Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{1, 4, 5})).  
137 - // Select(&expendSuMoney); err != nil {  
138 - // return nil, err  
139 - //}  
140 return map[string]interface{}{ 117 return map[string]interface{}{
141 "incomeSuMoney": incomeSuMoney, 118 "incomeSuMoney": incomeSuMoney,
142 "incomeSuMoneyOfYesterday": incomeSuMoneyOfYesterday, 119 "incomeSuMoneyOfYesterday": incomeSuMoneyOfYesterday,
@@ -69,7 +69,9 @@ func (repository *EmployeeRepository) FindOne(queryOptions map[string]interface{ @@ -69,7 +69,9 @@ func (repository *EmployeeRepository) FindOne(queryOptions map[string]interface{
69 if companyId, ok := queryOptions["companyId"]; ok { 69 if companyId, ok := queryOptions["companyId"]; ok {
70 query = query.Where("employee.company_id = ?", companyId) 70 query = query.Where("employee.company_id = ?", companyId)
71 } 71 }
72 - query = query.Where(`employee.status = ?`, 1) // 筛除已离职员工 72 + if status, ok := queryOptions["status"]; ok {
  73 + query = query.Where(`employee.status = ?`, status) // 筛除已离职员工
  74 + }
73 if err := query.First(); err != nil { 75 if err := query.First(); err != nil {
74 if err.Error() == "pg: no rows in result set" { 76 if err.Error() == "pg: no rows in result set" {
75 return nil, fmt.Errorf("没有此员工") 77 return nil, fmt.Errorf("没有此员工")
@@ -137,7 +139,7 @@ func (repository *EmployeeRepository) Find(queryOptions map[string]interface{}) @@ -137,7 +139,7 @@ func (repository *EmployeeRepository) Find(queryOptions map[string]interface{})
137 query = query.Where("employee.company_id = ?", companyId) 139 query = query.Where("employee.company_id = ?", companyId)
138 } 140 }
139 } 141 }
140 - query = query.Where(`employee.status = ?`, 1) 142 + //query = query.Where(`employee.status = ?`, 1)
141 if isPrincipal, ok := queryOptions["isPrincipal"]; ok && isPrincipal.(bool) != false { 143 if isPrincipal, ok := queryOptions["isPrincipal"]; ok && isPrincipal.(bool) != false {
142 query = query.Where("employee.is_principal = ? ", isPrincipal) 144 query = query.Where("employee.is_principal = ? ", isPrincipal)
143 } 145 }