Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
customer-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SuperHive
back-end
customer-service
Commits
27e5c86a
Commit
27e5c86a
authored
Apr 18, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增接口:新增货主帐号
parent
f846009e
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
234 additions
and
8 deletions
+234
-8
ErrorMessageComponent.java
...ight/customer/common/component/ErrorMessageComponent.java
+23
-0
VerifyUtils.java
...ava/com/esv/freight/customer/common/util/VerifyUtils.java
+103
-0
GoodsOwnerConstants.java
...eight/customer/module/goodsowner/GoodsOwnerConstants.java
+13
-0
GoodsOwnerController.java
...er/module/goodsowner/controller/GoodsOwnerController.java
+6
-0
AccountEntity.java
...ight/customer/module/goodsowner/entity/AccountEntity.java
+2
-3
AccountInfoForm.java
...ight/customer/module/goodsowner/form/AccountInfoForm.java
+0
-1
AccountServiceImpl.java
...er/module/goodsowner/service/impl/AccountServiceImpl.java
+50
-3
application-dev.yml
src/main/resources/application-dev.yml
+6
-1
VerifyUtilsTest.java
...com/esv/freight/customer/common/util/VerifyUtilsTest.java
+31
-0
No files found.
src/main/java/com/esv/freight/customer/common/component/ErrorMessageComponent.java
0 → 100644
View file @
27e5c86a
package
com
.
esv
.
freight
.
customer
.
common
.
component
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cloud.context.config.annotation.RefreshScope
;
import
org.springframework.stereotype.Component
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.common.component.ErrorMessageComponent
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/18 10:04
* @version:1.0
*/
@Component
@RefreshScope
public
class
ErrorMessageComponent
{
@Value
(
"${error-message.goodsowner.account.add.1001}"
)
public
String
goodsOwnerAccountAdd1001
;
}
src/main/java/com/esv/freight/customer/common/util/VerifyUtils.java
0 → 100644
View file @
27e5c86a
package
com
.
esv
.
freight
.
customer
.
common
.
util
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
static
java
.
util
.
regex
.
Pattern
.*;
/**
* @description: 电话号码/身份证号码校验工具类
* @project: freight-customer-service
* @name: com.esv.freight.customer.common.util.VerifyUtils
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/18 11:13
* @version:1.0
*/
public
class
VerifyUtils
{
/**
* description 校验是否有效18位身份证号码
* param [idCard]
* return boolean
* author Administrator
* createTime 2020/04/18 11:18
**/
public
static
boolean
isValidIdCard18
(
String
idCard
)
{
Pattern
pattern1
=
compile
(
"^(\\d{6})(19|20)(\\d{2})(1[0-2]|0[1-9])(0[1-9]|[1-2][0-9]|3[0-1])(\\d{3})(\\d|X|x)?$"
);
Matcher
matcher
=
pattern1
.
matcher
(
idCard
);
int
[]
prefix
=
new
int
[]{
7
,
9
,
10
,
5
,
8
,
4
,
2
,
1
,
6
,
3
,
7
,
9
,
10
,
5
,
8
,
4
,
2
};
int
[]
suffix
=
new
int
[]{
1
,
0
,
10
,
9
,
8
,
7
,
6
,
5
,
4
,
3
,
2
};
if
(
matcher
.
matches
())
{
Map
<
String
,
String
>
cityMap
=
initCityMap
();
if
(
cityMap
.
get
(
idCard
.
substring
(
0
,
2
))
==
null
)
{
return
false
;
}
// 用来保存前17位各自乖以加权因子后的总和
int
idCardWiSum
=
0
;
for
(
int
i
=
0
;
i
<
17
;
i
++)
{
idCardWiSum
+=
Integer
.
valueOf
(
idCard
.
substring
(
i
,
i
+
1
))
*
prefix
[
i
];
}
// 计算出校验码所在数组的位置
int
idCardMod
=
idCardWiSum
%
11
;
// 得到最后一位身份证号码
String
idCardLast
=
idCard
.
substring
(
17
);
// 如果等于2,则说明校验码是10,身份证号码最后一位应该是X
if
(
idCardMod
==
2
)
{
if
(
idCardLast
.
equalsIgnoreCase
(
"x"
))
{
return
true
;
}
else
{
return
false
;
}
}
else
{
// 用计算出的验证码与最后一位身份证号码匹配,如果一致,说明通过,否则是无效的身份证号码
if
(
idCardLast
.
equals
(
suffix
[
idCardMod
]
+
""
))
{
return
true
;
}
else
{
return
false
;
}
}
}
return
false
;
}
private
static
Map
<
String
,
String
>
initCityMap
(){
Map
<
String
,
String
>
cityMap
=
new
HashMap
<>(
31
);
cityMap
.
put
(
"11"
,
"北京"
);
cityMap
.
put
(
"12"
,
"天津"
);
cityMap
.
put
(
"13"
,
"河北"
);
cityMap
.
put
(
"14"
,
"山西"
);
cityMap
.
put
(
"15"
,
"内蒙古"
);
cityMap
.
put
(
"21"
,
"辽宁"
);
cityMap
.
put
(
"22"
,
"吉林"
);
cityMap
.
put
(
"23"
,
"黑龙江"
);
cityMap
.
put
(
"31"
,
"上海"
);
cityMap
.
put
(
"32"
,
"江苏"
);
cityMap
.
put
(
"33"
,
"浙江"
);
cityMap
.
put
(
"34"
,
"安徽"
);
cityMap
.
put
(
"35"
,
"福建"
);
cityMap
.
put
(
"36"
,
"江西"
);
cityMap
.
put
(
"37"
,
"山东"
);
cityMap
.
put
(
"41"
,
"河南"
);
cityMap
.
put
(
"42"
,
"湖北"
);
cityMap
.
put
(
"43"
,
"湖南"
);
cityMap
.
put
(
"44"
,
"广东"
);
cityMap
.
put
(
"45"
,
"广西"
);
cityMap
.
put
(
"46"
,
"海南"
);
cityMap
.
put
(
"50"
,
"重庆"
);
cityMap
.
put
(
"51"
,
"四川"
);
cityMap
.
put
(
"52"
,
"贵州"
);
cityMap
.
put
(
"53"
,
"云南"
);
cityMap
.
put
(
"54"
,
"西藏"
);
cityMap
.
put
(
"61"
,
"陕西"
);
cityMap
.
put
(
"62"
,
"甘肃"
);
cityMap
.
put
(
"63"
,
"青海"
);
cityMap
.
put
(
"64"
,
"宁夏"
);
cityMap
.
put
(
"65"
,
"新疆"
);
return
cityMap
;
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/GoodsOwnerConstants.java
View file @
27e5c86a
...
...
@@ -17,4 +17,17 @@ public class GoodsOwnerConstants {
public
static
final
String
OWNER_TYPE_PERSONAL
=
"1"
;
public
static
final
String
OWNER_TYPE_COMPANY
=
"2"
;
/**
* 货主帐号创建来源:1-平台创建、2-自行注册
**/
public
static
final
String
OWNER_SOURCE_TYPE_PLATFORM
=
"1"
;
public
static
final
String
OWNER_SOURCE_TYPE_REGISTER
=
"2"
;
/**
* 货主帐号审核状态:0-待审核、1-审核成功,2-审核失败,APP自行注册需要平台审核
**/
public
static
final
Integer
OWNER_AUDIT_STATUS_UNAUDITED
=
0
;
public
static
final
Integer
OWNER_AUDIT_STATUS_SUCCESS
=
1
;
public
static
final
Integer
OWNER_AUDIT_STATUS_FAILURE
=
2
;
}
src/main/java/com/esv/freight/customer/module/goodsowner/controller/GoodsOwnerController.java
View file @
27e5c86a
...
...
@@ -2,8 +2,10 @@ package com.esv.freight.customer.module.goodsowner.controller;
import
com.alibaba.fastjson.JSONObject
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.response.ECode
;
import
com.esv.freight.customer.common.response.EResponse
;
import
com.esv.freight.customer.common.util.ReqUtils
;
import
com.esv.freight.customer.common.util.VerifyUtils
;
import
com.esv.freight.customer.common.validator.groups.ValidatorInsert
;
import
com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants
;
import
com.esv.freight.customer.module.goodsowner.form.AccountInfoForm
;
...
...
@@ -59,6 +61,10 @@ public class GoodsOwnerController {
String
[]
notBlankParams
=
new
String
[]
{
"ownerFullName"
,
"uniCreditCode"
,
"creditCopyUrl"
,
"legalPerson"
};
ReqUtils
.
checkParamsNotBlank
(
JSONObject
.
parseObject
(
form
.
toString
()),
notBlankParams
);
}
// 校验身份证号码
if
(!
VerifyUtils
.
isValidIdCard18
(
form
.
getIdCard
()))
{
throw
new
EException
(
ECode
.
PARAM_ERROR
.
code
(),
"无效的身份证号码"
);
}
/****************************** 参数校验 ******************************/
return
EResponse
.
ok
(
accountService
.
createAccountByManager
(
form
));
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/entity/AccountEntity.java
View file @
27e5c86a
...
...
@@ -57,10 +57,9 @@ public class AccountEntity implements Serializable {
*/
private
String
accountStatus
;
/**
* 审核状态:1-未审核、2-审核通过,3-审核不通过
APP自行注册需要平台审核
* 货主帐号审核状态:0-待审核、1-审核成功,2-审核失败,APP自行注册需要平台审核
*/
private
String
auditStatus
;
private
Integer
auditStatus
;
/**
* 上报状态:字典表
*/
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/form/AccountInfoForm.java
View file @
27e5c86a
...
...
@@ -21,7 +21,6 @@ import javax.validation.constraints.Pattern;
@Data
public
class
AccountInfoForm
{
private
Long
id
;
/**
* (个人或企业联系人手机号)帐号
*/
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/AccountServiceImpl.java
View file @
27e5c86a
...
...
@@ -3,27 +3,47 @@ package com.esv.freight.customer.module.goodsowner.service.impl;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.esv.freight.customer.common.component.ErrorMessageComponent
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.util.FeignUtils
;
import
com.esv.freight.customer.common.util.ReqUtils
;
import
com.esv.freight.customer.feign.FeignBaseService
;
import
com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants
;
import
com.esv.freight.customer.module.goodsowner.dao.AccountDao
;
import
com.esv.freight.customer.module.goodsowner.entity.AccountEntity
;
import
com.esv.freight.customer.module.goodsowner.entity.AuditHistoryEntity
;
import
com.esv.freight.customer.module.goodsowner.entity.InfoEntity
;
import
com.esv.freight.customer.module.goodsowner.form.AccountInfoForm
;
import
com.esv.freight.customer.module.goodsowner.service.AccountService
;
import
com.esv.freight.customer.module.goodsowner.service.AuditHistoryService
;
import
com.esv.freight.customer.module.goodsowner.service.InfoService
;
import
com.esv.gateway.common.GatewayHeaders
;
import
org.apache.commons.codec.digest.DigestUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.UUID
;
@Service
(
"accountService"
)
public
class
AccountServiceImpl
extends
ServiceImpl
<
AccountDao
,
AccountEntity
>
implements
AccountService
{
private
FeignBaseService
feignBaseService
;
private
ErrorMessageComponent
errorMessageComponent
;
private
InfoService
infoService
;
private
AuditHistoryService
auditHistoryService
;
@Autowired
public
AccountServiceImpl
(
FeignBaseService
feignBaseService
)
{
public
AccountServiceImpl
(
FeignBaseService
feignBaseService
,
ErrorMessageComponent
errorMessageComponent
,
InfoService
infoService
,
AuditHistoryService
auditHistoryService
)
{
this
.
feignBaseService
=
feignBaseService
;
this
.
errorMessageComponent
=
errorMessageComponent
;
this
.
infoService
=
infoService
;
this
.
auditHistoryService
=
auditHistoryService
;
}
@Override
...
...
@@ -40,7 +60,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
// 1.判断帐号是否已存在
AccountEntity
accountEntity
=
this
.
getAccountRecordByAccount
(
form
.
getAccount
());
if
(
null
!=
accountEntity
)
{
throw
new
EException
(
1001
,
"帐号已存在"
);
throw
new
EException
(
1001
,
errorMessageComponent
.
goodsOwnerAccountAdd1001
);
}
else
{
accountEntity
=
new
AccountEntity
();
}
...
...
@@ -60,13 +80,40 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
String
ownerNumber
=
batchIdResJson
.
getString
(
"batchId"
);
// 3.新增帐号
BeanUtils
.
copyProperties
(
form
,
accountEntity
);
String
salt
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
String
password
=
DigestUtils
.
md5Hex
(
form
.
getPassword
()
+
salt
);
accountEntity
.
setSalt
(
salt
);
accountEntity
.
setPassword
(
password
);
accountEntity
.
setSourceType
(
GoodsOwnerConstants
.
OWNER_SOURCE_TYPE_PLATFORM
);
accountEntity
.
setAuditStatus
(
GoodsOwnerConstants
.
OWNER_AUDIT_STATUS_SUCCESS
);
int
accountId
=
this
.
baseMapper
.
insert
(
accountEntity
);
// 4.新增帐号信息
InfoEntity
infoEntity
=
new
InfoEntity
();
BeanUtils
.
copyProperties
(
form
,
infoEntity
);
// 货主为个人
if
(
GoodsOwnerConstants
.
OWNER_TYPE_PERSONAL
.
equals
(
form
.
getOwnerType
()))
{
infoEntity
.
setOwnerFullName
(
null
);
infoEntity
.
setOwnerBriefName
(
null
);
infoEntity
.
setUniCreditCode
(
null
);
infoEntity
.
setCreditOriginalUrl
(
null
);
infoEntity
.
setCreditCopyUrl
(
null
);
infoEntity
.
setCreditExpireDate
(
null
);
infoEntity
.
setLegalPerson
(
null
);
infoEntity
.
setLegalPhone
(
null
);
}
infoEntity
.
setOwnerNumber
(
ownerNumber
);
infoEntity
.
setAccountId
(
Long
.
parseLong
(
String
.
valueOf
(
accountId
)));
infoService
.
getBaseMapper
().
insert
(
infoEntity
);
// 5.新增帐号审核记录
AuditHistoryEntity
auditHistoryEntity
=
new
AuditHistoryEntity
();
auditHistoryEntity
.
setAccountId
(
Long
.
parseLong
(
String
.
valueOf
(
accountId
)));
auditHistoryEntity
.
setAuditStatus
(
GoodsOwnerConstants
.
OWNER_AUDIT_STATUS_SUCCESS
);
auditHistoryEntity
.
setOperateUser
(
ReqUtils
.
getRequestHeader
(
GatewayHeaders
.
USER_ACCOUNT
));
auditHistoryService
.
getBaseMapper
().
insert
(
auditHistoryEntity
);
return
0
;
return
accountId
;
}
}
\ No newline at end of file
src/main/resources/application-dev.yml
View file @
27e5c86a
...
...
@@ -45,3 +45,8 @@ ribbon:
eager-load
:
enabled
:
true
clients
:
freight-base-service
error-message
:
goodsowner
:
account
:
add
:
1001
:
帐号已存在
\ No newline at end of file
src/test/java/com/esv/freight/customer/common/util/VerifyUtilsTest.java
0 → 100644
View file @
27e5c86a
package
com
.
esv
.
freight
.
customer
.
common
.
util
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.common.util.VerifyUtilsTest
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/18 11:23
* @version:1.0
*/
@SpringBootTest
@Slf4j
public
class
VerifyUtilsTest
{
@Test
public
void
isValidIdCard18_test
()
{
String
idCard
=
"360721198712030856"
;
log
.
info
(
"{}={}"
,
idCard
,
VerifyUtils
.
isValidIdCard18
(
idCard
));
idCard
=
"900721198712030856"
;
log
.
info
(
"{}={}"
,
idCard
,
VerifyUtils
.
isValidIdCard18
(
idCard
));
idCard
=
"36072119871203085x"
;
log
.
info
(
"{}={}"
,
idCard
,
VerifyUtils
.
isValidIdCard18
(
idCard
));
}
}
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