From 27b817fcc8bce2cba7bc03c2918f423d7a5b2af2 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 13 Dec 2024 19:26:46 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/hdl/hdl_config.go | 10 +++++-- app/hdl/hdl_user.go | 58 +++++++++++++++++++++++++++++++++--- app/md/md_member_center.go | 13 ++++---- app/md/md_user.go | 5 ++++ app/router/router.go | 1 + app/svc/svc_advertising.go | 2 +- app/svc/svc_common.go | 6 ++-- app/svc/svc_playlet.go | 8 ++++- app/svc/svc_user_feedback.go | 2 +- app/svc/svc_video.go | 8 ++++- go.mod | 2 +- 11 files changed, 94 insertions(+), 21 deletions(-) diff --git a/app/hdl/hdl_config.go b/app/hdl/hdl_config.go index bfea869..d4c73af 100644 --- a/app/hdl/hdl_config.go +++ b/app/hdl/hdl_config.go @@ -73,10 +73,14 @@ func Version(c *gin.Context) { appVersion := svc.GetSysCfgStr("app_version") version := make([]md.Version, 0) json.Unmarshal([]byte(appVersion), &version) - for k, v := range version { - version[k].Img = svc.GetOssUrl("default_icon/" + v.Type + "_icon.png") + newVersion := make([]md.Version, 0) + for _, v := range version { + v.Img = svc.GetOssUrl("default_icon/" + v.Type + "_icon.png") + if v.Type != "360" { + newVersion = append(newVersion, v) + } } - res := md.VersionResp{Version: version, IsAuditVersion: "0"} + res := md.VersionResp{Version: newVersion, IsAuditVersion: "0"} NewCloudBundleDb := implement.NewCloudBundleDb(db.Db) os := "1" if c.GetHeader("platform") == "iOS" { diff --git a/app/hdl/hdl_user.go b/app/hdl/hdl_user.go index 6537c27..d3ab576 100644 --- a/app/hdl/hdl_user.go +++ b/app/hdl/hdl_user.go @@ -14,7 +14,7 @@ import ( "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/aliyun" - "code.fnuoos.com/EggPlanet/egg_system_rules.git/kuaizhan" + "code.fnuoos.com/EggPlanet/egg_system_rules.git/baidu" md3 "code.fnuoos.com/EggPlanet/egg_system_rules.git/md" md4 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" es2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/es" @@ -202,6 +202,56 @@ func UserBindParent(c *gin.Context) { return } +// BindUserInfo +// @Summary 绑定用户信息 +// @Tags 会员中心 +// @Description 绑定用户信息 +// @Accept json +// @Produce json +// @Param req body md.WechatAccountUserInfoReq true "注册参数" +// @Success 200 {string} "具体数据" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/v1/memberCenter/bindUserInfo [post] +func BindUserInfo(c *gin.Context) { + var req md.WechatAccountUserInfoReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = svc.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + if req.WechatAccount == "" { + e.OutErr(c, 400, e.NewErr(400, "微信号不能为空")) + return + } + ownUser := svc.GetUser(c) + cols := "" + if req.Nickname != "" { + ownUser.Nickname = req.Nickname + cols += ",nickname" + } + if req.HeadImg != "" { + ownUser.Avatar = req.HeadImg + cols += ",avatar" + } + if req.WechatAccount != "" { + ownUser.WechatAccount = req.WechatAccount + cols += ",wechat_account" + } + if cols == "" { + e.OutErr(c, 400, e.NewErr(400, "修改失败")) + return + } + _, err = db.Db.Where("id=?", ownUser.Id).Cols(cols[1:]).Update(ownUser) + if err != nil { + e.OutErr(c, 400, e.NewErr(400, "修改失败")) + return + } + e.OutSuc(c, "success", nil) + return +} + // UpdatePassword // @Summary 修改密码-不要原密码 换成验证码 // @Tags 账号与安全 @@ -308,11 +358,11 @@ func InviteUrl(c *gin.Context) { } } if isHas == 0 { - send, _ := kuaizhan.KuaizhanSend(svc.GetSysCfgStr("kuaizhan_app_key"), svc.GetSysCfgStr("kuaizhan_app_secret"), link) - if gjson.Get(send, "url").String() != "" { + url, _ := baidu.BaiduShortenUrl(svc.GetSysCfgStr("baidu_token"), link) + if url != "" { var uniqueId = php2go.Md5(link) oldLink := link - link = gjson.Get(send, "url").String() + link = url tmp := map[string]interface{}{ "uid": user.Id, "link": oldLink, diff --git a/app/md/md_member_center.go b/app/md/md_member_center.go index 3f7478e..050872b 100644 --- a/app/md/md_member_center.go +++ b/app/md/md_member_center.go @@ -1,8 +1,6 @@ package md type MemberCenterGetBasicResp struct { - Nickname string `json:"nickname"` // 会员名称 - LevelName string `json:"level_name"` // 会员等级名称 ActiveNum string `json:"active_num"` // 活跃值 EggScore string `json:"egg_score"` // 蛋蛋分 EggEnergy string `json:"egg_energy"` // 能量值 @@ -11,10 +9,13 @@ type MemberCenterGetBasicResp struct { Date string `json:"date"` // 兑换时间(每月x日) Ratio string `json:"ratio"` // 能量值兑换比例(x:y) Amount string `json:"amount"` // 账户余额 - Id string `json:"id"` - Phone string `json:"phone"` - InviteCode string `json:"invite_code"` - HeadImg string `json:"head_img"` + Nickname string `json:"nickname" example:"昵称"` + LevelName string `json:"level_name" example:"等级"` + InviteCode string `json:"invite_code" example:"邀请码"` + HeadImg string `json:"head_img" example:"头像"` + Id string `json:"id" example:"个人ID号"` + Phone string `json:"phone" example:"手机号"` + WechatAccount string `json:"wechat_account" example:"微信号"` IsBindExtend string `json:"is_bind_extend" example:"是否绑定了上级 0否 1是"` IsRealName string `json:"is_real_name" example:"是否实名认证 0否 1是"` } diff --git a/app/md/md_user.go b/app/md/md_user.go index a9c1ca2..c0280a8 100644 --- a/app/md/md_user.go +++ b/app/md/md_user.go @@ -11,6 +11,11 @@ type UserInfoResp struct { type InviteCodeUserInfoReq struct { InviteCode string `json:"invite_code"` } +type WechatAccountUserInfoReq struct { + WechatAccount string `json:"wechat_account" example:"微信号 不是修改不用传"` + HeadImg string `json:"head_img" example:"头像 不是修改不用传"` + Nickname string `json:"nickname" example:"昵称 不是修改不用传"` +} type InviteCodeUserInfoResp struct { Nickname string `json:"nickname"` HeadImg string `json:"head_img"` diff --git a/app/router/router.go b/app/router/router.go index 2662d58..0e3d99d 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -119,6 +119,7 @@ func route(r *gin.RouterGroup) { { rMemberCenter.GET("/getBasic", hdl.MemberCenterGetBasic) // 会员中心-基础数据 rMemberCenter.POST("/bindParent", hdl.UserBindParent) //绑定上级 + rMemberCenter.POST("/bindUserInfo", hdl.BindUserInfo) //绑定用户信息 rMemberCenter.GET("/parentInfo", hdl.ParentInfo) //上级信息 rMemberCenter.POST("/updatePassword", hdl.UpdatePassword) //修改密码 rMemberCenter.POST("/updatePasscode", hdl.UpdatePasscode) //修改支付密码 diff --git a/app/svc/svc_advertising.go b/app/svc/svc_advertising.go index 2d63c0f..ef8158b 100644 --- a/app/svc/svc_advertising.go +++ b/app/svc/svc_advertising.go @@ -100,7 +100,7 @@ func AdvertisingCheck(c *gin.Context) { if NewAdvertisingLimit != nil && NewAdvertisingLimit.ImeiNum > 0 { sql := `SELECT uid FROM user_imei WHERE create_at>='%s' and ip='%s' GROUP BY imei LIMIT %s` now := time.Now().Unix() - int64(NewAdvertisingLimit.Minute*60) - sql = fmt.Sprintf(sql, time.Unix(now, 0).Format("2006-01-02 15:04:05"), c.ClientIP(), NewAdvertisingLimit.ImeiNum) + sql = fmt.Sprintf(sql, time.Unix(now, 0).Format("2006-01-02 15:04:05"), utils.GetIP(c.Request), NewAdvertisingLimit.ImeiNum) nativeString, _ := db.QueryNativeString(db.Db, sql) for _, v := range nativeString { if utils.StrToInt64(v["uid"]) == user.Id { diff --git a/app/svc/svc_common.go b/app/svc/svc_common.go index 4cfa01a..2cd5dd2 100644 --- a/app/svc/svc_common.go +++ b/app/svc/svc_common.go @@ -65,14 +65,14 @@ func CheckRealName(uid int64) string { func UserImeiAdd(c *gin.Context, uid int64) { var tmp model.UserImei - get, _ := db.Db.Where("uid=? and imei=? and ip=?", uid, c.GetHeader("imei"), c.ClientIP()).Get(&tmp) + get, _ := db.Db.Where("uid=? and imei=? and ip=?", uid, c.GetHeader("imei"), utils.GetIP(c.Request)).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(), + Ip: utils.GetIP(c.Request), } db.Db.Insert(&data) } else { @@ -84,7 +84,7 @@ func UserImeiAdd(c *gin.Context, uid int64) { user, _ := NewUserDb.GetUser(uid) if user != nil { user.LastLoginAt = time.Now().Format("2006-01-02 15:04:05") - user.LastLoginIp = c.ClientIP() + user.LastLoginIp = utils.GetIP(c.Request) db.Db.Where("id=?", user.Id).Cols("last_login_at,last_login_ip").Update(user) UpdateUserTime(user.Id, "login") } diff --git a/app/svc/svc_playlet.go b/app/svc/svc_playlet.go index 206b2db..e194f87 100644 --- a/app/svc/svc_playlet.go +++ b/app/svc/svc_playlet.go @@ -37,10 +37,16 @@ func PlayletBase(c *gin.Context) { NewEggEnergyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db) eggData, _ := NewEggEnergyBasicSettingDb.EggEnergyBasicSettingGetOne() NewUserVirtualAmountDb := implement.NewUserVirtualAmountDb(db.Db) + var eggPoints float64 = 0 coin, _ := NewUserVirtualAmountDb.GetUserVirtualWalletBySession(user.Id, eggData.PersonEggPointsCoinId) if coin != nil { - res.Sum = coin.Amount + eggPoints += utils.StrToFloat64(coin.Amount) } + TeamEggPointsCoin, _ := NewUserVirtualAmountDb.GetUserVirtualWalletBySession(user.Id, eggData.TeamEggPointsCoinId) + if TeamEggPointsCoin != nil { + eggPoints += utils.StrToFloat64(TeamEggPointsCoin.Amount) + } + res.Sum = utils.Float64ToStrPrec8(eggPoints) e.OutSuc(c, res, nil) return } diff --git a/app/svc/svc_user_feedback.go b/app/svc/svc_user_feedback.go index f3368d3..f66b988 100644 --- a/app/svc/svc_user_feedback.go +++ b/app/svc/svc_user_feedback.go @@ -121,7 +121,7 @@ func UserFeedbackSave(c *gin.Context) { Idea: req.Idea, Phone: req.Phone, Cid: utils.StrToInt(req.Cid), - Ip: c.ClientIP(), + Ip: utils.GetIP(c.Request), CreateAt: time.Now(), } eg.Insert(&data) diff --git a/app/svc/svc_video.go b/app/svc/svc_video.go index d971787..b6ce2b3 100644 --- a/app/svc/svc_video.go +++ b/app/svc/svc_video.go @@ -37,10 +37,16 @@ func VideoBase(c *gin.Context) { NewEggEnergyBasicSettingDb := implement.NewEggEnergyBasicSettingDb(db.Db) eggData, _ := NewEggEnergyBasicSettingDb.EggEnergyBasicSettingGetOne() NewUserVirtualAmountDb := implement.NewUserVirtualAmountDb(db.Db) + var eggPoints float64 = 0 coin, _ := NewUserVirtualAmountDb.GetUserVirtualWalletBySession(user.Id, eggData.PersonEggPointsCoinId) if coin != nil { - res.Sum = coin.Amount + eggPoints += utils.StrToFloat64(coin.Amount) } + TeamEggPointsCoin, _ := NewUserVirtualAmountDb.GetUserVirtualWalletBySession(user.Id, eggData.TeamEggPointsCoinId) + if TeamEggPointsCoin != nil { + eggPoints += utils.StrToFloat64(TeamEggPointsCoin.Amount) + } + res.Sum = utils.Float64ToStrPrec8(eggPoints) e.OutSuc(c, res, nil) return } diff --git a/go.mod b/go.mod index 2442ccb..1136c03 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( require ( code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241213090643-10ffb038ded6 - code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241212140020-c99f60b4f868 + code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241213103509-834ad0148103 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