mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
新增获取产品购买到期时间接口
This commit is contained in:
+7
@@ -9,6 +9,7 @@ import com.cf.imes.module.system.service.pay.PayOrderService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -54,6 +55,12 @@ public class PayController {
|
||||
return success(payOrderRespDTO);
|
||||
}
|
||||
|
||||
@GetMapping("/product/expireTime")
|
||||
@Operation(summary = "获取产品购买到期时间")
|
||||
public CommonResult<String> getProductPayExpireTime(@Valid PayProductOrderUnifiedReqVO payProductOrderUnifiedReqVO) {
|
||||
return success(payOrderService.getProductPayExpireTime(payProductOrderUnifiedReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/order/{channelCode}/{outTradeNo}")
|
||||
@Operation(summary = "查询支付订单")
|
||||
@Parameter(name = "outTradeNo", description = "支付流水号", required = true, example = "P1O1955")
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.cf.imes.module.system.controller.admin.pay.vo;
|
||||
|
||||
/**
|
||||
* 产品购买请求校验组
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2025/9/24 16:28
|
||||
*/
|
||||
public interface PayProductGroup {
|
||||
}
|
||||
+1
-1
@@ -28,7 +28,7 @@ public class PayProductOrderUnifiedReqVO {
|
||||
|
||||
@Schema(description = "产品支付渠道编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
@PayProductChannelCodeValid
|
||||
@NotNull(message = "产品支付渠道编码不能为空")
|
||||
@NotNull(message = "产品支付渠道编码不能为空", groups = PayProductGroup.class)
|
||||
private Integer productChannelCode;
|
||||
|
||||
@Schema(description = "机构编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
|
||||
+8
@@ -24,6 +24,14 @@ public interface PayOrderService {
|
||||
*/
|
||||
PayOrderRespDTO productPay(PayProductOrderUnifiedReqVO payProductOrderUnifiedReqVO);
|
||||
|
||||
/**
|
||||
* 获取购买产品的到期时间
|
||||
*
|
||||
* @param payProductOrderUnifiedReqVO
|
||||
* @return
|
||||
*/
|
||||
String getProductPayExpireTime(PayProductOrderUnifiedReqVO payProductOrderUnifiedReqVO);
|
||||
|
||||
/**
|
||||
* 账户充值支付
|
||||
*
|
||||
|
||||
+34
@@ -2,6 +2,7 @@ package com.cf.imes.module.system.service.pay;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -86,6 +87,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.ORG_PRODUCT_PURCHASE_LOCK_ERROR;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.ORG_PRODUCT_PURCHASE_WAIT_PAY_ERROR;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.PAY_NOTIFY_PASSBACK_TRADETYPE_NOT_SUPPORT_ERROR;
|
||||
@@ -258,6 +260,38 @@ public class PayOrderServiceImpl implements PayOrderService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProductPayExpireTime(PayProductOrderUnifiedReqVO payProductOrderUnifiedReqVO) {
|
||||
Long organId = payProductOrderUnifiedReqVO.getOrganId();
|
||||
organId = ObjectUtil.isNull(organId) ? SecurityFrameworkUtils.getUserOrganId() : organId;
|
||||
|
||||
// 主动校验一次入参
|
||||
ValidationUtils.validate(validator, payProductOrderUnifiedReqVO);
|
||||
|
||||
// 校验产品和产品明细
|
||||
Long productId = payProductOrderUnifiedReqVO.getProductId();
|
||||
ProductsDO productsDO = productsDetailService.validateProductExist(productId);
|
||||
|
||||
// 解析产品定价明细
|
||||
ProductsDetailDO productsDetailDO = analyzeProductDetail(productId, payProductOrderUnifiedReqVO.getProductDetailsId());
|
||||
|
||||
// 检查机构产品是否有待支付的购买记录
|
||||
List<PurchaseRecordDO> pendingPurchaseList = purchaseService.getOrgProductPendingPurchaseList(organId, productId);
|
||||
if (CollUtil.isNotEmpty(pendingPurchaseList)) {
|
||||
throw new ServiceException(ORG_PRODUCT_PURCHASE_WAIT_PAY_ERROR);
|
||||
}
|
||||
|
||||
// 查询组织产品的首次购买记录
|
||||
PurchaseRecordDO orgInitialPurchaseRecord = purchaseService.getOrgInitialPurchaseRecord(organId, productsDO.getId());
|
||||
|
||||
// 查询组织有效产品购买记录下的延期记录
|
||||
PreviouProductDelayRespVO previouProductDelayRespVO = productDelayService.getActiveRecordsByProductId(productId, organId);
|
||||
|
||||
// 根据购买类型做价格处理
|
||||
PayProductProcessor payProductProcessor = new PayProductProcessor(productsDO, productsDetailDO, orgInitialPurchaseRecord, previouProductDelayRespVO, null, organId, null, null, null);
|
||||
return LocalDateTimeUtil.format(payProductProcessor.getProductPayExpireTime(), FORMAT_YEAR_MONTH_DAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析定价规则,年从数据库取,月就手动拼
|
||||
*
|
||||
|
||||
+9
@@ -171,6 +171,15 @@ public class PayProductProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订购产品的到期时间
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public LocalDate getProductPayExpireTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用现金余额支付
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user