|
@@ -1,432 +0,0 @@
|
|
|
-package com.pj.project.tb_business_item;
|
|
|
-
|
|
|
-
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
-import cn.hutool.core.codec.Base64;
|
|
|
-import cn.hutool.core.util.NumberUtil;
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
-import cn.hutool.core.util.RandomUtil;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
-import cn.hutool.extra.spring.SpringUtil;
|
|
|
-import cn.hutool.log.StaticLog;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.pj.api.wx.bo.PriceBO;
|
|
|
-import com.pj.constants.business.CarEnum;
|
|
|
-import com.pj.constants.business.GoodsEnum;
|
|
|
-import com.pj.constants.business.PayEnum;
|
|
|
-import com.pj.current.task.Task;
|
|
|
-import com.pj.project.tb_account.TbAccount;
|
|
|
-import com.pj.project.tb_account.TbAccountService;
|
|
|
-import com.pj.project.tb_business.TbBusiness;
|
|
|
-import com.pj.project.tb_business.TbBusinessService;
|
|
|
-import com.pj.project.tb_business_car.TbBusinessCar;
|
|
|
-import com.pj.project.tb_business_car.TbBusinessCarService;
|
|
|
-import com.pj.project.tb_deduction_bind.TbDeductionBind;
|
|
|
-import com.pj.project.tb_deduction_bind.TbDeductionBindService;
|
|
|
-import com.pj.project.tb_deduction_record.TbDeductionRecord;
|
|
|
-import com.pj.project.tb_fee_details.TbFeeDetails;
|
|
|
-import com.pj.project.tb_fee_details.TbFeeDetailsService;
|
|
|
-import com.pj.project.tb_goods.TbGoods;
|
|
|
-import com.pj.project.tb_invoice_order.TbInvoiceOrder;
|
|
|
-import com.pj.project.tb_invoice_order.TbInvoiceOrderService;
|
|
|
-import com.pj.project.tb_pay_record.TbPayRecord;
|
|
|
-import com.pj.project.tb_pay_record.TbPayRecordService;
|
|
|
-import com.pj.utils.AesUtil;
|
|
|
-import com.pj.utils.sg.NbUtil;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
-
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-
|
|
|
-public class PayTask extends Task {
|
|
|
-
|
|
|
- private String businessId;
|
|
|
- private String customerId;
|
|
|
- private String plate;
|
|
|
-
|
|
|
- public PayTask(String businessId, long delayInMilliseconds, String customerId, String plate) {
|
|
|
- super(businessId, delayInMilliseconds);
|
|
|
- this.businessId = businessId;
|
|
|
- this.customerId = customerId;
|
|
|
- this.plate = plate;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor={RuntimeException.class, Exception.class})
|
|
|
- public void run() {
|
|
|
-// StaticLog.info("开始执行自动扣款业务:{},{}", customerId, businessId);
|
|
|
-// TbAccountService tbAccountService = SpringUtil.getBean(TbAccountService.class);
|
|
|
-// TbAccount tbAccount = tbAccountService.getByCustomerId(customerId);
|
|
|
-// if (tbAccount == null) {
|
|
|
-// StaticLog.info("该客户还未开通存款账户,退出扣款程序:{}", customerId);
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// String totalMoney = AesUtil.decryptECB(tbAccount.getTotalMoney(),AesUtil.reverse(tbAccount.getAccSalt()));
|
|
|
-// BigDecimal money = new BigDecimal(0);
|
|
|
-// if (NumberUtil.isNumber(totalMoney)) {
|
|
|
-// money = new BigDecimal(totalMoney);
|
|
|
-// }
|
|
|
-// chargeBusinessFee(null,null);
|
|
|
-// // BigDecimal money = new BigDecimal(Base64.decodeStr(totalMoney));
|
|
|
-// TbBusinessService tbBusinessService = SpringUtil.getBean(TbBusinessService.class);
|
|
|
-// TbBusiness tbBusiness = tbBusinessService.getById(businessId);
|
|
|
-// TbBusinessItemService tbBusinessItemService = SpringUtil.getBean(TbBusinessItemService.class);
|
|
|
-// List<TbBusinessItem> list = tbBusinessItemService.findByBusinessId(businessId);
|
|
|
-// List<TbBusinessItem> allList = list;
|
|
|
-// long notConfirmCount = list.stream()
|
|
|
-// .filter(tbBusinessItem -> tbBusinessItem.getConfirm() == 0 && !StrUtil.equals(tbBusinessItem.getBusinessType(), "0"))
|
|
|
-// .count();
|
|
|
-// Date now = new Date();
|
|
|
-// if (notConfirmCount == 0) {
|
|
|
-// BigDecimal shouldPay = new BigDecimal("0");
|
|
|
-// list = allList.stream().filter(tbBusinessItem -> tbBusinessItem.getPayStatus() == 0).collect(Collectors.toList());
|
|
|
-// for (TbBusinessItem tbBusinessItem : list) {
|
|
|
-// tbBusinessItem.setPayStatus(1).setPayTime(now);
|
|
|
-// shouldPay = shouldPay.add(tbBusinessItem.getItemPrice());
|
|
|
-// }
|
|
|
-//
|
|
|
-// TbBusinessCarService tbBusinessCarService = SpringUtil.getBean(TbBusinessCarService.class);
|
|
|
-// List<TbBusinessCar> cars = tbBusinessCarService.findOtherBusinessCar(businessId);
|
|
|
-// cars = cars.stream().filter(tbBusinessCar -> tbBusinessCar.getPay() == 0).collect(Collectors.toList());
|
|
|
-// for (TbBusinessCar tbBusinessCar : cars) {
|
|
|
-// shouldPay = shouldPay.add(tbBusinessCar.getBasePartMoney());
|
|
|
-// tbBusinessCar.setPayTime(now).setPay(1);
|
|
|
-// }
|
|
|
-// if (shouldPay.subtract(money).doubleValue() > 0) {
|
|
|
-// StaticLog.error("账户支付余额不足");
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// String no = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) + RandomUtil.randomNumbers(4);
|
|
|
-// tbBusiness.setPayMoney(tbBusiness.getPayMoney().add(shouldPay)).setPayTime(now)
|
|
|
-// .setPayNo(no);
|
|
|
-// tbBusiness.setPayStatus(tbBusiness.getPayMoney().equals(tbBusiness.getTotalMoney()) ? 3 : 4);
|
|
|
-// tbBusinessItemService.updateBatchById(list);
|
|
|
-// tbBusinessService.updateById(tbBusiness);
|
|
|
-// tbBusinessCarService.updateBatchById(cars);
|
|
|
-// BigDecimal leftMoney = money.subtract(shouldPay);
|
|
|
-// tbAccount.setTotalMoney(Base64.encode(leftMoney.toString()));
|
|
|
-// tbAccountService.updateById(tbAccount);
|
|
|
-// TbPayRecord payRecord = new TbPayRecord();
|
|
|
-// TbPayRecordService tbPayRecordService = SpringUtil.getBean(TbPayRecordService.class);
|
|
|
-// payRecord.setCreateTime(now)
|
|
|
-// .setOutTradeNo(no)
|
|
|
-// .setTransactionId(no)
|
|
|
-// .setPayMoney(shouldPay)
|
|
|
-// .setCustomerId(tbBusiness.getCustomerId()).setCustomerName(tbBusiness.getCustomerName());
|
|
|
-// tbPayRecordService.save(payRecord);
|
|
|
-// }
|
|
|
- try {
|
|
|
- TbBusinessCarService tbBusinessCarService = SpringUtil.getBean(TbBusinessCarService.class);
|
|
|
- if(!NbUtil.isNull(this.businessId) && NbUtil.isNull(this.plate)){
|
|
|
- List<TbBusinessCar> cars = tbBusinessCarService.findOtherBusinessCar(this.businessId);
|
|
|
- for (TbBusinessCar car : cars){
|
|
|
- this.doBusinessFee(this.businessId,car.getCarNo());
|
|
|
- }
|
|
|
- }else {
|
|
|
- doOutFee(this.plate);
|
|
|
- }
|
|
|
- }catch (RuntimeException e){
|
|
|
-
|
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 收业务费
|
|
|
- * @param businessId
|
|
|
- */
|
|
|
- private void doBusinessFee(String businessId,String plate){
|
|
|
- if(!NumberUtil.isNumber(businessId) || NbUtil.isNull(plate)){
|
|
|
- return;
|
|
|
- }
|
|
|
- StaticLog.info("开始收取业务费:{}" , businessId);
|
|
|
- TbBusinessService tbBusinessService = SpringUtil.getBean(TbBusinessService.class);
|
|
|
- TbBusiness tbBusiness = tbBusinessService.getById(businessId);
|
|
|
- if(PayEnum.PayStatusEnum.NO_PAY.getCode()!=tbBusiness.getPayStatus()){
|
|
|
- StaticLog.info("已收取过业务费,退出收费程序:{}" , businessId);
|
|
|
- return;
|
|
|
- }
|
|
|
- if(!NumberUtil.isNumber(tbBusiness.getItemPrice().toString())){
|
|
|
- StaticLog.info("未获取到收费总金额或收费总金额非法,退出收费程序:{}" , businessId);
|
|
|
- return;
|
|
|
- }
|
|
|
- TbDeductionBindService deductionBindService = SpringUtil.getBean(TbDeductionBindService.class);
|
|
|
- if(!deductionBindService.checkBind(tbBusiness.getCustomerId(),plate)){
|
|
|
- StaticLog.info("业务车辆未绑定指定客户的预存款账户,退出收费程序:{}{}",businessId,tbBusiness.getCustomerName());
|
|
|
- return;
|
|
|
- }
|
|
|
- TbBusinessCarService tbBusinessCarService = SpringUtil.getBean(TbBusinessCarService.class);
|
|
|
- List<TbBusinessCar> cars = tbBusinessCarService.findOtherBusinessCar(businessId);
|
|
|
- TbAccountService tbAccountService = SpringUtil.getBean(TbAccountService.class);
|
|
|
- TbAccount tbAccount = tbAccountService.getByCustomerId(tbBusiness.getCustomerId());
|
|
|
- String key = AesUtil.reverse(tbAccount.getAccSalt());
|
|
|
- String totalMoney = tbAccount.getTotalMoney();
|
|
|
- BigDecimal parkingMoneyBig = new BigDecimal(0);
|
|
|
- BigDecimal totalMoneyBig = new BigDecimal(totalMoney);
|
|
|
- BigDecimal balance = totalMoneyBig.subtract(tbBusiness.getItemPrice());
|
|
|
- boolean isOut = (GoodsEnum.DeductionTypeEnum.OUT_KK.getCode()==tbBusiness.getAutoDeductionType())&&NbUtil.isNull(this.plate);
|
|
|
- if(isOut){
|
|
|
- parkingMoneyBig = getParkings(cars);
|
|
|
- balance = balance.subtract(parkingMoneyBig);
|
|
|
- }
|
|
|
- if(balance.doubleValue()<0){
|
|
|
- StaticLog.info("支付账户余额不足!,退出收费程序:{}" , businessId);
|
|
|
- deductionBindService.setFeeFailRecord(tbBusiness.getCustomerId(),plate,
|
|
|
- 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(
|
|
|
- PayEnum.PayStatusEnum.HAS_PAY_CONFIRM.getCode());
|
|
|
- tbBusiness.updateById();
|
|
|
- TbBusinessItemService tbBusinessItemService = SpringUtil.getBean(TbBusinessItemService.class);
|
|
|
- List<TbBusinessItem> businessItems = tbBusinessItemService.findByBusinessId(businessId);
|
|
|
- for(TbBusinessItem businessItem:businessItems){
|
|
|
- if(businessItem.getPayStatus()==1){
|
|
|
- continue;
|
|
|
- }
|
|
|
- businessItem.setPayStatus(1).setPayTime(now);
|
|
|
- }
|
|
|
- tbBusinessItemService.updateBatchById(businessItems);
|
|
|
- if(isOut){
|
|
|
- this.updateTbBusinessCars(cars);
|
|
|
- }
|
|
|
- //更新账户余额
|
|
|
- tbAccount.setTotalMoney(AesUtil.encryptECB(balance.toString(),key));
|
|
|
- tbAccount.updateById();
|
|
|
- deductionBindService.setDeductMoney(tbBusiness.getCustomerId(),plate,tbBusiness.getItemPrice());
|
|
|
- //生成收费明细
|
|
|
- TbFeeDetailsService tbFeeDetailsService = SpringUtil.getBean(TbFeeDetailsService.class);
|
|
|
- List<TbFeeDetails> tbFeeDetailsList = tbFeeDetailsService.autoChargeBusinessFee(
|
|
|
- businessItems,null,null,now);
|
|
|
- //生成扣费记录
|
|
|
- createTbDeductionRecord(tbFeeDetailsList,deductionBindService,tbFeeDetailsService,tbAccount,
|
|
|
- tbBusiness,totalMoneyBig,plate);
|
|
|
- //生成开票信息
|
|
|
- createTbInvoiceOrder(tbBusiness,cars,parkingMoneyBig);
|
|
|
- if(isOut){
|
|
|
- List<PriceBO> priceBOList=cars.stream().map(tbBusinessCar -> new PriceBO(tbBusinessCar.getId(),tbBusinessCar.getMoney())).collect(Collectors.toList());
|
|
|
- List<TbFeeDetails> parkFeeDetailsList = tbFeeDetailsService.chargeParkFee(
|
|
|
- priceBOList,null,null,now,PayEnum.PayType.PER_PAY);
|
|
|
- createTbDeductionRecord(parkFeeDetailsList,deductionBindService,tbFeeDetailsService,tbAccount,
|
|
|
- tbBusiness,totalMoneyBig,plate);
|
|
|
- deductionBindService.autoUnbindCar(cars);
|
|
|
- }
|
|
|
- StaticLog.info("预充值自动缴费成功!,退出收费程序:{}{}" , businessId,tbAccount.getCustomerId());
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 出场所收费,根据车牌号
|
|
|
- * @param plate
|
|
|
- */
|
|
|
- private void doOutFee(String plate){
|
|
|
- if(NbUtil.isNull(plate)){
|
|
|
- return;
|
|
|
- }
|
|
|
- TbBusinessCarService tbBusinessCarService = SpringUtil.getBean(TbBusinessCarService.class);
|
|
|
- TbBusinessCar tbBusinessCar = tbBusinessCarService.findTheLastRecord(plate);
|
|
|
- if(tbBusinessCar==null){
|
|
|
- return;
|
|
|
- }
|
|
|
- TbBusinessService tbBusinessService = SpringUtil.getBean(TbBusinessService.class);
|
|
|
- List<TbBusiness> businessList = tbBusinessService.findOtherBusinessByCarId(tbBusinessCar.getId());
|
|
|
- if(businessList==null){return;}
|
|
|
- for (TbBusiness business: businessList){
|
|
|
- List<TbBusinessCar> cars = tbBusinessCarService.findOtherBusinessCar(business.getId());
|
|
|
- if(cars==null)continue;
|
|
|
- for (TbBusinessCar car:cars){
|
|
|
- doBusinessFee(business.getId(), car.getCarNo());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- private void doParkingFee(TbBusinessCar car, double parkingFee){
|
|
|
- if(car==null)return;
|
|
|
- StaticLog.info("开始自动缴纳停车费:{}" , car.getCarNo());
|
|
|
- if(car.getPay()==1 || car.getPayTime()!=null){
|
|
|
- StaticLog.info("该车辆已缴纳过停车费!,退出收费程序:{}" , car.getCarNo());
|
|
|
- return;
|
|
|
- }
|
|
|
- TbAccountService tbAccountService = SpringUtil.getBean(TbAccountService.class);
|
|
|
- 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 {
|
|
|
- TbBusinessService tbBusinessService = SpringUtil.getBean(TbBusinessService.class);
|
|
|
- parkFeeBig = caulatePrice(car, new Date(), tbBusinessService);
|
|
|
- }
|
|
|
- BigDecimal balance = totalBig.subtract(parkFeeBig);
|
|
|
- if(balance.doubleValue()<0){
|
|
|
- StaticLog.info("支付账户余额不足!,退出收费程序:{}" , car.getCarNo());
|
|
|
- return;
|
|
|
- }
|
|
|
- car.setMoney(parkFeeBig);
|
|
|
- updateTbBusinessCar(car);
|
|
|
- account.setTotalMoney(AesUtil.encryptECB(balance.toString(),key));
|
|
|
- account.updateById();
|
|
|
-// List<TbFeeDetails> parkFeeDetailsList = tbFeeDetailsService.autoChargeParkFee(
|
|
|
-// cars,null,null,now);
|
|
|
-// createTbDeductionRecord(parkFeeDetailsList,deductionBindService,tbFeeDetailsService,tbAccount,
|
|
|
-// tbBusiness,totalMoneyBig,plate);
|
|
|
-// deductionBindService.autoUnbindCar(cars);
|
|
|
- StaticLog.info("停车费自动缴费成功!,退出收费程序:{}" , car.getCarNo());
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成扣费记录
|
|
|
- * @param tbFeeDetailsList
|
|
|
- * @param deductionBindService
|
|
|
- * @param tbFeeDetailsService
|
|
|
- * @param tbAccount
|
|
|
- * @param tbBusiness
|
|
|
- * @param totalMoneyBig
|
|
|
- */
|
|
|
- private void createTbDeductionRecord(List<TbFeeDetails> tbFeeDetailsList,TbDeductionBindService deductionBindService,
|
|
|
- TbFeeDetailsService tbFeeDetailsService,TbAccount tbAccount,
|
|
|
- TbBusiness tbBusiness,BigDecimal totalMoneyBig,String plate){
|
|
|
- if(tbFeeDetailsList==null)return;
|
|
|
- int i = 0;
|
|
|
- for (TbFeeDetails feeDetails : tbFeeDetailsList){
|
|
|
- TbDeductionRecord deductionRecord = BeanUtil.toBean(feeDetails,TbDeductionRecord.class);
|
|
|
- if(GoodsEnum.DeductionTypeEnum.BUSINESS_OK.getCode()==tbBusiness.getAutoDeductionType()){
|
|
|
- String bindIdStr = deductionBindService.getBindId(plate);
|
|
|
- deductionRecord.setDeductionBindId(bindIdStr);
|
|
|
- }
|
|
|
- String totalStr = null;
|
|
|
-// if(!NbUtil.isNull(totalStr) && !NumberUtil.isNumber(totalStr)){
|
|
|
-// totalStr = AesUtil.decryptECB(totalStr,AesUtil.reverse(tbAccount.getAccSalt()));
|
|
|
-// }
|
|
|
- if(totalMoneyBig!=null && feeDetails.getNoTaxPrice()!=null){
|
|
|
- if(i!=0){
|
|
|
- totalMoneyBig = new BigDecimal(deductionRecord.getTotalMoney());
|
|
|
- }
|
|
|
- totalStr = totalMoneyBig.subtract(feeDetails.getNoTaxPrice()).toString();
|
|
|
- }
|
|
|
- deductionRecord.setId(null);
|
|
|
- deductionRecord.setCustomerId(tbAccount.getCustomerId());
|
|
|
- deductionRecord.setFeeDetailsId(feeDetails.getId());
|
|
|
- deductionRecord.setOriginalMoney(totalMoneyBig.toString());
|
|
|
- deductionRecord.setDeductMoney(feeDetails.getNoTaxPrice());
|
|
|
- deductionRecord.setTotalMoney(totalStr);
|
|
|
- deductionRecord.setReviewStatus(0);
|
|
|
- deductionRecord.setCarNo(plate);
|
|
|
- deductionRecord.insert();
|
|
|
- feeDetails.setCarNo(plate);
|
|
|
- feeDetails.setCustomerId(tbAccount.getCustomerId());
|
|
|
- tbFeeDetailsService.updateById(feeDetails);
|
|
|
- i++;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新停车费状态
|
|
|
- */
|
|
|
- private void updateTbBusinessCar(TbBusinessCar car){
|
|
|
- if(car == null)return;
|
|
|
- car.setPay(1).setMoney(car.getMoney()).setPayTime(new Date()).setPayType(
|
|
|
- CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType());
|
|
|
- car.updateById();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 更新停车费状态
|
|
|
- */
|
|
|
- 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){
|
|
|
- TbInvoiceOrder invoiceOrder = new TbInvoiceOrder();
|
|
|
- List<String> businessNameList = new ArrayList<>();
|
|
|
- List<String> businessNoList = new ArrayList<>();
|
|
|
- List<String> carNos = new ArrayList<>();
|
|
|
- businessNoList.add(tbBusiness.getNo());
|
|
|
- carNos.add(tbBusiness.getCardNo());
|
|
|
- businessNameList.add(tbBusiness.getGoodsName());
|
|
|
- if(cars!=null && (GoodsEnum.DeductionTypeEnum.OUT_KK.getCode()==tbBusiness.getAutoDeductionType()) &&
|
|
|
- NbUtil.isNull(this.plate)){
|
|
|
- businessNameList.add("停车费");
|
|
|
- for (TbBusinessCar car : cars) {
|
|
|
- businessNoList.add(car.getNo());
|
|
|
- carNos.add(car.getCarNo());
|
|
|
- }
|
|
|
- }
|
|
|
- String businessNameStr = businessNameList.stream().map(String::valueOf).collect(Collectors.joining(","));
|
|
|
- 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){
|
|
|
- billMoney = parkingFee.add(billMoney);
|
|
|
- }
|
|
|
- invoiceOrder.setBusinessName(businessNameStr).setBusinessNo(businessNoStr).setCarNo(carNoStr)
|
|
|
- .setTransactionId(null).setBillMoney(billMoney)
|
|
|
- .setStatus(0).setCreateTime(new Date()).setCustomerId(tbBusiness.getCustomerId());
|
|
|
- TbInvoiceOrderService invoiceOrderService = SpringUtil.getBean(TbInvoiceOrderService.class);
|
|
|
- invoiceOrderService.save(invoiceOrder);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成停车费
|
|
|
- * @param tbBusinessCar
|
|
|
- * @param now
|
|
|
- * @return
|
|
|
- */
|
|
|
- private BigDecimal caulatePrice(TbBusinessCar tbBusinessCar, Date now, TbBusinessService tbBusinessService) {
|
|
|
- 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();
|
|
|
- }
|
|
|
- BigDecimal price = tbBusinessService.calculationPartMoney(inTime, now,tbBusinessCar.getCarSize());
|
|
|
- return price;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取所有停车费总和
|
|
|
- * @param cars
|
|
|
- * @return
|
|
|
- */
|
|
|
- private BigDecimal getParkings(List<TbBusinessCar> cars){
|
|
|
- if(cars==null) new BigDecimal("0");
|
|
|
- Date now = new Date();
|
|
|
- BigDecimal value = new BigDecimal("0");
|
|
|
- TbBusinessService tbBusinessService = SpringUtil.getBean(TbBusinessService.class);
|
|
|
- for (TbBusinessCar tbBusinessCar:cars){
|
|
|
- value = value.add(this.caulatePrice(tbBusinessCar,now,tbBusinessService));
|
|
|
- }
|
|
|
- return value;
|
|
|
- }
|
|
|
-}
|