|
|
@ -3,9 +3,7 @@ package client |
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"github.com/ouxuanserver/osmanthuswine/src/core" |
|
|
|
"hudongzhuanjia/controllers" |
|
|
|
"hudongzhuanjia/logger" |
|
|
|
"hudongzhuanjia/models" |
|
|
|
ws_send_service "hudongzhuanjia/services/ws_send" |
|
|
|
"hudongzhuanjia/utils/code" |
|
|
@ -70,15 +68,12 @@ func (t *SignCtl) Setting() { |
|
|
|
exist, err := service.GetByName(define.MODULE_SIGNIN) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "签到模块不存在") |
|
|
|
histories := make([]*models.ModuleServiceHistory, 0) |
|
|
|
err = core.GetXormAuto().Where("is_delete=0 and service_module_id=? and name=?", service.Id, service.Name).Find(&histories) |
|
|
|
t.CheckErr(err) |
|
|
|
historyIds := make([]int64, 0) |
|
|
|
for _, history := range histories { |
|
|
|
historyIds = append(historyIds, history.Id) |
|
|
|
} |
|
|
|
err = models.GetModuleServiceHistoryIdsByIdAndName(&historyIds, service.Id, service.Name) |
|
|
|
t.CheckErr(err) |
|
|
|
|
|
|
|
module := new(models.ActivityModuleService) |
|
|
|
exist, err = core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId).In("service_module_history_id", historyIds).Get(module) |
|
|
|
exist, err = module.GetByActivityIdAndHistoryIds(activityId, historyIds) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_MODULE_NOT_EXIST, "签到模块不存在") |
|
|
|
|
|
|
@ -111,9 +106,6 @@ func (t *SignCtl) Sign() { |
|
|
|
|
|
|
|
user := new(models.User) |
|
|
|
exist, err = models.Get(user, uid) |
|
|
|
logger.Error("user:===>%+v", user) |
|
|
|
logger.Error("token:==>%v", t.MustGet("token")) |
|
|
|
logger.Error("user_id:===>%v", uid) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") |
|
|
|
|
|
|
@ -132,16 +124,15 @@ func (t *SignCtl) Sign() { |
|
|
|
} |
|
|
|
//检查是否已经签到了
|
|
|
|
signHistory := new(models.SignHistory) |
|
|
|
exist, err = signHistory.GetByUserId(activityId, uid, activity.RehearsalId, t.MustGetAreaId()) |
|
|
|
exist, err = signHistory.GetByUserId(activityId, uid, activity.RehearsalId, area.Id) |
|
|
|
t.CheckErr(err) |
|
|
|
t.Assert(!exist, code.MSG_SIGN_HISTORY_EXIST, "您已经签到过了") // 存在判断
|
|
|
|
|
|
|
|
// 签到人数
|
|
|
|
signTotal, err := core.GetXormAuto().Where("is_delete=0 and sign_rule_id=? and rehearsal_id=? and activity_id=?", |
|
|
|
signUp.Id, activity.RehearsalId, activity.Id).Count(signHistory) |
|
|
|
signTotal, err := signHistory.Count(signUp.Id, activity.RehearsalId, activity.Id) |
|
|
|
t.CheckErr(err) |
|
|
|
|
|
|
|
signUpTotal, err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", activity.Id).Count(new(models.InvitationLetter)) |
|
|
|
signUpTotal, err := new(models.InvitationLetter).Count(activity.Id, activity.RehearsalId) |
|
|
|
t.CheckErr(err) |
|
|
|
|
|
|
|
if activity.RehearsalId != 0 && signTotal >= 10 { |
|
|
@ -158,7 +149,7 @@ func (t *SignCtl) Sign() { |
|
|
|
signHistory.IsDelete = false |
|
|
|
signHistory.UpdatedAt = time.Now() |
|
|
|
signHistory.CreatedAt = time.Now() |
|
|
|
_, err = core.GetXormAuto().InsertOne(signHistory) |
|
|
|
_, err = models.Add(signHistory) |
|
|
|
t.CheckErr(err) |
|
|
|
|
|
|
|
go ws_send_service.SendSign(fmt.Sprintf("%d", activity.Id), |
|
|
|