提交 e3024dec authored 作者: liuhaiquan's avatar liuhaiquan

Merge remote-tracking branch 'origin/v5.7_break_contract_reverse_20231020' into…

Merge remote-tracking branch 'origin/v5.7_break_contract_reverse_20231020' into v5.7_break_contract_reverse_20231020
......@@ -3,6 +3,7 @@ package com.clx.performance.component;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
import com.clx.order.enums.OrderEnum;
import com.clx.order.enums.VehicleUsageEnum;
import com.clx.order.feign.OrderFeign;
import com.clx.order.param.feign.RollbackOrderWeightParam;
import com.clx.order.vo.feign.FeignOrderVO;
......@@ -190,21 +191,26 @@ public class OrderCancelComponent implements InitializingBean {
RollbackOrderWeightParam rollbackOrderWeightParam = new RollbackOrderWeightParam();
rollbackOrderWeightParam.setOrderNo(orderGoods.getOrderNo());
BigDecimal residueWeight = orderGoods.getResidueTransportWeight().add(weight);
rollbackOrderWeightParam.setResidueWeight(residueWeight);
rollbackOrderWeightParam.setResidueWeight(weight);
//归还吨数
if (!truckDemand.equals(TruckDemandEnum.TruckType.PLATFORM_ANY_CAR.getCode())) {
if (truckDemand.equals(TruckDemandEnum.TruckType.PLATFORM_CAR.getCode())) {
rollbackOrderWeightParam.setOwnResidueCarryWeight(BigDecimal.ZERO);
rollbackOrderWeightParam.setPlatformResidueCarryWeight(residueWeight);
rollbackOrderWeightParam.setPlatformResidueCarryWeight(weight);
} else if (truckDemand.equals(TruckDemandEnum.TruckType.OWNER_CAR.getCode())) {
rollbackOrderWeightParam.setOwnResidueCarryWeight(residueWeight);
rollbackOrderWeightParam.setOwnResidueCarryWeight(weight);
rollbackOrderWeightParam.setPlatformResidueCarryWeight(BigDecimal.ZERO);
}
} else {
rollbackOrderWeightParam.setPlatformResidueCarryWeight(residueWeight);
rollbackOrderWeightParam.setOwnResidueCarryWeight(residueWeight);
if (orderGoods.getVehicleUsage().equals(VehicleUsageEnum.Status.OWN.getCode())) {
rollbackOrderWeightParam.setPlatformResidueCarryWeight(BigDecimal.ZERO);
rollbackOrderWeightParam.setOwnResidueCarryWeight(weight);
} else {
rollbackOrderWeightParam.setPlatformResidueCarryWeight(weight);
rollbackOrderWeightParam.setOwnResidueCarryWeight(BigDecimal.ZERO);
}
}
Result<Object> result = orderFeign.rollbackOrderWeight(rollbackOrderWeightParam);
......@@ -231,21 +237,25 @@ public class OrderCancelComponent implements InitializingBean {
RollbackOrderWeightParam rollbackOrderWeightParam = new RollbackOrderWeightParam();
rollbackOrderWeightParam.setOrderNo(orderGoods.getOrderNo());
BigDecimal residueWeight = orderGoods.getResidueTransportWeight().add(weight);
rollbackOrderWeightParam.setResidueWeight(residueWeight);
rollbackOrderWeightParam.setResidueWeight(weight);
//归还吨数
if (!truckDemand.equals(TruckDemandEnum.TruckType.PLATFORM_ANY_CAR.getCode())) {
if (truckDemand.equals(TruckDemandEnum.TruckType.PLATFORM_CAR.getCode())) {
rollbackOrderWeightParam.setOwnResidueCarryWeight(BigDecimal.ZERO);
rollbackOrderWeightParam.setPlatformResidueCarryWeight(residueWeight);
rollbackOrderWeightParam.setPlatformResidueCarryWeight(weight);
} else if (truckDemand.equals(TruckDemandEnum.TruckType.OWNER_CAR.getCode())) {
rollbackOrderWeightParam.setOwnResidueCarryWeight(residueWeight);
rollbackOrderWeightParam.setOwnResidueCarryWeight(weight);
rollbackOrderWeightParam.setPlatformResidueCarryWeight(BigDecimal.ZERO);
}
} else {
rollbackOrderWeightParam.setPlatformResidueCarryWeight(residueWeight);
rollbackOrderWeightParam.setOwnResidueCarryWeight(residueWeight);
if (orderGoods.getVehicleUsage().equals(VehicleUsageEnum.Status.OWN.getCode())) {
rollbackOrderWeightParam.setPlatformResidueCarryWeight(BigDecimal.ZERO);
rollbackOrderWeightParam.setOwnResidueCarryWeight(weight);
} else {
rollbackOrderWeightParam.setPlatformResidueCarryWeight(weight);
rollbackOrderWeightParam.setOwnResidueCarryWeight(BigDecimal.ZERO);
}
}
Result<Object> result = orderFeign.rollbackOrderWeight(rollbackOrderWeightParam);
......
......@@ -8,14 +8,11 @@ import com.clx.performance.constant.RedisConstants;
import com.clx.performance.dao.OrderChildDao;
import com.clx.performance.dao.OrderGoodsDao;
import com.clx.performance.dao.OrderGoodsTruckBindDao;
import com.clx.performance.enums.OrderChildEnum;
import com.clx.performance.enums.OrderGoodsStatusEnum;
import com.clx.performance.enums.OrderGoodsTruckBindEnum;
import com.clx.performance.enums.TruckDemandEnum;
import com.clx.performance.enums.*;
import com.clx.performance.extranal.user.DriverService;
import com.clx.performance.model.OrderChild;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.service.OrderChildService;
import com.clx.performance.service.OrderChildLogService;
import com.clx.performance.service.breakcontract.BreakContractDriverRecordService;
import com.clx.user.enums.driver.DriverInfoEnum;
import com.msl.common.base.Optional;
......@@ -24,7 +21,6 @@ import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Component;
......@@ -33,7 +29,10 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.*;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
/**
* 货单最晚接单时间、最晚到达货源地时间处理
......@@ -59,6 +58,8 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean {
private final BreakContractDriverRecordService breakContractDriverRecordService;
private final OrderChildLogService orderChildLogService;
//根据货单最晚接单时间处理
public void expireProduceByLastOrderTime(LocalDateTime localDateTime, String orderGoodsNo) {
......@@ -215,6 +216,11 @@ public class OrderGoodsStatusLazyComponent implements InitializingBean {
orderChild.setFinishTime(DateUtils.parseDateTime(now).get());
breakContractDriverRecordService.saveDriverRecordOfOrderChildCancel(orderChild, 0L, "系统");
//保存运单日志数据
// 日志
orderChildLogService.saveDriverOrderChildLog(orderChild.getChildNo(), OrderChildLogEnum.Type.PLATFORM_CANCEL.getCode(),
OrderChildLogEnum.Type.PLATFORM_CANCEL.getMsg(), 0L, "系统");
}
log.info("取消运单ID集合:{}", childNoList);
if (CollectionUtil.isNotEmpty(childNoList)) {
......
......@@ -684,7 +684,7 @@ public class OrderChildServiceImpl implements OrderChildService {
BigDecimal dif = param.getLoadNet().subtract(orderChild.getWeight());
if (orderGoods.getResidueTransportWeight().compareTo(dif) < 0) {
throw new ServiceSystemException(PerformanceResultEnum.ORDER_WEIGHT_LACK);
throw new ServiceSystemException(PerformanceResultEnum.ORDER_GOODS_WEIGHT_NOT_HAVE);
}
orderChild.setLoadRough(param.getLoadRough());
......@@ -1612,7 +1612,10 @@ public class OrderChildServiceImpl implements OrderChildService {
}
//实付运费(元)
BigDecimal realFreight = payableFreight.subtract(lossDeduction);
BigDecimal realFreight = null;
if(Objects.equals(orderChild.getPoundStatus(),OrderChildPoundAuditEnum.Status.APPROVED.getCode())){
realFreight = payableFreight.subtract(lossDeduction);
}
carrierOrderChildDetailVO.setPayableFreight(payableFreight);
carrierOrderChildDetailVO.setLossDeduction(lossDeduction);
carrierOrderChildDetailVO.setRealFreight(realFreight);
......
......@@ -655,6 +655,8 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
String ownerName = "";
BigDecimal frozenBalance = param.getFrozenBalance();
BigDecimal ensureBalance = param.getEnsureBalance();
boolean ensureBalanceZeroFlag = false;
boolean frozenBalanceZeroFlag = false;
Integer orderId = param.getOrderId();
String orderNo = param.getOrderNo();
LocalDateTime now = LocalDateTime.now();
......@@ -677,27 +679,38 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
if (ownerAccount.getUsableBalance().compareTo(ensureBalance) < 0) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前货主保证金账户可用余额不够冻结");
}
//冻结金额
entity.setFrozenBalance(ensureBalance);
//可用余额
entity.setUsableBalance(ensureBalance);
//账户余额
entity.setAccountBalance(BigDecimal.ZERO);
if (ensureBalance.compareTo(BigDecimal.ZERO) == 0) {
flag += 1;
ensureBalanceZeroFlag = true;
} else {
//冻结金额
entity.setFrozenBalance(ensureBalance);
//可用余额
entity.setUsableBalance(ensureBalance);
//账户余额
entity.setAccountBalance(BigDecimal.ZERO);
//updateList.add(entity);
flag += ownerAccountDao.updateAccountCAS(entity, now, false);
}
//updateList.add(entity);
flag += ownerAccountDao.updateAccountCAS(entity, now, false);
} else {
if (ownerAccount.getUsableBalance().compareTo(frozenBalance) < 0) {
throw new ServiceSystemException(PerformanceResultEnum.HTTP_ERROR, "当前货主预付运费账户可用余额不够冻结");
}
//冻结金额
entity.setFrozenBalance(frozenBalance);
//可用余额
entity.setUsableBalance(frozenBalance);
//账户余额
entity.setAccountBalance(BigDecimal.ZERO);
//updateList.add(entity);
flag += ownerAccountDao.updateAccountCAS(entity, now, false);
if (frozenBalance.compareTo(BigDecimal.ZERO) == 0) {
flag += 1;
frozenBalanceZeroFlag = true;
} else {
//冻结金额
entity.setFrozenBalance(frozenBalance);
//可用余额
entity.setUsableBalance(frozenBalance);
//账户余额
entity.setAccountBalance(BigDecimal.ZERO);
//updateList.add(entity);
flag += ownerAccountDao.updateAccountCAS(entity, now, false);
}
}
}
if (flag == 2) {
......@@ -707,6 +720,10 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
for (OwnerAccount ownerAccount : accountList) {
if (ownerAccount.getAccountType().equals(OwnerAccountEnum.AccountTypeStatus.MARGIN_ACCOUNT.getCode())) {
log.info("插入保证金冻结流水");
if (ensureBalanceZeroFlag) {
log.info("保证金账户需冻结金额为0,不产生流水");
continue;
}
OwnerRunningWaterRecord marginAccount = new OwnerRunningWaterRecord();
marginAccount.setOwnerUserName(ownerName);
marginAccount.setMobile(mobile);
......@@ -728,6 +745,10 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
ownerRunningWaterRecordDao.saveEntity(marginAccount);
} else {
log.info("插入预付运费冻结流水");
if (frozenBalanceZeroFlag) {
log.info("保证金账户需冻结金额为0,不产生流水");
continue;
}
OwnerRunningWaterRecord prepaidFreight = new OwnerRunningWaterRecord();
prepaidFreight.setOwnerUserName(ownerName);
prepaidFreight.setMobile(mobile);
......@@ -785,7 +806,7 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
String orderNo = param.getOrderNo();
if (OwnerAccountEnum.OrderChildTypeStatus.ORDINARY.getCode().equals(param.getOrderType())) {
List<OwnerRunningWaterRecord> list = ownerRunningWaterRecordDao.getOwnerRunningWaterRecord(orderNo);
if (null == list || list.size() != 2) {
if (CollectionUtil.isEmpty(list)) {
log.info("解冻预付运费、保证金账户出错,查询出冻结流水有问题,参数为{}", JSONUtil.parse(param));
return;
}
......@@ -802,7 +823,7 @@ public class OwnerAccountServiceImpl implements OwnerAccountService {
entity.setFrozenBalance(runningWaterRecord.getAlterationBalance());
flag += ownerAccountDao.thawAccount(entity, LocalDateTime.now());
}
if (flag == 2) {
if (flag == list.size()) {
log.info("解冻预付运费、保证金账户,账户扣款已处理,开始执行插入相关流水");
for (OwnerRunningWaterRecord runningWaterRecord : list) {
OwnerAccount account = ownerAccountDao.getAccountByOwnerUserNoAndAccountType(runningWaterRecord.getOwnerUserNo(), runningWaterRecord.getAccountType());
......
......@@ -480,7 +480,7 @@ public class BreakContractSettlementOwnerServiceImpl implements BreakContractSe
BigDecimal truckFigure = BigDecimal.ZERO;
if(Objects.equals(cancelType,CancelOrderEnum.Type.NOT_ARRIVE.getCode())){
truckFigure = seconds.multiply(orderCancelRule.getAfterFigurePerHour())
.divide(new BigDecimal(3600),2, BigDecimal.ROUND_HALF_UP);
.divide(new BigDecimal(3600),2, BigDecimal.ROUND_HALF_UP).movePointRight(2);
}
figure = baseFigure.add(truckFigure);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论