From ddc0994456d1b13e6ce37fdf05fbbbbd5c6a273e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 21 Feb 2020 16:44:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=81=E7=94=A8=E7=94=A8=E6=88=B7=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/user2.go | 99 ++++++++++++++------------- controllers/cms_user2.go | 12 ++-- routers/commentsRouter_controllers.go | 8 +-- 3 files changed, 60 insertions(+), 59 deletions(-) diff --git a/business/jxstore/cms/user2.go b/business/jxstore/cms/user2.go index ff29eb99b..a3db03ffc 100644 --- a/business/jxstore/cms/user2.go +++ b/business/jxstore/cms/user2.go @@ -992,61 +992,62 @@ func UpdateUserWxNoAndPercent(user *model.User, isReceiver bool) (num int64, err dao.Rollback(db) } if isReceiver { - // param := &wxpayapi.ProfitSharingReceiverParam{ - // Receiver: wxpayapi.CData(`{ - // "type":"` + wxpayapi.AccountTypeOpen + `", - // "account":"` + auth[0].AuthID + `", - // "relation_type":" ` + wxpayapi.Relation + `" - // }`), - // } - // _, err := api.WxpayAPI.AddProfitSharingReceiver(param) - // if err != nil { - // return 0, err - // } else { - // user2.IsReceiver = 1 - // num3, err := dao.UpdateEntity(db, user2, "IsReceiver") - // num += num3 - // if err != nil { - // dao.Rollback(db) - // } - // } + } dao.Commit(db) return num, err } -func DeleteProfitSharingReceiver(ctx *jxcontext.Context, userID string) (err error) { +func DeleteUserInfo(ctx *jxcontext.Context, userID string) (err error) { // db := dao.GetDB() - // auth, err := dao.GetUserBindAuthInfo(db, userID, model.AuthBindTypeAuth, []string{"weixinmini"}, "", "") - // if len(auth) == 0 { - // return fmt.Errorf("未找到此用户的微信验证方式!用户ID:[%v]\n", userID) + // sql := ` + // UPDATE user + // SET status = ? + // WHERE user_id = ? + // ` + // sqlParams := []interface{}{ + // model.NO, + // userID, // } - // dao.Begin(db) - // defer func() { - // if r := recover(); r != nil || err != nil { - // dao.Rollback(db) - // if r != nil { - // panic(r) - // } - // } - // }() - // param := &wxpayapi.ProfitSharingReceiverParam{ - // Receiver: wxpayapi.CData(`{ - // "type":"` + wxpayapi.AccountTypeOpen + `", - // "account":"` + auth[0].AuthID + `" - // }`), - // } - // _, err = api.WxpayAPI.DeleteProfitSharingReceiver(param) - // if err != nil { - // return err - // } else { - // user2, err := dao.GetUserByID(db, "user_id", userID) - // user2.IsReceiver = 0 - // _, err = dao.UpdateEntity(db, user2, "IsReceiver") - // if err != nil { - // dao.Rollback(db) - // } - // } - // dao.Commit(db) + // _, err = dao.ExecuteSQL(db, sql, sqlParams) + + // /* 删除离职人员门店市场人员 */ + // sql2 := ` + // UPDATE store t1 + // LEFT JOIN user t2 ON t2.mobile = t1.market_man_phone AND t2.status <> 0 + // SET t1.market_man_phone = '' + // WHERE t2.id IS NULL + // ` + // _, err = dao.ExecuteSQL(db, sql2, nil) + + // /* 删除离职人员门店运营人员 */ + // sql3 := ` + // UPDATE store t1 + // LEFT JOIN user t2 ON t2.mobile = t1.operator_phone AND t2.status <> 0 + // SET t1.operator_phone = '' + // WHERE t2.id IS NULL + // ` + // _, err = dao.ExecuteSQL(db, sql3, nil) + + // /* 删除离职人员门店运营人员 */ + // sql4 := ` + // UPDATE store t1 + // LEFT JOIN user t2 ON t2.mobile = t1.operator_phone2 AND t2.status <> 0 + // SET t1.operator_phone2 = '' + // WHERE t2.id IS NULL + // ` + // _, err = dao.ExecuteSQL(db, sql4, nil) + + // /*删除离职人员的角色信息*/ + // sql5 := ` + // DELETE t1 + // FROM casbin_rule t1 + // LEFT JOIN user t2 ON t2.user_id = t1.v0 AND t2.status <> 0 + // WHERE t2.id IS NULL + // ` + // _, err = dao.ExecuteSQL(db, sql5, nil) + + tokens, err := api.Cacher.Keys("TOKEN.V2.*") + globals.SugarLogger.Debugf("DeleteUserInfo,[%v]", tokens) return err } diff --git a/controllers/cms_user2.go b/controllers/cms_user2.go index c5537d149..ca2608ef5 100644 --- a/controllers/cms_user2.go +++ b/controllers/cms_user2.go @@ -472,16 +472,16 @@ func (c *User2Controller) UpdateUserWxNoAndPercent() { }) } -// @Title 删除分账接收方 -// @Description 删除分账接收方 +// @Title 禁用用户(删除离职用户信息) +// @Description 禁用用户(删除离职用户信息) // @Param token header string true "认证token" // @Param userID query string true "用户userID" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult -// @router /DeleteProfitSharingReceiver [delete] -func (c *User2Controller) DeleteProfitSharingReceiver() { - c.callDeleteProfitSharingReceiver(func(params *tUser2DeleteProfitSharingReceiverParams) (retVal interface{}, errCode string, err error) { - err = cms.DeleteProfitSharingReceiver(params.Ctx, params.UserID) +// @router /DeleteUserInfo [delete] +func (c *User2Controller) DeleteUserInfo() { + c.callDeleteUserInfo(func(params *tUser2DeleteUserInfoParams) (retVal interface{}, errCode string, err error) { + err = cms.DeleteUserInfo(params.Ctx, params.UserID) return retVal, "", err }) } diff --git a/routers/commentsRouter_controllers.go b/routers/commentsRouter_controllers.go index 9d46de0d6..67eddb1ce 100644 --- a/routers/commentsRouter_controllers.go +++ b/routers/commentsRouter_controllers.go @@ -2315,8 +2315,8 @@ func init() { beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"], beego.ControllerComments{ - Method: "DeleteProfitSharingReceiver", - Router: `/DeleteProfitSharingReceiver`, + Method: "DeleteRoles4User", + Router: `/DeleteRoles4User`, AllowHTTPMethods: []string{"delete"}, MethodParams: param.Make(), Filters: nil, @@ -2324,8 +2324,8 @@ func init() { beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:User2Controller"], beego.ControllerComments{ - Method: "DeleteRoles4User", - Router: `/DeleteRoles4User`, + Method: "DeleteUserInfo", + Router: `/DeleteUserInfo`, AllowHTTPMethods: []string{"delete"}, MethodParams: param.Make(), Filters: nil,