You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
2.9 KiB
117 lines
2.9 KiB
package pc
|
|
|
|
import (
|
|
"hudongzhuanjia/controllers"
|
|
"hudongzhuanjia/models"
|
|
"hudongzhuanjia/utils"
|
|
"hudongzhuanjia/utils/code"
|
|
"hudongzhuanjia/utils/define"
|
|
"strings"
|
|
|
|
"github.com/ouxuanserver/osmanthuswine/src/core"
|
|
)
|
|
|
|
//签到
|
|
type SignCtl struct {
|
|
controllers.AuthorCtl
|
|
}
|
|
|
|
//获取二维码
|
|
func (t *SignCtl) Qrcode() {
|
|
activityId := t.MustGetInt64("activity_id")
|
|
uid := t.MustGetUID()
|
|
signUpId := t.MustGetInt64("sign_rule_id")
|
|
|
|
area := new(models.AreaStore)
|
|
exist, err := area.GetByCustomerId(uid, activityId)
|
|
t.CheckErr(err)
|
|
t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户信息异常")
|
|
|
|
//将服务器得地址和activity_id,动态生成二维码
|
|
qrcode, err := utils.GenH5Qrcode(define.H5SignIn, map[string]interface{}{
|
|
"activity_id": activityId,
|
|
"area_id": area.Id,
|
|
"customer_id": uid,
|
|
"sign_rule_id": signUpId,
|
|
})
|
|
t.CheckErr(err)
|
|
t.JSON(map[string]interface{}{
|
|
"qrcode": qrcode,
|
|
"logo": "",
|
|
})
|
|
|
|
}
|
|
|
|
//获取签到模式
|
|
func (t *SignCtl) Mode() {
|
|
activityId := t.MustGetInt64("activity_id")
|
|
|
|
//通过activity_id查询ox_sign_rule的id
|
|
signUp := new(models.SignUp)
|
|
exist, err := signUp.GetByActivityId(activityId)
|
|
t.CheckErr(err)
|
|
t.Assert(exist, code.MSG_SIGN_UP_NOT_EXIST, "签到规则不存在")
|
|
|
|
t.JSON(signUp.MaxModel)
|
|
}
|
|
|
|
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)
|
|
t.CheckErr(err)
|
|
t.JSON(map[string]interface{}{
|
|
"total": len(signUps),
|
|
"list": signUps,
|
|
})
|
|
}
|
|
|
|
type SignResult struct {
|
|
models.SignHistory `xorm:"extends"`
|
|
User *models.User `json:"user" xorm:"extends"`
|
|
}
|
|
|
|
//处理签到信息
|
|
func (t *SignCtl) SignInfo() {
|
|
aid := t.MustGetInt64("activity_id")
|
|
//activityId := t.MustGetInt64("activity_id")
|
|
rehearsalId := t.MustGetInt64("rehearsal_id")
|
|
|
|
result := make([]*SignResult, 0)
|
|
session := core.GetXormAuto().Table(new(models.SignHistory)).Alias("h").
|
|
Join("LEFT", new(models.User).Alias("u"), "h.user_id=u.id and u.is_delete=0").
|
|
Where("h.is_delete=0 and h.activity_id=? and rehearsal_id=?", aid, rehearsalId)
|
|
if t.PageSize > 0 { // 增加分页
|
|
session.Limit(t.PageSize, t.Page*t.PageSize)
|
|
}
|
|
count, err := session.FindAndCount(&result)
|
|
|
|
t.CheckErr(err)
|
|
|
|
t.JSON(map[string]interface{}{
|
|
"list": result,
|
|
"sign_up_total": count,
|
|
})
|
|
}
|
|
|
|
// 实名签到信息
|
|
func (t *SignCtl) RealSignInfo() {
|
|
aid := t.MustGetInt64("activity_id")
|
|
rid := t.MustGetInt64("rehearsal_id")
|
|
results, err := models.GetApplyRealSigns(aid, rid)
|
|
t.CheckErr(err)
|
|
t.JSON(map[string]interface{}{
|
|
"result": results,
|
|
"count": len(results),
|
|
})
|
|
}
|
|
|
|
func (t *SignCtl) RealSignVerify() {
|
|
ids := strings.Split(t.MustGet("real_sign_history_ids"), ",")
|
|
history := new(models.SignHistory)
|
|
history.Status = 2
|
|
err := history.UpdateById(ids, "status")
|
|
t.CheckErr(err)
|
|
t.SUCCESS("审核成功")
|
|
}
|