|
@@ -1,6 +1,7 @@
|
|
|
package com.pj.project.tb_business;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
@@ -56,6 +57,8 @@ import com.pj.project.tb_business_sort.TbBusinessSort;
|
|
|
import com.pj.project.tb_business_sort.TbBusinessSortService;
|
|
|
import com.pj.project.tb_car.TbCar;
|
|
|
import com.pj.project.tb_car.TbCarService;
|
|
|
+import com.pj.project.tb_car_weight.TbCarWeight;
|
|
|
+import com.pj.project.tb_car_weight.TbCarWeightService;
|
|
|
import com.pj.project.tb_costomer.TbCostomer;
|
|
|
import com.pj.project.tb_costomer.TbCostomerService;
|
|
|
import com.pj.project.tb_declare.TbDeclare;
|
|
@@ -131,7 +134,8 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
private TbItemTypeService tbItemTypeService;
|
|
|
@Resource
|
|
|
private TbBusinessItemService tbBusinessItemService;
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private TbCarWeightService tbCarWeightService;
|
|
|
|
|
|
@Resource
|
|
|
private PartConfig partConfig;
|
|
@@ -365,7 +369,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
TbItemFac itemFac = list.get(0);
|
|
|
IOrderItem orderItem = new IOrderItem();
|
|
|
String uniqueExpenseId = itemFac.getUniqueExpenseId();
|
|
|
- orderItem.setUniqExpenseId(uniqueExpenseId).setExpenseNum(1);
|
|
|
+ orderItem.setUniqExpenseId(uniqueExpenseId).setExpenseNum("1");
|
|
|
List<IFactorItem> factors = new ArrayList<>();
|
|
|
for (TbItemFac fac : list) {
|
|
|
String operator = fac.getOperator();
|
|
@@ -413,15 +417,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
// boolean needPayPartMoney = !businessList.isEmpty();
|
|
|
TbBusinessCar tbBusinessCar = tbBusinessCarService.getById(businessCarId);
|
|
|
String carNo = tbBusinessCar.getCarNo();
|
|
|
- businessList = businessList.stream().filter(tbBusiness -> {
|
|
|
- TbGoods tbGoods = tbGoodsService.getById(tbBusiness.getGoodsId());
|
|
|
- Integer payStep = tbGoods.getPayStep();
|
|
|
- //确认订单后方可缴费
|
|
|
- return GoodsEnum.PayStep.AFTER_CONFIRM.getCode().equals(payStep) && tbBusiness.getAdminConfirmInput() == 1
|
|
|
- //或者下单后可缴费
|
|
|
- || GoodsEnum.PayStep.BEFORE_CONFIRM.getCode().equals(payStep) && tbBusiness.getAdminConfirmInput() >= 0;
|
|
|
- }).collect(Collectors.toList());
|
|
|
-
|
|
|
List<String> businessIdList = businessList.stream().map(TbBusiness::getId).collect(Collectors.toList());
|
|
|
String businessIds = StrUtil.join(",", businessIdList);
|
|
|
long judgeCount = businessList.stream().filter(tbBusiness -> tbBusiness.getConfirmJudge() == CarEnum.ConfirmJudgeEnum.JUDGE_PASS.getCode()).count();
|
|
@@ -492,6 +487,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
if (!items.isEmpty()) {
|
|
|
//未支付的
|
|
|
List<IOrderItem> expenses = new ArrayList<>();
|
|
|
+ //这辆车的地磅费用是否支付
|
|
|
items = items.stream().filter(item -> item.getPayStatus() == 0).collect(Collectors.toList());
|
|
|
for (TbBusinessItem businessItem : items) {
|
|
|
String num = businessItem.getNum();
|
|
@@ -500,7 +496,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
String itemAlias = businessItem.getItemAlias();
|
|
|
Date startTime = businessItem.getColdStartTime();
|
|
|
Date endTime = businessItem.getColdEndTime();
|
|
|
- iOrderItem.setExpenseNum(Integer.parseInt(num)).setUniqExpenseId(itemCode);
|
|
|
+ iOrderItem.setExpenseNum(num).setUniqExpenseId(itemCode);
|
|
|
if (StrUtil.equals(itemAlias, SystemObject.config.getColdItemAlias())) {
|
|
|
tbBusinessItemService.buildColdFceItem(businessItem, iOrderItem, startTime, endTime);
|
|
|
//充电打冷--->按小时计费
|
|
@@ -517,59 +513,77 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
//大车头、柜车、栏车
|
|
|
tbBusinessItemService.buildDaysFceItem(businessItem, iOrderItem, startTime, endTime);
|
|
|
//不收停车费
|
|
|
- carMap.put("price", 0);
|
|
|
+ // carMap.put("price", 0);
|
|
|
}
|
|
|
expenses.add(iOrderItem);
|
|
|
}
|
|
|
result.put("carList", Collections.singleton(carMap));
|
|
|
+
|
|
|
if (!expenses.isEmpty()) {
|
|
|
IOrderPriceRes orderPriceRes = syncService.orderPriceCal(expenses);
|
|
|
BigDecimal totalPrice = orderPriceRes.getTotalOrderPrice();
|
|
|
carCalculateIds.add(orderPriceRes.getCalculateId());
|
|
|
for (TbBusinessItem item : items) {
|
|
|
- BigDecimal itemPrice = item.getItemPrice().multiply(new BigDecimal(item.getNum()));
|
|
|
+ BigDecimal itemPrice = item.getItemPrice().multiply(new BigDecimal(item.getNum())).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
itemsPrice = itemsPrice.add(itemPrice);
|
|
|
Map<String, Object> itemMap = new HashMap<>();
|
|
|
itemMap.put("id", item.getId());
|
|
|
itemMap.put("name", item.getItemName() + "(" + item.getItemTypeName() + ")");
|
|
|
+ if (StrUtil.equals(SystemObject.config.getWeighbridge(), item.getItemAlias())) {
|
|
|
+ itemMap.put("name", item.getItemName() + "-" + carNo + "(" + item.getItemTypeName() + ")");
|
|
|
+ }
|
|
|
itemMap.put("price", itemPrice);
|
|
|
itemMap.put("pay", item.getPayStatus());
|
|
|
- orderPriceRes.getFireResult().stream().filter(priceItem -> StrUtil.equals(item.getItemCode(), priceItem.getUniqExpenseId()))
|
|
|
+ orderPriceRes.getFireResult().stream()
|
|
|
+ .filter(priceItem -> StrUtil.equals(item.getItemCode(), priceItem.getUniqExpenseId()))
|
|
|
.findAny().ifPresent(priceItem -> {
|
|
|
BigDecimal price = priceItem.getFirePrice().multiply(new BigDecimal(item.getNum()));
|
|
|
- //柜车、栏车只有离场才知道多少钱
|
|
|
- if (StrUtil.equals(item.getItemAlias(), SystemObject.config.getCabinetCar())) {
|
|
|
+ boolean weighbridge = StrUtil.equals(item.getItemAlias(), SystemObject.config.getWeighbridge());
|
|
|
+ if (weighbridge) {//地磅的,单价x重量
|
|
|
+ price = priceItem.getFirePrice().multiply(BigDecimal.valueOf(item.getWeighbridge())).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ }
|
|
|
+ //柜车、栏车 || 过磅费 只有离场才知道多少钱
|
|
|
+ if (StrUtil.equals(item.getItemAlias(), SystemObject.config.getCabinetCar())
|
|
|
+ ) {
|
|
|
TbBusiness tbBusiness = this.getById(item.getBusinessId());
|
|
|
tbBusiness.setItemPrice(price);
|
|
|
item.setTotal(price);
|
|
|
tbBusinessItemService.updateById(item);
|
|
|
this.updateById(tbBusiness);
|
|
|
}
|
|
|
+ if (weighbridge) {
|
|
|
+ tbBusinessCar.setNetweightMoney(price);
|
|
|
+ tbBusinessCarService.updateById(tbBusinessCar);
|
|
|
+ }
|
|
|
itemMap.put("price", price);
|
|
|
});
|
|
|
itemList.add(itemMap);
|
|
|
- TbBusinessSort tbBusinessSort = tbBusinessSortService.findByItemTypeId(item.getItemTypeId());
|
|
|
- if (tbBusinessSort != null) {
|
|
|
- TbSortGroup sortGroup = tbSortGroupService.getById(tbBusinessSort.getGroupId());
|
|
|
- if (sortGroup.getCompletePay().equals(1) && sortGroup.getStatus().equals(1)) {
|
|
|
- List<TbBusinessSort> sorts = tbBusinessSortService.findByGroupId(sortGroup.getId());
|
|
|
- for (TbBusinessSort sort : sorts) {
|
|
|
- long count = items.stream().filter(tbBusinessItem -> StrUtil.equals(sort.getTypeId(), tbBusinessItem.getItemTypeId()))
|
|
|
- .count();
|
|
|
- if (count == 0) {
|
|
|
- result.put("showPay", false);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
result.put("itemsPrice", totalPrice);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
result.put("itemList", itemList);
|
|
|
result.put("calculateId", String.join(",", carCalculateIds));
|
|
|
result.put("businessNo", businessList.stream().map(TbBusiness::getNo).distinct().collect(Collectors.joining("、")));
|
|
|
result.put("goodsName", businessList.stream().map(TbBusiness::getGoodsName).distinct().collect(Collectors.joining("、")));
|
|
|
+ List<TbCarWeight> carWeights = tbCarWeightService.findByBusinessCarId(tbBusinessCar.getId());
|
|
|
+ //未支付的过磅费用
|
|
|
+ carWeights = carWeights.stream().filter(tbCarWeight -> tbCarWeight.getPayStatus() == 0).collect(Collectors.toList());
|
|
|
+ if (!carWeights.isEmpty()) {
|
|
|
+ BigDecimal total = BigDecimal.ZERO;
|
|
|
+ String weightIds = carWeights.stream().map(tbCarWeight -> tbCarWeight.getId().toString()).collect(Collectors.joining(","));
|
|
|
+ for (TbCarWeight carWeight : carWeights) {
|
|
|
+ total = total.add(carWeight.getWeightPrice());
|
|
|
+ carCalculateIds.add(carWeight.getCalculateId());
|
|
|
+ }
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("id", weightIds);
|
|
|
+ map.put("label", "过磅费");
|
|
|
+ map.put("price", total);
|
|
|
+ result.put("w", map);
|
|
|
+ result.put("calculateId", String.join(",", carCalculateIds));
|
|
|
+ }
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -793,6 +807,9 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
itemList.add(item);
|
|
|
index++;
|
|
|
}
|
|
|
+ if (price.doubleValue() < 5) {
|
|
|
+ price = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
String declareNo = otherBusinessBO.getDeclareNo();
|
|
|
tbBusiness.setCardSize(otherBusinessBO.getCarSize()).setNetWeight(otherBusinessBO.getNetWeight())
|
|
|
.setOperator(otherBusinessBO.getOperator()).setOperateTime(otherBusinessBO.getOperateTime())
|
|
@@ -830,8 +847,8 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
exitBusinessList.add(tbBusiness);
|
|
|
long partBusinessCount = exitBusinessList.stream().filter(busienss -> StrUtil.equals("A10006", busienss.getGoodsCode()))
|
|
|
.count();
|
|
|
- if (exitBusinessList.size()>1&&partBusinessCount>0){
|
|
|
- throw new AjaxError("车辆【"+carNo+"】录入停车业务的同时存在其他业务");
|
|
|
+ if (exitBusinessList.size() > 1 && partBusinessCount > 0) {
|
|
|
+ throw new AjaxError("车辆【" + carNo + "】录入停车业务的同时存在其他业务");
|
|
|
}
|
|
|
}
|
|
|
if (!tbGoods.getName().contains("整车")) {
|
|
@@ -857,7 +874,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
db.setCarSize(car.getCarSize()).setConfirmJudge(CarEnum.ConfirmJudgeEnum.NO_JUDGE.getCode())//业务车都是未审核状态
|
|
|
.setTimeUpdate(now).setCarType(car.getCarType())
|
|
|
.setDriverName(car.getDriverName()).setDriverPhone(car.getDriverPhone())
|
|
|
- .setNetWeight(car.getNetWeight()).setColor(car.getColor())
|
|
|
+ .setColor(car.getColor())
|
|
|
.setCustomerId(customerId)
|
|
|
.setNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4));
|
|
|
tbBusinessCarService.saveOrUpdate(db);
|
|
@@ -1034,6 +1051,9 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
itemList.add(item);
|
|
|
index++;
|
|
|
}
|
|
|
+ if (price.doubleValue() < 5) {
|
|
|
+ price = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
dbBusiness.setItemPrice(price).setTotalMoney(price);
|
|
|
tbBusinessItemService.saveBatch(itemList);
|
|
|
}
|
|
@@ -1053,8 +1073,8 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
}
|
|
|
long partBusinessCount = exitBusinessList.stream().filter(busienss -> StrUtil.equals("A10006", busienss.getGoodsCode()))
|
|
|
.count();
|
|
|
- if (exitBusinessList.size()>1&&partBusinessCount>0){
|
|
|
- throw new AjaxError("车辆【"+carNo+"】录入停车业务的同时存在其他业务");
|
|
|
+ if (exitBusinessList.size() > 1 && partBusinessCount > 0) {
|
|
|
+ throw new AjaxError("车辆【" + carNo + "】录入停车业务的同时存在其他业务");
|
|
|
}
|
|
|
}
|
|
|
if (StrUtil.isNotEmpty(businessCarId)) {
|
|
@@ -1078,7 +1098,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
relationBusinessCar.setBusinessId(dbBusiness.getId()).setBusinessCarId(otherCar.getId());
|
|
|
relationBusinessCarService.save(relationBusinessCar);
|
|
|
} else {
|
|
|
- dbBusinessCar.setNetWeight(tbBusinessCar.getNetWeight()).setNetWeight(tbBusinessCar.getNetWeight())
|
|
|
+ dbBusinessCar
|
|
|
.setCarSize(tbBusinessCar.getCarSize()).setCarType(tbBusinessCar.getCarType())
|
|
|
.setConfirmJudge(CarEnum.ConfirmJudgeEnum.NO_JUDGE.getCode());
|
|
|
tbBusinessCarService.updateById(dbBusinessCar);
|
|
@@ -1090,10 +1110,10 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
throw new AjaxError("车辆【" + carNo + "】未入场");
|
|
|
}
|
|
|
checkCar.setCarNo(carNo).setCarType(tbBusinessCar.getCarType()).setCarSize(tbBusinessCar.getCarSize())
|
|
|
- .setNetWeight(tbBusinessCar.getNetWeight()).setCustomerId(dbBusiness.getCustomerId())
|
|
|
+ .setCustomerId(dbBusiness.getCustomerId())
|
|
|
.setTimeUpdate(now).setIsLock(0).setCarType(tbBusinessCar.getCarType()).setBusinessType(1)
|
|
|
.setConfirmJudge(CarEnum.ConfirmJudgeEnum.NO_JUDGE.getCode());
|
|
|
- tbBusinessCarService.saveOrUpdate(checkCar);
|
|
|
+ tbBusinessCarService.updateById(checkCar);
|
|
|
RelationBusinessCar relationBusinessCar = new RelationBusinessCar();
|
|
|
relationBusinessCar.setBusinessId(dbBusiness.getId()).setBusinessCarId(checkCar.getId());
|
|
|
relationBusinessCarService.save(relationBusinessCar);
|
|
@@ -1527,7 +1547,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
car.setCarNo(carNo).setIsLock(0);
|
|
|
car.setCarSize(car.getCarSize())
|
|
|
.setTimeUpdate(now).setCarType(car.getCarType())
|
|
|
- .setNetWeight(car.getNetWeight())
|
|
|
.setCustomerId(customerId)
|
|
|
.setNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4));
|
|
|
//新增放行记录
|
|
@@ -1669,23 +1688,12 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
String businessCarId;
|
|
|
Date now = new Date();
|
|
|
if (lastRecord == null || lastRecord.getRealOutTime() != null) {
|
|
|
- //不存在或者已经离场
|
|
|
- tbBusinessCar
|
|
|
- .setBusinessType(CarEnum.BusinessTypeEnum.BUSINESS_CAR.getType())
|
|
|
- .setCarNo(carNo).setPay(0).setIsLock(0).setPayUnloadMoney(0)
|
|
|
- .setPayType(CarEnum.PayTypeEnum.NO_PAY_TYPE.getType()).setPay(0)
|
|
|
- .setCreateTime(now).setCarType(CarEnum.CarTypeEnum.EMPTY_TYPE.getType())
|
|
|
- .setTimeUpdate(now)
|
|
|
- .setConfirmJudge(CarEnum.ConfirmJudgeEnum.NO_NEED_JUDGE.getCode())
|
|
|
- .setNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4));
|
|
|
- tbBusinessCarService.save(tbBusinessCar);
|
|
|
- businessCarId = tbBusinessCar.getId();
|
|
|
+ throw new AjaxError("车辆未入场");
|
|
|
} else {
|
|
|
businessCarId = lastRecord.getId();
|
|
|
lastRecord.setPayType(CarEnum.PayTypeEnum.NO_PAY_TYPE.getType())
|
|
|
.setCustomerId(tbBusiness.getCustomerId())
|
|
|
- .setCarNo(carNo).setConfirmJudge(CarEnum.ConfirmJudgeEnum.NO_JUDGE.getCode())
|
|
|
- .setPayUnloadMoney(lastRecord.getPayUnloadMoney())
|
|
|
+ .setCarNo(carNo)
|
|
|
.setTimeUpdate(now)
|
|
|
.setBusinessType(CarEnum.BusinessTypeEnum.BUSINESS_CAR.getType());
|
|
|
tbBusinessCarService.updateById(lastRecord);
|
|
@@ -1738,12 +1746,12 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
if (SystemObject.config.getEveryCarPay().contains(itemName) && tbBusinessCar.getPayUnloadMoney() == 0) {
|
|
|
List<IOrderItem> expenses = new ArrayList<>();
|
|
|
IOrderItem orderItem = new IOrderItem();
|
|
|
- orderItem.setExpenseNum(Integer.parseInt(item.getNum()))
|
|
|
+ orderItem.setExpenseNum(item.getNum())
|
|
|
.setUniqExpenseId(item.getItemCode());
|
|
|
expenses.add(orderItem);
|
|
|
IOrderPriceRes res = syncService.orderPriceCal(expenses);
|
|
|
BigDecimal price = res.getTotalOrderPrice();
|
|
|
- if (StrUtil.isEmpty(customerId)||tbAccount==null){
|
|
|
+ if (StrUtil.isEmpty(customerId) || tbAccount == null) {
|
|
|
throw new AjaxError("未选择合作伙伴");
|
|
|
}
|
|
|
BigDecimal balance = tbAccount.getTotalMoney();
|
|
@@ -1790,7 +1798,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
&& !SystemObject.config.getEveryCarPay().contains(itemName)) {
|
|
|
List<IOrderItem> expenses = new ArrayList<>();
|
|
|
IOrderItem orderItem = new IOrderItem();
|
|
|
- orderItem.setExpenseNum(Integer.parseInt(item.getNum()))
|
|
|
+ orderItem.setExpenseNum(item.getNum())
|
|
|
.setUniqExpenseId(item.getItemCode());
|
|
|
expenses.add(orderItem);
|
|
|
IOrderPriceRes res = syncService.orderPriceCal(expenses);
|