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
40c55000
Commit
40c55000
authored
May 08, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
货主接口:优化发货地址、收货地址列表功能
parent
2299e8be
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
827 additions
and
35 deletions
+827
-35
BaseDataComponent.java
.../freight/customer/common/component/BaseDataComponent.java
+61
-0
RedisComponent.java
...esv/freight/customer/common/component/RedisComponent.java
+518
-0
CacheConfig.java
...ain/java/com/esv/freight/customer/config/CacheConfig.java
+153
-0
FeignBaseService.java
...java/com/esv/freight/customer/feign/FeignBaseService.java
+10
-0
AccountServiceImpl.java
...er/module/goodsowner/service/impl/AccountServiceImpl.java
+31
-3
DeliveryAddressServiceImpl.java
...e/goodsowner/service/impl/DeliveryAddressServiceImpl.java
+12
-1
ReceiveAddressServiceImpl.java
...le/goodsowner/service/impl/ReceiveAddressServiceImpl.java
+12
-1
DeliveryAddressListVO.java
.../customer/module/goodsowner/vo/DeliveryAddressListVO.java
+2
-14
ReceiveAddressListVO.java
...t/customer/module/goodsowner/vo/ReceiveAddressListVO.java
+2
-14
application-dev.yml
src/main/resources/application-dev.yml
+12
-0
application-test.yml
src/main/resources/application-test.yml
+12
-0
bootstrap.yml
src/main/resources/bootstrap.yml
+2
-2
No files found.
src/main/java/com/esv/freight/customer/common/component/BaseDataComponent.java
0 → 100644
View file @
40c55000
package
com
.
esv
.
freight
.
customer
.
common
.
component
;
import
com.alibaba.fastjson.JSONObject
;
import
com.esv.freight.customer.common.response.ECode
;
import
com.esv.freight.customer.feign.FeignBaseService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* @description: 基础数据组件
* @project: freight-customer-service
* @name: com.esv.freight.customer.common.component.BaseDataComponent
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/08 15:57
* @version:1.0
*/
@Component
@Slf4j
public
class
BaseDataComponent
{
private
FeignBaseService
feignBaseService
;
private
RedisComponent
redisComponent
;
public
static
final
String
ALL_REGION_MAP_CACHE_KEY
=
"freight-customer-service::base-data::city::allMap"
;
public
static
final
Long
ALL_REGION_MAP_CACHE_TIME
=
36000L
;
@Autowired
public
BaseDataComponent
(
FeignBaseService
feignBaseService
,
RedisComponent
redisComponent
)
{
this
.
feignBaseService
=
feignBaseService
;
this
.
redisComponent
=
redisComponent
;
}
/**
* description 获取全国省市行政区划(键值对)
* param []
* return com.alibaba.fastjson.JSONObject
* author Administrator
* createTime 2020/05/08 16:10
**/
public
JSONObject
getAllRegionMap
()
{
JSONObject
allRegionMap
=
new
JSONObject
();
if
(
redisComponent
.
hasKey
(
ALL_REGION_MAP_CACHE_KEY
))
{
allRegionMap
=
JSONObject
.
parseObject
((
String
)
redisComponent
.
get
(
ALL_REGION_MAP_CACHE_KEY
));
}
else
{
try
{
JSONObject
feignResultJson
=
feignBaseService
.
getAllRegionMap
(
new
JSONObject
());
if
(
ECode
.
SUCCESS
.
code
()
==
feignResultJson
.
getIntValue
(
"code"
))
{
allRegionMap
=
feignResultJson
.
getJSONObject
(
"data"
);
redisComponent
.
set
(
ALL_REGION_MAP_CACHE_KEY
,
allRegionMap
.
toJSONString
(),
ALL_REGION_MAP_CACHE_TIME
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"调用[基础服务]获取全国省市行政区划(键值对)失败:"
+
e
.
getMessage
());
}
}
return
allRegionMap
;
}
}
src/main/java/com/esv/freight/customer/common/component/RedisComponent.java
0 → 100644
View file @
40c55000
package
com
.
esv
.
freight
.
customer
.
common
.
component
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
/**
* @description: RedisTemplate封装组件
* @project: freight-customer-service
* @name: com.esv.freight.customer.common.component.RedisComponent
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/08 15:52
* @version:1.0
*/
@Component
@Slf4j
public
class
RedisComponent
{
private
RedisTemplate
<
String
,
Object
>
redisTemplate
;
@Autowired
public
RedisComponent
(
RedisTemplate
<
String
,
Object
>
redisTemplate
)
{
this
.
redisTemplate
=
redisTemplate
;
}
/**
* 指定缓存失效时间
*
* @param key 键
* @param time 时间(秒)
* @return
*/
public
boolean
expire
(
String
key
,
long
time
)
{
if
(
0L
>=
time
)
{
return
false
;
}
try
{
redisTemplate
.
expire
(
key
,
time
,
TimeUnit
.
SECONDS
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 根据key 获取过期时间
*
* @param key 键 不能为null
* @return 时间(秒) 返回0代表为永久有效
*/
public
long
getExpire
(
String
key
)
{
return
redisTemplate
.
getExpire
(
key
,
TimeUnit
.
SECONDS
);
}
/**
* 判断key是否存在
*
* @param key 键
* @return true 存在 false不存在
*/
public
boolean
hasKey
(
String
key
)
{
try
{
return
redisTemplate
.
hasKey
(
key
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 删除缓存
*
* @param key 可以传一个值 或多个
*/
@SuppressWarnings
(
"unchecked"
)
public
void
del
(
String
...
key
)
{
if
(
key
!=
null
&&
key
.
length
>
0
)
{
if
(
key
.
length
==
1
)
{
redisTemplate
.
delete
(
key
[
0
]);
}
else
{
redisTemplate
.
delete
(
CollectionUtils
.
arrayToList
(
key
));
}
}
}
//================================String=================================
/**
* 普通缓存获取
*
* @param key 键
* @return 值
*/
public
Object
get
(
String
key
)
{
return
key
==
null
?
null
:
redisTemplate
.
opsForValue
().
get
(
key
);
}
/**
* 普通缓存放入并设置时间
*
* @param key 键
* @param value 值
* @param time 时间(秒) time要大于0
* @return true成功 false 失败
*/
public
boolean
set
(
String
key
,
Object
value
,
long
time
)
{
try
{
if
(
time
>
0
)
{
redisTemplate
.
opsForValue
().
set
(
key
,
value
,
time
,
TimeUnit
.
SECONDS
);
return
true
;
}
else
{
return
false
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 递增
*
* @param key 键
* @param delta 要增加几(大于0)
* @return
*/
public
long
incr
(
String
key
,
long
delta
)
{
if
(
delta
<
0
)
{
throw
new
RuntimeException
(
"递增因子必须大于0"
);
}
return
redisTemplate
.
opsForValue
().
increment
(
key
,
delta
);
}
/**
* 递减
*
* @param key 键
* @param delta 要减少几(小于0)
* @return
*/
public
long
decr
(
String
key
,
long
delta
)
{
if
(
delta
<
0
)
{
throw
new
RuntimeException
(
"递减因子必须大于0"
);
}
return
redisTemplate
.
opsForValue
().
increment
(
key
,
-
delta
);
}
//================================Map=================================
/**
* HashGet
*
* @param key 键 不能为null
* @param item 项 不能为null
* @return 值
*/
public
Object
hget
(
String
key
,
String
item
)
{
return
redisTemplate
.
opsForHash
().
get
(
key
,
item
);
}
/**
* 获取hashKey对应的所有键值
*
* @param key 键
* @return 对应的多个键值
*/
public
Map
<
Object
,
Object
>
hmget
(
String
key
)
{
return
redisTemplate
.
opsForHash
().
entries
(
key
);
}
/**
* HashSet 并设置时间
*
* @param key 键
* @param map 对应多个键值
* @param time 时间(秒)
* @return true成功 false失败
*/
public
boolean
hmset
(
String
key
,
Map
<
String
,
Object
>
map
,
long
time
)
{
if
(
0L
>=
time
)
{
return
false
;
}
try
{
redisTemplate
.
opsForHash
().
putAll
(
key
,
map
);
expire
(
key
,
time
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 向一张hash表中放入数据,如果不存在将创建
*
* @param key 键
* @param item 项
* @param value 值
* @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
* @return true 成功 false失败
*/
public
boolean
hset
(
String
key
,
String
item
,
Object
value
,
long
time
)
{
if
(
0L
>=
time
)
{
return
false
;
}
try
{
redisTemplate
.
opsForHash
().
put
(
key
,
item
,
value
);
expire
(
key
,
time
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 删除hash表中的值
*
* @param key 键 不能为null
* @param item 项 可以使多个 不能为null
*/
public
void
hdel
(
String
key
,
Object
...
item
)
{
redisTemplate
.
opsForHash
().
delete
(
key
,
item
);
}
/**
* 判断hash表中是否有该项的值
*
* @param key 键 不能为null
* @param item 项 不能为null
* @return true 存在 false不存在
*/
public
boolean
hHasKey
(
String
key
,
String
item
)
{
return
redisTemplate
.
opsForHash
().
hasKey
(
key
,
item
);
}
/**
* hash递增 如果不存在,就会创建一个 并把新增后的值返回
*
* @param key 键
* @param item 项
* @param by 要增加几(大于0)
* @return
*/
public
double
hincr
(
String
key
,
String
item
,
double
by
)
{
return
redisTemplate
.
opsForHash
().
increment
(
key
,
item
,
by
);
}
/**
* hash递减
*
* @param key 键
* @param item 项
* @param by 要减少记(小于0)
* @return
*/
public
double
hdecr
(
String
key
,
String
item
,
double
by
)
{
return
redisTemplate
.
opsForHash
().
increment
(
key
,
item
,
-
by
);
}
//============================set=============================
/**
* 根据key获取Set中的所有值
*
* @param key 键
* @return
*/
public
Set
<
Object
>
sGet
(
String
key
)
{
try
{
return
redisTemplate
.
opsForSet
().
members
(
key
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
null
;
}
}
/**
* 根据value从一个set中查询,是否存在
*
* @param key 键
* @param value 值
* @return true 存在 false不存在
*/
public
boolean
sHasKey
(
String
key
,
Object
value
)
{
try
{
return
redisTemplate
.
opsForSet
().
isMember
(
key
,
value
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 将数据放入set缓存
*
* @param key 键
* @param values 值 可以是多个
* @return 成功个数
*/
public
long
sSet
(
String
key
,
Object
...
values
)
{
try
{
return
redisTemplate
.
opsForSet
().
add
(
key
,
values
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
0
;
}
}
/**
* 将set数据放入缓存
*
* @param key 键
* @param time 时间(秒)
* @param values 值 可以是多个
* @return 成功个数
*/
public
long
sSetAndTime
(
String
key
,
long
time
,
Object
...
values
)
{
if
(
0L
>=
time
)
{
return
0L
;
}
try
{
Long
count
=
redisTemplate
.
opsForSet
().
add
(
key
,
values
);
expire
(
key
,
time
);
return
count
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
0
;
}
}
/**
* 获取set缓存的长度
*
* @param key 键
* @return
*/
public
long
sGetSetSize
(
String
key
)
{
try
{
return
redisTemplate
.
opsForSet
().
size
(
key
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
0
;
}
}
/**
* 移除值为value的
*
* @param key 键
* @param values 值 可以是多个
* @return 移除的个数
*/
public
long
setRemove
(
String
key
,
Object
...
values
)
{
try
{
Long
count
=
redisTemplate
.
opsForSet
().
remove
(
key
,
values
);
return
count
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
0
;
}
}
//===============================list=================================
/**
* 获取list缓存的内容
*
* @param key 键
* @param start 开始
* @param end 结束 0 到 -1代表所有值
* @return
*/
public
List
<
Object
>
lGet
(
String
key
,
long
start
,
long
end
)
{
try
{
return
redisTemplate
.
opsForList
().
range
(
key
,
start
,
end
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
null
;
}
}
/**
* 获取list缓存的长度
*
* @param key 键
* @return
*/
public
long
lGetListSize
(
String
key
)
{
try
{
return
redisTemplate
.
opsForList
().
size
(
key
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
0
;
}
}
/**
* 通过索引 获取list中的值
*
* @param key 键
* @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推
* @return
*/
public
Object
lGetIndex
(
String
key
,
long
index
)
{
try
{
return
redisTemplate
.
opsForList
().
index
(
key
,
index
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
null
;
}
}
/**
* 将list放入缓存
*
* @param key 键
* @param value 值
* @param time 时间(秒)
* @return
*/
public
boolean
lSet
(
String
key
,
Object
value
,
long
time
)
{
if
(
0L
>=
time
)
{
return
false
;
}
try
{
redisTemplate
.
opsForList
().
rightPush
(
key
,
value
);
expire
(
key
,
time
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 将list放入缓存
*
* @param key 键
* @param value 值
* @return
*/
public
boolean
lSet
(
String
key
,
List
<
Object
>
value
)
{
try
{
redisTemplate
.
opsForList
().
rightPushAll
(
key
,
value
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 将list放入缓存
*
* @param key 键
* @param value 值
* @param time 时间(秒)
* @return
*/
public
boolean
lSet
(
String
key
,
List
<
Object
>
value
,
long
time
)
{
if
(
0L
>=
time
)
{
return
false
;
}
try
{
redisTemplate
.
opsForList
().
rightPushAll
(
key
,
value
);
expire
(
key
,
time
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 根据索引修改list中的某条数据
*
* @param key 键
* @param index 索引
* @param value 值
* @return
*/
public
boolean
lUpdateIndex
(
String
key
,
long
index
,
Object
value
)
{
try
{
redisTemplate
.
opsForList
().
set
(
key
,
index
,
value
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
false
;
}
}
/**
* 移除N个值为value
*
* @param key 键
* @param count 移除多少个
* @param value 值
* @return 移除的个数
*/
public
long
lRemove
(
String
key
,
long
count
,
Object
value
)
{
try
{
Long
remove
=
redisTemplate
.
opsForList
().
remove
(
key
,
count
,
value
);
return
remove
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
0
;
}
}
}
src/main/java/com/esv/freight/customer/config/CacheConfig.java
0 → 100644
View file @
40c55000
package
com
.
esv
.
freight
.
customer
.
config
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.springframework.cache.CacheManager
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.cache.RedisCacheConfiguration
;
import
org.springframework.data.redis.cache.RedisCacheManager
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.core.*
;
import
org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer
;
import
org.springframework.data.redis.serializer.RedisSerializationContext
;
import
org.springframework.data.redis.serializer.RedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
import
java.time.Duration
;
/**
* @description: Cache配置类
* @project: freight-customer-service
* @name: com.esv.freight.customer.config.CacheConfig
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/05/08 15:53
* @version:1.0
*/
@Configuration
@EnableCaching
public
class
CacheConfig
{
/**
* description 为SpringCache注册缓存管理器
* param [redisConnectionFactory]
* return org.springframework.cache.CacheManager
* author Administrator
* createTime 2020/03/19 14:26
**/
@Bean
public
CacheManager
cacheManager
(
RedisConnectionFactory
redisConnectionFactory
)
{
long
timeToLive
=
60L
;
RedisSerializer
<
String
>
redisSerializer
=
new
StringRedisSerializer
();
Jackson2JsonRedisSerializer
jackson2JsonRedisSerializer
=
new
Jackson2JsonRedisSerializer
(
Object
.
class
);
// 解决查询缓存转换异常的问题
ObjectMapper
om
=
new
ObjectMapper
();
om
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
om
.
enableDefaultTyping
(
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
jackson2JsonRedisSerializer
.
setObjectMapper
(
om
);
// 配置序列化(解决乱码的问题)
RedisCacheConfiguration
config
=
RedisCacheConfiguration
.
defaultCacheConfig
()
.
entryTtl
(
Duration
.
ofMinutes
(
timeToLive
))
.
serializeKeysWith
(
RedisSerializationContext
.
SerializationPair
.
fromSerializer
(
redisSerializer
))
.
serializeValuesWith
(
RedisSerializationContext
.
SerializationPair
.
fromSerializer
(
jackson2JsonRedisSerializer
));
RedisCacheManager
cacheManager
=
RedisCacheManager
.
builder
(
redisConnectionFactory
)
.
cacheDefaults
(
config
)
.
build
();
return
cacheManager
;
}
/**
* RedisTemplate相关配置
* @param factory
* @return
*/
@Bean
public
RedisTemplate
<
String
,
Object
>
redisTemplate
(
RedisConnectionFactory
factory
)
{
RedisTemplate
<
String
,
Object
>
template
=
new
RedisTemplate
<>();
// 配置连接工厂
template
.
setConnectionFactory
(
factory
);
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式)
Jackson2JsonRedisSerializer
jacksonSeial
=
new
Jackson2JsonRedisSerializer
(
Object
.
class
);
ObjectMapper
om
=
new
ObjectMapper
();
// 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public
om
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
// 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常
om
.
enableDefaultTyping
(
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
jacksonSeial
.
setObjectMapper
(
om
);
// 值采用json序列化
template
.
setValueSerializer
(
jacksonSeial
);
//使用StringRedisSerializer来序列化和反序列化redis的key值
template
.
setKeySerializer
(
new
StringRedisSerializer
());
// 设置hash key 和value序列化模式
template
.
setHashKeySerializer
(
new
StringRedisSerializer
());
template
.
setHashValueSerializer
(
jacksonSeial
);
template
.
afterPropertiesSet
();
return
template
;
}
/**
* 对hash类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public
HashOperations
<
String
,
String
,
Object
>
hashOperations
(
RedisTemplate
<
String
,
Object
>
redisTemplate
)
{
return
redisTemplate
.
opsForHash
();
}
/**
* 对redis字符串类型数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public
ValueOperations
<
String
,
Object
>
valueOperations
(
RedisTemplate
<
String
,
Object
>
redisTemplate
)
{
return
redisTemplate
.
opsForValue
();
}
/**
* 对链表类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public
ListOperations
<
String
,
Object
>
listOperations
(
RedisTemplate
<
String
,
Object
>
redisTemplate
)
{
return
redisTemplate
.
opsForList
();
}
/**
* 对无序集合类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public
SetOperations
<
String
,
Object
>
setOperations
(
RedisTemplate
<
String
,
Object
>
redisTemplate
)
{
return
redisTemplate
.
opsForSet
();
}
/**
* 对有序集合类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public
ZSetOperations
<
String
,
Object
>
zSetOperations
(
RedisTemplate
<
String
,
Object
>
redisTemplate
)
{
return
redisTemplate
.
opsForZSet
();
}
}
src/main/java/com/esv/freight/customer/feign/FeignBaseService.java
View file @
40c55000
...
@@ -25,4 +25,14 @@ public interface FeignBaseService {
...
@@ -25,4 +25,14 @@ public interface FeignBaseService {
**/
**/
@PostMapping
(
value
=
"/base/batchId/generate"
)
@PostMapping
(
value
=
"/base/batchId/generate"
)
JSONObject
getBatchId
(
JSONObject
bodyJson
);
JSONObject
getBatchId
(
JSONObject
bodyJson
);
/**
* description 获取全国省市行政区划(键值对)
* param [bodyJson]
* return com.alibaba.fastjson.JSONObject
* author Administrator
* createTime 2020/05/08 15:54
**/
@PostMapping
(
value
=
"/base/geo/city/getAllRegionMap"
)
JSONObject
getAllRegionMap
(
JSONObject
bodyJson
);
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/AccountServiceImpl.java
View file @
40c55000
...
@@ -135,7 +135,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
...
@@ -135,7 +135,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
// 5.新增帐号审核记录
// 5.新增帐号审核记录
AuditHistoryEntity
auditHistoryEntity
=
new
AuditHistoryEntity
();
AuditHistoryEntity
auditHistoryEntity
=
new
AuditHistoryEntity
();
auditHistoryEntity
.
setAccountId
(
Long
.
parseLong
(
String
.
valueOf
(
accountId
))
);
auditHistoryEntity
.
setAccountId
(
accountId
);
auditHistoryEntity
.
setAuditStatus
(
GoodsOwnerConstants
.
OWNER_AUDIT_STATUS_SUCCESS
);
auditHistoryEntity
.
setAuditStatus
(
GoodsOwnerConstants
.
OWNER_AUDIT_STATUS_SUCCESS
);
auditHistoryEntity
.
setOperateUser
(
ReqUtils
.
getRequestHeader
(
GatewayHeaders
.
USER_ACCOUNT
));
auditHistoryEntity
.
setOperateUser
(
ReqUtils
.
getRequestHeader
(
GatewayHeaders
.
USER_ACCOUNT
));
auditHistoryService
.
getBaseMapper
().
insert
(
auditHistoryEntity
);
auditHistoryService
.
getBaseMapper
().
insert
(
auditHistoryEntity
);
...
@@ -279,7 +279,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
...
@@ -279,7 +279,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
@Override
@Override
public
Long
registerAccount
(
String
account
)
{
public
Long
registerAccount
(
String
account
)
{
//
判断帐号是否
存在
//
1.判断帐号是否已
存在
AccountEntity
accountEntity
=
this
.
getAccountRecordByAccount
(
account
);
AccountEntity
accountEntity
=
this
.
getAccountRecordByAccount
(
account
);
if
(
null
!=
accountEntity
)
{
if
(
null
!=
accountEntity
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getGoodsOwnerAccountRegister1001
());
throw
new
EException
(
1001
,
errorMessageComponent
.
getGoodsOwnerAccountRegister1001
());
...
@@ -287,7 +287,21 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
...
@@ -287,7 +287,21 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
accountEntity
=
new
AccountEntity
();
accountEntity
=
new
AccountEntity
();
}
}
// 新增注册帐号
// 2.获取客户编码
JSONObject
batchIdReqJson
=
new
JSONObject
();
batchIdReqJson
.
put
(
"prefix"
,
"HZ"
);
batchIdReqJson
.
put
(
"formatter"
,
"yyyyMMdd"
);
batchIdReqJson
.
put
(
"length"
,
13
);
JSONObject
batchIdResJson
;
try
{
batchIdResJson
=
FeignUtils
.
getFeignResultData
(
feignBaseService
.
getBatchId
(
batchIdReqJson
));
}
catch
(
Exception
e
)
{
log
.
error
(
"调用[基础服务]生成客户编号失败:"
+
e
.
getMessage
());
throw
new
EException
(
"生成客户编号时发生错误"
);
}
String
ownerNumber
=
batchIdResJson
.
getString
(
"batchId"
);
// 3.新增帐号
accountEntity
.
setAccount
(
account
);
accountEntity
.
setAccount
(
account
);
accountEntity
.
setSalt
(
passwordComponent
.
generateAccountPwdSalt
());
accountEntity
.
setSalt
(
passwordComponent
.
generateAccountPwdSalt
());
accountEntity
.
setSourceType
(
GoodsOwnerConstants
.
OWNER_SOURCE_TYPE_REGISTER
);
accountEntity
.
setSourceType
(
GoodsOwnerConstants
.
OWNER_SOURCE_TYPE_REGISTER
);
...
@@ -295,6 +309,20 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
...
@@ -295,6 +309,20 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
this
.
baseMapper
.
insert
(
accountEntity
);
this
.
baseMapper
.
insert
(
accountEntity
);
Long
accountId
=
accountEntity
.
getId
();
Long
accountId
=
accountEntity
.
getId
();
// 4.新增帐号信息
InfoEntity
infoEntity
=
new
InfoEntity
();
infoEntity
.
setOwnerNumber
(
ownerNumber
);
infoEntity
.
setAccountId
(
accountId
);
infoService
.
getBaseMapper
().
insert
(
infoEntity
);
// 5.新增帐号审核记录
AuditHistoryEntity
auditHistoryEntity
=
new
AuditHistoryEntity
();
auditHistoryEntity
.
setAccountId
(
accountId
);
auditHistoryEntity
.
setAuditStatus
(
GoodsOwnerConstants
.
OWNER_AUDIT_STATUS_UNAUDITED
);
auditHistoryEntity
.
setOperateUser
(
account
);
auditHistoryEntity
.
setRemark
(
"用户通过终端APP注册帐号"
);
auditHistoryService
.
getBaseMapper
().
insert
(
auditHistoryEntity
);
return
accountId
;
return
accountId
;
}
}
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/DeliveryAddressServiceImpl.java
View file @
40c55000
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.esv.freight.customer.common.component.BaseDataComponent
;
import
com.esv.freight.customer.common.component.ErrorMessageComponent
;
import
com.esv.freight.customer.common.component.ErrorMessageComponent
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.util.FeignUtils
;
import
com.esv.freight.customer.common.util.FeignUtils
;
...
@@ -36,10 +37,14 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
...
@@ -36,10 +37,14 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
private
ErrorMessageComponent
errorMessageComponent
;
private
ErrorMessageComponent
errorMessageComponent
;
private
BaseDataComponent
baseDataComponent
;
@Autowired
@Autowired
public
DeliveryAddressServiceImpl
(
FeignBaseService
feignBaseService
,
ErrorMessageComponent
errorMessageComponent
)
{
public
DeliveryAddressServiceImpl
(
FeignBaseService
feignBaseService
,
ErrorMessageComponent
errorMessageComponent
,
BaseDataComponent
baseDataComponent
)
{
this
.
feignBaseService
=
feignBaseService
;
this
.
feignBaseService
=
feignBaseService
;
this
.
errorMessageComponent
=
errorMessageComponent
;
this
.
errorMessageComponent
=
errorMessageComponent
;
this
.
baseDataComponent
=
baseDataComponent
;
}
}
@Override
@Override
...
@@ -178,6 +183,7 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
...
@@ -178,6 +183,7 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
// 数据转换
// 数据转换
List
<
DeliveryAddressDto
>
addressDtoList
=
page
.
getRecords
();
List
<
DeliveryAddressDto
>
addressDtoList
=
page
.
getRecords
();
JSONObject
allRegionMap
=
baseDataComponent
.
getAllRegionMap
();
List
<
DeliveryAddressListVO
>
addressListVOList
=
new
ArrayList
<>();
List
<
DeliveryAddressListVO
>
addressListVOList
=
new
ArrayList
<>();
addressDtoList
.
forEach
(
entity
->
{
addressDtoList
.
forEach
(
entity
->
{
DeliveryAddressListVO
vo
=
new
DeliveryAddressListVO
();
DeliveryAddressListVO
vo
=
new
DeliveryAddressListVO
();
...
@@ -188,6 +194,11 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
...
@@ -188,6 +194,11 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
}
else
{
}
else
{
vo
.
setGoodsOwnerName
(
entity
.
getOwnerFullName
());
vo
.
setGoodsOwnerName
(
entity
.
getOwnerFullName
());
}
}
StringBuffer
sb
=
new
StringBuffer
().
append
(
StringUtils
.
trimToEmpty
(
allRegionMap
.
getString
(
entity
.
getProvinceCode
())))
.
append
(
","
).
append
(
StringUtils
.
trimToEmpty
(
allRegionMap
.
getString
(
entity
.
getCityCode
())))
.
append
(
","
).
append
(
StringUtils
.
trimToEmpty
(
allRegionMap
.
getString
(
entity
.
getDistrictCode
())))
.
append
(
","
).
append
(
StringUtils
.
trimToEmpty
(
entity
.
getDetailAddress
()));
vo
.
setFullAddress
(
sb
.
toString
());
addressListVOList
.
add
(
vo
);
addressListVOList
.
add
(
vo
);
});
});
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/ReceiveAddressServiceImpl.java
View file @
40c55000
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.esv.freight.customer.common.component.BaseDataComponent
;
import
com.esv.freight.customer.common.component.ErrorMessageComponent
;
import
com.esv.freight.customer.common.component.ErrorMessageComponent
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.exception.EException
;
import
com.esv.freight.customer.common.util.FeignUtils
;
import
com.esv.freight.customer.common.util.FeignUtils
;
...
@@ -36,10 +37,14 @@ public class ReceiveAddressServiceImpl extends ServiceImpl<ReceiveAddressDao, Re
...
@@ -36,10 +37,14 @@ public class ReceiveAddressServiceImpl extends ServiceImpl<ReceiveAddressDao, Re
private
ErrorMessageComponent
errorMessageComponent
;
private
ErrorMessageComponent
errorMessageComponent
;
private
BaseDataComponent
baseDataComponent
;
@Autowired
@Autowired
public
ReceiveAddressServiceImpl
(
FeignBaseService
feignBaseService
,
ErrorMessageComponent
errorMessageComponent
)
{
public
ReceiveAddressServiceImpl
(
FeignBaseService
feignBaseService
,
ErrorMessageComponent
errorMessageComponent
,
BaseDataComponent
baseDataComponent
)
{
this
.
feignBaseService
=
feignBaseService
;
this
.
feignBaseService
=
feignBaseService
;
this
.
errorMessageComponent
=
errorMessageComponent
;
this
.
errorMessageComponent
=
errorMessageComponent
;
this
.
baseDataComponent
=
baseDataComponent
;
}
}
@Override
@Override
...
@@ -178,6 +183,7 @@ public class ReceiveAddressServiceImpl extends ServiceImpl<ReceiveAddressDao, Re
...
@@ -178,6 +183,7 @@ public class ReceiveAddressServiceImpl extends ServiceImpl<ReceiveAddressDao, Re
// 数据转换
// 数据转换
List
<
ReceiveAddressDto
>
addressDtoList
=
page
.
getRecords
();
List
<
ReceiveAddressDto
>
addressDtoList
=
page
.
getRecords
();
JSONObject
allRegionMap
=
baseDataComponent
.
getAllRegionMap
();
List
<
ReceiveAddressListVO
>
addressListVOList
=
new
ArrayList
<>();
List
<
ReceiveAddressListVO
>
addressListVOList
=
new
ArrayList
<>();
addressDtoList
.
forEach
(
entity
->
{
addressDtoList
.
forEach
(
entity
->
{
ReceiveAddressListVO
vo
=
new
ReceiveAddressListVO
();
ReceiveAddressListVO
vo
=
new
ReceiveAddressListVO
();
...
@@ -188,6 +194,11 @@ public class ReceiveAddressServiceImpl extends ServiceImpl<ReceiveAddressDao, Re
...
@@ -188,6 +194,11 @@ public class ReceiveAddressServiceImpl extends ServiceImpl<ReceiveAddressDao, Re
}
else
{
}
else
{
vo
.
setGoodsOwnerName
(
entity
.
getOwnerFullName
());
vo
.
setGoodsOwnerName
(
entity
.
getOwnerFullName
());
}
}
StringBuffer
sb
=
new
StringBuffer
().
append
(
StringUtils
.
trimToEmpty
(
allRegionMap
.
getString
(
entity
.
getProvinceCode
())))
.
append
(
","
).
append
(
StringUtils
.
trimToEmpty
(
allRegionMap
.
getString
(
entity
.
getCityCode
())))
.
append
(
","
).
append
(
StringUtils
.
trimToEmpty
(
allRegionMap
.
getString
(
entity
.
getDistrictCode
())))
.
append
(
","
).
append
(
StringUtils
.
trimToEmpty
(
entity
.
getDetailAddress
()));
vo
.
setFullAddress
(
sb
.
toString
());
addressListVOList
.
add
(
vo
);
addressListVOList
.
add
(
vo
);
});
});
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/vo/DeliveryAddressListVO.java
View file @
40c55000
...
@@ -33,21 +33,9 @@ public class DeliveryAddressListVO {
...
@@ -33,21 +33,9 @@ public class DeliveryAddressListVO {
*/
*/
private
String
addressName
;
private
String
addressName
;
/**
/**
*
省份代码
*
完整地址
*/
*/
private
String
provinceCode
;
private
String
fullAddress
;
/**
* 市代码
*/
private
String
cityCode
;
/**
* 区县代码
*/
private
String
districtCode
;
/**
* 详细地址
*/
private
String
detailAddress
;
/**
/**
* 发货人
* 发货人
*/
*/
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/vo/ReceiveAddressListVO.java
View file @
40c55000
...
@@ -33,21 +33,9 @@ public class ReceiveAddressListVO {
...
@@ -33,21 +33,9 @@ public class ReceiveAddressListVO {
*/
*/
private
String
addressName
;
private
String
addressName
;
/**
/**
*
省份代码
*
完整地址
*/
*/
private
String
provinceCode
;
private
String
fullAddress
;
/**
* 市代码
*/
private
String
cityCode
;
/**
* 区县代码
*/
private
String
districtCode
;
/**
* 详细地址
*/
private
String
detailAddress
;
/**
/**
* 收货人
* 收货人
*/
*/
...
...
src/main/resources/application-dev.yml
View file @
40c55000
...
@@ -21,6 +21,18 @@ spring:
...
@@ -21,6 +21,18 @@ spring:
log-slow-sql
:
true
log-slow-sql
:
true
slow-sql-millis
:
1000
slow-sql-millis
:
1000
merge-sql
:
false
merge-sql
:
false
redis
:
database
:
0
host
:
192.168.31.248
port
:
6379
password
:
timeout
:
1000
jedis
:
pool
:
max-active
:
8
max-wait
:
-1
max-idle
:
8
min-idle
:
0
#mybatis
#mybatis
mybatis-plus
:
mybatis-plus
:
mapper-locations
:
classpath*:/mapper/**/*Dao.xml
mapper-locations
:
classpath*:/mapper/**/*Dao.xml
...
...
src/main/resources/application-test.yml
View file @
40c55000
...
@@ -21,6 +21,18 @@ spring:
...
@@ -21,6 +21,18 @@ spring:
log-slow-sql
:
true
log-slow-sql
:
true
slow-sql-millis
:
1000
slow-sql-millis
:
1000
merge-sql
:
false
merge-sql
:
false
redis
:
database
:
0
host
:
192.168.31.248
port
:
6379
password
:
timeout
:
1000
jedis
:
pool
:
max-active
:
8
max-wait
:
-1
max-idle
:
8
min-idle
:
0
#mybatis
#mybatis
mybatis-plus
:
mybatis-plus
:
mapper-locations
:
classpath*:/mapper/**/*Dao.xml
mapper-locations
:
classpath*:/mapper/**/*Dao.xml
...
...
src/main/resources/bootstrap.yml
View file @
40c55000
...
@@ -3,8 +3,8 @@ server:
...
@@ -3,8 +3,8 @@ server:
servlet
:
servlet
:
context-path
:
/customer
context-path
:
/customer
nacos
:
nacos
:
url
:
1
27.0.0.1
:8848
url
:
1
92.168.31.248
:8848
namespace
:
548b506d-8d19-4d54-9715-bb0ac3a655b2
namespace
:
aad5aa26-5351-4e7a-a65e-ecb332f3c52c
group
:
DEFAULT_GROUP
group
:
DEFAULT_GROUP
spring
:
spring
:
application
:
application
:
...
...
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