Commit 71243df6 authored by jiaorz's avatar jiaorz

Merge branch 'jrz_dev' into base-modify

parents b79308f3 a4752a80
...@@ -3,6 +3,9 @@ package com.xxfc.platform.campsite.feign; ...@@ -3,6 +3,9 @@ package com.xxfc.platform.campsite.feign;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.GoodDataVO; import com.github.wxiaoqi.security.common.vo.GoodDataVO;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.campsite.vo.CampsiteShopDetailVo;
import com.xxfc.platform.campsite.vo.CampsiteShopPageVo;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -14,13 +17,31 @@ import java.util.List; ...@@ -14,13 +17,31 @@ import java.util.List;
* Created by ace on 2017/9/15. * Created by ace on 2017/9/15.
*/ */
//@FeignClient(value = "${auth.serviceId}",configuration = {}) //@FeignClient(value = "${auth.serviceId}",configuration = {})
@FeignClient("xx-campsite") @FeignClient(name = "xx-campsite",path = "/campsiteShop")
public interface CampsiteFeign { public interface CampsiteFeign {
@ApiOperation("首页营地列表") @ApiOperation("首页营地列表")
@GetMapping(value = "/campsiteShop/app/shopList") @GetMapping(value = "/app/shopList")
public List<GoodDataVO> goodList(@RequestParam(value = "page", defaultValue = "1") Integer page, List<GoodDataVO> goodList(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit",defaultValue = "4") Integer limit); @RequestParam(value = "limit", defaultValue = "4") Integer limit);
@GetMapping(value = "/campsiteShop/app/unauth/findRandomVehicle")
public ObjectRestResponse findRandomVehicle(@RequestParam(value = "number")Integer number); @GetMapping(value = "/app/unauth/findRandomVehicle")
ObjectRestResponse findRandomVehicle(@RequestParam(value = "number") Integer number);
@ApiOperation("分页查询营地列表")
@GetMapping("/app/unauth/shops")
ObjectRestResponse<PageDataVO<CampsiteShopPageVo>> findCampsiteShopPageByType(@RequestParam(value = "type", required = false) Integer type,
@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", required = false, defaultValue = "6") Integer pageSize);
/**
* @param longitude 经度
* @param latitude 纬度
* @return
*/
@ApiOperation("查询营地详情")
@GetMapping("/app/unauth/shop")
ObjectRestResponse<CampsiteShopDetailVo> findCampsiteShopDetailById(@RequestParam(value = "id") Integer id,
@RequestParam(value = "longitude", required = false) Double longitude,
@RequestParam(value = "latitude", required = false) Double latitude);
} }
...@@ -164,12 +164,14 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper, CampsiteShop> { ...@@ -164,12 +164,14 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper, CampsiteShop> {
} }
campsiteShopDetailVo.setTypeNames(shopTagDTOS == null ? Collections.EMPTY_LIST : shopTagDTOS.stream().map(CampsiteShopTagDTO::getName).collect(Collectors.toList())); campsiteShopDetailVo.setTypeNames(shopTagDTOS == null ? Collections.EMPTY_LIST : shopTagDTOS.stream().map(CampsiteShopTagDTO::getName).collect(Collectors.toList()));
//根据经纬度算距离 //根据经纬度算距离
if (campsiteShopDetailDTO.getLongitude() != null && campsiteShopDetailDTO.getLatitude() != null) { if(Objects.nonNull(latitude) && Objects.nonNull(longitude)) {
double distance = getDistance(campsiteShopDetailDTO.getLongitude(), campsiteShopDetailDTO.getLatitude(), longitude, latitude); if (campsiteShopDetailDTO.getLongitude() != null && campsiteShopDetailDTO.getLatitude() != null) {
if (log.isDebugEnabled()) { double distance = getDistance(campsiteShopDetailDTO.getLongitude(), campsiteShopDetailDTO.getLatitude(), longitude, latitude);
log.debug("根据店铺经度=【{}】,纬度=【{}】和自己所在位置的经度=【{}】,纬度=【{}】计算出的距离:【{}km】", campsiteShopDetailDTO.getLongitude(), campsiteShopDetailDTO.getLatitude(), longitude, latitude, distance); if (log.isDebugEnabled()) {
log.debug("根据店铺经度=【{}】,纬度=【{}】和自己所在位置的经度=【{}】,纬度=【{}】计算出的距离:【{}km】", campsiteShopDetailDTO.getLongitude(), campsiteShopDetailDTO.getLatitude(), longitude, latitude, distance);
}
campsiteShopDetailVo.setDistance(String.format("%.1f", distance));
} }
campsiteShopDetailVo.setDistance(String.format("%.1f", distance));
} }
campsiteValueOperations.set(String.format("%s%d", CAMSITE_DETAIL_CACHE_PREKEY, id), JSONObject.toJSONString(campsiteShopDetailVo)); campsiteValueOperations.set(String.format("%s%d", CAMSITE_DETAIL_CACHE_PREKEY, id), JSONObject.toJSONString(campsiteShopDetailVo));
return campsiteShopDetailVo; return campsiteShopDetailVo;
......
...@@ -48,7 +48,9 @@ public class CampsiteShopController extends BaseController<CampsiteShopBiz, Camp ...@@ -48,7 +48,9 @@ public class CampsiteShopController extends BaseController<CampsiteShopBiz, Camp
*/ */
@ApiOperation("查询营地详情") @ApiOperation("查询营地详情")
@GetMapping("/app/unauth/shop") @GetMapping("/app/unauth/shop")
public ObjectRestResponse<CampsiteShopDetailVo> findCampsiteShopDetailById(@RequestParam("id") Integer id, @RequestParam("longitude") Double longitude, @RequestParam("latitude") Double latitude) { public ObjectRestResponse<CampsiteShopDetailVo> findCampsiteShopDetailById(@RequestParam(value = "id") Integer id,
@RequestParam(value = "longitude",required = false) Double longitude,
@RequestParam(value = "latitude",required = false) Double latitude) {
CampsiteShopDetailVo campsiteShopDetailVo = getBaseBiz().findCampsiteShopDetailById(id, longitude, latitude); CampsiteShopDetailVo campsiteShopDetailVo = getBaseBiz().findCampsiteShopDetailById(id, longitude, latitude);
return ObjectRestResponse.succ(campsiteShopDetailVo); return ObjectRestResponse.succ(campsiteShopDetailVo);
} }
......
package com.xxfc.platform.uccn.dto;
import lombok.Data;
@Data
public class RandomListDto {
/**
* 列表类型 TypeEnum
*/
private Integer type;
/**
* 随机数量
*/
private Integer number;
/**
* 活动位置,1:欣欣官网 2:滴房车官网 0:无限制,
*/
private Integer location;
}
package com.xxfc.platform.uccn.vo;
import lombok.Data;
public enum TypeEnum {
VEHICLE(1, "车型"),
TOUR(2, "旅游"),
CAMPSITE(3, "营地"),
ACTIVITY(4, "活动");
private Integer code;
private String msg;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
TypeEnum(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public static TypeEnum getByValue(Integer value){
for(TypeEnum typeEnum : values()){
if (typeEnum.getCode() == value) {
return typeEnum;
}
}
return null;
}
}
...@@ -33,6 +33,18 @@ ...@@ -33,6 +33,18 @@
<version>2.0-SNAPSHOT</version> <version>2.0-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-tour-api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-campsite-api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>xx-uccn</finalName> <finalName>xx-uccn</finalName>
......
package com.xxfc.platform.uccn.biz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.xxfc.platform.campsite.feign.CampsiteFeign;
import com.xxfc.platform.tour.feign.TourFeign;
import com.xxfc.platform.uccn.vo.TypeEnum;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 获取随机数量的车型、旅游、营地、活动
*/
@Service
@Slf4j
public class RandomListBiz {
@Autowired
VehicleFeign vehicleFeign;
@Autowired
TourFeign tourFeign;
@Autowired
CampsiteFeign campsiteFeign;
@Autowired
SummitActivityBiz summitActivityBiz;
/**
* @param type 类型
* @param number 随机数,默认是2
* @return
*/
public ObjectRestResponse getRandomList(Integer type, Integer number, Integer location) {
if(type != null) {
number = number == null ? 2 : number;
switch (TypeEnum.getByValue(type)) {
case VEHICLE:
return vehicleFeign.findRandomVehicle(number);
case TOUR:
return tourFeign.findRandomVehicle(number);
case CAMPSITE:
return campsiteFeign.findRandomVehicle(number);
case ACTIVITY:
return ObjectRestResponse.succ(summitActivityBiz.getHostWithSummitActivity(number, location));
}
}
return ObjectRestResponse.succ();
}
}
package com.xxfc.platform.uccn.rest;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.campsite.feign.CampsiteFeign;
import com.xxfc.platform.campsite.vo.CampsiteShopDetailVo;
import com.xxfc.platform.campsite.vo.CampsiteShopPageVo;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/28 10:05
*/
@RestController
@RequestMapping("/app/unauth/campsite")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CampsiteUccnController {
private final CampsiteFeign campsiteFeign;
@ApiOperation("分页查询营地列表")
@GetMapping("/shops")
public ObjectRestResponse<PageDataVO<CampsiteShopPageVo>> findCampsiteShopPageByType(@RequestParam(value = "type", required = false) Integer type,
@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", required = false, defaultValue = "6") Integer pageSize) {
return campsiteFeign.findCampsiteShopPageByType(type, pageNo, pageSize);
}
/**
* @param longitude 经度
* @param latitude 纬度
* @return
*/
@ApiOperation("查询营地详情")
@GetMapping("/shop")
public ObjectRestResponse<CampsiteShopDetailVo> findCampsiteShopDetailById(@RequestParam(value = "id") Integer id,
@RequestParam(value = "longitude", required = false) Double longitude,
@RequestParam(value = "latitude", required = false) Double latitude) {
return campsiteFeign.findCampsiteShopDetailById(id, longitude, latitude);
}
}
...@@ -20,10 +20,7 @@ import org.springframework.stereotype.Service; ...@@ -20,10 +20,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service @Service
public class VehicleActiveService { public class VehicleActiveService {
...@@ -177,7 +174,7 @@ public class VehicleActiveService { ...@@ -177,7 +174,7 @@ public class VehicleActiveService {
stringBuilder.append(" 使用人电话:"); stringBuilder.append(" 使用人电话:");
stringBuilder.append(vehicleBookRecordVos.get(0).getVehicleUserPhone()); stringBuilder.append(vehicleBookRecordVos.get(0).getVehicleUserPhone());
} else { } else {
stringBuilder.append("请联系管理员修改车辆状态为正常状态"); stringBuilder.append(", 请联系管理员修改车辆状态为正常状态");
} }
return stringBuilder.toString(); return stringBuilder.toString();
} }
...@@ -311,6 +308,14 @@ public class VehicleActiveService { ...@@ -311,6 +308,14 @@ public class VehicleActiveService {
param.put("vehicleId", vehicleBookRecord.getVehicleId()); param.put("vehicleId", vehicleBookRecord.getVehicleId());
param.put("bookedEndDate", vehicleBookRecord.getBookStartDate()); param.put("bookedEndDate", vehicleBookRecord.getBookStartDate());
List<VehicleBookRecordVo> list = vehicleBookRecordBiz.selectByVehicleIdAndTime(param); List<VehicleBookRecordVo> list = vehicleBookRecordBiz.selectByVehicleIdAndTime(param);
if(list != null && list.size() > 0) {
Iterator<VehicleBookRecordVo> iterator = list.iterator();
while (iterator.hasNext()) {
if(iterator.next().getVehicleDepartureLogVo() == null && iterator.next().getBookEndDate().after(new Date())) {
iterator.remove();
}
}
}
if(!(startDate.minusDays(1).compareTo(DateTime.now()) <= 0 && DateTime.now().compareTo(endDate) <= 0 && vehicleBookRecord.getStatus() == VehicleBookRecordStatus.APPROVE.getCode() && (list == null || list.size() <= 0))) { if(!(startDate.minusDays(1).compareTo(DateTime.now()) <= 0 && DateTime.now().compareTo(endDate) <= 0 && vehicleBookRecord.getStatus() == VehicleBookRecordStatus.APPROVE.getCode() && (list == null || list.size() <= 0))) {
throw new BaseException(ResCode.VEHICLE_DEPARTURE_DATE_IS_NOT_ABLED.getDesc(), throw new BaseException(ResCode.VEHICLE_DEPARTURE_DATE_IS_NOT_ABLED.getDesc(),
ResCode.VEHICLE_DEPARTURE_DATE_IS_NOT_ABLED.getCode()); ResCode.VEHICLE_DEPARTURE_DATE_IS_NOT_ABLED.getCode());
......
...@@ -823,7 +823,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -823,7 +823,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
stringBuilder.append(" 使用人电话:"); stringBuilder.append(" 使用人电话:");
stringBuilder.append(vehicleBookRecordVos.get(0).getVehicleUserPhone()); stringBuilder.append(vehicleBookRecordVos.get(0).getVehicleUserPhone());
} else { } else {
stringBuilder.append("请联系管理员修改车辆状态为正常状态"); stringBuilder.append(", 请联系管理员修改车辆状态为正常状态");
} }
return stringBuilder.toString(); return stringBuilder.toString();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment