Browse Source

sign and history

master
黄梓健 5 years ago
parent
commit
3ead6974ed
  1. 2
      controllers/client/live.go
  2. 2
      controllers/client/login.go
  3. 43
      controllers/client/sign.go
  4. 2
      models/sign_history.go

2
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 {

2
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 = "已签到"
}

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

2
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)
}

Loading…
Cancel
Save