修复微信导入地址没有cityID的问题
This commit is contained in:
@@ -32,4 +32,10 @@ public interface SystemCityService extends IService<SystemCity> {
|
|||||||
List<Integer> getCityIdList();
|
List<Integer> getCityIdList();
|
||||||
|
|
||||||
SystemCity getCityByCityId(Integer cityId);
|
SystemCity getCityByCityId(Integer cityId);
|
||||||
}
|
/**
|
||||||
|
* 根据城市名称获取城市详细数据
|
||||||
|
* @param cityName 城市名称
|
||||||
|
* @return 城市数据
|
||||||
|
*/
|
||||||
|
SystemCity getCityByCityName(String cityName);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.zbkj.crmeb.system.service.impl;
|
package com.zbkj.crmeb.system.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.constants.Constants;
|
import com.constants.Constants;
|
||||||
import com.utils.RedisUtil;
|
import com.utils.RedisUtil;
|
||||||
@@ -173,5 +174,20 @@ public class SystemCityServiceImpl extends ServiceImpl<SystemCityDao, SystemCity
|
|||||||
public void asyncRedis(Integer pid){
|
public void asyncRedis(Integer pid){
|
||||||
systemCityAsyncService.async(pid);
|
systemCityAsyncService.async(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据城市名称获取城市详细数据
|
||||||
|
* @author 大粽子
|
||||||
|
* @param cityName 城市名称
|
||||||
|
* @return 城市数据
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SystemCity getCityByCityName(String cityName) {
|
||||||
|
LambdaQueryWrapper<SystemCity> systemCityLambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||||
|
systemCityLambdaQueryWrapper
|
||||||
|
.eq(SystemCity::getName,cityName)
|
||||||
|
.eq(SystemCity::getIsShow,1);
|
||||||
|
return getOne(systemCityLambdaQueryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.zbkj.crmeb.user.service.impl;
|
package com.zbkj.crmeb.user.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@@ -88,7 +89,20 @@ public class UserAddressServiceImpl extends ServiceImpl<UserAddressDao, UserAddr
|
|||||||
userAddress.setCityId(request.getAddress().getCityId());
|
userAddress.setCityId(request.getAddress().getCityId());
|
||||||
userAddress.setDistrict(request.getAddress().getDistrict());
|
userAddress.setDistrict(request.getAddress().getDistrict());
|
||||||
userAddress.setProvince(request.getAddress().getProvince());
|
userAddress.setProvince(request.getAddress().getProvince());
|
||||||
|
// 添加地址时cityId和城市名称不能同时为空,如果id为空,必须用城市名称自查后set CityId
|
||||||
|
if(request.getAddress().getCityId() == 0 && StringUtils.isBlank(request.getAddress().getCity())){
|
||||||
|
throw new CrmebException("请选择正确城市数据");
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotBlank(request.getAddress().getCity()) && request.getAddress().getCityId() == 0){
|
||||||
|
SystemCity currentCity = systemCityService.getCityByCityName(request.getAddress().getCity());
|
||||||
|
if(ObjectUtil.isNull(currentCity)) throw new CrmebException("当前城市未找到!");
|
||||||
|
|
||||||
|
userAddress.setCityId(currentCity.getCityId());
|
||||||
|
}
|
||||||
|
|
||||||
|
//if(request.getAddress().getCityId() > 0 && StringUtils.isNotBlank(request.getAddress().getCity())){
|
||||||
|
checkCity(userAddress.getCityId());
|
||||||
|
//}
|
||||||
if(request.getAddress().getCityId() > 0 && StringUtils.isNotBlank(request.getAddress().getCity())){
|
if(request.getAddress().getCityId() > 0 && StringUtils.isNotBlank(request.getAddress().getCity())){
|
||||||
checkCity(userAddress.getCityId());
|
checkCity(userAddress.getCityId());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user