package com.sonic.lion.service.impl;

import com.sonic.lion.dao.PayTradeDao;
import com.sonic.lion.domain.entity.PayCallChannelRecord;
import com.sonic.lion.domain.output.SyncChannelOutput;
import com.sonic.lion.enums.BizType;
import com.sonic.lion.service.ChannelProcessingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 交易处理
 */
@Slf4j
@Component
public class TradeHandler {

    @Autowired
    private PayTradeDao payTradeDao;

    @Autowired
    private ChannelProcessingService channelProcessingService;

    public SyncChannelOutput syncOrder(PayCallChannelRecord record) {
        if (BizType.CHARGE.equals(record.getBizType())) {
            return channelProcessingService.chargeProcessing(record);
        }
        if (BizType.WITHDRAW.equals(record.getBizType())) {
            return channelProcessingService.withdrawProcessing(record);
        }
        return null;
    }

}
