|
@@ -27,6 +27,7 @@ import com.pj.project.tb_item.TbItem;
|
|
|
import com.pj.utils.AesUtil;
|
|
|
import com.pj.utils.cache.RedisUtil;
|
|
|
import com.pj.utils.sg.NbUtil;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -63,76 +64,85 @@ public class AutomaticPay {
|
|
|
TbInvoiceOrderService invoiceOrderService;
|
|
|
@Resource
|
|
|
TbGoodsService tbGoodsService;
|
|
|
+ @Resource
|
|
|
+ @Lazy
|
|
|
+ private TbDeductionBindService tbDeductionBindService;
|
|
|
|
|
|
private Integer feeType;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 异步扣费入口
|
|
|
+ *
|
|
|
* @param businessId 业务id
|
|
|
- * @param plate 车牌号
|
|
|
- * @param feeType 收费类型,1-只收停车费、2-只收业务费,3-停车和业务费
|
|
|
+ * @param plate 车牌号
|
|
|
+ * @param feeType 收费类型,1-只收停车费、2-只收业务费,3-停车和业务费
|
|
|
*/
|
|
|
//TODO 不要在此方法写逻辑
|
|
|
@Async
|
|
|
public void run(String businessId, String plate, Integer feeType) {
|
|
|
this.feeType = feeType;
|
|
|
- task(businessId,plate,feeType);
|
|
|
+ task(businessId, plate, feeType);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 异步解绑入口
|
|
|
+ *
|
|
|
* @param plate
|
|
|
*/
|
|
|
@Async
|
|
|
- public void unbindRun(String plate){
|
|
|
+ public void unbindRun(String plate) {
|
|
|
if(isExistTask(null,plate)){
|
|
|
return;
|
|
|
}
|
|
|
autoUnbindCarByPlate(plate);
|
|
|
delRedisTask(null,plate);
|
|
|
+// TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(plate);
|
|
|
+// TbDeductionBind bind = tbDeductionBindService.findTheLastUnBindCar(plate);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 分配任务
|
|
|
*/
|
|
|
- private void task(String businessId, String plate, Integer feeType){
|
|
|
- if(isExistTask(businessId,plate)){
|
|
|
+ private void task(String businessId, String plate, Integer feeType) {
|
|
|
+ if (isExistTask(businessId, plate)) {
|
|
|
return;
|
|
|
}
|
|
|
- if(feeType==1){
|
|
|
- doParkingFee(plate,0.0);
|
|
|
- }else if(feeType==2){
|
|
|
+ if (feeType == 1) {
|
|
|
+ doParkingFee(plate, 0.0);
|
|
|
+ } else if (feeType == 2) {
|
|
|
List<TbBusinessCar> cars = tbBusinessCarService.findOtherBusinessCar(businessId);
|
|
|
- for (TbBusinessCar car : cars){
|
|
|
- this.doBusinessFee(businessId,car.getCarNo());
|
|
|
+ for (TbBusinessCar car : cars) {
|
|
|
+ this.doBusinessFee(businessId, car.getCarNo());
|
|
|
}
|
|
|
- }else if(feeType==3){
|
|
|
+ } else if (feeType == 3) {
|
|
|
doOutFee(plate);
|
|
|
}
|
|
|
- delRedisTask(businessId,plate);
|
|
|
+ delRedisTask(businessId, plate);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 收业务费
|
|
|
+ *
|
|
|
* @param businessId
|
|
|
*/
|
|
|
- private void doBusinessFee(String businessId,String plate){
|
|
|
- if(!NumberUtil.isNumber(businessId) || NbUtil.isNull(plate)){
|
|
|
+ private void doBusinessFee(String businessId, String plate) {
|
|
|
+ if (!NumberUtil.isNumber(businessId) || NbUtil.isNull(plate)) {
|
|
|
return;
|
|
|
}
|
|
|
- StaticLog.info("开始收取业务费:{}" , businessId);
|
|
|
+ StaticLog.info("开始收取业务费:{}", businessId);
|
|
|
TbBusiness tbBusiness = tbBusinessService.getById(businessId);
|
|
|
- if(TbBusiness.PayStatus.NO_PAY.getCode()!=tbBusiness.getPayStatus()){
|
|
|
- StaticLog.info("已收取过业务费,退出收费程序:{}" , businessId);
|
|
|
+ if (TbBusiness.PayStatus.NO_PAY.getCode() != tbBusiness.getPayStatus()) {
|
|
|
+ StaticLog.info("已收取过业务费,退出收费程序:{}", businessId);
|
|
|
return;
|
|
|
}
|
|
|
- if(!NumberUtil.isNumber(tbBusiness.getItemPrice().toString())){
|
|
|
- StaticLog.info("未获取到收费总金额或收费总金额非法,退出收费程序:{}" , businessId);
|
|
|
+ if (!NumberUtil.isNumber(tbBusiness.getItemPrice().toString())) {
|
|
|
+ StaticLog.info("未获取到收费总金额或收费总金额非法,退出收费程序:{}", businessId);
|
|
|
return;
|
|
|
}
|
|
|
- if(!deductionBindService.isBindCarByPlate(plate)){
|
|
|
- StaticLog.info("业务车辆未绑定指定客户的预存款账户,退出收费程序:{}{}",businessId,tbBusiness.getCustomerName());
|
|
|
+ if (!deductionBindService.isBindCarByPlate(plate)) {
|
|
|
+ StaticLog.info("业务车辆未绑定指定客户的预存款账户,退出收费程序:{}{}", businessId, tbBusiness.getCustomerName());
|
|
|
return;
|
|
|
}
|
|
|
List<TbBusinessCar> cars = tbBusinessCarService.findOtherBusinessCar(businessId);
|
|
@@ -143,75 +153,78 @@ public class AutomaticPay {
|
|
|
BigDecimal parkingMoneyBig = new BigDecimal(0);
|
|
|
BigDecimal totalMoneyBig = new BigDecimal(totalMoney);
|
|
|
BigDecimal balance = totalMoneyBig.subtract(tbBusiness.getItemPrice());
|
|
|
- boolean isOut = (TbGoods.DeductionTypeEnum.OUT_KK.getCode()==tbBusiness.getAutoDeductionType()) &&
|
|
|
- this.feeType==3;
|
|
|
- if(isOut){
|
|
|
+ boolean isOut = (TbGoods.DeductionTypeEnum.OUT_KK.getCode() == tbBusiness.getAutoDeductionType()) &&
|
|
|
+ this.feeType == 3;
|
|
|
+ if (isOut) {
|
|
|
parkingMoneyBig = getParkings(cars);
|
|
|
balance = balance.subtract(parkingMoneyBig);
|
|
|
}
|
|
|
- if(balance.doubleValue()<0){
|
|
|
- StaticLog.info("支付账户余额不足!,退出收费程序:{}" , businessId);
|
|
|
- deductionBindService.setFeeFailRecord(bind.getCustomerId(),plate,
|
|
|
- AesUtil.toStr(tbBusiness.getGoodsName())+":因支付账户余额不足,自动缴费失败。。");
|
|
|
+ if (balance.doubleValue() < 0) {
|
|
|
+ StaticLog.info("支付账户余额不足!,退出收费程序:{}", businessId);
|
|
|
+ deductionBindService.setFeeFailRecord(bind.getCustomerId(), plate,
|
|
|
+ AesUtil.toStr(tbBusiness.getGoodsName()) + ":因支付账户余额不足,自动缴费失败。。");
|
|
|
return;
|
|
|
}
|
|
|
Date now = new Date();
|
|
|
String no = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) + RandomUtil.randomNumbers(4);
|
|
|
tbBusiness.setPayMoney(tbBusiness.getItemPrice()).setPayTime(now).setPayType(5)
|
|
|
- .setPayNo(no).setConfirmInput(1).setConfirmInputTime(now).setPayStatus(
|
|
|
- TbBusiness.PayStatus.HAS_PAY_CONFIRM.getCode());
|
|
|
+ .setPayNo(no).setConfirmInput(1).setConfirmInputTime(now).setPayStatus(
|
|
|
+ TbBusiness.PayStatus.HAS_PAY_CONFIRM.getCode());
|
|
|
tbBusiness.updateById();
|
|
|
List<TbBusinessItem> businessItems = tbBusinessItemService.findByBusinessId(businessId);
|
|
|
- for(TbBusinessItem businessItem:businessItems){
|
|
|
- if(businessItem.getPayStatus()==1){
|
|
|
+ for (TbBusinessItem businessItem : businessItems) {
|
|
|
+ if (businessItem.getPayStatus() == 1) {
|
|
|
continue;
|
|
|
}
|
|
|
businessItem.setPayStatus(1).setPayTime(now);
|
|
|
}
|
|
|
tbBusinessItemService.updateBatchById(businessItems);
|
|
|
- if(isOut){
|
|
|
+ if (isOut) {
|
|
|
this.updateTbBusinessCars(cars);
|
|
|
}
|
|
|
//更新账户余额
|
|
|
- tbAccount.setTotalMoney(AesUtil.encryptECB(balance.toString(),key));
|
|
|
+ tbAccount.setTotalMoney(AesUtil.encryptECB(balance.toString(), key));
|
|
|
tbAccount.updateById();
|
|
|
- deductionBindService.setDeductMoney(bind.getCustomerId(),plate,tbBusiness.getItemPrice());
|
|
|
+ deductionBindService.setDeductMoney(bind.getCustomerId(), plate, tbBusiness.getItemPrice());
|
|
|
//生成收费明细
|
|
|
List<TbFeeDetails> tbFeeDetailsList = tbFeeDetailsService.autoChargeBusinessFee(
|
|
|
- businessItems,null,null,now);
|
|
|
+ businessItems, null, null, now);
|
|
|
//生成扣费记录
|
|
|
- createTbDeductionRecord(tbFeeDetailsList,tbAccount, totalMoneyBig,plate,bind.getCustomerName(),no);
|
|
|
+ createTbDeductionRecord(tbFeeDetailsList, tbAccount, totalMoneyBig, plate, bind.getCustomerName(), no);
|
|
|
//生成开票信息
|
|
|
- createTbInvoiceOrder(tbBusiness, cars, parkingMoneyBig, plate,bind.getCustomerId(),no,isOut);
|
|
|
- if(isOut){
|
|
|
- deductionBindService.setDeductMoney(bind.getCustomerId(),plate,parkingMoneyBig);
|
|
|
+ createTbInvoiceOrder(tbBusiness, cars, parkingMoneyBig, plate, bind.getCustomerId(), no, isOut);
|
|
|
+ if (isOut) {
|
|
|
+ deductionBindService.setDeductMoney(bind.getCustomerId(), plate, parkingMoneyBig);
|
|
|
List<TbFeeDetails> parkFeeDetailsList = tbFeeDetailsService.autoChargeParkFee(
|
|
|
- cars,null,null,now);
|
|
|
- createTbDeductionRecord(parkFeeDetailsList,tbAccount,
|
|
|
- totalMoneyBig.subtract(tbBusiness.getItemPrice()),plate,bind.getCustomerName(),no);
|
|
|
+ cars, null, null, now);
|
|
|
+ createTbDeductionRecord(parkFeeDetailsList, tbAccount,
|
|
|
+ totalMoneyBig.subtract(tbBusiness.getItemPrice()), plate, bind.getCustomerName(), no);
|
|
|
deductionBindService.autoUnbindCar(cars);
|
|
|
}
|
|
|
- StaticLog.info("预充值自动缴费成功!,退出收费程序:{}{}" , businessId,tbAccount.getCustomerId());
|
|
|
+ StaticLog.info("预充值自动缴费成功!,退出收费程序:{}{}", businessId, tbAccount.getCustomerId());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 出场所收费,根据车牌号
|
|
|
+ *
|
|
|
* @param plate
|
|
|
*/
|
|
|
- private void doOutFee(String plate){
|
|
|
- if(NbUtil.isNull(plate)){
|
|
|
+ private void doOutFee(String plate) {
|
|
|
+ if (NbUtil.isNull(plate)) {
|
|
|
return;
|
|
|
}
|
|
|
TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(plate);
|
|
|
- if(tbBusinessCar==null){
|
|
|
+ if (tbBusinessCar == null) {
|
|
|
return;
|
|
|
}
|
|
|
List<TbBusiness> businessList = tbBusinessService.findOtherBusinessByCarId(tbBusinessCar.getId());
|
|
|
- if(businessList==null){return;}
|
|
|
- for (TbBusiness business: businessList){
|
|
|
+ if (businessList == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (TbBusiness business : businessList) {
|
|
|
List<TbBusinessCar> cars = tbBusinessCarService.findOtherBusinessCar(business.getId());
|
|
|
- if(cars==null)continue;
|
|
|
- for (TbBusinessCar car:cars){
|
|
|
+ if (cars == null) continue;
|
|
|
+ for (TbBusinessCar car : cars) {
|
|
|
doBusinessFee(business.getId(), car.getCarNo());
|
|
|
}
|
|
|
}
|
|
@@ -220,83 +233,85 @@ public class AutomaticPay {
|
|
|
|
|
|
/**
|
|
|
* 收停车费,不判断免费车辆
|
|
|
+ *
|
|
|
* @param plate
|
|
|
* @param parkingFee
|
|
|
*/
|
|
|
- private void doParkingFee(String plate, double parkingFee){
|
|
|
- if(NbUtil.isNull(plate)){
|
|
|
+ private void doParkingFee(String plate, double parkingFee) {
|
|
|
+ if (NbUtil.isNull(plate)) {
|
|
|
return;
|
|
|
}
|
|
|
TbBusinessCar car = tbBusinessCarService.findTheLastRecord(plate);
|
|
|
- if(car==null){
|
|
|
+ if (car == null) {
|
|
|
return;
|
|
|
}
|
|
|
- StaticLog.info("开始自动缴纳停车费:{}" , car.getCarNo());
|
|
|
+ StaticLog.info("开始自动缴纳停车费:{}", car.getCarNo());
|
|
|
// if(car.getPay()==1 || car.getPayTime()!=null){
|
|
|
// StaticLog.info("该车辆已缴纳过停车费!,退出收费程序:{}" , car.getCarNo());
|
|
|
// return;
|
|
|
// }
|
|
|
TbAccount account = tbAccountService.getTbAccountByPlate(car.getCarNo());
|
|
|
- if (account==null){
|
|
|
- StaticLog.info("该车辆还未绑定客户预存款账户!,退出收费程序:{}" , car.getCarNo());
|
|
|
+ if (account == null) {
|
|
|
+ StaticLog.info("该车辆还未绑定客户预存款账户!,退出收费程序:{}", car.getCarNo());
|
|
|
return;
|
|
|
}
|
|
|
BigDecimal parkFeeBig = null;
|
|
|
- if(parkingFee>0){
|
|
|
+ if (parkingFee > 0) {
|
|
|
parkFeeBig = new BigDecimal(String.valueOf(parkingFee));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
parkFeeBig = caulatePrice(car, new Date());
|
|
|
}
|
|
|
- if(parkFeeBig==null ||parkFeeBig.doubleValue()<=0){
|
|
|
- StaticLog.info("该车辆无需缴纳停车费!,退出收费程序:{}" , car.getCarNo());
|
|
|
+ if (parkFeeBig == null || parkFeeBig.doubleValue() <= 0) {
|
|
|
+ StaticLog.info("该车辆无需缴纳停车费!,退出收费程序:{}", car.getCarNo());
|
|
|
return;
|
|
|
}
|
|
|
TbDeductionBind bind = deductionBindService.getBindCarByPlate(plate);
|
|
|
BigDecimal totalBig = new BigDecimal("0");
|
|
|
String key = null;
|
|
|
- if(!NumberUtil.isNumber(account.getTotalMoney())){
|
|
|
+ if (!NumberUtil.isNumber(account.getTotalMoney())) {
|
|
|
key = AesUtil.reverse(account.getAccSalt());
|
|
|
- totalBig = new BigDecimal(AesUtil.decryptECB(account.getTotalMoney(),key));
|
|
|
+ totalBig = new BigDecimal(AesUtil.decryptECB(account.getTotalMoney(), key));
|
|
|
}
|
|
|
|
|
|
BigDecimal balance = totalBig.subtract(parkFeeBig);
|
|
|
- if(balance.doubleValue()<0){
|
|
|
- StaticLog.info("支付账户余额不足!,退出收费程序:{}" , car.getCarNo());
|
|
|
+ if (balance.doubleValue() < 0) {
|
|
|
+ StaticLog.info("支付账户余额不足!,退出收费程序:{}", car.getCarNo());
|
|
|
return;
|
|
|
}
|
|
|
String no = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) + RandomUtil.randomNumbers(4);
|
|
|
car.setMoney(parkFeeBig);
|
|
|
updateTbBusinessCar(car);
|
|
|
- account.setTotalMoney(AesUtil.encryptECB(balance.toString(),key));
|
|
|
+ account.setTotalMoney(AesUtil.encryptECB(balance.toString(), key));
|
|
|
account.updateById();
|
|
|
- deductionBindService.setDeductMoney(bind.getCustomerId(),plate,parkFeeBig);
|
|
|
+ deductionBindService.setDeductMoney(bind.getCustomerId(), plate, parkFeeBig);
|
|
|
List<TbBusinessCar> cars = new ArrayList<TbBusinessCar>();
|
|
|
cars.add(car);
|
|
|
List<TbFeeDetails> parkFeeDetailsList = tbFeeDetailsService.autoChargeParkFee(
|
|
|
- cars,null,null,new Date());
|
|
|
- createTbDeductionRecord(parkFeeDetailsList,account, totalBig,plate,bind.getCustomerName(),no);
|
|
|
- createTbInvoiceOrderPark(car,account.getCustomerId(),no);
|
|
|
+ cars, null, null, new Date());
|
|
|
+ createTbDeductionRecord(parkFeeDetailsList, account, totalBig, plate, bind.getCustomerName(), no);
|
|
|
+ createTbInvoiceOrderPark(car, account.getCustomerId(), no);
|
|
|
deductionBindService.autoUnbindCar(cars);
|
|
|
- StaticLog.info("停车费自动缴费成功!,退出收费程序:{}" , car.getCarNo());
|
|
|
+ StaticLog.info("停车费自动缴费成功!,退出收费程序:{}", car.getCarNo());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 生成扣费记录
|
|
|
+ *
|
|
|
* @param tbFeeDetailsList
|
|
|
* @param tbAccount
|
|
|
* @param totalMoneyBig
|
|
|
*/
|
|
|
- private void createTbDeductionRecord(List<TbFeeDetails> tbFeeDetailsList,TbAccount tbAccount,
|
|
|
- BigDecimal totalMoneyBig,String plate,String customerName,String no ){
|
|
|
- if(tbFeeDetailsList==null)return;
|
|
|
+ private void createTbDeductionRecord(List<TbFeeDetails> tbFeeDetailsList, TbAccount tbAccount,
|
|
|
+ BigDecimal totalMoneyBig, String plate, String customerName, String no) {
|
|
|
+ if (tbFeeDetailsList == null) return;
|
|
|
int i = 0;
|
|
|
String tempMoney = null;
|
|
|
String bindIdStr = deductionBindService.getBindId(plate);
|
|
|
- for (TbFeeDetails feeDetails : tbFeeDetailsList){
|
|
|
- TbDeductionRecord deductionRecord = BeanUtil.toBean(feeDetails,TbDeductionRecord.class);
|
|
|
+ for (TbFeeDetails feeDetails : tbFeeDetailsList) {
|
|
|
+ TbDeductionRecord deductionRecord = BeanUtil.toBean(feeDetails, TbDeductionRecord.class);
|
|
|
String totalStr = null;
|
|
|
- if(totalMoneyBig!=null && feeDetails.getNoTaxPrice()!=null){
|
|
|
- if(i!=0){
|
|
|
+ if (totalMoneyBig != null && feeDetails.getNoTaxPrice() != null) {
|
|
|
+ if (i != 0) {
|
|
|
totalMoneyBig = new BigDecimal(tempMoney);
|
|
|
}
|
|
|
totalStr = totalMoneyBig.subtract(feeDetails.getItemPrice()).toString();
|
|
@@ -326,8 +341,8 @@ public class AutomaticPay {
|
|
|
/**
|
|
|
* 更新停车费状态
|
|
|
*/
|
|
|
- private void updateTbBusinessCar(TbBusinessCar car){
|
|
|
- if(car == null)return;
|
|
|
+ private void updateTbBusinessCar(TbBusinessCar car) {
|
|
|
+ if (car == null) return;
|
|
|
car.setPay(1).setPayTime(new Date());
|
|
|
car.updateById();
|
|
|
}
|
|
@@ -335,19 +350,20 @@ public class AutomaticPay {
|
|
|
/**
|
|
|
* 更新停车费状态
|
|
|
*/
|
|
|
- private void updateTbBusinessCars(List<TbBusinessCar> cars){
|
|
|
- if(cars == null)return;
|
|
|
- for (TbBusinessCar car:cars){
|
|
|
+ private void updateTbBusinessCars(List<TbBusinessCar> cars) {
|
|
|
+ if (cars == null) return;
|
|
|
+ for (TbBusinessCar car : cars) {
|
|
|
updateTbBusinessCar(car);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 生成开票订单信息
|
|
|
+ *
|
|
|
* @param tbBusiness
|
|
|
*/
|
|
|
- private void createTbInvoiceOrder(TbBusiness tbBusiness,List<TbBusinessCar> cars, BigDecimal parkingFee,
|
|
|
- String plate, String customerId, String no, boolean isOut){
|
|
|
+ private void createTbInvoiceOrder(TbBusiness tbBusiness, List<TbBusinessCar> cars, BigDecimal parkingFee,
|
|
|
+ String plate, String customerId, String no, boolean isOut) {
|
|
|
TbInvoiceOrder invoiceOrder = new TbInvoiceOrder();
|
|
|
List<String> businessNameList = new ArrayList<>();
|
|
|
List<String> businessNoList = new ArrayList<>();
|
|
@@ -355,24 +371,24 @@ public class AutomaticPay {
|
|
|
businessNoList.add(tbBusiness.getNo());
|
|
|
carNos.add(plate);
|
|
|
businessNameList.add(tbBusiness.getGoodsName());
|
|
|
- if(cars!=null){
|
|
|
+ if (cars != null) {
|
|
|
for (TbBusinessCar car : cars) {
|
|
|
- if(isOut){
|
|
|
- if(TbBusinessCar.PayTypeEnum.FEE_TYPE.getType().equals(car.getPayType())){
|
|
|
+ if (isOut) {
|
|
|
+ if (TbBusinessCar.PayTypeEnum.FEE_TYPE.getType().equals(car.getPayType())) {
|
|
|
continue;
|
|
|
}
|
|
|
- if(!businessNameList.contains("停车费")){
|
|
|
+ if (!businessNameList.contains("停车费")) {
|
|
|
businessNameList.add("停车费");
|
|
|
}
|
|
|
- }else {
|
|
|
- if(NbUtil.isNull(car.getCarNo()) || !car.getCarNo().equals(plate)){
|
|
|
+ } else {
|
|
|
+ if (NbUtil.isNull(car.getCarNo()) || !car.getCarNo().equals(plate)) {
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
- if(!businessNoList.contains(car.getNo())){
|
|
|
+ if (!businessNoList.contains(car.getNo())) {
|
|
|
businessNoList.add(car.getNo());
|
|
|
}
|
|
|
- if(!carNos.contains(car.getCarNo())){
|
|
|
+ if (!carNos.contains(car.getCarNo())) {
|
|
|
carNos.add(car.getCarNo());
|
|
|
}
|
|
|
}
|
|
@@ -381,19 +397,19 @@ public class AutomaticPay {
|
|
|
String businessNoStr = businessNoList.stream().map(String::valueOf).collect(Collectors.joining(","));
|
|
|
String carNoStr = carNos.stream().map(String::valueOf).collect(Collectors.joining(","));
|
|
|
BigDecimal billMoney = tbBusiness.getItemPrice();
|
|
|
- if(parkingFee!=null){
|
|
|
+ if (parkingFee != null) {
|
|
|
billMoney = parkingFee.add(billMoney);
|
|
|
}
|
|
|
invoiceOrder.setBusinessName(businessNameStr).setBusinessNo(businessNoStr).setCarNo(carNoStr)
|
|
|
- .setTransactionId(null).setBillMoney(billMoney).setBusinessId(tbBusiness.getId())
|
|
|
- .setStatus(0).setCreateTime(new Date()).setCustomerId(customerId).setPreOrderNum(no);
|
|
|
+ .setTransactionId(null).setBillMoney(billMoney).setBusinessId(tbBusiness.getId())
|
|
|
+ .setStatus(0).setCreateTime(new Date()).setCustomerId(customerId).setPreOrderNum(no);
|
|
|
invoiceOrderService.save(invoiceOrder);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 无业务车辆收停车费生成发票信息
|
|
|
*/
|
|
|
- private void createTbInvoiceOrderPark(TbBusinessCar car, String customerId,String no){
|
|
|
+ private void createTbInvoiceOrderPark(TbBusinessCar car, String customerId, String no) {
|
|
|
TbInvoiceOrder invoiceOrder = new TbInvoiceOrder();
|
|
|
|
|
|
invoiceOrder.setBusinessName("停车费").setBusinessNo(car.getNo()).setCarNo(car.getCarNo())
|
|
@@ -404,12 +420,13 @@ public class AutomaticPay {
|
|
|
|
|
|
/**
|
|
|
* 生成停车费
|
|
|
+ *
|
|
|
* @param tbBusinessCar
|
|
|
* @param now
|
|
|
* @return
|
|
|
*/
|
|
|
private BigDecimal caulatePrice(TbBusinessCar tbBusinessCar, Date now) {
|
|
|
- if(tbBusinessCar==null || now==null) new BigDecimal("0");
|
|
|
+ if (tbBusinessCar == null || now == null) new BigDecimal("0");
|
|
|
Date inTime = tbBusinessCar.getRealInTime();
|
|
|
if (tbBusinessCar.getPay() == 1 && tbBusinessCar.getRealOutTime() == null && tbBusinessCar.getPayTime() != null) {
|
|
|
inTime = tbBusinessCar.getPayTime();
|
|
@@ -421,15 +438,16 @@ public class AutomaticPay {
|
|
|
|
|
|
/**
|
|
|
* 获取所有停车费总和
|
|
|
+ *
|
|
|
* @param cars
|
|
|
* @return
|
|
|
*/
|
|
|
- private BigDecimal getParkings(List<TbBusinessCar> cars){
|
|
|
- if(cars==null) new BigDecimal("0");
|
|
|
+ private BigDecimal getParkings(List<TbBusinessCar> cars) {
|
|
|
+ if (cars == null) new BigDecimal("0");
|
|
|
Date now = new Date();
|
|
|
BigDecimal value = new BigDecimal("0");
|
|
|
- for (TbBusinessCar car:cars){
|
|
|
- value = value.add(this.caulatePrice(car,now));
|
|
|
+ for (TbBusinessCar car : cars) {
|
|
|
+ value = value.add(this.caulatePrice(car, now));
|
|
|
car.setPayType(TbBusinessCar.PayTypeEnum.HAS_PAY_TYPE.getType());
|
|
|
}
|
|
|
return value;
|
|
@@ -437,18 +455,19 @@ public class AutomaticPay {
|
|
|
|
|
|
/**
|
|
|
* 获取所有停车费总和,过滤免费车
|
|
|
+ *
|
|
|
* @param cars
|
|
|
* @return
|
|
|
*/
|
|
|
- private BigDecimal getParkingsByBS(List<TbBusinessCar> cars,TbBusiness tbBusiness){
|
|
|
- if(cars==null) new BigDecimal("0");
|
|
|
+ private BigDecimal getParkingsByBS(List<TbBusinessCar> cars, TbBusiness tbBusiness) {
|
|
|
+ if (cars == null) new BigDecimal("0");
|
|
|
Date now = new Date();
|
|
|
BigDecimal value = new BigDecimal("0");
|
|
|
- for (TbBusinessCar car:cars){
|
|
|
- if(isParkingFeeByBS(tbBusiness,car.getCarType())){
|
|
|
+ for (TbBusinessCar car : cars) {
|
|
|
+ if (isParkingFeeByBS(tbBusiness, car.getCarType())) {
|
|
|
car.setPayType(TbBusinessCar.PayTypeEnum.FEE_TYPE.getType());
|
|
|
- }else {
|
|
|
- value = value.add(this.caulatePrice(car,now));
|
|
|
+ } else {
|
|
|
+ value = value.add(this.caulatePrice(car, now));
|
|
|
car.setPayType(TbBusinessCar.PayTypeEnum.HAS_PAY_TYPE.getType());
|
|
|
}
|
|
|
}
|
|
@@ -457,9 +476,10 @@ public class AutomaticPay {
|
|
|
|
|
|
/**
|
|
|
* 判断有业务的车是否收停车费
|
|
|
+ *
|
|
|
* @return true是免费
|
|
|
*/
|
|
|
- private boolean isParkingFeeByBS(TbBusiness tbBusiness,String carType){
|
|
|
+ private boolean isParkingFeeByBS(TbBusiness tbBusiness, String carType) {
|
|
|
if (TbItem.ItemTypeEnum.EMPTY_TYPE.getType().equals(carType)) {
|
|
|
TbGoods tbGoods = tbGoodsService.getById(tbBusiness.getGoodsId());
|
|
|
return tbGoods.getChinaCarPay() == 1;
|
|
@@ -471,34 +491,35 @@ public class AutomaticPay {
|
|
|
|
|
|
/**
|
|
|
* 补录进场解绑逻辑
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
- private void autoUnbindCarByPlate(String plate){
|
|
|
- if(NbUtil.isNull(plate)) return;
|
|
|
+ private void autoUnbindCarByPlate(String plate) {
|
|
|
+ if (NbUtil.isNull(plate)) return;
|
|
|
TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(plate);
|
|
|
//离场逻辑
|
|
|
- if (tbBusinessCar!=null){
|
|
|
- if(doUnbindCarByPlate(tbBusinessCar)){
|
|
|
+ if (tbBusinessCar != null) {
|
|
|
+ if (doUnbindCarByPlate(tbBusinessCar)) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
//进场逻辑
|
|
|
TbDeductionBind bind = deductionBindService.getOne(new LambdaQueryWrapper<TbDeductionBind>().eq(
|
|
|
- TbDeductionBind::getBindCar,plate).isNull(TbDeductionBind::getUnbindTime));
|
|
|
- if(bind != null){
|
|
|
+ TbDeductionBind::getBindCar, plate).isNull(TbDeductionBind::getUnbindTime));
|
|
|
+ if (bind != null) {
|
|
|
TbDeductionRecord record = new TbDeductionRecord();
|
|
|
Integer count = record.selectCount(new LambdaQueryWrapper<TbDeductionRecord>().like(
|
|
|
- TbDeductionRecord::getDeductionBindId,bind.getId()));
|
|
|
- if(count>0){
|
|
|
+ TbDeductionRecord::getDeductionBindId, bind.getId()));
|
|
|
+ if (count > 0) {
|
|
|
bind.setUpdateBy("预充值自动缴费解绑");
|
|
|
bind.setUpdateTime(new Date());
|
|
|
bind.setUnbindTime(new Date());
|
|
|
bind.updateById();
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
Integer buCount = tbBusinessService.count(new LambdaQueryWrapper<TbBusiness>().ne(
|
|
|
- TbBusiness::getPayStatus,1)
|
|
|
- .between(TbBusiness::getCreateTime,bind.getBindTime(),NbUtil.getNow()));
|
|
|
- if(buCount>0){
|
|
|
+ TbBusiness::getPayStatus, 1)
|
|
|
+ .between(TbBusiness::getCreateTime, bind.getBindTime(), NbUtil.getNow()));
|
|
|
+ if (buCount > 0) {
|
|
|
bind.setUpdateBy("预充值自动缴费解绑");
|
|
|
bind.setUpdateTime(new Date());
|
|
|
bind.setUnbindTime(new Date());
|
|
@@ -510,17 +531,18 @@ public class AutomaticPay {
|
|
|
|
|
|
/**
|
|
|
* 补录出场解绑逻辑
|
|
|
+ *
|
|
|
* @param tbBusinessCar
|
|
|
*/
|
|
|
- private boolean doUnbindCarByPlate(TbBusinessCar tbBusinessCar){
|
|
|
- if (tbBusinessCar==null || tbBusinessCar.getRealOutTime()==null){
|
|
|
+ private boolean doUnbindCarByPlate(TbBusinessCar tbBusinessCar) {
|
|
|
+ if (tbBusinessCar == null || tbBusinessCar.getRealOutTime() == null) {
|
|
|
return false;
|
|
|
}
|
|
|
TbDeductionBind bind = deductionBindService.getOne(new LambdaQueryWrapper<TbDeductionBind>().eq(
|
|
|
- TbDeductionBind::getBindCar,tbBusinessCar.getCarNo())
|
|
|
- .lt(TbDeductionBind::getBindTime,tbBusinessCar.getRealOutTime())
|
|
|
- .isNull(TbDeductionBind::getUnbindTime));
|
|
|
- if(bind==null){
|
|
|
+ TbDeductionBind::getBindCar, tbBusinessCar.getCarNo())
|
|
|
+ .lt(TbDeductionBind::getBindTime, tbBusinessCar.getRealOutTime())
|
|
|
+ .isNull(TbDeductionBind::getUnbindTime));
|
|
|
+ if (bind == null) {
|
|
|
return false;
|
|
|
}
|
|
|
bind.setUpdateBy("预充值自动缴费解绑");
|
|
@@ -532,32 +554,33 @@ public class AutomaticPay {
|
|
|
|
|
|
/**
|
|
|
* 缓存任务,如果存在任务不继续往下执行
|
|
|
+ *
|
|
|
* @param businessId
|
|
|
* @param plate
|
|
|
* @return
|
|
|
*/
|
|
|
- private boolean isExistTask(String businessId, String plate){
|
|
|
- String key = getRedisKey(businessId,plate);
|
|
|
- if(NbUtil.isNullStr(RedisUtil.get(key))){
|
|
|
- RedisUtil.setByMINUTES(key,key,5);
|
|
|
+ private boolean isExistTask(String businessId, String plate) {
|
|
|
+ String key = getRedisKey(businessId, plate);
|
|
|
+ if (NbUtil.isNullStr(RedisUtil.get(key))) {
|
|
|
+ RedisUtil.setByMINUTES(key, key, 5);
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- private void delRedisTask(String businessId, String plate){
|
|
|
- String key = getRedisKey(businessId,plate);
|
|
|
+ private void delRedisTask(String businessId, String plate) {
|
|
|
+ String key = getRedisKey(businessId, plate);
|
|
|
RedisUtil.del(key);
|
|
|
}
|
|
|
|
|
|
- private String getRedisKey(String businessId, String plate){
|
|
|
- if(NbUtil.isNullStr(businessId)){
|
|
|
+ private String getRedisKey(String businessId, String plate) {
|
|
|
+ if (NbUtil.isNullStr(businessId)) {
|
|
|
businessId = "100";
|
|
|
}
|
|
|
- if(NbUtil.isNullStr(plate)){
|
|
|
+ if (NbUtil.isNullStr(plate)) {
|
|
|
plate = "100";
|
|
|
}
|
|
|
- String key = "autoPay:"+businessId+plate;
|
|
|
+ String key = "autoPay:" + businessId + plate;
|
|
|
return key;
|
|
|
}
|
|
|
}
|