| | |
| | | import com.ruoyi.shop.service.task.ShopTaskService; |
| | | import com.ruoyi.shop.util.HuiFuTianXiaUtil; |
| | | import com.ruoyi.shop.util.WechatPayUtils; |
| | | import com.ruoyi.shop.util.map.MapUtil; |
| | | import com.ruoyi.shop.util.map.vo.TencentDistanceMatrix; |
| | | import com.ruoyi.shop.util.map.vo.TencentDistanceMatrixElements; |
| | | import com.ruoyi.system.api.constant.AppErrorConstant; |
| | | import com.ruoyi.system.api.constant.SecurityConstant; |
| | | import com.ruoyi.system.api.domain.dto.*; |
| | |
| | | //获取绑定商户 |
| | | shop = this.getById(member.getRelationShopId()); |
| | | }else if(StringUtils.isNotBlank(appNearbyShopDto.getLatitude())&&StringUtils.isNotBlank(appNearbyShopDto.getLongitude())){ |
| | | AppNearShopVo appNearShopVo = shopMapper.getNearbyShop(appNearbyShopDto); |
| | | shop = this.getById(appNearShopVo.getShopId()); |
| | | List<AppNearShopVo> appNearShopVos = shopMapper.getNearbyShops(appNearbyShopDto); |
| | | if(appNearShopVos.size() > 0){ |
| | | StringBuffer to = new StringBuffer(); |
| | | for (AppNearShopVo appNearShopVo : appNearShopVos) { |
| | | to.append(appNearShopVo.getLatitude() + "," + appNearShopVo.getLongitude() + ";"); |
| | | } |
| | | String form = appNearbyShopDto.getLatitude() + "," + appNearbyShopDto.getLongitude(); |
| | | R<List<TencentDistanceMatrix>> r = MapUtil.tencentDistanceMatrix(form, to.substring(0, to.length() - 1), "walking"); |
| | | if(r.getCode() != 200){ |
| | | throw new ServiceException(r.getMsg()); |
| | | } |
| | | List<TencentDistanceMatrix> data = r.getData(); |
| | | //存储最短距离 |
| | | BigDecimal dis = new BigDecimal(0); |
| | | AppNearShopVo appNearShopVo = null; |
| | | List<TencentDistanceMatrixElements> elements = data.get(0).getElements(); |
| | | for (int i = 0; i < elements.size(); i++) { |
| | | TencentDistanceMatrixElements matrix = elements.get(i); |
| | | if(dis.compareTo(BigDecimal.ZERO) == 0 || dis.compareTo(new BigDecimal(matrix.getDistance())) > 0){ |
| | | dis = new BigDecimal(matrix.getDistance()); |
| | | appNearShopVo = appNearShopVos.get(i); |
| | | } |
| | | } |
| | | shop = this.getById(appNearShopVo.getShopId()); |
| | | } |
| | | }else{ |
| | | return appNearbyShopVo; |
| | | } |