Bladeren bron

add 查询绿色能量、活跃积分

tags/v0.0.2
shenjiachi 2 weken geleden
bovenliggende
commit
5475b310cc
7 gewijzigde bestanden met toevoegingen van 71 en 2 verwijderingen
  1. +2
    -0
      src/dao/user_virtual_amount_dao.go
  2. +1
    -0
      src/dao/user_virtual_coin_flow_dao.go
  3. +3
    -0
      src/dao/virtual_coin_dao.go
  4. +2
    -2
      src/implement/public_platoon_free_punish_with_user_implement.go
  5. +25
    -0
      src/implement/user_virtual_amount_implement.go
  6. +21
    -0
      src/implement/user_virtual_coin_flow_implement.go
  7. +17
    -0
      src/implement/virtual_coin_implement.go

+ 2
- 0
src/dao/user_virtual_amount_dao.go Bestand weergeven

@@ -6,4 +6,6 @@ import (

type UserVirtualAmountDao interface {
GetUserVirtualWalletBySession(uid int64, coinId int) (*model.UserVirtualAmount, error)
UserVirtualAmountFindAndCountByCoinKind(coinID int, page, pageSize int) ([]model.UserVirtualAmount, int64, error)
UserVirtualAmountGetSumByCoinKind(coinId int) (float64, error)
}

+ 1
- 0
src/dao/user_virtual_coin_flow_dao.go Bestand weergeven

@@ -7,4 +7,5 @@ import (

type UserVirtualCoinFlowDao interface {
UserVirtualCoinFlowInsertBySession(session *xorm.Session, UserVirtualCoinFlow *model.UserVirtualCoinFlow) (int64, error)
UserVirtualCoinFlowFindByCoinAndUser(page, pageSize int, coinID int, uid int64, startAt string, endAt string, direction int) ([]model.UserVirtualCoinFlow, int64, error)
}

+ 3
- 0
src/dao/virtual_coin_dao.go Bestand weergeven

@@ -1,5 +1,8 @@
package dao

import "code.fnuoos.com/EggPlanet/egg_models.git/src/model"

type VirtualCoinDao interface {
//TODO:: You can add specific method definitions here
VirtualCoinFindAllAndCount(pageSize, page int) (kindList []model.VirtualCoin, total int64, err error)
}

+ 2
- 2
src/implement/public_platoon_free_punish_with_user_implement.go Bestand weergeven

@@ -66,9 +66,9 @@ func (p PublicPlatoonFreePunishWithUserDb) PublicPlatoonFreePunishWithUserCountA
var err1 error
if params != nil {
query := fmt.Sprintf("%s = ?", params["key"])
err1 = session.Where(query, params["value"]).Limit(limit, page-1).Find(&m)
err1 = session.Where(query, params["value"]).Limit(limit, (page-1)*limit).Find(&m)
} else {
err1 = session.Where("1=1").Limit(limit, page-1).Find(&m)
err1 = session.Where("1=1").Limit(limit, (page-1)*limit).Find(&m)
}
if err1 != nil {
return nil, 0, zhios_order_relate_logx.Error(err1)


+ 25
- 0
src/implement/user_virtual_amount_implement.go Bestand weergeven

@@ -3,6 +3,7 @@
import (
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx"
"xorm.io/xorm"
)

@@ -33,3 +34,27 @@ func (u UserVirtualAmountDb) GetUserVirtualWalletBySession(uid int64, coinId int
return &UserVirtualWallet, nil
}
}

func (u UserVirtualAmountDb) UserVirtualAmountFindAndCountByCoinKind(coinID int, page, pageSize int) ([]model.UserVirtualAmount, int64, error) {
var userVirtualWallets []model.UserVirtualAmount
session := u.Db.Where("coin_id = ?", coinID)
total, err1 := session.Count(&userVirtualWallets)
if err1 != nil {
return nil, 0, zhios_order_relate_logx.Error(err1.Error())
}

err := session.Limit(pageSize, (page-1)*pageSize).Desc("amount").Find(&userVirtualWallets)
if err != nil {
return nil, 0, zhios_order_relate_logx.Error(err.Error())
}
return userVirtualWallets, total, nil
}

func (u UserVirtualAmountDb) UserVirtualAmountGetSumByCoinKind(coinId int) (float64, error) {
var m model.UserVirtualAmount
sum, err := u.Db.Where("coin_id = ?", coinId).Sum(m, "amount")
if err != nil {
return 0, zhios_order_relate_logx.Error(err.Error())
}
return sum, nil
}

+ 21
- 0
src/implement/user_virtual_coin_flow_implement.go Bestand weergeven

@@ -3,6 +3,7 @@
import (
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx"
"xorm.io/xorm"
)

@@ -21,3 +22,23 @@ func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowInsertBySession(session *xorm.
}
return UserVirtualCoinFlow.Id, nil
}

func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowFindByCoinAndUser(page, pageSize int, coinID int, uid int64, startAt string, endAt string, direction int) ([]model.UserVirtualCoinFlow, int64, error) {
var m []model.UserVirtualCoinFlow
session := u.Db.Where("uid = ?", uid).And("coin_id = ?", coinID).And("create_at > ?", startAt).And("create_at < ?", endAt)
if direction != 0 {
session = session.And("direction = ?", direction)
}

total, err1 := session.Count(&m)
if err1 != nil {
return nil, 0, zhios_order_relate_logx.Error(err1.Error())
}

err2 := session.Limit(pageSize, (page-1)*pageSize).Desc("create_at").Find(m)
if err2 != nil {
return nil, 0, err2
}

return m, total, nil
}

+ 17
- 0
src/implement/virtual_coin_implement.go Bestand weergeven

@@ -2,6 +2,8 @@

import (
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx"
"xorm.io/xorm"
)

@@ -12,3 +14,18 @@ func NewVirtualCoinDb(engine *xorm.Engine) dao.VirtualCoinDao {
type VirtualCoinDb struct {
Db *xorm.Engine
}

func (v VirtualCoinDb) VirtualCoinFindAllAndCount(pageSize, page int) (kindList []model.VirtualCoin, total int64, err error) {
var m []model.VirtualCoin
session := v.Db.Where("is_use = ?", 1)
total, err = session.Count(&m)
if err != nil {
return nil, 0, err
}

err = session.Asc("id").Limit(pageSize, (page-1)*pageSize).Find(&m)
if err != nil {
return nil, 0, zhios_order_relate_logx.Error(err)
}
return m, total, nil
}

Laden…
Annuleren
Opslaan