Browse Source

update

tags/v0.0.2
dengbiao 1 month ago
parent
commit
a9bc318a1d
9 changed files with 136 additions and 0 deletions
  1. +9
    -0
      src/dao/user_virtual_amount_dao.go
  2. +10
    -0
      src/dao/user_virtual_coin_flow_dao.go
  3. +5
    -0
      src/dao/virtual_coin_dao.go
  4. +35
    -0
      src/implement/user_virtual_amount_implement.go
  5. +23
    -0
      src/implement/user_virtual_coin_flow_implement.go
  6. +14
    -0
      src/implement/virtual_coin_implement.go
  7. +10
    -0
      src/model/user_virtual_amount.go
  8. +16
    -0
      src/model/user_virtual_coin_flow.go
  9. +14
    -0
      src/model/virtual_coin.go

+ 9
- 0
src/dao/user_virtual_amount_dao.go View File

@@ -0,0 +1,9 @@
package dao

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

type UserVirtualAmountDao interface {
GetUserVirtualWalletBySession(uid int64, coinId int) (*model.UserVirtualAmount, error)
}

+ 10
- 0
src/dao/user_virtual_coin_flow_dao.go View File

@@ -0,0 +1,10 @@
package dao

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

type UserVirtualCoinFlowDao interface {
UserVirtualCoinFlowInsertBySession(session *xorm.Session, UserVirtualCoinFlow *model.UserVirtualCoinFlow) (int64, error)
}

+ 5
- 0
src/dao/virtual_coin_dao.go View File

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

type VirtualCoinDao interface {
//TODO:: You can add specific method definitions here
}

+ 35
- 0
src/implement/user_virtual_amount_implement.go View File

@@ -0,0 +1,35 @@
package implement

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

func NewUserVirtualAmountDb(engine *xorm.Engine) dao.UserVirtualAmountDao {
return &UserVirtualAmountDb{Db: engine}
}

type UserVirtualAmountDb struct {
Db *xorm.Engine
}

func (u UserVirtualAmountDb) GetUserVirtualWalletBySession(uid int64, coinId int) (*model.UserVirtualAmount, error) {
var UserVirtualWallet model.UserVirtualAmount
get, err := u.Db.Where("uid = ? AND coin_id = ?", uid, coinId).Get(&UserVirtualWallet)
if err != nil {
return nil, err
}
if get {
return &UserVirtualWallet, nil
} else {
UserVirtualWallet.Amount = "0"
UserVirtualWallet.CoinId = coinId
UserVirtualWallet.Uid = uid
one, err1 := u.Db.InsertOne(&UserVirtualWallet)
if err1 != nil || one == 0 {
return nil, err1
}
return &UserVirtualWallet, nil
}
}

+ 23
- 0
src/implement/user_virtual_coin_flow_implement.go View File

@@ -0,0 +1,23 @@
package implement

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

func NewUserVirtualCoinFlowDb(engine *xorm.Engine) dao.UserVirtualCoinFlowDao {
return &UserVirtualCoinFlowDb{Db: engine}
}

type UserVirtualCoinFlowDb struct {
Db *xorm.Engine
}

func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowInsertBySession(session *xorm.Session, UserVirtualCoinFlow *model.UserVirtualCoinFlow) (int64, error) {
_, err := session.InsertOne(UserVirtualCoinFlow)
if err != nil {
return 0, err
}
return UserVirtualCoinFlow.Id, nil
}

+ 14
- 0
src/implement/virtual_coin_implement.go View File

@@ -0,0 +1,14 @@
package implement

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

func NewVirtualCoinDb(engine *xorm.Engine) dao.VirtualCoinDao {
return &VirtualCoinDb{Db: engine}
}

type VirtualCoinDb struct {
Db *xorm.Engine
}

+ 10
- 0
src/model/user_virtual_amount.go View File

@@ -0,0 +1,10 @@
package model

type UserVirtualAmount struct {
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"`
Uid int64 `json:"uid" xorm:"not null default 0 unique(idx_uid_coin_id) BIGINT(20)"`
CoinId int `json:"coin_id" xorm:"not null default 0 index(idx_coinid_amount) unique(idx_uid_coin_id) INT(11)"`
Amount string `json:"amount" xorm:"not null default 0.00000000 index(idx_coinid_amount) DECIMAL(28,8)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
}

+ 16
- 0
src/model/user_virtual_coin_flow.go View File

@@ -0,0 +1,16 @@
package model

type UserVirtualCoinFlow struct {
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"`
Uid int64 `json:"uid" xorm:"not null default 0 comment('用户id') index index(idx_uid_coinid) BIGINT(20)"`
CoinId int `json:"coin_id" xorm:"not null default 0 comment('虚拟币id') index(idx_uid_coinid) index INT(11)"`
Direction int `json:"direction" xorm:"not null default 0 comment('方向:1收入 2支出') index TINYINT(1)"`
Title string `json:"title" xorm:"not null default '' comment('标题') CHAR(50)"`
Amount string `json:"amount" xorm:"not null comment('变更数量') index DECIMAL(28,8)"`
BeforeAmount string `json:"before_amount" xorm:"not null comment('变更前数量') DECIMAL(28,8)"`
AfterAmount string `json:"after_amount" xorm:"not null comment('变更后数量') DECIMAL(28,8)"`
SysFee string `json:"sys_fee" xorm:"not null default 0.000000 comment('手续费') DECIMAL(28,8)"`
TransferType int `json:"transfer_type" xorm:"not null default 0 comment('转账类型') TINYINT(3)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') index DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"`
}

+ 14
- 0
src/model/virtual_coin.go View File

@@ -0,0 +1,14 @@
package model

import (
"time"
)

type VirtualCoin struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"`
ExchangeRatio string `json:"exchange_ratio" xorm:"not null comment('兑换比例(与金额)') DECIMAL(10,2)"`
IsUse int `json:"is_use" xorm:"not null default 0 comment('是否开启:0否 1是') TINYINT(1)"`
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
}

Loading…
Cancel
Save