Browse Source

ladder

master
黄梓健 5 years ago
parent
commit
c8c0e63d6c
  1. 6
      controllers/base.go
  2. 5
      controllers/client/lottery.go
  3. 2
      controllers/common/im.go
  4. 4
      controllers/pc/lottery_draw.go
  5. 22
      controllers/pc/ws.go
  6. 4
      models/customer_operation.go
  7. 2
      services/pay/transfer.go
  8. 1
      utils/code/code.go

6
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

5
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,
})
}

2
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,
})
}

4
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("操作成功")
}

22
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")

4
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

2
services/pay/transfer.go

@ -14,7 +14,7 @@ import (
)
func init() {
go loopTransfer()
//go loopTransfer()
}
var transferDelayQueue = make(chan *transferDelayQueueParam, math.MaxInt8)

1
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 // 签到规则不存在

Loading…
Cancel
Save