Browse Source

fix;bug

token_replace
Tooooommy 4 years ago
parent
commit
09be522af9
  1. 11
      controllers/client/sign.go
  2. 19
      controllers/pc/sign.go
  3. 17
      models/real_sign_list.go
  4. 16
      models/sign_history.go
  5. 6
      models/sign_up.go

11
controllers/client/sign.go

@ -162,7 +162,7 @@ func (t *SignCtl) Sign() {
}
// 签到人数
signTotal, err := history.Count(signUp.Id, activity.Id, activity.ArchId, activity.RehearsalId, 2)
signTotal, err := history.Count(activity.Id, activity.ArchId, activity.RehearsalId, 2)
t.CheckErr(err)
signUpTotal, err := new(models.InvitationLetter).Count(activity.Id, activity.ArchId, activity.RehearsalId)
@ -173,7 +173,6 @@ func (t *SignCtl) Sign() {
}
history = new(models.SignHistory)
history.Type = _type
history.UserId = uid
history.RehearsalId = activity.RehearsalId
history.ActivityId = activityId
@ -251,10 +250,15 @@ func (t *SignCtl) RealSign() {
realSignList := new(models.RealSignList)
exist, err = realSignList.CheckSignIn(activityId, extSql)
t.CheckErr(err)
if exist && realSignList.Status == 1 {
if exist {
existRsi, err := models.ExistReviewedSignInfo(activity.Id, activity.ArchId,
activity.RehearsalId, realSignList.Id)
t.CheckErr(err)
if existRsi {
t.ERROR("实名签到名单已被认证", code.MSG_SIGN_REAL_NOT_EXIST)
return
}
}
var body []byte
body, err = json.Marshal(params)
@ -268,6 +272,7 @@ func (t *SignCtl) RealSign() {
history.RehearsalId = activity.RehearsalId
history.AreaId = areaId
history.Content = string(body)
history.RealSignListId = realSignList.Id
if exist { // 存在 直接通过
history.Status = 2
} else {

19
controllers/pc/sign.go

@ -7,8 +7,6 @@ import (
"hudongzhuanjia/utils/code"
"hudongzhuanjia/utils/define"
"strings"
"github.com/ouxuanserver/osmanthuswine/src/core"
)
//签到
@ -57,13 +55,11 @@ func (t *SignCtl) Mode() {
func (t *SignCtl) List() {
activityId := t.MustGetInt("activity_id")
signUps := make([]*models.SignUp, 0)
err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId).
Asc("created_at").Find(&signUps)
sus, err := models.ListSignUp(activityId)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"total": len(signUps),
"list": signUps,
"total": len(sus),
"list": sus,
})
}
@ -102,9 +98,18 @@ func (t *SignCtl) RealSignInfo() {
results, err := models.GetApplyRealSigns(activity.Id, activity.ArchId, activity.RehearsalId)
t.CheckErr(err)
total, err := new(models.RealSignList).Count(activity.Id)
t.CheckErr(err)
signTotal, err := new(models.SignHistory).Count(activity.Id, activity.ArchId, activity.RehearsalId, 2)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"result": results,
"count": len(results),
"total": total,
"sign_total": signTotal,
"no_sign_total": total - signTotal,
})
}

17
models/real_sign_list.go

@ -1,22 +1,21 @@
package models
import (
"time"
"github.com/ouxuanserver/osmanthuswine/src/core"
)
const RealSignListTN = TableNamePrefix + "real_sign_list"
type RealSignList struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('是否删除') TINYINT(1)"`
CreatedAt time.Time `json:"created_at" xorm:"created comment('创建时间') TIMESTAMP"`
UpdatedAt time.Time `json:"updated_at" xorm:"updated comment('更新时间') TIMESTAMP"`
Model `xorm:"extends"`
//Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
//IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('是否删除') TINYINT(1)"`
//CreatedAt time.Time `json:"created_at" xorm:"created comment('创建时间') TIMESTAMP"`
//UpdatedAt time.Time `json:"updated_at" xorm:"updated comment('更新时间') TIMESTAMP"`
ActivityId int `json:"activity_id" xorm:"not null default 0 comment('主活动id') INT(11)"`
JsonList string `json:"json_list" xorm:"not null comment('名单记录') TEXT"`
Status int `json:"status" xorm:"not null default 0 comment('是否已被验证[0/1]') TINYINT(1)"`
//Status int `json:"status" xorm:"not null default 0 comment('是否已被验证[0/1]') TINYINT(1)"` // 废弃字段
}
func (t *RealSignList) TableName() string {
@ -28,3 +27,7 @@ func (t *RealSignList) CheckSignIn(aid int, ext string) (bool, error) {
ext += " 1 = 1 "
return core.GetXormAuto().Where("is_delete=0 and activity_id=?", aid).Where(ext).Get(t)
}
func (t *RealSignList) Count(activityId int) (int64, error) {
return core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId).Count(t)
}

16
models/sign_history.go

@ -19,7 +19,8 @@ type SignHistory struct {
ActivityId int `json:"activity_id" xorm:"not null default 0 comment('主活动id') INT(11)"`
RehearsalId int `json:"rehearsal_id" xorm:"not null default 0 comment('彩排id/ 0正式') INT(11)"`
SignRuleId int `json:"sign_rule_id" xorm:"not null default 0 comment('sign_up表id') INT(11)"`
Type int `json:"type" xorm:"not null default 0 comment('普通签到') TINYINT(1)"`
RealSignListId int `json:"real_sign_list_id" xorm:"not null default 0 comment('实名签到认证信息ID') INT(11)"`
// Type int `json:"type" xorm:"not null default 0 comment('普通签到') TINYINT(1)"`
UserId int `json:"user_id" xorm:"not null default 0 comment('用户表id') TINYINT(11)"`
SignMethod int `json:"sign_method" xorm:"not null default 0 comment('1扫码签到2实名签到3人脸签到') TINYINT(1)"`
Content string `json:"content" xorm:"json comment('提交审核的内容') TEXT"`
@ -36,11 +37,9 @@ func (t *SignHistory) GetByUserId(activityId, archId, userId, rehearsalId, areaI
"rehearsal_id=? and area_id=?", activityId, archId, userId, rehearsalId, areaId).Get(t)
}
func (t *SignHistory) Count(signUpId, activityId, archId, rehearsalId, status interface{}) (int64, error) {
// 签到人数
return core.GetXormAuto().Where("is_delete=0 and sign_rule_id=? and "+
" activity_id=? and arch_id=? and rehearsal_id=? and status=?",
signUpId, activityId, archId, rehearsalId, status).Count(t)
func (t *SignHistory) Count(activityId, archId, rehearsalId, status interface{}) (int64, error) {
return core.GetXormAuto().Where("is_delete=0 and activity_id=? and arch_id=? and "+
" rehearsal_id=? and status=?", activityId, archId, rehearsalId, status).Count(t)
}
func (t *SignHistory) UpdateByIds(ids interface{}, fields ...string) (err error) {
@ -75,3 +74,8 @@ func GetSignHistories(activityId, rehearsalId, archId, page, size int) (total in
total, err = session.FindAndCount(&result)
return
}
func ExistReviewedSignInfo(activityId, archId, rehearsalId, realSignListId interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and activity_id=? and arch_id=? and rehearsal_id=? and "+
" real_sign_list_id=? and status=2", activityId, archId, rehearsalId, realSignListId).Exist(&SignHistory{})
}

6
models/sign_up.go

@ -31,3 +31,9 @@ func (t *SignUp) TableName() string {
func (t *SignUp) GetByActivityId(aid int) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and activity_id=?", aid).Get(t)
}
func ListSignUp(activityId int) (sus []*SignUp, err error) {
err = core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId).
Asc("created_at").Find(&sus)
return
}
Loading…
Cancel
Save