|
@@ -29,6 +29,8 @@ import com.pj.project.tb_car.TbCar;
|
|
|
import com.pj.project.tb_car.TbCarService;
|
|
|
import com.pj.project.tb_car_no_color.TbCarNoColor;
|
|
|
import com.pj.project.tb_car_no_color.TbCarNoColorService;
|
|
|
+import com.pj.project.tb_goods.TbGoods;
|
|
|
+import com.pj.project.tb_goods.TbGoodsService;
|
|
|
import com.pj.project4sp.uploadfile.UploadConfig;
|
|
|
import com.pj.utils.cache.RedisUtil;
|
|
|
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
|
|
@@ -75,6 +77,9 @@ public class OpenService {
|
|
|
@Resource
|
|
|
TbCarNoColorService tbCarNoColorService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private TbGoodsService tbGoodsService;
|
|
|
+
|
|
|
|
|
|
private final List<String> CAR_LIST = StrUtil.splitTrim("浙,粤,京,津,冀,晋,蒙,辽,黑,沪,吉,苏,皖,赣,鲁,豫,鄂,湘,桂,琼,渝,川,贵,云,藏, 陕, 甘, 青, 宁", ",");
|
|
|
|
|
@@ -153,28 +158,19 @@ public class OpenService {
|
|
|
IMAGE_CACHE.put(carNo, image);
|
|
|
}
|
|
|
Date now = new Date();
|
|
|
- Integer businessType = tbBusinessCar.getBusinessType();
|
|
|
//判断是否蓝色车牌===免停车费
|
|
|
if (StrUtil.isNotEmpty(tbBusinessCar.getColor())) {
|
|
|
List<TbCarNoColor> freeList = tbCarNoColorService.getFreeColor();
|
|
|
List<String> colorList = freeList.stream().map(f -> f.getCarNoColor().substring(0, 1)).collect(Collectors.toList());
|
|
|
String color = tbBusinessCar.getColor().substring(0, 1);
|
|
|
if (colorList.contains(color)) {
|
|
|
- tbBusinessCar.setRealOutTime(now).setTimeUpdate(now).setOutChannel(channel);
|
|
|
- tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
- CoverBase64ToUrl(image, tbBusinessCar.getId(), carNo, 2);
|
|
|
- RedisUtil.del(channel);
|
|
|
- log.error("请求返回【放行】:{}", carNo);
|
|
|
+ freeOut(tbBusinessCar,now,channel,image);
|
|
|
return ResultJson.success();
|
|
|
}
|
|
|
}
|
|
|
//是否行政车辆=====
|
|
|
if (checkFree(carNo, 2, now)) {
|
|
|
- tbBusinessCar.setRealOutTime(now).setTimeUpdate(now).setOutChannel(channel);
|
|
|
- tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
- CoverBase64ToUrl(image, tbBusinessCar.getId(), carNo, 2);
|
|
|
- RedisUtil.del(channel);
|
|
|
- log.error("请求返回【放行】:{}", carNo);
|
|
|
+ freeOut(tbBusinessCar,now,channel,image);
|
|
|
return ResultJson.success();
|
|
|
}
|
|
|
if (tbBusinessCar.getIsLock() == 1) {
|
|
@@ -182,34 +178,65 @@ public class OpenService {
|
|
|
log.error("请求返回:车辆已锁定:{}", carNo);
|
|
|
return ResultJson.error("车辆已锁定");
|
|
|
}
|
|
|
- String carNoStr = carNo.substring(0, 1);
|
|
|
- Date inTime = tbBusinessCar.getRealInTime();
|
|
|
- if (tbBusinessCar.getPay() == 1 && tbBusinessCar.getRealOutTime() == null && tbBusinessCar.getPayTime() != null) {
|
|
|
- inTime = tbBusinessCar.getPayTime();
|
|
|
- }
|
|
|
- BigDecimal price = tbBusinessService.calculationPartMoney(inTime, now);
|
|
|
- //越南车牌,整车业务免停车费
|
|
|
- if (!CAR_LIST.contains(carNoStr) && TbBusiness.BusinessType.HOLD_CAR.getCode().equals(businessType)) {
|
|
|
- price = new BigDecimal("0");
|
|
|
- }
|
|
|
- double dif = price.doubleValue();
|
|
|
- if (dif > 0) {
|
|
|
- RedisUtil.setByMINUTES(channel, carNo, 1);
|
|
|
- log.error("请求返回:请缴停车费:{},{}元", carNo, dif);
|
|
|
- return ResultJson.error("请缴停车费" + dif + "元");
|
|
|
- }
|
|
|
- //无业务费用车辆===
|
|
|
- if (TbBusiness.BusinessType.NO_BUSINESS.getCode().equals(businessType)) {
|
|
|
- tbBusinessCar.setRealOutTime(now).setOutChannel(channel).setTimeUpdate(now);
|
|
|
- tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
- CoverBase64ToUrl(image, tbBusinessCar.getId(), carNo, 2);
|
|
|
- RedisUtil.del(channel);
|
|
|
- log.error("请求返回【放行】:{}", carNo);
|
|
|
- return ResultJson.success();
|
|
|
+ String businessCarId = tbBusinessCar.getId();
|
|
|
+ List<TbBusiness> businessList = tbBusinessService.findOtherBusinessByCarId(businessCarId);
|
|
|
+ if (businessList.isEmpty()) {//无业务车辆===>计算停车费
|
|
|
+ //如果已经支付过,则从支付时间算起,重新计算停车费
|
|
|
+ double dif=caulatePrice(tbBusinessCar,now);
|
|
|
+ if (dif > 0) {
|
|
|
+ RedisUtil.setByMINUTES(channel, carNo, 1);
|
|
|
+ log.error("请求返回:请缴停车费:{},{}元", carNo, dif);
|
|
|
+ return ResultJson.error("请缴停车费" + dif + "元");
|
|
|
+ }else {
|
|
|
+ freeOut(tbBusinessCar,now,channel,image);
|
|
|
+ return ResultJson.success();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //有业务的车
|
|
|
+ //1、分越南车和中国车
|
|
|
+ String carNoPrefix = StrUtil.sub(carNo, 0, 1);
|
|
|
+ //中国车是否收费
|
|
|
+ if (CAR_LIST.contains(carNoPrefix)){
|
|
|
+ boolean chinaCarPay = businessList.stream().anyMatch(tbBusiness -> {
|
|
|
+ TbGoods tbGoods = tbGoodsService.getById(tbBusiness.getGoodsId());
|
|
|
+ return tbGoods.getChinaCarPay() == 1;
|
|
|
+ });
|
|
|
+ if (!chinaCarPay){
|
|
|
+ freeOut(tbBusinessCar,now,channel,image);
|
|
|
+ return ResultJson.success();
|
|
|
+ }else {
|
|
|
+ double dif=caulatePrice(tbBusinessCar,now);
|
|
|
+ if (dif > 0) {
|
|
|
+ RedisUtil.setByMINUTES(channel, carNo, 1);
|
|
|
+ log.error("请求返回:请缴停车费:{},{}元", carNo, dif);
|
|
|
+ return ResultJson.error("请缴停车费" + dif + "元");
|
|
|
+ }else {
|
|
|
+ freeOut(tbBusinessCar,now,channel,image);
|
|
|
+ return ResultJson.success();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {//越南车
|
|
|
+ boolean vietnamCarPay = businessList.stream().anyMatch(tbBusiness -> {
|
|
|
+ TbGoods tbGoods = tbGoodsService.getById(tbBusiness.getGoodsId());
|
|
|
+ return tbGoods.getVietnamCarPay() == 1;
|
|
|
+ });
|
|
|
+ if (!vietnamCarPay){
|
|
|
+ freeOut(tbBusinessCar,now,channel,image);
|
|
|
+ return ResultJson.success();
|
|
|
+ }else {
|
|
|
+ double dif=caulatePrice(tbBusinessCar,now);
|
|
|
+ if (dif > 0) {
|
|
|
+ RedisUtil.setByMINUTES(channel, carNo, 1);
|
|
|
+ log.error("请求返回:请缴停车费:{},{}元", carNo, dif);
|
|
|
+ return ResultJson.error("请缴停车费" + dif + "元");
|
|
|
+ }else {
|
|
|
+ freeOut(tbBusinessCar,now,channel,image);
|
|
|
+ return ResultJson.success();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
//============业务费计算是否交完
|
|
|
- String businessId = tbBusinessCar.getBusinessId();
|
|
|
List<TbBusinessItem> items;
|
|
|
if (TbBusiness.BusinessType.HOLD_CAR.getCode().equals(businessType)) {
|
|
|
items = tbBusinessItemService.findByBusinessId(businessId);
|
|
@@ -230,6 +257,24 @@ public class OpenService {
|
|
|
return ResultJson.success();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private double caulatePrice(TbBusinessCar tbBusinessCar,Date now){
|
|
|
+ Date inTime=tbBusinessCar.getRealInTime();
|
|
|
+ if (tbBusinessCar.getPay() == 1 && tbBusinessCar.getRealOutTime() == null && tbBusinessCar.getPayTime() != null) {
|
|
|
+ inTime = tbBusinessCar.getPayTime();
|
|
|
+ }
|
|
|
+ BigDecimal price = tbBusinessService.calculationPartMoney(inTime, now);
|
|
|
+ return price.doubleValue();
|
|
|
+ }
|
|
|
+ private void freeOut(TbBusinessCar tbBusinessCar,Date now,String outChannel,String base64Image){
|
|
|
+ tbBusinessCar.setRealOutTime(now).setTimeUpdate(now).setOutChannel(outChannel);
|
|
|
+ tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
+ String carNo=tbBusinessCar.getCarNo();
|
|
|
+ CoverBase64ToUrl(base64Image, tbBusinessCar.getId(), carNo, 2);
|
|
|
+ RedisUtil.del(outChannel);
|
|
|
+ log.error("请求返回【放行】:{}", carNo);
|
|
|
+ }
|
|
|
+
|
|
|
private boolean checkFree(String carNo, int inOrOut, Date now) {
|
|
|
TbCar tbCar = tbCarService.findByCardNo(carNo);
|
|
|
if (tbCar != null) {
|