作者 陈志颖

test:支出素币

... ... @@ -207,8 +207,8 @@ func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interf
// 计算个人素币收支(素币明细收支)
func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transactionStartTime time.Time, transactionEndTime time.Time) (map[string]interface{}, error) {
var (
incomeSuMoney float64 // 收入的素币(2:任务奖励,3:增加 6: 兑换素币撤回)
expendSuMoney float64 // 消耗的素币(1:兑换物资,4:扣除,5:兑换现金)
incomeSuMoney float64 // 收入的素币(2:任务奖励,3:增加)
expendSuMoney float64 // 消耗的素币(1:兑换物资,4:扣除)
expendSuMoneyExchange float64 // 5: 兑换现金
incomeSuMoneyExchangeRestore float64 // 6: 兑换素币撤回
)
... ... @@ -218,7 +218,7 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction
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 IN (?)`, pg.In([]int{2, 3})).
Where(`su_money_transaction_record.create_time > ?`, transactionStartTime).
Where(`su_money_transaction_record.create_time < ?`, transactionEndTime).
Select(&incomeSuMoney); err != nil {
... ... @@ -238,7 +238,7 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction
if err := tx.Model(suMoneyTransactionRecordModel).
ColumnExpr("sum(su_money_transaction_record.su_money) AS expend_su_money").
Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
Where(`su_money_transaction_record.record_type =?`, 5).
Where(`su_money_transaction_record.record_type = ?`, 5).
Where(`su_money_transaction_record.create_time > ?`, transactionStartTime).
Where(`su_money_transaction_record.create_time < ?`, transactionEndTime).
Select(&expendSuMoneyExchange); err != nil {
... ... @@ -255,8 +255,8 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction
return nil, err
}
return map[string]interface{}{
"incomeSuMoney": incomeSuMoney, // 个人素币收入
"expendSuMoney": expendSuMoney + expendSuMoneyExchange - incomeSuMoneyExchangeRestore, // 个人素币支出
"incomeSuMoney": incomeSuMoney + incomeSuMoneyExchangeRestore, // 个人素币收入
"expendSuMoney": expendSuMoney, // 个人素币支出
}, nil
}
... ...