From 425d2fdd2a16c035d519aee9550b6bee2496dd75 Mon Sep 17 00:00:00 2001 From: tommy <3405129587@qq.com> Date: Wed, 27 May 2020 10:26:52 +0800 Subject: [PATCH] xxx --- controllers/client/login.go | 15 ++++--- controllers/client/sign.go | 28 ++++++------ controllers/pc/sign.go | 7 +-- models/base.go | 2 +- models/real_sign_history.go | 102 +++++++++++++++++++++----------------------- models/sign_history.go | 26 ++++++++++- models/sign_up.go | 1 + 7 files changed, 101 insertions(+), 80 deletions(-) diff --git a/controllers/client/login.go b/controllers/client/login.go index 1e6548f..20ec1a6 100644 --- a/controllers/client/login.go +++ b/controllers/client/login.go @@ -116,6 +116,11 @@ func (t *UserCtl) WxLogin() { } t.CheckErr(err) + sign := new(models.SignUp) + exist, err = sign.GetByActivityId(activityId) + t.CheckErr(err) + t.Assert(exist, code.MSG_SIGN_UP_NOT_EXIST, "签到活动不存在") + history := new(models.SignHistory) signExist, err := history.GetByUserId(activityId, user.Id, activity.RehearsalId, area.Id) t.CheckErr(err) @@ -124,13 +129,9 @@ func (t *UserCtl) WxLogin() { if signExist { // 存在数据 signIn = "已签到" } - sign := new(models.SignUp) - exist, err = sign.GetByActivityId(activityId) - t.CheckErr(err) - t.Assert(exist, code.MSG_SIGN_UP_NOT_EXIST, "签到活动不存在") - realSignExist, err := new(models.RealSignHistory).Check(user.Id, activity.Id, activity.RehearsalId) - t.CheckErr(err) + //realSignExist, err := new(models.RealSignHistory).Check(user.Id, activity.Id, activity.RehearsalId) + //t.CheckErr(err) jwtToken, err := jwt.GenJwtToken(define.TYPE_H5USER, user.Id, customer.Id, customer.Pid, area.Id, activityId) t.CheckErr(err) @@ -142,7 +143,7 @@ func (t *UserCtl) WxLogin() { "activity": activity, "sign_in": signIn, "sign": signExist, - "real_sign": realSignExist, + "sign_method": sign.SignMethod, "real_sign_form": sign.RealSignJsonForm, "tag": "activity", }) diff --git a/controllers/client/sign.go b/controllers/client/sign.go index b486060..290309c 100644 --- a/controllers/client/sign.go +++ b/controllers/client/sign.go @@ -166,22 +166,24 @@ func (t *SignCtl) Sign() { } func (t *SignCtl) RealSign() { - aid := t.MustGetInt64("activity_id") - uid := t.MustGetInt64("user_id") - rid := t.MustGetInt64("rehearsal_id") + activityId := t.MustGetInt64("activity_id") + userId := t.MustGetInt64("user_id") + rehearsalId := t.MustGetInt64("rehearsal_id") + areaId := t.MustGetAreaId() user := new(models.User) - exist, err := models.Get(user, uid) + exist, err := models.Get(user, userId) t.CheckErr(err) t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") sign := new(models.SignUp) - exist, err = sign.GetByActivityId(aid) + exist, err = sign.GetByActivityId(activityId) t.CheckErr(err) t.Assert(exist, code.MSG_SIGN_UP_NOT_EXIST, "签到活动不存在") + t.Assert(sign.SignMethod != 1, code.MSG_ERR_Param, "非实名签到") - history := new(models.RealSignHistory) - isSign, err := history.Info(uid, aid, rid) + history := new(models.SignHistory) + isSign, err := history.GetByUserId(activityId, userId, rehearsalId, areaId) t.CheckErr(err) if isSign && history.Status == 1 { t.SUCCESS("已通过实名签到") @@ -198,24 +200,22 @@ func (t *SignCtl) RealSign() { } } if len(extSql) > 0 { - exist, err = new(models.RealSignList).CheckSignIn(aid, extSql) + exist, err = new(models.RealSignList).CheckSignIn(activityId, extSql) var body []byte body, err = json.Marshal(params) t.CheckErr(err) - history.ActivityId = aid - history.UserId = uid + history.ActivityId = activityId + history.UserId = userId history.Nickname = user.Nickname - history.RehearsalId = rid + history.RehearsalId = rehearsalId + history.AreaId = areaId history.Content = string(body) if exist { // 存在 直接通过 history.Status = 1 } else { history.Status = 0 } - history.IsDelete = 0 - history.CreatedAt = time.Now() - history.UpdatedAt = time.Now() if isSign { err = history.UpdateById([]interface{}{history.Id}) } else { diff --git a/controllers/pc/sign.go b/controllers/pc/sign.go index 69d2c45..bd94377 100644 --- a/controllers/pc/sign.go +++ b/controllers/pc/sign.go @@ -58,7 +58,8 @@ func (t *SignCtl) Mode() { func (t *SignCtl) List() { activityId := t.MustGetInt64("activity_id") signUps := make([]*models.SignUp, 0) - err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId).Asc("created_at").Find(&signUps) + err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId). + Asc("created_at").Find(&signUps) t.CheckErr(err) t.JSON(map[string]interface{}{ "total": len(signUps), @@ -98,7 +99,7 @@ func (t *SignCtl) SignInfo() { func (t *SignCtl) RealSignInfo() { aid := t.MustGetInt64("activity_id") rid := t.MustGetInt64("rehearsal_id") - results, err := models.GetRealSignHistories(aid, rid) + results, err := models.GetSignHistories(aid, rid) t.CheckErr(err) t.JSON(map[string]interface{}{ "result": results, @@ -112,7 +113,7 @@ func (t *SignCtl) RealSignVerify() { for _, id := range ids { idList = append(idList, id) } - history := new(models.RealSignHistory) + history := new(models.SignHistory) history.Status = 1 err := history.UpdateById(idList, "status") t.CheckErr(err) diff --git a/models/base.go b/models/base.go index cb14436..cf3cbb8 100644 --- a/models/base.go +++ b/models/base.go @@ -76,7 +76,7 @@ func init() { new(UserOrder), new(UserRedPack), new(RealSignList), - new(RealSignHistory), + //new(RealSignHistory), new(LiveViewer), new(LiveConfig), new(LiveRedEnvelopeRule), diff --git a/models/real_sign_history.go b/models/real_sign_history.go index 498c2ff..3767865 100644 --- a/models/real_sign_history.go +++ b/models/real_sign_history.go @@ -1,56 +1,50 @@ package models -import ( - "time" - - "github.com/ouxuanserver/osmanthuswine/src/core" -) - -const RealSignHistoryTN = TableNamePrefix + "real_sign_history" - -type RealSignHistory struct { - Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"` - ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('主活动') INT(11)"` - UserId int64 `json:"user_id" xorm:"not null default 0 comment('用户id') INT(11)"` - Nickname string `json:"nickname" xorm:"not null default('') comment('微信昵称') VARCHAR(128)"` - RehearsalId int64 `json:"rehearsal_id" xorm:"not null default 0 comment('彩排id') INT(11)"` - Content string `json:"content" xorm:"not null comment('提交审核的内容') TEXT"` - Status int64 `json:"status" xorm:"not null default 0 comment('是否通过审核') TINYINT(1)"` - IsDelete int `json:"is_delete" xorm:"not null default(0) comment('是否删除') TINYINT(1)"` - CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"` - UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') TIMESTAMP"` -} - -func (t *RealSignHistory) TableName() string { - return RealSignHistoryTN -} - -func (t *RealSignHistory) Info(uid, aid, rid int64) (bool, error) { - return core.GetXormAuto().Where("is_delete=0 and user_id=? and activity_id=? and rehearsal_id=?", - uid, aid, rid).Get(t) -} - -func (t *RealSignHistory) Check(uid, aid, rid int64) (bool, error) { - return core.GetXormAuto().Where("is_delete=0 and user_id=? and activity_id=? and rehearsal_id=? and status=1", - uid, aid, rid).Get(t) -} - -func (t *RealSignHistory) UpdateById(ids interface{}, fields ...string) (err error) { - if len(fields) > 0 { - _, err = core.GetXormAuto().In("id", ids).Cols(fields...).Update(t) - } else { - _, err = core.GetXormAuto().In("id", ids).AllCols().Update(t) - } - return err -} -func (t *RealSignHistory) Insert() error { - _, err := core.GetXormAuto().InsertOne(t) - return err -} - -func GetRealSignHistories(aid interface{}, rid interface{}) ([]*RealSignHistory, error) { - results := make([]*RealSignHistory, 0) - err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=? and status=0", - aid, rid).Asc("updated_at").Find(&results) - return results, err -} +//const RealSignHistoryTN = TableNamePrefix + "real_sign_history" + +//type RealSignHistory struct { +// Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"` +// ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('主活动') INT(11)"` +// UserId int64 `json:"user_id" xorm:"not null default 0 comment('用户id') INT(11)"` +// Nickname string `json:"nickname" xorm:"not null default('') comment('微信昵称') VARCHAR(128)"` +// RehearsalId int64 `json:"rehearsal_id" xorm:"not null default 0 comment('彩排id') INT(11)"` +// Content string `json:"content" xorm:"not null comment('提交审核的内容') TEXT"` +// Status int64 `json:"status" xorm:"not null default 0 comment('是否通过审核') TINYINT(1)"` +// IsDelete int `json:"is_delete" xorm:"not null default(0) comment('是否删除') TINYINT(1)"` +// CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"` +// UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') TIMESTAMP"` +//} + +//func (t *RealSignHistory) TableName() string { +// return RealSignHistoryTN +//} +// +//func (t *RealSignHistory) Info(uid, aid, rid int64) (bool, error) { +// return core.GetXormAuto().Where("is_delete=0 and user_id=? and activity_id=? and rehearsal_id=?", +// uid, aid, rid).Get(t) +//} +// +//func (t *RealSignHistory) Check(uid, aid, rid int64) (bool, error) { +// return core.GetXormAuto().Where("is_delete=0 and user_id=? and activity_id=? and rehearsal_id=? and status=1", +// uid, aid, rid).Get(t) +//} +// +//func (t *RealSignHistory) UpdateById(ids interface{}, fields ...string) (err error) { +// if len(fields) > 0 { +// _, err = core.GetXormAuto().In("id", ids).Cols(fields...).Update(t) +// } else { +// _, err = core.GetXormAuto().In("id", ids).AllCols().Update(t) +// } +// return err +//} +//func (t *RealSignHistory) Insert() error { +// _, err := core.GetXormAuto().InsertOne(t) +// return err +//} +// +//func GetRealSignHistories(aid interface{}, rid interface{}) ([]*RealSignHistory, error) { +// results := make([]*RealSignHistory, 0) +// err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=? and status=0", +// aid, rid).Asc("updated_at").Find(&results) +// return results, err +//} diff --git a/models/sign_history.go b/models/sign_history.go index 1278252..114ec26 100644 --- a/models/sign_history.go +++ b/models/sign_history.go @@ -15,7 +15,11 @@ type SignHistory struct { RehearsalId int64 `json:"rehearsal_id" xorm:"not null default 0 comment('彩排id/ 0正式') INT(11)"` SignRuleId int64 `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)"` - UserId int64 `json:"user_id" xorm:"not null default 0 comment('用户表id') INT(11)"` + UserId int64 `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:"not null comment('提交审核的内容') TEXT"` + Nickname string `json:"nickname" xorm:"not null default('') comment('微信昵称') VARCHAR(128)"` + Status int64 `json:"status" xorm:"not null default 0 comment('是否通过审核') TINYINT(1)"` IsDelete bool `json:"is_delete" xorm:"not null default(0) comment('删除') TINYINT(1)"` CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"` UpdatedAt time.Time `json:"updated_at" xorm:"not null updated comment('更新时间') DATETIME"` @@ -35,3 +39,23 @@ func (t *SignHistory) Count(signUpId, activityId, rehearsalId interface{}) (int6 return core.GetXormAuto().Where("is_delete=0 and sign_rule_id=? and rehearsal_id=? and activity_id=?", signUpId, rehearsalId, activityId).Count(t) } + +func (t *SignHistory) UpdateById(ids interface{}, fields ...string) (err error) { + if len(fields) > 0 { + _, err = core.GetXormAuto().In("id", ids).Cols(fields...).Update(t) + } else { + _, err = core.GetXormAuto().In("id", ids).AllCols().Update(t) + } + return err +} +func (t *SignHistory) Insert() error { + _, err := core.GetXormAuto().InsertOne(t) + return err +} + +func GetSignHistories(aid interface{}, rid interface{}) ([]*SignHistory, error) { + results := make([]*SignHistory, 0) + err := core.GetXormAuto().Where("is_delete=0 and activity_id=? and rehearsal_id=? and status=0", + aid, rid).Asc("updated_at").Find(&results) + return results, err +} diff --git a/models/sign_up.go b/models/sign_up.go index 98f3082..af6fb0f 100644 --- a/models/sign_up.go +++ b/models/sign_up.go @@ -16,6 +16,7 @@ type SignUp struct { LogoUrl string `json:"logo_url"` RealSignJsonForm string `json:"real_sign_json_form"` RealSignJsonTitle string `json:"real_sign_json_title"` + SignMethod int `json:"sign_method"` RealSignListPath string `json:"real_sign_list_path"` IsDelete bool `json:"is_delete" xorm:"default(0)" description:"是否删除"` CreatedAt time.Time `json:"created_at" xorm:"created" description:"创建时间"`