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