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
2c30edac
Commit
2c30edac
authored
Mar 02, 2023
by
徐高华
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'developer' into 'master'
订单拉取日期bug See merge request
!971
parents
5fc10b1e
be13eabb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
64 deletions
+75
-64
HaobanQywxFeeApiServiceImpl.java
...ice/service/out/impl/fee/HaobanQywxFeeApiServiceImpl.java
+75
-64
No files found.
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/fee/HaobanQywxFeeApiServiceImpl.java
View file @
2c30edac
...
...
@@ -15,21 +15,17 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gic.api.base.commons.Page
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.GICMQClientUtil
;
import
com.gic.commons.util.UniqueIdUtils
;
import
com.gic.dubbo.entity.ProviderLocalTag
;
import
com.gic.haoban.common.utils.PageUtil
;
import
com.gic.haoban.manage.api.constants.Manage3Constants
;
import
com.gic.haoban.manage.api.dto.AlertMessageDTO
;
import
com.gic.haoban.manage.api.dto.WxEnterpriseDTO
;
import
com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeAccountInterceptLogDTO
;
import
com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDTO
;
import
com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDetailDTO
;
import
com.gic.haoban.manage.api.dto.qdto.QywxFeeListQDTO
;
import
com.gic.haoban.manage.api.enums.AlertTypeEnum
;
import
com.gic.haoban.manage.api.service.fee.HaobanQywxFeeApiService
;
import
com.gic.haoban.manage.service.config.Config
;
import
com.gic.haoban.manage.service.entity.TabHaobanStaff
;
...
...
@@ -85,7 +81,7 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
@Autowired
private
HaobanQywxFeeAccountInterceptLogService
haobanQywxFeeAccountInterceptLogService
;
@Autowired
private
WxEnterpriseActiveDataService
wxEnterpriseActiveDataService
;
private
WxEnterpriseActiveDataService
wxEnterpriseActiveDataService
;
@Override
public
void
run
(
String
param
)
{
...
...
@@ -104,12 +100,14 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
List
<
String
>
orderIds
=
new
ArrayList
<>();
FeeOrderListQDTO
feeOrderListQDTO
=
new
FeeOrderListQDTO
();
feeOrderListQDTO
.
setCorpid
(
corpid
);
if
(
null
==
RedisUtil
.
getCache
(
"qywx-order-search-date"
))
{
feeOrderListQDTO
.
setStartTime
(
DateUtil
.
beginOfDay
(
new
Date
()).
offsetNew
(
DateField
.
HOUR_OF_DAY
,
-
1
).
getTime
());
feeOrderListQDTO
.
setEndTime
(
DateUtil
.
endOfDay
(
new
Date
()).
offsetNew
(
DateField
.
HOUR_OF_DAY
,
-
1
).
getTime
());
if
(
null
==
RedisUtil
.
getCache
(
"qywx-order-search-date"
))
{
feeOrderListQDTO
.
setStartTime
(
DateUtil
.
beginOfDay
(
new
Date
()).
offsetNew
(
DateField
.
HOUR_OF_DAY
,
-
24
).
getTime
());
feeOrderListQDTO
.
setEndTime
(
new
Date
().
getTime
());
}
feeOrderListQDTO
.
setLimit
(
Manage3Constants
.
QW_LIMIT
);
FeeOrderResponseList
feeOrderResponseList
=
qywxUserApiService
.
listOrder
(
corpid
,
config
.
getCorpid
(),
feeOrderListQDTO
);
FeeOrderResponseList
feeOrderResponseList
=
qywxUserApiService
.
listOrder
(
corpid
,
config
.
getCorpid
(),
feeOrderListQDTO
);
logger
.
error
(
"查询激活码订单,{}"
,
JSON
.
toJSONString
(
feeOrderResponseList
));
int
errcode
=
feeOrderResponseList
.
getErrcode
();
if
(
errcode
==
0
)
{
...
...
@@ -117,37 +115,39 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
orderIds
.
add
(
orderListDTO
.
getOrderId
());
}
}
return
orderIds
;
return
orderIds
;
}
// 查询订单下的激活码code列表
private
void
getOrderAccount
(
String
orderId
,
String
corpid
,
String
cursor
,
List
<
Map
<
String
,
String
>>
activeCodeList
)
{
logger
.
info
(
"处理订单激活码,orderid={}"
,
orderId
);
private
void
getOrderAccount
(
String
orderId
,
String
corpid
,
String
cursor
,
List
<
Map
<
String
,
String
>>
activeCodeList
)
{
logger
.
info
(
"处理订单激活码,orderid={}"
,
orderId
);
FeeOrderListQDTO
feeOrderListQDTO
=
new
FeeOrderListQDTO
();
feeOrderListQDTO
.
setOrderId
(
orderId
);
feeOrderListQDTO
.
setCursor
(
cursor
);
feeOrderListQDTO
.
setLimit
(
Manage3Constants
.
QW_LIMIT
);
AccountListResponseDTO
accountListResponseDTO
=
qywxUserApiService
.
listOrderAccount
(
corpid
,
config
.
getCorpid
(),
feeOrderListQDTO
);
AccountListResponseDTO
accountListResponseDTO
=
qywxUserApiService
.
listOrderAccount
(
corpid
,
config
.
getCorpid
(),
feeOrderListQDTO
);
if
(
accountListResponseDTO
.
getErrcode
()
!=
0
)
{
logger
.
info
(
"订单账号列表报错:{}"
,
accountListResponseDTO
.
getErrmsg
());
return
;
return
;
}
// 只记录互通账号
for
(
AccountListDTO
accountListDTO
:
accountListResponseDTO
.
getAccountList
())
{
if
(
accountListDTO
.
getType
()==
2
)
{
if
(
accountListDTO
.
getType
()
==
2
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"orderId"
,
orderId
);
map
.
put
(
"activeCode"
,
accountListDTO
.
getActiveCode
());
activeCodeList
.
add
(
map
);
}
}
cursor
=
accountListResponseDTO
.
getNextCursor
()
;
cursor
=
accountListResponseDTO
.
getNextCursor
();
Integer
hasMore
=
accountListResponseDTO
.
getHasMore
();
if
(
hasMore
==
1
&&
StringUtils
.
isNotBlank
(
cursor
))
{
this
.
getOrderAccount
(
orderId
,
corpid
,
cursor
,
activeCodeList
);
}
}
@Override
public
void
addFee
(
String
wxEnterpriseId
)
{
logger
.
info
(
"企微收费wxEnterpriseId={}"
,
wxEnterpriseId
);
...
...
@@ -157,15 +157,15 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
}
String
serviceCorpid
=
config
.
getCorpid
();
WxEnterpriseDTO
wxEnterpriseDTO
=
wxEnterpriseService
.
selectById
(
wxEnterpriseId
);
if
(
wxEnterpriseDTO
.
getWxSecurityType
()<=
0
)
{
logger
.
info
(
"WxSecurityType=0,wxEnterpriseId={}"
,
wxEnterpriseId
);
return
;
if
(
wxEnterpriseDTO
.
getWxSecurityType
()
<=
0
)
{
logger
.
info
(
"WxSecurityType=0,wxEnterpriseId={}"
,
wxEnterpriseId
);
return
;
}
String
corpid
=
wxEnterpriseDTO
.
getOpenCorpid
()
;
String
corpid
=
wxEnterpriseDTO
.
getOpenCorpid
();
String
corpName
=
wxEnterpriseDTO
.
getCorpName
();
String
autoActiveStatus
=
qywxUserApiService
.
getAutoActiveStatus
(
corpid
,
serviceCorpid
);
if
(!
"1"
.
equals
(
autoActiveStatus
))
{
logger
.
info
(
"未开启自动激活:{},wxeid={}"
,
corpid
,
wxEnterpriseId
);
logger
.
info
(
"未开启自动激活:{},wxeid={}"
,
corpid
,
wxEnterpriseId
);
this
.
wxEnterpriseService
.
updateAutoActiveFlagById
(
0
,
wxEnterpriseId
);
return
;
}
...
...
@@ -173,14 +173,14 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
if
(
autoActiveFlag
!=
null
&&
autoActiveFlag
!=
1
)
{
this
.
wxEnterpriseService
.
updateAutoActiveFlagById
(
1
,
wxEnterpriseId
);
}
List
<
String
>
orderIdList
=
this
.
listOrderId
(
corpid
)
;
List
<
String
>
orderIdList
=
this
.
listOrderId
(
corpid
);
for
(
String
orderId
:
orderIdList
)
{
FeeOrderDeatilResponseDTO
order
=
qywxUserApiService
.
getOrder
(
corpid
,
serviceCorpid
,
orderId
);
if
(
order
.
getErrcode
()
!=
0
)
{
logger
.
error
(
"请求企微失败:{}"
,
orderId
);
continue
;
}
//插入订单
//
插入订单
FeeOrderDeatilResponseDTO
.
OrderDTO
orderDTO
=
order
.
getOrder
();
Integer
orderStatus
=
orderDTO
.
getOrderStatus
();
if
(
orderStatus
!=
1
)
{
...
...
@@ -203,35 +203,35 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
// 增加到订单表,如果存在不更新
this
.
haobanQywxFeeOrderService
.
insert
(
tabHaobanQywxFeeOrder
);
}
// 更新订单的激活码状态
List
<
TabHaobanQywxFeeOrder
>
orderList
=
this
.
haobanQywxFeeOrderService
.
listOrder
(
wxEnterpriseId
)
;
if
(
CollectionUtils
.
isEmpty
(
orderList
))
{
List
<
TabHaobanQywxFeeOrder
>
orderList
=
this
.
haobanQywxFeeOrderService
.
listOrder
(
wxEnterpriseId
);
if
(
CollectionUtils
.
isEmpty
(
orderList
))
{
logger
.
error
(
"无企微订单:{}"
,
wxEnterpriseId
);
return
;
return
;
}
// 查询订单下的激活码code列表,记录到activeCodeList
for
(
TabHaobanQywxFeeOrder
order
:
orderList
)
{
for
(
TabHaobanQywxFeeOrder
order
:
orderList
)
{
List
<
Map
<
String
,
String
>>
activeCodeList
=
new
ArrayList
<>();
// 查询订单下的激活码code列表
this
.
getOrderAccount
(
order
.
getOrderId
(),
corpid
,
null
,
activeCodeList
);
// 保存激活码列表
this
.
addOrderAccount
(
wxEnterpriseId
,
serviceCorpid
,
corpid
,
activeCodeList
);
}
// 成员的激活码信息
this
.
staffService
.
activedAccountTimer
(
wxEnterpriseId
);
// 更新企业的激活数量统计
this
.
wxEnterpriseActiveDataService
.
saveOrUpdate
(
wxEnterpriseId
)
;
this
.
wxEnterpriseActiveDataService
.
saveOrUpdate
(
wxEnterpriseId
);
//统计 haobanQywxFeeDetailDTO 30天内最新过期的时间和人数
//
统计 haobanQywxFeeDetailDTO 30天内最新过期的时间和人数
HaobanQywxFeeDetailDTO
haobanQywxFeeDetailDTO
=
haobanQywxFeeAccountStaffService
.
feeIntercept
(
wxEnterpriseId
);
// 未激活数(状态1)
int
permissionUserNum
=
haobanQywxFeeOrderAccountService
.
countOrderAccountStatus
(
1
,
wxEnterpriseId
);
// 待转移数(状态4)
int
transferUserNum
=
haobanQywxFeeOrderAccountService
.
countOrderAccountStatus
(
4
,
wxEnterpriseId
);
int
totalCount
=
this
.
haobanQywxFeeOrderService
.
countExternalContactCount
(
wxEnterpriseId
)
;
int
totalCount
=
this
.
haobanQywxFeeOrderService
.
countExternalContactCount
(
wxEnterpriseId
);
if
(
haobanQywxFeeDetailDTO
!=
null
&&
permissionUserNum
>
0
)
{
TabHaobanQywxFee
tabHaobanQywxFee
=
new
TabHaobanQywxFee
();
tabHaobanQywxFee
.
setQwFeeId
(
UniqueIdUtils
.
uniqueLong
());
...
...
@@ -245,17 +245,22 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
tabHaobanQywxFee
.
setBuyPermissionUserNum
(
totalCount
);
tabHaobanQywxFee
.
setInterceptFlag
(
0
);
haobanQywxFeeService
.
insert
(
tabHaobanQywxFee
);
//判断今天是否是本月最后一天
//
判断今天是否是本月最后一天
if
(
DateUtil
.
isSameDay
(
DateUtil
.
endOfMonth
(
new
Date
()),
new
Date
()))
{
// int monthWillInterceptNum = haobanQywxFeeAccountStaffService.monthWillInterceptNum(wxEnterpriseId);
// String content = "30天将有" + monthWillInterceptNum + "个接口许可证即将过期,您总共还剩余" + permissionUserNum + "个可用的接口许可证,请保证数量充足,如需增加请及时联系相关人员续费,避免影响使用";
//告警
// messageAlert(wxEnterpriseId, corpName, corpid, AlertTypeEnum.FEE_ALARM.getName(), content);
// int monthWillInterceptNum =
// haobanQywxFeeAccountStaffService.monthWillInterceptNum(wxEnterpriseId);
// String content = "30天将有" + monthWillInterceptNum +
// "个接口许可证即将过期,您总共还剩余" + permissionUserNum +
// "个可用的接口许可证,请保证数量充足,如需增加请及时联系相关人员续费,避免影响使用";
// 告警
// messageAlert(wxEnterpriseId, corpName, corpid,
// AlertTypeEnum.FEE_ALARM.getName(), content);
}
}
// 更加企微通知记录已拦截数
List
<
TabHaobanQywxFeeAccountInterceptLog
>
interceptLogs
=
haobanQywxFeeAccountInterceptLogService
.
queryByWxEnterpriseId
(
wxEnterpriseId
);
List
<
TabHaobanQywxFeeAccountInterceptLog
>
interceptLogs
=
haobanQywxFeeAccountInterceptLogService
.
queryByWxEnterpriseId
(
wxEnterpriseId
);
if
(
CollectionUtils
.
isNotEmpty
(
interceptLogs
))
{
TabHaobanQywxFee
tabHaobanQywxFee
=
new
TabHaobanQywxFee
();
tabHaobanQywxFee
.
setQwFeeId
(
UniqueIdUtils
.
uniqueLong
());
...
...
@@ -271,36 +276,38 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
haobanQywxFeeService
.
insert
(
tabHaobanQywxFee
);
}
}
// 保存订单下的激活码信息-tab_haoban_qywx_fee_order_account
private
void
addOrderAccount
(
String
wxEnterpriseId
,
String
serviceCorpid
,
String
corpid
,
List
<
Map
<
String
,
String
>>
activeCodeList
)
{
private
void
addOrderAccount
(
String
wxEnterpriseId
,
String
serviceCorpid
,
String
corpid
,
List
<
Map
<
String
,
String
>>
activeCodeList
)
{
if
(
CollectionUtils
.
isEmpty
(
activeCodeList
))
{
logger
.
error
(
"订单账号无激活码"
);
return
;
}
List
<
String
>
codeList
=
new
ArrayList
<>();
Map
<
String
,
String
>
keyMap
=
new
HashMap
<>();
Map
<
String
,
String
>
keyMap
=
new
HashMap
<>();
for
(
Map
<
String
,
String
>
activeCodeMap
:
activeCodeList
)
{
String
activeCode
=
activeCodeMap
.
get
(
"activeCode"
);
String
orderId
=
activeCodeMap
.
get
(
"orderId"
);
codeList
.
add
(
activeCode
)
;
keyMap
.
put
(
activeCode
,
orderId
)
;
codeList
.
add
(
activeCode
);
keyMap
.
put
(
activeCode
,
orderId
)
;
}
TabHaobanQywxFeeOrderAccount
activeAccount
=
new
TabHaobanQywxFeeOrderAccount
();
// 查询激活码的详情
List
<
ActiveInfoCodeResponseDTO
>
respList
=
qywxUserApiService
.
getActiveInfoByCodeList
(
corpid
,
serviceCorpid
,
codeList
);
if
(
CollectionUtils
.
isNotEmpty
(
respList
))
{
List
<
List
<
ActiveInfoCodeResponseDTO
>>
list
=
Lists
.
partition
(
respList
,
800
)
;
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
List
<
ActiveInfoCodeResponseDTO
>
respList
=
qywxUserApiService
.
getActiveInfoByCodeList
(
corpid
,
serviceCorpid
,
codeList
);
if
(
CollectionUtils
.
isNotEmpty
(
respList
))
{
List
<
List
<
ActiveInfoCodeResponseDTO
>>
list
=
Lists
.
partition
(
respList
,
800
);
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
List
<
ActiveInfoCodeResponseDTO
>
subList
=
list
.
get
(
i
);
for
(
ActiveInfoCodeResponseDTO
activeDetail
:
subList
)
{
for
(
ActiveInfoCodeResponseDTO
activeDetail
:
subList
)
{
String
userid
=
activeDetail
.
getUserid
();
String
activeCode
=
activeDetail
.
getActiveCode
()
;
String
activeCode
=
activeDetail
.
getActiveCode
();
activeAccount
.
setWxUserId
(
userid
);
activeAccount
.
setStatus
(
activeDetail
.
getStatus
());
if
(
null
!=
activeDetail
.
getExpireTime
())
{
if
(
null
!=
activeDetail
.
getExpireTime
())
{
activeAccount
.
setExpireTime
(
DateUtil
.
date
(
activeDetail
.
getExpireTime
()
*
1000
));
activeAccount
.
setActiveTime
(
DateUtil
.
date
(
activeDetail
.
getActiveTime
()
*
1000
));
}
...
...
@@ -328,24 +335,28 @@ public class HaobanQywxFeeApiServiceImpl implements HaobanQywxFeeApiService {
@Override
public
void
addInterceptLog
(
String
param
)
{
HaobanQywxFeeAccountInterceptLogDTO
logDTO
=
JSON
.
toJavaObject
(
JSON
.
parseObject
(
param
),
HaobanQywxFeeAccountInterceptLogDTO
.
class
);
HaobanQywxFeeAccountInterceptLogDTO
logDTO
=
JSON
.
toJavaObject
(
JSON
.
parseObject
(
param
),
HaobanQywxFeeAccountInterceptLogDTO
.
class
);
logDTO
.
setFeeAccountInterceptId
(
UniqueIdUtils
.
uniqueLong
());
TabHaobanWxEnterprise
haobanWxEnterprise
=
wxEnterpriseService
.
getEnterpriseBycorpId
(
logDTO
.
getCorpId
());
if
(
null
==
haobanWxEnterprise
)
{
return
;
if
(
null
==
haobanWxEnterprise
)
{
return
;
}
String
wxEnterpriseId
=
haobanWxEnterprise
.
getWxEnterpriseId
();
logDTO
.
setWxEnterpriseId
(
wxEnterpriseId
);
TabHaobanStaff
tabHaobanStaff
=
staffService
.
selectByUserIdAndEnterpriseId
(
logDTO
.
getWxUserId
(),
wxEnterpriseId
);
if
(
null
==
tabHaobanStaff
)
{
return
;
TabHaobanStaff
tabHaobanStaff
=
staffService
.
selectByUserIdAndEnterpriseId
(
logDTO
.
getWxUserId
(),
wxEnterpriseId
);
if
(
null
==
tabHaobanStaff
)
{
return
;
}
logDTO
.
setStaffId
(
tabHaobanStaff
.
getStaffId
());
haobanQywxFeeAccountInterceptLogService
.
insert
(
EntityUtil
.
changeEntityNew
(
TabHaobanQywxFeeAccountInterceptLog
.
class
,
logDTO
));
haobanQywxFeeAccountInterceptLogService
.
insert
(
EntityUtil
.
changeEntityNew
(
TabHaobanQywxFeeAccountInterceptLog
.
class
,
logDTO
));
}
@Override
public
HaobanQywxFeeDTO
queryByWxEnterpriseId
(
String
wxEnterpriseId
)
{
return
EntityUtil
.
changeEntityNew
(
HaobanQywxFeeDTO
.
class
,
haobanQywxFeeService
.
queryByWxEnterpriseId
(
wxEnterpriseId
));
return
EntityUtil
.
changeEntityNew
(
HaobanQywxFeeDTO
.
class
,
haobanQywxFeeService
.
queryByWxEnterpriseId
(
wxEnterpriseId
));
}
}
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