|
@@ -3,15 +3,14 @@ package com.sckw.freight.service.freight.impl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.sckw.freight.entity.freight.KwpLedgerLogistics;
|
|
|
|
|
-import com.sckw.freight.entity.freight.KwpLedgerLogisticsOrder;
|
|
|
|
|
-import com.sckw.freight.entity.freight.KwpLedgerLogisticsTrack;
|
|
|
|
|
-import com.sckw.freight.entity.freight.KwpSettlementLogistics;
|
|
|
|
|
|
|
+import com.sckw.freight.entity.freight.*;
|
|
|
import com.sckw.freight.entity.kll.KllOrder;
|
|
import com.sckw.freight.entity.kll.KllOrder;
|
|
|
import com.sckw.freight.entity.kll.KllOrderTask;
|
|
import com.sckw.freight.entity.kll.KllOrderTask;
|
|
|
import com.sckw.freight.mapper.freight.KwpLedgerLogisticsMapper;
|
|
import com.sckw.freight.mapper.freight.KwpLedgerLogisticsMapper;
|
|
|
import com.sckw.freight.mapper.freight.KwpSettlementLogisticsMapper;
|
|
import com.sckw.freight.mapper.freight.KwpSettlementLogisticsMapper;
|
|
|
|
|
+import com.sckw.freight.mapper.freight.KwpWalletRelationMapper;
|
|
|
import com.sckw.freight.mapper.kll.KllOrderTaskMapper;
|
|
import com.sckw.freight.mapper.kll.KllOrderTaskMapper;
|
|
|
|
|
+import com.sckw.freight.model.dto.PayIndex;
|
|
|
import com.sckw.freight.model.enums.*;
|
|
import com.sckw.freight.model.enums.*;
|
|
|
import com.sckw.freight.model.po.LedgerLogisticsStatistics;
|
|
import com.sckw.freight.model.po.LedgerLogisticsStatistics;
|
|
|
import com.sckw.freight.model.vo.request.RequestLedgerLogisticsPageInfo;
|
|
import com.sckw.freight.model.vo.request.RequestLedgerLogisticsPageInfo;
|
|
@@ -20,15 +19,18 @@ import com.sckw.freight.model.vo.response.ResponseKllOrderTask;
|
|
|
import com.sckw.freight.model.vo.response.ResponseLedgerLogistics;
|
|
import com.sckw.freight.model.vo.response.ResponseLedgerLogistics;
|
|
|
import com.sckw.freight.model.vo.response.ResponseLedgerLogisticsStatistics;
|
|
import com.sckw.freight.model.vo.response.ResponseLedgerLogisticsStatistics;
|
|
|
import com.sckw.freight.model.vo.response.ResponsePageData;
|
|
import com.sckw.freight.model.vo.response.ResponsePageData;
|
|
|
|
|
+import com.sckw.freight.service.PayCenterService;
|
|
|
import com.sckw.freight.service.freight.IKwpLedgerLogisticsOrderService;
|
|
import com.sckw.freight.service.freight.IKwpLedgerLogisticsOrderService;
|
|
|
import com.sckw.freight.service.freight.IKwpLedgerLogisticsService;
|
|
import com.sckw.freight.service.freight.IKwpLedgerLogisticsService;
|
|
|
import com.sckw.freight.service.freight.IKwpLedgerLogisticsTrackService;
|
|
import com.sckw.freight.service.freight.IKwpLedgerLogisticsTrackService;
|
|
|
|
|
+import com.sckw.freight.service.freight.IKwpSettlementLogisticsService;
|
|
|
import com.sckw.freight.service.kll.IKllOrderService;
|
|
import com.sckw.freight.service.kll.IKllOrderService;
|
|
|
import com.sckw.freight.util.DateTimeUtil;
|
|
import com.sckw.freight.util.DateTimeUtil;
|
|
|
import com.sckw.freight.util.R;
|
|
import com.sckw.freight.util.R;
|
|
|
import com.sckw.freight.util.SnowflakeIdUtil;
|
|
import com.sckw.freight.util.SnowflakeIdUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
@@ -60,6 +62,13 @@ public class KwpLedgerLogisticsServiceImpl extends ServiceImpl<KwpLedgerLogistic
|
|
|
KwpLedgerLogisticsMapper kwpLedgerLogisticsMapper;
|
|
KwpLedgerLogisticsMapper kwpLedgerLogisticsMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
KllOrderTaskMapper kllOrderTaskMapper;
|
|
KllOrderTaskMapper kllOrderTaskMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ KwpWalletRelationMapper kwpWalletRelationMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ PayCenterService payCenterService;
|
|
|
|
|
+ @Lazy
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ IKwpSettlementLogisticsService iKwpSettlementLogisticsService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @description: 物流对账统计信息
|
|
* @description: 物流对账统计信息
|
|
@@ -108,11 +117,12 @@ public class KwpLedgerLogisticsServiceImpl extends ServiceImpl<KwpLedgerLogistic
|
|
|
|
|
|
|
|
LambdaQueryWrapper<KwpSettlementLogistics> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<KwpSettlementLogistics> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(KwpSettlementLogistics::getLLedgerId, ledgerLogistics.getId());
|
|
wrapper.eq(KwpSettlementLogistics::getLLedgerId, ledgerLogistics.getId());
|
|
|
- wrapper.eq(KwpSettlementLogistics::getStatus, KwpSettlementLogisticsStatusEnum.FullSettlement.getCode());
|
|
|
|
|
|
|
+ wrapper.eq(KwpSettlementLogistics::getStatus, KwpSettlementLogisticsStatusEnum.Paid.getCode());
|
|
|
List<KwpSettlementLogistics> kwpSettlementLogistics = kwpSettlementLogisticsMapper.selectList(wrapper);
|
|
List<KwpSettlementLogistics> kwpSettlementLogistics = kwpSettlementLogisticsMapper.selectList(wrapper);
|
|
|
if (kwpSettlementLogistics == null) kwpSettlementLogistics = new ArrayList<>();
|
|
if (kwpSettlementLogistics == null) kwpSettlementLogistics = new ArrayList<>();
|
|
|
BigDecimal totalPrice = kwpSettlementLogistics.stream().map(KwpSettlementLogistics::getActualPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
BigDecimal totalPrice = kwpSettlementLogistics.stream().map(KwpSettlementLogistics::getActualPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
newLedgerLogistics.setActualPrice(totalPrice);
|
|
newLedgerLogistics.setActualPrice(totalPrice);
|
|
|
|
|
+ if (totalPrice.compareTo(BigDecimal.ZERO)==0)return;
|
|
|
KwpLedgerLogisticsStatusEnum status = KwpLedgerLogisticsStatusEnum.Unpaid;
|
|
KwpLedgerLogisticsStatusEnum status = KwpLedgerLogisticsStatusEnum.Unpaid;
|
|
|
if (totalPrice.compareTo(ledgerLogistics.getSettlePrice()) < 0) {
|
|
if (totalPrice.compareTo(ledgerLogistics.getSettlePrice()) < 0) {
|
|
|
status = KwpLedgerLogisticsStatusEnum.PartialPaid;
|
|
status = KwpLedgerLogisticsStatusEnum.PartialPaid;
|
|
@@ -448,4 +458,66 @@ public class KwpLedgerLogisticsServiceImpl extends ServiceImpl<KwpLedgerLogistic
|
|
|
boolean isUpdate = iKllOrderService.update(newOrder, new LambdaQueryWrapper<KllOrder>().in(KllOrder::getId, orderList.stream().map(KllOrder::getId).collect(Collectors.toList())));
|
|
boolean isUpdate = iKllOrderService.update(newOrder, new LambdaQueryWrapper<KllOrder>().in(KllOrder::getId, orderList.stream().map(KllOrder::getId).collect(Collectors.toList())));
|
|
|
if (!isUpdate) throw new RuntimeException("更新物流订单状态失败");
|
|
if (!isUpdate) throw new RuntimeException("更新物流订单状态失败");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 申请收款
|
|
|
|
|
+ * 1:检查信息(状态、所属)
|
|
|
|
|
+ * 2:查询收款方、付款方对应的 账户信息
|
|
|
|
|
+ * 3:支付中台的 【在线充值】接口
|
|
|
|
|
+ * 4:保存 付款单信息
|
|
|
|
|
+ * 5:返回前端支付连接
|
|
|
|
|
+ *
|
|
|
|
|
+ * @description: 申请收款
|
|
|
|
|
+ * @author: xj
|
|
|
|
|
+ * @date: 2025/1/14 星期二 10:54
|
|
|
|
|
+ * @param:
|
|
|
|
|
+ * @return: null
|
|
|
|
|
+ **/
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public R<PayIndex> applyPayment(Long ledgerLogisticsId, Long entId) {
|
|
|
|
|
+ if (entId == null) return R.failed("企业id不能为空");
|
|
|
|
|
+ if (ledgerLogisticsId == null) return R.failed("对账单id不能为空");
|
|
|
|
|
+ //查询对账单信息
|
|
|
|
|
+ LambdaQueryWrapper<KwpLedgerLogistics> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.eq(KwpLedgerLogistics::getId, ledgerLogisticsId);
|
|
|
|
|
+ wrapper.eq(KwpLedgerLogistics::getEntId, entId);
|
|
|
|
|
+ KwpLedgerLogistics ledgerLogistics = this.getOne(wrapper);
|
|
|
|
|
+
|
|
|
|
|
+ if (ledgerLogistics == null) {
|
|
|
|
|
+ return R.failed("对账单不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (KwpLedgerLogisticsStatusEnum.Paid.getCode().equals(ledgerLogistics.getStatus())) {
|
|
|
|
|
+ return R.failed("对账单支付");
|
|
|
|
|
+ }
|
|
|
|
|
+ //计算剩余未付金额=实际结算金额-已付金额
|
|
|
|
|
+ BigDecimal money = ledgerLogistics.getSettlePrice().subtract(ledgerLogistics.getActualPrice());
|
|
|
|
|
+ if (money.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
|
|
+ return R.failed("对账单已支付");
|
|
|
|
|
+ }
|
|
|
|
|
+ //查询收款方(卖方) 账户信息
|
|
|
|
|
+ LambdaQueryWrapper<KwpWalletRelation> walletRelationWrapperS = new LambdaQueryWrapper<>();
|
|
|
|
|
+ walletRelationWrapperS.eq(KwpWalletRelation::getEntId, entId);
|
|
|
|
|
+ KwpWalletRelation walletRelationS = kwpWalletRelationMapper.selectOne(walletRelationWrapperS);
|
|
|
|
|
+ if (walletRelationS == null) {
|
|
|
|
|
+ return R.failed("收款方【"+entId+"】账户不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ //查询付款方(买方) 账户信息
|
|
|
|
|
+ LambdaQueryWrapper<KwpWalletRelation> walletRelationWrapperP = new LambdaQueryWrapper<>();
|
|
|
|
|
+ walletRelationWrapperP.eq(KwpWalletRelation::getEntId, ledgerLogistics.getCompanyId());
|
|
|
|
|
+ KwpWalletRelation walletRelationP = kwpWalletRelationMapper.selectOne(walletRelationWrapperP);
|
|
|
|
|
+ if (walletRelationP == null) {
|
|
|
|
|
+ return R.failed("付款方【"+ledgerLogistics.getCompanyId()+"】账户不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ //调用支付中台的【在线充值】接口
|
|
|
|
|
+ R<PayIndex> payIndexR = payCenterService.payIndex(walletRelationP.getUid(), walletRelationS.getUid(), ChannelEnum.XW, money.multiply(BigDecimal.valueOf(100)).longValue());
|
|
|
|
|
+ if (payIndexR == null || !payIndexR.getStatus() || payIndexR.getCode() != 200) {
|
|
|
|
|
+ return R.failed("支付中台的【在线充值】接口失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ PayIndex payIndex = payIndexR.getData();
|
|
|
|
|
+ //保存付款单信息
|
|
|
|
|
+ iKwpSettlementLogisticsService.addSettlementLogistics(ledgerLogisticsId, money, payIndex.getOrderNo(), null, ledgerLogistics.getCreateBy());
|
|
|
|
|
+ // 返回前端支付连接
|
|
|
|
|
+ return R.ok(payIndex);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|