1、校验组织产品有效期增加产品本身有效性校验;2、新增 编辑组织首购记录操作删除时删除关联延期记录和不允许删除已支付的延期记录提示;

This commit is contained in:
gaoqr
2026-05-13 15:18:00 +08:00
parent 18746c6e68
commit 6218789cfc
8 changed files with 48 additions and 9 deletions
@@ -8,8 +8,10 @@ import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.module.system.api.organ.dto.OrganizationDTO;
import com.cf.imes.module.system.controller.admin.funds.delay.vo.PreviouProductDelayRespVO;
import com.cf.imes.module.system.controller.admin.funds.delay.vo.ProductDelayRespVO;
import com.cf.imes.module.system.dal.dataobject.funds.products.ProductsDO;
import com.cf.imes.module.system.dal.dataobject.funds.purchase.PurchaseRecordDO;
import com.cf.imes.module.system.service.funds.delay.ProductDelayService;
import com.cf.imes.module.system.service.funds.products.ProductsService;
import com.cf.imes.module.system.service.organ.OrganService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
@@ -31,6 +33,9 @@ public class OrganApiImpl implements OrganApi {
@Resource
private ProductDelayService productDelayService;
@Resource
private ProductsService productsService;
@Override
public CommonResult<List<Long>> getOrganIdList() {
return success(organService.getOrganIdList());
@@ -57,7 +62,11 @@ public class OrganApiImpl implements OrganApi {
@Override
public CommonResult<Boolean> validOrganProduct(Long organId, Long productId) {
PreviouProductDelayRespVO recordsByProductId = productDelayService.getActiveRecordsByProductId(productId, organId);
// 校验产品有效性
ProductsDO productsDO = productsService.get(productId);
// 查询组织产品下有效的延期记录
PreviouProductDelayRespVO recordsByProductId = productDelayService.getActiveRecordsByProductId(productsDO.getId(), organId);
PurchaseRecordDO previouPurchaseRecord = recordsByProductId.getPreviouPurchaseRecord();
List<ProductDelayRespVO> delayRespVOList = recordsByProductId.getDelayRespVOList();
// 当前产品购买记录有效期是否超过当前时间
@@ -73,4 +73,12 @@ public interface ProductDelayService {
* @param organId
*/
void resetPurchaseDelayRecordsRemark(Long purchaseId, Long organId);
/**
* 批量删除延期记录
*
* @param ids
* @param organId
*/
void deleteProductDelayRecords(List<Long> ids, Long organId);
}
@@ -211,4 +211,11 @@ public class ProductDelayServiceImpl implements ProductDelayService {
.eq(ProductDelayRecordDO::getOrganId, organId)
.set(ProductDelayRecordDO::getRemark, null));
}
@Override
public void deleteProductDelayRecords(List<Long> ids, Long organId) {
productDelayRecordMapper.delete(new LambdaUpdateWrapper<ProductDelayRecordDO>()
.in(ProductDelayRecordDO::getId, ids)
.eq(ProductDelayRecordDO::getOrganId, organId));
}
}
@@ -56,6 +56,7 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.ORG_PRODUCT_PURCHASE_DELAY_RECORD_PAID_ERROR;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.ORG_PRODUCT_PURCHASE_EXIST_ERROR;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.ORG_PRODUCT_PURCHASE_NOT_EXIST_ERROR;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.PRODUCT_PRICE_NULL_ERROR;
@@ -231,8 +232,8 @@ public class PurchaseServiceImpl implements PurchaseService {
.eq(PurchaseRecordDO::getDeleted, false));
// 2、入参整理为新增列表和修改列表
List<OrganCreateProductPurchaseReqVO> createList = productPurchaseReqVOS.stream().filter(purchaseReqVO -> ObjectUtil.isNull(purchaseReqVO.getPurchaseId())).collect(Collectors.toList());
List<OrganCreateProductPurchaseReqVO> updateList = productPurchaseReqVOS.stream().filter(purchaseReqVO -> ObjectUtil.isNotNull(purchaseReqVO.getPurchaseId())).collect(Collectors.toList());
List<OrganCreateProductPurchaseReqVO> createList = productPurchaseReqVOS.stream().filter(purchaseReqVO -> ObjectUtil.isNull(purchaseReqVO.getPurchaseId())).toList();
List<OrganCreateProductPurchaseReqVO> updateList = productPurchaseReqVOS.stream().filter(purchaseReqVO -> ObjectUtil.isNotNull(purchaseReqVO.getPurchaseId())).toList();
// 3、筛选出修改列表和当前记录中有差集的部分提示首购不存在
Set<Long> currPurchaseIds = currOrgProductInitialPurchaseList.stream()
@@ -261,9 +262,9 @@ public class PurchaseServiceImpl implements PurchaseService {
// 5、删选出当前记录和入参列表中purchaseId不重复的,作为删除的部分
Set<Long> inputPurchaseIds = updateList.stream().map(OrganCreateProductPurchaseReqVO::getPurchaseId).collect(Collectors.toSet());
List<Long> deleteIdList = currOrgProductInitialPurchaseList.stream()
.filter(record -> !inputPurchaseIds.contains(record.getId()))
.map(PurchaseRecordDO::getId)
.collect(Collectors.toList());
.filter(id -> !inputPurchaseIds.contains(id))
.toList();
// 6、修改
for (OrganCreateProductPurchaseReqVO purchaseReqVO : updateList) {
@@ -285,8 +286,21 @@ public class PurchaseServiceImpl implements PurchaseService {
// 7、新增
createOrgInitProductPurchaseRecord(organId, createList);
// 8、删除
// 8、删除首购记录关联的延期记录如果有已经支付的不允许删除
for (Long purchaseId : deleteIdList) {
List<ProductDelayRespVO> recordsByPurchaseId = productDelayService.getRecordsByPurchaseId(purchaseId, organId);
if (CollUtil.isNotEmpty(recordsByPurchaseId)) {
Optional<ProductDelayRespVO> anyPaid = recordsByPurchaseId.stream().filter(ProductDelayRespVO::getPaid).findAny();
if (anyPaid.isPresent()) {
throw new ServiceException(ORG_PRODUCT_PURCHASE_DELAY_RECORD_PAID_ERROR);
}
productDelayService.deleteProductDelayRecords(recordsByPurchaseId.stream().map(ProductDelayRespVO::getId).toList(), organId);
}
}
// 9、删除
purchaseRecordMapper.deleteByIds(deleteIdList);
}
@Override
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long