Commit 40c55000 authored by huangcb's avatar huangcb

货主接口:优化发货地址、收货地址列表功能

parent 2299e8be
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;
}
}
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;
}
}
}
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();
}
}
......@@ -25,4 +25,14 @@ public interface FeignBaseService {
**/
@PostMapping(value = "/base/batchId/generate")
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);
}
......@@ -135,7 +135,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
// 5.新增帐号审核记录
AuditHistoryEntity auditHistoryEntity = new AuditHistoryEntity();
auditHistoryEntity.setAccountId(Long.parseLong(String.valueOf(accountId)));
auditHistoryEntity.setAccountId(accountId);
auditHistoryEntity.setAuditStatus(GoodsOwnerConstants.OWNER_AUDIT_STATUS_SUCCESS);
auditHistoryEntity.setOperateUser(ReqUtils.getRequestHeader(GatewayHeaders.USER_ACCOUNT));
auditHistoryService.getBaseMapper().insert(auditHistoryEntity);
......@@ -279,7 +279,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
@Override
public Long registerAccount(String account) {
// 判断帐号是否存在
// 1.判断帐号是否已存在
AccountEntity accountEntity = this.getAccountRecordByAccount(account);
if (null != accountEntity) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountRegister1001());
......@@ -287,7 +287,21 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
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.setSalt(passwordComponent.generateAccountPwdSalt());
accountEntity.setSourceType(GoodsOwnerConstants.OWNER_SOURCE_TYPE_REGISTER);
......@@ -295,6 +309,20 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
this.baseMapper.insert(accountEntity);
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;
}
......
......@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.exception.EException;
import com.esv.freight.customer.common.util.FeignUtils;
......@@ -36,10 +37,14 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
private ErrorMessageComponent errorMessageComponent;
private BaseDataComponent baseDataComponent;
@Autowired
public DeliveryAddressServiceImpl(FeignBaseService feignBaseService, ErrorMessageComponent errorMessageComponent) {
public DeliveryAddressServiceImpl(FeignBaseService feignBaseService, ErrorMessageComponent errorMessageComponent,
BaseDataComponent baseDataComponent) {
this.feignBaseService = feignBaseService;
this.errorMessageComponent = errorMessageComponent;
this.baseDataComponent = baseDataComponent;
}
@Override
......@@ -178,6 +183,7 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
// 数据转换
List<DeliveryAddressDto> addressDtoList = page.getRecords();
JSONObject allRegionMap = baseDataComponent.getAllRegionMap();
List<DeliveryAddressListVO> addressListVOList = new ArrayList<>();
addressDtoList.forEach(entity -> {
DeliveryAddressListVO vo = new DeliveryAddressListVO();
......@@ -188,6 +194,11 @@ public class DeliveryAddressServiceImpl extends ServiceImpl<DeliveryAddressDao,
} else {
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);
});
......
......@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.exception.EException;
import com.esv.freight.customer.common.util.FeignUtils;
......@@ -36,10 +37,14 @@ public class ReceiveAddressServiceImpl extends ServiceImpl<ReceiveAddressDao, Re
private ErrorMessageComponent errorMessageComponent;
private BaseDataComponent baseDataComponent;
@Autowired
public ReceiveAddressServiceImpl(FeignBaseService feignBaseService, ErrorMessageComponent errorMessageComponent) {
public ReceiveAddressServiceImpl(FeignBaseService feignBaseService, ErrorMessageComponent errorMessageComponent,
BaseDataComponent baseDataComponent) {
this.feignBaseService = feignBaseService;
this.errorMessageComponent = errorMessageComponent;
this.baseDataComponent = baseDataComponent;
}
@Override
......@@ -178,6 +183,7 @@ public class ReceiveAddressServiceImpl extends ServiceImpl<ReceiveAddressDao, Re
// 数据转换
List<ReceiveAddressDto> addressDtoList = page.getRecords();
JSONObject allRegionMap = baseDataComponent.getAllRegionMap();
List<ReceiveAddressListVO> addressListVOList = new ArrayList<>();
addressDtoList.forEach(entity -> {
ReceiveAddressListVO vo = new ReceiveAddressListVO();
......@@ -188,6 +194,11 @@ public class ReceiveAddressServiceImpl extends ServiceImpl<ReceiveAddressDao, Re
} else {
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);
});
......
......@@ -33,21 +33,9 @@ public class DeliveryAddressListVO {
*/
private String addressName;
/**
* 省份代码
* 完整地址
*/
private String provinceCode;
/**
* 市代码
*/
private String cityCode;
/**
* 区县代码
*/
private String districtCode;
/**
* 详细地址
*/
private String detailAddress;
private String fullAddress;
/**
* 发货人
*/
......
......@@ -33,21 +33,9 @@ public class ReceiveAddressListVO {
*/
private String addressName;
/**
* 省份代码
* 完整地址
*/
private String provinceCode;
/**
* 市代码
*/
private String cityCode;
/**
* 区县代码
*/
private String districtCode;
/**
* 详细地址
*/
private String detailAddress;
private String fullAddress;
/**
* 收货人
*/
......
......@@ -21,6 +21,18 @@ spring:
log-slow-sql: true
slow-sql-millis: 1000
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-plus:
mapper-locations: classpath*:/mapper/**/*Dao.xml
......
......@@ -21,6 +21,18 @@ spring:
log-slow-sql: true
slow-sql-millis: 1000
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-plus:
mapper-locations: classpath*:/mapper/**/*Dao.xml
......
......@@ -3,8 +3,8 @@ server:
servlet:
context-path: /customer
nacos:
url: 127.0.0.1:8848
namespace: 548b506d-8d19-4d54-9715-bb0ac3a655b2
url: 192.168.31.248:8848
namespace: aad5aa26-5351-4e7a-a65e-ecb332f3c52c
group: DEFAULT_GROUP
spring:
application:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment