diff --git a/controllers/client/live.go b/controllers/client/live.go index 8acfab4..e5d620b 100644 --- a/controllers/client/live.go +++ b/controllers/client/live.go @@ -45,7 +45,7 @@ func (t *LiveCtl) Detail() { fs["is_order"] = 0 fs["is_lottery"] = 0 if live.AdaptationFunc != nil && len(live.AdaptationFunc) != 0 { - modules := make([]*models.ModuleService, 0) + modules := make([]*models.ModuleServiceHistory, 0) err = core.GetXormAuto().Where("is_delete=0").In("id", live.AdaptationFunc).Find(&modules) t.CheckErr(err) for _, module := range modules { diff --git a/controllers/client/login.go b/controllers/client/login.go index 18abcc4..8d2f2b1 100644 --- a/controllers/client/login.go +++ b/controllers/client/login.go @@ -128,7 +128,7 @@ func (t *UserCtl) WxLogin() { t.CheckErr(err) var signIn = "未签到" - if signExist { // 存在数据 + if signExist && history.Status == 2 { // 存在数据 signIn = "已签到" } diff --git a/controllers/client/sign.go b/controllers/client/sign.go index 221d6f2..a393aaa 100644 --- a/controllers/client/sign.go +++ b/controllers/client/sign.go @@ -56,8 +56,11 @@ func (t *SignCtl) CheckSign() { history := new(models.SignHistory) signExist, err := history.GetByUserId(activityId, uid, activity.RehearsalId, area.Id) t.CheckErr(err) - - t.JSON(signExist) + if !signExist || history.Status != 2 { + t.JSON(false) + } else { + t.JSON(true) + } } func (t *SignCtl) Setting() { @@ -129,13 +132,15 @@ func (t *SignCtl) Sign() { t.Assert(exist, code.MSG_INVITE_LETTER_NOT_EXIST, "您没收到邀请函") } //检查是否已经签到了 - signHistory := new(models.SignHistory) - exist, err = signHistory.GetByUserId(activityId, uid, activity.RehearsalId, area.Id) + history := new(models.SignHistory) + exist, err = history.GetByUserId(activityId, uid, activity.RehearsalId, area.Id) t.CheckErr(err) - t.Assert(!exist, code.MSG_SIGN_HISTORY_EXIST, "您已经签到过了") // 存在判断 + if exist || history.Status == 2 { + t.ERROR("您已经签到过了", code.MSG_SIGN_HISTORY_EXIST) + } // 签到人数 - signTotal, err := signHistory.Count(signUp.Id, activity.RehearsalId, activity.Id) + signTotal, err := history.Count(signUp.Id, activity.RehearsalId, activity.Id) t.CheckErr(err) signUpTotal, err := new(models.InvitationLetter).Count(activity.Id, activity.RehearsalId) @@ -145,18 +150,18 @@ func (t *SignCtl) Sign() { t.ERROR("彩排人数不能超过10人", code.MSG_SIGN_UP_REHEARSAL_LIMIT) } - signHistory = new(models.SignHistory) - signHistory.Type = _type - signHistory.UserId = uid - signHistory.RehearsalId = activity.RehearsalId - signHistory.ActivityId = activityId - signHistory.SignRuleId = signUp.Id - signHistory.AreaId = areaId - signHistory.Status = 2 - signHistory.IsDelete = false - signHistory.UpdatedAt = time.Now() - signHistory.CreatedAt = time.Now() - _, err = models.Add(signHistory) + history = new(models.SignHistory) + history.Type = _type + history.UserId = uid + history.RehearsalId = activity.RehearsalId + history.ActivityId = activityId + history.SignRuleId = signUp.Id + history.AreaId = areaId + history.Status = 2 + history.IsDelete = false + history.UpdatedAt = time.Now() + history.CreatedAt = time.Now() + _, err = models.Add(history) t.CheckErr(err) go ws_send_service.SendSign(fmt.Sprintf("%d", activity.Id), @@ -176,7 +181,7 @@ func (t *SignCtl) Sign() { func (t *SignCtl) RealSign() { activityId := t.MustGetInt64("activity_id") userId := t.MustGetUID() - areaId := t.MustGetAreaId() + areaId := t.MustGetInt64("area_id") user := new(models.User) exist, err := models.Get(user, userId) diff --git a/models/sign_history.go b/models/sign_history.go index 9b1001d..a5fec95 100644 --- a/models/sign_history.go +++ b/models/sign_history.go @@ -30,7 +30,7 @@ func (t *SignHistory) TableName() string { } func (t *SignHistory) GetByUserId(aid, uid, rid, arid int64) (bool, error) { - return core.GetXormAuto().Where("is_delete=0 and status=2 and activity_id=? and user_id=? and "+ + 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) }