|
@@ -31,6 +31,7 @@ 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.global.BusinessException;
|
|
|
import com.pj.project4sp.uploadfile.UploadConfig;
|
|
|
import com.pj.utils.cache.RedisUtil;
|
|
|
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
|
|
@@ -164,13 +165,13 @@ public class OpenService {
|
|
|
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)) {
|
|
|
- freeOut(tbBusinessCar,now,channel,image);
|
|
|
+ freeOut(tbBusinessCar, now, channel, image);
|
|
|
return ResultJson.success();
|
|
|
}
|
|
|
}
|
|
|
//是否行政车辆=====
|
|
|
if (checkFree(carNo, 2, now)) {
|
|
|
- freeOut(tbBusinessCar,now,channel,image);
|
|
|
+ freeOut(tbBusinessCar, now, channel, image);
|
|
|
return ResultJson.success();
|
|
|
}
|
|
|
if (tbBusinessCar.getIsLock() == 1) {
|
|
@@ -179,97 +180,92 @@ public class OpenService {
|
|
|
return ResultJson.error("车辆已锁定");
|
|
|
}
|
|
|
String businessCarId = tbBusinessCar.getId();
|
|
|
+ String carNoPrefix = StrUtil.sub(carNo, 0, 1);
|
|
|
List<TbBusiness> businessList = tbBusinessService.findOtherBusinessByCarId(businessCarId);
|
|
|
if (businessList.isEmpty()) {//无业务车辆===>计算停车费
|
|
|
//如果已经支付过,则从支付时间算起,重新计算停车费
|
|
|
- double dif=caulatePrice(tbBusinessCar,now);
|
|
|
+ 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);
|
|
|
+ } else {
|
|
|
+ freeOut(tbBusinessCar, now, channel, image);
|
|
|
return ResultJson.success();
|
|
|
}
|
|
|
} else {
|
|
|
//有业务的车
|
|
|
//1、分越南车和中国车
|
|
|
- String carNoPrefix = StrUtil.sub(carNo, 0, 1);
|
|
|
//中国车是否收费
|
|
|
- if (CAR_LIST.contains(carNoPrefix)){
|
|
|
+ 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 (chinaCarPay) {
|
|
|
+ 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 {//越南车
|
|
|
+ } 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 (vietnamCarPay) {
|
|
|
+ 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();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//============业务费计算是否交完
|
|
|
- List<TbBusinessItem> items;
|
|
|
- if (TbBusiness.BusinessType.HOLD_CAR.getCode().equals(businessType)) {
|
|
|
- items = tbBusinessItemService.findByBusinessId(businessId);
|
|
|
- } else {
|
|
|
- List<TbBusiness> businessList = tbBusinessService.findOtherBusinessByCarId(tbBusinessCar.getId());
|
|
|
- items = tbBusinessItemService.findByBusinessIdList(businessList.stream().map(TbBusiness::getId).collect(Collectors.toList()));
|
|
|
- }
|
|
|
- long count = items.stream().filter(tbBusinessItem -> tbBusinessItem.getPayStatus() == 0).count();
|
|
|
- if (count > 0) {
|
|
|
- RedisUtil.setByMINUTES(channel, carNo, 1);
|
|
|
- log.error("请求返回:请缴纳业务费用:{}", carNo);
|
|
|
- return ResultJson.error("请缴纳业务费用");
|
|
|
+ for (TbBusiness tbBusiness : businessList) {
|
|
|
+ TbGoods tbGoods = tbGoodsService.getById(tbBusiness.getGoodsId());
|
|
|
+ int vietnamLeave = tbGoods.getVietnamCarLeave();
|
|
|
+ int chinaCarLeave = tbGoods.getChinaCarLeave();
|
|
|
+ boolean pay = tbBusiness.getPayMoney().doubleValue() >= tbBusiness.getItemPrice().doubleValue();
|
|
|
+ //需要交业务费
|
|
|
+ if (!CAR_LIST.contains(carNoPrefix)) {//越南车
|
|
|
+ if (TbGoods.LeaveEnum.PART_MONEY.getCode() != vietnamLeave
|
|
|
+ && !pay) {
|
|
|
+ RedisUtil.setByMINUTES(channel, carNo, 1);
|
|
|
+ log.error("请求返回:请缴纳业务费用:{}", carNo);
|
|
|
+ return ResultJson.error("请缴纳业务费用");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (TbGoods.LeaveEnum.PART_MONEY.getCode() != chinaCarLeave
|
|
|
+ && !pay) {
|
|
|
+ RedisUtil.setByMINUTES(channel, carNo, 1);
|
|
|
+ log.error("请求返回:请缴纳业务费用:{}", carNo);
|
|
|
+ return ResultJson.error("请缴纳业务费用");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- tbBusinessCar.setRealOutTime(now).setOutChannel(channel).setTimeUpdate(now);
|
|
|
- tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
- CoverBase64ToUrl(image, tbBusinessCar.getId(), carNo, 2);
|
|
|
- RedisUtil.del(channel);
|
|
|
+ freeOut(tbBusinessCar, now, channel, image);
|
|
|
return ResultJson.success();
|
|
|
}
|
|
|
|
|
|
|
|
|
- private double caulatePrice(TbBusinessCar tbBusinessCar,Date now){
|
|
|
- Date inTime=tbBusinessCar.getRealInTime();
|
|
|
+ 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){
|
|
|
+
|
|
|
+ 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();
|
|
|
+ String carNo = tbBusinessCar.getCarNo();
|
|
|
CoverBase64ToUrl(base64Image, tbBusinessCar.getId(), carNo, 2);
|
|
|
RedisUtil.del(outChannel);
|
|
|
log.error("请求返回【放行】:{}", carNo);
|