Browse Source

live

master
黄梓健 5 years ago
parent
commit
8592bb4c3b
  1. 4
      controllers/client/live.go
  2. 13
      controllers/common/im.go
  3. 6
      models/live_red_envelope_rule.go
  4. 3
      services/pay/handle.go
  5. 2
      services/pay/order.go
  6. 3
      utils/code/code.go

4
controllers/client/live.go

@ -168,7 +168,7 @@ func (t *LiveCtl) GetLiveRedPack() {
t.CheckErr(err)
if !exist {
// 通知其他的人
t.ERROR("红包被领完了", code.MSG_LIVE_RED_PACK_NOT_EXIST)
t.ERROR("红包被领完了", code.MSG_SHAKERB_RECORD_NOT_HIT)
return
}
@ -179,7 +179,7 @@ func (t *LiveCtl) GetLiveRedPack() {
row, err := redPack.UpdateAllColsById(redPack.Id)
t.CheckErr(err)
if row != 1 {
t.ERROR("红包被领完了", code.MSG_LIVE_RED_PACK_NOT_EXIST)
t.ERROR("红包被领完了", code.MSG_SHAKERB_RECORD_NOT_HIT)
return
}
pay_service.PutTransferDelayQueue("欧轩互动-红包活动", user.Openid, redPack.PartnerTradeNo, int(redPack.Amount*100), 5, 5*60)

13
controllers/common/im.go

@ -22,3 +22,16 @@ func (t *ImTestCtl) SendNotice() {
})
t.SUCCESS("发送成功")
}
func (t *ImTestCtl) SendRedPack() {
activityId := t.MustGetInt64("activity_id")
prompt := t.MustGet("prompt")
im_service.SendGroupCustomMessage(activityId, im.NoticeLiveRedPackStart,
map[string]interface{}{
"live_red_envelope_rule_id": 1,
"prompt": prompt,
"timestamp": time.Now().Unix(),
})
t.SUCCESS("发送成功")
}

6
models/live_red_envelope_rule.go

@ -32,12 +32,6 @@ func (t *LiveRedEnvelopeRule) Add() (int64, error) {
return core.GetXormAuto().InsertOne(t)
}
func GetLiveRedPackInfos(status int) ([]*LiveRedEnvelopeRule, error) {
infos := make([]*LiveRedEnvelopeRule, 0)
err := core.GetXormAuto().Where("is_delete=0 and status=?", status).Find(&infos)
return infos, err
}
func (t *LiveRedEnvelopeRule) GetByOutTradeNo(outTradeNo string) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and out_trade_no=?", outTradeNo).Get(t)
}

3
services/pay/handle.go

@ -11,7 +11,7 @@ import (
//处理支付成功之后的回调问题
// 直播红包
func Handle(order *models.UserOrder) error {
func HandleSuccess(order *models.UserOrder) error {
if order == nil {
return errors.New("订单信息不存在")
}
@ -84,6 +84,7 @@ func Handle(order *models.UserOrder) error {
return im_service.SendGroupCustomMessage(order.ActivityId, im.NoticeLiveRedPackStart,
map[string]interface{}{
"live_red_envelope_rule_id": info.Id,
"prompt": info.Prompt,
"timestamp": time.Now().Unix(),
})
} else if order.GoodType == 2 { // 打赏

2
services/pay/order.go

@ -109,7 +109,7 @@ func loopUnifiedOrder() {
}
if res.Query.TradeState == CODE_TRADE_SUCCESS {
go Handle(res.Order)
go HandleSuccess(res.Order)
} else if res.Query.TradeState == CODE_TRADE_REFUND {
param.Status = 3
orderDelayQueue <- param

3
utils/code/code.go

@ -12,9 +12,6 @@ const (
MSG_CUSTOMER_NOT_EXIST = 700
MSG_AREASTORE_NOT_EXIST = 800
MSG_ENTRYPEOPLE_NOT_EXIST = 900
MSG_LIVE_ACTIVITY_NOT_EXIST = 950 // 直播活动不存在
MSG_LIVE_RED_PACK_NOT_EXIST = 951 // 直播红包不存在
MSG_LIVE_RED_PACK_INFO_NOT_EXIST = 952 // 直播红包不存在
MSG_ACTIVITY_NOT_EXIST = 1000 // 互动不存在
MSG_MODULE_NOT_EXIST = 1001 // 模块活动不存在
MSG_MODULE_STATUS_END = 1002 // 该模块活动已结束

Loading…
Cancel
Save