| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | import static java.util.Objects.isNull; |
| | | import static java.util.Objects.nonNull; |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R addPoint(ConvenientElevatingPointDTO convenientElevatingPointDTO) { |
| | | ConvenientElevatingPointDO convenientElevatingPointDODB = this.baseMapper.selectOne(new LambdaQueryWrapper<ConvenientElevatingPointDO>().eq(ConvenientElevatingPointDO::getWechatAccount, convenientElevatingPointDTO.getWechatAccount())); |
| | | if (!Objects.isNull(convenientElevatingPointDODB)){ |
| | | return R.fail("该微信手机号已使用,请更换"); |
| | | } |
| | | ConvenientElevatingPointDO convenientElevatingPointDO = new ConvenientElevatingPointDO(); |
| | | BeanUtils.copyProperties(convenientElevatingPointDTO, convenientElevatingPointDO); |
| | | String communityId = convenientElevatingPointDTO.getCommunityId(); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R putPoint(ConvenientElevatingPointDTO convenientElevatingPointDTO) { |
| | | ConvenientElevatingPointDO convenientElevatingPointDODB = this.baseMapper.selectOne(new LambdaQueryWrapper<ConvenientElevatingPointDO>().eq(ConvenientElevatingPointDO::getWechatAccount, convenientElevatingPointDTO.getWechatAccount())); |
| | | |
| | | Long id = convenientElevatingPointDTO.getId(); |
| | | ConvenientElevatingPointDO convenientElevatingPointDO = this.baseMapper.selectById(id); |
| | | if (isNull(convenientElevatingPointDO)) { |
| | | return R.fail("自提点不存在"); |
| | | } |
| | | if (nonNull(convenientElevatingPointDODB) && !convenientElevatingPointDODB.getId().equals(convenientElevatingPointDO.getId())) { |
| | | R.fail("该微信手机号:" + convenientElevatingPointDTO.getWechatAccount() + "已被使用!请更换"); |
| | | } |
| | | String communityId = convenientElevatingPointDTO.getCommunityId(); |
| | | if (nonNull(communityId)) { |
| | |
| | | @Override |
| | | public R detailPoint(Long pointId) { |
| | | ConvenientElevatingPointDO convenientElevatingPointDO = this.baseMapper.selectById(pointId); |
| | | return R.ok(convenientElevatingPointDO); |
| | | ConvenientElevatingPointVO convenientElevatingPointVO = new ConvenientElevatingPointVO(); |
| | | BeanUtils.copyProperties(convenientElevatingPointDO,convenientElevatingPointVO); |
| | | return R.ok(convenientElevatingPointVO); |
| | | } |
| | | |
| | | public R findPointByMerchantId(Long merchantId, String lat, String lng) { |
| | |
| | | String maxLng = around.get("maxLng").toString(); |
| | | List<ConvenientElevatingPointDO> convenientElevatingPointDOS = this.baseMapper.selectList( |
| | | new LambdaQueryWrapper<ConvenientElevatingPointDO>() |
| | | .ge(ConvenientElevatingPointDO::getLat, minLng) |
| | | .le(ConvenientElevatingPointDO::getLat, maxLng) |
| | | .ge(ConvenientElevatingPointDO::getLon, minLat) |
| | | .le(ConvenientElevatingPointDO::getLon, maxLat)); |
| | | .ge(ConvenientElevatingPointDO::getLat, Double.parseDouble(minLng)) |
| | | .le(ConvenientElevatingPointDO::getLat, Double.parseDouble(maxLng)) |
| | | .ge(ConvenientElevatingPointDO::getLon, Double.parseDouble(minLat)) |
| | | .le(ConvenientElevatingPointDO::getLon, Double.parseDouble(maxLat)) |
| | | .eq(ConvenientElevatingPointDO::getBusinessStatus,1)); |
| | | List<ConvenientElevatingPointVO> convenientElevatingPointVOS = new ArrayList<>(); |
| | | convenientElevatingPointDOS.forEach(f -> { |
| | | ConvenientElevatingPointVO convenientElevatingPointVO = new ConvenientElevatingPointVO(); |
| | | BeanUtils.copyProperties(f, convenientElevatingPointVO); |
| | | Double distance = MapDistance.distanceOfTwoPoints(lng, lat, f.getLon(), f.getLat()); |
| | | Double distance = MapDistance.distanceOfTwoPoints(lat, lng, f.getLon(), f.getLat()); |
| | | convenientElevatingPointVO.setDistance(distance); |
| | | convenientElevatingPointVOS.add(convenientElevatingPointVO); |
| | | }); |
| | | Collections.sort(convenientElevatingPointVOS); |
| | | return R.ok(convenientElevatingPointVOS); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public R findPointNumByDistance(Integer distance, String lat, String lng) { |
| | | Map<Object, Object> around = MapDistance.getAround(lat, lng, distance * 1000d); |
| | | String maxLat = around.get("maxLat").toString(); |
| | | String minLat = around.get("minLat").toString(); |
| | | String minLng = around.get("minLng").toString(); |
| | | String maxLng = around.get("maxLng").toString(); |
| | | List<ConvenientElevatingPointDO> convenientElevatingPointDOS = this.baseMapper.selectList( |
| | | new LambdaQueryWrapper<ConvenientElevatingPointDO>() |
| | | .ge(ConvenientElevatingPointDO::getLat, Double.parseDouble(minLng)) |
| | | .le(ConvenientElevatingPointDO::getLat, Double.parseDouble(maxLng)) |
| | | .ge(ConvenientElevatingPointDO::getLon, Double.parseDouble(minLat)) |
| | | .le(ConvenientElevatingPointDO::getLon, Double.parseDouble(maxLat)) |
| | | .eq(ConvenientElevatingPointDO::getBusinessStatus,1)); |
| | | List<ConvenientElevatingPointVO> convenientElevatingPointVOS = new ArrayList<>(); |
| | | convenientElevatingPointDOS.forEach(f -> { |
| | | ConvenientElevatingPointVO convenientElevatingPointVO = new ConvenientElevatingPointVO(); |
| | | BeanUtils.copyProperties(f, convenientElevatingPointVO); |
| | | Double distancem = MapDistance.distanceOfTwoPoints(lat, lng, f.getLon(), f.getLat()); |
| | | convenientElevatingPointVO.setDistance(distancem); |
| | | convenientElevatingPointVOS.add(convenientElevatingPointVO); |
| | | }); |
| | | Collections.sort(convenientElevatingPointVOS); |
| | | return R.ok(convenientElevatingPointVOS.size()); |
| | | } |
| | | } |