package com.ruoyi.cai.pay;

import com.ruoyi.cai.manager.ConsumerManager;
import com.ruoyi.cai.service.RechargeOrderService;
import com.ruoyi.cai.service.VipOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class PayManager {

    @Autowired
    private VipOrderService vipOrderService;
    @Autowired
    private ConsumerManager consumerManager;

    public void callBack(String orderNo){
        OrderTypeEnum orderTypeEnum = OrderNoUtil.getType(orderNo);
        if(orderTypeEnum == null){
            log.error("订单类型有误！orderNo={}",orderNo);
            return;
        }
        switch (orderTypeEnum){
            case VIP_ORDER_SUB:
                vipOrderService.orderSuccess(orderNo);
                break;
            case RECHARGE_ORDER_SUB:
                consumerManager.rechargeOrderSuccess(orderNo);
                break;
            default:
                break;
        }

    }
}
