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
07b041db
Commit
07b041db
authored
Sep 29, 2022
by
墨竹
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/developer' into developer
parents
717c1129
cf9ae6b7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
25 deletions
+78
-25
QwFriendApiService.java
...com/gic/haoban/manage/api/service/QwFriendApiService.java
+15
-0
QwFriendApiServiceImpl.java
...nage/service/service/out/impl/QwFriendApiServiceImpl.java
+45
-4
QwTimesUtils.java
...java/com/gic/haoban/manage/service/util/QwTimesUtils.java
+18
-21
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/QwFriendApiService.java
View file @
07b041db
package
com
.
gic
.
haoban
.
manage
.
api
.
service
;
package
com
.
gic
.
haoban
.
manage
.
api
.
service
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.haoban.manage.api.dto.QwPendingIdDTO
;
import
com.gic.haoban.manage.api.dto.QwPendingIdDTO
;
...
@@ -17,6 +18,20 @@ public interface QwFriendApiService {
...
@@ -17,6 +18,20 @@ public interface QwFriendApiService {
/**
/**
*
*
* @Title: pendingCheck
* @Description: 校验商户能否获取pending
* @author xugh
* @param enterpriseId
* @param unionid
* @param openid
* @param wxaOpenid
* @return
* @throws
*/
public
ServiceResponse
<
Map
<
String
,
String
>>
pendingIdCheck
(
String
enterpriseId
,
String
unionid
,
String
openid
,
String
wxaOpenid
);
/**
*
* @Title: getPendingIdByUnionid
* @Title: getPendingIdByUnionid
* @Description: 通过uniond获取好友id/pendingid
* @Description: 通过uniond获取好友id/pendingid
* @author xugh
* @author xugh
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/QwFriendApiServiceImpl.java
View file @
07b041db
...
@@ -2,7 +2,9 @@ package com.gic.haoban.manage.service.service.out.impl;
...
@@ -2,7 +2,9 @@ package com.gic.haoban.manage.service.service.out.impl;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
...
@@ -44,24 +46,63 @@ public class QwFriendApiServiceImpl implements QwFriendApiService {
...
@@ -44,24 +46,63 @@ public class QwFriendApiServiceImpl implements QwFriendApiService {
private
Config
config
;
private
Config
config
;
@Override
@Override
public
ServiceResponse
<
QwPendingIdDTO
>
getPendingIdByUnionid
(
String
enterpriseId
,
String
unionid
,
String
openid
)
{
public
ServiceResponse
<
Map
<
String
,
String
>>
pendingIdCheck
(
String
enterpriseId
,
String
unionid
,
String
openid
,
String
wxaOpenid
)
{
ServiceResponse
<
WxEnterpriseQwDTO
>
corpidResp
=
this
.
checkAndGetCorpid
(
enterpriseId
);
if
(!
corpidResp
.
isSuccess
())
{
return
ServiceResponse
.
failure
(
corpidResp
.
getCode
(),
corpidResp
.
getMessage
());
}
String
suiteid
=
config
.
getWxSuiteid
();
String
suiteid
=
config
.
getWxSuiteid
();
WxEnterpriseQwDTO
qwDTO
=
corpidResp
.
getResult
();
String
corpid
=
qwDTO
.
getThirdCorpid
();
ServiceResponse
<
PendingIdDTO
>
wxResp
=
this
.
qywxExternalUserService
.
unionidToExternalUserid
(
corpid
,
suiteid
,
unionid
,
openid
,
0
);
Map
<
String
,
String
>
retMap
=
new
HashMap
<>();
StringBuilder
sb
=
new
StringBuilder
();
String
result
=
""
;
String
wxCode
=
"0"
;
String
wxaCode
=
"0"
;
if
(
wxResp
.
isSuccess
())
{
result
=
"ok"
;
}
else
{
result
=
wxResp
.
getCode
();
wxCode
=
result
;
}
retMap
.
put
(
"wxCode"
,
wxCode
);
sb
.
append
(
"服务号-"
).
append
(
result
).
append
(
","
);
ServiceResponse
<
PendingIdDTO
>
wxaResp
=
this
.
qywxExternalUserService
.
unionidToExternalUserid
(
corpid
,
suiteid
,
unionid
,
wxaOpenid
,
0
);
if
(
wxaResp
.
isSuccess
())
{
result
=
"ok"
;
}
else
{
result
=
wxResp
.
getCode
();
wxaCode
=
result
;
}
sb
.
append
(
"小程序-"
).
append
(
result
);
retMap
.
put
(
"remark"
,
sb
.
toString
());
retMap
.
put
(
"wxaCode"
,
wxaCode
);
return
ServiceResponse
.
success
(
retMap
);
}
@Override
public
ServiceResponse
<
QwPendingIdDTO
>
getPendingIdByUnionid
(
String
enterpriseId
,
String
unionid
,
String
openid
)
{
ServiceResponse
<
WxEnterpriseQwDTO
>
corpidResp
=
this
.
checkAndGetCorpid
(
enterpriseId
);
ServiceResponse
<
WxEnterpriseQwDTO
>
corpidResp
=
this
.
checkAndGetCorpid
(
enterpriseId
);
if
(!
corpidResp
.
isSuccess
())
{
if
(!
corpidResp
.
isSuccess
())
{
return
ServiceResponse
.
failure
(
corpidResp
.
getCode
(),
corpidResp
.
getMessage
());
return
ServiceResponse
.
failure
(
corpidResp
.
getCode
(),
corpidResp
.
getMessage
());
}
}
String
suiteid
=
config
.
getWxSuiteid
();
WxEnterpriseQwDTO
qwDTO
=
corpidResp
.
getResult
();
WxEnterpriseQwDTO
qwDTO
=
corpidResp
.
getResult
();
String
wxEnterpriseId
=
qwDTO
.
getWxEnterpriseId
();
String
wxEnterpriseId
=
qwDTO
.
getWxEnterpriseId
();
boolean
isLimit
=
QwTimesUtils
.
isLimit
(
wxEnterpriseId
,
enterpriseId
,
QwInterfaceLimitEnum
.
GET_PENDING_ID
);
boolean
isLimit
=
QwTimesUtils
.
isLimit
(
wxEnterpriseId
,
enterpriseId
,
QwInterfaceLimitEnum
.
GET_PENDING_ID
);
if
(
isLimit
)
{
if
(
isLimit
)
{
return
ServiceResponse
.
failure
(
HaoBanErrCode
.
ERR_2000
.
getCode
(),
HaoBanErrCode
.
ERR_2000
.
getMsg
());
return
ServiceResponse
.
failure
(
HaoBanErrCode
.
ERR_2000
.
getCode
(),
HaoBanErrCode
.
ERR_2000
.
getMsg
());
}
}
String
corpid
=
qwDTO
.
getThirdCorpid
();
String
corpid
=
qwDTO
.
getThirdCorpid
();
ServiceResponse
<
PendingIdDTO
>
qwResp
=
this
.
qywxExternalUserService
.
unionidToExternalUserid
(
corpid
,
suiteid
,
ServiceResponse
<
PendingIdDTO
>
qwResp
=
this
.
qywxExternalUserService
.
unionidToExternalUserid
(
corpid
,
suiteid
,
unionid
,
openid
,
1
);
unionid
,
openid
,
0
);
QwTimesUtils
.
addTimes
(
wxEnterpriseId
,
QwInterfaceLimitEnum
.
GET_PENDING_ID
);
QwTimesUtils
.
addTimes
(
wxEnterpriseId
,
QwInterfaceLimitEnum
.
GET_PENDING_ID
);
log
.
info
(
"获取pendingid,参数={},
返回={}"
,
unio
nid
,
JSON
.
toJSONString
(
qwResp
));
log
.
info
(
"获取pendingid,参数={},
{},返回={}"
,
unionid
,
ope
nid
,
JSON
.
toJSONString
(
qwResp
));
if
(!
qwResp
.
isSuccess
())
{
if
(!
qwResp
.
isSuccess
())
{
return
ServiceResponse
.
failure
(
qwResp
.
getCode
(),
qwResp
.
getMessage
());
return
ServiceResponse
.
failure
(
qwResp
.
getCode
(),
qwResp
.
getMessage
());
}
}
...
...
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/util/QwTimesUtils.java
View file @
07b041db
...
@@ -39,29 +39,29 @@ public class QwTimesUtils {
...
@@ -39,29 +39,29 @@ public class QwTimesUtils {
QwTimesUtils
.
enterpriseService
=
enterpriseService
;
QwTimesUtils
.
enterpriseService
=
enterpriseService
;
}
}
public
static
boolean
isLimit
(
String
wxEnterpriseId
,
String
enterpriseId
,
QwInterfaceLimitEnum
obj
)
{
public
static
boolean
isLimit
(
String
wxEnterpriseId
,
String
enterpriseId
,
QwInterfaceLimitEnum
qwInterface
)
{
QwLimitTimesBO
setTimeBO
=
getSettingTimes
(
wxEnterpriseId
,
obj
);
QwLimitTimesBO
setTimeBO
=
getSettingTimes
(
wxEnterpriseId
,
qwInterface
);
logger
.
info
(
"获取配置次数={},wxEnterpriseId={}"
,
JSON
.
toJSONString
(
setTimeBO
),
wxEnterpriseId
);
logger
.
info
(
"获取配置次数={},wxEnterpriseId={}"
,
JSON
.
toJSONString
(
setTimeBO
),
wxEnterpriseId
);
// 先判断月
// 先判断月
String
interfaceName
=
obj
.
getName
();
String
interfaceName
=
qwInterface
.
getName
();
Date
now
=
new
Date
();
Date
now
=
new
Date
();
String
dateStr
=
getDateStr
(
now
);
String
dateStr
=
getDateStr
(
now
);
String
keyMonth
=
getCacheKey
(
wxEnterpriseId
,
interfaceName
,
dateStr
.
substring
(
0
,
6
));
String
keyMonth
=
getCacheKey
(
wxEnterpriseId
,
interfaceName
,
dateStr
.
substring
(
0
,
6
));
boolean
monthResult
=
timesCheck
(
1
,
keyMonth
,
obj
,
wxEnterpriseId
,
enterpriseId
,
now
,
setTimeBO
);
boolean
monthResult
=
timesCheck
(
1
,
keyMonth
,
qwInterface
,
wxEnterpriseId
,
enterpriseId
,
now
,
setTimeBO
);
if
(
monthResult
)
{
if
(
monthResult
)
{
logger
.
info
(
"月达到限制={}"
,
keyMonth
);
logger
.
info
(
"月达到限制={}"
,
keyMonth
);
return
true
;
return
true
;
}
}
// 天
// 天
String
keyDay
=
getCacheKey
(
wxEnterpriseId
,
interfaceName
,
dateStr
.
substring
(
0
,
8
));
String
keyDay
=
getCacheKey
(
wxEnterpriseId
,
interfaceName
,
dateStr
.
substring
(
0
,
8
));
boolean
dayResult
=
timesCheck
(
2
,
keyDay
,
obj
,
wxEnterpriseId
,
enterpriseId
,
now
,
setTimeBO
);
boolean
dayResult
=
timesCheck
(
2
,
keyDay
,
qwInterface
,
wxEnterpriseId
,
enterpriseId
,
now
,
setTimeBO
);
if
(
dayResult
)
{
if
(
dayResult
)
{
logger
.
info
(
"天达到限制={}"
,
keyDay
);
logger
.
info
(
"天达到限制={}"
,
keyDay
);
return
true
;
return
true
;
}
}
// 小时
// 小时
String
keyHour
=
getCacheKey
(
wxEnterpriseId
,
interfaceName
,
dateStr
.
substring
(
0
,
10
));
String
keyHour
=
getCacheKey
(
wxEnterpriseId
,
interfaceName
,
dateStr
.
substring
(
0
,
10
));
boolean
hourResult
=
timesCheck
(
3
,
keyHour
,
obj
,
wxEnterpriseId
,
enterpriseId
,
now
,
setTimeBO
);
boolean
hourResult
=
timesCheck
(
3
,
keyHour
,
qwInterface
,
wxEnterpriseId
,
enterpriseId
,
now
,
setTimeBO
);
if
(
hourResult
)
{
if
(
hourResult
)
{
logger
.
info
(
"小时达到限制={}"
,
keyHour
);
logger
.
info
(
"小时达到限制={}"
,
keyHour
);
return
true
;
return
true
;
...
@@ -69,11 +69,11 @@ public class QwTimesUtils {
...
@@ -69,11 +69,11 @@ public class QwTimesUtils {
return
false
;
return
false
;
}
}
private
static
boolean
timesCheck
(
int
type
,
String
cacheKey
,
QwInterfaceLimitEnum
obj
,
String
wxEnterpriseId
,
private
static
boolean
timesCheck
(
int
type
,
String
cacheKey
,
QwInterfaceLimitEnum
qwInterface
,
String
enterpriseId
,
Date
now
,
QwLimitTimesBO
setTimeBO
)
{
String
wxEnterpriseId
,
String
enterpriseId
,
Date
now
,
QwLimitTimesBO
setTimeBO
)
{
Integer
doneTimes
=
RedisUtil
.
getCache
(
cacheKey
,
Integer
.
class
);
Integer
doneTimes
=
RedisUtil
.
getCache
(
cacheKey
,
Integer
.
class
);
logger
.
info
(
"
获取已调次数={},cacheKey={}"
,
doneTimes
,
cacheKey
);
logger
.
info
(
"
type{}获取已调次数={},cacheKey={}"
,
type
,
doneTimes
==
null
?
0
:
doneTimes
,
cacheKey
);
if
(
null
==
doneTimes
)
{
if
(
null
==
doneTimes
||
doneTimes
==
0
)
{
return
false
;
return
false
;
}
}
int
setTimes
=
0
;
int
setTimes
=
0
;
...
@@ -90,18 +90,18 @@ public class QwTimesUtils {
...
@@ -90,18 +90,18 @@ public class QwTimesUtils {
default
:
default
:
break
;
break
;
}
}
sendAlert
(
type
,
doneTimes
,
setTimes
,
obj
,
enterpriseId
,
now
);
sendAlert
(
type
,
doneTimes
,
setTimes
,
qwInterface
,
enterpriseId
,
now
);
if
(
doneTimes
>=
setTimes
)
{
if
(
doneTimes
>=
setTimes
)
{
return
true
;
return
true
;
}
}
return
false
;
return
false
;
}
}
private
static
QwLimitTimesBO
getSettingTimes
(
String
wxEnterpriseId
,
QwInterfaceLimitEnum
obj
)
{
private
static
QwLimitTimesBO
getSettingTimes
(
String
wxEnterpriseId
,
QwInterfaceLimitEnum
qwInterface
)
{
String
key
=
String
.
format
(
"%s_%s"
,
obj
.
getName
(),
wxEnterpriseId
);
String
key
=
String
.
format
(
"%s_%s"
,
qwInterface
.
getName
(),
wxEnterpriseId
);
QwLimitTimesBO
times
=
getTimes
(
key
);
QwLimitTimesBO
times
=
getTimes
(
key
);
if
(
null
==
times
)
{
if
(
null
==
times
)
{
return
getTimes
(
obj
.
getName
());
return
getTimes
(
qwInterface
.
getName
());
}
}
return
times
;
return
times
;
}
}
...
@@ -112,16 +112,13 @@ public class QwTimesUtils {
...
@@ -112,16 +112,13 @@ public class QwTimesUtils {
ServiceResponse
<
Map
<
String
,
Object
>>
resp
=
customSettingApiService
.
getDetail
(
"tab_gic_map"
,
ServiceResponse
<
Map
<
String
,
Object
>>
resp
=
customSettingApiService
.
getDetail
(
"tab_gic_map"
,
searchParamMap
.
toJSONString
());
searchParamMap
.
toJSONString
());
if
(
resp
.
isSuccess
()
&&
null
!=
resp
.
getResult
())
{
if
(
resp
.
isSuccess
()
&&
null
!=
resp
.
getResult
())
{
QwLimitTimesBO
times
=
new
QwLimitTimesBO
();
return
JSON
.
parseObject
(
resp
.
getResult
().
get
(
"value"
).
toString
(),
QwLimitTimesBO
.
class
);
times
=
JSON
.
parseObject
(
resp
.
getResult
().
get
(
"value"
).
toString
(),
QwLimitTimesBO
.
class
);
logger
.
info
(
"获取默认配置次数={},{}"
,
times
,
key
);
return
times
;
}
}
return
null
;
return
null
;
}
}
private
static
void
sendAlert
(
int
type
,
int
doneTimes
,
int
setTimes
,
QwInterfaceLimitEnum
obj
,
String
enterpriseId
,
private
static
void
sendAlert
(
int
type
,
int
doneTimes
,
int
setTimes
,
QwInterfaceLimitEnum
qwInterface
,
Date
now
)
{
String
enterpriseId
,
Date
now
)
{
// 调用次数达上线
// 调用次数达上线
String
time
=
null
;
String
time
=
null
;
String
title
=
"已达上限"
;
String
title
=
"已达上限"
;
...
@@ -163,7 +160,7 @@ public class QwTimesUtils {
...
@@ -163,7 +160,7 @@ public class QwTimesUtils {
EnterpriseDTO
enterpriseDTO
=
enterpriseService
.
getEnterpriseById
(
enterpriseId
);
EnterpriseDTO
enterpriseDTO
=
enterpriseService
.
getEnterpriseById
(
enterpriseId
);
String
brandName
=
enterpriseDTO
.
getBrandName
();
String
brandName
=
enterpriseDTO
.
getBrandName
();
// 达到上限时文案
// 达到上限时文案
String
msg
=
String
.
format
(
"告警【%s】%s调用在【%s】%s"
,
brandName
,
obj
.
getRemark
(),
time
,
title
);
String
msg
=
String
.
format
(
"告警【%s】%s调用在【%s】%s"
,
brandName
,
qwInterface
.
getRemark
(),
time
,
title
);
DingUtils
.
send
(
msg
,
false
);
DingUtils
.
send
(
msg
,
false
);
}
}
}
}
...
...
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