|
@@ -475,7 +475,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
}
|
|
|
|
|
|
|
|
|
- public BigDecimal calculationPartMoney(Date iTime, Date oTime,double carSize) {
|
|
|
+ public BigDecimal calculationPartMoney(Date iTime, Date oTime, double carSize) {
|
|
|
BigDecimal zero = new BigDecimal("0");
|
|
|
if (iTime == null || oTime == null) {
|
|
|
return zero;
|
|
@@ -483,21 +483,30 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
LocalDateTime inDayTime = iTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
LocalDateTime outDayTime = oTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
long minutes = ChronoUnit.MINUTES.between(inDayTime, outDayTime);
|
|
|
- if (minutes < 0) {
|
|
|
+ if (minutes < 0 || minutes < partConfig.getFreeMinutes()) {
|
|
|
return zero;
|
|
|
}
|
|
|
- long days = ChronoUnit.DAYS.between(inDayTime.toLocalDate(), outDayTime.toLocalDate());
|
|
|
- BigDecimal p = partConfig.getBasePrice();//乘积因子
|
|
|
+ BigDecimal extraPrice=partConfig.getExtraPrice();
|
|
|
+ BigDecimal basePrice=partConfig.getBasePrice();
|
|
|
+ BigDecimal uniPrice = basePrice.add(extraPrice);//超过24小时之后每24个小时收费金额
|
|
|
//4.2~9.6
|
|
|
- if (carSize<partConfig.getMildCarLength()&&carSize>=partConfig.getFreeCarLength()){
|
|
|
- p=partConfig.getMildCarBasePrice();
|
|
|
- }
|
|
|
- BigDecimal extraPrice = partConfig.getExtraPrice();
|
|
|
- int unit = (int) Math.ceil(NumberUtil.div(minutes, 24 * 60));
|
|
|
- if (minutes < partConfig.getFreeMinutes()) {
|
|
|
- unit = 0;
|
|
|
- }
|
|
|
- return p.multiply(new BigDecimal(unit)).add(new BigDecimal(days).multiply(extraPrice));
|
|
|
+ if (carSize < partConfig.getMildCarLength() && carSize >= partConfig.getFreeCarLength()) {
|
|
|
+ basePrice=partConfig.getMildCarBasePrice();
|
|
|
+ uniPrice = basePrice.add(extraPrice);
|
|
|
+ }
|
|
|
+ //间隔小时
|
|
|
+ long hours = ChronoUnit.HOURS.between(inDayTime, outDayTime);
|
|
|
+ final int hoursOf24=24;
|
|
|
+ //24小时内只用交20或者30元
|
|
|
+ if (hours<hoursOf24){
|
|
|
+ return basePrice;
|
|
|
+ }
|
|
|
+ //24小时个数
|
|
|
+ int count=(int) Math.ceil(NumberUtil.div(hours, hoursOf24));
|
|
|
+ //超过24小时总停车费
|
|
|
+ BigDecimal price=new BigDecimal(count).multiply(uniPrice);
|
|
|
+ return price.add(basePrice);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -559,13 +568,15 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
if (tbBusinessCar.getPay() == 1 && tbBusinessCar.getPayTime() != null) {
|
|
|
inTime = tbBusinessCar.getPayTime();
|
|
|
}
|
|
|
- partMoney = this.calculationPartMoney(inTime, now,tbBusinessCar.getCarSize());
|
|
|
+ partMoney = this.calculationPartMoney(inTime, now, tbBusinessCar.getCarSize());
|
|
|
}
|
|
|
- if (StrUtil.isNotEmpty(tbBusinessCar.getColor())) {//蓝色车辆免费
|
|
|
+ if (StrUtil.isNotEmpty(tbBusinessCar.getColor())) {
|
|
|
String freeColor = partConfig.getFreeColor();
|
|
|
- if (tbBusinessCar.getColor().contains(freeColor)){
|
|
|
- TbMildCar tbMildCar= tbMildCarService.findByCarNo(tbBusinessCar.getCarNo());
|
|
|
- if (tbMildCar==null){
|
|
|
+ //蓝色车辆
|
|
|
+ if (tbBusinessCar.getColor().contains(freeColor)) {
|
|
|
+ //不在4.2~9.6米之内的免费
|
|
|
+ TbMildCar tbMildCar = tbMildCarService.findByCarNo(tbBusinessCar.getCarNo());
|
|
|
+ if (tbMildCar == null) {
|
|
|
partMoney = new BigDecimal("0");
|
|
|
}
|
|
|
}
|
|
@@ -716,7 +727,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
Date realInTime = tbBusinessCar.getRealInTime();
|
|
|
Date realOutTime = tbBusinessCar.getRealOutTime();
|
|
|
if (realInTime != null && realOutTime != null) {
|
|
|
- BigDecimal price = calculationPartMoney(realInTime, realOutTime,tbBusinessCar.getCarSize());
|
|
|
+ BigDecimal price = calculationPartMoney(realInTime, realOutTime, tbBusinessCar.getCarSize());
|
|
|
tbBusinessCar.setMoney(price);
|
|
|
}
|
|
|
tbBusinessCar.setPay(1).setPayTime(now)
|
|
@@ -798,7 +809,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
for (TbBusinessCar car : cars) {
|
|
|
String carNo = car.getCarNo().trim().toUpperCase();
|
|
|
String carType = car.getCarType();
|
|
|
- if (car.getCarSize()==null||car.getCarSize()<=0) {
|
|
|
+ if (car.getCarSize() == null || car.getCarSize() <= 0) {
|
|
|
throw new AjaxError(carNo + "规格不正确");
|
|
|
}
|
|
|
if (StrUtil.isEmpty(carType)) {
|
|
@@ -811,13 +822,13 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
//最新一条记录
|
|
|
TbBusinessCar db = tbBusinessCarService.findTheLastRecord(carNo);
|
|
|
//存在并且未离场+已审核
|
|
|
- if (db!=null&&db.getConfirmJudge()==TbBusinessCar.ConfirmJudgeEnum.JUDGE_PASS.getCode()&&db.getRealOutTime()==null){
|
|
|
- throw new BusinessException("车辆【"+carNo+"】已审核,请驳回再录入业务");
|
|
|
+ if (db != null && db.getConfirmJudge() == TbBusinessCar.ConfirmJudgeEnum.JUDGE_PASS.getCode() && db.getRealOutTime() == null) {
|
|
|
+ throw new BusinessException("车辆【" + carNo + "】已审核,请驳回再录入业务");
|
|
|
}
|
|
|
- if (!tbGoods.getName().contains("整车")){
|
|
|
+ if (!tbGoods.getName().contains("整车")) {
|
|
|
//记录不存在或者已离场
|
|
|
- if (db==null||db.getRealOutTime()!=null){
|
|
|
- throw new BusinessException("车辆【"+carNo+"】未入场,无法录入业务");
|
|
|
+ if (db == null || db.getRealOutTime() != null) {
|
|
|
+ throw new BusinessException("车辆【" + carNo + "】未入场,无法录入业务");
|
|
|
}
|
|
|
}
|
|
|
//不存在,或者已离场记录--->新建记录;
|
|
@@ -933,8 +944,8 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
if (StrUtil.isNotEmpty(businessCarId)) {
|
|
|
//原来已存在的
|
|
|
TbBusinessCar dbBusinessCar = tbBusinessCarService.getById(businessCarId);
|
|
|
- if (dbBusinessCar.getConfirmJudge()==TbBusinessCar.ConfirmJudgeEnum.JUDGE_PASS.getCode()){
|
|
|
- throw new BusinessException("车辆【"+carNo+"】已审核,请驳回再录入业务");
|
|
|
+ if (dbBusinessCar.getConfirmJudge() == TbBusinessCar.ConfirmJudgeEnum.JUDGE_PASS.getCode()) {
|
|
|
+ throw new BusinessException("车辆【" + carNo + "】已审核,请驳回再录入业务");
|
|
|
}
|
|
|
//如果修改了车牌号
|
|
|
String dbCarNo = dbBusinessCar.getCarNo();
|
|
@@ -970,10 +981,10 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
} else {
|
|
|
TbBusinessCar checkCar = tbBusinessCarService.findTheLastRecord(carNo);
|
|
|
//存在+审核+未离场的
|
|
|
- if (checkCar!=null
|
|
|
- &&checkCar.getConfirmJudge()==TbBusinessCar.ConfirmJudgeEnum.JUDGE_PASS.getCode()
|
|
|
- &&checkCar.getRealOutTime()==null){
|
|
|
- throw new BusinessException("车辆【"+carNo+"】已审核,请驳回再录入业务");
|
|
|
+ if (checkCar != null
|
|
|
+ && checkCar.getConfirmJudge() == TbBusinessCar.ConfirmJudgeEnum.JUDGE_PASS.getCode()
|
|
|
+ && checkCar.getRealOutTime() == null) {
|
|
|
+ throw new BusinessException("车辆【" + carNo + "】已审核,请驳回再录入业务");
|
|
|
}
|
|
|
//不存在或者已经离场的
|
|
|
if (checkCar == null ||
|
|
@@ -1101,7 +1112,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
* @param isAdmin 是否管理员
|
|
|
*/
|
|
|
public void selectErrorBusiness(ErrorBusinessBO errorBusinessBO, boolean isAdmin) {
|
|
|
- log.info("is admin :{}",isAdmin);
|
|
|
+ log.info("is admin :{}", isAdmin);
|
|
|
TbBusiness tbBusiness = getById(errorBusinessBO.getId());
|
|
|
if (tbBusiness == null) {
|
|
|
throw new AjaxError("业务已被删除");
|
|
@@ -1153,7 +1164,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
outTime = payTime;
|
|
|
}
|
|
|
//计算停车费
|
|
|
- BigDecimal parkMoney = this.calculationPartMoney(inTime, outTime,tbBusinessCar.getCarSize());
|
|
|
+ BigDecimal parkMoney = this.calculationPartMoney(inTime, outTime, tbBusinessCar.getCarSize());
|
|
|
tbBusinessCar.setMoney(parkMoney);
|
|
|
}
|
|
|
|
|
@@ -1166,7 +1177,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
* @param sendBy
|
|
|
*/
|
|
|
private void sendOA(TbBusiness tbBusiness, List<TbBusinessItem> items, List<TbBusinessCar> tbBusinessCars, String sendBy) {
|
|
|
- if (!oaConfig.isEnable()){
|
|
|
+ if (!oaConfig.isEnable()) {
|
|
|
return;
|
|
|
}
|
|
|
ParamsBO paramsBO = buildParams(tbBusiness, items, tbBusinessCars);
|
|
@@ -1442,7 +1453,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
* @param id
|
|
|
*/
|
|
|
public void applyOA(String id, String sendBy) {
|
|
|
- log.info("发起流程:{},{}",id,sendBy);
|
|
|
+ log.info("发起流程:{},{}", id, sendBy);
|
|
|
TbBusiness tbBusiness = this.getById(id);
|
|
|
List<TbBusinessItem> items = tbBusinessItemService.findByBusinessId(id);
|
|
|
List<TbBusinessCar> tbBusinessCars = tbBusinessCarService.findOtherBusinessCar(id);
|
|
@@ -1497,7 +1508,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
.setOaJudgeTime(new Date());
|
|
|
this.updateById(tbBusiness);
|
|
|
String businessId = tbBusiness.getId();
|
|
|
- if (StrUtil.contains(result, "通过") &&pushfeeConfig.isEnable()) {
|
|
|
+ if (StrUtil.contains(result, "通过") && pushfeeConfig.isEnable()) {
|
|
|
//todo 审批通过-==>已支付的生成明细===>推送订单到计费系统
|
|
|
List<TbBusinessCar> cars = tbBusinessCarService.findOtherBusinessCar(businessId);
|
|
|
String transactionId = tbBusiness.getTransactionId();
|
|
@@ -1512,11 +1523,11 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
}).
|
|
|
collect(Collectors.toList());
|
|
|
if (!priceBOList.isEmpty()) {
|
|
|
- tbFeeDetailsService.chargeParkFee(priceBOList, transactionId, outTradeNo, payTime,TbFeeDetails.ModuleEnum.OFFLINE.getDesc());//添加cars的收费明细
|
|
|
+ tbFeeDetailsService.chargeParkFee(priceBOList, transactionId, outTradeNo, payTime, TbFeeDetails.ModuleEnum.OFFLINE.getDesc());//添加cars的收费明细
|
|
|
}
|
|
|
if (tbBusiness.getPayStatus() == TbBusiness.PayStatus.HAS_PAY_CONFIRM.getCode()) {
|
|
|
List<TbBusinessItem> items = tbBusinessItemService.findByBusinessId(businessId);
|
|
|
- tbFeeDetailsService.chargeBusinessFee(items, transactionId, outTradeNo, payTime,TbFeeDetails.ModuleEnum.OFFLINE.getDesc());//添加items的收费明细
|
|
|
+ tbFeeDetailsService.chargeBusinessFee(items, transactionId, outTradeNo, payTime, TbFeeDetails.ModuleEnum.OFFLINE.getDesc());//添加items的收费明细
|
|
|
}
|
|
|
|
|
|
}
|