Browse Source

add new user red package

master
shenjiachi 6 days ago
parent
commit
f52a1098db
10 changed files with 192 additions and 1 deletions
  1. +10
    -0
      src/dao/new_user_red_package_dao.go
  2. +8
    -0
      src/dao/new_user_red_package_with_user_records_dao.go
  3. +8
    -0
      src/dao/new_user_red_package_with_user_records_flow_dao.go
  4. +1
    -1
      src/implement/egg_energy_community_dividends_implement.go
  5. +48
    -0
      src/implement/new_user_red_package_implement.go
  6. +34
    -0
      src/implement/new_user_red_package_with_user_records_flow_implement.go
  7. +34
    -0
      src/implement/new_user_red_package_with_user_records_implement.go
  8. +11
    -0
      src/model/new_user_red_package.go
  9. +18
    -0
      src/model/new_user_red_package_with_user_records.go
  10. +20
    -0
      src/model/new_user_red_package_with_user_records_flow.go

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

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

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

type NewUserRedPackageDao interface {
//TODO:: You can add specific method definitions here
NewUserRedPackageGetOne() (*model.NewUserRedPackage, error)
NewUserRedPackageInsert(newUserRedPackage *model.NewUserRedPackage) (int, error)
NewUserRedPackageUpdate(id interface{}, newUserRedPackage *model.NewUserRedPackage, forceColums ...string) (int64, error)
}

+ 8
- 0
src/dao/new_user_red_package_with_user_records_dao.go View File

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

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

type NewUserRedPackageWithUserRecordsDao interface {
//TODO:: You can add specific method definitions here
NewUserRedPackageWithUserRecordsFind(page, limit int, uid int64, startAt, endAt string) (*[]model.NewUserRedPackageWithUserRecords, int64, error)
}

+ 8
- 0
src/dao/new_user_red_package_with_user_records_flow_dao.go View File

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

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

type NewUserRedPackageWithUserRecordsFlowDao interface {
//TODO:: You can add specific method definitions here
NewUserRedPackageWithUserRecordsFlowFindAndCount(page, limit int, uid int64, startAt, endAt string) (*[]model.NewUserRedPackageWithUserRecordsFlow, int64, error)
}

+ 1
- 1
src/implement/egg_energy_community_dividends_implement.go View File

@@ -38,7 +38,7 @@ func (e EggEnergyCommunityDividendsDb) EggEnergyCommunityDividendsFindAndCount(p
if endNums != 0 {
session = session.And("nums <= ?", endNums)
}
total, err := session.Limit(limit, (page-1)*limit).FindAndCount(&m)
total, err := session.Limit(limit, (page-1)*limit).Desc("create_at").FindAndCount(&m)
if err != nil {
return nil, 0, zhios_order_relate_logx.Error(err.Error())
}


+ 48
- 0
src/implement/new_user_red_package_implement.go View File

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

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"
)

func NewNewUserRedPackageDb(engine *xorm.Engine) dao.NewUserRedPackageDao {
return &NewUserRedPackageDb{Db: engine}
}

type NewUserRedPackageDb struct {
Db *xorm.Engine
}

func (n NewUserRedPackageDb) NewUserRedPackageGetOne() (*model.NewUserRedPackage, error) {
var m model.NewUserRedPackage
if has, err := n.Db.Where("id >= 1").Get(&m); err != nil || has == false {
return nil, zhios_order_relate_logx.Error(err)
}
return &m, nil
}

func (n NewUserRedPackageDb) NewUserRedPackageInsert(newUserRedPackage *model.NewUserRedPackage) (int, error) {
_, err := n.Db.InsertOne(newUserRedPackage)
if err != nil {
return 0, err
}
return newUserRedPackage.Id, nil
}

func (n NewUserRedPackageDb) NewUserRedPackageUpdate(id interface{}, newUserRedPackage *model.NewUserRedPackage, forceColums ...string) (int64, error) {
var (
affected int64
err error
)
if forceColums != nil {
affected, err = n.Db.Where("id=?", id).Cols(forceColums...).Update(newUserRedPackage)
} else {
affected, err = n.Db.Where("id=?", id).Update(newUserRedPackage)
}
if err != nil {
return 0, err
}
return affected, nil
}

+ 34
- 0
src/implement/new_user_red_package_with_user_records_flow_implement.go View File

@@ -0,0 +1,34 @@
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 NewNewUserRedPackageWithUserRecordsFlowDb(engine *xorm.Engine) dao.NewUserRedPackageWithUserRecordsFlowDao {
return &NewUserRedPackageWithUserRecordsFlowDb{Db: engine}
}

type NewUserRedPackageWithUserRecordsFlowDb struct {
Db *xorm.Engine
}

func (n NewUserRedPackageWithUserRecordsFlowDb) NewUserRedPackageWithUserRecordsFlowFindAndCount(page, limit int, uid int64, startAt, endAt string) (*[]model.NewUserRedPackageWithUserRecordsFlow, int64, error) {
var m []model.NewUserRedPackageWithUserRecordsFlow
session := n.Db.NewSession()
if uid != 0 {
session.Where(" uid = ? ", uid)
}
if startAt != "" {
session.Where(" create_at >= ? ", startAt)
}
if endAt != "" {
session.Where(" create_at <= ? ", endAt)
}
total, err := session.Limit(limit, (page-1)*limit).Desc("create_at").FindAndCount(&m)
if err != nil {
return nil, 0, err
}
return &m, total, nil
}

+ 34
- 0
src/implement/new_user_red_package_with_user_records_implement.go View File

@@ -0,0 +1,34 @@
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 NewNewUserRedPackageWithUserRecordsDb(engine *xorm.Engine) dao.NewUserRedPackageWithUserRecordsDao {
return &NewUserRedPackageWithUserRecordsDb{Db: engine}
}

type NewUserRedPackageWithUserRecordsDb struct {
Db *xorm.Engine
}

func (n NewUserRedPackageWithUserRecordsDb) NewUserRedPackageWithUserRecordsFind(page, limit int, uid int64, startAt, endAt string) (*[]model.NewUserRedPackageWithUserRecords, int64, error) {
var m []model.NewUserRedPackageWithUserRecords
session := n.Db.NewSession()
if uid != 0 {
session.Where(" uid = ? ", uid)
}
if startAt != "" {
session.Where(" create_at >= ? ", startAt)
}
if endAt != "" {
session.Where(" create_at <= ? ", endAt)
}
total, err := session.Limit(limit, (page-1)*limit).Desc("create_at").FindAndCount(&m)
if err != nil {
return nil, 0, err
}
return &m, total, nil
}

+ 11
- 0
src/model/new_user_red_package.go View File

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

type NewUserRedPackage struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
IsOpen int `json:"is_open" xorm:"not null default 1 comment('是否开启(1:开启 0:关闭)') TINYINT(1)"`
TotalAmount string `json:"total_amount" xorm:"not null comment('总金额') DECIMAL(10,2)"`
Days int `json:"days" xorm:"not null default 1 comment('天数') TINYINT(3)"`
IsDouble int `json:"is_double" xorm:"not null default 1 comment('是否翻倍') TINYINT(1)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
}

+ 18
- 0
src/model/new_user_red_package_with_user_records.go View File

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

import (
"time"
)

type NewUserRedPackageWithUserRecords struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int64 `json:"uid" xorm:"not null default 0 comment('uid') BIGINT(20)"`
TotalAmount string `json:"total_amount" xorm:"not null comment('金额') DECIMAL(10,2)"`
Days int `json:"days" xorm:"not null default 1 comment('天数') TINYINT(3)"`
BalanceAmount string `json:"balance_amount" xorm:"not null comment('剩余金额') DECIMAL(10,2)"`
BalanceDays int `json:"balance_days" xorm:"not null default 0 comment('剩余天数') TINYINT(3)"`
ReceiveDays int `json:"receive_days" xorm:"not null default 0 comment('领取天数') TINYINT(3)"`
State int `json:"state" xorm:"not null default 1 comment('状态(0:待领取 1:领取中 2:已领取 3:已冻结)') 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"`
}

+ 20
- 0
src/model/new_user_red_package_with_user_records_flow.go View File

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

import (
"time"
)

type NewUserRedPackageWithUserRecordsFlow struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int64 `json:"uid" xorm:"not null default 0 comment('uid') BIGINT(20)"`
BasicAmount string `json:"basic_amount" xorm:"not null comment('基础金额') DECIMAL(10,2)"`
TotalAmount string `json:"total_amount" xorm:"not null comment('实际金额') DECIMAL(10,2)"`
DayNum int `json:"day_num" xorm:"not null default 1 comment('第x天') TINYINT(3)"`
IsDouble int `json:"is_double" xorm:"not null default 1 comment('是否翻倍') TINYINT(1)"`
DoubleRate string `json:"double_rate" xorm:"not null comment('倍率') DECIMAL(4,2)"`
BalanceAmount string `json:"balance_amount" xorm:"not null comment('剩余金额') DECIMAL(10,2)"`
BalanceDays int `json:"balance_days" xorm:"not null default 0 comment('剩余天数') TINYINT(3)"`
ReceiveDays int `json:"receive_days" xorm:"not null default 0 comment('领取天数') TINYINT(3)"`
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