package pc import ( "hudongzhuanjia/controllers" "hudongzhuanjia/models" "hudongzhuanjia/utils" "hudongzhuanjia/utils/code" "hudongzhuanjia/utils/define" "strings" ) //签到 type SignCtl struct { controllers.AuthorCtl } //获取二维码 func (t *SignCtl) Qrcode() { activityId := t.MustGetInt("activity_id") uid := t.GetAccountId() signUpId := t.MustGetInt("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.MustGetInt("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.MustGetInt("activity_id") sus, err := models.ListSignUp(activityId) t.CheckErr(err) t.JSON(map[string]interface{}{ "total": len(sus), "list": sus, }) } type SignResult struct { models.SignHistory `xorm:"extends"` User *models.User `json:"user" xorm:"extends"` } //处理签到信息 func (t *SignCtl) SignInfo() { activityId := t.MustGetInt("activity_id") activity := &models.Activity{} exist, err := models.Get(activity, activityId) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") count, result, err := models.GetSignHistories(activity.Id, activity.RehearsalId, activity.ArchId, t.Page, t.PageSize) t.CheckErr(err) t.JSON(map[string]interface{}{ "list": result, "sign_up_total": count, }) } // 实名签到信息 func (t *SignCtl) RealSignInfo() { aid := t.MustGetInt("activity_id") activity := &models.Activity{} exist, err := models.Get(activity, aid) t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") 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, }) } // 审核实名签到 func (t *SignCtl) RealSignVerify() { ids := strings.Split(t.MustGet("real_sign_history_ids"), ",") history := new(models.SignHistory) history.Status = 2 err := history.UpdateByIds(ids, "status") t.CheckErr(err) t.SUCCESS("审核成功") }