diff --git a/app/hdl/hdl_user.go b/app/hdl/hdl_user.go index 97e9277..26b10cf 100644 --- a/app/hdl/hdl_user.go +++ b/app/hdl/hdl_user.go @@ -5,21 +5,26 @@ import ( "applet/app/e" "applet/app/es/hdl" md2 "applet/app/es/md" + "applet/app/lib/auth" "applet/app/md" "applet/app/svc" "applet/app/utils" + "applet/app/utils/cache" "applet/app/utils/qrcode" "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/go_rely_warehouse/zyos_go_es.git/es" + "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" "context" + "fmt" "github.com/gin-gonic/gin" "github.com/olivere/elastic/v7" "github.com/syyongx/php2go" "github.com/tidwall/gjson" "strings" + "time" ) // UserInfo @@ -314,3 +319,57 @@ func InviteUrl(c *gin.Context) { e.OutSuc(c, res, nil) return } + +// Delete +// @Summary 注销账号 +// @Tags 账号与安全 +// @Description 注销账号 +// @Accept json +// @Produce json +// @Param req body md.DeleteUserReq true "注册参数" +// @Success 200 string "登录成功返回" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/v1/memberCenter/delete [post] +func Delete(c *gin.Context) { + var req md.DeleteUserReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = svc.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + 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 + //} + user.State = 3 + db.Db.Where("id=?", user.Id).Cols("state").Update(user) + tmp := model.UserDeleteInfo{ + Uid: int(user.Id), + Phone: user.Phone, + CreateAt: time.Now(), + } + db.Db.Insert(&tmp) + ch, err := rabbit.Cfg.Pool.GetChannel() + if err == nil { + defer ch.Release() + err = ch.PublishV2(md.EggUserExchange, md.CommUserId{ + Uid: utils.Int64ToStr(user.Id), + }, md.EggUserDelete) + if err != nil { + ch.PublishV2(md.EggUserExchange, md.CommUserId{ + Uid: utils.Int64ToStr(user.Id), + }, md.EggUserDelete) + } + } + // 清掉token + cacheKey := fmt.Sprintf(auth.TokenKey, user.Id) + _, err = cache.SetEx(cacheKey, "", 1) + e.OutSuc(c, "success", nil) + return +} diff --git a/app/md/md_advertising.go b/app/md/md_advertising.go index 69e372c..21e3250 100644 --- a/app/md/md_advertising.go +++ b/app/md/md_advertising.go @@ -29,6 +29,7 @@ type AdvertisingCheck struct { } type AdvertisingState struct { IsSuccess string `json:"is_success"` + Integral string `json:"integral"` } type AdvertisingFunction struct { Name string `json:"name" example:"名称"` diff --git a/app/md/md_login.go b/app/md/md_login.go index e124d07..f8ddf0a 100644 --- a/app/md/md_login.go +++ b/app/md/md_login.go @@ -34,6 +34,9 @@ type UpdatePasscodeReq struct { Code string `json:"code" example:"验证码"` PassCode string `json:"passcode" example:"密码 如 123"` } +type DeleteUserReq struct { + Code string `json:"code" example:"验证码"` +} type WechatLoginReq struct { OpenID string `json:"open_id" example:"微信openId"` UnionId string `json:"union_id" example:"微信UnionId"` diff --git a/app/md/md_mq.go b/app/md/md_mq.go index 3f054f9..8292fea 100644 --- a/app/md/md_mq.go +++ b/app/md/md_mq.go @@ -11,6 +11,8 @@ const ( EggVideoPlayletExchange = "egg.video_playlet" EggVideoReward = "video" EggPlayletReward = "playlet" + EggUserExchange = "egg.user" + EggUserDelete = "user_delete" ) type VideoReward struct { @@ -19,7 +21,9 @@ type VideoReward struct { type PlayletReward struct { Uid string `json:"uid"` } - +type CommUserId struct { + Uid string `json:"uid"` +} type JpushRecordFundData struct { Id string `json:"id"` UserId string `json:"user_id"` diff --git a/app/router/router.go b/app/router/router.go index e1867e4..3fbb454 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -121,6 +121,7 @@ func route(r *gin.RouterGroup) { rMemberCenter.POST("/updatePassword", hdl.UpdatePassword) //修改密码 rMemberCenter.POST("/updatePasscode", hdl.UpdatePasscode) //修改支付密码 rMemberCenter.GET("/inviteUrl", hdl.InviteUrl) //邀请链接 + rMemberCenter.POST("/delete", hdl.Delete) //注销账号 } rPointsCenter := r.Group("/pointsCenter") // 积分中心 { diff --git a/app/svc/svc_advertising.go b/app/svc/svc_advertising.go index f7f2bf6..2d63c0f 100644 --- a/app/svc/svc_advertising.go +++ b/app/svc/svc_advertising.go @@ -5,6 +5,7 @@ import ( "applet/app/e" "applet/app/md" "applet/app/utils" + "applet/app/utils/cache" "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" "encoding/json" @@ -126,13 +127,22 @@ func AdvertisingState(c *gin.Context) { return } isSuccess := "0" - var data model.AdvertisingCallback - db.Db.Where("uniq_id=? ", req.Id).Get(&data) - if data.Id > 0 { + getString, _ := cache.GetString(req.Id) + integral := "0" + if getString == "" { + var data model.AdvertisingCallback + db.Db.Where("uniq_id=? ", req.Id).Get(&data) + if data.Id > 0 { + isSuccess = "1" + integral = data.Integral + } + } else { isSuccess = "1" + integral = getString } res := md.AdvertisingState{ IsSuccess: isSuccess, + Integral: integral, } e.OutSuc(c, res, nil) return diff --git a/docs/docs.go b/docs/docs.go index 95b03b8..cba0e2f 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1,4 +1,5 @@ -// Package docs Code generated by swaggo/swag. DO NOT EDIT +// Code generated by swaggo/swag. DO NOT EDIT. + package docs import "github.com/swaggo/swag" @@ -2266,6 +2267,46 @@ const docTemplate = `{ } } }, + "/api/v1/memberCenter/delete": { + "post": { + "description": "注销账号", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "账号与安全" + ], + "summary": "注销账号", + "parameters": [ + { + "description": "注册参数", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.DeleteUserReq" + } + } + ], + "responses": { + "200": { + "description": "登录成功返回", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/v1/memberCenter/getBasic": { "get": { "description": "基础数据(获取)", @@ -3090,7 +3131,9 @@ const docTemplate = `{ "name": "req", "in": "body", "required": true, - "schema": {} + "schema": { + "type": "object" + } } ], "responses": { @@ -3881,6 +3924,68 @@ const docTemplate = `{ } } }, + "code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd": { + "type": "object", + "properties": { + "amount": { + "type": "string" + }, + "create_time": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "im_data": { + "type": "string" + }, + "im_uid": { + "type": "integer" + }, + "ord_no": { + "type": "string" + }, + "received_im_user_ids": { + "type": "string" + }, + "received_times": { + "type": "string" + }, + "received_user_amount": { + "type": "string" + }, + "received_user_ids": { + "type": "string" + }, + "red_packet_balance_amount": { + "type": "string" + }, + "red_packet_balance_nums": { + "type": "integer" + }, + "red_packet_nums": { + "type": "integer" + }, + "red_packet_type": { + "type": "integer" + }, + "state": { + "type": "integer" + }, + "uid": { + "type": "integer" + }, + "update_time": { + "type": "string" + }, + "wait_draw_im_user_ids": { + "type": "string" + }, + "wait_draw_user_ids": { + "type": "string" + } + } + }, "comm.AccessRecordsReq": { "type": "object", "properties": { @@ -4240,6 +4345,9 @@ const docTemplate = `{ "md.AdvertisingState": { "type": "object", "properties": { + "integral": { + "type": "string" + }, "is_success": { "type": "string" } @@ -4476,6 +4584,15 @@ const docTemplate = `{ } } }, + "md.DeleteUserReq": { + "type": "object", + "properties": { + "code": { + "type": "string", + "example": "验证码" + } + } + }, "md.DynamicDataResp": { "type": "object", "properties": { @@ -5476,7 +5593,7 @@ const docTemplate = `{ "description": "红包详情信息", "allOf": [ { - "$ref": "#/definitions/model.ImSendRedPackageOrd" + "$ref": "#/definitions/code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd" } ] }, @@ -6158,68 +6275,6 @@ const docTemplate = `{ } } }, - "model.ImSendRedPackageOrd": { - "type": "object", - "properties": { - "amount": { - "type": "string" - }, - "create_time": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "im_data": { - "type": "string" - }, - "im_uid": { - "type": "integer" - }, - "ord_no": { - "type": "string" - }, - "received_im_user_ids": { - "type": "string" - }, - "received_times": { - "type": "string" - }, - "received_user_amount": { - "type": "string" - }, - "received_user_ids": { - "type": "string" - }, - "red_packet_balance_amount": { - "type": "string" - }, - "red_packet_balance_nums": { - "type": "integer" - }, - "red_packet_nums": { - "type": "integer" - }, - "red_packet_type": { - "type": "integer" - }, - "state": { - "type": "integer" - }, - "uid": { - "type": "integer" - }, - "update_time": { - "type": "string" - }, - "wait_draw_im_user_ids": { - "type": "string" - }, - "wait_draw_user_ids": { - "type": "string" - } - } - }, "pb.SendRedPacketResp": { "type": "object", "properties": { @@ -6242,8 +6297,6 @@ var SwaggerInfo = &swag.Spec{ Description: "APP客户端-Api接口", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, - LeftDelim: "{{", - RightDelim: "}}", } func init() { diff --git a/docs/swagger.json b/docs/swagger.json index 01b7f57..6baec14 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -2260,6 +2260,46 @@ } } }, + "/api/v1/memberCenter/delete": { + "post": { + "description": "注销账号", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "账号与安全" + ], + "summary": "注销账号", + "parameters": [ + { + "description": "注册参数", + "name": "req", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/md.DeleteUserReq" + } + } + ], + "responses": { + "200": { + "description": "登录成功返回", + "schema": { + "type": "string" + } + }, + "400": { + "description": "具体错误", + "schema": { + "$ref": "#/definitions/md.Response" + } + } + } + } + }, "/api/v1/memberCenter/getBasic": { "get": { "description": "基础数据(获取)", @@ -3084,7 +3124,9 @@ "name": "req", "in": "body", "required": true, - "schema": {} + "schema": { + "type": "object" + } } ], "responses": { @@ -3875,6 +3917,68 @@ } } }, + "code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd": { + "type": "object", + "properties": { + "amount": { + "type": "string" + }, + "create_time": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "im_data": { + "type": "string" + }, + "im_uid": { + "type": "integer" + }, + "ord_no": { + "type": "string" + }, + "received_im_user_ids": { + "type": "string" + }, + "received_times": { + "type": "string" + }, + "received_user_amount": { + "type": "string" + }, + "received_user_ids": { + "type": "string" + }, + "red_packet_balance_amount": { + "type": "string" + }, + "red_packet_balance_nums": { + "type": "integer" + }, + "red_packet_nums": { + "type": "integer" + }, + "red_packet_type": { + "type": "integer" + }, + "state": { + "type": "integer" + }, + "uid": { + "type": "integer" + }, + "update_time": { + "type": "string" + }, + "wait_draw_im_user_ids": { + "type": "string" + }, + "wait_draw_user_ids": { + "type": "string" + } + } + }, "comm.AccessRecordsReq": { "type": "object", "properties": { @@ -4234,6 +4338,9 @@ "md.AdvertisingState": { "type": "object", "properties": { + "integral": { + "type": "string" + }, "is_success": { "type": "string" } @@ -4470,6 +4577,15 @@ } } }, + "md.DeleteUserReq": { + "type": "object", + "properties": { + "code": { + "type": "string", + "example": "验证码" + } + } + }, "md.DynamicDataResp": { "type": "object", "properties": { @@ -5470,7 +5586,7 @@ "description": "红包详情信息", "allOf": [ { - "$ref": "#/definitions/model.ImSendRedPackageOrd" + "$ref": "#/definitions/code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd" } ] }, @@ -6152,68 +6268,6 @@ } } }, - "model.ImSendRedPackageOrd": { - "type": "object", - "properties": { - "amount": { - "type": "string" - }, - "create_time": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "im_data": { - "type": "string" - }, - "im_uid": { - "type": "integer" - }, - "ord_no": { - "type": "string" - }, - "received_im_user_ids": { - "type": "string" - }, - "received_times": { - "type": "string" - }, - "received_user_amount": { - "type": "string" - }, - "received_user_ids": { - "type": "string" - }, - "red_packet_balance_amount": { - "type": "string" - }, - "red_packet_balance_nums": { - "type": "integer" - }, - "red_packet_nums": { - "type": "integer" - }, - "red_packet_type": { - "type": "integer" - }, - "state": { - "type": "integer" - }, - "uid": { - "type": "integer" - }, - "update_time": { - "type": "string" - }, - "wait_draw_im_user_ids": { - "type": "string" - }, - "wait_draw_user_ids": { - "type": "string" - } - } - }, "pb.SendRedPacketResp": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index bef0bf8..1aeba9c 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -12,6 +12,47 @@ definitions: description: 总数据量 type: integer type: object + code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd: + properties: + amount: + type: string + create_time: + type: string + id: + type: integer + im_data: + type: string + im_uid: + type: integer + ord_no: + type: string + received_im_user_ids: + type: string + received_times: + type: string + received_user_amount: + type: string + received_user_ids: + type: string + red_packet_balance_amount: + type: string + red_packet_balance_nums: + type: integer + red_packet_nums: + type: integer + red_packet_type: + type: integer + state: + type: integer + uid: + type: integer + update_time: + type: string + wait_draw_im_user_ids: + type: string + wait_draw_user_ids: + type: string + type: object comm.AccessRecordsReq: properties: index: @@ -265,6 +306,8 @@ definitions: type: object md.AdvertisingState: properties: + integral: + type: string is_success: type: string type: object @@ -430,6 +473,12 @@ definitions: description: 标题 type: string type: object + md.DeleteUserReq: + properties: + code: + example: 验证码 + type: string + type: object md.DynamicDataResp: properties: development_committee: @@ -1123,7 +1172,7 @@ definitions: properties: detail: allOf: - - $ref: '#/definitions/model.ImSendRedPackageOrd' + - $ref: '#/definitions/code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd' description: 红包详情信息 list: description: 领取红包用户列表 @@ -1593,47 +1642,6 @@ definitions: description: 余额 type: string type: object - model.ImSendRedPackageOrd: - properties: - amount: - type: string - create_time: - type: string - id: - type: integer - im_data: - type: string - im_uid: - type: integer - ord_no: - type: string - received_im_user_ids: - type: string - received_times: - type: string - received_user_amount: - type: string - received_user_ids: - type: string - red_packet_balance_amount: - type: string - red_packet_balance_nums: - type: integer - red_packet_nums: - type: integer - red_packet_type: - type: integer - state: - type: integer - uid: - type: integer - update_time: - type: string - wait_draw_im_user_ids: - type: string - wait_draw_user_ids: - type: string - type: object pb.SendRedPacketResp: properties: seq: @@ -3133,6 +3141,32 @@ paths: summary: 绑定上级-要登陆的 tags: - 登录注册 + /api/v1/memberCenter/delete: + post: + consumes: + - application/json + description: 注销账号 + parameters: + - description: 注册参数 + in: body + name: req + required: true + schema: + $ref: '#/definitions/md.DeleteUserReq' + produces: + - application/json + responses: + "200": + description: 登录成功返回 + schema: + type: string + "400": + description: 具体错误 + schema: + $ref: '#/definitions/md.Response' + summary: 注销账号 + tags: + - 账号与安全 /api/v1/memberCenter/getBasic: get: consumes: @@ -3674,7 +3708,8 @@ paths: in: body name: req required: true - schema: {} + schema: + type: object produces: - application/json responses: diff --git a/go.mod b/go.mod index 1791791..45903e8 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( ) require ( - code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241206115326-8cbc93c7c64d + code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241210053355-df51eb14c56e code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241207095445-64c8aa0b486e 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