蛋蛋星球-客户端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

svc_playlet.go 2.4 KiB

pirms 2 nedēļām
pirms 2 nedēļām
pirms 2 nedēļām
pirms 2 nedēļām
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package svc
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/md"
  6. "applet/app/utils"
  7. "applet/app/utils/cache"
  8. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  9. "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
  10. "github.com/gin-gonic/gin"
  11. "github.com/tidwall/gjson"
  12. "time"
  13. )
  14. func PlayletBase(c *gin.Context) {
  15. playletBase := GetSysCfgStr("playlet_base")
  16. var res = md.PlayletBaseData{
  17. Reward: gjson.Get(playletBase, "reward").String(),
  18. Total: gjson.Get(playletBase, "total").String(),
  19. FirstCount: gjson.Get(playletBase, "first_count").String(),
  20. SecondCount: gjson.Get(playletBase, "second_count").String(),
  21. Leave: gjson.Get(playletBase, "total").String(),
  22. Sum: "0.00",
  23. CoinName: "活跃值",
  24. }
  25. user := GetUser(c)
  26. //剩余次数
  27. NewPlayletTotalDb := implement.NewPlayletTotalDb(db.Db)
  28. total, _ := NewPlayletTotalDb.GetPlayletTotal(utils.Int64ToStr(user.Id), time.Now().Format("20060102"))
  29. if total != nil {
  30. res.Leave = utils.IntToStr(utils.StrToInt(res.Total) - total.Total)
  31. if utils.StrToInt(res.Leave) < 0 {
  32. res.Leave = "0"
  33. }
  34. }
  35. NewEggEnergyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db)
  36. eggData, _ := NewEggEnergyBasicSettingDb.EggEnergyBasicSettingGetOne()
  37. NewUserVirtualAmountDb := implement.NewUserVirtualAmountDb(db.Db)
  38. coin, _ := NewUserVirtualAmountDb.GetUserVirtualWalletBySession(user.Id, eggData.PersonEggPointsCoinId)
  39. if coin != nil {
  40. res.Sum = coin.Amount
  41. }
  42. e.OutSuc(c, res, nil)
  43. return
  44. }
  45. func PlayletReward(c *gin.Context) {
  46. var args md.PlayletRewardRequest
  47. if err := c.ShouldBindJSON(&args); err != nil {
  48. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  49. return
  50. }
  51. playletBase := GetSysCfgStr("playlet_base")
  52. user := GetUser(c)
  53. //判断数量 读取缓存的
  54. numKey := "video.num:" + time.Now().Format("20060102") + "." + utils.Int64ToStr(user.Id)
  55. numString, _ := cache.GetString(numKey)
  56. Leave := utils.StrToInt(gjson.Get(playletBase, "total").String()) - utils.StrToInt(numString)
  57. if Leave-1 < 0 {
  58. e.OutErr(c, 400, e.NewErr(400, "今天已领取完"))
  59. return
  60. }
  61. ch, err := rabbit.Cfg.Pool.GetChannel()
  62. if err == nil {
  63. defer ch.Release()
  64. err = ch.PublishV2(md.EggVideoPlayletExchange, md.PlayletReward{
  65. Uid: utils.Int64ToStr(user.Id),
  66. }, md.EggPlayletReward)
  67. if err != nil {
  68. ch.PublishV2(md.EggVideoPlayletExchange, md.PlayletReward{
  69. Uid: utils.Int64ToStr(user.Id),
  70. }, md.EggPlayletReward)
  71. }
  72. }
  73. e.OutSuc(c, "success", nil)
  74. return
  75. }