mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、校验组织产品有效期增加产品本身有效性校验;2、新增 编辑组织首购记录操作删除时删除关联延期记录和不允许删除已支付的延期记录提示;
This commit is contained in:
+1
@@ -346,6 +346,7 @@ public class ErrorCodeConstants {
|
||||
public static final ErrorCode PRODUCT_PRICE_NULL_ERROR = new ErrorCode(1_002_045_007, "product.price_null_error");
|
||||
public static final ErrorCode ORG_PRODUCT_PURCHASE_NOT_EXIST_ERROR = new ErrorCode(1_002_045_008, "org.product_purchase_not_exist_error");
|
||||
public static final ErrorCode ORG_PRODUCT_PURCHASE_EXIST_ERROR = new ErrorCode(1_002_045_009, "org.product_purchase_exist_error");
|
||||
public static final ErrorCode ORG_PRODUCT_PURCHASE_DELAY_RECORD_PAID_ERROR = new ErrorCode(1_002_045_010, "org.product_purchase_delay_record.paid.error");
|
||||
|
||||
//=========== 广告相关 1-002-046-000 ============
|
||||
public static final ErrorCode ADVERTISEMENT_NO_EXIST = new ErrorCode(1_002_046_001, "advertisement.no_exist");
|
||||
|
||||
+10
-1
@@ -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();
|
||||
// 当前产品购买记录有效期是否超过当前时间
|
||||
|
||||
+8
@@ -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);
|
||||
}
|
||||
|
||||
+7
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
+19
-5
@@ -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
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user