From 894667c23f3ee2c949d03f4b371babee718f7fdc Mon Sep 17 00:00:00 2001 From: tommy <3405129587@qq.com> Date: Thu, 14 May 2020 10:17:44 +0800 Subject: [PATCH] hd sign --- controllers/client/sign.go | 36 ++++++++++++++++++------------------ controllers/pc/auction.go | 20 -------------------- log/hdzj.log | 1 + models/customer.go | 4 ++++ models/sign_history.go | 2 +- 5 files changed, 24 insertions(+), 39 deletions(-) diff --git a/controllers/client/sign.go b/controllers/client/sign.go index c9aa0e0..43fafe5 100644 --- a/controllers/client/sign.go +++ b/controllers/client/sign.go @@ -94,7 +94,15 @@ func (t *SignCtl) Setting() { func (t *SignCtl) Sign() { uid := t.MustGetUID() activityId := t.MustGetInt64("activity_id") - _type, _ := t.GetInt("_type") + _type := t.DefaultInt("_type", 0) // 默认 0 + + // 适配直播 + var areaId int64 = 0 + if _type == 0 { + areaId = t.MustGetAreaId() + } else { + areaId = t.MustGetInt64("area_id") + } //根据activity_id查找主活动的信息 activity := new(models.Activity) @@ -102,24 +110,16 @@ func (t *SignCtl) Sign() { t.CheckErr(err) t.Assert(exist, code.MSG_ACTIVITY_NOT_EXIST, "互动不存在") - user := new(models.User) - exist, err = models.GetById(user, uid) - t.CheckErr(err) - t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") - - customer := models.Customer{} - exist, err = models.GetById(&customer, activity.CustomerId) + // 根据areaId + customer := new(models.Customer) + exist, err = customer.GetByActivityIdAndAreaId(activityId, areaId) t.CheckErr(err) t.Assert(exist, code.MSG_CUSTOMER_NOT_EXIST, "客户不存在") - var area = new(models.AreaStore) - if customer.AreaId == 0 { - exist, err = area.GetMainAreaById(activityId) - } else { - exist, err = area.GetAreaStoreById(customer.AreaId) - } + user := new(models.User) + exist, err = models.GetById(user, uid) t.CheckErr(err) - t.Assert(exist, code.MSG_AREASTORE_NOT_EXIST, "地区不存在") + t.Assert(exist, code.MSG_USER_NOT_EXIST, "用户不存在") //根据activity_id查找副活动的规则信息 signUp := new(models.SignUp) @@ -127,7 +127,7 @@ func (t *SignCtl) Sign() { t.CheckErr(err) t.Assert(exist, code.MSG_DATA_NOT_EXIST, "签到规则不存在") - if signUp.OnlyInvitation == 1 { // + if signUp.OnlyInvitation == 1 && _type == 0 { // 直播不需要进行邀请函 // 邀请函才能签到 letter := new(models.InvitationLetter) exist, err := letter.GetByUserIdAndActivityId(uid, activityId, activity.RehearsalId) @@ -158,7 +158,7 @@ func (t *SignCtl) Sign() { signHistory.RehearsalId = activity.RehearsalId signHistory.ActivityId = activityId signHistory.SignRuleId = signUp.Id - signHistory.AreaId = area.Id + signHistory.AreaId = areaId signHistory.IsDelete = false signHistory.UpdatedAt = time.Now() signHistory.CreatedAt = time.Now() @@ -168,7 +168,7 @@ func (t *SignCtl) Sign() { go ws_send_service.SendSign(fmt.Sprintf("%d", activity.Id), define.TYPE_CUSTOMER, activity.CustomerId, map[string]interface{}{ "type": "sign_up", - "customer_id": activity.CustomerId, + "customer_id": customer.Id, "data": map[string]interface{}{ "avatar": user.Avatar, "sign_total": signTotal + 1, diff --git a/controllers/pc/auction.go b/controllers/pc/auction.go index 694fa82..0ee3c06 100644 --- a/controllers/pc/auction.go +++ b/controllers/pc/auction.go @@ -36,16 +36,6 @@ func (t *AuctionCtl) ReadyAuction() { t.SUCCESS("success") } -//开始竞拍 -// auction doc -// @Summary auction -// @Description 开始竞拍 -// @Tags pc -// @Accept json -// @Produce json -// @Param auction_activity_id query int true "竞拍id" -// @Success 200 {string} string "success" -// @Router /Pc/AuctionCtl/startAuction [get] func (t *AuctionCtl) StartAuction() { auctionId := t.MustGetInt64("auction_activity_id") @@ -68,16 +58,6 @@ func (t *AuctionCtl) StartAuction() { t.STRING("操作成功") } -//停止竞拍 -// auction doc -// @Summary auction -// @Description 结束竞拍 -// @Tags pc -// @Accept json -// @Produce json -// @Param auction_activity_id query int true "竞拍id" -// @Success 200 {string} string "success" -// @Router /Pc/AuctionCtl/stopAuction [get] func (t *AuctionCtl) StopAuction() { auctionId := t.MustGetInt64("auction_activity_id") rehearsalId := t.MustGetInt64("rehearsal_id") diff --git a/log/hdzj.log b/log/hdzj.log index 3c86a30..165ac51 100644 --- a/log/hdzj.log +++ b/log/hdzj.log @@ -75,3 +75,4 @@ 2020-05-07 12:00:47.151 ERROR logger/logger.go:92 查询订单出现错误 {"错误原因": "订单不存在", "交易订单号": "TLXnC3wQ7Ybd7Cd9bUGtFk3tTc6DM9CN"} 2020-05-07 12:00:57.542 ERROR logger/logger.go:92 打赏状态发送变化: err->Params type error, out_trade_no GjpJb0V0iJ1Z3yOFJQJailW3boAUWbvF 2020-05-07 12:03:33.742 ERROR logger/logger.go:92 打赏状态发送变化: err->Params type error, out_trade_no GjpJb0V0iJ1Z3yOFJQJailW3boAUWbvF +2020-05-11 16:16:45.145 ERROR logger/logger.go:92 查询订单出现错误 {"错误原因": "FAIL当前使用此业务的用户过多,请稍后再试", "交易订单号": "4gzTv4P1fqMOe2LsXCaKAeAxNX1ngnue"} diff --git a/models/customer.go b/models/customer.go index aa38452..b4d669b 100644 --- a/models/customer.go +++ b/models/customer.go @@ -74,3 +74,7 @@ func (t *Customer) GetByOpenid(openid string) (bool, error) { func (t *Customer) GetByQQOpenid(openid string) (bool, error) { return core.GetXormAuto().Where("is_delete=0 and qq_openid=?", openid).Get(t) } + +func (t *Customer) GetByActivityIdAndAreaId(activityId, areaId interface{}) (bool, error) { + return core.GetXormAuto().Where("is_delete=0 and activity_id=? and area_id=?", activityId, areaId).Get(t) +} diff --git a/models/sign_history.go b/models/sign_history.go index ccb9464..f7b0aeb 100644 --- a/models/sign_history.go +++ b/models/sign_history.go @@ -14,7 +14,7 @@ type SignHistory struct { 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)"` + 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)"` 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"`