|
@@ -41,6 +41,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
@@ -41,6 +41,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
41
|
|
41
|
|
|
42
|
import javax.annotation.Resource;
|
42
|
import javax.annotation.Resource;
|
|
43
|
import java.io.Serializable;
|
43
|
import java.io.Serializable;
|
|
|
|
44
|
+import java.math.BigDecimal;
|
|
44
|
import java.time.LocalDate;
|
45
|
import java.time.LocalDate;
|
|
45
|
import java.time.LocalDateTime;
|
46
|
import java.time.LocalDateTime;
|
|
46
|
import java.util.ArrayList;
|
47
|
import java.util.ArrayList;
|
|
@@ -558,6 +559,69 @@ public class ContractDistributorStandardServiceImpl extends |
|
@@ -558,6 +559,69 @@ public class ContractDistributorStandardServiceImpl extends |
|
558
|
OpLogUtil.setExtra(vo);
|
559
|
OpLogUtil.setExtra(vo);
|
|
559
|
}
|
560
|
}
|
|
560
|
|
561
|
|
|
|
|
562
|
+ @Override
|
|
|
|
563
|
+ @OpLog(type = OtherOpLogType.class, name = "合同锁规,ID:{}", params = {"#vo.id"})
|
|
|
|
564
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
565
|
+ public void specificationLock(UpdateContractDistributorStandardVo vo) {
|
|
|
|
566
|
+ ContractDistributorStandard data = getBaseMapper().selectById(vo.getId());
|
|
|
|
567
|
+ if (ObjectUtil.isNull(data)) {
|
|
|
|
568
|
+ throw new DefaultClientException("合同不存在!");
|
|
|
|
569
|
+ }
|
|
|
|
570
|
+
|
|
|
|
571
|
+ List<UpdateContractDistributorLineVo> lineVoList = vo.getContractDistributorLineList();
|
|
|
|
572
|
+ if (CollectionUtils.isEmpty(lineVoList)) {
|
|
|
|
573
|
+ throw new DefaultClientException("合同行数据为空!");
|
|
|
|
574
|
+ }
|
|
|
|
575
|
+
|
|
|
|
576
|
+ Wrapper<ContractDistributorStandard> childWrapper = Wrappers.lambdaQuery(ContractDistributorStandard.class)
|
|
|
|
577
|
+ .eq(ContractDistributorStandard::getParentId, vo.getId());
|
|
|
|
578
|
+
|
|
|
|
579
|
+ List<ContractDistributorStandard> childContractList = getBaseMapper().selectList(childWrapper);
|
|
|
|
580
|
+ BigDecimal allChildTotalQuantity = vo.getTotalQuantity().add(CollectionUtils.isEmpty(childContractList) ? new BigDecimal(0) : childContractList.get(0).getTotalQuantity());
|
|
|
|
581
|
+ if (allChildTotalQuantity.compareTo(data.getTotalQuantity()) > 0) {
|
|
|
|
582
|
+ throw new DefaultClientException("锁规总数量大于合同总数量,锁规失败!");
|
|
|
|
583
|
+ }
|
|
|
|
584
|
+
|
|
|
|
585
|
+ // 判断锁规是否完成(锁规两次或锁规数量等于合同数量)
|
|
|
|
586
|
+ boolean checkPriceSpecLocked = CollectionUtils.isNotEmpty(childContractList) || (allChildTotalQuantity.compareTo(data.getTotalQuantity()) == 0);
|
|
|
|
587
|
+
|
|
|
|
588
|
+ data.setId(IdUtil.getUUID());
|
|
|
|
589
|
+ data.setTotalQuantity(vo.getTotalQuantity());
|
|
|
|
590
|
+ data.setTotalAmountCapital(vo.getTotalAmountCapital());
|
|
|
|
591
|
+ data.setTotalAmountExcludingTax(vo.getTotalAmountExcludingTax());
|
|
|
|
592
|
+ data.setTotalAmountIncludingTax(vo.getTotalAmountIncludingTax());
|
|
|
|
593
|
+ data.setStatus("STANDARD");
|
|
|
|
594
|
+ data.setParentId(vo.getId());
|
|
|
|
595
|
+ getBaseMapper().insert(data);
|
|
|
|
596
|
+
|
|
|
|
597
|
+ Wrapper<ContractDistributorLine> lineWrapper = Wrappers.lambdaQuery(ContractDistributorLine.class)
|
|
|
|
598
|
+ .eq(ContractDistributorLine::getContractId, vo.getId())
|
|
|
|
599
|
+ .orderByAsc(ContractDistributorLine::getShowOrder);
|
|
|
|
600
|
+ List<ContractDistributorLine> oldContractDistributorLineList = contractDistributorLineService.list(lineWrapper);
|
|
|
|
601
|
+ Map<String, ContractDistributorLine> contractDistributorLineMap = CollectionUtils.emptyIfNull(oldContractDistributorLineList)
|
|
|
|
602
|
+ .stream().collect(Collectors.toMap(ContractDistributorLine::getId, Function.identity()));
|
|
|
|
603
|
+
|
|
|
|
604
|
+ for (UpdateContractDistributorLineVo lineVo : lineVoList) {
|
|
|
|
605
|
+ ContractDistributorLine contractDistributorLine = contractDistributorLineMap.remove(lineVo.getId());
|
|
|
|
606
|
+ if (contractDistributorLine == null) {
|
|
|
|
607
|
+ throw new DefaultClientException("合同行数据不存在!");
|
|
|
|
608
|
+ }
|
|
|
|
609
|
+
|
|
|
|
610
|
+ contractDistributorLine.setId(IdUtil.getUUID());
|
|
|
|
611
|
+ contractDistributorLine.setContractId(data.getId());
|
|
|
|
612
|
+ contractDistributorLine.setQuantity(lineVo.getQuantity());
|
|
|
|
613
|
+ contractDistributorLine.setUnitPrice(lineVo.getUnitPrice());
|
|
|
|
614
|
+ contractDistributorLine.setAmountExcludingTax(lineVo.getAmountExcludingTax());
|
|
|
|
615
|
+ contractDistributorLine.setTotalAmount(lineVo.getTotalAmount());
|
|
|
|
616
|
+ contractDistributorLineService.getBaseMapper().insert(contractDistributorLine);
|
|
|
|
617
|
+ }
|
|
|
|
618
|
+
|
|
|
|
619
|
+ Wrapper<ContractDistributorStandard> changeLocked = Wrappers.lambdaUpdate(ContractDistributorStandard.class)
|
|
|
|
620
|
+ .set(ContractDistributorStandard::getPriceSpecLocked, checkPriceSpecLocked)
|
|
|
|
621
|
+ .eq(ContractDistributorStandard::getId, vo.getId());
|
|
|
|
622
|
+ getBaseMapper().update(changeLocked);
|
|
|
|
623
|
+ }
|
|
|
|
624
|
+
|
|
561
|
@CacheEvict(value = ContractDistributorStandard.CACHE_NAME, key = "@cacheVariables.tenantId() + #key")
|
625
|
@CacheEvict(value = ContractDistributorStandard.CACHE_NAME, key = "@cacheVariables.tenantId() + #key")
|
|
562
|
@Override
|
626
|
@Override
|
|
563
|
public void cleanCacheByKey(Serializable key) {
|
627
|
public void cleanCacheByKey(Serializable key) {
|