package com.jeequan.jeepay.pay.mq;

import com.jeequan.jeepay.components.mq.model.ZftSettOrderMQ;
import com.jeequan.jeepay.pay.service.PayOrderSettService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 接收MQ消息
 * 业务： 直付通结算通知
 * @author xiaoyu
 * @date 2021/7/27 9:23
 */
@Slf4j
@Component
public class ZftSettOrderMQReceiver implements ZftSettOrderMQ.IMQReceiver {

    @Autowired private PayOrderSettService payOrderSettService;

    @Override
    public void receive(ZftSettOrderMQ.MsgPayload payload) {

        try {
            log.info("接收直付通结算通知MQ, msg={}", payload.toString());

            String settRecordId = payload.getSettRecordId();

            // 发起结算
            payOrderSettService.tradeSettleConfirm(settRecordId);

            return;
        }catch (Exception e) {
            log.error(e.getMessage(), e);
            return;
        }
    }
}
