FinanceSchedule.java 2.26 KB
package com.glsx.usedcar.task;

import com.github.binarywang.wxpay.bean.transfer.TransferBillsGetResult;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.glsx.usedcar.module.finance.entity.Withdraw;
import com.glsx.usedcar.module.finance.service.WithdrawService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Component
public class FinanceSchedule {

    @Resource
    private WxPayService wxService;
    @Resource
    private WithdrawService withdrawService;

    /**
     * 查询企业付款到零钱的结果
     *
     * @return
     * @throws WxPayException
     */
//    @Scheduled(fixedDelay = 1000 * 10, initialDelay = 1000 * 50)
//    public void queryEntPay() {
//        LocalDateTime now = LocalDateTime.now();
//        List<Withdraw> auditedWithdraws = withdrawService.getAuditedWithdraws(now.minusDays(2));
//        for (Withdraw withdraw : auditedWithdraws) {
//            String outBillNo = withdraw.getWithdrawCode();
//            // 查询企业付款到零钱的结果
//            try {
//                TransferBillsGetResult result = wxService.getTransferService().getBillsByOutBillNo(outBillNo);
//                log.debug("=== 查询转账结果(商户单号)===");
//                log.debug("商户单号: " + result.getOutBillNo());
//                log.debug("微信转账单号: " + result.getTransferBillNo());
//                log.debug("状态: " + result.getState());
//                log.debug("转账金额: " + result.getTransferAmount() + "分");
//                log.debug("用户openid: " + result.getOpenid());
//                log.debug("转账备注: " + result.getTransferRemark());
//                log.debug("查询企业付款到零钱的结果:{}", result);
//                withdrawService.updateWithdrawStatus(result);
//            } catch (Exception e) {
//                // 处理异常
//                e.printStackTrace();
//                log.error("查询企业付款到零钱的结果失败:{}", e.getMessage());
//            }
//        }
//    }
}