|
@@ -6,7 +6,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ylx.common.utils.StringUtils;
|
|
import com.ylx.common.utils.StringUtils;
|
|
|
|
|
+import com.ylx.massage.domain.dto.CoordinateDTO;
|
|
|
|
|
+import com.ylx.massage.domain.vo.CityInfoVo;
|
|
|
import com.ylx.massage.domain.vo.UserAddressListVO;
|
|
import com.ylx.massage.domain.vo.UserAddressListVO;
|
|
|
|
|
+import com.ylx.massage.service.AreaService;
|
|
|
import com.ylx.useradress.domain.dto.UserAddressAddDto;
|
|
import com.ylx.useradress.domain.dto.UserAddressAddDto;
|
|
|
import com.ylx.useradress.domain.dto.UserAddressDeleteDto;
|
|
import com.ylx.useradress.domain.dto.UserAddressDeleteDto;
|
|
|
import com.ylx.useradress.domain.dto.UserAddressDto;
|
|
import com.ylx.useradress.domain.dto.UserAddressDto;
|
|
@@ -16,6 +19,7 @@ import com.ylx.massage.mapper.TAddressMapper;
|
|
|
import com.ylx.massage.domain.TAddress;
|
|
import com.ylx.massage.domain.TAddress;
|
|
|
import com.ylx.massage.service.TAddressService;
|
|
import com.ylx.massage.service.TAddressService;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
@@ -43,6 +47,8 @@ public class TAddressServiceImpl extends ServiceImpl<TAddressMapper, TAddress> i
|
|
|
private static final Integer IS_DEFAULT = 1;
|
|
private static final Integer IS_DEFAULT = 1;
|
|
|
//0=不是默认地址
|
|
//0=不是默认地址
|
|
|
private static final Integer NO_DEFAULT = 0;
|
|
private static final Integer NO_DEFAULT = 0;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private AreaService areaService;
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -119,9 +125,9 @@ public class TAddressServiceImpl extends ServiceImpl<TAddressMapper, TAddress> i
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Object insertVirtualAddress(TAddress tAddress) {
|
|
public Object insertVirtualAddress(TAddress tAddress) {
|
|
|
-// if (StringUtils.isBlank(tAddress.getOpenid())) {
|
|
|
|
|
-// throw new RuntimeException("openid不能为空");
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ if (StringUtils.isBlank(tAddress.getOpenid())) {
|
|
|
|
|
+ throw new RuntimeException("openid不能为空");
|
|
|
|
|
+ }
|
|
|
//检查用户类型是否为空
|
|
//检查用户类型是否为空
|
|
|
if (Objects.isNull(tAddress.getUserType())) {
|
|
if (Objects.isNull(tAddress.getUserType())) {
|
|
|
throw new RuntimeException("用户类型不能为空");
|
|
throw new RuntimeException("用户类型不能为空");
|
|
@@ -139,10 +145,20 @@ public class TAddressServiceImpl extends ServiceImpl<TAddressMapper, TAddress> i
|
|
|
if (Objects.isNull(tAddress.getType())) {
|
|
if (Objects.isNull(tAddress.getType())) {
|
|
|
throw new RuntimeException("地址类型不能为空");
|
|
throw new RuntimeException("地址类型不能为空");
|
|
|
}
|
|
}
|
|
|
-// //检查地址类型是否为1或2
|
|
|
|
|
-// if (tAddress.getType() != 2) {
|
|
|
|
|
-// throw new RuntimeException("地址类型错误,地址类型只能为2");
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ //检查地址类型是否为1或2
|
|
|
|
|
+ if (tAddress.getType() != 2) {
|
|
|
|
|
+ throw new RuntimeException("地址类型错误,地址类型只能为2");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StrUtil.isBlank(tAddress.getCityCode())){
|
|
|
|
|
+ CoordinateDTO dto = new CoordinateDTO();
|
|
|
|
|
+ dto.setLongitude(tAddress.getLongitude());
|
|
|
|
|
+ dto.setLatitude(tAddress.getLatitude());
|
|
|
|
|
+ CityInfoVo cityInfoVo = areaService.getCityInfoByCoordinates(dto);
|
|
|
|
|
+ tAddress.setCityCode(cityInfoVo.getCityCode());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isBlank(tAddress.getDetailAddress())){
|
|
|
|
|
+ tAddress.setDetailAddress(tAddress.getAddress());
|
|
|
|
|
+ }
|
|
|
return this.save(tAddress);
|
|
return this.save(tAddress);
|
|
|
}
|
|
}
|
|
|
|
|
|