Commit a04dbc86 authored by unset's avatar unset

Merge remote-tracking branch 'origin/dev-chw' into dev-chw

parents 953f42e8 179c53b6
...@@ -1664,10 +1664,11 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -1664,10 +1664,11 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
vehicleDaysPrice.setPriceJson(jsonObject.getString("priceList")); vehicleDaysPrice.setPriceJson(jsonObject.getString("priceList"));
vehicleDaysPrice.setStatus(jsonObject.getInteger("status")); vehicleDaysPrice.setStatus(jsonObject.getInteger("status"));
vehicleDaysPriceBiz.addOrUpd(vehicleDaysPrice); vehicleDaysPriceBiz.addOrUpd(vehicleDaysPrice);
BigDecimal vehiclePrice = vehicleDaysPriceBiz.getVehiclePrice(vehicleId, 0); Vehicle vehiclePrice = vehicleDaysPriceBiz.getVehiclePrice(vehicleId, 0);
if (vehiclePrice != null && vehiclePrice.compareTo(BigDecimal.ZERO) > 0){ if (vehiclePrice != null ){
Vehicle vehicle = new Vehicle(); Vehicle vehicle = new Vehicle();
vehicle.setPrice(vehiclePrice); vehicle.setPrice(vehiclePrice.getPrice());
vehicle.setHolidayPrice(vehiclePrice.getHolidayPrice());
vehicle.setId(vehicleId); vehicle.setId(vehicleId);
updateSelectiveById(vehicle); updateSelectiveById(vehicle);
} }
......
...@@ -63,6 +63,17 @@ public class VehicleDaysPriceBiz extends BaseBiz<VehicleDaysPriceMapper, Vehicle ...@@ -63,6 +63,17 @@ public class VehicleDaysPriceBiz extends BaseBiz<VehicleDaysPriceMapper, Vehicle
} }
public VehicleDaysPrice getInfoV2(String vehicleId){
Example example = new Example(VehicleDaysPrice.class);
example.createCriteria().andEqualTo("vehicleId",vehicleId).andEqualTo("isDel",0);
List<VehicleDaysPrice> list = selectByExample(example);
if (list.size() > 0){
return list.get(0);
}
return null;
}
public List<VehicleDaysPriceVo> getListByVehicleId(String vehicleId){ public List<VehicleDaysPriceVo> getListByVehicleId(String vehicleId){
VehicleDaysPrice vehicleDaysPrice = getInfo(vehicleId); VehicleDaysPrice vehicleDaysPrice = getInfo(vehicleId);
List<VehicleDaysPriceVo> priceVos = null; List<VehicleDaysPriceVo> priceVos = null;
...@@ -72,25 +83,29 @@ public class VehicleDaysPriceBiz extends BaseBiz<VehicleDaysPriceMapper, Vehicle ...@@ -72,25 +83,29 @@ public class VehicleDaysPriceBiz extends BaseBiz<VehicleDaysPriceMapper, Vehicle
return priceVos; return priceVos;
} }
public BigDecimal getVehiclePrice(String vehicleId,Integer days){ public Vehicle getVehiclePrice(String vehicleId,Integer days){
Vehicle vehicle = vehicleBiz.selectById(vehicleId);
List<VehicleDaysPriceVo> priceVos = getListByVehicleId(vehicleId); List<VehicleDaysPriceVo> priceVos = getListByVehicleId(vehicleId);
BigDecimal price = BigDecimal.ZERO; BigDecimal price = vehicle.getPrice();
BigDecimal maxPrice = vehicle.getHolidayPrice();
if (priceVos != null && priceVos.size() > 0){ if (priceVos != null && priceVos.size() > 0){
VehicleDaysPriceVo vehicleDaysPriceVo; VehicleDaysPriceVo vehicleDaysPriceVo;
VehicleDaysPriceVo maxVehicleDaysPriceVo;
if (days == null || days == 0){ if (days == null || days == 0){
vehicleDaysPriceVo = priceVos.stream().min(Comparator.comparing(VehicleDaysPriceVo::getPrice)).get(); vehicleDaysPriceVo = priceVos.stream().min(Comparator.comparing(VehicleDaysPriceVo::getPrice)).get();
maxVehicleDaysPriceVo = priceVos.stream().max(Comparator.comparing(VehicleDaysPriceVo::getPrice)).get();
}else { }else {
vehicleDaysPriceVo = priceVos.stream().filter(x -> x.getStartDay() <= days && (x.getEndDay() == -1 || x.getEndDay() >= days)).min(Comparator.comparing(VehicleDaysPriceVo::getPrice)).get(); vehicleDaysPriceVo = priceVos.stream().filter(x -> x.getStartDay() <= days && (x.getEndDay() == -1 || x.getEndDay() >= days)).min(Comparator.comparing(VehicleDaysPriceVo::getPrice)).get();
maxVehicleDaysPriceVo = priceVos.stream().filter(x -> x.getStartDay() <= days && (x.getEndDay() == -1 || x.getEndDay() >= days)).max(Comparator.comparing(VehicleDaysPriceVo::getPrice)).get();
} }
if (vehicleDaysPriceVo != null ) if (vehicleDaysPriceVo != null )
price = vehicleDaysPriceVo.getPrice(); price = vehicleDaysPriceVo.getPrice();
if (maxVehicleDaysPriceVo != null )
maxPrice = maxVehicleDaysPriceVo.getPrice();
} }
if (price.compareTo(BigDecimal.ZERO) == 0 ){ vehicle.setPrice(price);
Vehicle vehicle = vehicleBiz.selectById(vehicleId); vehicle.setHolidayPrice(maxPrice);
if (vehicle != null) return vehicle;
price = vehicle.getPrice();
}
return price;
} }
......
...@@ -6,12 +6,15 @@ import com.github.wxiaoqi.security.common.util.process.ResultCode; ...@@ -6,12 +6,15 @@ import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.vehicle.aop.GlobalLog; import com.xxfc.platform.vehicle.aop.GlobalLog;
import com.xxfc.platform.vehicle.biz.VehicleApplyBiz; import com.xxfc.platform.vehicle.biz.VehicleApplyBiz;
import com.xxfc.platform.vehicle.biz.VehicleBiz; import com.xxfc.platform.vehicle.biz.VehicleBiz;
import com.xxfc.platform.vehicle.biz.VehicleDaysPriceBiz;
import com.xxfc.platform.vehicle.entity.Vehicle; import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.entity.VehicleApply;
import com.xxfc.platform.vehicle.pojo.dto.VehicleFindDTO; import com.xxfc.platform.vehicle.pojo.dto.VehicleFindDTO;
import com.xxfc.platform.vehicle.pojo.vo.VehicleVO; import com.xxfc.platform.vehicle.pojo.vo.VehicleVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
...@@ -26,6 +29,10 @@ import java.util.List; ...@@ -26,6 +29,10 @@ import java.util.List;
public class AppVehicleController extends BaseController<VehicleBiz> { public class AppVehicleController extends BaseController<VehicleBiz> {
@Autowired
VehicleDaysPriceBiz vehicleDaysPriceBiz;
...@@ -94,6 +101,23 @@ public class AppVehicleController extends BaseController<VehicleBiz> { ...@@ -94,6 +101,23 @@ public class AppVehicleController extends BaseController<VehicleBiz> {
@PostMapping("setDaysPrice")
@ApiModelProperty("设置价格")
public ObjectRestResponse setDaysPrice(@RequestBody VehicleApply vehicle) {
baseBiz.updVehicleDaysPrice(vehicle);
return ObjectRestResponse.succ();
}
@GetMapping("daysPriceInfo")
@ApiModelProperty("商品详情")
public ObjectRestResponse info(@RequestParam(value = "vehicleId")String vehicleId) {
return ObjectRestResponse.succ(vehicleDaysPriceBiz.getInfoV2(vehicleId));
}
......
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