Administrator
2025-04-25 5af707003f4c7b26f09a554a4d3c75c1c6769ab2
src/main/java/com/taoke/autopay/manager/UserCreditExchangeManager.java
@@ -1,10 +1,12 @@
package com.taoke.autopay.manager;
import com.alipay.api.AlipayApiException;
import com.taoke.autopay.dao.credit.CreditExchangeRecordMapper;
import com.taoke.autopay.dao.credit.ExchangeRateMapper;
import com.taoke.autopay.entity.credit.*;
import com.taoke.autopay.exception.UserCreditExchangeException;
import com.taoke.autopay.service.credit.*;
import com.taoke.autopay.utils.AlipayUtil;
import com.taoke.autopay.utils.TimeUtil;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -123,7 +125,13 @@
        // 如果是红包兑换,调用通过兑换逻辑(TODO)
        if (exchangeRecord.getExchangeType() == CreditExchangeRecord.ExchangeType.FUND_EXCHANGE) {
            // TODO: 调用通过兑换逻辑
            try {
                AlipayUtil.transfer("credit_exchange_"+exchangeRecordId, exchangeRecord.getExchangeInfo2(), exchangeRecord.getExchangeInfo1(), exchangeRecord.getExchangeValue(), "红包兑换", "红包兑换");
            } catch (AlipayApiException e) {
                throw new UserCreditExchangeException(UserCreditExchangeException.CODE_ALIPAY_TRANSFER_FAILED, e.getErrCode()+ ":"+ e.getErrMsg());
            } catch (AlipayUtil.AlipayTransferException e) {
                throw new UserCreditExchangeException(UserCreditExchangeException.CODE_ALIPAY_TRANSFER_FAILED, e.getMessage());
            }
        }
        // 改变兑换记录状态