@@ -2,10 +2,10 @@ package dao | |||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | ||||
"xorm.io/xorm" | |||||
) | ) | ||||
type AdvertisingCallbackDao interface { | type AdvertisingCallbackDao interface { | ||||
FindAdvertisingCallbackAndTotal(page, limit, amount, uid, startTime, endTime, platform, types string) (*[]model.AdvertisingCallback, int64, error) | FindAdvertisingCallbackAndTotal(page, limit, amount, uid, startTime, endTime, platform, types string) (*[]model.AdvertisingCallback, int64, error) | ||||
AdvertisingCallbackCountBySession(session *xorm.Session, uid, startTime, endTime, types string) (int64, error) | |||||
AdvertisingCallbackCount(uid, startTime, endTime, typePrefix string) (int64, error) | |||||
AdvertisingCallbackDeleteByDateByPage(date string, limit int) (int64, error) | |||||
} | } |
@@ -9,5 +9,7 @@ type EggEnergyTeamAssistanceDao interface { | |||||
EggEnergyTeamAssistanceInsertBySession(session *xorm.Session, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance) (int64, error) | EggEnergyTeamAssistanceInsertBySession(session *xorm.Session, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance) (int64, error) | ||||
EggEnergyTeamAssistanceUpdateBySession(session *xorm.Session, id interface{}, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance, forceColums ...string) (int64, error) | EggEnergyTeamAssistanceUpdateBySession(session *xorm.Session, id interface{}, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance, forceColums ...string) (int64, error) | ||||
EggEnergyTeamAssistanceGetOneByParamsBySession(session *xorm.Session, params map[string]interface{}) (*model.EggEnergyTeamAssistance, error) | EggEnergyTeamAssistanceGetOneByParamsBySession(session *xorm.Session, params map[string]interface{}) (*model.EggEnergyTeamAssistance, error) | ||||
EggEnergyTeamAssistanceGetOneBySession(session *xorm.Session, uid int64, date string) (*model.EggEnergyTeamAssistance, error) | |||||
EggEnergyTeamAssistanceGetOne(uid int64, date string) (*model.EggEnergyTeamAssistance, error) | |||||
EggEnergyTeamAssistanceInsert(EggEnergyTeamAssistance *model.EggEnergyTeamAssistance) (int64, error) | |||||
EggEnergyTeamAssistanceUpdate(id interface{}, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance, forceColums ...string) (int64, error) | |||||
} | } |
@@ -5,6 +5,7 @@ import ( | |||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | ||||
zhios_order_relate_utils "code.fnuoos.com/EggPlanet/egg_models.git/utils" | zhios_order_relate_utils "code.fnuoos.com/EggPlanet/egg_models.git/utils" | ||||
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" | zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" | ||||
"fmt" | |||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
) | ) | ||||
@@ -45,13 +46,14 @@ func (a AdvertisingCallbackDb) FindAdvertisingCallbackAndTotal(page, limit, amou | |||||
return &m, count, nil | return &m, count, nil | ||||
} | } | ||||
func (a AdvertisingCallbackDb) AdvertisingCallbackCountBySession(session *xorm.Session, uid, startTime, endTime, types string) (int64, error) { | |||||
sess := session.Where("1=1") | |||||
func (a AdvertisingCallbackDb) AdvertisingCallbackCount(uid, startTime, endTime, typePrefix string) (int64, error) { | |||||
sess := a.Db.Where("1=1") | |||||
if uid != "" { | if uid != "" { | ||||
sess.And("uid=?", uid) | sess.And("uid=?", uid) | ||||
} | } | ||||
if types != "" { | |||||
sess.And("type=?", types) | |||||
if typePrefix != "" { | |||||
types := fmt.Sprintf("type LIKE '%s'", typePrefix+"%") | |||||
sess.And(types) | |||||
} | } | ||||
if startTime != "" { | if startTime != "" { | ||||
sess.And("create_at>=?", startTime) | sess.And("create_at>=?", startTime) | ||||
@@ -65,3 +67,11 @@ func (a AdvertisingCallbackDb) AdvertisingCallbackCountBySession(session *xorm.S | |||||
} | } | ||||
return count, nil | return count, nil | ||||
} | } | ||||
func (a AdvertisingCallbackDb) AdvertisingCallbackDeleteByDateByPage(date string, limit int) (int64, error) { | |||||
affected, err := a.Db.Where("create_at < ?", date).Limit(limit).Delete(&model.AdvertisingCallback{}) | |||||
if err != nil { | |||||
return 0, zhios_order_relate_logx.Error(err.Error()) | |||||
} | |||||
return affected, nil | |||||
} |
@@ -53,9 +53,9 @@ func (e EggEnergyTeamAssistanceDb) EggEnergyTeamAssistanceGetOneByParamsBySessio | |||||
return &m, nil | return &m, nil | ||||
} | } | ||||
func (e EggEnergyTeamAssistanceDb) EggEnergyTeamAssistanceGetOneBySession(session *xorm.Session, uid int64, date string) (*model.EggEnergyTeamAssistance, error) { | |||||
func (e EggEnergyTeamAssistanceDb) EggEnergyTeamAssistanceGetOne(uid int64, date string) (*model.EggEnergyTeamAssistance, error) { | |||||
var m model.EggEnergyTeamAssistance | var m model.EggEnergyTeamAssistance | ||||
has, err := session.Where("uid = ?", uid).And("date = ?", date).Get(&m) | |||||
has, err := e.Db.Where("uid = ?", uid).And("date = ?", date).Get(&m) | |||||
if err != nil { | if err != nil { | ||||
return nil, err | return nil, err | ||||
} | } | ||||
@@ -64,3 +64,27 @@ func (e EggEnergyTeamAssistanceDb) EggEnergyTeamAssistanceGetOneBySession(sessio | |||||
} | } | ||||
return &m, nil | return &m, nil | ||||
} | } | ||||
func (e EggEnergyTeamAssistanceDb) EggEnergyTeamAssistanceInsert(EggEnergyTeamAssistance *model.EggEnergyTeamAssistance) (int64, error) { | |||||
_, err := e.Db.InsertOne(EggEnergyTeamAssistance) | |||||
if err != nil { | |||||
return 0, err | |||||
} | |||||
return EggEnergyTeamAssistance.Id, nil | |||||
} | |||||
func (e EggEnergyTeamAssistanceDb) EggEnergyTeamAssistanceUpdate(id interface{}, EggEnergyTeamAssistance *model.EggEnergyTeamAssistance, forceColums ...string) (int64, error) { | |||||
var ( | |||||
affected int64 | |||||
err error | |||||
) | |||||
if forceColums != nil { | |||||
affected, err = e.Db.Where("id=?", id).Cols(forceColums...).Update(EggEnergyTeamAssistance) | |||||
} else { | |||||
affected, err = e.Db.Where("id=?", id).Update(EggEnergyTeamAssistance) | |||||
} | |||||
if err != nil { | |||||
return 0, err | |||||
} | |||||
return affected, nil | |||||
} |
@@ -1,11 +1,12 @@ | |||||
package model | package model | ||||
type EggEnergyTeamAssistance struct { | type EggEnergyTeamAssistance struct { | ||||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||||
Uid int64 `json:"uid" xorm:"not null default 0 comment('用户 ID') BIGINT(20)"` | |||||
AssistedNum int `json:"assisted_num" xorm:"not null default 0 comment('助力人数') INT(11)"` | |||||
RewardScore string `json:"reward_score" xorm:"not null default 0.00000000 comment('奖励积分数量') DECIMAL(20,8)"` | |||||
Date string `json:"date" xorm:"not null default '0000-00-00' comment('日期') CHAR(50)"` | |||||
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') BIGINT(20)"` | |||||
AssistedNum int `json:"assisted_num" xorm:"not null default 0 comment('助力人数') INT(11)"` | |||||
AssistedTimes int `json:"assisted_times" xorm:"not null default 0 comment('助力次数') INT(11)"` | |||||
RewardScore string `json:"reward_score" xorm:"not null default 0.00000000 comment('奖励积分数量') DECIMAL(20,8)"` | |||||
Date string `json:"date" xorm:"not null default '0000-00-00' comment('日期') CHAR(50)"` | |||||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||||
} | } |