|
@@ -1,8 +1,8 @@
|
|
package rpc
|
|
package rpc
|
|
|
|
|
|
import (
|
|
import (
|
|
- "bp.jydev.jianyu360.cn/BaseService/gateway/common"
|
|
|
|
. "bp.jydev.jianyu360.cn/BaseService/gateway/common/gatecode"
|
|
. "bp.jydev.jianyu360.cn/BaseService/gateway/common/gatecode"
|
|
|
|
+ "bp.jydev.jianyu360.cn/BaseService/gateway/core/router"
|
|
"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
|
|
"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
|
|
"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/usercenter"
|
|
"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/usercenter"
|
|
"fmt"
|
|
"fmt"
|
|
@@ -24,28 +24,21 @@ func initUserCenterRpc() {
|
|
}
|
|
}
|
|
|
|
|
|
// CheckAccountStatus 校验企业认证状态及账户状态
|
|
// CheckAccountStatus 校验企业认证状态及账户状态
|
|
-// authCheck 是否需要认证;xy x个人 y企业 0:否 1是,
|
|
|
|
-// statusCheck是否需要检查状态(冻结);xy x个人 y企业 0:否 1是,
|
|
|
|
-func CheckAccountStatus(entId int64, userId string, authCheck, statusCheck int) error {
|
|
|
|
- if authCheck == 0 && statusCheck == 0 {
|
|
|
|
|
|
+func CheckAccountStatus(entId int64, userId string, rule *router.Router) error {
|
|
|
|
+ if rule.AuthCheck.GetCode() == 0 && rule.AccountCheck.GetCode() == 0 {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
- authCheckArr := common.SplitPower(authCheck, 2)
|
|
|
|
- statusCheckArr := common.SplitPower(statusCheck, 2)
|
|
|
|
- authUser, authEnt := authCheckArr[0], authCheckArr[1]
|
|
|
|
- statusUser, statusEnt := statusCheckArr[0], statusCheckArr[1]
|
|
|
|
-
|
|
|
|
//查询个人状态
|
|
//查询个人状态
|
|
- if authUser || statusUser {
|
|
|
|
- if userErr := checkPersonalStatus(userId, authCheck == 2, statusCheck == 2); userErr != nil {
|
|
|
|
|
|
+ if rule.AuthCheck.CheckUserAuth() || rule.AccountCheck.CheckUserAccount() {
|
|
|
|
+ if userErr := checkPersonalStatus(userId, rule.AuthCheck.CheckUserAuth(), rule.AccountCheck.CheckUserAccount()); userErr != nil {
|
|
return userErr
|
|
return userErr
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//查询企业状态
|
|
//查询企业状态
|
|
- if authEnt || statusEnt {
|
|
|
|
- if entErr := checkEntStatus(entId, authCheck == 1, statusCheck == 1); entErr != nil {
|
|
|
|
|
|
+ if rule.AuthCheck.CheckEntAuth() || rule.AccountCheck.CheckEntAccount() {
|
|
|
|
+ if entErr := checkEntStatus(entId, rule.AuthCheck.CheckEntAuth(), rule.AccountCheck.CheckEntAccount()); entErr != nil {
|
|
return entErr
|
|
return entErr
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -53,7 +46,7 @@ func CheckAccountStatus(entId int64, userId string, authCheck, statusCheck int)
|
|
}
|
|
}
|
|
|
|
|
|
// checkEntStatus 校验企业状态
|
|
// checkEntStatus 校验企业状态
|
|
-func checkEntStatus(entId int64, authCheck, statusCheck bool) error {
|
|
|
|
|
|
+func checkEntStatus(entId int64, authCheck, accountCheck bool) error {
|
|
res, err := UserCenterRpc.CheckEnt(gctx.New(), &pb.CheckEntReq{
|
|
res, err := UserCenterRpc.CheckEnt(gctx.New(), &pb.CheckEntReq{
|
|
EntId: entId,
|
|
EntId: entId,
|
|
})
|
|
})
|
|
@@ -62,7 +55,7 @@ func checkEntStatus(entId int64, authCheck, statusCheck bool) error {
|
|
}
|
|
}
|
|
|
|
|
|
//校验是否冻结
|
|
//校验是否冻结
|
|
- if statusCheck && res.Data.FrozenStatus == 1 {
|
|
|
|
|
|
+ if accountCheck && res.Data.FrozenStatus == 1 {
|
|
return NewErrorWithCode(GLOBAL_ERR_ENTACCOUNT_STATUS, fmt.Sprintf("企业账户 %d 已被冻结", entId))
|
|
return NewErrorWithCode(GLOBAL_ERR_ENTACCOUNT_STATUS, fmt.Sprintf("企业账户 %d 已被冻结", entId))
|
|
}
|
|
}
|
|
|
|
|
|
@@ -84,6 +77,6 @@ func checkEntStatus(entId int64, authCheck, statusCheck bool) error {
|
|
}
|
|
}
|
|
|
|
|
|
// checkPersonalStatus 校验个人状态账户状态
|
|
// checkPersonalStatus 校验个人状态账户状态
|
|
-func checkPersonalStatus(userId string, authCheck, statusCheck bool) error {
|
|
|
|
|
|
+func checkPersonalStatus(userId string, authCheck, accountCheck bool) error {
|
|
return NewErrorWithCode(GLOBAL_ERR_UNFINISH, "checkPersonalStatus")
|
|
return NewErrorWithCode(GLOBAL_ERR_UNFINISH, "checkPersonalStatus")
|
|
}
|
|
}
|