yeg
2026-09-12 d879291f56eb64adffa44f763238ea736b4be99b
talent-card-server/src/main/java/com/talentcard/server/business/payment/huifu/HuifuMiniProgramPaymentGateway.java
@@ -35,11 +35,12 @@
    public Map<String, Object> createMiniProgramPayment(HuifuMiniProgramPaymentCommand command) {
        ensureConfigured();
        ensureCollectingMerchant(command.huifuId());
        initializeSdk();
        V3TradePaymentJspayRequest request = new V3TradePaymentJspayRequest();
        request.setReqDate(REQUEST_DATE.format(LocalDateTime.now()));
        request.setReqSeqId(command.paymentNo());
        request.setHuifuId(properties.getMerchantId().trim());
        request.setHuifuId(command.huifuId().trim());
        request.setGoodsDesc(command.goodsDescription());
        request.setTransAmt(BigDecimal.valueOf(command.amountInCent(), 2).toPlainString());
        request.setTradeType("T_MINIAPP");
@@ -56,7 +57,7 @@
        log.info("Huifu mini-program payment request: {}", logJson(Map.of(
                "req_date", REQUEST_DATE.format(LocalDateTime.now()),
                "req_seq_id", command.paymentNo(),
                "huifu_id", properties.getMerchantId().trim(),
                "huifu_id", command.huifuId().trim(),
                "goods_desc", command.goodsDescription(),
                "trans_amt", BigDecimal.valueOf(command.amountInCent(), 2).toPlainString(),
                "trade_type", "T_MINIAPP",
@@ -82,9 +83,10 @@
    public Map<String, Object> queryMiniProgramPayment(HuifuPaymentQueryCommand command) {
        ensureConfigured();
        ensureCollectingMerchant(command.huifuId());
        initializeSdk();
        V3TradePaymentScanpayQueryRequest request = new V3TradePaymentScanpayQueryRequest();
        request.setHuifuId(properties.getMerchantId().trim());
        request.setHuifuId(command.huifuId().trim());
        request.setOrgReqDate(command.requestDate());
        request.setOrgReqSeqId(command.paymentNo());
        if (!blank(command.providerTransactionNo())) request.setOrgHfSeqId(command.providerTransactionNo());
@@ -106,6 +108,11 @@
        }
    }
    /** A payment must always be collected by the order's own sub-merchant, never by the platform. */
    private void ensureCollectingMerchant(String huifuId) {
        if (blank(huifuId)) throw new BusinessException(ErrorCode.CONFLICT, "订单缺少收款子商户,请重新下单");
    }
    private void initializeSdk() {
        if (initialized) return;
        synchronized (SDK_INIT_LOCK) {