...
|
...
|
@@ -115,8 +115,8 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{ |
|
|
}
|
|
|
|
|
|
func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transactionStartTime time.Time, transactionEndTime time.Time) (map[string]interface{}, error) {
|
|
|
var incomeSuMoney float64
|
|
|
var expendSuMoney float64
|
|
|
var incomeSuMoney float64 // 收入的素币(2:任务奖励,3:增加)
|
|
|
var expendSuMoney float64 // 消耗的素币(1:兑换(物资、现金),4: 扣除)
|
|
|
tx := dao.transactionContext.PgTx
|
|
|
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
|
|
|
if err := tx.Model(suMoneyTransactionRecordModel).
|
...
|
...
|
@@ -143,40 +143,47 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction |
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
func (dao *EmployeeDao) CalculateSystemUnChangeSuMoney(companyId int64) (map[string]interface{}, error) {
|
|
|
var unExchangeSuMoney float64
|
|
|
// 计算系统素币
|
|
|
func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) ( float64, float64, error) {
|
|
|
var systemUnExchangeSuMoney float64
|
|
|
var systemExchangedSuMoney float64
|
|
|
|
|
|
tx := dao.transactionContext.PgTx
|
|
|
employeeModel := new(models.Employee)
|
|
|
|
|
|
employeeModel := new(models.Employee)
|
|
|
if err := tx.Model(employeeModel).
|
|
|
ColumnExpr("sum(employee.su_money) AS unExchangeSuMoney").
|
|
|
ColumnExpr("sum(employee.su_money) AS system_unExchange_su_money").
|
|
|
Where("employee.company_id = ?", companyId).
|
|
|
Select(&employeeModel); err != nil {
|
|
|
return nil, err
|
|
|
Select(&systemUnExchangeSuMoney); err != nil {
|
|
|
return 0, 0, err
|
|
|
}
|
|
|
|
|
|
return map[string]interface{}{
|
|
|
"unExchangeSuMoney": unExchangeSuMoney,
|
|
|
}, nil
|
|
|
exchangeCashActivityModel := new(models.ExchangeCashActivity)
|
|
|
if err := tx.Model(exchangeCashActivityModel).
|
|
|
ColumnExpr("sum(exchange_cash_activity.exchanged_su_money) AS system_changed_su_money").
|
|
|
Where("exchange_cash_activity.company_id = ?", companyId).
|
|
|
Select(&systemExchangedSuMoney); err != nil {
|
|
|
return 0, 0, err
|
|
|
}
|
|
|
|
|
|
return systemUnExchangeSuMoney, systemExchangedSuMoney, nil
|
|
|
}
|
|
|
|
|
|
func (dao *EmployeeDao) CalculateSystemExchangedCash(companyId int64) (map[string]interface{}, error) {
|
|
|
var exchangedCash float64
|
|
|
// 计算系统已兑换现金
|
|
|
func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (float64, error) {
|
|
|
var systemExchangedCash float64 // 系统已兑换现金
|
|
|
|
|
|
tx := dao.transactionContext.PgTx
|
|
|
suMoneyExchangeTransactionRecordModel := new(models.SuMoneyExchangeTransactionRecord)
|
|
|
exchangeCashActivityModel := new(models.ExchangeCashActivity)
|
|
|
|
|
|
if err := tx.Model(suMoneyExchangeTransactionRecordModel).
|
|
|
ColumnExpr("sum(su_money_exchange_transaction_record.cash) AS exchangedCash").
|
|
|
Where("su_money_exchange_transaction_record.company_id = ?", companyId).
|
|
|
Select(&suMoneyExchangeTransactionRecordModel) ; err != nil {
|
|
|
return nil, err
|
|
|
if err := tx.Model(exchangeCashActivityModel).
|
|
|
ColumnExpr("sum(exchange_cash_activity.exchanged_cash) AS system_exchanged_cash").
|
|
|
Where("exchange_cash_activity.company_id = ?", companyId).
|
|
|
Select(&systemExchangedCash) ; err != nil {
|
|
|
return 0, err
|
|
|
}
|
|
|
|
|
|
return map[string]interface{}{
|
|
|
"exchangedCash": exchangedCash,
|
|
|
}, nil
|
|
|
return systemExchangedCash, nil
|
|
|
}
|
|
|
|
|
|
func NewEmployeeDao(transactionContext *pgTransaction.TransactionContext) (*EmployeeDao, error) {
|
...
|
...
|
|