|
@@ -19,6 +19,7 @@ import com.inkasso.factoring.common.entity.ResponseJson;
|
|
|
import com.inkasso.factoring.common.enums.ProjectInitiationStatusEnum;
|
|
|
import com.inkasso.factoring.creditmanagement.entity.Enterprise;
|
|
|
import com.inkasso.factoring.creditmanagement.entity.ProjectInformation;
|
|
|
+import com.inkasso.factoring.creditmanagement.enums.ProjectInitiationStatusDict;
|
|
|
import com.inkasso.factoring.creditmanagement.service.IEnterpriseService;
|
|
|
import com.inkasso.factoring.creditmanagement.service.IProjectInformationService;
|
|
|
import com.inkasso.factoring.dict.entity.Dictionary;
|
|
@@ -181,39 +182,49 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
|
|
|
.eq("c_acceptance_basic_info_id", cAcceptanceBasicInfo.getId()));
|
|
|
if (CollectionUtil.isNotEmpty(goodsInfoList)) {
|
|
|
List<Long> settlementBasicInfoIds = goodsInfoList.stream().map(SettlementGoodsInfo::getSettlementBasicInfoId).distinct().collect(Collectors.toList());
|
|
|
- SettlementBasicInfo settlementBasicInfo = settlementBasicInfoService.getById(settlementBasicInfoIds.get(0));
|
|
|
+
|
|
|
+ SettlementBasicInfo settlementBasicInfo = null;
|
|
|
+ for (Long settlementBasicInfoId : settlementBasicInfoIds) {
|
|
|
+ SettlementBasicInfo info = settlementBasicInfoService.getById(settlementBasicInfoId);
|
|
|
+ if (info != null && ProjectInitiationStatusDict.COMPLETED.getCode().equals(info.getSettlementStatus())) {
|
|
|
+ settlementBasicInfo = info;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (settlementBasicInfo != null) {
|
|
|
vo.setSettlementNumber(settlementBasicInfo.getSettlementNumber());
|
|
|
vo.setSettlementStatus(dictService.getByCode(settlementBasicInfo.getSettlementStatus()).getName());
|
|
|
+
|
|
|
+ List<SettlementGoodsInfo> settlementGoodsInfoList = settlementGoodsInfoService.list(new QueryWrapper<SettlementGoodsInfo>()
|
|
|
+ .eq("acceptance_goods_number", cAcceptanceBasicInfo.getAcceptanceGoodsNumber())
|
|
|
+ .eq("c_settlement_basic_info_id", settlementBasicInfo.getId()));
|
|
|
+ if (CollectionUtil.isNotEmpty(settlementGoodsInfoList)) {
|
|
|
+ List<CAcceptanceGoodsInfo> acceptanceGoodsInfoList = settlementGoodsInfoList.stream().map(settlementGoodsInfo -> {
|
|
|
+ CAcceptanceGoodsInfo cAcceptanceGoodsInfo = acceptanceGoodsInfoService.getById(settlementGoodsInfo.getAcceptanceGoodsInfoId());
|
|
|
+ cAcceptanceGoodsInfo.setSettlementGoodsInfoId(settlementGoodsInfo.getId());
|
|
|
+ cAcceptanceGoodsInfo.setSettlementBasicInfoId(settlementGoodsInfo.getSettlementBasicInfoId());
|
|
|
+ cAcceptanceGoodsInfo.setSalesPrice(settlementGoodsInfo.getSalesPrice());
|
|
|
+ cAcceptanceGoodsInfo.setSalesTotalPrice(settlementGoodsInfo.getSalesTotalPrice());
|
|
|
+ cAcceptanceGoodsInfo.setSalesGuaranteeMoney(settlementGoodsInfo.getSalesGuaranteeMoney());
|
|
|
+ cAcceptanceGoodsInfo.setPurchasePrice(settlementGoodsInfo.getPurchasePrice());
|
|
|
+ cAcceptanceGoodsInfo.setPurchaseTotalPrice(settlementGoodsInfo.getPurchaseTotalPrice());
|
|
|
+ cAcceptanceGoodsInfo.setPurchGuaranteeMoney(settlementGoodsInfo.getPurchaseGuaranteeMoney());
|
|
|
+ cAcceptanceGoodsInfo.setFloatingPrice(settlementGoodsInfo.getFloatingPrice());
|
|
|
+ cAcceptanceGoodsInfo.setReferencePrice(settlementGoodsInfo.getReferencePrice());
|
|
|
+ return cAcceptanceGoodsInfo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ //计算验收数量
|
|
|
+ BigDecimal acceptanceNumTotal = settlementGoodsInfoList.stream().filter(goods -> goods.getGoodsQuantity() != null).map(SettlementGoodsInfo::getGoodsQuantity)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ vo.setAcceptanceNumTotal(acceptanceNumTotal);
|
|
|
+ //计算结算总价
|
|
|
+ BigDecimal settlementAmountTotal = settlementGoodsInfoList.stream().filter(goods -> goods.getSalesTotalPrice() != null).map(SettlementGoodsInfo::getSalesTotalPrice)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ vo.setSettlementAmountTotal(settlementAmountTotal);
|
|
|
+ vo.setAcceptanceGoodInfos(acceptanceGoodsInfoList);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- List<SettlementGoodsInfo> settlementGoodsInfoList = settlementGoodsInfoService.list(new QueryWrapper<SettlementGoodsInfo>()
|
|
|
- .eq("acceptance_goods_number", cAcceptanceBasicInfo.getAcceptanceGoodsNumber()));
|
|
|
- if (CollectionUtil.isNotEmpty(settlementGoodsInfoList)) {
|
|
|
- List<CAcceptanceGoodsInfo> acceptanceGoodsInfoList = settlementGoodsInfoList.stream().map(settlementGoodsInfo -> {
|
|
|
- CAcceptanceGoodsInfo cAcceptanceGoodsInfo = acceptanceGoodsInfoService.getById(settlementGoodsInfo.getAcceptanceGoodsInfoId());
|
|
|
- cAcceptanceGoodsInfo.setSettlementGoodsInfoId(settlementGoodsInfo.getId());
|
|
|
- cAcceptanceGoodsInfo.setSettlementBasicInfoId(settlementGoodsInfo.getSettlementBasicInfoId());
|
|
|
- cAcceptanceGoodsInfo.setSalesPrice(settlementGoodsInfo.getSalesPrice());
|
|
|
- cAcceptanceGoodsInfo.setSalesTotalPrice(settlementGoodsInfo.getSalesTotalPrice());
|
|
|
- cAcceptanceGoodsInfo.setSalesGuaranteeMoney(settlementGoodsInfo.getSalesGuaranteeMoney());
|
|
|
- cAcceptanceGoodsInfo.setPurchasePrice(settlementGoodsInfo.getPurchasePrice());
|
|
|
- cAcceptanceGoodsInfo.setPurchaseTotalPrice(settlementGoodsInfo.getPurchaseTotalPrice());
|
|
|
- cAcceptanceGoodsInfo.setPurchGuaranteeMoney(settlementGoodsInfo.getPurchaseGuaranteeMoney());
|
|
|
- cAcceptanceGoodsInfo.setFloatingPrice(settlementGoodsInfo.getFloatingPrice());
|
|
|
- cAcceptanceGoodsInfo.setReferencePrice(settlementGoodsInfo.getReferencePrice());
|
|
|
- return cAcceptanceGoodsInfo;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- //计算验收数量
|
|
|
- BigDecimal acceptanceNumTotal = settlementGoodsInfoList.stream().filter(goods -> goods.getGoodsQuantity() != null).map(SettlementGoodsInfo::getGoodsQuantity)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- vo.setAcceptanceNumTotal(acceptanceNumTotal);
|
|
|
- //计算结算总价
|
|
|
- BigDecimal settlementAmountTotal = settlementGoodsInfoList.stream().filter(goods -> goods.getSalesTotalPrice() != null).map(SettlementGoodsInfo::getSalesTotalPrice)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- vo.setSettlementAmountTotal(settlementAmountTotal);
|
|
|
- vo.setAcceptanceGoodInfos(acceptanceGoodsInfoList);
|
|
|
- }
|
|
|
} else {
|
|
|
//如果该笔验收单未做过结算
|
|
|
List<CAcceptanceGoodsInfo> goodsInfoList = acceptanceGoodsInfoService
|
|
@@ -519,14 +530,17 @@ public class FinancingApplyServiceImpl implements FinancingApplyService {
|
|
|
* @param businessNumber
|
|
|
*/
|
|
|
private void checkAcceptance(String businessNumber) {
|
|
|
- List<CAcceptanceBasicInfo> acceptanceBasicInfoList = acceptanceBasicInfoService.list(new QueryWrapper<CAcceptanceBasicInfo>().eq("business_number", businessNumber));
|
|
|
+ List<CAcceptanceBasicInfo> acceptanceBasicInfoList = acceptanceBasicInfoService.list(new QueryWrapper<CAcceptanceBasicInfo>()
|
|
|
+ .eq("business_number", businessNumber));
|
|
|
if (CollectionUtil.isNotEmpty(acceptanceBasicInfoList)) {
|
|
|
for (CAcceptanceBasicInfo acceptanceBasicInfo : acceptanceBasicInfoList) {
|
|
|
- if (acceptanceBasicInfo.getSettlement() != null && !acceptanceBasicInfo.getSettlement()) {
|
|
|
- //未结算
|
|
|
- if (acceptanceBasicInfo.getExpectedSettlementDate() != null
|
|
|
- && DateUtil.beginOfDay(new Date()).compareTo(acceptanceBasicInfo.getExpectedSettlementDate()) > 0) {
|
|
|
- throw new BusinessException(CodeUtil.FAIL, "存在到期未结算的验收单,请联系业务经理");
|
|
|
+ if (ProjectInitiationStatusEnum.COMPLETED.getCode().equals(acceptanceBasicInfo.getAcceptanceStatus())) {
|
|
|
+ if (acceptanceBasicInfo.getSettlement() != null && !acceptanceBasicInfo.getSettlement()) {
|
|
|
+ //未结算
|
|
|
+ if (acceptanceBasicInfo.getExpectedSettlementDate() != null
|
|
|
+ && DateUtil.beginOfDay(new Date()).compareTo(acceptanceBasicInfo.getExpectedSettlementDate()) > 0) {
|
|
|
+ throw new BusinessException(CodeUtil.FAIL, "存在到期未结算的验收单,请联系业务经理");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|