zhangyuewww 1 سال پیش
والد
کامیت
776469beae

+ 1 - 0
unimall-admin-api/src/main/java/com/iotechn/unimall/admin/api/tourism/IProductManagementService.java

@@ -46,6 +46,7 @@ public interface IProductManagementService{
 							@HttpParam(name = "userLongitude", type = HttpParamType.COMMON, description = "用户经度") String userLongitude,
 							@HttpParam(name = "userLatitude", type = HttpParamType.COMMON, description = "用户纬度") String userLatitude,
 							@HttpParam(name = "place", type = HttpParamType.COMMON, description = "用户定位的地址") String place,
+							@HttpParam(name = "myFlag", type = HttpParamType.COMMON, description = "") String myFlag,
 							@HttpParam(name = "searchKeyWord", type = HttpParamType.COMMON, description = "") String searchKeyWord,
 							@HttpParam(name = "gmtCreate", type = HttpParamType.COMMON, description = "") Date gmtCreate,
 							@HttpParam(name = "gmtUpdate", type = HttpParamType.COMMON, description = "") Date gmtUpdate,

+ 61 - 59
unimall-admin-api/src/main/java/com/iotechn/unimall/admin/api/tourism/impl/ProductManagementServiceImpl.java

@@ -57,7 +57,7 @@ public class ProductManagementServiceImpl implements IProductManagementService{
 	}
 
 	@Override
-	public Page<ProductManagement> list(Long commonId,String mainBody,String shopNames,String coverImage,String province,String city,String area,String location,String detailedAddress,String serviceDescription,String nickname,String phone,String realname,String personNo,String personImageFront,String personImageBack,String businessLicense,String status,String userLongitude,String userLatitude,String place,String searchKeyWord,Date gmtCreate,Date gmtUpdate,Long deleteFlag, Integer page, Integer limit)throws ServiceException {
+	public Page<ProductManagement> list(Long commonId,String mainBody,String shopNames,String coverImage,String province,String city,String area,String location,String detailedAddress,String serviceDescription,String nickname,String phone,String realname,String personNo,String personImageFront,String personImageBack,String businessLicense,String status,String userLongitude,String userLatitude,String place,String myFlag,String searchKeyWord,Date gmtCreate,Date gmtUpdate,Long deleteFlag, Integer page, Integer limit)throws ServiceException {
 		Wrapper<ProductManagement> wrapper = new EntityWrapper<ProductManagement>();
 														if (!StringUtils.isEmpty(commonId)) {
 					wrapper.eq("common_id", commonId);
@@ -125,70 +125,72 @@ public class ProductManagementServiceImpl implements IProductManagementService{
 				}
 					wrapper.eq("delete_flag", 0);
 		List<ProductManagement> list = productManagementMapper.selectPage(new RowBounds((page - 1) * limit, limit), wrapper);
-		if (!CollectionUtils.isEmpty(list)){
-			for (ProductManagement productManagement:list){
-				String[] parts=productManagement.getLocation().split(",");
-				String latitude=parts[0];
-				String longitude=parts[1];
-				//根据用户经纬度求距离
-				if (!StringUtils.isEmpty(userLatitude) && !StringUtils.isEmpty(userLongitude)) {
-					// 参数解释:lng:经度,lat:维度。KEY:高德地图key
-					String urlString = "https://restapi.amap.com/v3/direction/driving?origin=" + userLongitude + "," +userLatitude + "&destination=" + longitude + "," + latitude  + "&key=" + KEY ;
-					//输入流的缓冲
-					StringBuffer sb = new StringBuffer();
-					try {
-						URL url = new URL(urlString);
-						BufferedReader in =  new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"));
-						String line;
-						// 获取地址解析结果
-						while ((line = in.readLine()) != null) {
-							sb.append(line);
+		if (!"1".equals(myFlag)) {
+			if (!CollectionUtils.isEmpty(list)) {
+				for (ProductManagement productManagement : list) {
+					String[] parts = productManagement.getLocation().split(",");
+					String latitude = parts[0];
+					String longitude = parts[1];
+					//根据用户经纬度求距离
+					if (!StringUtils.isEmpty(userLatitude) && !StringUtils.isEmpty(userLongitude)) {
+						// 参数解释:lng:经度,lat:维度。KEY:高德地图key
+						String urlString = "https://restapi.amap.com/v3/direction/driving?origin=" + userLongitude + "," + userLatitude + "&destination=" + longitude + "," + latitude + "&key=" + KEY;
+						//输入流的缓冲
+						StringBuffer sb = new StringBuffer();
+						try {
+							URL url = new URL(urlString);
+							BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"));
+							String line;
+							// 获取地址解析结果
+							while ((line = in.readLine()) != null) {
+								sb.append(line);
+							}
+							in.close();
+						} catch (Exception e) {
+							e.getMessage();
 						}
-						in.close();
-					} catch (Exception e) {
-						e.getMessage();
-					}
-					String result = sb.toString();
-					JSONObject jsonObj = JSONObject.parseObject(result);
-					JSONObject obj = jsonObj.getJSONObject("route");
-					JSONArray jsonArray = obj.getJSONArray("paths");
-					if(jsonArray != null&&jsonArray.size() > 0){
-						String distance=JSONObject.parseObject(jsonArray.get(0).toString()).getString("distance");
-						productManagement.setDistance(Double.valueOf(distance));
-					}
-				}
-				//根据用户定位的位置求距离
-				else if (!StringUtils.isEmpty(place)) {
-					//根据装货城市获取经纬度
-					String str = EntCoordUtil.getCoordinate(place);
-					// 参数解释:lng:经度,lat:维度。KEY:高德地图key
-					String urlString = "https://restapi.amap.com/v3/direction/driving?origin=" + str + "&destination=" + longitude + "," + latitude  + "&key=" + KEY ;
-					//输入流的缓冲
-					StringBuffer sb = new StringBuffer();
-					try {
-						URL url = new URL(urlString);
-						BufferedReader in =  new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"));
-						String line;
-						// 获取地址解析结果
-						while ((line = in.readLine()) != null) {
-							sb.append(line);
+						String result = sb.toString();
+						JSONObject jsonObj = JSONObject.parseObject(result);
+						JSONObject obj = jsonObj.getJSONObject("route");
+						JSONArray jsonArray = obj.getJSONArray("paths");
+						if (jsonArray != null && jsonArray.size() > 0) {
+							String distance = JSONObject.parseObject(jsonArray.get(0).toString()).getString("distance");
+							productManagement.setDistance(Double.valueOf(distance));
 						}
-						in.close();
-					} catch (Exception e) {
-						e.getMessage();
 					}
-					String result = sb.toString();
-					JSONObject jsonObj = JSONObject.parseObject(result);
-					JSONObject obj = jsonObj.getJSONObject("route");
-					JSONArray jsonArray = obj.getJSONArray("paths");
-					if(jsonArray != null&&jsonArray.size() > 0){
-						String distance=JSONObject.parseObject(jsonArray.get(0).toString()).getString("distance");
-						productManagement.setDistance(Double.valueOf(distance));
+					//根据用户定位的位置求距离
+					else if (!StringUtils.isEmpty(place)) {
+						//根据装货城市获取经纬度
+						String str = EntCoordUtil.getCoordinate(place);
+						// 参数解释:lng:经度,lat:维度。KEY:高德地图key
+						String urlString = "https://restapi.amap.com/v3/direction/driving?origin=" + str + "&destination=" + longitude + "," + latitude + "&key=" + KEY;
+						//输入流的缓冲
+						StringBuffer sb = new StringBuffer();
+						try {
+							URL url = new URL(urlString);
+							BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"));
+							String line;
+							// 获取地址解析结果
+							while ((line = in.readLine()) != null) {
+								sb.append(line);
+							}
+							in.close();
+						} catch (Exception e) {
+							e.getMessage();
+						}
+						String result = sb.toString();
+						JSONObject jsonObj = JSONObject.parseObject(result);
+						JSONObject obj = jsonObj.getJSONObject("route");
+						JSONArray jsonArray = obj.getJSONArray("paths");
+						if (jsonArray != null && jsonArray.size() > 0) {
+							String distance = JSONObject.parseObject(jsonArray.get(0).toString()).getString("distance");
+							productManagement.setDistance(Double.valueOf(distance));
+						}
 					}
 				}
+				//按权重降序 距离升序排序
+				list.sort(Comparator.comparing(ProductManagement::getWeightSort).reversed().thenComparing(ProductManagement::getDistance));
 			}
-			//按权重降序 距离升序排序
-			list.sort(Comparator.comparing(ProductManagement::getWeightSort).reversed().thenComparing(ProductManagement::getDistance));
 		}
 		Integer count = productManagementMapper.selectCount(wrapper);
 		return new Page<ProductManagement>(list, page, limit, count);

+ 5 - 0
unimall-data/src/main/java/com/iotechn/unimall/data/domain/ProductManagement.java

@@ -162,6 +162,11 @@ public class ProductManagement extends SuperDO{
     private String place;
     @TableField(exist = false)
     private String searchKeyWord;
+    /**
+     * 我的发布列表标识
+     */
+    @TableField(exist = false)
+    private String myFlag;
 
     @Override
     public String toString() {