|
|
@@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
|
import com.pj.api.open.bo.ItemPriceBO;
|
|
|
import com.pj.api.pushfee.oa.CallbackBO;
|
|
|
+import com.pj.api.wx.bo.ManagerBO;
|
|
|
import com.pj.api.wx.bo.MsgDataBO;
|
|
|
import com.pj.api.wx.bo.PriceBO;
|
|
|
import com.pj.api.wx.service.WxService;
|
|
|
@@ -331,6 +332,9 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
public IOrderPriceRes getPartMoney(Date iTime, Date oTime, String carNo, String carColor) {
|
|
|
long minutes = DateUtil.between(iTime, oTime, DateUnit.MINUTE);
|
|
|
double hours = NumberUtil.div(minutes, 60, 1);
|
|
|
+ if (hours == 0) {
|
|
|
+ hours = 0.1D;
|
|
|
+ }
|
|
|
List<IOrderItem> expenses = new ArrayList<>();
|
|
|
TbMildCar tbMildCar = tbMildCarService.findByCarNo(carNo);
|
|
|
IOrderPriceRes res = new IOrderPriceRes();
|
|
|
@@ -339,7 +343,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
res.setHourDesc(PartFeeEnum.IN_24_HOURS.getDesc());
|
|
|
if (tbMildCar == null) {
|
|
|
// 9.6以上
|
|
|
- carSize = 13D;
|
|
|
+ carSize = 12D;
|
|
|
res.setCarDesc(PartFeeEnum.BIG_CAR.getDesc());
|
|
|
}
|
|
|
if (hours > 24) {
|
|
|
@@ -425,7 +429,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 微信端获取缴费信息
|
|
|
*
|
|
|
@@ -437,23 +440,10 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
//对应的业务
|
|
|
List<TbBusiness> businessList = this.findOtherBusinessByCarId(businessCarId);
|
|
|
+ //是否需要交停车费---->业务车都要交
|
|
|
+// boolean needPayPartMoney = !businessList.isEmpty();
|
|
|
TbBusinessCar tbBusinessCar = tbBusinessCarService.getById(businessCarId);
|
|
|
String carNo = tbBusinessCar.getCarNo();
|
|
|
- //越南车是否需要支付---停车费
|
|
|
- int vietnamCarPay = businessList.stream().anyMatch(tbBusiness -> {
|
|
|
- TbGoods tbGoods = tbGoodsService.getById(tbBusiness.getGoodsId());
|
|
|
- return tbGoods.getVietnamCarPay() == 1;
|
|
|
- }) ? 1 : 0;
|
|
|
- //中国车是否需要支付--停车费
|
|
|
- int chinaCarPay = businessList.stream().anyMatch(tbBusiness -> {
|
|
|
- TbGoods tbGoods = tbGoodsService.getById(tbBusiness.getGoodsId());
|
|
|
- return tbGoods.getChinaCarPay() == 1;
|
|
|
- }) ? 1 : 0;
|
|
|
- //无业务的车辆,中国车和越南车都需要支付
|
|
|
- if (businessList.isEmpty()) {
|
|
|
- vietnamCarPay = 1;
|
|
|
- chinaCarPay = 1;
|
|
|
- }
|
|
|
businessList = businessList.stream().filter(tbBusiness -> {
|
|
|
TbGoods tbGoods = tbGoodsService.getById(tbBusiness.getGoodsId());
|
|
|
Integer payStep = tbGoods.getPayStep();
|
|
|
@@ -480,35 +470,22 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
carMap.put("price", 0);
|
|
|
List<String> carCalculateIds = new ArrayList<>();
|
|
|
//停车费
|
|
|
- if (pay == 0 && inTime != null) {
|
|
|
+ if (inTime != null) {
|
|
|
Date outTime = tbBusinessCar.getRealOutTime();
|
|
|
String cacheCarNo = RedisUtil.get(channel);
|
|
|
- if (outTime == null && StrUtil.isNotEmpty(cacheCarNo)) {
|
|
|
+ if (outTime == null && StrUtil.isNotEmpty(cacheCarNo) && StrUtil.equals(carNo.trim().toUpperCase(), cacheCarNo.trim().toUpperCase())) {
|
|
|
outTime = new Date();
|
|
|
}
|
|
|
if (outTime != null) {
|
|
|
- String carType = tbBusinessCar.getCarType();
|
|
|
- if (StrUtil.isEmpty(carType)) {
|
|
|
- carType = CarEnum.CarTypeEnum.EMPTY_TYPE.getType();
|
|
|
- }
|
|
|
//默认需要缴费--->
|
|
|
BigDecimal partMoney = new BigDecimal("1");
|
|
|
-
|
|
|
if (StrUtil.isNotEmpty(tbBusinessCar.getColor()) && tbBusinessCar.getCarSize() != null) {
|
|
|
String freeColor = partConfig.getFreeColor();
|
|
|
//4.2米以下蓝色车辆
|
|
|
- if (tbBusinessCar.getColor().contains(freeColor) && tbBusinessCar.getCarSize() <= partConfig.getFreeCarLength()) {
|
|
|
+ if (tbBusinessCar.getColor().contains(freeColor)) {
|
|
|
partMoney = new BigDecimal("0");
|
|
|
}
|
|
|
}
|
|
|
- //越南车牌,是否免费
|
|
|
- if (CarEnum.CarTypeEnum.WEIGHT_TYPE.getType().equals(carType) && vietnamCarPay == 0) {
|
|
|
- partMoney = new BigDecimal("0");
|
|
|
- }
|
|
|
- //中国车,是否免费
|
|
|
- if (CarEnum.CarTypeEnum.EMPTY_TYPE.getType().equals(carType) && chinaCarPay == 0) {
|
|
|
- partMoney = new BigDecimal("0");
|
|
|
- }
|
|
|
if (CarEnum.PayTypeEnum.FEE_TYPE.getType().equals(tbBusinessCar.getPayType())) {
|
|
|
partMoney = new BigDecimal("0");
|
|
|
}
|
|
|
@@ -529,7 +506,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
}
|
|
|
//todo 计算停车费
|
|
|
}
|
|
|
- // partMoney = calculationPartMoney(inTime, outTime, tbBusinessCar.getCarSize());
|
|
|
carMap.put("price", partMoney);
|
|
|
}
|
|
|
}
|
|
|
@@ -545,26 +521,9 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
List<IOrderItem> expenses = new ArrayList<>();
|
|
|
items = items.stream().filter(item -> item.getPayStatus() == 0).collect(Collectors.toList());
|
|
|
//如果不需要支付,则过滤掉入场管理费
|
|
|
-// boolean needPayManagerMoney = needPayManagerMoney(carNo, items);
|
|
|
-// if (needPayManagerMoney) {
|
|
|
-// //查询出对应的费项
|
|
|
-// TbItem tbItem = tbItemService.findByName(SystemObject.config.getManagerWord());
|
|
|
-// if (tbItem != null) {
|
|
|
-// List<IOrderItem> managerList = new ArrayList<>();
|
|
|
-// IOrderItem iOrderItem = new IOrderItem();
|
|
|
-// iOrderItem.setExpenseNum(1).setUniqExpenseId(tbItem.getItemCode());
|
|
|
-// managerList.add(iOrderItem);
|
|
|
-// IOrderPriceRes managerPriceRes = syncService.orderPriceCal(managerList);
|
|
|
-// Map<String, Object> managerMap = new HashMap<>();
|
|
|
-// managerMap.put("id", tbItem.getId());
|
|
|
-// managerMap.put("name", tbItem.getItemName());
|
|
|
-// managerMap.put("carNo", carNo);
|
|
|
-// managerMap.put("carId", businessCarId);
|
|
|
-// managerMap.put("label", tbItem.getItemName() + "(入场管理费)");
|
|
|
-// managerMap.put("price", managerPriceRes.getTotalOrderPrice());
|
|
|
-// managerMap.put("calculateId", managerPriceRes.getCalculateId());
|
|
|
-// result.put("manager", managerMap);
|
|
|
-// }
|
|
|
+// ManagerBO dto = needPayManagerMoney(carNo, businessCarId, items);
|
|
|
+// if (dto.isNeed()) {
|
|
|
+// result.put("manager", dto);
|
|
|
// }
|
|
|
items.forEach(item -> {
|
|
|
String num = item.getNum();
|
|
|
@@ -573,7 +532,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
iOrderItem.setExpenseNum(Integer.parseInt(num)).setUniqExpenseId(itemCode);
|
|
|
expenses.add(iOrderItem);
|
|
|
});
|
|
|
- if (!expenses.isEmpty()){
|
|
|
+ if (!expenses.isEmpty()) {
|
|
|
IOrderPriceRes orderPriceRes = syncService.orderPriceCal(expenses);
|
|
|
BigDecimal totalPrice = orderPriceRes.getTotalOrderPrice();
|
|
|
carCalculateIds.add(orderPriceRes.getCalculateId());
|
|
|
@@ -621,12 +580,13 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
* @param carNo
|
|
|
* @return
|
|
|
*/
|
|
|
- public boolean needPayManagerMoney(String carNo, List<TbBusinessItem> items) {
|
|
|
+ public ManagerBO needPayManagerMoney(String carNo, String carId, List<TbBusinessItem> items) {
|
|
|
+ ManagerBO dto = new ManagerBO();
|
|
|
List<String> needItemTypeList = SystemObject.config.getManagerItemType();
|
|
|
//是否有相关业务,,,没有的话直接不用交入场管理费
|
|
|
boolean before = items.stream().anyMatch(item -> needItemTypeList.contains(item.getItemTypeName()));
|
|
|
if (!before) {
|
|
|
- return false;
|
|
|
+ return dto;
|
|
|
}
|
|
|
String carPrefix = StrUtil.sub(carNo, 0, 1);
|
|
|
boolean isvietnamCar = !CAR_LIST.contains(carPrefix);
|
|
|
@@ -636,8 +596,25 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
//中国车是否需要支付
|
|
|
boolean chinaNeePay = managerList.contains(ManagerEnum.CHINA_PAY.getType());
|
|
|
//是否需要支付入场管理费
|
|
|
- return isvietnamCar && verNeePay || !isvietnamCar && chinaNeePay;
|
|
|
-
|
|
|
+ boolean need = isvietnamCar && verNeePay || !isvietnamCar && chinaNeePay;
|
|
|
+ dto.setNeed(need);
|
|
|
+ if (need) {
|
|
|
+ //查询出对应的费项
|
|
|
+ TbItem tbItem = tbItemService.findByName(SystemObject.config.getManagerWord());
|
|
|
+ if (tbItem != null) {
|
|
|
+ List<IOrderItem> itemList = new ArrayList<>();
|
|
|
+ IOrderItem iOrderItem = new IOrderItem();
|
|
|
+ iOrderItem.setExpenseNum(1).setUniqExpenseId(tbItem.getItemCode());
|
|
|
+ itemList.add(iOrderItem);
|
|
|
+ IOrderPriceRes managerPriceRes = syncService.orderPriceCal(itemList);
|
|
|
+ dto.setCalculateId(managerPriceRes.getCalculateId())
|
|
|
+ .setPrice(managerPriceRes.getTotalOrderPrice())
|
|
|
+ .setCarNo(carNo).setId(tbItem.getId())
|
|
|
+ .setLabel(tbItem.getItemName() + "(入场管理费)")
|
|
|
+ .setName(tbItem.getItemName()).setCarId(carId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return dto;
|
|
|
}
|
|
|
|
|
|
public List<TbBusiness> findOtherBusinessByCarId(String businessCarId) {
|
|
|
@@ -709,115 +686,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
return tbBusinessMapper.checkCarBusinessTypeByTime(typeId, carNo, timeStart, timeEnd, businessId);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 线下收费
|
|
|
- *
|
|
|
- * @param id
|
|
|
- * @param cars
|
|
|
- * @param remark
|
|
|
- * @param payTime
|
|
|
- * @param payChannelType
|
|
|
- * @param payType
|
|
|
- * @param transactionId
|
|
|
- */
|
|
|
- public void manualConfirmPay(String id, List<TbBusinessCar> cars, String remark, Date payTime, int payChannelType, int payType, String transactionId) {
|
|
|
- TbBusiness db = this.getById(id);
|
|
|
- if (db == null) {
|
|
|
- throw new BusinessException("业务不存在");
|
|
|
- }
|
|
|
- List<TbBusinessItem> items = tbBusinessItemService.findByBusinessId(id);
|
|
|
- TbDeductionBind bind = null;
|
|
|
- BigDecimal partMoney = new BigDecimal(0);
|
|
|
- String plate = null;
|
|
|
- List<PriceBO> priceBOList = new ArrayList<>();
|
|
|
- TbGoods tbGoods = tbGoodsService.getById(db.getGoodsId());
|
|
|
- //该确认确未确认
|
|
|
- if (tbGoods.getPayStep().equals(GoodsEnum.PayStep.AFTER_CONFIRM.getCode()) && db.getAdminConfirmInput() == 0) {
|
|
|
- throw new AjaxError("该业务需要确认后才能收费");
|
|
|
- }
|
|
|
- for (TbBusinessCar tbBusinessCar : cars) {
|
|
|
- String carNo = tbBusinessCar.getCarNo().toUpperCase();
|
|
|
- String prefix = StrUtil.sub(carNo, 0, 1);
|
|
|
- if (CAR_LIST.contains(prefix) && tbGoods.getChinaCarPay() == 1
|
|
|
- || !CAR_LIST.contains(prefix) && tbGoods.getVietnamCarPay() == 1) {
|
|
|
- Date realInTime = tbBusinessCar.getRealInTime();
|
|
|
- Date realOutTime = tbBusinessCar.getRealOutTime();
|
|
|
- if (realInTime != null && realOutTime != null) {
|
|
|
- IOrderPriceRes orderPriceRes = getPartMoney(realInTime, realOutTime, tbBusinessCar.getCarNo(),tbBusinessCar.getColor());
|
|
|
- BigDecimal price=orderPriceRes.getTotalOrderPrice();
|
|
|
- if (price.doubleValue() > 0) {
|
|
|
- PriceBO priceBO = new PriceBO();
|
|
|
- priceBO.setId(tbBusinessCar.getId()).setP(price);
|
|
|
- priceBOList.add(priceBO);
|
|
|
- }
|
|
|
- partMoney = partMoney.add(price);
|
|
|
- tbBusinessCar.setMoney(price);
|
|
|
- }
|
|
|
- }
|
|
|
- tbBusinessCar.setPay(1).setPayTime(payTime)
|
|
|
- .setPayType(CarEnum.PayTypeEnum.HAS_PAY_TYPE.getType());
|
|
|
- if (payType == PayEnum.PayType.PER_PAY.getCode()) {
|
|
|
- TbDeductionBind deductionBind = tbDeductionBindService.getBindCarByPlate(carNo);
|
|
|
- if (deductionBind != null) {
|
|
|
- plate = carNo;
|
|
|
- bind = deductionBind;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- BigDecimal itemPrice = db.getItemPrice();
|
|
|
- BigDecimal money = itemPrice.add(partMoney);
|
|
|
- String no = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) + RandomUtil.randomNumbers(4);
|
|
|
- if (payType == PayEnum.PayType.PER_PAY.getCode()) {
|
|
|
- if (bind == null) {
|
|
|
- throw new AjaxError("车辆未绑定预支付款,无法完成收费");
|
|
|
- }
|
|
|
- TbAccount tbAccount = tbAccountService.getByCustomerId(bind.getCustomerId());
|
|
|
- String key = AesUtil.reverse(tbAccount.getAccSalt());
|
|
|
- BigDecimal balance = new BigDecimal(tbAccount.getTotalMoney());
|
|
|
- if (balance.compareTo(money) < 0) {
|
|
|
- throw new AjaxError("车辆绑定账户余额不足,无法完成收费");
|
|
|
- }
|
|
|
- balance = balance.subtract(money);
|
|
|
- tbAccount.setTotalMoney(AesUtil.encryptECB(balance.toString(), key));
|
|
|
- tbAccountService.updateById(tbAccount);
|
|
|
- //生成扣款记录
|
|
|
- if (partMoney.doubleValue() > 0 && !priceBOList.isEmpty()) {
|
|
|
- //车辆的扣费记录
|
|
|
- List<TbFeeDetails> parkFeeDetailsList = tbFeeDetailsService.chargeParkFee(
|
|
|
- priceBOList, null, null, payTime, PayEnum.PayType.PER_PAY);
|
|
|
- automaticPay.createTbDeductionRecord(parkFeeDetailsList, tbAccount, plate, bind.getCustomerName(), no);
|
|
|
- }
|
|
|
- //生成收费明细
|
|
|
- List<TbFeeDetails> tbFeeDetailsList = tbFeeDetailsService.chargeBusinessFee(
|
|
|
- items, null, null, payTime, PayEnum.PayType.PER_PAY);
|
|
|
- //生成扣费记录
|
|
|
- automaticPay.createTbDeductionRecord(tbFeeDetailsList, tbAccount, plate, bind.getCustomerName(), no);
|
|
|
- automaticPay.unbindRun(plate);
|
|
|
- } else if (payType == PayEnum.PayType.OFF_LINE_PAY.getCode()) {
|
|
|
- //车辆的扣费记录
|
|
|
- if (partMoney.doubleValue() > 0) {
|
|
|
- tbFeeDetailsService.chargeParkFee(
|
|
|
- priceBOList, null, null, payTime, PayEnum.PayType.OFF_LINE_PAY);
|
|
|
- }
|
|
|
- //生成收费明细
|
|
|
- tbFeeDetailsService.chargeBusinessFee(
|
|
|
- items, null, null, payTime, PayEnum.PayType.OFF_LINE_PAY);
|
|
|
- }
|
|
|
- db.setPayStatus(PayEnum.PayStatusEnum.HAS_PAY_CONFIRM.getCode())
|
|
|
- .setPayMoney(db.getItemPrice())
|
|
|
- .setPayType(payType).setPayChannelType(payChannelType)
|
|
|
- .setTransactionId(transactionId)
|
|
|
- .setPayTime(payTime);
|
|
|
- items.forEach(tbBusinessItem -> tbBusinessItem
|
|
|
- .setPayStatus(1).setPayTime(payTime)
|
|
|
- .setRemark(StrUtil.isEmpty(remark) ? "手动确认" : remark)
|
|
|
- );
|
|
|
- this.updateById(db);
|
|
|
- tbBusinessCarService.updateBatchById(cars);
|
|
|
- tbBusinessItemService.updateBatchById(items);
|
|
|
- tbFeeStatisticsService.addOrUpdateStatistic(payTime);//更新当前日期的日统计
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
public void unBindCar(String id, String businessCarId) {
|
|
|
QueryWrapper<TbBusiness> ew = new QueryWrapper<>();
|
|
|
@@ -853,9 +721,17 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
BigDecimal price = new BigDecimal("0");
|
|
|
List<TbBusinessItem> itemList = new ArrayList<>();
|
|
|
String no = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4);
|
|
|
+ String pickCustomerId = otherBusinessBO.getPickCustomerId();
|
|
|
+ TbCostomer partner = null;
|
|
|
+ if (StrUtil.isNotEmpty(pickCustomerId)) {
|
|
|
+ partner = tbCostomerService.getById(pickCustomerId);
|
|
|
+ tbBusiness.setPickCustomerId(pickCustomerId).setPickCustomerName(partner.getName());
|
|
|
+ }
|
|
|
int index = 1;
|
|
|
+ int size = cars.size();
|
|
|
for (TbItem tbItem : tbItems) {
|
|
|
TbItem db = tbItemService.getById(tbItem.getId());
|
|
|
+ String itemName = db.getItemName();
|
|
|
TbBusinessItem item = new TbBusinessItem();
|
|
|
int num = tbItem.getNum();
|
|
|
String typeId = tbItem.getTypeId();
|
|
|
@@ -863,10 +739,17 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
BigDecimal itemTotalPrice = tbItem.getPrice().multiply(new BigDecimal(num));
|
|
|
item.setNo(no + "0" + index).setPayTypeName(db.getPayTypeName()).setPayType(db.getPayType())
|
|
|
.setBusinessType(db.getBusinessType()).setTaxRate(NumberUtil.div(db.getTaxRate().doubleValue(), 100D, 2));
|
|
|
- item.setItemCode(db.getItemCode()).setNum(num + "").setItemId(db.getId())
|
|
|
+ item.setItemCode(db.getItemCode()).setNum(num + "").setItemId(db.getId()).setCabinetNo(tbItem.getCabinetNo())
|
|
|
.setItemName(db.getItemName()).setItemPrice(db.getPrice()).setRemark(tbItem.getRemark())
|
|
|
.setItemTypeId(typeId).setItemTypeName(tbItemType.getName())
|
|
|
.setUnit(db.getUnit()).setTotal(itemTotalPrice).setCreateTime(now);
|
|
|
+ if (partner != null) {
|
|
|
+ item.setPick(1).setPickCustomerId(pickCustomerId).setPickCustomerName(partner.getName())
|
|
|
+ .setPickBy(StpUserUtil.getCreateBy()).setPickTime(now);
|
|
|
+ }
|
|
|
+ if (SystemObject.config.getEveryCarPay().contains(itemName)) {
|
|
|
+ itemTotalPrice = itemTotalPrice.multiply(BigDecimal.valueOf(size));
|
|
|
+ }
|
|
|
price = price.add(itemTotalPrice);
|
|
|
itemList.add(item);
|
|
|
index++;
|
|
|
@@ -880,9 +763,8 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
tbBusiness.setCreateTime(now).setCreateByCustomerId(StpUserUtil.getCustomerId())
|
|
|
.setItemPrice(price).setTotalMoney(price).setOwner(otherBusinessBO.getOwner());
|
|
|
tbBusiness.setChinaCarNo(otherBusinessBO.getChinaCarNo());
|
|
|
+
|
|
|
this.save(tbBusiness);
|
|
|
- Integer chinaCarPay = tbGoods.getChinaCarPay();
|
|
|
- Integer vietnamCarPay = tbGoods.getVietnamCarPay();
|
|
|
String carBuseinssNo = DateUtil.format(now, "yyyyMMddHHmm");
|
|
|
for (TbBusinessCar car : cars) {
|
|
|
String carNo = car.getCarNo().trim().toUpperCase();
|
|
|
@@ -920,10 +802,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
}
|
|
|
}
|
|
|
db.setPayType(CarEnum.PayTypeEnum.NO_PAY_TYPE.getType());
|
|
|
- if ((CarEnum.CarTypeEnum.EMPTY_TYPE.getType().equals(carType) && chinaCarPay == 0)
|
|
|
- || (CarEnum.CarTypeEnum.WEIGHT_TYPE.getType().equals(carType) && vietnamCarPay == 0)) {
|
|
|
- db.setPayType(CarEnum.PayTypeEnum.FEE_TYPE.getType());
|
|
|
- }
|
|
|
TbCar tbCar = tbCarService.findByCardNo(carNo);
|
|
|
if (tbCar != null) {
|
|
|
db.setCarCompany(tbCar.getCustomerName());
|
|
|
@@ -984,8 +862,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
relationBusinessCarService.removeByIds(removeIds);
|
|
|
}
|
|
|
TbGoods tbGoods = tbGoodsService.getById(otherBusinessBO.getGoodsId());
|
|
|
- Integer chinaCarPay = tbGoods.getChinaCarPay();
|
|
|
- Integer vietnamCarPay = tbGoods.getVietnamCarPay();
|
|
|
String carBuseinssNo = DateUtil.format(now, "yyyyMMddHHmm");
|
|
|
List<TbBusinessItem> itemList = new ArrayList<>();
|
|
|
if (PayEnum.PayStatusEnum.HAS_PAY_CONFIRM.getCode() != dbBusiness.getPayStatus()) {
|
|
|
@@ -993,18 +869,35 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
BigDecimal price = new BigDecimal("0");
|
|
|
String no = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4);
|
|
|
int index = 1;
|
|
|
+ String pickCustomerId = otherBusinessBO.getPickCustomerId();
|
|
|
+ TbCostomer partner = null;
|
|
|
+ if (StrUtil.isNotEmpty(pickCustomerId)) {
|
|
|
+ partner = tbCostomerService.getById(pickCustomerId);
|
|
|
+ dbBusiness.setPickCustomerId(pickCustomerId).setPickCustomerName(partner.getName());
|
|
|
+ }
|
|
|
+ int size = cars.size();
|
|
|
for (TbItem tbItem : tbItems) {
|
|
|
TbItem db = tbItemService.getById(tbItem.getId());
|
|
|
+ String itemName = db.getItemName();
|
|
|
TbBusinessItem item = new TbBusinessItem();
|
|
|
int num = tbItem.getNum();
|
|
|
TbItemType tbItemType = tbItemTypeService.getById(tbItem.getTypeId());
|
|
|
BigDecimal itemTotalPrice = tbItem.getPrice().multiply(new BigDecimal(num));
|
|
|
+
|
|
|
item.setNo(no + "0" + index).setPayTypeName(db.getPayTypeName()).setPayType(db.getPayType())
|
|
|
.setBusinessType(db.getBusinessType()).setTaxRate(NumberUtil.div(db.getTaxRate().doubleValue(), 100D, 2));
|
|
|
item.setItemCode(db.getItemCode()).setNum(num + "").setItemId(db.getId()).setBusinessId(dbBusiness.getId())
|
|
|
.setItemName(db.getItemName()).setItemPrice(db.getPrice()).setRemark(tbItem.getRemark())
|
|
|
.setItemTypeId(tbItem.getTypeId()).setItemTypeName(tbItemType.getName())
|
|
|
+ .setCabinetNo(tbItem.getCabinetNo())
|
|
|
.setUnit(db.getUnit()).setTotal(itemTotalPrice).setCreateTime(now);
|
|
|
+ if (partner != null) {
|
|
|
+ item.setPick(1).setPickCustomerId(pickCustomerId).setPickCustomerName(partner.getName())
|
|
|
+ .setPickBy(StpUserUtil.getCreateBy()).setPickTime(now);
|
|
|
+ }
|
|
|
+ if (SystemObject.config.getEveryCarPay().contains(itemName)) {
|
|
|
+ itemTotalPrice = itemTotalPrice.multiply(BigDecimal.valueOf(size));
|
|
|
+ }
|
|
|
price = price.add(itemTotalPrice);
|
|
|
itemList.add(item);
|
|
|
index++;
|
|
|
@@ -1018,7 +911,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
for (TbBusinessItem item : itemList) {
|
|
|
checkOtherBusiness(item.getItemTypeId(), otherBusinessBO.getOperateTime(), dbBusiness.getId(), carNo);
|
|
|
}
|
|
|
- String carType = tbBusinessCar.getCarType();
|
|
|
if (StrUtil.isNotEmpty(businessCarId)) {
|
|
|
//原来已存在的
|
|
|
TbBusinessCar dbBusinessCar = tbBusinessCarService.getById(businessCarId);
|
|
|
@@ -1031,16 +923,15 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
//把关联删除掉,然后添加新的关联
|
|
|
relationBusinessCarService.removeByBusinessIdAndCarId(dbBusiness.getId(), businessCarId);
|
|
|
TbBusinessCar otherCar = tbBusinessCarService.findTheLastRecord(carNo);
|
|
|
+
|
|
|
if (otherCar == null ||//不存在或者已离场===>新建
|
|
|
(otherCar.getRealInTime() != null && otherCar.getRealOutTime() != null)) {
|
|
|
otherCar = new TbBusinessCar();
|
|
|
otherCar.setCreateTime(now).setPay(0).setNo(carBuseinssNo + RandomUtil.randomNumbers(4))
|
|
|
.setCarNo(carNo).setCarType(tbBusinessCar.getCarType()).setCarSize(tbBusinessCar.getCarSize())
|
|
|
.setNetWeight(tbBusinessCar.getNetWeight()).setCustomerId(dbBusiness.getCustomerId())
|
|
|
- .setTimeUpdate(now).setIsLock(0).setCarType(tbBusinessCar.getCarType());
|
|
|
- if ((CarEnum.CarTypeEnum.EMPTY_TYPE.getType().equals(carType) && chinaCarPay == 0) || (CarEnum.CarTypeEnum.WEIGHT_TYPE.getType().equals(carType) && vietnamCarPay == 0)) {
|
|
|
- otherCar.setPayType(CarEnum.PayTypeEnum.FEE_TYPE.getType());
|
|
|
- }
|
|
|
+ .setTimeUpdate(now).setIsLock(0).setCarType(tbBusinessCar.getCarType())
|
|
|
+ .setConfirmJudge(CarEnum.ConfirmJudgeEnum.NO_JUDGE.getCode());
|
|
|
tbBusinessCarService.save(otherCar);
|
|
|
} else {
|
|
|
List<TbBusiness> tbBusinessList = this.findOtherBusinessByCarId(businessCarId);
|
|
|
@@ -1053,7 +944,8 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
relationBusinessCarService.save(relationBusinessCar);
|
|
|
} else {
|
|
|
dbBusinessCar.setNetWeight(tbBusinessCar.getNetWeight()).setNetWeight(tbBusinessCar.getNetWeight())
|
|
|
- .setCarSize(tbBusinessCar.getCarSize()).setCarType(tbBusinessCar.getCarType());
|
|
|
+ .setCarSize(tbBusinessCar.getCarSize()).setCarType(tbBusinessCar.getCarType())
|
|
|
+ .setConfirmJudge(CarEnum.ConfirmJudgeEnum.NO_JUDGE.getCode());
|
|
|
tbBusinessCarService.updateById(dbBusinessCar);
|
|
|
}
|
|
|
} else {
|
|
|
@@ -1074,10 +966,8 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
}
|
|
|
checkCar.setCarNo(carNo).setCarType(tbBusinessCar.getCarType()).setCarSize(tbBusinessCar.getCarSize())
|
|
|
.setNetWeight(tbBusinessCar.getNetWeight()).setCustomerId(dbBusiness.getCustomerId())
|
|
|
- .setTimeUpdate(now).setIsLock(0).setCarType(tbBusinessCar.getCarType());
|
|
|
- if ((CarEnum.CarTypeEnum.EMPTY_TYPE.getType().equals(carType) && chinaCarPay == 0) || (CarEnum.CarTypeEnum.WEIGHT_TYPE.getType().equals(carType) && vietnamCarPay == 0)) {
|
|
|
- checkCar.setPayType(CarEnum.PayTypeEnum.FEE_TYPE.getType());
|
|
|
- }
|
|
|
+ .setTimeUpdate(now).setIsLock(0).setCarType(tbBusinessCar.getCarType()).setBusinessType(1)
|
|
|
+ .setConfirmJudge(CarEnum.ConfirmJudgeEnum.NO_JUDGE.getCode());
|
|
|
tbBusinessCarService.saveOrUpdate(checkCar);
|
|
|
RelationBusinessCar relationBusinessCar = new RelationBusinessCar();
|
|
|
relationBusinessCar.setBusinessId(dbBusiness.getId()).setBusinessCarId(checkCar.getId());
|
|
|
@@ -1088,18 +978,23 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
dbBusiness.setGoodsId(otherBusinessBO.getGoodsId())
|
|
|
.setGoodsName(tbGoods.getName()).setPayStep(tbGoods.getPayStep());
|
|
|
}
|
|
|
- String declareNo = otherBusinessBO.getDeclareNo();
|
|
|
- if (!StrUtil.equals(declareNo, dbBusiness.getDeclareNo())) {
|
|
|
- tbDeclareService.rebackDeclareNo(dbBusiness.getDeclareNo());
|
|
|
- TbDeclare tbDeclare = tbDeclareService.findByDeclareNo(declareNo);
|
|
|
- tbDeclare.setBusinessId(dbBusiness.getId());
|
|
|
- tbDeclareService.updateById(tbDeclare);
|
|
|
+ String customerId=otherBusinessBO.getCustomerId();
|
|
|
+ if (StrUtil.isNotEmpty(customerId)){
|
|
|
+ TbCostomer tbCostomer=tbCostomerService.getById(customerId);
|
|
|
+ dbBusiness.setCustomerId(customerId).setCustomerName(tbCostomer.getName());
|
|
|
+ }
|
|
|
+ String pickCustomerId=otherBusinessBO.getPickCustomerId();
|
|
|
+ if (StrUtil.isNotEmpty(pickCustomerId)){
|
|
|
+ TbCostomer tbCostomer=tbCostomerService.getById(pickCustomerId);
|
|
|
+ dbBusiness.setPickCustomerId(pickCustomerId).setPickCustomerName(tbCostomer.getName());
|
|
|
}
|
|
|
+
|
|
|
dbBusiness.setCardSize(otherBusinessBO.getCarSize()).setNetWeight(otherBusinessBO.getNetWeight())
|
|
|
.setOperator(otherBusinessBO.getOperator()).setOperateTime(otherBusinessBO.getOperateTime())
|
|
|
- .setGoodsId(otherBusinessBO.getGoodsId()).setOwner(otherBusinessBO.getOwner()).setBusinessGoodsName(otherBusinessBO.getBusinessGoodsName())
|
|
|
+ .setGoodsId(otherBusinessBO.getGoodsId())
|
|
|
+ .setOwner(otherBusinessBO.getOwner()).setBusinessGoodsName(otherBusinessBO.getBusinessGoodsName())
|
|
|
.setBusinessGoodsNum(otherBusinessBO.getBusinessGoodsNum())
|
|
|
- .setDeclareNo(declareNo).setCardNo(otherBusinessBO.getCardNo());
|
|
|
+ .setCardNo(otherBusinessBO.getCardNo());
|
|
|
String chinaCar = cars.stream().filter(tbBusinessCar -> CAR_LIST.contains(StrUtil.sub(tbBusinessCar.getCarNo(), 0, 1)))
|
|
|
.map(TbBusinessCar::getCarNo).collect(Collectors.joining("、")).toUpperCase();
|
|
|
dbBusiness.setChinaCarNo(chinaCar);
|
|
|
@@ -1253,7 +1148,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
outTime = payTime;
|
|
|
}
|
|
|
//计算停车费
|
|
|
- IOrderPriceRes parkMoney = this.getPartMoney(inTime, outTime, tbBusinessCar.getCarNo(),tbBusinessCar.getColor());
|
|
|
+ IOrderPriceRes parkMoney = this.getPartMoney(inTime, outTime, tbBusinessCar.getCarNo(), tbBusinessCar.getColor());
|
|
|
tbBusinessCar.setMoney(parkMoney.getTotalOrderPrice());
|
|
|
}
|
|
|
|
|
|
@@ -1489,8 +1384,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
.setPayTime(businessPayTime);
|
|
|
}
|
|
|
this.save(tbBusiness);
|
|
|
- Integer chinaCarPay = tbGoods.getChinaCarPay();
|
|
|
- Integer vietnamCarPay = tbGoods.getVietnamCarPay();
|
|
|
String carBuseinssNo = DateUtil.format(now, "yyyyMMddHHmm");
|
|
|
//业务车
|
|
|
for (TbBusinessCar car : cars) {
|
|
|
@@ -1501,10 +1394,6 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
}
|
|
|
|
|
|
car.setCreateTime(now).setNo(carBuseinssNo + RandomUtil.randomNumbers(4));
|
|
|
- if ((CarEnum.CarTypeEnum.EMPTY_TYPE.getType().equals(carType) && chinaCarPay == 0)
|
|
|
- || (CarEnum.CarTypeEnum.WEIGHT_TYPE.getType().equals(carType) && vietnamCarPay == 0)) {
|
|
|
- car.setPayType(CarEnum.PayTypeEnum.FEE_TYPE.getType());
|
|
|
- }
|
|
|
TbCar tbCar = tbCarService.findByCardNo(carNo);
|
|
|
if (tbCar != null) {
|
|
|
car.setCarCompany(tbCar.getCustomerName());
|
|
|
@@ -1641,4 +1530,60 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 额外添加车牌
|
|
|
+ *
|
|
|
+ * @param tbBusinessCar
|
|
|
+ */
|
|
|
+ public void addBusinessCar(TbBusinessCar tbBusinessCar) {
|
|
|
+ String businessId = tbBusinessCar.getBusinessId();
|
|
|
+ TbBusiness tbBusiness = this.getById(businessId);
|
|
|
+ String carNo = tbBusinessCar.getCarNo().trim().toUpperCase();
|
|
|
+ TbBusinessCar lastRecord = tbBusinessCarService.findTheLastRecord(carNo);
|
|
|
+ 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();
|
|
|
+ } else {
|
|
|
+ businessCarId = lastRecord.getId();
|
|
|
+ lastRecord.setPayType(CarEnum.PayTypeEnum.NO_PAY_TYPE.getType()).setCustomerId(tbBusiness.getCustomerId())
|
|
|
+ .setCarNo(carNo).setConfirmJudge(CarEnum.ConfirmJudgeEnum.NO_JUDGE.getCode()).setPayUnloadMoney(0)
|
|
|
+ .setTimeUpdate(now)
|
|
|
+ .setBusinessType(CarEnum.BusinessTypeEnum.BUSINESS_CAR.getType());
|
|
|
+ tbBusinessCarService.updateById(lastRecord);
|
|
|
+ }
|
|
|
+ tbBusiness.setCardNo(tbBusiness.getCardNo() + "、" + carNo);
|
|
|
+ this.updateById(tbBusiness);
|
|
|
+ RelationBusinessCar relationBusinessCar = new RelationBusinessCar();
|
|
|
+ relationBusinessCar.setBusinessId(businessId).setBusinessCarId(businessCarId);
|
|
|
+ relationBusinessCarService.save(relationBusinessCar);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除业务车
|
|
|
+ *
|
|
|
+ * @param carId
|
|
|
+ * @param businessId
|
|
|
+ */
|
|
|
+ public void deleteBusinessCar(String carId, String businessId) {
|
|
|
+
|
|
|
+ relationBusinessCarService.removeByBusinessIdAndCarId(businessId, carId);
|
|
|
+ List<RelationBusinessCar> list = relationBusinessCarService.findByBusinessCarId(carId);
|
|
|
+ if (list.isEmpty()) {
|
|
|
+ TbBusinessCar db = tbBusinessCarService.getById(carId);
|
|
|
+ if (db.getRealInTime() == null) {
|
|
|
+ tbBusinessCarService.removeById(carId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|