diff --git a/app/hdl/hdl_user.go b/app/hdl/hdl_user.go index 26b10cf..59c1961 100644 --- a/app/hdl/hdl_user.go +++ b/app/hdl/hdl_user.go @@ -15,9 +15,12 @@ import ( "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" + md3 "code.fnuoos.com/EggPlanet/egg_system_rules.git/md" + es2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils/es" "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" "context" + "encoding/json" "fmt" "github.com/gin-gonic/gin" "github.com/olivere/elastic/v7" @@ -321,9 +324,9 @@ func InviteUrl(c *gin.Context) { } // Delete -// @Summary 注销账号 +// @Summary 注销账号操作 // @Tags 账号与安全 -// @Description 注销账号 +// @Description 注销账号操作 // @Accept json // @Produce json // @Param req body md.DeleteUserReq true "注册参数" @@ -340,13 +343,13 @@ func Delete(c *gin.Context) { return } user := svc.GetUser(c) - //data := svc.AliyunSmsBase(c, "") - ////校验短信 - //err = aliyun.AliyunCheckSms(data["aliyun_sms_id"], data["aliyun_sms_secret"], user.Phone, req.Code) - //if err != nil { - // e.OutErr(c, 400, e.NewErr(400, "验证码错误,请重试")) - // return - //} + data := svc.AliyunSmsBase(c, "") + //校验短信 + err = aliyun.AliyunCheckSms(data["aliyun_sms_id"], data["aliyun_sms_secret"], user.Phone, req.Code) + if err != nil { + e.OutErr(c, 400, e.NewErr(400, "验证码错误,请重试")) + return + } user.State = 3 db.Db.Where("id=?", user.Id).Cols("state").Update(user) tmp := model.UserDeleteInfo{ @@ -373,3 +376,81 @@ func Delete(c *gin.Context) { e.OutSuc(c, "success", nil) return } + +// DeleteInfo +// @Summary 注销账号信息 +// @Tags 账号与安全 +// @Description 注销账号信息 +// @Accept json +// @Produce json +// @Success 200 {object} md.UserDeleteInfo "登录成功返回" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/v1/memberCenter/delete/info [get] +func DeleteInfo(c *gin.Context) { + user := svc.GetUser(c) + resp := md.UserDeleteInfo{ + Url: fmt.Sprintf("%s%s?id=%s&is_hide=1", svc.GetSysCfgStr("wap_host"), "/#/pages/course-detail-page/course-detail-page", "115"), + } + extendUserCount, _ := db.Db.Where("parent_uid=?", user.Id).Count(&model.User{}) + NewUserWalletDb := implement.NewUserWalletDb(db.Db) + walletAmount := "0" + wallet, _ := NewUserWalletDb.GetUserVirtualWallet(user.Id) + if wallet != nil { + walletAmount = wallet.Amount + } + NewUserVirtualAmountDb := implement.NewUserVirtualAmountDb(db.Db) + virtualWallet, _ := NewUserVirtualAmountDb.GetUserVirtualAllWallets(user.Id) + virtualAmount1 := "0" + virtualAmount2 := "0" + virtualAmount3 := "0" + settingDb := implement.NewEggEnergyBasicSettingDb(db.Db) + setting, _ := settingDb.EggEnergyBasicSettingGetOne() + if virtualWallet != nil { + for _, v := range *virtualWallet { + if v.CoinId == setting.PersonEggPointsCoinId { + virtualAmount3 = utils.Float64ToStrPrec8(utils.StrToFloat64(v.Amount) + utils.StrToFloat64(virtualAmount3)) + } + if v.CoinId == setting.TeamEggPointsCoinId { + virtualAmount3 = utils.Float64ToStrPrec8(utils.StrToFloat64(v.Amount) + utils.StrToFloat64(virtualAmount3)) + } + if v.CoinId == setting.PersonEggEnergyCoinId { + virtualAmount2 = utils.Float64ToStrPrec8(utils.StrToFloat64(v.Amount) + utils.StrToFloat64(virtualAmount2)) + } + if v.CoinId == setting.TeamEggEnergyCoinId { + virtualAmount2 = utils.Float64ToStrPrec8(utils.StrToFloat64(v.Amount) + utils.StrToFloat64(virtualAmount2)) + } + if v.CoinId == setting.ContributionCoinId { + virtualAmount1 = utils.Float64ToStrPrec8(utils.StrToFloat64(v.Amount) + utils.StrToFloat64(virtualAmount1)) + } + } + } + score := 60.00 + now := time.Now() + esIndex := es2.GetLatestEffectiveIndexFromAlias(now) + esIndexName := md3.EggEnergyUserEggScoreEsAlias + "_" + esIndex + results, _ := es.FirstDoc(esIndexName, esIndex+"_"+utils.Int64ToStr(user.Id)) + if results != nil { + var doc md.UserEggFlowReqRespList + json.Unmarshal(results.Source, &doc) + score = doc.ScoreValue + } + uid := user.Id + sql := fmt.Sprintf("SELECT COUNT(*)AS total FROM `public_platoon_user_relation` WHERE father_uid1 = %d OR father_uid2= %d OR father_uid3= %d OR father_uid4= %d OR father_uid5= %d OR father_uid6= %d OR father_uid7= %d OR father_uid8= %d OR father_uid9= %d", uid, uid, uid, uid, uid, uid, uid, uid, uid) + nativeString1, _ := db.QueryNativeString(db.Db, sql) + hasUserCount := "0" + if len(nativeString1) > 0 { + hasUserCount = nativeString1[0]["total"] + } + info := []md.UserDeleteInfoList{ + {Img: svc.GetOssUrl("default_icon/user_delete_icon.png"), Title: "贡献值", Content: "贡献值 " + virtualAmount1}, + {Img: svc.GetOssUrl("default_icon/user_delete_icon.png"), Title: "能量值", Content: "能量值 " + virtualAmount2}, + {Img: svc.GetOssUrl("default_icon/user_delete_icon.png"), Title: "活跃值", Content: "活跃值 " + virtualAmount3}, + {Img: svc.GetOssUrl("default_icon/user_delete_icon.png"), Title: "蛋蛋分", Content: "蛋蛋分 " + utils.Float64ToStr(score)}, + {Img: svc.GetOssUrl("default_icon/user_delete_icon.png"), Title: "余额", Content: "余额 " + walletAmount}, + {Img: svc.GetOssUrl("default_icon/user_delete_icon.png"), Title: "直推好友", Content: "直推好友 " + utils.Int64ToStr(extendUserCount) + " 人"}, + {Img: svc.GetOssUrl("default_icon/user_delete_icon.png"), Title: "团队", Content: "团队 " + hasUserCount + " 人"}, + } + resp.Info = info + e.OutSuc(c, resp, nil) + return +} diff --git a/app/md/md_user.go b/app/md/md_user.go index 4a23d7c..3eacaf2 100644 --- a/app/md/md_user.go +++ b/app/md/md_user.go @@ -15,3 +15,13 @@ type InviteCodeUserInfoResp struct { Nickname string `json:"nickname"` HeadImg string `json:"head_img"` } + +type UserDeleteInfo struct { + Url string `json:"url"` + Info []UserDeleteInfoList `json:"info"` +} +type UserDeleteInfoList struct { + Img string `json:"img"` + Title string `json:"title"` + Content string `json:"content"` +} diff --git a/app/router/router.go b/app/router/router.go index 5528add..c3ce8c2 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -123,6 +123,7 @@ func route(r *gin.RouterGroup) { rMemberCenter.POST("/updatePasscode", hdl.UpdatePasscode) //修改支付密码 rMemberCenter.GET("/inviteUrl", hdl.InviteUrl) //邀请链接 rMemberCenter.POST("/delete", hdl.Delete) //注销账号 + rMemberCenter.GET("/delete/info", hdl.DeleteInfo) //注销账号相关信息 } rPointsCenter := r.Group("/pointsCenter") // 积分中心 { diff --git a/app/utils/convert.go b/app/utils/convert.go index 63fe4ef..6a39371 100644 --- a/app/utils/convert.go +++ b/app/utils/convert.go @@ -282,6 +282,9 @@ func Float64ToStrPrec1(f float64) string { func Float64ToStrPrec10(f float64) string { return strconv.FormatFloat(f, 'f', 10, 64) } +func Float64ToStrPrec8(f float64) string { + return strconv.FormatFloat(f, 'f', 8, 64) +} func Float32ToStr(f float32) string { return Float64ToStr(float64(f))