package com.hzya.frame.plugin.lets.util;

import cn.hutool.core.lang.Assert;
import com.hzya.frame.ttxofs.dto.ofspoorder.OfsPoOrderData;
import com.hzya.frame.ttxofs.dto.ofspoorder.OfsPoOrderDetails;
import com.hzya.frame.ttxofs.dto.ofspoorder.OfsPoOrderHeader;
import com.hzya.frame.ttxofs.dto.ofspurchasereturnorder.PurchaseReturnOrder;
import com.hzya.frame.ttxofs.dto.ofspurchasereturnorder.PurchaseReturnOrderDetails;
import com.hzya.frame.ttxofs.dto.ofspurchasereturnorder.PurchaseReturnOrderHeader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author：liuyang
 * @Package：com.hzya.frame.plugin.lets.util
 * @Project：kangarooDataCenterV3
 * @name：OnlyImplementProxyOrderUtil
 * @Date：2024/8/27 13:43
 * @Filename：OnlyImplementProxyOrderUtil
 */
@Component
public class OnlyImplementProxyOrderUtil {

    Logger logger = LoggerFactory.getLogger(OnlyImplementProxyOrderUtil.class);

    /**
     * 判断是代理品牌采购还是委外加工（采购订单）
     *
     * @author liuyang
     */
    public boolean onlyImplementProxyOrder(OfsPoOrderData ofsPoOrderData, String targetName) {
        Assert.state(ofsPoOrderData != null, "ofsPoOrderData不能为空！");
        OfsPoOrderHeader header = ofsPoOrderData.getHeader();
        List<OfsPoOrderDetails> details = ofsPoOrderData.getDetails();

        String purchaseOrderType = header.getPurchaseOrderType();
//        String targetName = "DLCG";
        if (targetName.equals(purchaseOrderType)) {
            return true;
        }
        logger.info("采购订单单号：{} 为：{}不触发代理品牌采购业务流程", header.getCode(), purchaseOrderType);
        return false;
    }

    /**
     * 判断是代理品牌采购还是委外加工（采退订单）
     *
     * @author liuyang
     */
    public boolean onlyImplementProxyOrder(PurchaseReturnOrder purchaseReturnOrder, String targetName) {
        Assert.state(purchaseReturnOrder != null, "ofsPoOrderData不能为空！");
        PurchaseReturnOrderHeader header = purchaseReturnOrder.getHeader();
        List<PurchaseReturnOrderDetails> details = purchaseReturnOrder.getDetails();

        String purchaseOrderType = header.getPurchaseOrderType();
        if (targetName.equals(purchaseOrderType)) {
            return true;
        }
        logger.info("采购订单单号：{} 为：{}不触发代理品牌采购业务流程", header.getCode(), purchaseOrderType);
        return false;
    }
}
