|
@@ -162,6 +162,14 @@ func GetActivitySignupByUserCount(uid, activityId int) (count int, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+//获取用户报名禁止数量
|
|
|
+func GetActivitySignupByUserRestrictCount(uid, activityId int) (count int, err error) {
|
|
|
+ sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE do_fail_type=3 AND user_id=? AND activity_id=? `
|
|
|
+ o := orm.NewOrm()
|
|
|
+ err = o.Raw(sqlCount, uid, activityId).QueryRow(&count)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
//获取某一活动已经报名的数量
|
|
|
func GetActivitySignupSuccessCount(activityId int) (count int, err error) {
|
|
|
sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE is_cancel=0 AND fail_type = 0 AND activity_id=? `
|
|
@@ -245,3 +253,42 @@ func GetActivitySignupDetail(activityId, uid int) (item *CygxActivitySignup, err
|
|
|
err = o.Raw(sql, activityId, uid).QueryRow(&item)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+//解除报名限制之后二次报名
|
|
|
+func AddActivitySignupByRestrict(item *CygxActivitySignup) (lastId int64, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ o.Begin()
|
|
|
+ defer func() {
|
|
|
+ fmt.Println(err)
|
|
|
+ if err == nil {
|
|
|
+ o.Commit()
|
|
|
+ } else {
|
|
|
+ o.Rollback()
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ itemMy := new(CygxMySchedule)
|
|
|
+ itemMy.UserId = item.UserId
|
|
|
+ itemMy.ActivityId = item.ActivityId
|
|
|
+ itemMy.CreateTime = time.Now()
|
|
|
+ itemMy.Mobile = item.Mobile
|
|
|
+ itemMy.Email = item.Email
|
|
|
+ itemMy.CompanyId = item.CompanyId
|
|
|
+ itemMy.CompanyName = item.CompanyName
|
|
|
+ lastId, err = o.Insert(itemMy)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ sql := `UPDATE cygx_activity_signup SET do_fail_type = 0 , fail_type=0 WHERE user_id=? AND activity_id=? `
|
|
|
+ _, err = o.Raw(sql, item.UserId, item.ActivityId).Exec()
|
|
|
+ itemLog := new(CygxActivitySignupLog)
|
|
|
+ itemLog.UserId = item.UserId
|
|
|
+ itemLog.ActivityId = item.ActivityId
|
|
|
+ itemLog.CreateTime = time.Now()
|
|
|
+ itemLog.Mobile = item.Mobile
|
|
|
+ itemLog.Email = item.Email
|
|
|
+ itemLog.CompanyId = item.CompanyId
|
|
|
+ itemLog.CompanyName = item.CompanyName
|
|
|
+ itemLog.Type = 1
|
|
|
+ lastId, err = o.Insert(itemLog)
|
|
|
+ return
|
|
|
+}
|