Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haoban3.0
haoban-manage3.0
Commits
67f503bb
Commit
67f503bb
authored
Oct 10, 2022
by
徐高华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pendingid
parent
fe67cf2a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
16 deletions
+24
-16
HaoBanErrCode.java
...om/gic/haoban/manage/service/errorcode/HaoBanErrCode.java
+4
-1
QwFriendApiServiceImpl.java
...nage/service/service/out/impl/QwFriendApiServiceImpl.java
+9
-9
QwTimesUtils.java
...java/com/gic/haoban/manage/service/util/QwTimesUtils.java
+11
-6
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/errorcode/HaoBanErrCode.java
View file @
67f503bb
...
...
@@ -9,7 +9,10 @@ public enum HaoBanErrCode {
ERR_10012
(
"10012"
,
"企业微信不存在"
),
ERR_OTHER
(
"9999"
,
"业务异常"
),
ERR_100033
(
"100033"
,
"活码分组已经被关联,不可删除"
),
ERR_2000
(
"2000"
,
"企微接口调用次数限制"
)
ERR_2000
(
"2000"
,
"企微接口调用次数限制-月"
),
ERR_2001
(
"2001"
,
"企微接口调用次数限制-天"
),
ERR_2002
(
"2002"
,
"企微接口调用次数限制-小时"
),
ERR_2010
(
"2010"
,
"pending接口调用限制"
)
;
private
String
code
;
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/QwFriendApiServiceImpl.java
View file @
67f503bb
...
...
@@ -127,9 +127,9 @@ public class QwFriendApiServiceImpl implements QwFriendApiService {
WxEnterpriseQwDTO
qwDTO
=
corpidResp
.
getResult
();
String
wxEnterpriseId
=
qwDTO
.
getWxEnterpriseId
();
boolean
isLimit
=
QwTimesUtils
.
isLimit
(
wxEnterpriseId
,
enterpriseId
,
QwInterfaceLimitEnum
.
GET_PENDING_ID
);
if
(
isLimit
)
{
return
ServiceResponse
.
failure
(
HaoBanErrCode
.
ERR_2000
.
getCode
(),
HaoBanErrCode
.
ERR_2000
.
getMsg
());
HaoBanErrCode
limitCode
=
QwTimesUtils
.
isLimit
(
wxEnterpriseId
,
enterpriseId
,
QwInterfaceLimitEnum
.
GET_PENDING_ID
);
if
(
null
!=
limitCode
)
{
return
ServiceResponse
.
failure
(
limitCode
.
getCode
(),
limitCode
.
getMsg
());
}
String
corpid
=
qwDTO
.
getThirdCorpid
();
ServiceResponse
<
PendingIdDTO
>
qwResp
=
this
.
qywxExternalUserService
.
unionidToExternalUserid
(
corpid
,
suiteid
,
...
...
@@ -209,28 +209,28 @@ public class QwFriendApiServiceImpl implements QwFriendApiService {
WxEnterpriseRelationBO
enterpriseRelation
=
this
.
wxEnterpriseRelatedService
.
getHeadEnterprise
(
enterpriseId
);
if
(
null
==
enterpriseRelation
)
{
// 非总部或不存在
return
ServiceResponse
.
failure
(
"2010"
,
"请确认商户是否有效且是总部"
);
return
ServiceResponse
.
failure
(
HaoBanErrCode
.
ERR_2010
.
getCode
()
,
"请确认商户是否有效且是总部"
);
}
EnterpriseSettingDTO
setting
=
this
.
enterpriseService
.
getEnterpriseSettingByEnterpriseId
(
enterpriseId
)
;
String
customSetting
=
setting
.
getCustomSetting
()
;
if
(
StringUtils
.
isNotBlank
(
customSetting
))
{
JSONObject
json
=
JSON
.
parseObject
(
customSetting
)
;
String
qw
=
json
.
getString
(
"qwPendingidFlag"
)
;
if
(
StringUtils
.
is
NotBlank
(
qw
)
&&
"0"
.
equals
(
qw
))
{
String
pendingidFlag
=
json
.
getString
(
"qwPendingidFlag"
)
;
if
(
StringUtils
.
is
Blank
(
pendingidFlag
)
||
"0"
.
equals
(
pendingidFlag
))
{
log
.
info
(
"未配置unionid查询企微外部联系人接口调用"
);
return
ServiceResponse
.
failure
(
"2010"
,
"未配置unionid查询企微外部联系人接口调用"
);
return
ServiceResponse
.
failure
(
HaoBanErrCode
.
ERR_2010
.
getCode
()
,
"未配置unionid查询企微外部联系人接口调用"
);
}
}
Integer
code
=
this
.
enterpriseUseForbidService
.
selectPermissionStatus
(
enterpriseId
,
EnterpriseServiceEnum
.
HAO_BAN
.
getRightMenuCode
());
log
.
info
(
"好办是否到期停用={},{}"
,
enterpriseId
,
code
);
if
(
code
!=
0
&&
code
!=
1
)
{
return
ServiceResponse
.
failure
(
"2010"
,
"商户已停用"
);
return
ServiceResponse
.
failure
(
HaoBanErrCode
.
ERR_2010
.
getCode
()
,
"商户已停用"
);
}
int
memberOpenCardlag
=
enterpriseRelation
.
getMemberOpenCardFlag
();
if
(
memberOpenCardlag
!=
0
)
{
// 不在同一开放平台
return
ServiceResponse
.
failure
(
"2010"
,
"不在同一开放平台"
);
return
ServiceResponse
.
failure
(
HaoBanErrCode
.
ERR_2010
.
getCode
()
,
"不在同一开放平台"
);
}
String
wxEnterpriseId
=
enterpriseRelation
.
getWxEnterpriseId
();
WxEnterpriseQwDTO
qwDTO
=
this
.
wxEnterpriseService
.
getQwInfo
(
wxEnterpriseId
);
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/util/QwTimesUtils.java
View file @
67f503bb
...
...
@@ -19,6 +19,7 @@ import com.gic.enterprise.api.dto.EnterpriseDTO;
import
com.gic.enterprise.api.service.EnterpriseService
;
import
com.gic.enterprise.service.CustomSettingApiService
;
import
com.gic.haoban.common.utils.DingUtils
;
import
com.gic.haoban.manage.service.errorcode.HaoBanErrCode
;
import
com.gic.haoban.manage.service.pojo.bo.QwLimitTimesBO
;
import
com.gic.redis.data.util.RedisUtil
;
...
...
@@ -60,7 +61,7 @@ public class QwTimesUtils {
return
map
;
}
public
static
boolean
isLimit
(
String
wxEnterpriseId
,
String
enterpriseId
,
QwInterfaceLimitEnum
qwInterface
)
{
public
static
HaoBanErrCode
isLimit
(
String
wxEnterpriseId
,
String
enterpriseId
,
QwInterfaceLimitEnum
qwInterface
)
{
QwLimitTimesBO
setTimeBO
=
getSettingTimes
(
wxEnterpriseId
,
qwInterface
);
logger
.
info
(
"获取配置次数={},wxEnterpriseId={},{}"
,
JSON
.
toJSONString
(
setTimeBO
),
wxEnterpriseId
,
enterpriseId
);
// 先判断月
...
...
@@ -71,23 +72,23 @@ public class QwTimesUtils {
boolean
monthResult
=
timesCheck
(
1
,
keyMonth
,
qwInterface
,
wxEnterpriseId
,
enterpriseId
,
now
,
setTimeBO
);
if
(
monthResult
)
{
logger
.
info
(
"月达到限制={},{}"
,
keyMonth
,
enterpriseId
);
return
true
;
return
HaoBanErrCode
.
ERR_2000
;
}
// 天
String
keyDay
=
getCacheKey
(
wxEnterpriseId
,
interfaceName
,
dateStr
.
substring
(
0
,
8
));
boolean
dayResult
=
timesCheck
(
2
,
keyDay
,
qwInterface
,
wxEnterpriseId
,
enterpriseId
,
now
,
setTimeBO
);
if
(
dayResult
)
{
logger
.
info
(
"天达到限制={},{}"
,
keyDay
,
enterpriseId
);
return
true
;
return
HaoBanErrCode
.
ERR_2001
;
}
// 小时
String
keyHour
=
getCacheKey
(
wxEnterpriseId
,
interfaceName
,
dateStr
.
substring
(
0
,
10
));
boolean
hourResult
=
timesCheck
(
3
,
keyHour
,
qwInterface
,
wxEnterpriseId
,
enterpriseId
,
now
,
setTimeBO
);
if
(
hourResult
)
{
logger
.
info
(
"小时达到限制={},{}"
,
keyHour
,
enterpriseId
);
return
true
;
return
HaoBanErrCode
.
ERR_2002
;
}
return
false
;
return
null
;
}
private
static
boolean
timesCheck
(
int
type
,
String
cacheKey
,
QwInterfaceLimitEnum
qwInterface
,
...
...
@@ -181,7 +182,11 @@ public class QwTimesUtils {
}
logger
.
info
(
"告警key={},value={}"
,
alertKey
,
RedisUtil
.
getCache
(
alertKey
));
if
(
sendFlag
&&
null
==
RedisUtil
.
getCache
(
alertKey
))
{
RedisUtil
.
setCache
(
alertKey
,
1
,
60
*
60
*
24L
);
if
(
type
==
3
)
{
RedisUtil
.
setCache
(
alertKey
,
1
,
60
*
59L
);
}
else
{
RedisUtil
.
setCache
(
alertKey
,
1
,
60
*
60
*
12L
);
}
EnterpriseDTO
enterpriseDTO
=
enterpriseService
.
getEnterpriseById
(
enterpriseId
);
String
brandName
=
enterpriseDTO
.
getBrandName
();
// 达到上限时文案
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment