@@ -1,5 +1,7 @@ | |||||
package dao | package dao | ||||
import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||||
type UserWalletDao interface { | type UserWalletDao interface { | ||||
//TODO:: You can add specific method definitions here | |||||
GetUserVirtualWallet(uid int64) (*model.UserWallet, error) | |||||
} | } |
@@ -0,0 +1,10 @@ | |||||
package dao | |||||
import ( | |||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||||
"xorm.io/xorm" | |||||
) | |||||
type UserWalletFlowDao interface { | |||||
UserWalletFlowInsertBySession(session *xorm.Session, userWalletFlow *model.UserWalletFlow) (int64, error) | |||||
} |
@@ -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 NewUserWalletFlowDb(engine *xorm.Engine) dao.UserWalletFlowDao { | |||||
return &UserWalletFlowDb{Db: engine} | |||||
} | |||||
type UserWalletFlowDb struct { | |||||
Db *xorm.Engine | |||||
} | |||||
func (u UserWalletFlowDb) UserWalletFlowInsertBySession(session *xorm.Session, userWalletFlow *model.UserWalletFlow) (int64, error) { | |||||
_, err := session.InsertOne(userWalletFlow) | |||||
if err != nil { | |||||
return 0, err | |||||
} | |||||
return userWalletFlow.Id, nil | |||||
} |
@@ -2,6 +2,7 @@ | |||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
) | ) | ||||
@@ -12,3 +13,22 @@ func NewUserWalletDb(engine *xorm.Engine) dao.UserWalletDao { | |||||
type UserWalletDb struct { | type UserWalletDb struct { | ||||
Db *xorm.Engine | Db *xorm.Engine | ||||
} | } | ||||
func (u UserWalletDb) GetUserVirtualWallet(uid int64) (*model.UserWallet, error) { | |||||
var userWallet model.UserWallet | |||||
get, err := u.Db.Where("uid = ?", uid).Get(&userWallet) | |||||
if err != nil { | |||||
return nil, err | |||||
} | |||||
if get { | |||||
return &userWallet, nil | |||||
} else { | |||||
userWallet.Amount = "0" | |||||
userWallet.Uid = uid | |||||
one, err1 := u.Db.InsertOne(&userWallet) | |||||
if err1 != nil || one == 0 { | |||||
return nil, err1 | |||||
} | |||||
return &userWallet, nil | |||||
} | |||||
} |
@@ -2,7 +2,7 @@ package model | |||||
type EggEnergyAvailableEnergyFlow struct { | type EggEnergyAvailableEnergyFlow struct { | ||||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | ||||
Kind int `json:"kind" xorm:"not null default 1 comment('种类(1:个人蛋蛋积分兑换 2:团队蛋蛋积分兑换 3:余额兑换蛋蛋能量 4:蛋蛋能量兑换余额 5:星级分红 6:社区分红 7:平台盈利)') TINYINT(1)"` | |||||
Kind int `json:"kind" xorm:"not null default 1 comment('种类(1:个人蛋蛋积分兑换 2:团队蛋蛋积分兑换 3:余额兑换蛋蛋能量 4:蛋蛋能量兑换余额 5:星级分红 6:社区分红 7:平台盈利 8:市商数量自动兑换市商资金 9:市商资金自动兑换市商数量 10:资金注入)') TINYINT(1)"` | |||||
Title string `json:"title" xorm:"not null default '' comment('标题') VARCHAR(255)"` | Title string `json:"title" xorm:"not null default '' comment('标题') VARCHAR(255)"` | ||||
BeforePrice string `json:"before_price" xorm:"not null default 0.0000000000 comment('变更前-价格') DECIMAL(28,10)"` | BeforePrice string `json:"before_price" xorm:"not null default 0.0000000000 comment('变更前-价格') DECIMAL(28,10)"` | ||||
AfterPrice string `json:"after_price" xorm:"not null default 0.0000000000 comment('变更后-价格') DECIMAL(28,10)"` | AfterPrice string `json:"after_price" xorm:"not null default 0.0000000000 comment('变更后-价格') DECIMAL(28,10)"` | ||||
@@ -1,10 +1,12 @@ | |||||
package model | package model | ||||
import "time" | |||||
type EggEnergyUserWatchRecords struct { | type EggEnergyUserWatchRecords struct { | ||||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||||
Uid int64 `json:"uid" xorm:"not null default 0 comment('用户id') index BIGINT(20)"` | |||||
NextWatchAdDate string `json:"next_watch_ad_date" xorm:"not null default 'CURRENT_TIMESTAMP' comment('下一轮观看视屏时间') DATETIME"` | |||||
ResidueWatchAdNum int `json:"residue_watch_ad_num" xorm:"not null default 0 comment('剩余观看视屏数') INT(11)"` | |||||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||||
Uid int64 `json:"uid" xorm:"not null default 0 comment('用户id') index BIGINT(20)"` | |||||
NextWatchAdDate time.Time `json:"next_watch_ad_date" xorm:"not null default 'CURRENT_TIMESTAMP' comment('下一轮观看视屏时间') DATETIME"` | |||||
ResidueWatchAdNum int `json:"residue_watch_ad_num" xorm:"not null default 0 comment('剩余观看视屏数') INT(11)"` | |||||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
} | } |
@@ -0,0 +1,18 @@ | |||||
package model | |||||
type UserWalletFlow struct { | |||||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||||
Uid int64 `json:"uid" xorm:"not null default 0 comment('用户id') index BIGINT(20)"` | |||||
Direction int `json:"direction" xorm:"not null default 0 comment('方向:1收入 2支出') index TINYINT(1)"` | |||||
Amount string `json:"amount" xorm:"not null default 0.00000000 comment('变动金额') DECIMAL(20,8)"` | |||||
BeforeAmount string `json:"before_amount" xorm:"not null default 0.00000000 comment('变动前金额') DECIMAL(20,8)"` | |||||
AfterAmount string `json:"after_amount" xorm:"not null default 0.00000000 comment('变动后金额') DECIMAL(20,8)"` | |||||
SysFee string `json:"sys_fee" xorm:"not null default 0.00000000 comment('手续费') DECIMAL(20,8)"` | |||||
OrdId string `json:"ord_id" xorm:"not null default '' comment('对应订单编号') VARCHAR(50)"` | |||||
Title string `json:"title" xorm:"not null default '' comment('标题') VARCHAR(50)"` | |||||
Kind int `json:"kind" xorm:"not null default 0 comment('1:管理员操作增加余额 2:管理员操作扣除余额 3:蛋蛋能量兑换余额 4:余额兑换蛋蛋能量') TINYINT(3)"` | |||||
State int `json:"state" xorm:"not null default 1 comment('1未到账,2已到账') TINYINT(1)"` | |||||
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"` | |||||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') TIMESTAMP"` | |||||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"` | |||||
} |