From c8c0e63d6cf016d68c3aa4a287e8672fbfd04a73 Mon Sep 17 00:00:00 2001 From: tommy <3405129587@qq.com> Date: Fri, 15 May 2020 16:32:40 +0800 Subject: [PATCH] ladder --- controllers/base.go | 6 +++--- controllers/client/lottery.go | 5 +++-- controllers/common/im.go | 2 ++ controllers/pc/lottery_draw.go | 4 ++++ controllers/pc/ws.go | 22 +--------------------- models/customer_operation.go | 4 ++-- services/pay/transfer.go | 2 +- utils/code/code.go | 1 + 8 files changed, 17 insertions(+), 29 deletions(-) diff --git a/controllers/base.go b/controllers/base.go index 415e50c..e98f976 100644 --- a/controllers/base.go +++ b/controllers/base.go @@ -75,7 +75,7 @@ func (t *BaseCtl) GetInt64(key string) (int64, bool) { } value, err := strconv.ParseInt(v, 10, 64) if err != nil { - logger.Sugar.Infof("get int64 from request error", err) + logger.Error("get int64 from request error", err) t.ERROR(fmt.Sprintf("%v的数据类型不为int", key), code.MSG_ERR_Param) return value, false } @@ -123,7 +123,7 @@ func (t *BaseCtl) GetBool(key string) (bool, bool) { } value, err := strconv.ParseBool(v) if err != nil { - logger.Sugar.Infof("get bool from request error", err) + logger.Error("get bool from request error", err) t.ERROR(fmt.Sprintf("%v的数据类型不为bool", key), code.MSG_ERR_Param) } return value, true @@ -150,7 +150,7 @@ func (t *BaseCtl) GetDouble(key string) (float64, bool) { } value, err := strconv.ParseFloat(v, 64) if err != nil { - logger.Sugar.Infof("get double from request error", err) + logger.Error("get double from request error", err) t.ERROR(fmt.Sprintf("%v的数据类型不为double", key), code.MSG_ERR_Param) } return value, true diff --git a/controllers/client/lottery.go b/controllers/client/lottery.go index 5b1d2a7..175fd7d 100644 --- a/controllers/client/lottery.go +++ b/controllers/client/lottery.go @@ -141,7 +141,8 @@ func (t *LotteryCtl) Users() { t.CheckErr(err) t.JSON(map[string]interface{}{ - "total": len(result), - "list": result, + "ladder": ladder, + "total": len(result), + "list": result, }) } diff --git a/controllers/common/im.go b/controllers/common/im.go index d72261d..189a332 100644 --- a/controllers/common/im.go +++ b/controllers/common/im.go @@ -88,11 +88,13 @@ func (t *ImTestCtl) SendLottery() { }) } else { + num := t.MustGetInt("num") im_service.SendGroupCustomMessage("admin", activityId, im_service.NoticeStatus(notice), map[string]interface{}{ "lottery_draw_ladder_id": ladderId, "timestamp": time.Now().Unix(), "desc": desc, + "number": num, }) } diff --git a/controllers/pc/lottery_draw.go b/controllers/pc/lottery_draw.go index 2dc069b..0c64eb4 100644 --- a/controllers/pc/lottery_draw.go +++ b/controllers/pc/lottery_draw.go @@ -52,6 +52,7 @@ func (t *LotteryDrawCtl) Start() { func (t *LotteryDrawCtl) StartRoll() { ladderId := t.MustGetInt64("lottery_draw_ladder_id") activityId := t.MustGetInt64("activity_id") + num := t.MustGetInt64("num") ladder := new(models.LotteryDrawRuleLadder) exist, err := models.GetById(ladder, ladderId) @@ -67,6 +68,7 @@ func (t *LotteryDrawCtl) StartRoll() { "lottery_draw_ladder_id": ladder.Id, "timestamp": time.Now().Unix(), "desc": "开始滚动", + "number": num, }) t.SUCCESS("操作成功") } @@ -74,6 +76,7 @@ func (t *LotteryDrawCtl) StartRoll() { func (t *LotteryDrawCtl) StopRoll() { ladderId := t.MustGetInt64("lottery_draw_ladder_id") activityId := t.MustGetInt64("activity_id") + num := t.MustGetInt64("num") ladder := new(models.LotteryDrawRuleLadder) exist, err := models.GetById(ladder, ladderId) @@ -89,6 +92,7 @@ func (t *LotteryDrawCtl) StopRoll() { "lottery_draw_ladder_id": ladder.Id, "timestamp": time.Now().Unix(), "desc": "停止滚动", + "number": num, }) t.SUCCESS("操作成功") } diff --git a/controllers/pc/ws.go b/controllers/pc/ws.go index b2c5947..f815b40 100644 --- a/controllers/pc/ws.go +++ b/controllers/pc/ws.go @@ -14,16 +14,6 @@ type WsCtl struct { } // ws doc -// @Summary ws -// @Description get current operation -// @Tags ws -// @Accept json -// @Produce json -// @Param activity_id query int true "Activity ID" -// @Success 0 {array} models.CustomerOperation -// @Failure 503 {string} string "参数不存在" -// @Failure 504 {object} string "用户不存在" -// @Router /Pc/WsCtl/ops [get] func (t *WsCtl) Ops() { customerId := t.MustGetUID() activityId, _ := t.GetInt64("activity_id") @@ -56,16 +46,6 @@ func (t *WsCtl) Ops() { } // ws doc -// @Summary ws -// @Description save operation -// @Tags ws -// @Accept json -// @Produce json -// @Param operation query string true "操作内容" -// @Success 0 {string} string "success" -// @Failure 503 {string} string "参数不存在" -// @Failure 504 {object} string "用户不存在" -// @Router /Pc/WsCtl/saveOp [post] func (t *WsCtl) SaveOp() { customerId := t.MustGetInt64("customer_id") extraData := t.Default("extra_data", "") @@ -76,7 +56,7 @@ func (t *WsCtl) SaveOp() { CreatedAt: time.Now(), } if row := op.SaveCustomerOperation(); row != 1 { - logger.Sugar.Debugf("save customer_operation出现错误") + logger.Error("save customer_operation出现错误") t.ERROR("customer operation格式错误", code.MSG_ERR) } t.STRING("success") diff --git a/models/customer_operation.go b/models/customer_operation.go index bee9e37..376277e 100644 --- a/models/customer_operation.go +++ b/models/customer_operation.go @@ -27,7 +27,7 @@ type CustomerOperation struct { func (op *CustomerOperation) SaveCustomerOperation() int64 { row, err := core.GetXormAuto().InsertOne(op) if err != nil { - logger.Sugar.Debugf("customer operation insert failed. error: %v; content: %s", err, op.ExtraData) + logger.Error("customer operation insert failed. error: %v; content: %s", err, op.ExtraData) return 0 } return row @@ -42,7 +42,7 @@ func (op *CustomerOperation) GetOpsByCustomerId(customerId int64, areaId int64) err = core.GetXormAuto().Where("customer_id=? and area_id=?", customerId, areaId).OrderBy("created_at asc").Find(&ops) } if err != nil { - logger.Sugar.Debugf("customer_operation find failed. error: %v", err) + logger.Error("customer_operation find failed. error: %v", err) return nil } return ops diff --git a/services/pay/transfer.go b/services/pay/transfer.go index 881c956..ca8f958 100644 --- a/services/pay/transfer.go +++ b/services/pay/transfer.go @@ -14,7 +14,7 @@ import ( ) func init() { - go loopTransfer() + //go loopTransfer() } var transferDelayQueue = make(chan *transferDelayQueueParam, math.MaxInt8) diff --git a/utils/code/code.go b/utils/code/code.go index 4d4fe7e..11c7674 100644 --- a/utils/code/code.go +++ b/utils/code/code.go @@ -34,6 +34,7 @@ const ( MSG_CUSTOMER_ORDER_NO_PAY = 4008 // 订单未支付 MSG_CUSTOMER_ORDER_SEND = 4009 // 订单已发货 MSG_LOTTERY_DRAW_NOT_HIT = 4010 // 没有抽中奖 + MSG_LOTTERY_DRAW_LADDER_NOT_EXIST = 4011 // 中奖阶梯规则不存在 MSG_ORDER_NOT_EXIST = 5000 // 订单活动不存在 MSG_CUSTOMER_ORDER_ERROR = 5001 // 订单已完成 MSG_SIGN_UP_NOT_EXIST = 5000 // 签到规则不存在