黄梓健 5 years ago
parent
commit
425d2fdd2a
  1. 15
      controllers/client/login.go
  2. 28
      controllers/client/sign.go
  3. 7
      controllers/pc/sign.go
  4. 2
      models/base.go
  5. 102
      models/real_sign_history.go
  6. 26
      models/sign_history.go
  7. 1
      models/sign_up.go

15
controllers/client/login.go

@ -116,6 +116,11 @@ func (t *UserCtl) WxLogin() {
} }
t.CheckErr(err) 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) history := new(models.SignHistory)
signExist, err := history.GetByUserId(activityId, user.Id, activity.RehearsalId, area.Id) signExist, err := history.GetByUserId(activityId, user.Id, activity.RehearsalId, area.Id)
t.CheckErr(err) t.CheckErr(err)
@ -124,13 +129,9 @@ func (t *UserCtl) WxLogin() {
if signExist { // 存在数据 if signExist { // 存在数据
signIn = "已签到" 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) jwtToken, err := jwt.GenJwtToken(define.TYPE_H5USER, user.Id, customer.Id, customer.Pid, area.Id, activityId)
t.CheckErr(err) t.CheckErr(err)
@ -142,7 +143,7 @@ func (t *UserCtl) WxLogin() {
"activity": activity, "activity": activity,
"sign_in": signIn, "sign_in": signIn,
"sign": signExist, "sign": signExist,
"real_sign": realSignExist,
"sign_method": sign.SignMethod,
"real_sign_form": sign.RealSignJsonForm, "real_sign_form": sign.RealSignJsonForm,
"tag": "activity", "tag": "activity",
}) })

28
controllers/client/sign.go

@ -166,22 +166,24 @@ func (t *SignCtl) Sign() {
} }
func (t *SignCtl) RealSign() { 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) user := new(models.User)
exist, err := models.Get(user, uid)
exist, err := models.Get(user, userId)
t.CheckErr(err) t.CheckErr(err)
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在")
sign := new(models.SignUp) sign := new(models.SignUp)
exist, err = sign.GetByActivityId(aid)
exist, err = sign.GetByActivityId(activityId)
t.CheckErr(err) t.CheckErr(err)
t.Assert(exist, code.MSG_SIGN_UP_NOT_EXIST, "签到活动不存在") 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) t.CheckErr(err)
if isSign && history.Status == 1 { if isSign && history.Status == 1 {
t.SUCCESS("已通过实名签到") t.SUCCESS("已通过实名签到")
@ -198,24 +200,22 @@ func (t *SignCtl) RealSign() {
} }
} }
if len(extSql) > 0 { if len(extSql) > 0 {
exist, err = new(models.RealSignList).CheckSignIn(aid, extSql)
exist, err = new(models.RealSignList).CheckSignIn(activityId, extSql)
var body []byte var body []byte
body, err = json.Marshal(params) body, err = json.Marshal(params)
t.CheckErr(err) t.CheckErr(err)
history.ActivityId = aid
history.UserId = uid
history.ActivityId = activityId
history.UserId = userId
history.Nickname = user.Nickname history.Nickname = user.Nickname
history.RehearsalId = rid
history.RehearsalId = rehearsalId
history.AreaId = areaId
history.Content = string(body) history.Content = string(body)
if exist { // 存在 直接通过 if exist { // 存在 直接通过
history.Status = 1 history.Status = 1
} else { } else {
history.Status = 0 history.Status = 0
} }
history.IsDelete = 0
history.CreatedAt = time.Now()
history.UpdatedAt = time.Now()
if isSign { if isSign {
err = history.UpdateById([]interface{}{history.Id}) err = history.UpdateById([]interface{}{history.Id})
} else { } else {

7
controllers/pc/sign.go

@ -58,7 +58,8 @@ func (t *SignCtl) Mode() {
func (t *SignCtl) List() { func (t *SignCtl) List() {
activityId := t.MustGetInt64("activity_id") activityId := t.MustGetInt64("activity_id")
signUps := make([]*models.SignUp, 0) 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.CheckErr(err)
t.JSON(map[string]interface{}{ t.JSON(map[string]interface{}{
"total": len(signUps), "total": len(signUps),
@ -98,7 +99,7 @@ func (t *SignCtl) SignInfo() {
func (t *SignCtl) RealSignInfo() { func (t *SignCtl) RealSignInfo() {
aid := t.MustGetInt64("activity_id") aid := t.MustGetInt64("activity_id")
rid := t.MustGetInt64("rehearsal_id") rid := t.MustGetInt64("rehearsal_id")
results, err := models.GetRealSignHistories(aid, rid)
results, err := models.GetSignHistories(aid, rid)
t.CheckErr(err) t.CheckErr(err)
t.JSON(map[string]interface{}{ t.JSON(map[string]interface{}{
"result": results, "result": results,
@ -112,7 +113,7 @@ func (t *SignCtl) RealSignVerify() {
for _, id := range ids { for _, id := range ids {
idList = append(idList, id) idList = append(idList, id)
} }
history := new(models.RealSignHistory)
history := new(models.SignHistory)
history.Status = 1 history.Status = 1
err := history.UpdateById(idList, "status") err := history.UpdateById(idList, "status")
t.CheckErr(err) t.CheckErr(err)

2
models/base.go

@ -76,7 +76,7 @@ func init() {
new(UserOrder), new(UserOrder),
new(UserRedPack), new(UserRedPack),
new(RealSignList), new(RealSignList),
new(RealSignHistory),
//new(RealSignHistory),
new(LiveViewer), new(LiveViewer),
new(LiveConfig), new(LiveConfig),
new(LiveRedEnvelopeRule), new(LiveRedEnvelopeRule),

102
models/real_sign_history.go

@ -1,56 +1,50 @@
package models 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
//}

26
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)"` 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)"` 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)"` 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)"` 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"` CreatedAt time.Time `json:"created_at" xorm:"not null created comment('创建时间') DATETIME"`
UpdatedAt time.Time `json:"updated_at" xorm:"not null updated 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=?", return core.GetXormAuto().Where("is_delete=0 and sign_rule_id=? and rehearsal_id=? and activity_id=?",
signUpId, rehearsalId, activityId).Count(t) 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
}

1
models/sign_up.go

@ -16,6 +16,7 @@ type SignUp struct {
LogoUrl string `json:"logo_url"` LogoUrl string `json:"logo_url"`
RealSignJsonForm string `json:"real_sign_json_form"` RealSignJsonForm string `json:"real_sign_json_form"`
RealSignJsonTitle string `json:"real_sign_json_title"` RealSignJsonTitle string `json:"real_sign_json_title"`
SignMethod int `json:"sign_method"`
RealSignListPath string `json:"real_sign_list_path"` RealSignListPath string `json:"real_sign_list_path"`
IsDelete bool `json:"is_delete" xorm:"default(0)" description:"是否删除"` IsDelete bool `json:"is_delete" xorm:"default(0)" description:"是否删除"`
CreatedAt time.Time `json:"created_at" xorm:"created" description:"创建时间"` CreatedAt time.Time `json:"created_at" xorm:"created" description:"创建时间"`

Loading…
Cancel
Save