@ -18,11 +18,40 @@ type SignCtl struct {
controllers . AuthorCtl
}
func ( t * SignCtl ) CheckSign ( ) {
activityId := t . MustGetInt64 ( "activity_id" )
uid := t . MustGetUID ( )
activity := models . Activity { }
exist , err := models . GetById ( & activity , activityId )
t . CheckErr ( err )
t . Assert ( exist , code . MSG_ACTIVITY_NOT_EXIST , "主活动不存在" )
customer := models . Customer { }
exist , err = models . GetById ( & 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 )
t . CheckErr ( err )
t . JSON ( signExist )
}
//签到动作
func ( t * SignCtl ) Sign ( ) {
uid := t . MustGetUID ( )
activityId := t . MustGetInt64 ( "activity_id" )
customerId := t . MustGetInt64 ( "customer_id" )
_type , _ := t . GetInt ( "_type" )
//根据activity_id查找主活动的信息
@ -32,16 +61,25 @@ func (t *SignCtl) Sign() {
t . Assert ( exist , code . MSG_ACTIVITY_NOT_EXIST , "互动不存在" )
t . CheckRunning ( activity . Status )
customer := new ( models . Customer )
exist , err = models . GetById ( customer , customerId )
t . CheckErr ( err )
t . Assert ( exist , code . MSG_CUSTOMER_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 )
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 )
}
t . CheckErr ( err )
t . Assert ( exist , code . MSG_AREASTORE_NOT_EXIST , "地区不存在" )
//根据activity_id查找副活动的规则信息
signUp := new ( models . SignUp )
exist , err = signUp . GetByActivityId ( activityId )
@ -79,7 +117,7 @@ func (t *SignCtl) Sign() {
signHistory . RehearsalId = activity . RehearsalId
signHistory . ActivityId = activityId
signHistory . SignRuleId = signUp . Id
signHistory . AreaId = user . Area Id
signHistory . AreaId = area . Id
signHistory . IsDelete = false
signHistory . UpdatedAt = time . Now ( )
signHistory . CreatedAt = time . Now ( )
@ -87,9 +125,9 @@ func (t *SignCtl) Sign() {
t . CheckErr ( err )
go ws_send_service . SendSign ( fmt . Sprintf ( "%d" , activity . Id ) ,
define . TYPE_CUSTOMER , customerId , map [ string ] interface { } {
define . TYPE_CUSTOMER , a ctivity . C ustomerId, map [ string ] interface { } {
"type" : "sign_up" ,
"customer_id" : customer . Id ,
"customer_id" : activity . Customer Id,
"data" : map [ string ] interface { } {
"avatar" : user . Avatar ,
"sign_total" : signTotal + 1 ,
@ -100,8 +138,8 @@ func (t *SignCtl) Sign() {
}
func ( t * SignCtl ) RealSign ( ) {
aid := t . MustGetActivityId ( )
uid := t . MustGetUID ( )
aid := t . MustGetInt64 ( "activity_id" )
uid := t . MustGetInt64 ( "user_id" )
rid := t . MustGetInt64 ( "rehearsal_id" )
user := new ( models . User )