提交 571de275 authored 作者: huyufan's avatar huyufan

修改逻辑

上级 671de885
...@@ -75,99 +75,90 @@ public class SettlementServiceImpl implements SettlementService { ...@@ -75,99 +75,90 @@ public class SettlementServiceImpl implements SettlementService {
OrderChild orderChild = orderChildDao.getByChildNo(childNo).orElseThrow(PerformanceResultEnum.ORDER_CHILD_NO_FOUND); OrderChild orderChild = orderChildDao.getByChildNo(childNo).orElseThrow(PerformanceResultEnum.ORDER_CHILD_NO_FOUND);
SettlementOwnerDetail settlementOwnerDetail = settlementOwnerDetailDao.getByChildNo(childNo).orElseThrow(PerformanceResultEnum.DATA_NOT_FIND); SettlementOwnerDetail settlementOwnerDetail = settlementOwnerDetailDao.getByChildNo(childNo).orElseThrow(PerformanceResultEnum.DATA_NOT_FIND);
SettlementDriverDetail settlementDriverDetail = settlementDriverDetailDao.getByChildNo(childNo).orElseThrow(PerformanceResultEnum.DATA_NOT_FIND); SettlementDriverDetail settlementDriverDetail = settlementDriverDetailDao.getByChildNo(childNo).orElseThrow(PerformanceResultEnum.DATA_NOT_FIND);
// 开票金额
settlementOwnerDetail.setInvoiceFreight(invoiceFreightCalc(orderChild.getSettlementWay(),settlementOwnerDetail));
// 结算金额
settlementOwnerDetail.setSettlementFreight(settlementFreightCalc(orderChild.getSettlementWay(),settlementOwnerDetail));
settlementOwnerDetail.setFinalPaymentStatus(SettlementOwnerDetailEnum.FinalPaymentStatus.NO.getCode());
if (settlementOwnerDetail.getInvoiceType() != null) {return;} if (settlementOwnerDetail.getInvoiceType() != null) {return;}
//设置司机预付运费标示 OrderGoods orderGoods = orderGoodsDao.getByOrderGoodsNo(orderChild.getOrderGoodsNo()).get();
if (settlementOwnerDetail.getPrepayFreight().compareTo(BigDecimal.ZERO) > 0) { //是否通过风控,调用网络货运
settlementDriverDetail.setPrepayFreightFlag(1); ThirdOrderChildBrokerParam param = transportSyncService.generateOrderChildSync(orderChild, orderGoods, settlementOwnerDetail, settlementDriverDetail);
} else { HttpDTO httpDTOResult = transportFeignService.orderChildSync(param);
settlementDriverDetail.setPrepayFreightFlag(0); String decrypt = ThirdComponent.decrypt(httpDTOResult.getData());
} OrderChildSyncDTO bean = JSONUtil.toBean(decrypt, OrderChildSyncDTO.class);
log.info("OrderChildSyncDTO信息为:{}", JSONUtil.parse(bean));
if (bean.getCode() == 0) {
Integer status = bean.getData().getStatus();
// 货主结算金额<0走普通单 BigDecimal ans = settlementOwnerDetail.getFreight().subtract(settlementOwnerDetail.getLossFreight());
if (settlementOwnerDetail.getSettlementFreight().compareTo(BigDecimal.ZERO) < 0){ if (status == 1) {
invoiceType = SettlementOwnerEnum.InvoiceType.ORDINARY.getCode(); //通过风控
settlementDriverDetail.setPrepayFreightFlag(0); invoiceType = SettlementOwnerEnum.InvoiceType.ONLINE.getCode();
} else { List<OwnerRunningWaterRecord> runningWaterRecordList = ownerRunningWaterRecordDao.getOwnerRunningWaterRecord(orderChild.getOrderNo());
OrderGoods orderGoods = orderGoodsDao.getByOrderGoodsNo(orderChild.getOrderGoodsNo()).get(); BigDecimal frozen = runningWaterRecordList.stream().filter(item -> {
//是否通过风控,调用网络货运 return item.getRunningWaterType().equals(OwnerAccountEnum.RunningWaterStatus.FROZEN.getCode());
ThirdOrderChildBrokerParam param = transportSyncService.generateOrderChildSync(orderChild, orderGoods, settlementOwnerDetail, settlementDriverDetail); }).map(OwnerRunningWaterRecord::getAlterationBalance).reduce(BigDecimal.ZERO, BigDecimal::add);
HttpDTO httpDTOResult = transportFeignService.orderChildSync(param);
String decrypt = ThirdComponent.decrypt(httpDTOResult.getData()); BigDecimal takeOut = runningWaterRecordList.stream().filter(item -> {
OrderChildSyncDTO bean = JSONUtil.toBean(decrypt, OrderChildSyncDTO.class); return item.getRunningWaterType().equals(OwnerAccountEnum.RunningWaterStatus.TAKE_OUT.getCode());
log.info("OrderChildSyncDTO信息为:{}", JSONUtil.parse(bean)); }).map(OwnerRunningWaterRecord::getAlterationBalance).reduce(BigDecimal.ZERO, BigDecimal::add);
if (bean.getCode() == 0) { BigDecimal subtract = frozen.subtract(takeOut);
Integer status = bean.getData().getStatus(); if (subtract.compareTo(BigDecimal.ZERO) <= 0) {
BigDecimal ans = settlementOwnerDetail.getFreight().subtract(settlementOwnerDetail.getLossFreight()); settlementOwnerDetail.setPrepayFreight(BigDecimal.ZERO);
if (status == 1) { }
//通过风控 if (subtract.subtract(ans).compareTo(BigDecimal.ZERO) >= 0) {
invoiceType = SettlementOwnerEnum.InvoiceType.ONLINE.getCode(); OwnerAccount account = ownerAccountDao.getAccountByOwnerUserNoAndAccountType(orderChild.getOwnerUserNo(),
List<OwnerRunningWaterRecord> runningWaterRecordList = ownerRunningWaterRecordDao.getOwnerRunningWaterRecord(orderChild.getOrderNo()); OwnerAccountEnum.AccountTypeStatus.PREPAID_FREIGHT_ACCOUNT.getCode());
BigDecimal frozen = runningWaterRecordList.stream().filter(item -> {
return item.getRunningWaterType().equals(OwnerAccountEnum.RunningWaterStatus.FROZEN.getCode()); settlementOwnerDetail.setPrepayFreight(ans);
}).map(OwnerRunningWaterRecord::getAlterationBalance).reduce(BigDecimal.ZERO, BigDecimal::add); //生成扣除流水
OwnerRunningWaterRecord runningWaterRecord = new OwnerRunningWaterRecord();
BigDecimal takeOut = runningWaterRecordList.stream().filter(item -> { runningWaterRecord.setOwnerUserName(orderChild.getOwnerName());
return item.getRunningWaterType().equals(OwnerAccountEnum.RunningWaterStatus.TAKE_OUT.getCode()); runningWaterRecord.setMobile(orderChild.getDriverMobile());
}).map(OwnerRunningWaterRecord::getAlterationBalance).reduce(BigDecimal.ZERO, BigDecimal::add); runningWaterRecord.setCreateBy("系统");
BigDecimal subtract = frozen.subtract(takeOut); runningWaterRecord.setOrderId(orderChild.getId());
if (subtract.compareTo(BigDecimal.ZERO) <= 0) { runningWaterRecord.setOrderNo(orderChild.getOrderNo());
settlementOwnerDetail.setPrepayFreight(BigDecimal.ZERO);
} runningWaterRecord.setRelationId(null);
if (subtract.subtract(ans).compareTo(BigDecimal.ZERO) >= 0) { runningWaterRecord.setAlterationBalance(ans);
OwnerAccount account = ownerAccountDao.getAccountByOwnerUserNoAndAccountType(orderChild.getOwnerUserNo(), runningWaterRecord.setFrozenBalance(ans);
OwnerAccountEnum.AccountTypeStatus.PREPAID_FREIGHT_ACCOUNT.getCode()); runningWaterRecord.setUsableBalance(account.getUsableBalance());
runningWaterRecord.setTakeOutBalance(BigDecimal.ZERO);
settlementOwnerDetail.setPrepayFreight(ans); runningWaterRecord.setAccountBalance(account.getAccountBalance());
//生成扣除流水 runningWaterRecord.setOwnerUserNo(account.getOwnerUserNo());
OwnerRunningWaterRecord runningWaterRecord = new OwnerRunningWaterRecord();
runningWaterRecord.setOwnerUserName(orderChild.getOwnerName()); runningWaterRecord.setAccountType(OwnerAccountEnum.AccountTypeStatus.PREPAID_FREIGHT_ACCOUNT.getCode());
runningWaterRecord.setMobile(orderChild.getDriverMobile()); runningWaterRecord.setRunningWaterType(OwnerAccountEnum.RunningWaterStatus.TAKE_OUT.getCode());
runningWaterRecord.setCreateBy("系统"); runningWaterRecord.setRunningWaterNo(idGenerateSnowFlake.nextId(IdTypeEnum.Type.TAKE_OUT.getCode()));
runningWaterRecord.setOrderId(orderChild.getId()); ownerRunningWaterRecordDao.saveEntity(runningWaterRecord);
runningWaterRecord.setOrderNo(orderChild.getOrderNo());
runningWaterRecord.setRelationId(null);
runningWaterRecord.setAlterationBalance(ans);
runningWaterRecord.setFrozenBalance(ans);
runningWaterRecord.setUsableBalance(account.getUsableBalance());
runningWaterRecord.setTakeOutBalance(BigDecimal.ZERO);
runningWaterRecord.setAccountBalance(account.getAccountBalance());
runningWaterRecord.setOwnerUserNo(account.getOwnerUserNo());
runningWaterRecord.setAccountType(OwnerAccountEnum.AccountTypeStatus.PREPAID_FREIGHT_ACCOUNT.getCode());
runningWaterRecord.setRunningWaterType(OwnerAccountEnum.RunningWaterStatus.TAKE_OUT.getCode());
runningWaterRecord.setRunningWaterNo(idGenerateSnowFlake.nextId(IdTypeEnum.Type.TAKE_OUT.getCode()));
ownerRunningWaterRecordDao.saveEntity(runningWaterRecord);
} else {
settlementOwnerDetail.setPrepayFreight(BigDecimal.ZERO);
}
} else { } else {
invoiceType = SettlementOwnerEnum.InvoiceType.ORDINARY.getCode(); settlementOwnerDetail.setPrepayFreight(BigDecimal.ZERO);
} }
} else { } else {
throw new ServiceSystemException(PerformanceResultEnum.ORDER_CHILD_SYNC_ERROR); settlementDriverDetail.setPrepayFreightFlag(0);
invoiceType = SettlementOwnerEnum.InvoiceType.ORDINARY.getCode();
settlementOwnerDetail.setPrepayFreight(BigDecimal.ZERO);
settlementOwnerDetail.setFinalPaymentStatus(SettlementOwnerDetailEnum.FinalPaymentStatus.NO.getCode());
} }
} else {
throw new ServiceSystemException(PerformanceResultEnum.ORDER_CHILD_SYNC_ERROR);
if (SettlementOwnerEnum.InvoiceType.ONLINE.getCode().equals(invoiceType) && settlementOwnerDetail.getPrepayFreight().compareTo(BigDecimal.ZERO) > 0) {
settlementDriverDetail.setPrepayFreightFlag(1);
}
} }
if (SettlementOwnerEnum.InvoiceType.ONLINE.getCode().equals(invoiceType) && settlementOwnerDetail.getPrepayFreight().compareTo(BigDecimal.ZERO) > 0) {
settlementDriverDetail.setPrepayFreightFlag(1);
}
settlementOwnerDetail.setInvoiceType(invoiceType); settlementOwnerDetail.setInvoiceType(invoiceType);
settlementDriverDetail.setInvoiceType(invoiceType); settlementDriverDetail.setInvoiceType(invoiceType);
// 开票金额
settlementOwnerDetail.setInvoiceFreight(invoiceFreightCalc(orderChild.getSettlementWay(),settlementOwnerDetail));
// 结算金额
settlementOwnerDetail.setSettlementFreight(settlementFreightCalc(orderChild.getSettlementWay(),settlementOwnerDetail));
//设置司机预付运费标示
if (settlementOwnerDetail.getPrepayFreight().compareTo(BigDecimal.ZERO) > 0) {
settlementDriverDetail.setPrepayFreightFlag(1);
} else {
settlementDriverDetail.setPrepayFreightFlag(0);
}
// // 网运单更新预付运费 // // 网运单更新预付运费
// if (Objects.equals(settlementOwnerDetail.getInvoiceType(), SettlementOwnerEnum.InvoiceType.ONLINE.getCode())) { // if (Objects.equals(settlementOwnerDetail.getInvoiceType(), SettlementOwnerEnum.InvoiceType.ONLINE.getCode())) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论