Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
extend
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
park
extend
Commits
5554c9b6
Commit
5554c9b6
authored
Jun 24, 2020
by
xieshixiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加提示
parent
42af403e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
37 deletions
+40
-37
domain/src/main/java/com/hikcreate/edl/pub/web/mobile/domain/IBindService.java
+5
-5
domain/src/main/java/com/hikcreate/edl/pub/web/mobile/domain/impl/BindServiceImpl.java
+31
-32
infra/src/main/java/com/hikcreate/edl/pub/web/mobile/infra/core/Result/ResultGenerator.java
+4
-0
No files found.
domain/src/main/java/com/hikcreate/edl/pub/web/mobile/domain/IBindService.java
View file @
5554c9b6
...
...
@@ -29,14 +29,14 @@ public interface IBindService extends IService<ParkBindInfo> {
* @author: xsx
* @date: 2020/6/19 10:32
*/
Res
ponse
bind
(
ParkBindInfo
info
);
Res
ult
bind
(
ParkBindInfo
info
);
/**
* 信息解绑
* @param req
* @return
*/
Res
ponse
unbindInfo
(
UnBindReq
req
);
Res
ult
unbindInfo
(
UnBindReq
req
);
/**
* 查询用户绑定信息
...
...
@@ -51,7 +51,7 @@ public interface IBindService extends IService<ParkBindInfo> {
* @param query
* @return
*/
Res
ponse
yearCheckInfo
(
H5BindInfoQuery
query
);
Res
ult
yearCheckInfo
(
H5BindInfoQuery
query
);
/**
* 保险信息查询接口
...
...
@@ -68,7 +68,7 @@ public interface IBindService extends IService<ParkBindInfo> {
* @author: xsx
* @date: 2020/6/19 16:06
*/
Res
ponse
violationInfo
(
H5BindInfoQuery
query
);
Res
ult
violationInfo
(
H5BindInfoQuery
query
);
/**
* 驾照信息查询接口
...
...
@@ -78,6 +78,6 @@ public interface IBindService extends IService<ParkBindInfo> {
* @author: xsx
* @date: 2020/6/19 16:29
*/
Res
ponse
<
DrivingLicenseInfoRes
>
drivingLicenseInfo
(
H5BindInfoQuery
query
);
Res
ult
<
DrivingLicenseInfoRes
>
drivingLicenseInfo
(
H5BindInfoQuery
query
);
}
domain/src/main/java/com/hikcreate/edl/pub/web/mobile/domain/impl/BindServiceImpl.java
View file @
5554c9b6
...
...
@@ -5,9 +5,6 @@ import cn.hutool.core.date.DateUtil;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.hikcreate.common.sdk.response.apiparam.Response
;
import
com.hikcreate.common.sdk.response.apiparam.ResponseGenerator
;
import
com.hikcreate.common.sdk.response.statuscode.StatusCode
;
import
com.hikcreate.edl.common.distributed.lock.annotation.DistributedLock
;
import
com.hikcreate.edl.pub.web.mobile.domain.IBindService
;
import
com.hikcreate.edl.pub.web.mobile.infra.core.Result.Result
;
...
...
@@ -92,15 +89,16 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@DistributedLock
(
key
=
"'park:extend:lock:bind:userId:'+#info.userId+':timestamp:'+#info.timestamp"
,
expireTime
=
3000
,
waitTime
=
2000
,
retryTimes
=
50
)
public
Response
bind
(
ParkBindInfo
info
)
{
@DistributedLock
(
key
=
"'park:extend:lock:bind:userId:'+#info.userId+':timestamp:'+#info.timestamp"
,
expireTime
=
3000
,
waitTime
=
2000
,
retryTimes
=
50
)
public
Result
bind
(
ParkBindInfo
info
)
{
//判断规则1:用户已绑定的车辆不超过3辆,包括已解绑但未过一个月的车辆
QueryWrapper
<
ParkBindInfo
>
boundQuery
=
new
QueryWrapper
();
boundQuery
.
eq
(
"user_id"
,
info
.
getUserId
());
boundQuery
.
eq
(
"status"
,
"1"
);
List
<
ParkBindInfo
>
list
=
mapper
.
selectList
(
boundQuery
);
if
(
list
!=
null
&&
list
.
size
()
>=
3
)
{
return
Res
ponseGenerator
.
fail
(
StatusCode
.
BUSINESS_ERROR
,
"同一用户下,最多绑定3辆车"
);
return
Res
ultGenerator
.
fail
(
ResultCode
.
BIND_NUM_ERROR
);
}
/**
* 规则:30天内,同一客户解绑超过10次不能再进行绑定
...
...
@@ -111,14 +109,14 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
unbindQuery
.
eq
(
"status"
,
"0"
);
Integer
integer
=
mapper
.
selectCount
(
unbindQuery
);
if
(
integer
>=
unBindCount
)
{
return
Res
ponseGenerator
.
fail
(
StatusCode
.
BUSINESS_ERROR
,
StrUtil
.
format
(
"{}天内,同一用户解绑超过{}次不能再进行绑定"
,
unBindTime
/
24
,
unBindCount
));
return
Res
ultGenerator
.
fail
(
StrUtil
.
format
(
"{}天内,同一用户解绑超过{}次不能再进行绑定"
,
unBindTime
/
24
,
unBindCount
));
}
//规则:一个客户只能绑定一个电话号码
if
(
list
!=
null
&&
!
list
.
isEmpty
())
{
boolean
equals
=
list
.
get
(
0
).
getPhone
().
equals
(
info
.
getPhone
());
if
(!
equals
)
{
return
Res
ponseGenerator
.
fail
(
StatusCode
.
BUSINESS_ERROR
,
"当前客户手机号与历史绑定手机号不一致"
);
return
Res
ultGenerator
.
fail
(
"当前客户手机号与历史绑定手机号不一致"
);
}
}
...
...
@@ -130,7 +128,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
if
(
phones
!=
null
&&
!
phones
.
isEmpty
())
{
boolean
phoneExist
=
phones
.
get
(
0
).
getUserId
().
equals
(
info
.
getUserId
());
if
(!
phoneExist
)
{
return
Res
ponseGenerator
.
fail
(
StatusCode
.
BUSINESS_ERROR
,
"当前手机号已被其他客户绑定"
);
return
Res
ultGenerator
.
fail
(
"当前手机号已被其他客户绑定"
);
}
}
...
...
@@ -140,7 +138,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
req
.
setPlateNum
(
info
.
getPlateNum
());
List
<
VehicleRes
>
byPlateNum
=
vechicleCache
.
getByPlateNum
(
req
);
if
(
byPlateNum
==
null
||
byPlateNum
.
size
()
==
0
)
{
return
Res
ponseGenerator
.
fail
(
StatusCode
.
DATA_ERROR
,
"车辆信息不存在"
);
return
Res
ultGenerator
.
fail
(
ResultCode
.
CAR_MESSAGE_UNKNOWN
);
}
for
(
VehicleRes
res
:
byPlateNum
)
{
...
...
@@ -149,7 +147,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
}
}
if
(
info
.
getPlateType
()
==
null
||
""
.
equals
(
info
.
getPlateType
()))
{
return
Res
ponseGenerator
.
fail
(
StatusCode
.
DATA_ERROR
,
"当前手机号,与车辆备案手机号不一致"
);
return
Res
ultGenerator
.
fail
(
ResultCode
.
CAR_PHONE_UNMATCHED
);
}
//规则3:判断当前车牌号是否已绑定
...
...
@@ -159,14 +157,14 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
queryWrapper
.
eq
(
"status"
,
"1"
);
ParkBindInfo
bindExist
=
mapper
.
selectOne
(
queryWrapper
);
if
(
bindExist
!=
null
)
{
return
Res
ponseGenerator
.
fail
(
StatusCode
.
DATA_ERROR
,
"此车牌号已绑定"
);
return
Res
ultGenerator
.
fail
(
ResultCode
.
CAR_HAVE_BIND
);
}
info
.
setUnqId
(
unqIdUtil
.
getUnqId
());
info
.
setGmtBindTime
(
new
Date
());
bindCache
.
insert
(
info
);
return
Res
ponse
Generator
.
success
(
new
BindInfoRes
(
info
.
getUnqId
()));
return
Res
ult
Generator
.
success
(
new
BindInfoRes
(
info
.
getUnqId
()));
}
/**
...
...
@@ -177,19 +175,20 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@DistributedLock
(
key
=
"'park:extend:lock:unbind:unqId:'+#req.unqId+':userId:'+#req.userId+':timestamp:'+#req.timestamp"
,
expireTime
=
3000
,
waitTime
=
2000
,
retryTimes
=
50
)
public
Response
unbindInfo
(
UnBindReq
req
)
{
@DistributedLock
(
key
=
"'park:extend:lock:unbind:unqId:'+#req.unqId+':userId:'+#req.userId+':timestamp:'+#req"
+
".timestamp"
,
expireTime
=
3000
,
waitTime
=
2000
,
retryTimes
=
50
)
public
Result
unbindInfo
(
UnBindReq
req
)
{
ParkBindInfo
bindInfo
=
bindCache
.
getById
(
req
.
getUnqId
());
if
(
bindInfo
==
null
||
"0"
.
equals
(
bindInfo
.
getStatus
()))
{
return
Res
ponseGenerator
.
fail
(
StatusCode
.
DATA_ERROR
,
"绑定信息不存在"
);
return
Res
ultGenerator
.
fail
(
ResultCode
.
BIND_INFO_UNKNOWN
);
}
if
(!
bindCache
.
unBind
(
req
.
getUnqId
(),
req
.
getUserId
()))
{
//手动回滚
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
Res
ponseGenerator
.
fail
(
StatusCode
.
SYSTEM_ERROR
,
"解绑失败"
);
return
Res
ultGenerator
.
fail
(
"解绑失败"
);
}
return
Res
ponse
Generator
.
success
();
return
Res
ult
Generator
.
success
();
}
/**
...
...
@@ -217,17 +216,17 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
}
@Override
public
Res
ponse
<
YearCheckInfoRes
>
yearCheckInfo
(
H5BindInfoQuery
query
)
{
public
Res
ult
<
YearCheckInfoRes
>
yearCheckInfo
(
H5BindInfoQuery
query
)
{
ParkBindInfo
bindInfo
=
bindCache
.
getById
(
query
.
getUnqId
());
if
(
bindInfo
==
null
||
"0"
.
equals
(
bindInfo
.
getStatus
()))
{
return
Res
ponseGenerator
.
fail
(
StatusCode
.
DATA_ERROR
,
"绑定信息不存在"
);
return
Res
ultGenerator
.
fail
(
ResultCode
.
BIND_INFO_UNKNOWN
);
}
PlateNumAndTypeQueryReq
req
=
new
PlateNumAndTypeQueryReq
();
req
.
setPlateNum
(
bindInfo
.
getPlateNum
());
req
.
setPlateType
(
bindInfo
.
getPlateType
());
VehicleRes
vehicleRes
=
vechicleCache
.
getByPlateNumAndType
(
req
);
if
(
Objects
.
isNull
(
vehicleRes
))
{
return
Res
ponse
Generator
.
success
();
return
Res
ult
Generator
.
success
();
}
YearCheckInfoRes
yearCheckInfoRes
=
new
YearCheckInfoRes
();
yearCheckInfoRes
.
setPlateNum
(
bindInfo
.
getPlateNum
());
...
...
@@ -240,11 +239,11 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
yearCheckInfoRes
.
setStatus
(
"已到期"
);
}
}
return
Res
ponse
Generator
.
success
(
yearCheckInfoRes
);
return
Res
ult
Generator
.
success
(
yearCheckInfoRes
);
}
@Override
public
Result
<
InsuranceInfoRes
>
insuranceInfo
(
H5BindInfoQuery
query
)
{
public
Result
<
InsuranceInfoRes
>
insuranceInfo
(
H5BindInfoQuery
query
)
{
ParkBindInfo
bindInfo
=
bindCache
.
getById
(
query
.
getUnqId
());
if
(
bindInfo
==
null
||
"0"
.
equals
(
bindInfo
.
getStatus
()))
{
return
ResultGenerator
.
fail
(
ResultCode
.
BIND_INFO_UNKNOWN
);
...
...
@@ -279,13 +278,13 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
@Override
public
Res
ponse
<
ResultList
<
ViolationInfoRes
>>
violationInfo
(
H5BindInfoQuery
query
)
{
public
Res
ult
<
ResultList
<
ViolationInfoRes
>>
violationInfo
(
H5BindInfoQuery
query
)
{
/**
* 校验当前的绑定信息是否存在
*/
ParkBindInfo
bindInfo
=
bindCache
.
getById
(
query
.
getUnqId
());
if
(
bindInfo
==
null
||
"0"
.
equals
(
bindInfo
.
getStatus
()))
{
return
Res
ponseGenerator
.
fail
(
StatusCode
.
DATA_ERROR
,
"绑定信息不存在"
);
return
Res
ultGenerator
.
fail
(
ResultCode
.
BIND_INFO_UNKNOWN
);
}
/**
...
...
@@ -312,17 +311,17 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
info
.
setTime
(
res
.
getDate
());
violationInfoResList
.
add
(
info
);
}
return
Res
ponse
Generator
.
success
(
new
ResultList
<>(
violationInfoResList
));
return
Res
ult
Generator
.
success
(
new
ResultList
<>(
violationInfoResList
));
}
@Override
public
Res
ponse
<
DrivingLicenseInfoRes
>
drivingLicenseInfo
(
H5BindInfoQuery
query
)
{
public
Res
ult
<
DrivingLicenseInfoRes
>
drivingLicenseInfo
(
H5BindInfoQuery
query
)
{
/**
* 校验当前的绑定信息是否存在
*/
ParkBindInfo
bindInfo
=
bindCache
.
getById
(
query
.
getUnqId
());
if
(
bindInfo
==
null
||
"0"
.
equals
(
bindInfo
.
getStatus
()))
{
return
Res
ponseGenerator
.
fail
(
StatusCode
.
DATA_ERROR
,
"绑定信息不存在"
);
return
Res
ultGenerator
.
fail
(
ResultCode
.
BIND_INFO_UNKNOWN
);
}
/**
...
...
@@ -331,7 +330,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
ParkVerifyInfo
verify
=
verifyInfo
.
checkValidity
(
query
.
getPhone
(),
query
.
getUserId
(),
DateUtil
.
offsetDay
(
DateTime
.
now
(),
-
1
));
if
(
verify
==
null
)
{
return
Res
ponseGenerator
.
fail
(
Status
Code
.
PERMISSION_DENIED
);
return
Res
ultGenerator
.
fail
(
Result
Code
.
PERMISSION_DENIED
);
}
/**
...
...
@@ -342,7 +341,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
vechicleInfoReq
.
setPlateNum
(
bindInfo
.
getPlateNum
());
VehicleRes
byPlateNumAndType
=
vechicleCache
.
getByPlateNumAndType
(
vechicleInfoReq
);
if
(
byPlateNumAndType
.
getSfzmhm
()
==
null
)
{
return
Res
ponseGenerator
.
fail
(
StatusCode
.
ALERT_ERROR
,
"车主身份证信息不存在"
);
return
Res
ultGenerator
.
fail
(
ResultCode
.
DRIVING_LICENSE_UNKNOWN
);
}
/**
...
...
@@ -352,7 +351,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
idCardQueryReq
.
setIdCard
(
byPlateNumAndType
.
getSfzmhm
());
DrivingLicenseRes
drivingLicenseRes
=
drivingLicenseCache
.
getByIdCard
(
idCardQueryReq
);
if
(
drivingLicenseRes
==
null
)
{
return
Res
ponseGenerator
.
fail
(
StatusCode
.
ALERT_ERROR
,
"车主驾照信息不存在"
);
return
Res
ultGenerator
.
fail
(
ResultCode
.
DRIVING_LICENSE_UNKNOWN
);
}
/**
...
...
@@ -369,7 +368,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
result
.
setStatus
(
status
);
result
.
setSurplusGrade
(
String
.
valueOf
(
12
-
Integer
.
parseInt
(
drivingLicenseRes
.
getLjjf
())));
return
Res
ponse
Generator
.
success
(
result
);
return
Res
ult
Generator
.
success
(
result
);
}
...
...
infra/src/main/java/com/hikcreate/edl/pub/web/mobile/infra/core/Result/ResultGenerator.java
View file @
5554c9b6
...
...
@@ -2,6 +2,9 @@ package com.hikcreate.edl.pub.web.mobile.infra.core.Result;
import
com.hikcreate.common.sdk.response.statuscode.StatusCode
;
/**
*
*/
public
class
ResultGenerator
{
public
static
<
T
>
Result
<
T
>
success
()
{
...
...
@@ -43,6 +46,7 @@ public class ResultGenerator {
return
result
;
}
public
static
<
T
>
Result
<
T
>
fail
(
long
code
,
String
msg
)
{
Result
<
T
>
result
=
new
Result
<>();
result
.
setSuccess
(
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