|
@@ -1,15 +1,22 @@
|
|
|
package com.ylx.massage.service.impl;
|
|
package com.ylx.massage.service.impl;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+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.useradress.domain.dto.UserAddressDto;
|
|
|
|
|
+import com.ylx.useradress.domain.vo.UserAddressVo;
|
|
|
import com.ylx.massage.mapper.TAddressMapper;
|
|
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.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
+import java.util.Collections;
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 轮播图(TAddress)表服务实现类
|
|
* 轮播图(TAddress)表服务实现类
|
|
@@ -27,6 +34,34 @@ public class TAddressServiceImpl extends ServiceImpl<TAddressMapper, TAddress> i
|
|
|
return this.getOne(objectLambdaQueryWrapper);
|
|
return this.getOne(objectLambdaQueryWrapper);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private List<TAddress> getAddressList(String openId, Integer userType,String cityCode) {
|
|
|
|
|
+ LambdaQueryWrapper<TAddress> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ objectLambdaQueryWrapper.eq(TAddress::getOpenid, openId)
|
|
|
|
|
+ .eq(TAddress::getUserType, userType)
|
|
|
|
|
+ .eq(TAddress::getCityCode,cityCode)
|
|
|
|
|
+ .eq(TAddress::getIsDelete,0)
|
|
|
|
|
+ .orderByDesc(TAddress::getCreateTime);
|
|
|
|
|
+ return this.list(objectLambdaQueryWrapper);
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据openId和userType获取地址列表 用户类型(1:用户 2:商户)
|
|
|
|
|
+ * @param dto
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<UserAddressVo> getByOpenIdList(UserAddressDto dto) {
|
|
|
|
|
+ List<TAddress> addressList = getAddressList(dto.getOpenId(), 1,dto.getCityCode());
|
|
|
|
|
+ if (CollectionUtils.isEmpty(addressList)) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+ return addressList.stream().map(this::convertToVo).collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+ private UserAddressVo convertToVo(TAddress address) {
|
|
|
|
|
+ UserAddressVo vo = new UserAddressVo();
|
|
|
|
|
+ BeanUtils.copyProperties(address, vo);
|
|
|
|
|
+ return vo;
|
|
|
|
|
+ }
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean defaultAddress(TAddress tAddress) {
|
|
public Boolean defaultAddress(TAddress tAddress) {
|