|
@@ -131,12 +131,13 @@ public class AutomaticPay {
|
|
|
StaticLog.info("未获取到收费总金额或收费总金额非法,退出收费程序:{}" , businessId);
|
|
|
return;
|
|
|
}
|
|
|
- if(!deductionBindService.checkBind(tbBusiness.getCustomerId(),plate)){
|
|
|
+ if(!deductionBindService.isBindCarByPlate(plate)){
|
|
|
StaticLog.info("业务车辆未绑定指定客户的预存款账户,退出收费程序:{}{}",businessId,tbBusiness.getCustomerName());
|
|
|
return;
|
|
|
}
|
|
|
List<TbBusinessCar> cars = tbBusinessCarService.findOtherBusinessCar(businessId);
|
|
|
- TbAccount tbAccount = tbAccountService.getByCustomerId(tbBusiness.getCustomerId());
|
|
|
+ TbDeductionBind bind = deductionBindService.getBindCarByPlate(plate);
|
|
|
+ TbAccount tbAccount = tbAccountService.getByCustomerId(bind.getCustomerId());
|
|
|
String key = AesUtil.reverse(tbAccount.getAccSalt());
|
|
|
String totalMoney = tbAccount.getTotalMoney();
|
|
|
BigDecimal parkingMoneyBig = new BigDecimal(0);
|
|
@@ -150,7 +151,7 @@ public class AutomaticPay {
|
|
|
}
|
|
|
if(balance.doubleValue()<0){
|
|
|
StaticLog.info("支付账户余额不足!,退出收费程序:{}" , businessId);
|
|
|
- deductionBindService.setFeeFailRecord(tbBusiness.getCustomerId(),plate,
|
|
|
+ deductionBindService.setFeeFailRecord(bind.getCustomerId(),plate,
|
|
|
AesUtil.toStr(tbBusiness.getGoodsName())+":因支付账户余额不足,自动缴费失败。。");
|
|
|
return;
|
|
|
}
|
|
@@ -174,19 +175,20 @@ public class AutomaticPay {
|
|
|
//更新账户余额
|
|
|
tbAccount.setTotalMoney(AesUtil.encryptECB(balance.toString(),key));
|
|
|
tbAccount.updateById();
|
|
|
- deductionBindService.setDeductMoney(tbBusiness.getCustomerId(),plate,tbBusiness.getItemPrice());
|
|
|
+ deductionBindService.setDeductMoney(bind.getCustomerId(),plate,tbBusiness.getItemPrice());
|
|
|
//生成收费明细
|
|
|
List<TbFeeDetails> tbFeeDetailsList = tbFeeDetailsService.autoChargeBusinessFee(
|
|
|
businessItems,null,null,now);
|
|
|
//生成扣费记录
|
|
|
- createTbDeductionRecord(tbFeeDetailsList,tbAccount, totalMoneyBig,plate);
|
|
|
+ createTbDeductionRecord(tbFeeDetailsList,tbAccount, totalMoneyBig,plate,bind.getCustomerName(),no);
|
|
|
//生成开票信息
|
|
|
- createTbInvoiceOrder(tbBusiness, cars, parkingMoneyBig, plate,isOut);
|
|
|
+ createTbInvoiceOrder(tbBusiness, cars, parkingMoneyBig, plate,bind.getCustomerId(),no,isOut);
|
|
|
if(isOut){
|
|
|
- deductionBindService.setDeductMoney(tbBusiness.getCustomerId(),plate,parkingMoneyBig);
|
|
|
+ deductionBindService.setDeductMoney(bind.getCustomerId(),plate,parkingMoneyBig);
|
|
|
List<TbFeeDetails> parkFeeDetailsList = tbFeeDetailsService.autoChargeParkFee(
|
|
|
cars,null,null,now);
|
|
|
- createTbDeductionRecord(parkFeeDetailsList,tbAccount, totalMoneyBig.subtract(tbBusiness.getItemPrice()),plate);
|
|
|
+ createTbDeductionRecord(parkFeeDetailsList,tbAccount,
|
|
|
+ totalMoneyBig.subtract(tbBusiness.getItemPrice()),plate,bind.getCustomerName(),no);
|
|
|
deductionBindService.autoUnbindCar(cars);
|
|
|
}
|
|
|
StaticLog.info("预充值自动缴费成功!,退出收费程序:{}{}" , businessId,tbAccount.getCustomerId());
|
|
@@ -230,41 +232,50 @@ public class AutomaticPay {
|
|
|
return;
|
|
|
}
|
|
|
StaticLog.info("开始自动缴纳停车费:{}" , car.getCarNo());
|
|
|
- if(car.getPay()==1 || car.getPayTime()!=null){
|
|
|
- StaticLog.info("该车辆已缴纳过停车费!,退出收费程序:{}" , car.getCarNo());
|
|
|
- return;
|
|
|
- }
|
|
|
+// 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());
|
|
|
return;
|
|
|
}
|
|
|
- BigDecimal totalBig = new BigDecimal("0");
|
|
|
- String key = null;
|
|
|
- if(!NumberUtil.isNumber(account.getTotalMoney())){
|
|
|
- key = AesUtil.reverse(account.getAccSalt());
|
|
|
- totalBig = new BigDecimal(AesUtil.decryptECB(account.getTotalMoney(),key));
|
|
|
- }
|
|
|
BigDecimal parkFeeBig = null;
|
|
|
if(parkingFee>0){
|
|
|
parkFeeBig = new BigDecimal(String.valueOf(parkingFee));
|
|
|
}else {
|
|
|
parkFeeBig = caulatePrice(car, new Date());
|
|
|
}
|
|
|
+ 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())){
|
|
|
+ key = AesUtil.reverse(account.getAccSalt());
|
|
|
+ totalBig = new BigDecimal(AesUtil.decryptECB(account.getTotalMoney(),key));
|
|
|
+ }
|
|
|
+
|
|
|
BigDecimal balance = totalBig.subtract(parkFeeBig);
|
|
|
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.updateById();
|
|
|
+ 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);
|
|
|
+ createTbDeductionRecord(parkFeeDetailsList,account, totalBig,plate,bind.getCustomerName(),no);
|
|
|
+ createTbInvoiceOrderPark(car,account.getCustomerId(),no);
|
|
|
deductionBindService.autoUnbindCar(cars);
|
|
|
StaticLog.info("停车费自动缴费成功!,退出收费程序:{}" , car.getCarNo());
|
|
|
}
|
|
@@ -276,11 +287,11 @@ public class AutomaticPay {
|
|
|
* @param totalMoneyBig
|
|
|
*/
|
|
|
private void createTbDeductionRecord(List<TbFeeDetails> tbFeeDetailsList,TbAccount tbAccount,
|
|
|
- BigDecimal totalMoneyBig,String plate){
|
|
|
+ BigDecimal totalMoneyBig,String plate,String customerName,String no ){
|
|
|
if(tbFeeDetailsList==null)return;
|
|
|
int i = 0;
|
|
|
String tempMoney = null;
|
|
|
- String bindIdStr = deductionBindService.getBindId(tbAccount.getCustomerId(),plate);
|
|
|
+ String bindIdStr = deductionBindService.getBindId(plate);
|
|
|
for (TbFeeDetails feeDetails : tbFeeDetailsList){
|
|
|
TbDeductionRecord deductionRecord = BeanUtil.toBean(feeDetails,TbDeductionRecord.class);
|
|
|
String totalStr = null;
|
|
@@ -294,15 +305,19 @@ public class AutomaticPay {
|
|
|
deductionRecord.setId(null);
|
|
|
deductionRecord.setDeductionBindId(bindIdStr);
|
|
|
deductionRecord.setCustomerId(tbAccount.getCustomerId());
|
|
|
+ deductionRecord.setCustomerName(customerName);
|
|
|
deductionRecord.setFeeDetailsId(feeDetails.getId());
|
|
|
deductionRecord.setOriginalMoney(totalMoneyBig.toString());
|
|
|
deductionRecord.setDeductMoney(feeDetails.getItemPrice());
|
|
|
deductionRecord.setTotalMoney(totalStr);
|
|
|
deductionRecord.setReviewStatus(0);
|
|
|
deductionRecord.setCarNo(plate);
|
|
|
+ deductionRecord.setPreOrderNum(no);
|
|
|
deductionRecord.insert();
|
|
|
feeDetails.setCarNo(plate);
|
|
|
+ feeDetails.setPreOrderNum(no);
|
|
|
feeDetails.setCustomerId(tbAccount.getCustomerId());
|
|
|
+ feeDetails.setCustomerName(customerName);
|
|
|
tbFeeDetailsService.updateById(feeDetails);
|
|
|
i++;
|
|
|
}
|
|
@@ -332,7 +347,7 @@ public class AutomaticPay {
|
|
|
* @param tbBusiness
|
|
|
*/
|
|
|
private void createTbInvoiceOrder(TbBusiness tbBusiness,List<TbBusinessCar> cars, BigDecimal parkingFee,
|
|
|
- String plate,boolean isOut){
|
|
|
+ String plate, String customerId, String no, boolean isOut){
|
|
|
TbInvoiceOrder invoiceOrder = new TbInvoiceOrder();
|
|
|
List<String> businessNameList = new ArrayList<>();
|
|
|
List<String> businessNoList = new ArrayList<>();
|
|
@@ -371,7 +386,19 @@ public class AutomaticPay {
|
|
|
}
|
|
|
invoiceOrder.setBusinessName(businessNameStr).setBusinessNo(businessNoStr).setCarNo(carNoStr)
|
|
|
.setTransactionId(null).setBillMoney(billMoney).setBusinessId(tbBusiness.getId())
|
|
|
- .setStatus(0).setCreateTime(new Date()).setCustomerId(tbBusiness.getCustomerId());
|
|
|
+ .setStatus(0).setCreateTime(new Date()).setCustomerId(customerId).setPreOrderNum(no);
|
|
|
+ invoiceOrderService.save(invoiceOrder);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 无业务车辆收停车费生成发票信息
|
|
|
+ */
|
|
|
+ private void createTbInvoiceOrderPark(TbBusinessCar car, String customerId,String no){
|
|
|
+ TbInvoiceOrder invoiceOrder = new TbInvoiceOrder();
|
|
|
+
|
|
|
+ invoiceOrder.setBusinessName("停车费").setBusinessNo(car.getNo()).setCarNo(car.getCarNo())
|
|
|
+ .setTransactionId(null).setBillMoney(car.getMoney()).setBusinessId(null)
|
|
|
+ .setStatus(0).setCreateTime(new Date()).setCustomerId(customerId).setPreOrderNum(no);
|
|
|
invoiceOrderService.save(invoiceOrder);
|
|
|
}
|
|
|
|