Browse Source

sign history

master
黄梓健 5 years ago
parent
commit
cff1123c82
  1. 4
      controllers/author.go
  2. 9
      controllers/client/order_entry.go
  3. 11
      controllers/client/sign.go
  4. 4
      controllers/pc/login.go
  5. 4
      controllers/pc/sign.go
  6. 7
      models/order_entry_person.go
  7. 7
      models/real_sign_history.go
  8. 14
      models/sign_history.go
  9. 4
      models/user.go

4
controllers/author.go

@ -46,10 +46,6 @@ func (t *AuthorCtl) MustGetActivityId() int64 {
return t.MustGetInt64("activity_id")
}
func (t *AuthorCtl) MustGetName() string {
return t.claims.Username
}
func (t *AuthorCtl) MustGetCustomerId() int64 {
return t.claims.CustomerId
}

9
controllers/client/order_entry.go

@ -154,8 +154,13 @@ func (t *OrderEntryCtl) EntryOrders() {
uid := t.MustGetUID()
activityId := t.MustGetInt64("activity_id")
entry := new(models.OrderEntryPerson)
exist, err := entry.GetById(uid)
t.CheckErr(err)
t.Assert(exist, code.MSG_ENTRYPEOPLE_NOT_EXIST, "录入人员不存在")
activity := new(models.Activity)
exist, err := models.GetById(activity, activityId)
exist, err = models.GetById(activity, activityId)
t.CheckErr(err)
t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在")
@ -178,7 +183,7 @@ func (t *OrderEntryCtl) EntryOrders() {
data, err := invitation_service.GetOptionValue(optionItems, list[i].ExtraData)
t.CheckErr(err)
list[i].Extra = data
list[i].EntryName = t.MustGetName()
list[i].EntryName = entry.Name
}
t.JSON(map[string]interface{}{

11
controllers/client/sign.go

@ -23,6 +23,7 @@ func (t *SignCtl) Sign() {
uid := t.MustGetUID()
activityId := t.MustGetInt64("activity_id")
customerId := t.MustGetInt64("customer_id")
kind, _ := t.GetInt("kind")
//根据activity_id查找主活动的信息
activity := new(models.Activity)
@ -73,6 +74,7 @@ func (t *SignCtl) Sign() {
}
signHistory = new(models.SignHistory)
signHistory.Type = kind
signHistory.UserId = uid
signHistory.RehearsalId = activity.RehearsalId
signHistory.ActivityId = activityId
@ -102,8 +104,13 @@ func (t *SignCtl) RealSign() {
uid := t.MustGetUID()
rid := t.MustGetInt64("rehearsal_id")
user := new(models.User)
exist, err := user.GetById(uid)
t.CheckErr(err)
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在")
sign := new(models.SignUp)
exist, err := sign.GetByActivityId(aid)
exist, err = sign.GetByActivityId(aid)
t.CheckErr(err)
t.Assert(exist, code.MSG_SIGN_UP_NOT_EXIST, "签到活动不存在")
@ -132,7 +139,7 @@ func (t *SignCtl) RealSign() {
history.ActivityId = aid
history.UserId = uid
history.Nickname = t.MustGetName()
history.Nickname = user.Nickname
history.RehearsalId = rid
history.Content = string(body)
if exist { // 存在 直接通过

4
controllers/pc/login.go

@ -38,7 +38,7 @@ func (t *UserCtl) Login() {
t.CheckErr(err)
// 主账号无法确定
token, err := jwt.GenJwtToken("customer", customer.Id, customer.Id, customer.Pid, customer.AreaId, customer.ActivityId, customer.Username)
token, err := jwt.GenJwtToken("customer", customer.Id, customer.Id, customer.Pid, customer.AreaId, customer.ActivityId)
t.CheckErr(err)
t.SetSession(define.TOKEN, token)
customer.Token = token
@ -68,7 +68,7 @@ func (t *UserCtl) DebugLogin() {
t.CheckErr(err)
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在")
token, err := jwt.GenJwtToken("customer", customer.Id, customer.Id, customer.Pid, customer.AreaId, customer.ActivityId, customer.Username)
token, err := jwt.GenJwtToken("customer", customer.Id, customer.Id, customer.Pid, customer.AreaId, customer.ActivityId)
t.CheckErr(err)
t.SetSession(define.TOKEN, token)
t.JSON(map[string]interface{}{

4
controllers/pc/sign.go

@ -92,9 +92,7 @@ func (t *SignCtl) SignInfo() {
func (t *SignCtl) RealSignInfo() {
aid := t.MustGetActivityId()
rid := t.MustGetInt64("rehearsal_id")
results := make([]*models.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)
results, err := models.GetRealSignHistories(aid, rid)
t.CheckErr(err)
t.JSON(map[string]interface{}{
"result": results,

7
models/order_entry_person.go

@ -1,6 +1,7 @@
package models
import (
"github.com/ouxuanserver/osmanthuswine/src/core"
"time"
)
@ -26,6 +27,6 @@ func (t *OrderEntryPerson) TableName() string {
return OrderEntryPersonTableName
}
//func (t *OrderEntryPerson) GetById(eid int64) (bool, error) {
// return core.GetXormAuto().Where("is_delete=0 and id=?", eid).Get(t)
//}
func (t *OrderEntryPerson) GetById(id interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and id=?", id).Get(t)
}

7
models/real_sign_history.go

@ -47,3 +47,10 @@ 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
}

14
models/sign_history.go

@ -9,13 +9,13 @@ const SignHistoryTN = TableNamePrefix + "sign_history"
//签到历史表
type SignHistory struct {
Id int64 `json:"id" xorm:"pk autoincr comment('主键') BIGINT(20)"`
AreaId int64 `json:"area_id" xorm:"not null default 0 comment('地区id') BIGINT(20)"`
ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('主活动id') BIGINT(20)"`
RehearsalId int64 `json:"rehearsal_id" xorm:"not null default 0 comment('彩排id/ 0正式') BIGINT(20)"`
SignRuleId int64 `json:"sign_rule_id" xorm:"not null default 0 comment('sign_up表id') BIGINT(20)"`
UserId int64 `json:"user_id" xorm:"not null default 0 comment('用户表id') BIGINT(20)"`
User *User `json:"user" xorm:"-" description:"用户得信息"`
Id int64 `json:"id" xorm:"pk autoincr comment('主键') INT(11)"`
AreaId int64 `json:"area_id" xorm:"not null default 0 comment('地区id') INT(11)"`
ActivityId int64 `json:"activity_id" xorm:"not null default 0 comment('主活动id') 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)"`
Type int `json:"type" xorm:"not null default 0 comment('普通签到') INT(2)"`
UserId int64 `json:"user_id" xorm:"not null default 0 comment('用户表id') INT(11)"`
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"`

4
models/user.go

@ -43,6 +43,10 @@ func (t *User) GetUserByOpenid(openId string) (bool, error) {
return core.GetXormAuto().Where("openid=?", openId).Get(t)
}
func (t *User) GetById(id interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and id=?", id).Get(t)
}
func (t *User) SaveAndUpdateWithOpenId() error {
exist, err := core.GetXormAuto().Table(UserTN).Where("openid=?", t.Openid).Exist()
if err != nil {

Loading…
Cancel
Save