@@ -6,6 +6,7 @@ import ( | |||
type HappyOrchardRewardDao interface { | |||
GetHappyOrchardReward(id int) (m *models.HappyOrchardReward, err error) | |||
GetHappyOrchardRewardSess(id int) (m *models.HappyOrchardReward, err error) | |||
FindHappyOrchardRewardById(seedId []int) (m *[]models.HappyOrchardReward, err error) | |||
FindHappyOrchardRewardAll(rewardIds []int, start, limit int) (mm *[]models.HappyOrchardReward, err error) | |||
} |
@@ -1,6 +1,8 @@ | |||
package dao | |||
import "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
import ( | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
) | |||
type HappyOrchardSeedDao interface { | |||
GetHappyOrchardSeed(id int) (m *models.HappyOrchardSeed, err error) | |||
@@ -0,0 +1,8 @@ | |||
package dao | |||
import "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
type HappyOrchardTaskDao interface { | |||
GetHappyOrchardTaskByPid(pid int) (mm *[]models.HappyOrchardTask, err error) | |||
GetHappyOrchardTaskById(id int) (m *models.HappyOrchardTask, err error) | |||
} |
@@ -0,0 +1,8 @@ | |||
package dao | |||
import "code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
type HappyOrchardTaskNumDao interface { | |||
GetHappyOrchardTaskNumTotal(args map[string]string) int | |||
GetHappyOrchardTaskNum(args map[string]string) *models.HappyOrchardTaskNum | |||
} |
@@ -0,0 +1,6 @@ | |||
package dao | |||
type HappyOrchardTaskUserRewardDao interface { | |||
GetHappyOrchardTaskUserRewardByIdAndTime(uid string, taskId int, stime, etime int64) (count int64, err error) | |||
GetHappyOrchardTaskUserRewardByIdAndTimeSum(uid string, taskId int, stime, etime int64, i int) int64 | |||
} |
@@ -2,10 +2,12 @@ package dao | |||
import ( | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
"xorm.io/xorm" | |||
) | |||
type HappyOrchardUserSeedRecordDao interface { | |||
GetHappyOrchardUserSeedRecord(id int) (m *models.HappyOrchardUserSeedRecord, err error) | |||
GetHappyOrchardUserSeedRecordSess(sess *xorm.Session, id int) (m *models.HappyOrchardUserSeedRecord, err error) | |||
FindHappyOrchardUserSeedRecordByUid(uid int) (mm *[]models.HappyOrchardUserSeedRecord, err error) | |||
GetHappyOrchardUserSeedRecordByUidWithState(uid, state int) (m *models.HappyOrchardUserSeedRecord, err error) | |||
GetHappyOrchardUserSeedRecordByUidWithStateAndId(uid, id, state int) (m *models.HappyOrchardUserSeedRecord, err error) | |||
@@ -8,13 +8,16 @@ import ( | |||
) | |||
type HappyOrchardRewardDb struct { | |||
Db *xorm.Engine | |||
Db *xorm.Engine | |||
Sess *xorm.Session | |||
} | |||
func NewHappyOrchardRewardDb(engine *xorm.Engine) dao.HappyOrchardRewardDao { | |||
return &HappyOrchardRewardDb{Db: engine} | |||
} | |||
func NewHappyOrchardRewardDbSess(sess *xorm.Session) dao.HappyOrchardRewardDao { | |||
return &HappyOrchardRewardDb{Sess: sess} | |||
} | |||
func (h HappyOrchardRewardDb) GetHappyOrchardReward(id int) (m *models.HappyOrchardReward, err error) { | |||
m = new(models.HappyOrchardReward) | |||
has, err := h.Db.Where("id =?", id).Get(m) | |||
@@ -26,6 +29,17 @@ func (h HappyOrchardRewardDb) GetHappyOrchardReward(id int) (m *models.HappyOrch | |||
} | |||
return m, nil | |||
} | |||
func (h HappyOrchardRewardDb) GetHappyOrchardRewardSess(id int) (m *models.HappyOrchardReward, err error) { | |||
m = new(models.HappyOrchardReward) | |||
has, err := h.Sess.Where("id =?", id).Get(m) | |||
if err != nil { | |||
return nil, zhios_order_relate_logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (h HappyOrchardRewardDb) FindHappyOrchardRewardById(id []int) (mm *[]models.HappyOrchardReward, err error) { | |||
var m []models.HappyOrchardReward | |||
if err := h.Db.In("id", id).Find(&m); err != nil { | |||
@@ -0,0 +1,34 @@ | |||
package implement | |||
import ( | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/dao" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_model.git/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
type HappyOrchardTaskDb struct { | |||
Db *xorm.Engine | |||
} | |||
func NewHappyOrchardTaskDb(engine *xorm.Engine) dao.HappyOrchardTaskDao { | |||
return &HappyOrchardTaskDb{Db: engine} | |||
} | |||
func (h HappyOrchardTaskDb) GetHappyOrchardTaskByPid(pid int) (mm *[]models.HappyOrchardTask, err error) { | |||
var m []models.HappyOrchardTask | |||
if err := h.Db.Where("is_use=? and pid =?", 1, pid).Find(&m); err != nil { | |||
return nil, zhios_order_relate_logx.Error(err) | |||
} | |||
return &m, nil | |||
} | |||
func (h HappyOrchardTaskDb) GetHappyOrchardTaskById(id int) (m *models.HappyOrchardTask, err error) { | |||
m = new(models.HappyOrchardTask) | |||
has, err := h.Db.Where("id =?", id).Get(m) | |||
if err != nil { | |||
return nil, zhios_order_relate_logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} |
@@ -0,0 +1,35 @@ | |||
package implement | |||
import ( | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/dao" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
"xorm.io/xorm" | |||
) | |||
type HappyOrchardTaskNumDb struct { | |||
Db *xorm.Engine | |||
} | |||
func NewHappyOrchardTaskNumDb(engine *xorm.Engine) dao.HappyOrchardTaskNumDao { | |||
return &HappyOrchardTaskNumDb{Db: engine} | |||
} | |||
func (h HappyOrchardTaskNumDb) GetHappyOrchardTaskNumTotal(args map[string]string) int { | |||
sess := h.Db.Where("uid=? and time>=? and time<? and task_type=?", args["uid"], args["start_time"], args["end_time"], args["task_type"]) | |||
if args["task_id"] != "" { | |||
sess.And("task_id=?", args["task_id"]) | |||
} | |||
sum, _ := sess.Sum(&models.HappyOrchardTaskNum{}, "count") | |||
return int(sum) | |||
} | |||
func (h HappyOrchardTaskNumDb) GetHappyOrchardTaskNum(args map[string]string) *models.HappyOrchardTaskNum { | |||
var data models.HappyOrchardTaskNum | |||
sess := h.Db.Where("uid=? and time=? and task_type=?", args["uid"], args["time"], args["task_type"]) | |||
if args["task_id"] != "" { | |||
sess.And("task_id=?", args["task_id"]) | |||
} | |||
get, err := sess.Get(&data) | |||
if get == false || err != nil { | |||
return nil | |||
} | |||
return &data | |||
} |
@@ -0,0 +1,47 @@ | |||
package implement | |||
import ( | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/dao" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" | |||
"xorm.io/xorm" | |||
) | |||
type HappyOrchardTaskUserRewardDb struct { | |||
Db *xorm.Engine | |||
} | |||
func NewHappyOrchardTaskUserRewardDb(engine *xorm.Engine) dao.HappyOrchardTaskUserRewardDao { | |||
return &HappyOrchardTaskUserRewardDb{Db: engine} | |||
} | |||
func (h HappyOrchardTaskUserRewardDb) GetHappyOrchardTaskUserRewardByIdAndTime(uid string, taskId int, stime, etime int64) (count int64, err error) { | |||
sess := h.Db.Where("uid = ? AND task_id = ? and create_time>=?", | |||
uid, taskId, stime) | |||
if etime > 0 { | |||
sess.And("create_time<?", etime) | |||
} | |||
total, err := sess.Count(&models.HappyOrchardTaskUserReward{}) | |||
return total, err | |||
} | |||
func (h HappyOrchardTaskUserRewardDb) GetHappyOrchardTaskUserRewardByIdAndTimeSum(uid string, taskId int, stime, etime int64, i int) int64 { | |||
var totals float64 = 0 | |||
if i == 0 { | |||
sess := h.Db.Where("uid = ? AND task_id = ? and create_time>=?", | |||
uid, taskId, stime) | |||
if etime > 0 { | |||
sess.And("create_time<?", etime) | |||
} | |||
total, _ := sess.Sum(&models.HappyOrchardTaskUserReward{}, "task_num") | |||
totals = total | |||
} | |||
if i == 1 { | |||
sess1 := h.Db.Where("uid = ? AND task_id = ? and create_time>=?", | |||
uid, taskId, stime) | |||
if etime > 0 { | |||
sess1.And("create_time<?", etime) | |||
} | |||
total1, _ := sess1.Sum(&models.HappyOrchardTaskUserReward{}, "task_num_second") | |||
totals = total1 | |||
} | |||
return int64(totals) | |||
} |
@@ -43,7 +43,18 @@ func (h HappyOrchardUserSeedRecordDb) GetHappyOrchardUserSeedRecord(id int) (m * | |||
} | |||
return m, nil | |||
} | |||
func (h HappyOrchardUserSeedRecordDb) GetHappyOrchardUserSeedRecordSess(sess *xorm.Session, id int) (m *models.HappyOrchardUserSeedRecord, err error) { | |||
//TODO implement me | |||
m = new(models.HappyOrchardUserSeedRecord) | |||
has, err := h.Db.Where("id =?", id).Get(m) | |||
if err != nil { | |||
return nil, zhios_order_relate_logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (h HappyOrchardUserSeedRecordDb) FindHappyOrchardUserSeedRecordByUid(uid int) (mm *[]models.HappyOrchardUserSeedRecord, err error) { | |||
//TODO implement me | |||
var m []models.HappyOrchardUserSeedRecord | |||
@@ -0,0 +1,31 @@ | |||
package models | |||
import ( | |||
"time" | |||
) | |||
type HappyOrchardTask struct { | |||
Id int `json:"id" xorm:"not null pk autoincr comment('主键id') INT(11)"` | |||
Pid int `json:"pid" xorm:"default 0 comment('父级任务id') INT(11)"` | |||
TaskName string `json:"task_name" xorm:"default '' comment('任务名称') VARCHAR(255)"` | |||
TaskDescribe string `json:"task_describe" xorm:"default '' comment('描述') VARCHAR(255)"` | |||
TaskType int `json:"task_type" xorm:"default 0 comment('任务类型') TINYINT(2)"` | |||
TaskNum int `json:"task_num" xorm:"default 0 comment('达成条件数') INT(11)"` | |||
LimitRewardNum int `json:"limit_reward_num" xorm:"default 0 comment('每天限制奖励次数') INT(11)"` | |||
TaskReward string `json:"task_reward" xorm:"default '' comment('[{"coin_id": "cny","coin_name": "佣金","reward_num": "20"},{"coin_id": "1","coin_name": "积分","reward_num": "1"}]') VARCHAR(600)"` | |||
IsUse int `json:"is_use" xorm:"default 0 comment('是否启用') TINYINT(1)"` | |||
CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') TIMESTAMP"` | |||
UpdateAt time.Time `json:"update_at" xorm:"default CURRENT_TIMESTAMP comment('更新时间') TIMESTAMP"` | |||
SkipData string `json:"skip_data" xorm:"comment('跳转页面的数据') LONGTEXT"` | |||
AdvId int `json:"adv_id" xorm:"default 0 comment('广告id') INT(11)"` | |||
TaskLvLimit string `json:"task_lv_limit" xorm:"comment('等级限制 json') LONGTEXT"` | |||
IsAuto int `json:"is_auto" xorm:"default 0 comment('是否自动领取 0否 1是') TINYINT(1)"` | |||
GiveLvData string `json:"give_lv_data" xorm:"comment('赠送等级信息 json') LONGTEXT"` | |||
TipStr string `json:"tip_str" xorm:"VARCHAR(255)"` | |||
RewardType int `json:"reward_type" xorm:"default 0 INT(11)"` | |||
TaskData string `json:"task_data" xorm:"default '' VARCHAR(2000)"` | |||
TimeData string `json:"time_data" xorm:"VARCHAR(2000)"` | |||
IsNotRelate int `json:"is_not_relate" xorm:"default 0 INT(1)"` | |||
AllAdvId int `json:"all_adv_id" xorm:"default 0 comment('广告id') INT(11)"` | |||
Type string `json:"type" xorm:"default '' comment('空是原来的 新的是pineapple') VARCHAR(255)"` | |||
} |
@@ -0,0 +1,16 @@ | |||
package models | |||
import ( | |||
"time" | |||
) | |||
type HappyOrchardTaskNum struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Uid int `json:"uid" xorm:"default 0 unique(uid) INT(11)"` | |||
Time int `json:"time" xorm:"default 0 unique(uid) INT(11)"` | |||
InviteTime time.Time `json:"invite_time" xorm:"DATETIME"` | |||
ParentUid int `json:"parent_uid" xorm:"default 0 INT(11)"` | |||
Count int `json:"count" xorm:"default 0 INT(11)"` | |||
TaskType int `json:"task_type" xorm:"default 0 unique(uid) INT(11)"` | |||
TaskId int `json:"task_id" xorm:"default 0 unique(uid) INT(11)"` | |||
} |
@@ -0,0 +1,26 @@ | |||
package models | |||
type HappyOrchardTaskUserReward struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Uid int `json:"uid" xorm:"default 0 comment('用户id') index INT(11)"` | |||
Type string `json:"type" xorm:"default '' comment('类型 sign签到') index VARCHAR(255)"` | |||
Title string `json:"title" xorm:"default '' comment('任务标题') VARCHAR(255)"` | |||
IsFinish int `json:"is_finish" xorm:"default 0 comment('是否完成') INT(1)"` | |||
CreateTime int `json:"create_time" xorm:"default 0 comment('创建时间') index INT(11)"` | |||
FinishTime int `json:"finish_time" xorm:"default 0 comment('完成时间') INT(11)"` | |||
Reward string `json:"reward" xorm:"default '' comment('奖励 ["0":""]') VARCHAR(255)"` | |||
TaskId int `json:"task_id" xorm:"default 0 comment('任务id') INT(11)"` | |||
TaskNum int `json:"task_num" xorm:"default 0 comment('任务数量') INT(11)"` | |||
Platform string `json:"platform" xorm:"default '' comment('平台') VARCHAR(255)"` | |||
TaskNumSecond int `json:"task_num_second" xorm:"default 0 INT(11)"` | |||
TaskName string `json:"task_name" xorm:"VARCHAR(255)"` | |||
Oid int64 `json:"oid" xorm:"default 0 BIGINT(20)"` | |||
DeviceModel string `json:"device_model" xorm:"VARCHAR(255)"` | |||
Bili string `json:"bili" xorm:"VARCHAR(255)"` | |||
BiliType int `json:"bili_type" xorm:"default 0 INT(11)"` | |||
TaskType string `json:"task_type" xorm:"default '' VARCHAR(255)"` | |||
Price string `json:"price" xorm:"default 0.000000 DECIMAL(20,6)"` | |||
OldPrice string `json:"old_price" xorm:"default 0.000000 DECIMAL(20,6)"` | |||
Ext string `json:"ext" xorm:"VARCHAR(5000)"` | |||
IsSend int `json:"is_send" xorm:"default 0 INT(1)"` | |||
} |
@@ -1,11 +1,16 @@ | |||
package models | |||
type HappyOrchardUserSeedRecord struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Uid int `json:"uid" xorm:"INT(11)"` | |||
SeedId int `json:"seed_id" xorm:"not null default 0 INT(11)"` | |||
WaterNums int `json:"water_nums" xorm:"not null default 0 comment('当前获得水滴数') INT(11)"` | |||
State int `json:"state" xorm:"not null default 1 comment('状态(1:种植中 2:待领取 3:已领取)') INT(11)"` | |||
CreateAt string `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') DATETIME"` | |||
UpdateAt string `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP comment('更新时间') DATETIME"` | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Uid int `json:"uid" xorm:"INT(11)"` | |||
SeedId int `json:"seed_id" xorm:"not null default 0 INT(11)"` | |||
WaterNums int `json:"water_nums" xorm:"not null default 0 comment('当前获得水滴数') INT(11)"` | |||
State int `json:"state" xorm:"not null default 1 comment('状态(1:种植中 2:待领取 3:已领取)') INT(11)"` | |||
CreateAt string `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') DATETIME"` | |||
UpdateAt string `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP comment('更新时间') DATETIME"` | |||
HasReward1 int `json:"has_reward_1" xorm:"has_reward_1 not null default 0 comment('阶段2是否领取了奖励') INT(11)"` | |||
HasReward2 int `json:"has_reward_2" xorm:"has_reward_2 not null default 0 comment('阶段3是否领取了奖励') INT(11)"` | |||
HasReward3 int `json:"has_reward_3" xorm:"has_reward_3 not null default 0 comment('阶段4是否领取了奖励') INT(11)"` | |||
HasReward4 int `json:"has_reward_4" xorm:"has_reward_4 not null default 0 comment('阶段5是否领取了奖励') INT(11)"` | |||
HasReward5 int `json:"has_reward_5" xorm:"has_reward_5 not null default 0 comment('阶段6是否领取了奖励') INT(11)"` | |||
} |