Ver a proveniência

主页签到状态调整

adv_callback
huangjiajun há 2 semanas
ascendente
cometimento
154d8b6e60
8 ficheiros alterados com 225 adições e 15 eliminações
  1. +20
    -2
      app/hdl/hdl_add_friend.go
  2. +14
    -4
      app/hdl/hdl_home_page.go
  3. +35
    -0
      app/hdl/hdl_video.go
  4. +14
    -0
      app/md/md_video.go
  5. +5
    -0
      app/router/router.go
  6. +15
    -6
      app/svc/svc_common.go
  7. +119
    -0
      app/svc/svc_video.go
  8. +3
    -3
      go.mod

+ 20
- 2
app/hdl/hdl_add_friend.go Ver ficheiro

@@ -485,9 +485,27 @@ func TotalRate(c *gin.Context) {
return
}
now := time.Now()
nowStr := now.Format("2006-01-02 15:04:05")
//开始时间 以当前时间 往前推多少
//1、查找 `egg_energy_basic_setting` 基础设置
eggEnergyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
eggEnergyBasicSetting, err := eggEnergyBasicSettingDb.EggEnergyBasicSettingGetOneByParams(map[string]interface{}{
"key": "is_open",
"value": 1,
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
var videoRewardSystem *md2.VideoRewardSystemStruct
err = json.Unmarshal([]byte(eggEnergyBasicSetting.VideoRewardSystem), &videoRewardSystem)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
var oneRoundDuration = utils.StrToInt(videoRewardSystem.EachRoundHour)
startTime := now.Add(-time.Hour * time.Duration(oneRoundDuration)).Format("2006-01-02 15:04:05")
signInDb := implement.NewEggSignInDb(db.Db)
exit, signIn, err := signInDb.EggSignInGetOne(nowStr, nowStr, user.Id)
exit, signIn, err := signInDb.EggSignINGetOneByTimeAndUid(startTime, "", user.Id, 0)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return


+ 14
- 4
app/hdl/hdl_home_page.go Ver ficheiro

@@ -64,9 +64,17 @@ func HomePage(c *gin.Context) {
var signPersonalEggEnergy = "0.00"
var signTeamEggEnergy = "0.00"
var totalEggEnergy float64
nowStr := now.Format("2006-01-02 15:04:05")
//开始时间 以当前时间 往前推多少
var videoRewardSystem *md2.VideoRewardSystemStruct
err = json.Unmarshal([]byte(eggEnergyBasicSetting.VideoRewardSystem), &videoRewardSystem)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
var oneRoundDuration = utils.StrToInt(videoRewardSystem.EachRoundHour)
startTime := now.Add(-time.Hour * time.Duration(oneRoundDuration)).Format("2006-01-02 15:04:05")
signInDb := implement.NewEggSignInDb(db.Db)
has, signIn, err := signInDb.EggSignInGetOne(nowStr, nowStr, user.Id)
has, signIn, err := signInDb.EggSignINGetOneByTimeAndUid(startTime, "", user.Id, 0)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
@@ -237,9 +245,11 @@ func HomePageWatchAdRule(c *gin.Context) {
}
var roundRemainingSecs int64
now := time.Now()
nowStr := now.Format("2006-01-02 15:04:05")
//开始时间 以当前时间 往前推多少
var oneRoundDuration = utils.StrToInt(videoRewardSystem.EachRoundHour)
startTime := now.Add(-time.Hour * time.Duration(oneRoundDuration)).Format("2006-01-02 15:04:05")
signInDb := implement.NewEggSignInDb(db.Db)
has, signIn, err := signInDb.EggSignInGetOne(nowStr, nowStr, user.Id)
has, signIn, err := signInDb.EggSignINGetOneByTimeAndUid(startTime, "", user.Id, 0)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return


+ 35
- 0
app/hdl/hdl_video.go Ver ficheiro

@@ -0,0 +1,35 @@
package hdl

import (
"applet/app/svc"
"github.com/gin-gonic/gin"
)

// VideoBase
// @Summary 短视频-基本信息
// @Tags 短视频
// @Description 短视频-基本信息
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Success 200 {object} md.VideoBaseData "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/video/base [get]
func VideoBase(c *gin.Context) {
svc.VideoBase(c)
}

// VideoReward
// @Summary 实名认证-保存
// @Tags 实名认证
// @Description 实名认证-保存
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param req body md.VideoRewardRequest true "参数"
// @Success 200 {string} "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/v1/video/reward [post]
func VideoReward(c *gin.Context) {
svc.VideoReward(c)
}

+ 14
- 0
app/md/md_video.go Ver ficheiro

@@ -0,0 +1,14 @@
package md

type VideoBaseData struct {
Reward string `json:"reward" example:"单次奖励"`
Total string `json:"total" example:"可领取总次数"`
Timer string `json:"timer" example:"观看X秒奖励"`
Leave string `json:"leave" example:"剩余次数"`
Sum string `json:"sum" example:"奖励总数"`
CoinName string `json:"coin_name" example:"积分名称"`
Interval string `json:"interval" example:"领取间隔 秒"`
}
type VideoRewardRequest struct {
Id string `json:"id" example:"广告id"`
}

+ 5
- 0
app/router/router.go Ver ficheiro

@@ -183,6 +183,11 @@ func route(r *gin.RouterGroup) {
rFaceRealName.GET("/state", hdl.GetRealNameAuthState) //实名认证基础
rFaceRealName.POST("/save", hdl.RealNameSave)
}
rVideo := r.Group("/video") //短视频
{
rVideo.GET("/base", hdl.VideoBase) //基础数据
rVideo.POST("/reward", hdl.VideoReward) //奖励
}
}

func rCircleFriends(r *gin.RouterGroup) {


+ 15
- 6
app/svc/svc_common.go Ver ficheiro

@@ -69,13 +69,22 @@ func CheckRealName(uid int64) string {
//存入用户的设备

func UserImeiAdd(c *gin.Context, uid int64) {
var data = model.UserImei{
Uid: int(uid),
Imei: c.GetHeader("imei"),
CreateAt: time.Now(),
Ip: c.ClientIP(),
var tmp model.UserImei
get, _ := db.Db.Where("uid=? and imei=? and ip=?", uid, c.GetHeader("imei"), c.ClientIP()).Get(&tmp)
if get == false {
var data = model.UserImei{
Uid: int(uid),
Imei: c.GetHeader("imei"),
CreateAt: time.Now(),
UpdateAt: time.Now(),
Ip: c.ClientIP(),
}
db.Db.Insert(&data)
} else {
tmp.UpdateAt = time.Now()
db.Db.Where("id=?", tmp.Id).Cols("update_at").Update(&tmp)
}
db.Db.Insert(&data)
NewUserDb := implement.NewUserDb(db.Db)
user, _ := NewUserDb.GetUser(uid)
if user != nil {


+ 119
- 0
app/svc/svc_video.go Ver ficheiro

@@ -0,0 +1,119 @@
package svc

import (
"applet/app/db"
"applet/app/e"
"applet/app/md"
"applet/app/utils"
"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"
"time"
)

func VideoBase(c *gin.Context) {
videoBase := GetSysCfgStr("video_base")
var res = md.VideoBaseData{
Reward: gjson.Get(videoBase, "reward").String(),
Total: gjson.Get(videoBase, "total").String(),
Timer: gjson.Get(videoBase, "timer").String(),
Leave: gjson.Get(videoBase, "total").String(),
Sum: "0.00",
CoinName: "活跃值",
Interval: gjson.Get(videoBase, "interval").String(),
}
user := GetUser(c)
//剩余次数
NewVideoTotalDb := implement.NewVideoTotalDb(db.Db)
total, _ := NewVideoTotalDb.GetVideoTotal(utils.Int64ToStr(user.Id), time.Now().Format("20060102"))
if total != nil {
res.Leave = utils.IntToStr(utils.StrToInt(res.Total) - total.Total)
if utils.StrToInt(res.Leave) < 0 {
res.Leave = "0"
}
}
NewEggEnergyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
eggData, _ := NewEggEnergyBasicSettingDb.EggEnergyBasicSettingGetOne()
NewUserVirtualAmountDb := implement.NewUserVirtualAmountDb(db.Db)
coin, _ := NewUserVirtualAmountDb.GetUserVirtualWalletBySession(user.Id, eggData.PersonEggPointsCoinId)
if coin != nil {
res.Sum = coin.Amount
}
e.OutSuc(c, res, nil)
return
}

func VideoReward(c *gin.Context) {
var args md.VideoRewardRequest
if err := c.ShouldBindJSON(&args); err != nil {
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
}
}
Leave := utils.StrToInt(gjson.Get(videoBase, "total").String()) - total.Total
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.EggEnergyWatchAdRewardPersonalActiveCoin.String(),
TransferType: int(enum.EggEnergyWatchAdRewardPersonalActiveCoin),
CoinId: eggData.PersonEggPointsCoinId,
Uid: user.Id,
Amount: utils.StrToFloat64(gjson.Get(videoBase, "reward").String()),
}, md2.EggEnergyRoutKeyForDealUserVirtualCoinData)
if err != nil {
ch.PublishV2(md2.EggEnergyExchange, md2.EggEnergyStructForDealUserVirtualCoinData{
Kind: "add",
Title: enum.EggEnergyWatchAdRewardPersonalActiveCoin.String(),
TransferType: int(enum.EggEnergyWatchAdRewardPersonalActiveCoin),
CoinId: eggData.PersonEggPointsCoinId,
Uid: user.Id,
Amount: utils.StrToFloat64(gjson.Get(videoBase, "reward").String()),
}, md2.EggEnergyRoutKeyForDealUserVirtualCoinData)
}
}
e.OutSuc(c, "success", nil)
return
}

+ 3
- 3
go.mod Ver ficheiro

@@ -4,7 +4,7 @@ go 1.19

//replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models

replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules
//replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules

require (
github.com/boombuler/barcode v1.0.1
@@ -32,8 +32,8 @@ require (
)

require (
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241204091019-14b93d36ac8e
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241204070258-4712985349b4
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241204095350-c895baf67bc5
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241204095556-04ee23549ee5
code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible


Carregando…
Cancelar
Guardar