package com.yc.ship.module.trade.service.order.handler;

import com.yc.ship.module.ota.api.OtaDistributorApi;
import com.yc.ship.module.trade.dal.dataobject.order.TradeOrderDO;
import com.yc.ship.module.trade.service.ota.TiktokCalendarService;
import com.yc.ship.module.trade.service.thirdsystem.ThirdGateSystemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Description  ：订单通知
 *
 * @author le'yang
 */
@Component
@Order(TradeOrderHandler.ORDER_NOTIFY)
@Slf4j
public class TradeOrderNotifyHandler implements TradeOrderHandler {

    @Resource
    private TiktokCalendarService tiktokCalendarService;
    @Resource
    private OtaDistributorApi otaDistributorApi;
    @Resource
    private ThirdGateSystemService thirdGateSystemService;

    @Override
    public void afterProcessSuccess(TradeOrderDO tradeOrderDO) {
        try {
            //实名制系统通知,实时推送今天的
//            thirdGateSystemService.pushVisitor(tradeOrderDO.getId());

        }catch (Exception e) {
            log.error("实名制系统推送异常",e);
        }
    }

    @Override
    public void afterProcessFail(TradeOrderDO tradeOrderDO) {

    }

    @Override
    public void afterRefundOrder(Long refundId) {
        try {
            //实名制系统通知,实时推送今天的
            thirdGateSystemService.cancelCertAsync(refundId);
        }catch (Exception e) {
            log.error("实名制系统取消推送异常",e);
        }
    }
}
