package hdl import ( "applet/app/db" "applet/app/e" "applet/app/md" "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" "github.com/gin-gonic/gin" ) func NewUserRedPacketInfo(c *gin.Context) { val, exists := c.Get("user") if !exists { e.OutErr(c, e.ERR_USER_CHECK_ERR, nil) return } user, ok := val.(*model.User) if !ok { e.OutErr(c, e.ERR_USER_CHECK_ERR, nil) return } userRecordsDb := implement.NewNewUserRedPackageWithUserRecordsDb(db.Db) records, err := userRecordsDb.NewUserRedPackageWithUserRecordsGetLastPendingByParams(map[string]interface{}{ "key": "uid", "value": user.Id, }) if err != nil { e.OutErr(c, e.ERR_DB_ORM, nil) return } if records == nil { e.OutErr(c, e.ERR_NO_DATA, "该用户没有有效新人红包活动") return } resp := md.RedPacketInfoResp{ Uid: records.Uid, TotalAmount: records.TotalAmount, Days: records.Days, BalanceAmount: records.BalanceAmount, BalanceDays: records.BalanceDays, ReceiveDays: records.ReceiveDays, State: records.State, CreateAt: records.CreateAt, } e.OutSuc(c, resp, nil) }