蛋蛋星球-客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

50 lines
1.2 KiB

  1. package hdl
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/md"
  6. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  7. "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
  8. "github.com/gin-gonic/gin"
  9. )
  10. func NewUserRedPacketInfo(c *gin.Context) {
  11. val, exists := c.Get("user")
  12. if !exists {
  13. e.OutErr(c, e.ERR_USER_CHECK_ERR, nil)
  14. return
  15. }
  16. user, ok := val.(*model.User)
  17. if !ok {
  18. e.OutErr(c, e.ERR_USER_CHECK_ERR, nil)
  19. return
  20. }
  21. userRecordsDb := implement.NewNewUserRedPackageWithUserRecordsDb(db.Db)
  22. records, err := userRecordsDb.NewUserRedPackageWithUserRecordsGetLastPendingByParams(map[string]interface{}{
  23. "key": "uid",
  24. "value": user.Id,
  25. })
  26. if err != nil {
  27. e.OutErr(c, e.ERR_DB_ORM, nil)
  28. return
  29. }
  30. if records == nil {
  31. e.OutErr(c, e.ERR_NO_DATA, "该用户没有有效新人红包活动")
  32. return
  33. }
  34. resp := md.RedPacketInfoResp{
  35. Uid: records.Uid,
  36. TotalAmount: records.TotalAmount,
  37. Days: records.Days,
  38. BalanceAmount: records.BalanceAmount,
  39. BalanceDays: records.BalanceDays,
  40. ReceiveDays: records.ReceiveDays,
  41. State: records.State,
  42. CreateAt: records.CreateAt,
  43. }
  44. e.OutSuc(c, resp, nil)
  45. }