...
|
...
|
@@ -98,17 +98,17 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{ |
|
|
tx := dao.transactionContext.PgTx
|
|
|
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
|
|
|
yesterday := time.Now().AddDate(0, 0, -1)
|
|
|
// 昨日收益
|
|
|
// 昨日总收益
|
|
|
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 IN (?)`, pg.In([]int{2, 3, 6})).
|
|
|
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).
|
...
|
...
|
@@ -122,7 +122,7 @@ 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 IN (?)`, pg.In([]int{2, 3, 6})).
|
|
|
Select(&incomeSuMoney); err != nil {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
@@ -180,7 +180,7 @@ func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] int |
|
|
},nil
|
|
|
}
|
|
|
|
|
|
// 计算系统已兑换现金、未兑换现金
|
|
|
// 计算现金池已兑换现金、未兑换现金
|
|
|
func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interface{}, error) {
|
|
|
tx := dao.transactionContext.PgTx
|
|
|
var (
|
...
|
...
|
@@ -220,7 +220,7 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction |
|
|
)
|
|
|
tx := dao.transactionContext.PgTx
|
|
|
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
|
|
|
// 收入素币
|
|
|
// 总收入素币
|
|
|
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).
|
...
|
...
|
@@ -230,7 +230,7 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction |
|
|
Select(&incomeSuMoney); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
// 支出素币
|
|
|
// 总支出素币
|
|
|
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).
|
...
|
...
|
@@ -241,20 +241,20 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction |
|
|
return nil, err
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
"incomeSuMoney": incomeSuMoney,
|
|
|
"expendSuMoney": expendSuMoney,
|
|
|
"incomeSuMoney": incomeSuMoney - expendSuMoney, // 个人素币盈利
|
|
|
"expendSuMoney": expendSuMoney, // 个人素币支出
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
// 计算个人贡献值收支
|
|
|
func (dao *EmployeeDao) CalculateContributionsTransactionRecord(uid int64, transactionStartTime time.Time, transactionEndTime time.Time) (map[string]interface{}, error) {
|
|
|
var (
|
|
|
incomeContributions float64 // 增加的贡献值(2:任务奖励,3:增加)
|
|
|
expendContributions float64 // 扣除的贡献值 (4: 扣除)
|
|
|
incomeContributions float64 // 收入的贡献值(2:任务奖励,3:增加)
|
|
|
expendContributions float64 // 支出的贡献值 (4: 扣除)
|
|
|
)
|
|
|
tx := dao.transactionContext.PgTx
|
|
|
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
|
|
|
// 增加的贡献值
|
|
|
// 总收入的贡献值
|
|
|
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).
|
...
|
...
|
@@ -264,7 +264,7 @@ func (dao *EmployeeDao) CalculateContributionsTransactionRecord(uid int64, trans |
|
|
Select(&incomeContributions); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
// 扣除的贡献值
|
|
|
// 总支出的贡献值
|
|
|
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).
|
...
|
...
|
@@ -275,8 +275,8 @@ func (dao *EmployeeDao) CalculateContributionsTransactionRecord(uid int64, trans |
|
|
return nil, err
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
"incomeContributions": incomeContributions,
|
|
|
"expendContributions": expendContributions,
|
|
|
"incomeContributions": incomeContributions - expendContributions, // 个人贡献值盈利
|
|
|
"expendContributions": expendContributions, // 个人贡献支出
|
|
|
}, nil
|
|
|
}
|
|
|
|
...
|
...
|
|