|
@@ -133,12 +133,10 @@ public class AutomaticPay {
|
|
|
*/
|
|
|
public boolean payBusinessAndPartMoney(List<TbBusiness> businessList,
|
|
|
TbBusinessCar tbBusinessCar,
|
|
|
- IOrderPriceRes partMoneyRes, BigDecimal totalMoney, List<TbCarWeight> carWeights, TbAccount tbAccount) {
|
|
|
+ IOrderPriceRes partMoneyRes, List<TbCarWeight> carWeights, BigDecimal originalMoney) {
|
|
|
|
|
|
Date now = new Date();
|
|
|
String customerId = tbBusinessCar.getCustomerId();
|
|
|
- //原金额
|
|
|
- BigDecimal originalMoney = tbAccount.getTotalMoney();
|
|
|
//停车费扣除
|
|
|
BigDecimal partMoney = partMoneyRes.getTotalOrderPrice();
|
|
|
//过磅费
|
|
@@ -146,19 +144,6 @@ public class AutomaticPay {
|
|
|
for (TbCarWeight carWeight : carWeights) {
|
|
|
weightMoney = weightMoney.add(carWeight.getWeightPrice());
|
|
|
}
|
|
|
- if (totalMoney.compareTo(originalMoney) > 0) {
|
|
|
- return false;//不够交
|
|
|
- }
|
|
|
- BigDecimal finalOriginalMoney2 = originalMoney;
|
|
|
- new Thread(() -> {
|
|
|
- //余额
|
|
|
- BigDecimal balance = finalOriginalMoney2.subtract(totalMoney);
|
|
|
- log.info("Balance: " + balance);
|
|
|
- tbAccount.setTotalMoney(balance);
|
|
|
- //更新账户余额
|
|
|
- boolean flag = tbAccountService.updateById(tbAccount);
|
|
|
- log.info("update result:{},{},{},{}",finalOriginalMoney2,flag,totalMoney,balance);
|
|
|
- }).start();
|
|
|
TbCostomer tbCostomer = tbCostomerService.getById(customerId);
|
|
|
String customerName = tbCostomer.getName();
|
|
|
//地磅费统计
|
|
@@ -167,14 +152,12 @@ public class AutomaticPay {
|
|
|
TbItem tbItem = tbItemService.findByAliasName(SystemObject.config.getWeighbridge());
|
|
|
for (TbCarWeight carWeight : carWeights) {
|
|
|
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();
|
|
|
+ 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);
|
|
|
originalMoney = originalMoney.subtract(carWeight.getWeightPrice());
|
|
|
}
|
|
|
}
|
|
@@ -212,21 +195,19 @@ public class AutomaticPay {
|
|
|
List<TbFeeDetails> parkFeeDetailsList = tbFeeDetailsService.chargeParkFee(priceBOList, null, null, now, PayEnum.PayType.PER_PAY);
|
|
|
//停车费明细
|
|
|
for (TbFeeDetails tbFeeDetails : parkFeeDetailsList) {
|
|
|
- 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();
|
|
|
+ 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);
|
|
|
originalMoney = originalMoney.subtract(tbFeeDetails.getItemPrice());
|
|
|
}
|
|
|
}
|
|
|
//业务费用
|
|
|
for (TbBusiness tbBusiness : businessList) {
|
|
|
List<TbBusinessItem> items = tbBusinessItemService.findByBusinessId(tbBusiness.getId());
|
|
|
- items = items.stream().filter(item -> item.getPayStatus() == 0).collect(Collectors.toList());
|
|
|
+ items = items.stream()
|
|
|
+ .filter(item -> item.getPayStatus() == 0&&!SystemObject.config.getEveryCarPay().contains(item.getItemName()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
for (TbBusinessItem item : items) {
|
|
|
if (item.getPayStatus() == 1) {//已支付的
|
|
|
continue;
|
|
@@ -248,8 +229,10 @@ public class AutomaticPay {
|
|
|
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);
|
|
|
+ new Thread(()->{
|
|
|
+ invoiceOrderService.addInvoiceOrder(tbBusiness.getGoodsName(), tbBusiness.getNo(), tbBusiness.getCarNoStr(), tbBusiness.getId(),
|
|
|
+ tbBusiness.getCustomerId(), tbBusiness.getCustomerName(), tbBusiness.getCustomerName(), res.getTotalOrderPrice(), details, record);
|
|
|
+ }).start();
|
|
|
originalMoney = originalMoney.subtract(details.getItemPrice());
|
|
|
log.info("after originalMoney:{}", originalMoney);
|
|
|
} else {
|