package com.ruoyi.web.modules.trading;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import com.ruoyi.web.modules.trading.domain.BizMarketEntry;
import com.ruoyi.web.modules.trading.domain.BizMarketStall;
import com.ruoyi.web.modules.trading.domain.BizSupplier;
import com.ruoyi.web.modules.trading.support.MarketEntryRules;
import com.ruoyi.web.modules.trading.support.MarketStallRules;
import com.ruoyi.web.modules.trading.support.SupplierRules;

/**
 * 市场进栏登记测试样本。
 */
public final class MarketEntryTestSamples
{
    public static final Long STALL_ID_1 = 1L;

    public static final Long SUPPLIER_ID_1 = 1L;

    public static final Long ENTRY_ID = 1001L;

    private MarketEntryTestSamples()
    {
    }

    public static BizMarketStall activeStall()
    {
        BizMarketStall stall = new BizMarketStall();
        stall.setId(STALL_ID_1);
        stall.setStallCode("01");
        stall.setDelFlag(MarketStallRules.DEL_FLAG_NORMAL);
        return stall;
    }

    public static BizSupplier activeSupplier()
    {
        BizSupplier supplier = new BizSupplier();
        supplier.setId(SUPPLIER_ID_1);
        supplier.setSupplierName("扎西合作社");
        supplier.setDelFlag(SupplierRules.DEL_FLAG_NORMAL);
        return supplier;
    }

    public static BizMarketEntry normalSaveRow() throws ParseException
    {
        BizMarketEntry row = new BizMarketEntry();
        row.setEntryTime(parseDateTime("2026-05-20 14:00:00"));
        row.setStallId(STALL_ID_1);
        row.setSupplierId(SUPPLIER_ID_1);
        row.setEarTagList(Collections.singletonList("E103"));
        return row;
    }

    public static BizMarketEntry twoTagSaveRow() throws ParseException
    {
        BizMarketEntry row = new BizMarketEntry();
        row.setEntryTime(parseDateTime("2026-05-20 15:00:00"));
        row.setStallId(STALL_ID_1);
        row.setSupplierId(SUPPLIER_ID_1);
        row.setEarTagList(Arrays.asList("E103", "E104"));
        return row;
    }

    public static BizMarketEntry persistedRow() throws ParseException
    {
        BizMarketEntry row = normalSaveRow();
        row.setId(ENTRY_ID);
        row.setStallCode("01");
        row.setSupplierName("扎西合作社");
        row.setQuantity(1);
        row.setEarTags("E103");
        row.setDelFlag(MarketEntryRules.DEL_FLAG_NORMAL);
        return row;
    }

    public static Date parseDateTime(String text) throws ParseException
    {
        SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        fmt.setLenient(false);
        return fmt.parse(text);
    }

}
