dengbiao пре 3 недеља
родитељ
комит
0a2784846c
5 измењених фајлова са 47 додато и 111 уклоњено
  1. +5
    -5
      app/hdl/hdl_playlet.go
  2. +3
    -3
      app/hdl/hdl_video.go
  3. +10
    -0
      app/md/md_mq.go
  4. +11
    -52
      app/svc/svc_playlet.go
  5. +18
    -51
      app/svc/svc_video.go

+ 5
- 5
app/hdl/hdl_playlet.go Прегледај датотеку

@@ -6,9 +6,9 @@ import (
)

// PlayletBase
// @Summary 短视频-基本信息
// @Summary 短-基本信息
// @Tags 短视频
// @Description 短视频-基本信息
// @Description 短-基本信息
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
@@ -20,9 +20,9 @@ func PlayletBase(c *gin.Context) {
}

// PlayletReward
// @Summary 实名认证-保存
// @Tags 实名认证
// @Description 实名认证-保存
// @Summary 短剧-保存
// @Tags 短视频
// @Description 短剧-保存
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"


+ 3
- 3
app/hdl/hdl_video.go Прегледај датотеку

@@ -20,9 +20,9 @@ func VideoBase(c *gin.Context) {
}

// VideoReward
// @Summary 实名认证-保存
// @Tags 实名认证
// @Description 实名认证-保存
// @Summary 短视频-领取
// @Tags 短视频
// @Description 短视频-领取
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"


+ 10
- 0
app/md/md_mq.go Прегледај датотеку

@@ -8,8 +8,18 @@ const (
EggAdvertisingSign = "advertising_sign"
EggAliyunSmsRecordQueueExchange = "egg.aliyun_sms"
EggAliyunSmsRecordQueue = "aliyun_sms_record"
EggVideoPlayletExchange = "egg.video_playlet"
EggVideoReward = "video"
EggPlayletReward = "playlet"
)

type VideoReward struct {
Uid string `json:"uid"`
}
type PlayletReward struct {
Uid string `json:"uid"`
}

type JpushRecordFundData struct {
Id string `json:"id"`
UserId string `json:"user_id"`


+ 11
- 52
app/svc/svc_playlet.go Прегледај датотеку

@@ -5,10 +5,8 @@ import (
"applet/app/e"
"applet/app/md"
"applet/app/utils"
"applet/app/utils/cache"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
"code.fnuoos.com/EggPlanet/egg_system_rules.git/enum"
md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md"
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
"github.com/gin-gonic/gin"
"github.com/tidwall/gjson"
@@ -53,65 +51,26 @@ func PlayletReward(c *gin.Context) {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
eg := db.Db
playletBase := GetSysCfgStr("playlet_base")
sess := eg.NewSession()
defer sess.Close()
sess.Begin()
user := GetUser(c)
NewPlayletTotalDb := implement.NewPlayletTotalDb(db.Db)
total, _ := NewPlayletTotalDb.GetPlayletTotalSess(sess, utils.Int64ToStr(user.Id), time.Now().Format("20060102"))
if total == nil {
total = &model.PlayletTotal{
Uid: int(user.Id),
Date: utils.StrToInt(time.Now().Format("20060102")),
Time: time.Now(),
}
insert, err := sess.Insert(total)
if insert == 0 || err != nil {
sess.Rollback()

e.OutErr(c, 400, e.NewErr(400, "获取奖励失败"))
return
}
}
Leave := utils.StrToInt(gjson.Get(playletBase, "total").String()) - total.Total
//判断数量 读取缓存的
numKey := "video.num:" + time.Now().Format("20060102") + "." + utils.Int64ToStr(user.Id)
numString, _ := cache.GetString(numKey)
Leave := utils.StrToInt(gjson.Get(playletBase, "total").String()) - utils.StrToInt(numString)
if Leave-1 < 0 {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "今天已领取完"))
return
}
total.Total++

update, err2 := sess.Where("id=?", total.Id).Cols("total").Update(total)
if update == 0 || err2 != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "获取奖励失败"))
return
}
sess.Commit()
ch, err := rabbit.Cfg.Pool.GetChannel()
if err == nil {
defer ch.Release()
NewEggEnergyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
eggData, _ := NewEggEnergyBasicSettingDb.EggEnergyBasicSettingGetOne()
err = ch.PublishV2(md2.EggEnergyExchange, md2.EggEnergyStructForDealUserVirtualCoinData{
Kind: "add",
Title: enum.EggEnergyPlayletRewardPersonalActiveCoin.String(),
TransferType: int(enum.EggEnergyPlayletRewardPersonalActiveCoin),
CoinId: eggData.PersonEggPointsCoinId,
Uid: user.Id,
Amount: utils.StrToFloat64(gjson.Get(playletBase, "reward").String()),
}, md2.EggEnergyRoutKeyForDealUserVirtualCoinData)
err = ch.PublishV2(md.EggVideoPlayletExchange, md.PlayletReward{
Uid: utils.Int64ToStr(user.Id),
}, md.EggPlayletReward)
if err != nil {
ch.PublishV2(md2.EggEnergyExchange, md2.EggEnergyStructForDealUserVirtualCoinData{
Kind: "add",
Title: enum.EggEnergyPlayletRewardPersonalActiveCoin.String(),
TransferType: int(enum.EggEnergyPlayletRewardPersonalActiveCoin),
CoinId: eggData.PersonEggPointsCoinId,
Uid: user.Id,
Amount: utils.StrToFloat64(gjson.Get(playletBase, "reward").String()),
}, md2.EggEnergyRoutKeyForDealUserVirtualCoinData)
ch.PublishV2(md.EggVideoPlayletExchange, md.PlayletReward{
Uid: utils.Int64ToStr(user.Id),
}, md.EggPlayletReward)
}
}
e.OutSuc(c, "success", nil)


+ 18
- 51
app/svc/svc_video.go Прегледај датотеку

@@ -5,10 +5,8 @@ import (
"applet/app/e"
"applet/app/md"
"applet/app/utils"
"applet/app/utils/cache"
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
"code.fnuoos.com/EggPlanet/egg_system_rules.git/enum"
md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md"
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
"github.com/gin-gonic/gin"
"github.com/tidwall/gjson"
@@ -53,65 +51,34 @@ func VideoReward(c *gin.Context) {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
eg := db.Db
videoBase := GetSysCfgStr("video_base")
sess := eg.NewSession()
defer sess.Close()
sess.Begin()
user := GetUser(c)
NewVideoTotalDb := implement.NewVideoTotalDb(db.Db)
total, _ := NewVideoTotalDb.GetVideoTotalSess(sess, utils.Int64ToStr(user.Id), time.Now().Format("20060102"))
if total == nil {
total = &model.VideoTotal{
Uid: int(user.Id),
Date: utils.StrToInt(time.Now().Format("20060102")),
Time: time.Now(),
}
insert, err := sess.Insert(total)
if insert == 0 || err != nil {
sess.Rollback()

e.OutErr(c, 400, e.NewErr(400, "获取奖励失败"))
return
}
//判断到时间领了没
timeKey := "video.timer:" + utils.Int64ToStr(user.Id)
timeString, _ := cache.GetString(timeKey)
if timeString == "1" {
e.OutErr(c, 400, e.NewErr(400, "未到时间领取"))
return
}
Leave := utils.StrToInt(gjson.Get(videoBase, "total").String()) - total.Total
cache.SetEx(timeKey, "1", utils.StrToInt(gjson.Get(videoBase, "interval").String()))
//判断数量 读取缓存的
numKey := "video.num:" + time.Now().Format("20060102") + "." + utils.Int64ToStr(user.Id)
numString, _ := cache.GetString(numKey)
Leave := utils.StrToInt(gjson.Get(videoBase, "total").String()) - utils.StrToInt(numString)
if Leave-1 < 0 {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "今天已领取完"))
return
}
total.Total++

update, err2 := sess.Where("id=?", total.Id).Cols("total").Update(total)
if update == 0 || err2 != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "获取奖励失败"))
return
}
sess.Commit()
ch, err := rabbit.Cfg.Pool.GetChannel()
if err == nil {
defer ch.Release()
NewEggEnergyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
eggData, _ := NewEggEnergyBasicSettingDb.EggEnergyBasicSettingGetOne()
err = ch.PublishV2(md2.EggEnergyExchange, md2.EggEnergyStructForDealUserVirtualCoinData{
Kind: "add",
Title: enum.EggEnergyVideoRewardPersonalActiveCoin.String(),
TransferType: int(enum.EggEnergyVideoRewardPersonalActiveCoin),
CoinId: eggData.PersonEggPointsCoinId,
Uid: user.Id,
Amount: utils.StrToFloat64(gjson.Get(videoBase, "reward").String()),
}, md2.EggEnergyRoutKeyForDealUserVirtualCoinData)
err = ch.PublishV2(md.EggVideoPlayletExchange, md.PlayletReward{
Uid: utils.Int64ToStr(user.Id),
}, md.EggVideoReward)
if err != nil {
ch.PublishV2(md2.EggEnergyExchange, md2.EggEnergyStructForDealUserVirtualCoinData{
Kind: "add",
Title: enum.EggEnergyVideoRewardPersonalActiveCoin.String(),
TransferType: int(enum.EggEnergyVideoRewardPersonalActiveCoin),
CoinId: eggData.PersonEggPointsCoinId,
Uid: user.Id,
Amount: utils.StrToFloat64(gjson.Get(videoBase, "reward").String()),
}, md2.EggEnergyRoutKeyForDealUserVirtualCoinData)
ch.PublishV2(md.EggVideoPlayletExchange, md.PlayletReward{
Uid: utils.Int64ToStr(user.Id),
}, md.EggVideoReward)
}
}
e.OutSuc(c, "success", nil)


Loading…
Откажи
Сачувај