|
@@ -167,7 +167,14 @@ public class OpenService {
|
|
|
|
|
|
final TimedCache<String, String> IMAGE_CACHE = CacheUtil.newTimedCache(30 * 60 * 1000);
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 离场处理逻辑
|
|
|
+ *
|
|
|
+ * @param carNo
|
|
|
+ * @param channel
|
|
|
+ * @param image
|
|
|
+ * @return
|
|
|
+ */
|
|
|
private ResultJson handlerOut(String carNo, String channel, String image) {
|
|
|
carNo = carNo.toUpperCase();
|
|
|
TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(carNo);
|
|
@@ -192,6 +199,19 @@ public class OpenService {
|
|
|
//4蓝色车辆
|
|
|
if (tbBusinessCar.getColor().contains(freeColor)) {
|
|
|
log.error("请求返回【蓝牌未备案车辆,放行】:{},{}", carNo, ResultJson.success());
|
|
|
+ List<TbCarWeight> carWeights = tbCarWeightService.findByBusinessCarId(tbBusinessCar.getId());
|
|
|
+ carWeights = carWeights.stream().filter(tbCarWeight -> tbCarWeight.getPayStatus() == 0).collect(Collectors.toList());
|
|
|
+ BigDecimal weightMoney = BigDecimal.ZERO;
|
|
|
+ if (!carWeights.isEmpty()) {
|
|
|
+ for (TbCarWeight carWeight : carWeights) {
|
|
|
+ weightMoney = carWeight.getWeightPrice().add(weightMoney);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ double wMoney = weightMoney.doubleValue();
|
|
|
+ if (wMoney > 0) {
|
|
|
+ log.info("请求返回【蓝牌车过磅费】,{},{}", carNo, wMoney);
|
|
|
+ return ResultJson.error("过磅费" + wMoney);
|
|
|
+ }
|
|
|
freeOut(tbBusinessCar, now, channel, image);
|
|
|
return ResultJson.success();
|
|
|
}
|
|
@@ -228,45 +248,33 @@ public class OpenService {
|
|
|
//无业务车辆===>计算停车费
|
|
|
//如果已经支付过,则从支付时间算起,重新计算停车费
|
|
|
Date inTime = tbBusinessCar.getRealInTime();
|
|
|
- if (CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType().equals(tbBusinessCar.getPayType())&&tbBusinessCar.getPayTime()!=null) {
|
|
|
+ if (CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType().equals(tbBusinessCar.getPayType()) && tbBusinessCar.getPayTime() != null) {
|
|
|
inTime = tbBusinessCar.getPayTime();
|
|
|
}
|
|
|
IOrderPriceRes res = tbBusinessService.getPartMoney(inTime, now, carNo, tbBusinessCar.getColor());
|
|
|
double dif = res.getTotalOrderPrice().subtract(tbBusinessCar.getMoney()).doubleValue();
|
|
|
- if (dif > 0) {
|
|
|
- String desc = "请缴停车费" + dif + "元";
|
|
|
- RedisUtil.setByMINUTES(channel, carNo, 5);
|
|
|
- log.error("请求返回:请缴停车费,过磅费:{},{},{}元", carNo, dif, wMoney);
|
|
|
- if (wMoney > 0) {
|
|
|
- desc += "过磅费:" + wMoney + "元";
|
|
|
- }
|
|
|
- //是否可以预充值缴费 true扣款成功 false否
|
|
|
+ double total = NumberUtil.add(dif, wMoney);
|
|
|
+ if (total > 0) {
|
|
|
+ String desc = "请缴费用" + total + "元";
|
|
|
+ log.error("请求返回:{},{}", carNo, desc);
|
|
|
return ResultJson.error(desc);
|
|
|
- } else {
|
|
|
- if (wMoney > 0) {
|
|
|
- log.error("请求返回:过磅费:{},{},{}元", carNo, dif, wMoney);
|
|
|
- String desc = "过磅费:" + wMoney + "元";
|
|
|
- RedisUtil.setByMINUTES(channel, carNo, 5);
|
|
|
- return ResultJson.error(desc);
|
|
|
- }
|
|
|
- //无需交停车费,又没有支付的--->设置成免费车辆
|
|
|
- if (tbBusinessCar.getPayTime() == null) {
|
|
|
- tbBusinessCar.setPayType(CarEnum.PayTypeEnum.FEE_TYPE.getType()).setPay(1);
|
|
|
- }
|
|
|
- freeOut(tbBusinessCar, now, channel, image);
|
|
|
- return ResultJson.success();
|
|
|
}
|
|
|
+ //无需交停车费,又没有支付的--->设置成免费车辆
|
|
|
+ if (tbBusinessCar.getPayTime() == null) {
|
|
|
+ tbBusinessCar.setPayType(CarEnum.PayTypeEnum.FEE_TYPE.getType()).setPay(1);
|
|
|
+ }
|
|
|
+ freeOut(tbBusinessCar, now, channel, image);
|
|
|
+ return ResultJson.success();
|
|
|
} else {
|
|
|
//有业务的车--->都要交停车费====>除了大头车,拦车
|
|
|
//该车所有的业务都是到达卡口才进行扣费才会进入自动扣费
|
|
|
Date inTime = tbBusinessCar.getRealInTime();
|
|
|
- if (CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType().equals(tbBusinessCar.getPayType())&&tbBusinessCar.getPayTime()!=null) {
|
|
|
+ if (CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType().equals(tbBusinessCar.getPayType()) && tbBusinessCar.getPayTime() != null) {
|
|
|
inTime = tbBusinessCar.getPayTime();
|
|
|
}
|
|
|
partMoneyRes = tbBusinessService.getPartMoney(inTime, now, carNo, tbBusinessCar.getColor());
|
|
|
double dif = partMoneyRes.getTotalOrderPrice().doubleValue();
|
|
|
if (dif > 0) {
|
|
|
- RedisUtil.setByMINUTES(channel, carNo, 5);
|
|
|
log.error("停车费:{},{}元", carNo, dif);
|
|
|
} else {
|
|
|
if (tbBusinessCar.getPayTime() == null) {
|
|
@@ -323,17 +331,7 @@ public class OpenService {
|
|
|
total = total.add(weightMoney);
|
|
|
}
|
|
|
if (total.doubleValue() > 0) {
|
|
|
- String desc = "请缴";
|
|
|
- if (businessMoney.doubleValue() > 0) {
|
|
|
- desc += "业务费" + businessMoney.toString() + "元";
|
|
|
- }
|
|
|
- if (weightMoney.doubleValue() > 0) {
|
|
|
- desc += "过磅费" + weightMoney.toString() + "元 ";
|
|
|
- }
|
|
|
- if (carMoney.doubleValue() > 0) {
|
|
|
- desc += " 停车费" + carMoney.toString() + "元";
|
|
|
- }
|
|
|
- RedisUtil.setByMINUTES(channel, carNo, 5);
|
|
|
+ String desc = "请缴"+total+"费用";
|
|
|
boolean flag = automaticPay.payBusinessAndPartMoney(businessList, tbBusinessCar, partMoneyRes, businessRes, carWeights);
|
|
|
if (flag) {
|
|
|
log.error("预存款扣款成功,返回:{},{}", carNo, desc);
|
|
@@ -417,7 +415,7 @@ public class OpenService {
|
|
|
String carNo = checkCarNumberBO.getCarNumber();
|
|
|
String channel = checkCarNumberBO.getChannelName();
|
|
|
TbChannelConfig tbChannelConfig = tbChannelConfigService.findByName(channel);
|
|
|
- if (tbChannelConfig==null){
|
|
|
+ if (tbChannelConfig == null) {
|
|
|
StaticLog.error("通道未配置,{}", channel);
|
|
|
return ResultJson.error("通道未配置");
|
|
|
}
|
|
@@ -442,7 +440,7 @@ public class OpenService {
|
|
|
log.error("未找到有效入场记录:{},{}", channel, carNo);
|
|
|
return ResultJson.error("未找到有效入场记录");
|
|
|
}
|
|
|
- REQ_CACHE.put(carNo, 1);
|
|
|
+
|
|
|
Date now = new Date();
|
|
|
double weighbridge = NumberUtil.div(Double.valueOf(weight).doubleValue(), 1000, 2);
|
|
|
tbBusinessCar.setNetWeight(weighbridge + "");
|
|
@@ -462,10 +460,11 @@ public class OpenService {
|
|
|
tbCarWeightService.save(carWeight);
|
|
|
taskService.addTask(new CoverWeightBase64ToImageTask("=======" + carWeight.getId() + "", 2000, carWeight.getId(), WEIGHT_IMAGE_CACHE.get(carNo)));
|
|
|
WEIGHT_CACHE.remove(carNo);
|
|
|
- if (tbChannelConfig.getHandlerUp()==1){
|
|
|
+ REQ_CACHE.put(carNo, 1);
|
|
|
+ if (tbChannelConfig.getHandlerUp() == 1) {
|
|
|
return ResultJson.success(tbBusinessCar.getNetWeight());
|
|
|
- }else {
|
|
|
- return ResultJson.error("过磅完成"+tbBusinessCar.getNetWeight());
|
|
|
+ } else {
|
|
|
+ return ResultJson.error("过磅完成" + tbBusinessCar.getNetWeight());
|
|
|
}
|
|
|
|
|
|
}
|