Browse Source

add: 归档

token_replace
黄梓健 5 years ago
parent
commit
bafc8131b2
  1. 2
      controllers/client/auction.go
  2. 2
      controllers/client/calorie.go
  3. 4
      controllers/client/invite_envelope.go
  4. 2
      controllers/client/login.go
  5. 1
      controllers/client/shake_red_envelope.go
  6. 57
      controllers/client/sign.go
  7. 6
      controllers/client/tug_war.go
  8. 2
      controllers/pc/auction.go
  9. 2
      controllers/pc/lottery_draw.go
  10. 2
      controllers/pc/order_draw.go
  11. 2
      controllers/pc/shake_red_envelope.go
  12. 10
      controllers/pc/sign.go
  13. 5
      models/CalorieUser.go
  14. 4
      models/activity.go
  15. 2
      models/activity_module_service.go
  16. 1
      models/auction_result_record.go
  17. 8
      models/bahe_team_member.go
  18. 2
      models/base.go
  19. 2
      models/bully_screen_server.go
  20. 2
      models/customer_goods.go
  21. 14
      models/invitation_letter.go
  22. 1
      models/lottery_draw_record.go
  23. 2
      models/lottery_draw_rule_ladder.go
  24. 2
      models/module_service_history.go
  25. 2
      models/new_auction_activity.go
  26. 2
      models/new_vote_activity_history.go
  27. 1
      models/order_draw_record.go
  28. 2
      models/order_draw_rule.go
  29. 2
      models/order_draw_rule_ladder.go
  30. 2
      models/shake_red_envelope_activity.go
  31. 1
      models/shake_red_envelope_record.go
  32. 28
      models/sign_history.go
  33. 2
      models/user.go
  34. 2
      models/user_order.go
  35. 1
      models/user_prize.go
  36. 2
      services/lottery/lottery.go

2
controllers/client/auction.go

@ -16,6 +16,7 @@ type AuctionCtl struct {
}
// 竞拍动作
// todo: 进行替换
func (t *AuctionCtl) Auction() {
auctionId := t.MustGetInt64("auction_activity_id")
totalMoney := t.MustGetDouble("total_money")
@ -116,6 +117,7 @@ func (t *AuctionCtl) Auction() {
record.UserName = user.Nickname
record.AreaId = area.Id
record.AreaName = area.Name
record.ArchId = activity.ArchId
record.DealPrice = totalMoney
record.RehearsalId = activity.RehearsalId
record.PlayerCode = player.Code

2
controllers/client/calorie.go

@ -35,7 +35,7 @@ func (t *CalorieCtl) Shake() {
// 增加score
if calorie.Status == define.StatusRunning && score > 0 {
_, err = calorieUser.IncrScore(score)
_, err = calorieUser.IncrScore(activity.ArchId, calorieUser.Id, score)
t.CheckErr(err)
calorieUser.Score += int64(score) // 增加
}

4
controllers/client/invite_envelope.go

@ -23,7 +23,7 @@ func (t *InvitationLetterCtl) Invite() {
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
letter := new(models.InvitationLetter)
exist, err = letter.GetByUserIdAndActivityId(uid, activityId, activity.RehearsalId)
exist, err = letter.GetByUserIdAndActivityId(uid, activity.Id, activity.ArchId, activity.RehearsalId)
t.CheckErr(err)
t.Assert(!exist, code.MSG_INVITE_LETTER_EXIST, "您已经接受过邀请")
@ -32,12 +32,12 @@ func (t *InvitationLetterCtl) Invite() {
letter.InvitationId = invitationId
letter.RehearsalId = activity.RehearsalId
letter.ExtraData = answer
letter.ArchId = activity.ArchId
letter.IsDelete = false
letter.CreatedAt = time.Now()
letter.UpdatedAt = time.Now()
_, err = models.Add(letter)
t.CheckErr(err)
t.SUCCESS("success")
}

2
controllers/client/login.go

@ -124,7 +124,7 @@ func (t *UserCtl) WxLogin() {
t.Assert(exist, code.MSG_SIGN_UP_NOT_EXIST, "签到活动不存在")
history := new(models.SignHistory)
signExist, err := history.GetByUserId(activityId, user.Id, activity.RehearsalId, area.Id)
signExist, err := history.GetByUserId(activityId, activity.ArchId, user.Id, activity.RehearsalId, area.Id)
t.CheckErr(err)
var signIn = "未签到"

1
controllers/client/shake_red_envelope.go

@ -86,6 +86,7 @@ func (t *ShakeRedEnvelopeCtl) Shake() {
record.IsDraw = 0
record.UserId = userId
record.AreaId = areaId
record.ArchId = activity.ArchId
row, err := models.Update(record.Id, record, "is_draw", "user_id", "area_id")
t.CheckErr(err)
t.Assert(row == 1, code.MSG_SHAKERB_RECORD_NOT_HIT, "您与红包擦肩而过") // 那么 row == 1 为已经成功抢到

57
controllers/client/sign.go

@ -18,12 +18,28 @@ type SignCtl struct {
func (t *SignCtl) CheckSign() {
activityId := t.MustGetInt64("activity_id")
areaId := t.MustGetInt64("area_id")
uid := t.MustGetUID()
_type := t.MustGetInt("type")
activity := models.Activity{}
exist, err := models.Get(&activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
customer := models.Customer{}
exist, err = models.Get(&customer, activity.CustomerId)
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
area := new(models.AreaStore)
exist, err = models.Get(area, areaId)
t.CheckErr(err)
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在")
if _type == 1 {
live := new(models.LiveConfig)
exist, err := live.GetByActivityId(activityId)
exist, err := live.GetByActivityId(activity.Id)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "直播活动不存在")
if live.LiveMode == 2 {
@ -60,27 +76,8 @@ func (t *SignCtl) CheckSign() {
}
activity := models.Activity{}
exist, err := models.Get(&activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
customer := models.Customer{}
exist, err = models.Get(&customer, activity.CustomerId)
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
area := new(models.AreaStore)
if customer.AreaId == 0 {
exist, err = area.GetMainAreaById(activityId)
} else {
exist, err = area.GetAreaStoreById(customer.AreaId)
}
t.CheckErr(err)
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在")
history := new(models.SignHistory)
signExist, err := history.GetByUserId(activityId, uid, activity.RehearsalId, area.Id)
signExist, err := history.GetByUserId(activityId, activity.ArchId, uid, activity.RehearsalId, area.Id)
t.CheckErr(err)
if !signExist || history.Status != 2 {
t.JSON(false)
@ -159,17 +156,17 @@ func (t *SignCtl) Sign() {
}
//检查是否已经签到了
history := new(models.SignHistory)
exist, err = history.GetByUserId(activityId, uid, activity.RehearsalId, area.Id)
exist, err = history.GetByUserId(activityId, activity.ArchId, uid, activity.RehearsalId, area.Id)
t.CheckErr(err)
if exist || history.Status == 2 {
t.ERROR("您已经签到过了", code.MSG_SIGN_HISTORY_EXIST)
}
// 签到人数
signTotal, err := history.Count(signUp.Id, activity.RehearsalId, activity.Id)
signTotal, err := history.Count(signUp.Id, activity.Id, activity.ArchId, activity.RehearsalId)
t.CheckErr(err)
signUpTotal, err := new(models.InvitationLetter).Count(activity.Id, activity.RehearsalId)
signUpTotal, err := new(models.InvitationLetter).Count(activity.Id, activity.ArchId, activity.RehearsalId)
t.CheckErr(err)
if activity.RehearsalId != 0 && signTotal >= 10 {
@ -183,6 +180,7 @@ func (t *SignCtl) Sign() {
history.ActivityId = activityId
history.SignRuleId = signUp.Id
history.AreaId = areaId
history.ArchId = activity.ArchId
history.Status = 2
history.IsDelete = false
history.UpdatedAt = time.Now()
@ -226,7 +224,7 @@ func (t *SignCtl) RealSign() {
t.Assert(sign.SignMethod == 2, code.MSG_ERR_Param, "非实名签到")
history := new(models.SignHistory)
isSign, err := history.GetByUserId(activityId, userId, activity.RehearsalId, areaId)
isSign, err := history.GetByUserId(activityId, activity.ArchId, userId, activity.RehearsalId, areaId)
t.CheckErr(err)
if isSign && history.Status == 2 {
t.SUCCESS("已通过实名签到")
@ -270,6 +268,7 @@ func (t *SignCtl) RealSign() {
history.ActivityId = activityId
history.UserId = userId
history.Nickname = user.Nickname
history.ArchId = activity.ArchId
history.RehearsalId = activity.RehearsalId
history.AreaId = areaId
history.Content = string(body)
@ -279,9 +278,9 @@ func (t *SignCtl) RealSign() {
history.Status = 0
}
if isSign {
err = history.UpdateById([]interface{}{history.Id})
_, err = models.Update(history.Id, history)
} else {
err = history.Insert()
_, err = models.Add(history)
}
t.CheckErr(err)
if !exist { // 找不到导入的签名信息
@ -307,7 +306,7 @@ func (t *SignCtl) ApplySign() {
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
history := new(models.SignHistory)
exist, err = history.GetByUserId(activityId, userId, activity.RehearsalId, areaId)
exist, err = history.GetByUserId(activityId, activity.ArchId, userId, activity.RehearsalId, areaId)
t.CheckErr(err)
t.Assert(exist, code.MSG_SIGN_HISTORY_NOT_EXIST, "签到不存在")
if history.Status == 2 {
@ -332,7 +331,7 @@ func (t *SignCtl) CheckRealSign() {
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
history := new(models.SignHistory)
exist, err = history.GetByUserId(activityId, userId, activity.RehearsalId, areaId)
exist, err = history.GetByUserId(activityId, activity.ArchId, userId, activity.RehearsalId, areaId)
t.CheckErr(err)
t.Assert(exist, code.MSG_SIGN_HISTORY_NOT_EXIST, "签到信息不存在")
if history.Status == 2 {

6
controllers/client/tug_war.go

@ -70,7 +70,6 @@ func (t *TugOfWarCtl) Shake() {
exist, err := models.Get(bahe, baheId)
t.CheckErr(err)
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "拔河活动不存在")
t.CheckRunning(bahe.Status)
activity := new(models.Activity)
exist, err = models.Get(activity, bahe.ActivityId)
@ -83,8 +82,8 @@ func (t *TugOfWarCtl) Shake() {
t.CheckErr(err)
t.Assert(exist, code.MSG_ERR, "该用户尚未加入队伍")
if score != 0 {
_, err = member.IncrScoreById(member.Id, score)
if bahe.Status == define.StatusRunning && score > 0 { // 增加分数
_, err = member.IncrScoreById(activity.ArchId, member.Id, score)
t.CheckErr(err)
member.Score += score
}
@ -158,6 +157,7 @@ func (t *TugOfWarCtl) JoinTeam() {
member.TeamName = team.TeamName
member.MemberId = uid
member.Avatar = user.Avatar
member.ArchId = activity.ArchId
member.NickName = user.Nickname
member.BaheActivityId = baheActivityId
member.RehearsalId = activity.RehearsalId

2
controllers/pc/auction.go

@ -58,7 +58,6 @@ func (t *AuctionCtl) StartAuction() {
func (t *AuctionCtl) StopAuction() {
auctionId := t.MustGetInt64("auction_activity_id")
auction := new(models.NewAuctionActivity)
exist, err := models.Get(auction, auctionId)
t.CheckErr(err)
@ -95,6 +94,7 @@ func (t *AuctionCtl) StopAuction() {
record.UserId = history.UserId
record.UserPhone = user.Phone
record.UserName = user.Nickname
record.ArchId = activity.ArchId
record.Unit = history.Unit
record.DealPrice = history.Money
record.PlayerCode = history.PlayerCode

2
controllers/pc/lottery_draw.go

@ -333,6 +333,7 @@ func (t *LotteryDrawCtl) Lottery() {
userPrize.UserId = winners[i].UserId
userPrize.PrizeImg = ladder.PrizeImg
userPrize.PrizeName = ladder.PrizeName
userPrize.ArchId = activity.ArchId
userPrize.PrizeType = 1
userPrize.IsDelete = false
userPrize.CreatedAt = time.Now()
@ -345,6 +346,7 @@ func (t *LotteryDrawCtl) Lottery() {
record.ActivityId = activityId
record.RehearsalId = activity.RehearsalId
record.LotteryDrawActivityId = rule.LotteryDrawActivityId
record.ArchId = activity.ArchId
record.LotteryDrawRuleId = rule.Id
record.UserId = winners[i].UserId
record.UserName = winners[i].Username

2
controllers/pc/order_draw.go

@ -321,6 +321,7 @@ func (t *OrderDrawCtl) Draw() {
userPrize.UserId = winners[i].UserId
userPrize.PrizeImg = ladder.PrizeImg
userPrize.PrizeName = ladder.PrizeName
userPrize.ArchId = activity.ArchId
userPrize.PrizeType = 2
userPrize.IsDelete = false
userPrize.CreatedAt = time.Now()
@ -332,6 +333,7 @@ func (t *OrderDrawCtl) Draw() {
record.UserPrizeId = userPrize.Id
record.ActivityId = activityId
record.RehearsalId = activity.RehearsalId
record.ArchId = activity.ArchId
record.OrderDrawActivityId = rule.OrderDrawActivityId
record.OrderDrawRuleId = rule.Id
record.UserId = winners[i].UserId

2
controllers/pc/shake_red_envelope.go

@ -249,7 +249,7 @@ func (t *ShakeRedEnvelopeCtl) Winners() {
rehearsalId := t.MustGetInt64("rehearsal_id")
records := make([]*ShakeRedEnvelopeRecordAndUser, 0)
err := core.GetXormAuto().Table(new(models.ShakeRedEnvelopeRecord)).Alias("r").
Join("LEFT", models.AliasTableName(new(models.User), "u"), "r.user_id=u.id and u.is_delete=0").
Join("LEFT", models.Alias(new(models.User), "u"), "r.user_id=u.id and u.is_delete=0").
Where("r.shake_red_envelope_rule_id=? and is_draw<>-1 and r.is_delete=0 and r.rehearsal_id=?",
ruleId, rehearsalId).OrderBy("r.created_at desc").Find(&records)
t.CheckErr(err)

10
controllers/pc/sign.go

@ -98,8 +98,12 @@ func (t *SignCtl) SignInfo() {
// 实名签到信息
func (t *SignCtl) RealSignInfo() {
aid := t.MustGetInt64("activity_id")
rid := t.MustGetInt64("rehearsal_id")
results, err := models.GetApplyRealSigns(aid, rid)
activity := &models.Activity{}
exist, err := models.Get(activity, aid)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
results, err := models.GetApplyRealSigns(activity.Id, activity.ArchId, activity.RehearsalId)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"result": results,
@ -111,7 +115,7 @@ func (t *SignCtl) RealSignVerify() {
ids := strings.Split(t.MustGet("real_sign_history_ids"), ",")
history := new(models.SignHistory)
history.Status = 2
err := history.UpdateById(ids, "status")
err := history.UpdateByIds(ids, "status")
t.CheckErr(err)
t.SUCCESS("审核成功")
}

5
models/CalorieUser.go

@ -30,9 +30,10 @@ func (t *CalorieUser) GetByCalorieIdAndUserId(cid, uid, rid int64) (bool, error)
return core.GetXormAuto().Where("is_delete=0 and calorie_id=? and user_id=? and rehearsal_id=?", cid, uid, rid).Get(t)
}
func (t *CalorieUser) IncrScore(score int) (int64, error) {
func (t *CalorieUser) IncrScore(archId, id, score interface{}) (int64, error) {
t.JoinTime = time.Now().UnixNano()
return core.GetXormAuto().Where("is_delete=0 and id=?", t.Id).Cols("score", "join_time").Incr("score", score).Update(t)
return core.GetXormAuto().Where("is_delete=0 and arch_id=? and id=?", archId, id).
Cols("score", "join_time").Incr("score", score).Update(t)
}
func (t *CalorieUser) CountByCalorieId(calorieId, rehearsalId interface{}) (int64, error) {

4
models/activity.go

@ -10,7 +10,7 @@ const ActivityTableName = TableNamePrefix + "activity"
type Activity struct {
Id int64 `json:"id" xorm:"pk autoincr INT(11)"`
CustomerId int64 `json:"customer_id" xorm:"not null default(0) comment('customer_id, 创建客户id') INT(11)"`
ArchId int64 `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
Services []*ActivityModuleService `json:"services,omitempty" xorm:"-" description:"主活动下的服务"`
AreaStores []*AreaStore `json:"area_stores,omitempty" xorm:"-" description:"地区"`
BarrageStatus string `json:"barrage_status,omitempty" xorm:"-" description:"弹幕服务状态"`
@ -44,5 +44,5 @@ func (t *Activity) TableName() string {
}
func (t *Activity) Alias(name string) string {
return AliasTableName(t, name)
return Alias(t, name)
}

2
models/activity_module_service.go

@ -42,7 +42,7 @@ func (t *ActivityModuleService) TableName() string {
}
func (t *ActivityModuleService) Alias(name string) string {
return AliasTableName(t, name)
return Alias(t, name)
}
//

1
models/auction_result_record.go

@ -13,6 +13,7 @@ type AuctionResultRecord struct {
RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('0正式/!0彩排id') INT(11)"` // 增加彩排功能
AuctionActivityId int64 `json:"auction_activity_id" xorm:"not null comment('竞拍活动id') INT(11)"`
AreaId int64 `json:"area_id" xorm:"not null default('0') comment('地区id') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
AreaName string `json:"area_name" xorm:"not null default('') comment('地区名字') VARCHAR(255)"`
UserId int64 `json:"user_id" xorm:"not null comment('用户id') INT(11)"`
UserName string `json:"user_name" xorm:"not null comment('用户名字') VARCHAR(255)"`

8
models/bahe_team_member.go

@ -16,6 +16,7 @@ type BaheTeamMember struct {
TeamName string `json:"team_name" xorm:"not null default('') comment('队伍名字') VARCHAR(255)"`
MemberId int64 `json:"member_id" xorm:"not null comment('用户id') BIGINT(20)"`
Score int64 `json:"score" xorm:"not null default(0) comment('分数') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('彩排id/0正式') BIGINT(20)"`
Avatar string `json:"avatar" xorm:"not null comment('头像') VARCHAR(255)"`
NickName string `json:"nick_name" xorm:"not null comment('昵称') VARCHAR(255)"`
@ -30,16 +31,17 @@ func (t *BaheTeamMember) TableName() string {
}
func (t *BaheTeamMember) Alias(name string) string {
return AliasTableName(t, name)
return Alias(t, name)
}
func (t *BaheTeamMember) GetMemberByBaheIdAndUserId(uid, bid, rid int64) (bool, error) {
return core.GetXormAuto().Where("member_id=? and bahe_activity_id=? and rehearsal_id=? and is_delete=0", uid, bid, rid).Get(t)
}
func (t *BaheTeamMember) IncrScoreById(id, score int64) (int64, error) {
func (t *BaheTeamMember) IncrScoreById(archId, id, score interface{}) (int64, error) {
t.SortTime = time.Now().UnixNano()
return core.GetXormAuto().ID(id).Incr("score", score).Cols("score, sort_time").Update(t)
return core.GetXormAuto().Where("arch_id=? and id=?", archId, id).
Incr("score", score).Cols("score, sort_time").Update(t)
}
func GetBaheMembersByTeamId(obj, teamId, rehearsalId interface{}) error {

2
models/base.go

@ -134,7 +134,7 @@ func GetTableName(bean interface{}) string {
return core.GetXormAuto().TableName(bean)
}
func AliasTableName(bean interface{}, alias string) string {
func Alias(bean interface{}, alias string) string {
tn := GetTableName(bean)
return fmt.Sprintf("%s as %s", tn, alias)
}

2
models/bully_screen_server.go

@ -26,7 +26,7 @@ func (t *BullyScreenServer) TableName() string {
}
func (t *BullyScreenServer) Alias(name string) string {
return AliasTableName(t, name)
return Alias(t, name)
}
func (t *BullyScreenServer) GetByActivityId(aid int64) (bool, error) {

2
models/customer_goods.go

@ -34,7 +34,7 @@ func (t *CustomerGoods) TableName() string {
}
func (t *CustomerGoods) Alias(name string) string {
return AliasTableName(t, name)
return Alias(t, name)
}
func GetGoodsByActivityId(activityId, areaId int64) ([]*CustomerGoods, error) {

14
models/invitation_letter.go

@ -14,6 +14,7 @@ type InvitationLetter struct {
ActivityId int64 `json:"activity_id" xorm:"not null default(0) comment('主活动id') INT(11)"`
InvitationId int64 `json:"invitation_id" xorm:"not null default(0) comment('邀请函id') INT(11)"`
RehearsalId int64 `json:"rehearsal_id" xorm:"not null default 0 comment('彩排id') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
ExtraData string `json:"extra_data" xorm:"comment('邀请函信息') TEXT"`
IsDelete bool `json:"is_delete" xorm:"default(0)" description:"删除"`
CreatedAt time.Time `json:"created_at" xorm:"created" description:"创建"`
@ -25,14 +26,15 @@ func (t *InvitationLetter) TableName() string {
}
func (t *InvitationLetter) Alias(name string) string {
return AliasTableName(t, name)
return Alias(t, name)
}
func (t *InvitationLetter) GetByUserIdAndActivityId(uid, aid, rid int64) (bool, error) {
return core.GetXormAuto().Where("user_id=? and activity_id=? and rehearsal_id=? and is_delete=0", uid, aid, rid).Get(t)
func (t *InvitationLetter) GetByUserIdAndActivityId(userId, activityId, archId, rehearsalId interface{}) (bool, error) {
return core.GetXormAuto().Where("user_id=? and activity_id=? and arch_id=? and rehearsal_id=? and is_delete=0",
userId, activityId, archId, rehearsalId).Get(t)
}
func (t *InvitationLetter) Count(activityId, rehearsalId interface{}) (int64, error) {
return core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=?", activityId, rehearsalId).
Count(t)
func (t *InvitationLetter) Count(activityId, archId, rehearsalId interface{}) (int64, error) {
return core.GetXormAuto().Where("is_delete=0 and activity_id=? and arch_id=? and rehearsal_id=?",
activityId, archId, rehearsalId).Count(t)
}

1
models/lottery_draw_record.go

@ -15,6 +15,7 @@ type LotteryDrawRecord struct {
LotteryDrawActivityId int64 `json:"lottery_draw_activity_id" xorm:"not null comment('抽奖活动id')"`
LotteryDrawRuleId int64 `json:"lottery_draw_rule_id" xorm:"not null comment('抽奖规则id') BIGINT(20)"`
LotteryDrawRuleLadderId int64 `json:"lottery_draw_rule_ladder_id" xorm:"not null comment('规则阶梯id')"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
UserId int64 `json:"user_id" xorm:"not null comment('用户id')"`
RollNum int `json:"roll_num" xrom:"not null default 0 comment('滚动次数') INT(11)"`
UserName string `json:"user_name" description:"用户名" xorm:"not null comment('用户名')"`

2
models/lottery_draw_rule_ladder.go

@ -29,7 +29,7 @@ func (t *LotteryDrawRuleLadder) TableName() string {
}
func (t *LotteryDrawRuleLadder) Alias(name string) string {
return AliasTableName(t, name)
return Alias(t, name)
}
func UpdateLDLadderStatusByLDRuleIds(ids []int64) (int64, error) {

2
models/module_service_history.go

@ -26,7 +26,7 @@ func (t *ModuleServiceHistory) TableName() string {
}
func (t *ModuleServiceHistory) Alias(name string) string {
return AliasTableName(t, name)
return Alias(t, name)
}
func (t *ModuleServiceHistory) GetByModuleIdAndName(id int64, name string) (bool, error) {

2
models/new_auction_activity.go

@ -38,7 +38,7 @@ func (t *NewAuctionActivity) TableName() string {
}
func (t *NewAuctionActivity) Alias(name string) string {
return AliasTableName(t, name)
return Alias(t, name)
}
func (t *NewAuctionActivity) IncrMoneyById(id int64, money float64) (int64, error) {

2
models/new_vote_activity_history.go

@ -23,7 +23,7 @@ func (t *NewVoteActivityHistory) TableName() string {
}
func (t *NewVoteActivityHistory) Alias(name string) string {
return AliasTableName(t, name)
return Alias(t, name)
}
func (t *NewVoteActivityHistory) ExistByLadderId(uid, lid, rid int64) (bool, error) {

1
models/order_draw_record.go

@ -16,6 +16,7 @@ type OrderDrawRecord struct {
OrderDrawRuleLadderId int64 `json:"order_draw_rule_ladder_id" xorm:"not null comment('订单规则阶梯id')"`
OrderDrawRuleLadder *OrderDrawRuleLadder `json:"order_draw_rule_ladder" xorm:"-"`
UserId int64 `json:"user_id" xorm:"not null comment('用户id')"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
User *User `json:"user" xorm:"-"`
PrizeName string `json:"prize_name" xorm:"not null comment('奖品名字')"`
AreaId int64 `json:"area_id" xorm:"not null default(0) comment('地区id') BIGINT(20)"`

2
models/order_draw_rule.go

@ -27,7 +27,7 @@ func (t *OrderDrawRule) TableName() string {
}
func (t *OrderDrawRule) Alias(name string) string {
return AliasTableName(t, name)
return Alias(t, name)
}
func GetODRuleIdsByODActivityIds(ids []int64) ([]int64, error) {

2
models/order_draw_rule_ladder.go

@ -29,7 +29,7 @@ func (t *OrderDrawRuleLadder) TableName() string {
}
func (t *OrderDrawRuleLadder) Alias(name string) string {
return AliasTableName(t, name)
return Alias(t, name)
}
func UpdateODLadderStatusByODRuleIds(ids []int64) (int64, error) {

2
models/shake_red_envelope_activity.go

@ -28,7 +28,7 @@ func (t *ShakeRedEnvelopeActivity) TableName() string {
}
func (t *ShakeRedEnvelopeActivity) Alias(name string) string {
return AliasTableName(t, name)
return Alias(t, name)
}
func (t *ShakeRedEnvelopeActivity) GetPayedById(id int64) (bool, error) {

1
models/shake_red_envelope_record.go

@ -19,6 +19,7 @@ type ShakeRedEnvelopeRecord struct {
ShakeRedEnvelopeType int `json:"red_envelope_type" xorm:"not null default 0 comment('红包类型[0摇红包1直播红包]')"`
ShakeRedEnvelopeRuleId int64 `json:"shake_red_envelope_rule_id,omitempty" xorm:"not null default 0 comment('摇红包规则id') INT(11)"`
ShakeRedEnvelopeActivityId int64 `json:"shake_red_envelope_activity_id,omitempty" xorm:"not null default 0 comment('摇红包活动id') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
AreaId int64 `json:"area_id" xorm:"not null default 0 comment('地区id') INT(11)"`
Name string `json:"name" xorm:"not null default '' comment('红包名字') VARCHAR(255)"`
UserId int64 `json:"user_id" xorm:"not null default 0 comment('用户id') INT(11)"`

28
models/sign_history.go

@ -11,6 +11,7 @@ const SignHistoryTN = TableNamePrefix + "sign_history"
type SignHistory struct {
Id int64 `json:"id" xorm:"pk autoincr comment('主键') INT(11)"`
AreaId int64 `json:"area_id" xorm:"not null default 0 comment('地区id') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('主活动id') INT(11)"`
RehearsalId int64 `json:"rehearsal_id" xorm:"not null default 0 comment('彩排id/ 0正式') INT(11)"`
SignRuleId int64 `json:"sign_rule_id" xorm:"not null default 0 comment('sign_up表id') INT(11)"`
@ -29,33 +30,30 @@ func (t *SignHistory) TableName() string {
return SignHistoryTN
}
func (t *SignHistory) GetByUserId(aid, uid, rid, arid int64) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and activity_id=? and user_id=? and "+
"rehearsal_id=? and area_id=?", aid, uid, rid, arid).Get(t)
func (t *SignHistory) GetByUserId(activityId, archId, userId, rehearsalId, areaId interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and activity_id=? and arch_id=? and user_id=? and "+
"rehearsal_id=? and area_id=?", activityId, archId, userId, rehearsalId, areaId).Get(t)
}
func (t *SignHistory) Count(signUpId, activityId, rehearsalId interface{}) (int64, error) {
func (t *SignHistory) Count(signUpId, activityId, archId, rehearsalId interface{}) (int64, error) {
// 签到人数
return core.GetXormAuto().Where("is_delete=0 and sign_rule_id=? and rehearsal_id=? and activity_id=? and status=2",
signUpId, rehearsalId, activityId).Count(t)
return core.GetXormAuto().Where("is_delete=0 and sign_rule_id=? and "+
" activity_id=? and arch_id=? and rehearsal_id=? and status=2",
signUpId, activityId, archId, rehearsalId).Count(t)
}
func (t *SignHistory) UpdateById(ids interface{}, fields ...string) (err error) {
func (t *SignHistory) UpdateByIds(ids interface{}, fields ...string) (err error) {
if len(fields) > 0 {
_, err = core.GetXormAuto().In("id", ids).Cols(fields...).Update(t)
} else {
_, err = core.GetXormAuto().In("id", ids).AllCols().Update(t)
_, err = core.GetXormAuto().In("id", ids).Update(t)
}
return err
}
func (t *SignHistory) Insert() error {
_, err := core.GetXormAuto().InsertOne(t)
return err
}
func GetApplyRealSigns(aid interface{}, rid interface{}) ([]*SignHistory, error) {
func GetApplyRealSigns(activityId, archId, rehearsalId interface{}) ([]*SignHistory, error) {
results := make([]*SignHistory, 0)
err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=? and status=1",
aid, rid).Asc("updated_at").Find(&results)
err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and arch_id=? and rehearsal_id=? "+
" and status=1", activityId, archId, rehearsalId).Asc("updated_at").Find(&results)
return results, err
}

2
models/user.go

@ -37,7 +37,7 @@ func (t *User) TableName() string {
}
func (t *User) Alias(name string) string {
return AliasTableName(t, name)
return Alias(t, name)
}
func (t *User) GetUserByOpenid(openId string) (bool, error) {

2
models/user_order.go

@ -39,7 +39,7 @@ func (t *UserOrder) TableName() string {
}
func (t *UserOrder) AliasName(alias string) string {
return AliasTableName(t, alias)
return Alias(t, alias)
}
func (t *UserOrder) AddUserOrder() (int64, error) {

1
models/user_prize.go

@ -12,6 +12,7 @@ type UserPrize struct {
UserId int64 `json:"user_id" xorm:"not null comment('用户表id') INT(11)"`
ActivityId int64 `json:"activity_id" xorm:"not null comment('互动表id') INT(11)"`
RehearsalId int64 `json:"rehearsal_id" xorm:"not null default(0) comment('彩排id') INT(11)"`
ArchId int `json:"arch_id" xorm:"not null default 0 comment('归档id') INT(11)"`
ActivityName string `json:"activity_name" xorm:"not null default('') comment('互动名字') VARCHAR(128)"`
PrizeName string `json:"prize_name" xorm:"not null default('') comment('奖品名字') VARCHAR(128)"`
PrizeImg string `json:"prize_img" xorm:"not null default('') comment('奖品图片') VARCHAR(255)"`

2
services/lottery/lottery.go

@ -83,7 +83,7 @@ func GetLotteryAndLadder(activityId, rehearsalId interface{}) ([]*LotteryListRes
result := make([]*LotteryListResult, 0)
err := core.GetXormAuto().Table(new(models.LotteryDrawActivity)).Alias("a").
Select("a.id as lottery_draw_activity_id, r.id as lottery_draw_rule_id, a.lottery_draw_activity_name").
Join("LEFT", models.AliasTableName(new(models.LotteryDrawRule), "r"),
Join("LEFT", models.Alias(new(models.LotteryDrawRule), "r"),
"a.id=r.lottery_draw_activity_id and r.is_delete=0").
Where("a.is_delete=0 and a.activity_id=?", activityId).Find(&result)
if err != nil {

Loading…
Cancel
Save