|
|
@ -94,7 +94,15 @@ func (t *SignCtl) Setting() { |
|
|
|
func (t *SignCtl) Sign() { |
|
|
|
uid := t.MustGetUID() |
|
|
|
activityId := t.MustGetInt64("activity_id") |
|
|
|
_type, _ := t.GetInt("_type") |
|
|
|
_type := t.DefaultInt("_type", 0) // 默认 0
|
|
|
|
|
|
|
|
// 适配直播
|
|
|
|
var areaId int64 = 0 |
|
|
|
if _type == 0 { |
|
|
|
areaId = t.MustGetAreaId() |
|
|
|
} else { |
|
|
|
areaId = t.MustGetInt64("area_id") |
|
|
|
} |
|
|
|
|
|
|
|
//根据activity_id查找主活动的信息
|
|
|
|
activity := new(models.Activity) |
|
|
@ -102,24 +110,16 @@ func (t *SignCtl) Sign() { |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") |
|
|
|
|
|
|
|
user := new(models.User) |
|
|
|
exist, err = models.GetById(user, uid) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") |
|
|
|
|
|
|
|
customer := models.Customer{} |
|
|
|
exist, err = models.GetById(&customer, activity.CustomerId) |
|
|
|
// 根据areaId
|
|
|
|
customer := new(models.Customer) |
|
|
|
exist, err = customer.GetByActivityIdAndAreaId(activityId, areaId) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") |
|
|
|
|
|
|
|
var area = new(models.AreaStore) |
|
|
|
if customer.AreaId == 0 { |
|
|
|
exist, err = area.GetMainAreaById(activityId) |
|
|
|
} else { |
|
|
|
exist, err = area.GetAreaStoreById(customer.AreaId) |
|
|
|
} |
|
|
|
user := new(models.User) |
|
|
|
exist, err = models.GetById(user, uid) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") |
|
|
|
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") |
|
|
|
|
|
|
|
//根据activity_id查找副活动的规则信息
|
|
|
|
signUp := new(models.SignUp) |
|
|
@ -127,7 +127,7 @@ func (t *SignCtl) Sign() { |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_DATA_NOT_EXIST, "签到规则不存在") |
|
|
|
|
|
|
|
if signUp.OnlyInvitation == 1 { //
|
|
|
|
if signUp.OnlyInvitation == 1 && _type == 0 { // 直播不需要进行邀请函
|
|
|
|
// 邀请函才能签到
|
|
|
|
letter := new(models.InvitationLetter) |
|
|
|
exist, err := letter.GetByUserIdAndActivityId(uid, activityId, activity.RehearsalId) |
|
|
@ -158,7 +158,7 @@ func (t *SignCtl) Sign() { |
|
|
|
signHistory.RehearsalId = activity.RehearsalId |
|
|
|
signHistory.ActivityId = activityId |
|
|
|
signHistory.SignRuleId = signUp.Id |
|
|
|
signHistory.AreaId = area.Id |
|
|
|
signHistory.AreaId = areaId |
|
|
|
signHistory.IsDelete = false |
|
|
|
signHistory.UpdatedAt = time.Now() |
|
|
|
signHistory.CreatedAt = time.Now() |
|
|
@ -168,7 +168,7 @@ func (t *SignCtl) Sign() { |
|
|
|
go ws_send_service.SendSign(fmt.Sprintf("%d", activity.Id), |
|
|
|
define.TYPE_CUSTOMER, activity.CustomerId, map[string]interface{}{ |
|
|
|
"type": "sign_up", |
|
|
|
"customer_id": activity.CustomerId, |
|
|
|
"customer_id": customer.Id, |
|
|
|
"data": map[string]interface{}{ |
|
|
|
"avatar": user.Avatar, |
|
|
|
"sign_total": signTotal + 1, |
|
|
|