|
@@ -3,6 +3,7 @@ package com.pj.project.tb_account;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.thread.ThreadUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
@@ -133,6 +134,7 @@ public class AutomaticPay {
|
|
|
public boolean payBusinessAndPartMoney(List<TbBusiness> businessList,
|
|
|
TbBusinessCar tbBusinessCar,
|
|
|
IOrderPriceRes partMoneyRes, BigDecimal businessMoney, List<TbCarWeight> carWeights) {
|
|
|
+
|
|
|
Date now = new Date();
|
|
|
String customerId = tbBusinessCar.getCustomerId();
|
|
|
if (StrUtil.isEmpty(customerId)) {
|
|
@@ -141,14 +143,8 @@ public class AutomaticPay {
|
|
|
TbAccount tbAccount = tbAccountService.getAccountByCustomerId(customerId);
|
|
|
//原金额
|
|
|
BigDecimal originalMoney = tbAccount.getTotalMoney();
|
|
|
-
|
|
|
-
|
|
|
//停车费扣除
|
|
|
BigDecimal partMoney = partMoneyRes.getTotalOrderPrice();
|
|
|
-
|
|
|
- //业务费用
|
|
|
-// BigDecimal businessMoney = businessRes.getTotalOrderPrice();
|
|
|
-
|
|
|
//过磅费
|
|
|
BigDecimal weightMoney = BigDecimal.ZERO;
|
|
|
for (TbCarWeight carWeight : carWeights) {
|
|
@@ -159,9 +155,6 @@ public class AutomaticPay {
|
|
|
if (totalMoney.compareTo(originalMoney) > 0) {
|
|
|
return false;//不够交
|
|
|
}
|
|
|
- log.info("payment============:{}",partMoney);
|
|
|
- log.info("businessMoney=========:{}",businessMoney);
|
|
|
- log.info("totalMoney==========:{}",totalMoney);
|
|
|
//余额
|
|
|
BigDecimal balance = originalMoney.subtract(totalMoney);
|
|
|
log.info("Balance: " + balance);
|
|
@@ -175,12 +168,16 @@ public class AutomaticPay {
|
|
|
tbBusinessCar.setNetweightMoney(weightMoney).setPayNetweightMoney(1);
|
|
|
TbItem tbItem = tbItemService.findByAliasName(SystemObject.config.getWeighbridge());
|
|
|
for (TbCarWeight carWeight : carWeights) {
|
|
|
- TbFeeDetails details = tbFeeDetailsService.saveCarWeightDetails("",carWeight.getWeightPrice(), carWeight.getCalculateId(), carWeight.getNo(), tbBusinessCar, customerName, customerName, tbItem, PayEnum.PayType.PER_PAY);
|
|
|
- createTbDeductionRecord(details, originalMoney, BigDecimal.ZERO, customerId, customerName,
|
|
|
- tbBusinessCar.getCarNo(), tbBusinessCar.getId(), FeeTypeEnum.WEIGHT_FEE);
|
|
|
- carWeight.setPayStatus(1).setPayTime(now).setPayType(PayEnum.PayType.PER_PAY.getCode());
|
|
|
- tbCarWeightService.updateById(carWeight);
|
|
|
- originalMoney=originalMoney.subtract(carWeight.getWeightPrice());
|
|
|
+ BigDecimal finalOriginalMoney = originalMoney;
|
|
|
+ new Thread(() -> {
|
|
|
+ TbFeeDetails details = tbFeeDetailsService.saveCarWeightDetails("", carWeight.getWeightPrice(), carWeight.getCalculateId(), carWeight.getNo(), tbBusinessCar, customerName, customerName, tbItem, PayEnum.PayType.PER_PAY);
|
|
|
+ createTbDeductionRecord(details, finalOriginalMoney, BigDecimal.ZERO, customerId, customerName,
|
|
|
+ tbBusinessCar.getCarNo(), tbBusinessCar.getId(), FeeTypeEnum.WEIGHT_FEE);
|
|
|
+ carWeight.setPayStatus(1).setPayTime(now).setPayType(PayEnum.PayType.PER_PAY.getCode());
|
|
|
+ tbCarWeightService.updateById(carWeight);
|
|
|
+ tbFeeDetailsService.saveInvoiceOrder(details);
|
|
|
+ }).start();
|
|
|
+ originalMoney = originalMoney.subtract(carWeight.getWeightPrice());
|
|
|
}
|
|
|
}
|
|
|
//需要交停车费且未交的话
|
|
@@ -217,10 +214,14 @@ public class AutomaticPay {
|
|
|
List<TbFeeDetails> parkFeeDetailsList = tbFeeDetailsService.chargeParkFee(priceBOList, null, null, now, PayEnum.PayType.PER_PAY);
|
|
|
//停车费明细
|
|
|
for (TbFeeDetails tbFeeDetails : parkFeeDetailsList) {
|
|
|
- tbFeeDetails.setBusinessNo(businessNo);
|
|
|
- TbDeductionRecord record = this.createTbDeductionRecord(tbFeeDetails, originalMoney, BigDecimal.ZERO,
|
|
|
- customerId, customerName, plate, tbBusinessCar.getId(), FeeTypeEnum.PARK_FEE);
|
|
|
- invoiceOrderService.addInvoiceOrder("停车业务", businessNo, tbBusinessCar.getCarNo(), tbBusiness.getId(), tbBusinessCar.getCustomerId(), tbBusiness.getCustomerName(), tbBusiness.getCustomerName(), tbFeeDetails.getItemPrice(), tbFeeDetails, record);
|
|
|
+ BigDecimal finalOriginalMoney1 = originalMoney;
|
|
|
+ new Thread(() -> {
|
|
|
+ tbFeeDetails.setBusinessNo(businessNo);
|
|
|
+ TbDeductionRecord record = this.createTbDeductionRecord(tbFeeDetails, finalOriginalMoney1, BigDecimal.ZERO,
|
|
|
+ customerId, customerName, plate, tbBusinessCar.getId(), FeeTypeEnum.PARK_FEE);
|
|
|
+ invoiceOrderService.addInvoiceOrder("停车业务", businessNo, tbBusinessCar.getCarNo(), tbBusiness.getId(), tbBusinessCar.getCustomerId(), tbBusiness.getCustomerName(), tbBusiness.getCustomerName(), tbFeeDetails.getItemPrice(), tbFeeDetails, record);
|
|
|
+
|
|
|
+ }).start();
|
|
|
originalMoney = originalMoney.subtract(tbFeeDetails.getItemPrice());
|
|
|
}
|
|
|
}
|
|
@@ -246,13 +247,13 @@ public class AutomaticPay {
|
|
|
int feeType = item.getPayType();
|
|
|
FeeTypeEnum feeTypeEnum = FeeTypeEnum.getEnum(feeType);
|
|
|
TbFeeDetails details = tbFeeDetailsService.savePrePayDetails(res, item, tbBusinessCar, tbBusiness, tbBusiness.getCustomerName(), tbBusiness.getPickCustomerName(), feeTypeEnum);
|
|
|
- log.info("originalMoney:{}",originalMoney);
|
|
|
+ log.info("originalMoney:{}", originalMoney);
|
|
|
TbDeductionRecord record = createTbDeductionRecord(details, originalMoney, BigDecimal.ZERO, customerId, tbBusiness.getCustomerName(),
|
|
|
tbBusinessCar.getCarNo(), tbBusinessCar.getId(), feeTypeEnum);
|
|
|
invoiceOrderService.addInvoiceOrder(tbBusiness.getGoodsName(), tbBusiness.getNo(), tbBusiness.getCarNoStr(), tbBusiness.getId(),
|
|
|
tbBusiness.getCustomerId(), tbBusiness.getCustomerName(), tbBusiness.getCustomerName(), res.getTotalOrderPrice(), details, record);
|
|
|
- originalMoney=originalMoney.subtract(details.getItemPrice());
|
|
|
- log.info("after originalMoney:{}",originalMoney);
|
|
|
+ originalMoney = originalMoney.subtract(details.getItemPrice());
|
|
|
+ log.info("after originalMoney:{}", originalMoney);
|
|
|
} else {
|
|
|
tbBusiness.setPayMoney(tbBusiness.getPayMoney().add(partMoney)).setItemPrice(BigDecimal.ZERO);
|
|
|
}
|