Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-enterprise
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
base_platform_enterprise
gic-platform-enterprise
Commits
5ba2da31
Commit
5ba2da31
authored
Mar 01, 2021
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解除联合发短信
parent
9249e78f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
3 deletions
+69
-3
UnionEnterpriseAuthApiServiceImpl.java
...e/outer/impl/union/UnionEnterpriseAuthApiServiceImpl.java
+69
-3
No files found.
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/impl/union/UnionEnterpriseAuthApiServiceImpl.java
View file @
5ba2da31
package
com
.
gic
.
enterprise
.
service
.
outer
.
impl
.
union
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -7,6 +8,8 @@ import java.util.stream.Collectors;
import
javax.validation.Valid
;
import
javax.validation.constraints.NotNull
;
import
com.alibaba.fastjson.JSON
;
import
com.gic.marketing.process.api.service.sms.SmsSendApiService
;
import
com.gic.member.config.api.service.AuthorizationEnterConfApiService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -70,6 +73,17 @@ public class UnionEnterpriseAuthApiServiceImpl implements UnionEnterpriseAuthApi
private
StoreAuthorizationApiService
storeAuthorizationApiService
;
@Autowired
private
AuthorizationEnterConfApiService
authorizationEnterConfApiService
;
@Autowired
private
SmsSendApiService
smsSendApiService
;
/**
* 待解除中短信模板
*/
private
static
String
SMS_CODE_RELIEVE
=
"GICSHHT009"
;
/**
* 解除成功短信模板
*/
private
static
String
SMS_CODE_RELIEVED
=
"GICSHHT010"
;
@Override
public
ServiceResponse
<
Void
>
saveUnionEnterprise
(
Integer
ownEnterpriseId
,
Integer
unionEnterpriseId
)
{
...
...
@@ -360,20 +374,52 @@ public class UnionEnterpriseAuthApiServiceImpl implements UnionEnterpriseAuthApi
public
ServiceResponse
<
Void
>
relieveTask
(
String
param
)
{
List
<
TabSysUnionEnterpriseAuth
>
list
=
unionEnterpriseAuthService
.
listAll
();
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
List
<
EnterpriseDTO
>
enterpriseList
=
enterpriseService
.
listEnterprise
();
Map
<
String
,
String
>
enterpriseMap
=
enterpriseList
.
stream
().
collect
(
Collectors
.
toMap
(
e
->
e
.
getEnterpriseId
().
toString
(),
e
->
e
.
getEnterpriseName
()));
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
for
(
TabSysUnionEnterpriseAuth
temp
:
list
)
{
if
(
temp
.
getRelieveTime
()
!=
null
&&
temp
.
getRelieveEffectDate
()
!=
null
)
{
//待解除状态会进行轮训
if
(
temp
.
getRelieveTime
()
!=
null
&&
temp
.
getRelieveEffectDate
()
!=
null
&&
UnionEnterpriseAuthStatusEnum
.
TO_DO_RELIEVE
.
getCode
().
equals
(
temp
.
getStatusFlag
()))
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
temp
.
getRelieveTime
());
calendar
.
add
(
Calendar
.
DAY_OF_YEAR
,
temp
.
getRelieveEffectDate
());
//如果到达解除时间,发通知
if
(
sdf
.
format
(
calendar
.
getTime
()).
compareTo
(
sdf
.
format
(
new
Date
()))
>=
0
)
{
String
[]
smsArr
;
//如果到达解除时间,发通知 boolean hasDate = sdf.format(calendar.getTime()).compareTo(sdf.format(new Date())) >= 0;
int
days
=
differentDaysByMillisecond
(
calendar
.
getTime
(),
new
Date
());
if
(
days
==
0
)
{
smsArr
=
new
String
[]
{
enterpriseMap
.
get
(
temp
.
getUnionEnterpriseId
()),
enterpriseMap
.
get
(
temp
.
getOwnEnterpriseId
()),
enterpriseMap
.
get
(
temp
.
getOwnEnterpriseId
())};
if
(
UnionEnterpriseAuthStatusEnum
.
TO_DO_RELIEVE
.
getCode
().
equals
(
temp
.
getStatusFlag
()))
{
//todo 发通知
//门店解除
storeAuthorizationApiService
.
cancelStoreAll
(
temp
.
getUnionEnterpriseId
(),
temp
.
getOwnEnterpriseId
());
authorizationEnterConfApiService
.
delAuthorizationEnterpriseConf
(
temp
.
getUnionEnterpriseAuthId
(),
temp
.
getOwnEnterpriseId
());
}
}
else
{
//发送短信模板
smsArr
=
new
String
[]
{
enterpriseMap
.
get
(
temp
.
getUnionEnterpriseId
()),
enterpriseMap
.
get
(
temp
.
getOwnEnterpriseId
()),
String
.
valueOf
(
days
),
sdf
.
format
(
calendar
.
getTime
()),
enterpriseMap
.
get
(
temp
.
getOwnEnterpriseId
())};
}
ServiceResponse
<
UserDTO
>
userResponse
=
userApiService
.
getUserByEnterpriseId
(
temp
.
getUnionEnterpriseId
());
//发送手机验证码
ServiceResponse
<
Void
>
smsSendResult
=
smsSendApiService
.
sendPlatformSms
(
days
==
0
?
SMS_CODE_RELIEVED
:
SMS_CODE_RELIEVE
,
temp
.
getUnionEnterpriseId
(),
userResponse
.
getResult
().
getPhoneAreaCode
(),
userResponse
.
getResult
().
getPhoneNumber
(),
smsArr
);
if
(!
smsSendResult
.
isSuccess
())
{
LOGGER
.
warn
(
"解除联合发送短信错误信息:{}"
,
JSON
.
toJSONString
(
smsSendResult
));
}
}
}
...
...
@@ -476,4 +522,24 @@ public class UnionEnterpriseAuthApiServiceImpl implements UnionEnterpriseAuthApi
return
resourceResponse
.
getResult
();
}
/**
* 通过时间秒毫秒数判断两个时间的间隔
* @param date1
* @param date2
* @return
*/
private
static
int
differentDaysByMillisecond
(
Date
date1
,
Date
date2
)
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
long
startDateTime
=
0
;
long
endDateTime
=
0
;
try
{
startDateTime
=
dateFormat
.
parse
(
dateFormat
.
format
(
date1
)).
getTime
();
endDateTime
=
dateFormat
.
parse
(
dateFormat
.
format
(
date2
)).
getTime
();
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
(
int
)
((
endDateTime
-
startDateTime
)
/
(
1000
*
3600
*
24
));
}
}
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