|
@@ -122,12 +122,12 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
|
|
|
return getOne(qw);
|
|
|
}
|
|
|
|
|
|
- public TbFeeDetails getByBusinessCarIdAndCarNoAndFeeType(String businessCarId, String carNo, Integer feeType){
|
|
|
+ public List<TbFeeDetails> getByBusinessCarIdAndCarNoAndFeeType(String businessCarId, String carNo, Integer feeType){
|
|
|
QueryWrapper<TbFeeDetails> qw = new QueryWrapper<>();
|
|
|
qw.eq("business_car_id", businessCarId);
|
|
|
qw.eq("car_no", carNo);
|
|
|
qw.eq("fee_type", feeType);
|
|
|
- return getOne(qw);
|
|
|
+ return list(qw);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -142,21 +142,21 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
|
|
|
TbBusinessCar car = tbBusinessCarService.getById(bo1.getId());
|
|
|
TbBusiness business = tbBusinessService.getById(car.getBusinessId());
|
|
|
String carNo = car.getCarNo();
|
|
|
- TbFeeDetails parkFee;
|
|
|
- if(business != null){
|
|
|
- parkFee = getByBusinessIdAndCarNoAndFeeType(car.getBusinessId(), carNo, TbFeeDetails.fee.PARK_FEE.getCode());
|
|
|
- } else {
|
|
|
- parkFee = getByBusinessCarIdAndCarNoAndFeeType(car.getId(), carNo, TbFeeDetails.fee.PARK_FEE.getCode());
|
|
|
- }
|
|
|
+ TbFeeDetails parkFee = null;
|
|
|
+// if(business != null){
|
|
|
+// parkFee = getByBusinessIdAndCarNoAndFeeType(car.getBusinessId(), carNo, TbFeeDetails.fee.PARK_FEE.getCode());
|
|
|
+// } else {
|
|
|
+// parkFee = getByBusinessCarIdAndCarNoAndFeeType(car.getId(), carNo, TbFeeDetails.fee.PARK_FEE.getCode());
|
|
|
+// }
|
|
|
if(parkFee == null){
|
|
|
parkFee = new TbFeeDetails();
|
|
|
parkFee.setTaxRate(partConfig.getTaxRate());
|
|
|
}
|
|
|
- BigDecimal taxPrice = car.getMoney().divide(BigDecimal.valueOf(1).add(parkFee.getTaxRate()),2, BigDecimal.ROUND_HALF_UP).multiply(parkFee.getTaxRate());
|
|
|
- BigDecimal noTaxPrice = car.getMoney().subtract(taxPrice);
|
|
|
+ BigDecimal taxPrice = bo1.getP().divide(BigDecimal.valueOf(1).add(parkFee.getTaxRate()),2, BigDecimal.ROUND_HALF_UP).multiply(parkFee.getTaxRate());
|
|
|
+ BigDecimal noTaxPrice = bo1.getP().subtract(taxPrice);
|
|
|
parkFee.setBusinessId(car.getBusinessId()).setBusinessCarId(car.getId())
|
|
|
.setCarNo(car.getCarNo())
|
|
|
- .setItemPrice(car.getMoney()).setUnitPrice(car.getMoney()).setNoTaxPrice(noTaxPrice).setTaxPrice(taxPrice)
|
|
|
+ .setItemPrice(bo1.getP()).setUnitPrice(bo1.getP()).setNoTaxPrice(noTaxPrice).setTaxPrice(taxPrice)
|
|
|
.setFeeType(TbFeeDetails.fee.PARK_FEE.getCode()).setItemTypeName("停车业务")
|
|
|
.setPayDay(toDay).setPayType(3).setCreateTime(now)
|
|
|
.setNum(1).setIsSettle(1).setPayMode(1).setPayTime(nowStr)
|
|
@@ -169,64 +169,32 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //@Async
|
|
|
- public void chargeBusinessFee(List<TbBusinessItem> items) {
|
|
|
- Date now = new Date();
|
|
|
- String nowStr = DateUtil.format(now, "yyyy-MM-dd HH:mm:ss");
|
|
|
- String toDay = DateUtil.format(now, "yyyy-MM-dd");
|
|
|
- for (TbBusinessItem item : items) {
|
|
|
- int feeType = -1;
|
|
|
- String itemType = item.getItemTypeName();
|
|
|
- if (itemType.contains("核酸")) {
|
|
|
- feeType = TbFeeDetails.fee.NUCLEIC_FEE.getCode();
|
|
|
- } else if (itemType.contains("消毒") || itemType.contains("消杀")) {
|
|
|
- feeType = TbFeeDetails.fee.DISINFECT_FEE.getCode();
|
|
|
- } else if (itemType.contains("装卸")) {
|
|
|
- feeType = TbFeeDetails.fee.STEVEDORE_FEE.getCode();
|
|
|
- } else if (StrUtil.equals(itemType, "特殊车辆") || StrUtil.equals(itemType, "汽车吊")) {
|
|
|
- feeType = TbFeeDetails.fee.STEVEDORE_FEE.getCode();
|
|
|
- } else if (itemType.contains("入场管理")) {
|
|
|
- feeType = TbFeeDetails.fee.MANAGE_FEE.getCode();
|
|
|
- } else if (StrUtil.equals(itemType, "充电打冷")) {
|
|
|
- feeType = TbFeeDetails.fee.CHARGE_FEE.getCode();
|
|
|
- }
|
|
|
- TbBusiness business = tbBusinessService.getById(item.getBusinessId());
|
|
|
- TbFeeDetails businessFeeDetail = this.getByBusinessIdAndCarNoAndItemType(item.getBusinessId(), business.getCardNo(), item.getItemTypeId());
|
|
|
- if (businessFeeDetail == null) {
|
|
|
- businessFeeDetail = new TbFeeDetails();
|
|
|
- businessFeeDetail.setTaxRate(BigDecimal.valueOf(TbFeeStatistics.taxRate.BUSINESS.getValue()));
|
|
|
- }
|
|
|
- BigDecimal taxPrice = item.getItemPrice()
|
|
|
- .divide(BigDecimal.valueOf(1).add(businessFeeDetail.getTaxRate()),2, BigDecimal.ROUND_HALF_UP)
|
|
|
- .multiply(businessFeeDetail.getTaxRate());
|
|
|
- BigDecimal noTaxPrice = item.getItemPrice().subtract(taxPrice);
|
|
|
|
|
|
- String carNo = business.getCardNo();
|
|
|
- if(StrUtil.isEmpty(business.getCardNo())){
|
|
|
- carNo = business.getChinaCarNo();
|
|
|
- }
|
|
|
- businessFeeDetail.setBusinessId(item.getBusinessId()).setBusinessNo(business.getNo())
|
|
|
- .setBusinessItemNo(item.getNo())
|
|
|
- .setCarNo(carNo)
|
|
|
- .setItemPrice(item.getItemPrice()).setUnitPrice(item.getItemPrice()).setNoTaxPrice(noTaxPrice).setTaxPrice(taxPrice)
|
|
|
- .setFeeType(feeType)
|
|
|
- .setItemTypeId(item.getItemTypeId()).setItemTypeName(item.getItemTypeName())
|
|
|
- .setItemId(item.getItemId()).setItemName(item.getItemName())
|
|
|
- .setPayDay(toDay).setPayType(3).setCreateTime(now)
|
|
|
- .setBusinessItemId(item.getId() + "")
|
|
|
- .setPickCustomerName(item.getPickCustomerName())
|
|
|
- .setNum(1).setIsSettle(1).setPayMode(1).setPayTime(nowStr).setWeight(business.getNetWeight());
|
|
|
- this.saveOrUpdate(businessFeeDetail);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
public String export(SoMap so) throws Exception{
|
|
|
Date now = new Date();
|
|
|
String nowStr = DateUtil.format(now, "yyyy-MM-dd HH:mm");
|
|
|
- String time = so.getString("beginTime") + "至" + so.getString("endTime");
|
|
|
+ String beginTime = so.getString("beginTime");
|
|
|
+ String endTime = so.getString("endTime");
|
|
|
+ String time = beginTime + "至" + endTime;
|
|
|
Map<String, String> head = new HashMap<>();
|
|
|
head.put("time", time);
|
|
|
head.put("exportTime", nowStr);
|
|
|
+ String inCarNum = "";
|
|
|
+ String outPayCarNum = "";
|
|
|
+ String notOutCarNum = "";
|
|
|
+ boolean isIn = checkTimeRange(beginTime, endTime, now);
|
|
|
+ if(isIn){
|
|
|
+ inCarNum = getInCarNum(now) + "";
|
|
|
+ outPayCarNum = getOutAndPayCarNum(now) + "";
|
|
|
+ notOutCarNum = getNotOutCarNum(now) + "";
|
|
|
+ }
|
|
|
+ head.put("inCarNum", inCarNum);
|
|
|
+ head.put("outPayCarNum", outPayCarNum);
|
|
|
+ head.put("notOutCarNum", notOutCarNum);
|
|
|
+
|
|
|
+ BigDecimal toDayFee = new BigDecimal(0);
|
|
|
+ BigDecimal allDayFee = new BigDecimal(0);
|
|
|
List<ExportFeeDetailDTO> exportList = new ArrayList<>();
|
|
|
List<TbFeeDetails> list = this.getList(so);
|
|
|
Integer index = 1;
|
|
@@ -247,10 +215,18 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
|
|
|
}else {
|
|
|
detailDTO.setBusinessNo(feeDetails.getBusinessCarNo());
|
|
|
}
|
|
|
-
|
|
|
exportList.add(detailDTO);
|
|
|
+ if(checkTimeRange(beginTime, endTime, feeDetails.getCreateTime()) && feeDetails.getFeeType()==TbFeeDetails.fee.PARK_FEE.getCode()){
|
|
|
+ toDayFee = toDayFee.add(feeDetails.getItemPrice());
|
|
|
+ }
|
|
|
+ if(feeDetails.getFeeType()==TbFeeDetails.fee.PARK_FEE.getCode()){
|
|
|
+ allDayFee = allDayFee.add(feeDetails.getItemPrice());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ head.put("toDayFee", toDayFee.toString());
|
|
|
+ head.put("allDayFee", allDayFee.toString());
|
|
|
+
|
|
|
String separator = File.separator;
|
|
|
String today = DateUtil.today();
|
|
|
String rootPath = UploadUtil.uploadConfig.rootFolder + separator + UploadUtil.uploadConfig.httpPrefix;
|
|
@@ -275,4 +251,54 @@ public class TbFeeDetailsService extends ServiceImpl<TbFeeDetailsMapper, TbFeeDe
|
|
|
return prefix + "/feeDetails/" + today + "/收费明细表_" + time + ".xlsx";
|
|
|
}
|
|
|
|
|
|
+ private boolean checkTimeRange(String begin, String end, Date now) {
|
|
|
+ Date beginTime = DateUtil.beginOfDay(DateUtil.parse(begin));
|
|
|
+ Date endTime = DateUtil.endOfDay(DateUtil.parse(end));
|
|
|
+ if(now.getTime() >= beginTime.getTime() && now.getTime() <= endTime.getTime()){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Integer getInCarNum(Date now){
|
|
|
+ Date beginOfDay = DateUtil.beginOfDay(now);
|
|
|
+ Date endOfDay = DateUtil.endOfDay(now);
|
|
|
+ QueryWrapper<TbBusinessCar> qw = new QueryWrapper();
|
|
|
+ qw.isNotNull("real_in_time")
|
|
|
+ .ge("real_in_time", beginOfDay)
|
|
|
+ .le("real_in_time", endOfDay);
|
|
|
+ List<TbBusinessCar> list = tbBusinessCarService.list(qw);
|
|
|
+ return list != null ? list.size() : 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Integer getOutAndPayCarNum(Date now){
|
|
|
+ Date beginOfDay = DateUtil.beginOfDay(now);
|
|
|
+ Date endOfDay = DateUtil.endOfDay(now);
|
|
|
+ QueryWrapper<TbBusinessCar> qw = new QueryWrapper();
|
|
|
+ qw.eq("pay", 1)
|
|
|
+ .isNotNull("real_in_time").isNotNull("real_out_time")
|
|
|
+ .ge("real_out_time", beginOfDay)
|
|
|
+ .le("real_out_time", endOfDay);
|
|
|
+ List<TbBusinessCar> list = tbBusinessCarService.list(qw);
|
|
|
+ return list != null ? list.size() : 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Integer getNotOutCarNum(Date now){
|
|
|
+ Date beginOfDay = DateUtil.beginOfDay(now);
|
|
|
+ Date endOfDay = DateUtil.endOfDay(now);
|
|
|
+ QueryWrapper<TbBusinessCar> qw = new QueryWrapper();
|
|
|
+ qw.isNotNull("real_in_time")
|
|
|
+ .ge("real_in_time", beginOfDay)
|
|
|
+ .le("real_in_time", endOfDay)
|
|
|
+ .isNull("real_out_time");
|
|
|
+ List<TbBusinessCar> list = tbBusinessCarService.list(qw);
|
|
|
+ return list != null ? list.size() : 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ public TbFeeDetails findByBusinessCarId(String businessCarId,int feeType) {
|
|
|
+ QueryWrapper<TbFeeDetails>ew=new QueryWrapper<>();
|
|
|
+ ew.eq("business_car_id",businessCarId);
|
|
|
+ ew.eq("fee_type",feeType);
|
|
|
+ return getOne(ew);
|
|
|
+ }
|
|
|
}
|